diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index f0e6446..39eab90 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -95,6 +95,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index f0e6446..39eab90 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -95,6 +95,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); diff --git a/src/com/szpg/rmi/RemoteWSCommandAction.java b/src/com/szpg/rmi/RemoteWSCommandAction.java index dc76245..af8c683 100644 --- a/src/com/szpg/rmi/RemoteWSCommandAction.java +++ b/src/com/szpg/rmi/RemoteWSCommandAction.java @@ -132,6 +132,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -237,6 +238,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字操作 @@ -355,6 +357,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); // 按字操作 diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index f0e6446..39eab90 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -95,6 +95,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); diff --git a/src/com/szpg/rmi/RemoteWSCommandAction.java b/src/com/szpg/rmi/RemoteWSCommandAction.java index dc76245..af8c683 100644 --- a/src/com/szpg/rmi/RemoteWSCommandAction.java +++ b/src/com/szpg/rmi/RemoteWSCommandAction.java @@ -132,6 +132,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -237,6 +238,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字操作 @@ -355,6 +357,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); // 按字操作 diff --git a/src/com/szpg/rmi/RemoteZMCommandAction.java b/src/com/szpg/rmi/RemoteZMCommandAction.java index 6c12fcc..c7f3c61 100644 --- a/src/com/szpg/rmi/RemoteZMCommandAction.java +++ b/src/com/szpg/rmi/RemoteZMCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,8 +188,9 @@ // 2 发送设置启动位的命令 // 构建打开照明指令 SetZmOnBitCommand setOnCmd = LightCommandService.buildTurnOnCommand(sour, dest, zcbh); - if (null != setOnCmd) { + setOnCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOnCmd); @@ -285,6 +287,8 @@ // 2 发送设置停止位的命令 SetZmOffBitCommand setOffCmd = LightCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { + setOffCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOffCmd); diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index f0e6446..39eab90 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -95,6 +95,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); diff --git a/src/com/szpg/rmi/RemoteWSCommandAction.java b/src/com/szpg/rmi/RemoteWSCommandAction.java index dc76245..af8c683 100644 --- a/src/com/szpg/rmi/RemoteWSCommandAction.java +++ b/src/com/szpg/rmi/RemoteWSCommandAction.java @@ -132,6 +132,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -237,6 +238,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字操作 @@ -355,6 +357,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); // 按字操作 diff --git a/src/com/szpg/rmi/RemoteZMCommandAction.java b/src/com/szpg/rmi/RemoteZMCommandAction.java index 6c12fcc..c7f3c61 100644 --- a/src/com/szpg/rmi/RemoteZMCommandAction.java +++ b/src/com/szpg/rmi/RemoteZMCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,8 +188,9 @@ // 2 发送设置启动位的命令 // 构建打开照明指令 SetZmOnBitCommand setOnCmd = LightCommandService.buildTurnOnCommand(sour, dest, zcbh); - if (null != setOnCmd) { + setOnCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOnCmd); @@ -285,6 +287,8 @@ // 2 发送设置停止位的命令 SetZmOffBitCommand setOffCmd = LightCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { + setOffCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOffCmd); diff --git a/src/com/szpg/service/ReadControllerStatusService.java b/src/com/szpg/service/ReadControllerStatusService.java index 2f022a4..e72b2e6 100644 --- a/src/com/szpg/service/ReadControllerStatusService.java +++ b/src/com/szpg/service/ReadControllerStatusService.java @@ -37,7 +37,7 @@ ACUClientUtil.getInstance().sendACUCommand(client, content); // 1查找数据库中的ACU对象 - PgAcu acu = acuDao.findACUByDest(command.getDestinationId()); + PgAcu acu = acuDao.findACUByHost(command.getMessageProducerHost()); if (null == acu) { return; } @@ -50,45 +50,6 @@ // 3将命令保存入数据库 cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - - // 7如果没有报警值则退出 - - // 8如果有报警值则推送报警信息 - - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } } } diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f3dfd77..387a0db 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -2039,6 +2039,15 @@ #\u6E29\u6E7F\u5EA6\u76D1\u6D4B\u503C\u6240\u5360\u5B57\u6570 THXC.ACU301.HSCH4.WORDCOUNT = 8 +#\u98CE\u673A\u6570\u91CF +THXC.ACU301.FJ.COUNT = 3 +#\u98CE\u673A\u7F16\u7801\u5217\u8868 +THXC.ACU301.FJ.ZC.LIST = THXC.ACU301.F.ZFJ01;THXC.ACU301.F.ZFJ02;THXC.ACU301.F.DFJ01 +#\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 +THXC.ACU301.FJSTAT.START = 1050 +#\u98CE\u673A\u72B6\u6001\u6240\u5360\u5B57\u6570 +THXC.ACU301.FJSTAT.WORDCOUNT = 3 + diff --git a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java index 112be5c..fb1c0c9 100644 --- a/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadFjStatCommandResponse.java @@ -83,7 +83,7 @@ // fjDao.addStatRecord(fjRun.get(i), fjFlt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); fjDao.updateDeviceStatus(deviceId, fjRun.get(i)); - if (fjFlt.get(i) == true) { + if (null != fjFlt.get(i) && fjFlt.get(i) == true) { PgAlarm alarm = new PgAlarm(); alarm.setActive(1); alarm.setAlarm_date(this.getTime().getTime()); @@ -150,6 +150,8 @@ // 解析风机运行状态 PgHjsbbl runBlObj = blDao.findBlByBh(zcbh + ".Run"); if (null == runBlObj) { + getFjRun().add(null); + getFjFlt().add(null); continue; } @@ -158,10 +160,12 @@ int rbit = runBlObj.getSzw(); //所在位 char runBt = dataStr.charAt(dataStr.length() - 1 - roffset * 16 - rbit); // 风机运行状态标志位 + getFjRun().add(runBt == '1' ? true : false); // 解析风机故障报警状态 PgHjsbbl fltBlObj = blDao.findBlByBh(zcbh + ".Flt"); if (null == fltBlObj) { + getFjFlt().add(null); continue; } @@ -170,9 +174,8 @@ int fbit = fltBlObj.getSzw(); //所在位 char fltBt = dataStr.charAt(dataStr.length() - 1 - foffset * 16 - fbit); // 风机故障报警标志位 - getFjFlt().add(fltBt == '1' ? true : false); - getFjRun().add(runBt == '1' ? true : false); + } logger.info("解析[读取风机状态]响应指令结束"); diff --git a/src/com/szpg/rmi/RemoteCH4CommandAction.java b/src/com/szpg/rmi/RemoteCH4CommandAction.java index b3d2368..740ef64 100644 --- a/src/com/szpg/rmi/RemoteCH4CommandAction.java +++ b/src/com/szpg/rmi/RemoteCH4CommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetCH4ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteCOCommandAction.java b/src/com/szpg/rmi/RemoteCOCommandAction.java index dde2ac3..42a1618 100644 --- a/src/com/szpg/rmi/RemoteCOCommandAction.java +++ b/src/com/szpg/rmi/RemoteCOCommandAction.java @@ -116,6 +116,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -200,6 +201,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d1ec179..d48bae7 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -188,6 +189,7 @@ if (null != rstBlObj) { rstCmd.setMessageProducerId(sour); rstCmd.setDestinationId(dest); + rstCmd.setMessageProducerHost(client.getHost()); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteFJCommandAction.java b/src/com/szpg/rmi/RemoteFJCommandAction.java index 81510c8..8114c3a 100644 --- a/src/com/szpg/rmi/RemoteFJCommandAction.java +++ b/src/com/szpg/rmi/RemoteFJCommandAction.java @@ -1,5 +1,6 @@ package com.szpg.rmi; +import com.szpg.service.RemoteDeviceControlService; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +26,9 @@ import z.json.JSONObject; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + public class RemoteFJCommandAction extends ActionSupport { /** @@ -101,16 +105,33 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字读取内容 + // 二期风机状态所在内存区域为D区 + if (client.getFlag().equals("23") || client.getFlag().equals("24")) { + command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); + } try { + // 没有找到对应的配置项,直接返回 + String start = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START"); + String countWord = Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"); + if (null == start || start.equals("")) { + jResult.put("success", false); + jResult.put("code", "4"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到对应的变量配置项")); + + returnToFront(jResult); + return null; + } + // 设置读取的地址范围 // 从配置文件读取而来 - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJSTAT.WORDCOUNT"))); + command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(start), 2)) + "00"); + command.setCountWord(Integer.parseInt(countWord)); // 调用服务过程执行命令发送服务 ReadControllerStatusService service = new ReadControllerStatusService(); @@ -186,11 +207,11 @@ // 构建打开风机指令 SetFjOnBitCommand setOnCmd = ExhaustFanCommandService.buildTurnOnCommand(sour, dest, zcbh); if (null != setOnCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOnCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOnCmd); + Logger.getLogger(this.getClass().getName()).info(setOnCmd); } else { jResult.put("success", false); @@ -211,11 +232,8 @@ } // 5秒后查询一次风机的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -282,11 +300,11 @@ // 2 发送设置停止位的命令 SetFjOffBitCommand setOffCmd = ExhaustFanCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); + setOffCmd.setMessageProducerHost(client.getHost()); + + RemoteDeviceControlService service = new RemoteDeviceControlService(); + service.executeService(client, setOffCmd); + Logger.getLogger(this.getClass().getName()).info(setOffCmd); } else { jResult.put("success", false); @@ -306,12 +324,9 @@ Logger.getLogger(this.getClass().getName()).info("[关闭风机置1位复位]"); } - // 5秒后查询一次照明的状态 - Thread.sleep(5 * 1000); - // 调用远程接口查询风机状态 - String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); - HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); - + // 5秒后查询一次风机的状态 + new ScheduledThreadPoolExecutor(1).schedule(new ReadFjStatusTask(zcbh), 5, TimeUnit.SECONDS); + // 返回成功给界面 jResult.put("success", true); jResult.put("code", "0"); @@ -342,4 +357,23 @@ ServletActionContext.getResponse().getWriter().write(jResult.toString()); } + + /** + * 执行风机操作之后的查询风机状态单次任务 + */ + class ReadFjStatusTask implements Runnable { + + private String zcbh; + + public ReadFjStatusTask(String zcbh) { + this.zcbh = zcbh; + } + + @Override + public void run() { + // 调用远程接口查询风机状态 + String baseURL = Configure.getProperty("sys", "PGDSC_API_URL"); + HttpRequest.sendGet(baseURL + "remote/readFjStatus.action", "zcbh=" + zcbh); + } + } } diff --git a/src/com/szpg/rmi/RemoteHSCommandAction.java b/src/com/szpg/rmi/RemoteHSCommandAction.java index 9e131d7..de12ce3 100644 --- a/src/com/szpg/rmi/RemoteHSCommandAction.java +++ b/src/com/szpg/rmi/RemoteHSCommandAction.java @@ -121,6 +121,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -226,6 +227,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ((SetHSThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 69a8d3f..b39059b 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -102,6 +102,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,6 +188,7 @@ PgHjsbbl unlockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != unlockBlObj) { setUnlockCmd.setMessageProducerId(sour); + setUnlockCmd.setMessageProducerHost(client.getHost()); setUnlockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 @@ -296,6 +298,7 @@ PgHjsbbl lockBlObj = blDao.findBlByBh(zcbh + ".Lock"); if (null != lockBlObj) { setLockCmd.setMessageProducerId(sour); + setLockCmd.setMessageProducerHost(client.getHost()); setLockCmd.setDestinationId(dest); // SID在new对象的时候已经生成 diff --git a/src/com/szpg/rmi/RemoteO2CommandAction.java b/src/com/szpg/rmi/RemoteO2CommandAction.java index 08ef47b..7793359 100644 --- a/src/com/szpg/rmi/RemoteO2CommandAction.java +++ b/src/com/szpg/rmi/RemoteO2CommandAction.java @@ -119,6 +119,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -224,6 +225,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ((SetO2ThresholdWordCommand) command).setThreshold(Float.parseFloat(threshold)); diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index f0e6446..39eab90 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -95,6 +95,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); diff --git a/src/com/szpg/rmi/RemoteWSCommandAction.java b/src/com/szpg/rmi/RemoteWSCommandAction.java index dc76245..af8c683 100644 --- a/src/com/szpg/rmi/RemoteWSCommandAction.java +++ b/src/com/szpg/rmi/RemoteWSCommandAction.java @@ -132,6 +132,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); @@ -237,6 +238,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); //按字操作 @@ -355,6 +357,7 @@ // SID在new对象的时候已经生成 command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); command.setDestinationId(dest); command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); // 按字操作 diff --git a/src/com/szpg/rmi/RemoteZMCommandAction.java b/src/com/szpg/rmi/RemoteZMCommandAction.java index 6c12fcc..c7f3c61 100644 --- a/src/com/szpg/rmi/RemoteZMCommandAction.java +++ b/src/com/szpg/rmi/RemoteZMCommandAction.java @@ -101,6 +101,7 @@ Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); String dest = client.getNet() + client.getNode() + client.getUnit(); command.setDestinationId(dest); @@ -187,8 +188,9 @@ // 2 发送设置启动位的命令 // 构建打开照明指令 SetZmOnBitCommand setOnCmd = LightCommandService.buildTurnOnCommand(sour, dest, zcbh); - if (null != setOnCmd) { + setOnCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOnCmd); @@ -285,6 +287,8 @@ // 2 发送设置停止位的命令 SetZmOffBitCommand setOffCmd = LightCommandService.buildTurnOffCommand(sour, dest, zcbh); if (null != setOffCmd) { + setOffCmd.setMessageProducerHost(client.getHost()); + // 解析命令对象为字节数组 byte[] content = finspi.messageToBytes(setOffCmd); diff --git a/src/com/szpg/service/ReadControllerStatusService.java b/src/com/szpg/service/ReadControllerStatusService.java index 2f022a4..e72b2e6 100644 --- a/src/com/szpg/service/ReadControllerStatusService.java +++ b/src/com/szpg/service/ReadControllerStatusService.java @@ -37,7 +37,7 @@ ACUClientUtil.getInstance().sendACUCommand(client, content); // 1查找数据库中的ACU对象 - PgAcu acu = acuDao.findACUByDest(command.getDestinationId()); + PgAcu acu = acuDao.findACUByHost(command.getMessageProducerHost()); if (null == acu) { return; } @@ -50,45 +50,6 @@ // 3将命令保存入数据库 cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - - // 7如果没有报警值则退出 - - // 8如果有报警值则推送报警信息 - - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } } } diff --git a/src/com/szpg/service/RemoteDeviceControlService.java b/src/com/szpg/service/RemoteDeviceControlService.java new file mode 100644 index 0000000..43fc53f --- /dev/null +++ b/src/com/szpg/service/RemoteDeviceControlService.java @@ -0,0 +1,53 @@ +package com.szpg.service; + +import com.szpg.db.dao.PgAcuCmdDao; +import com.szpg.db.dao.PgAcuDao; +import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; +import com.szpg.db.dao.impl.PgAcuDaoImpl; +import com.szpg.db.data.PgAcu; +import com.szpg.db.data.PgAcuCmd; +import com.szpg.plc.message.command.WriteMemoryCommand; +import com.szpg.plc.protocol.DTProtocolInterface; +import com.szpg.plc.protocol.ProtocolFactory; +import com.szpg.plc.server.ACUClient; +import com.szpg.plc.server.ACUClientUtil; +import org.apache.log4j.Logger; + +/** + * 远程控制设备 + * + * @author admin + * + */ +public class RemoteDeviceControlService { + + private final Logger logger = Logger.getLogger(this.getClass().getName()); + + private PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); + private PgAcuDao acuDao = new PgAcuDaoImpl(); + + public void executeService(ACUClient client, WriteMemoryCommand command) { + // 解析命令对象为字节数组 + DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); + byte[] content = finspi.messageToBytes(command); + + // 通过socket接口发送出去 + ACUClientUtil.getInstance().sendACUCommand(client, content); + + // 1查找数据库中的ACU对象 + PgAcu acu = acuDao.findACUByHost(command.getMessageProducerHost()); + if (null == acu) { + return; + } + + // 2生成命令对象 + PgAcuCmd cmd = new PgAcuCmd(); + cmd.setCmd_type(command.getCommandType()); + cmd.setDest_acu_code(acu.getAcu_code()); + cmd.setTm(command.getTime().getTime()); + + // 3将命令保存入数据库 + cmdDao.addCmdRecord(cmd); + } + +}