package com.szpg; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import com.szpg.db.dao.impl.PgAcuDaoImpl; import com.szpg.db.data.PgAcu; import com.szpg.plc.message.AppMessageConstants; import com.szpg.plc.message.command.ReadMemoryCommand; import com.szpg.plc.protocol.fins.FINSConstants; import com.szpg.plc.server.ACUClient; import com.szpg.plc.server.ACUClientUtil; import com.szpg.plc.util.ByteUtil; import com.szpg.task.ACUSocketCheckTask; import com.szpg.task.ReadCH4ValueTask; import com.szpg.task.ReadCOStatusTask; import com.szpg.task.ReadCOValueTask; import com.szpg.task.ReadDSStatusTask; import com.szpg.task.ReadFjRtTask; import com.szpg.task.ReadFjStatTask; import com.szpg.task.ReadHSStatusTask; import com.szpg.task.ReadHSValueTask; import com.szpg.task.ReadO2StatusTask; import com.szpg.task.ReadO2ValueTask; import com.szpg.task.ReadWSStatusTask; import com.szpg.task.ReadWSValueTask; import com.szpg.task.ReadYWStatusTask; import com.szpg.task.ReadCH4StatusTask; import com.szpg.util.Configure; public class DSCTest { private static DSCTest dsc = new DSCTest(); public static void main(String[] args) { // PLC设备地址和端口 ACUClient client = new ACUClient("192.168.0.244", 6800); client.setNet("00"); //网络号 client.setNode("F4"); //节点号 client.setUnit("00"); //单元号 // 3将ACU的信息加入到map中 ACUClientUtil.getInstance().addClient(client); // 4新建线程启动client new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); // 测试发送查询甲烷参数命令 // dsc.testSendCH4Command(client); // // 测试发送查询甲烷报警状态命令 // dsc.testSendCH4StatusCommand(client); // 测试发送查询温湿度监测值命令 // dsc.testSendWSCommand(client); // 测试发送查询温湿度报警状态命令 // dsc.testSendWSStatusCommand(client); // // 测试发送查询一氧化碳参数命令 // dsc.testSendCOCommand(client); // // 测试发送查询一氧化碳报警状态命令 // dsc.testSendCOStatusCommand(client); // // 测试发送查询氧气参数命令 // dsc.testSendO2Command(client); // 测试发送查询氧气报警状态命令 // dsc.testSendO2StatusCommand(client); // // // 测试发送查询硫化氢参数命令 // dsc.testSendHSCommand(client); // // 测试发送查询硫化氢报警状态命令 // dsc.testSendHSStatusCommand(client); // 测试发送查询爆管液位报警状态命令 // dsc.testSendYWStatusCommand(client); // 测试发送查询对射报警状态命令 // dsc.testSendDSStatusCommand(client); // 测试发送查询风机运行状态命令 dsc.testSendFjStatCommand(client); // 测试发送风机运行时长命令 dsc.testSendFjRtCommand(client); } /** * 发送查询甲烷监测值命令 * * @param client */ public void testSendCH4Command(ACUClient client) { ReadMemoryCommand ch4 = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4VALUE); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); ch4.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); ch4.setDestinationId(dest); ch4.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ch4.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CH.START")), 2)) + "00"); ch4.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CH.WORDCOUNT"))); ch4.setCountBit(0); //读取监测值时位数量无效 ch4.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CH.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadCH4ValueTask(client, ch4), 10, 300, TimeUnit.SECONDS); // sche.schedule(new ReadCH4ValueTask(client, ch4), 12, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询甲烷报警状态命令 * @param client */ public void testSendCH4StatusCommand(ACUClient client) { ReadMemoryCommand ch4alm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); ch4alm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); ch4alm.setDestinationId(dest); ch4alm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ch4alm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CHALM.START")), 2)) + "00"); ch4alm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CHALM.WORDCOUNT"))); ch4alm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CHALM.BITCOUNT"))); ch4alm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CH.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadCH4StatusTask(client, ch4alm), 15, 300, TimeUnit.SECONDS); // sche.schedule(new ReadCH4StatusTask(client, ch4alm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询温湿度监测值命令 * * @param client */ public void testSendWSCommand(ACUClient client) { ReadMemoryCommand ws = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSVALUE); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); ws.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); ws.setDestinationId(dest); ws.setMemoryArea(FINSConstants.MEMORY_DM_AREA); ws.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WD.START")), 2)) + "00"); ws.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WS.WORDCOUNT"))); ws.setCountBit(0); //读取监测值时位数量无效 ws.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WS.COUNT"))); ws.setOffset(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".SD.OFFSET"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadWSValueTask(client, ws), 20, 300, TimeUnit.SECONDS); // sche.schedule(new ReadWSValueTask(client, ws), 12, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询温湿度报警状态命令 * @param client */ public void testSendWSStatusCommand(ACUClient client) { ReadMemoryCommand wsalm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); wsalm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); wsalm.setDestinationId(dest); wsalm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); wsalm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WSALM.START")), 2)) + "00"); wsalm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WSALM.WORDCOUNT"))); wsalm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WSALM.BITCOUNT"))); wsalm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".WS.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadWSStatusTask(client, wsalm), 25, 300, TimeUnit.SECONDS); // sche.schedule(new ReadWSStatusTask(client, wsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询一氧化碳监测值命令 * * @param client */ public void testSendCOCommand(ACUClient client) { ReadMemoryCommand co = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOVALUE); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); co.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); co.setDestinationId(dest); co.setMemoryArea(FINSConstants.MEMORY_DM_AREA); co.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CO.START")), 2)) + "00"); co.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CO.WORDCOUNT"))); co.setCountBit(0); //读取监测值时位数量无效 co.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CO.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadCOValueTask(client, co), 30, 300, TimeUnit.SECONDS); // sche.schedule(new ReadCOValueTask(client, co), 12, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询一氧化碳报警状态命令 * @param client */ public void testSendCOStatusCommand(ACUClient client) { ReadMemoryCommand coalm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); coalm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); coalm.setDestinationId(dest); coalm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); coalm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".COALM.START")), 2)) + "00"); coalm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".COALM.WORDCOUNT"))); coalm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".COALM.BITCOUNT"))); coalm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".CO.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadCOStatusTask(client, coalm), 35, 300, TimeUnit.SECONDS); // sche.schedule(new ReadCOStatusTask(client, coalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询氧气监测值命令 * * @param client */ public void testSendO2Command(ACUClient client) { ReadMemoryCommand o2 = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2VALUE); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); o2.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); o2.setDestinationId(dest); o2.setMemoryArea(FINSConstants.MEMORY_DM_AREA); o2.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2.START")), 2)) + "00"); o2.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2.WORDCOUNT"))); o2.setCountBit(0); //读取监测值时位数量无效 o2.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadO2ValueTask(client, o2), 40, 300, TimeUnit.SECONDS); // sche.schedule(new ReadO2ValueTask(client, o2), 12, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询一氧化碳报警状态命令 * @param client */ public void testSendO2StatusCommand(ACUClient client) { ReadMemoryCommand o2alm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); o2alm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); o2alm.setDestinationId(dest); o2alm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); o2alm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2ALM.START")), 2)) + "00"); o2alm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2ALM.WORDCOUNT"))); o2alm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2ALM.BITCOUNT"))); o2alm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".O2.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadO2StatusTask(client, o2alm), 45, 300, TimeUnit.SECONDS); // sche.schedule(new ReadO2StatusTask(client, o2alm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询硫化氢监测值命令 * * @param client */ public void testSendHSCommand(ACUClient client) { ReadMemoryCommand hs = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSVALUE); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); hs.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); hs.setDestinationId(dest); hs.setMemoryArea(FINSConstants.MEMORY_DM_AREA); hs.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HS.START")), 2)) + "00"); hs.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HS.WORDCOUNT"))); hs.setCountBit(0); //读取监测值时位数量无效 hs.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HS.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadHSValueTask(client, hs), 50, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSValueTask(client, hs), 12, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询硫化氢报警状态命令 * @param client */ public void testSendHSStatusCommand(ACUClient client) { ReadMemoryCommand hsalm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); hsalm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); hsalm.setDestinationId(dest); hsalm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); hsalm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HSALM.START")), 2)) + "00"); hsalm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HSALM.WORDCOUNT"))); hsalm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HSALM.BITCOUNT"))); hsalm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".HS.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadHSStatusTask(client, hsalm), 55, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSStatusTask(client, hsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询爆管液位报警状态命令 * @param client */ public void testSendYWStatusCommand(ACUClient client) { ReadMemoryCommand ywalm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READYWSTATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); ywalm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); ywalm.setDestinationId(dest); ywalm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); ywalm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".YWALM.START")), 2)) + "00"); ywalm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".YWALM.WORDCOUNT"))); ywalm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".YWALM.BITCOUNT"))); ywalm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".YW.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadYWStatusTask(client, ywalm), 15, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSStatusTask(client, hsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询对射报警状态命令 * @param client */ public void testSendDSStatusCommand(ACUClient client) { ReadMemoryCommand dsalm = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READDSSTATUS); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); dsalm.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); dsalm.setDestinationId(dest); dsalm.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); dsalm.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".DSALM.START")), 2)) + "00"); dsalm.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".DSALM.WORDCOUNT"))); dsalm.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".DSALM.BITCOUNT"))); dsalm.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".DS.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadDSStatusTask(client, dsalm), 20, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSStatusTask(client, hsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询风机运行状态命令 * @param client */ public void testSendFjStatCommand(ACUClient client) { ReadMemoryCommand fjstat = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJSTAT); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); fjstat.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); fjstat.setDestinationId(dest); fjstat.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); fjstat.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJSTAT.START")), 2)) + "00"); fjstat.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJSTAT.WORDCOUNT"))); fjstat.setCountBit(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJSTAT.BITCOUNT"))); fjstat.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJ.COUNT"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadFjStatTask(client, fjstat), 15, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSStatusTask(client, hsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } /** * 发送查询风机运行时长命令 * @param client */ public void testSendFjRtCommand(ACUClient client) { ReadMemoryCommand fjrt = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); String sour = Configure.getProperty("sys", "LOCALHOST.NET") + Configure.getProperty("sys", "LOCALHOST.NODE") + Configure.getProperty("sys", "LOCALHOST.UNIT"); fjrt.setMessageProducerId(sour); PgAcu acu = new PgAcuDaoImpl().findACUById(1); String dest = acu.getAcu_net() + acu.getAcu_node() + acu.getAcu_unit(); fjrt.setDestinationId(dest); fjrt.setMemoryArea(FINSConstants.MEMORY_DM_AREA); fjrt.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJRT.START")), 2)) + "00"); fjrt.setCountWord(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJRT.WORDCOUNT"))); fjrt.setCountBit(0); //读取DM区时位无效 fjrt.setCountSensor(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJ.COUNT"))); fjrt.setOffset(Integer.parseInt(Configure.getProperty("acubl", acu.getAcu_code() + ".FJRT.OFFSET"))); ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); sche.scheduleWithFixedDelay(new ReadFjRtTask(client, fjrt), 20, 300, TimeUnit.SECONDS); // sche.schedule(new ReadHSStatusTask(client, hsalm), 15, TimeUnit.SECONDS); // sche.shutdown(); //执行完任务之后关闭线程 } }