package com.mes.service;
|
|
import com.mes.tools.WebSocketServer;
|
import org.springframework.stereotype.Component;
|
|
import java.util.function.Supplier;
|
|
@Component
|
public class Plchome extends Thread {
|
private int i = 1;
|
private final Supplier<PlcService> plcServiceSupplier;
|
|
public Plchome() {
|
this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(PlcService.class);
|
}
|
|
@Override
|
public void run() {
|
while (!Thread.currentThread().isInterrupted()) {
|
try {
|
i++;
|
Thread.sleep(100);
|
PlcService plcService = plcServiceSupplier.get();
|
plcService.performPlcActions();
|
} catch (InterruptedException e) {
|
Thread.currentThread().interrupt();
|
e.printStackTrace();
|
}
|
}
|
}
|
}
|