告警硬接点装置睡眠时间代码修改

main
liuguijing 6 months ago
parent dfbb28af3d
commit 9232abfa74

@ -1,6 +1,7 @@
package com.xydl.cac.serialport;
import com.fazecast.jSerialComm.SerialPort;
import com.xydl.cac.model.StaticVariable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
@ -80,14 +81,17 @@ public class SerialPortServer {
}
LastWarningTime = l;
port.writeBytes(openbuffer, openbuffer.length);
try {
Thread.sleep(warntime * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
port.writeBytes(stopbuffer, stopbuffer.length);
started = false;
int seconds = 0;
while (StaticVariable.shutdown == 0 && seconds > warntime) {
try {
Thread.sleep(1000);
seconds++;
} catch (Exception ignore) {
port.writeBytes(stopbuffer, stopbuffer.length);
started = false;
}
}
port.writeBytes(stopbuffer, stopbuffer.length);
}
}
started = false;

Loading…
Cancel
Save