|
|
@ -66,11 +66,12 @@ public class LedScreenDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
|
|
|
|
@Override |
|
|
|
public void execute() throws Exception { |
|
|
|
try { |
|
|
|
if (isInitialized.compareAndSet(false, true)) { |
|
|
|
Bx6GEnv.initial(30000); |
|
|
|
} |
|
|
|
//建立连接
|
|
|
|
if (this.screen == null) { |
|
|
|
if (this.screen == null || !this.screen.isConnected()) { |
|
|
|
String ip = Optional.ofNullable(this.getDevice().getExtraValue().get("ip_address")).map(Object::toString).orElse(null); |
|
|
|
int port = Optional.ofNullable(this.getDevice().getExtraValue().get("ip_port")).map(Object::toString).map(Integer::parseInt).orElse(0); |
|
|
|
if (ip == null || port == 0) { |
|
|
@ -79,7 +80,6 @@ public class LedScreenDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
this.screen = new Bx6GScreenClient(this.getDevice().getDevice_code(), new Bx6E()); |
|
|
|
this.screen.connect(ip, port); |
|
|
|
} |
|
|
|
|
|
|
|
//设置节目
|
|
|
|
DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyle[0]); |
|
|
|
ProgramBxFile pf = new ProgramBxFile(0, this.screen.getProfile()); |
|
|
@ -110,7 +110,6 @@ public class LedScreenDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
this.screen.writeProgram(pf); |
|
|
|
this.modeMsgInfo = sb.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
//设置动态区1报警信息
|
|
|
|
List<String> errorDevices = this.getExtraDeviceCodes("errorDevices"); |
|
|
|
StringBuilder sbMsg = new StringBuilder(); |
|
|
@ -169,7 +168,6 @@ public class LedScreenDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
this.screen.writeDynamic(rule_2, area_2); |
|
|
|
this.errorMsgInfo = sbMsg.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
//设置动态区2任务信息
|
|
|
|
StringBuilder sb2 = new StringBuilder(); |
|
|
|
sb2.append("任务信息: "); |
|
|
@ -224,6 +222,13 @@ public class LedScreenDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
this.taskMsgInfo = sb2.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
if (this.screen != null) { |
|
|
|
this.screen.disconnect(); |
|
|
|
System.out.println(this.getDevice().getDevice_code() + "关闭Screen连接!"); |
|
|
|
Thread.sleep(60000); |
|
|
|
} |
|
|
|
} |
|
|
|
Integer upTime = Optional.ofNullable(this.getDevice().getExtraValue().get("upTime")).map(Object::toString).map(Integer::parseInt).orElse(60); |
|
|
|
Thread.sleep(upTime * 1000); |
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
|
|
|