|
|
|
@ -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;
|
|
|
|
|