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

main
liuguijing 6 months ago
parent dfbb28af3d
commit 9232abfa74

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

Loading…
Cancel
Save