|
@@ -0,0 +1,493 @@
|
|
|
+package com.zcxk.tcpserver.tcp.generator;
|
|
|
+
|
|
|
+import com.zcxk.tcpserver.entity.DataUnit;
|
|
|
+import com.zcxk.tcpserver.entity.Document;
|
|
|
+import com.zcxk.tcpserver.entity.FrameFormat;
|
|
|
+import com.zcxk.tcpserver.util.Accumulator;
|
|
|
+import com.zcxk.tcpserver.util.HexUtil;
|
|
|
+
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.google.common.collect.Lists.newArrayList;
|
|
|
+
|
|
|
+public class ConcentratorDemo {
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+
|
|
|
+ //String request = "683500350068705507DB27008C600000010003BE16";
|
|
|
+ //String request = "683500350068705507DB27008C600000010003BE16";
|
|
|
+ //ProtocolGenerator.analysis(request);
|
|
|
+ //a();
|
|
|
+ //b();
|
|
|
+ //c();
|
|
|
+ //login();
|
|
|
+ //readTime();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Document document1 = new Document();
|
|
|
+ document1.setMeterMac("000123456789");
|
|
|
+ document1.setMeterType("3");
|
|
|
+ document1.setCollector("000000000000");
|
|
|
+
|
|
|
+ Document document2 = new Document();
|
|
|
+ document2.setMeterMac("000123456790");
|
|
|
+ document2.setMeterType("3");
|
|
|
+ document2.setCollector("000000000000");
|
|
|
+
|
|
|
+ issueWaterMeterFiles("",newArrayList(document1,document2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String readTime(){
|
|
|
+ //--功能:读时间;SEQ:6;帧状态:3;AFN:8C;FN:1;集中器编号:075527DB00;时间:2020-03-10 13:26:15;
|
|
|
+ //68 35 00 35 00 68 70 55 07 DB 27 00 8C 66 00 00 01 00 03 C4 16
|
|
|
+ //68 49 00 49 00 68 88 55 07 DB 27 00 8C 66 00 00 01 00 15 26 13 10 43 20 9A 16 0D
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "8C";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit = new DataUnit();
|
|
|
+ dataUnit.setIdentify("00000100");
|
|
|
+ dataUnit.setData("03");
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String readDoc(){
|
|
|
+ //--功能:读档案;SEQ:8;帧状态:3;AFN:8A;FN:1;集中器编号:075527DB00;数量:2;测量点:1;水表电子号:021506003011;采集器编号:000000000004;测量点:2;水表电子号:021708000339;采集器编号:000000000004;
|
|
|
+ //
|
|
|
+ //-> 68 61 00 61 00 68 70 55 07 DB 27 00 8A 68 00 00 01 00 05 00 01 00 02 00 03 00 04 00 05 00 D5 16
|
|
|
+ //68 E9 00 E9 00 68 88 55 07 DB 27 00 8A 68 00 00 01 00 02 00 01 00 11 30 00 06 15 02 00 00 00 10 00 00 00 00 04 00 00 00 00 00 02 00 39 03 00 08 17 02 00 00 00 10 00 00 00 00 04 00 00 00 00 00 C1 16 0D
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "8A";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit = new DataUnit();
|
|
|
+ dataUnit.setIdentify("00000100");
|
|
|
+ dataUnit.setData("050001000200030004000500");
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ //System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String readFreezeData(){
|
|
|
+ //--功能:读冻结数据;SEQ:9;帧状态:3;AFN:8C;FN:57;集中器编号:075527DB00;数量:2;测量点:1;当前累积用量: ;测量点:2;当前累积用量:000003.00;
|
|
|
+ //
|
|
|
+ //-> 68 4D 00 4D 00 68
|
|
|
+ // 70 55 07 DB 27 00 8C 69
|
|
|
+ // 00 00 01 07
|
|
|
+ // 02
|
|
|
+ // 02 00
|
|
|
+ // 01 00
|
|
|
+ // 02 00 D2 16
|
|
|
+ //68 69 00 69 00 68 88 55 07 DB 27 00 8C 69 00 00 01 07 02 00 01 00 EE EE EE EE 02 00 00 03 00 00 A3 16 0D
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "8C";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit = new DataUnit();
|
|
|
+ dataUnit.setIdentify("00000107");
|
|
|
+ dataUnit.setData("02020001000200");
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ //System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String login(){
|
|
|
+ DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
+ String controlDomain = "10";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "00";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit1 = new DataUnit();
|
|
|
+ dataUnit1.setIdentify("00000400");
|
|
|
+ dataUnit1.setData("02");
|
|
|
+ DataUnit dataUnit2 = new DataUnit();
|
|
|
+ dataUnit2.setIdentify("00000100");
|
|
|
+ dataUnit2.setData("00");
|
|
|
+
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit1,dataUnit2));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String heartbeat(){
|
|
|
+ DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
+ String controlDomain = "10";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "00";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit1 = new DataUnit();
|
|
|
+ dataUnit1.setIdentify("00000400");
|
|
|
+ dataUnit1.setData("02");
|
|
|
+ DataUnit dataUnit2 = new DataUnit();
|
|
|
+ dataUnit2.setIdentify("00000400");
|
|
|
+ //dataUnit2.setData("00"+LocalDateTime.now().format(f));
|
|
|
+ dataUnit2.setData("00");
|
|
|
+
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit1,dataUnit2));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //下发水表档案
|
|
|
+ public static String issueWaterMeterFiles(String deviceNo, List<Document> documents){
|
|
|
+ // -2020-03-13 15:19:41,374 [1752] INFO IDCServer - 收到客户端指令<下发水表档案>,目标设备<075510203>:{"command":"8400000100","concentrator":"10203","region":"0755","documents":[{"port":"1","meter_mac":"000123456789","meter_type":"冷水表","collector":"000000000000","channel":"0"},{"port":"2","meter_mac":"000123456790","meter_type":"冷水表","collector":"000000000000","channel":"0"}]}
|
|
|
+ // -2020-03-13 15:19:41,413 [10624] INFO IDCServer - 已向设备<075510203>发送数据包:682901290168705507DB270084710000010002000100896745230100300000100000000000000000000002009067452301003000001000000000000000000000363534333231393837363534333231304416
|
|
|
+ // -2020-03-13 15:19:45,540 [1752] INFO IDCServer - 接收到设备<075510203>的指令<0000000100>:683100310068805507DB27000061000001004016
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "84";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit1 = new DataUnit();
|
|
|
+ dataUnit1.setIdentify("00000100");
|
|
|
+
|
|
|
+ int size = documents.size();
|
|
|
+ StringBuilder data = new StringBuilder("");
|
|
|
+ String sizeStr = HexUtil.hexTransfer(HexUtil.fill(HexUtil.demical2Hex(size),4,'0'));
|
|
|
+ data.append(sizeStr);
|
|
|
+
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ //0100
|
|
|
+ //896745230100
|
|
|
+ //30 测量点性质
|
|
|
+ //00 接线方式
|
|
|
+ //00 电表费率号
|
|
|
+ //10 表类型代码
|
|
|
+ //0000 线路编号
|
|
|
+ //0000 表箱编号
|
|
|
+ //000000000000 采集器编号
|
|
|
+ Document document = documents.get(i);
|
|
|
+ String waterNo = HexUtil.hexTransfer(HexUtil.fill(HexUtil.demical2Hex(i+1),4,'0'));//表序号
|
|
|
+ String meterMac = HexUtil.hexTransfer(document.getMeterMac());//表号
|
|
|
+ String measuringPointProperties = document.getMeasuringPointProperties();//测量点性质 数据格式27
|
|
|
+ String connection = document.getConnection();//接线方式 数据格式28 00 表号12位 01表号14位(最高2位在电表费率号)
|
|
|
+ String meterRateNo = document.getMeterRateNo();;//电表费率号 数据格式29
|
|
|
+ String typeCode = "10";//表类型代码 数据格式30
|
|
|
+ String lineNo = "0000";//线路编号 数据格式31
|
|
|
+ String boxNo = "0000";//表箱编号
|
|
|
+ String collector = HexUtil.hexTransfer(document.getCollector());//采集器编号
|
|
|
+
|
|
|
+ data.append(waterNo);
|
|
|
+ data.append(meterMac);
|
|
|
+ data.append(measuringPointProperties);
|
|
|
+ data.append(connection);
|
|
|
+ data.append(meterRateNo);
|
|
|
+ data.append(typeCode);
|
|
|
+ data.append(lineNo);
|
|
|
+ data.append(boxNo);
|
|
|
+ data.append(collector);
|
|
|
+ }
|
|
|
+ String subjoin = "36353433323139383736353433323130";//默认值
|
|
|
+ data.append(subjoin);
|
|
|
+ //dataUnit1.setData("0200010089674523010030000010000000000000000000000200906745230100300000100000000000000000000036353433323139383736353433323130");
|
|
|
+ System.out.println(data.toString());
|
|
|
+ dataUnit1.setData(data.toString());
|
|
|
+
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit1));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除水表档案
|
|
|
+ public static String delWaterMeterFiles(String deviceNo, List<Integer> meterNos){
|
|
|
+ // -2020-03-13 15:45:11,189 [3288] INFO IDCServer - 收到客户端指令<删除水表档案>,目标设备<075510203>:{"command":"8400008002","concentrator":"10203","region":"0755","ports":["1","2","3"]}
|
|
|
+ // -2020-03-13 15:45:11,274 [1616] INFO IDCServer - 已向设备<075510203>发送数据包:685500550068705507DB27008472000080020003000100020003004F16
|
|
|
+ // -2020-03-13 15:45:11,874 [16320] INFO IDCServer - 接收到设备<075510203>的指令<0000000100>:683100310068805507DB27000062000001004116
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "84";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit1 = new DataUnit();
|
|
|
+ dataUnit1.setIdentify("00800200");
|
|
|
+
|
|
|
+ int size = meterNos.size();
|
|
|
+ StringBuilder data = new StringBuilder("");
|
|
|
+ String sizeStr = HexUtil.hexTransfer(HexUtil.fill(HexUtil.demical2Hex(size),4,'0'));
|
|
|
+ data.append(sizeStr);
|
|
|
+
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ String waterNo = HexUtil.hexTransfer(HexUtil.fill(HexUtil.demical2Hex(i+1),4,'0'));//表序号
|
|
|
+ data.append(waterNo);
|
|
|
+ }
|
|
|
+ System.out.println(data.toString());
|
|
|
+ dataUnit1.setData(data.toString());
|
|
|
+
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit1));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //水表开阀
|
|
|
+ public static String waterMeterOpen(){
|
|
|
+ //2020-03-13 17:01:06,968 [8808] INFO IDCServer - 收到客户端指令<开阀>,目标设备<075510203>:{"command":"8500000100","concentrator":"10203","region":"0755","port":"1","keys":"01111111","valve_state":"1"}
|
|
|
+ //2020-03-13 17:01:07,024 [9720] INFO IDCServer - 已向设备<075510203>发送数据包:688500850068705507DB27008579000001005634120100011111110055393837363534333231300016
|
|
|
+ //2020-03-13 17:04:25,303 [14392] INFO IDCServer - 接收到设备<075510203>的指令<0000000200>:683100310068805507DB2700006B000002004B16
|
|
|
+
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //水表关阀
|
|
|
+ public static String waterMeterClose(){
|
|
|
+ //2020-03-13 17:02:39,886 [5332] INFO IDCServer - 收到客户端指令<关阀>,目标设备<075510203>:{"command":"8500000100","concentrator":"10203","region":"0755","port":"1","keys":"01111111","valve_state":"0"}
|
|
|
+ //2020-03-13 17:02:39,949 [8808] INFO IDCServer - 已向设备<075510203>发送数据包:688500850068705507DB2700857A0000010056341201000111111100AA393837363534333231305616
|
|
|
+ //2020-03-13 17:02:47,774 [8808] INFO IDCServer - 接收到设备<075510203>的指令<0000000200>:683100310068805507DB2700006A000002004A16
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询版本
|
|
|
+ public static String queryVersion(){
|
|
|
+ //2020-03-13 17:00:09,765 [11884] INFO IDCServer - 收到客户端指令<查询集中器版本信息>,目标设备<075510203>:{"command":"8C00000101","concentrator":"10203","region":"0755"}
|
|
|
+ //2020-03-13 17:00:09,867 [8808] INFO IDCServer - 已向设备<075510203>发送数据包:683500350068705507DB27008C780000010103D716
|
|
|
+ //2020-03-13 17:00:10,464 [14392] INFO IDCServer - 接收到设备<075510203>的指令<8C00000101>:687100710068885507DB27008C680000010148583635533138384741313548344742CE16
|
|
|
+ //^^{"status":1,"msg":"success","results":[{"soft_version":"HX-65-S-188","hardware_version":"GA-15-H-4GB"}]}$$
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "8C";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit1 = new DataUnit();
|
|
|
+ dataUnit1.setIdentify("00000101");
|
|
|
+ dataUnit1.setData("03");
|
|
|
+
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit1));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //实时抄表 0107
|
|
|
+ public static String meterReading(){
|
|
|
+ //2020-03-13 16:52:29,926 [5332] INFO IDCServer - 收到客户端指令<实时抄表>,目标设备<075510203>:{"command":"8C00000107","concentrator":"10203","region":"0755","type":"00","ports":["1","2","3"]}
|
|
|
+ //2020-03-13 16:52:30,007 [8808] INFO IDCServer - 已向设备<075510203>发送数据包:685500550068705507DB27008C7100000107000300010002000300DC16
|
|
|
+ //2020-03-13 16:52:48,152 [8808] INFO IDCServer - 接收到设备<075510203>的指令<8C00000107>:686900690068885507DB27008C610000010702000100EEEEEEEE0200EEEEEEEE5016
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //冻结数据 0107
|
|
|
+ public static String freezeData(){
|
|
|
+ //2020-03-13 16:54:08,564 [5332] INFO IDCServer - 收到客户端指令<实时抄表>,目标设备<075510203>:{"command":"8C00000107","concentrator":"10203","region":"0755","type":"02","ports":["1","2","3"]}
|
|
|
+ //2020-03-13 16:54:08,571 [11884] INFO IDCServer - 已向设备<075510203>发送数据包:685500550068705507DB27008C7200000107020300010002000300DF16
|
|
|
+ //2020-03-13 16:54:09,175 [9720] INFO IDCServer - 接收到设备<075510203>的指令<8C00000107>:686900690068885507DB27008C620000010702000100EEEEEEEE0200EEEEEEEE5116
|
|
|
+ String controlDomain = "70";
|
|
|
+ String addressDomain = "5507DB2700";
|
|
|
+ String afn = "8C";
|
|
|
+ String seq = Accumulator.getSeq();
|
|
|
+ DataUnit dataUnit = new DataUnit();
|
|
|
+ dataUnit.setIdentify("00000107");
|
|
|
+ dataUnit.setData("02020001000200");
|
|
|
+
|
|
|
+ FrameFormat frameFormat = new FrameFormat();
|
|
|
+ frameFormat.setControlDomain(controlDomain);
|
|
|
+ frameFormat.setAddressDomain(addressDomain);
|
|
|
+ frameFormat.setAfn(afn);
|
|
|
+ frameFormat.setSeq(seq);
|
|
|
+ frameFormat.setDataUnitList(newArrayList(dataUnit));
|
|
|
+ //计算长度
|
|
|
+ String length = frameFormat.calculatedLength();
|
|
|
+ //System.out.println("length="+length);
|
|
|
+ //计算校验码
|
|
|
+ String cs = frameFormat.checkout();
|
|
|
+ //System.out.println("cs="+cs);
|
|
|
+
|
|
|
+ frameFormat.setLength1(length);
|
|
|
+ frameFormat.setLength2(length);
|
|
|
+ frameFormat.setCs(cs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //获取帧格式字符
|
|
|
+ String frameFormatStr = frameFormat.builFrameFormatStr();
|
|
|
+ //System.out.println(frameFormatStr);
|
|
|
+ return frameFormatStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询水表状态字 0209
|
|
|
+ public static String waterMeterStatus(){
|
|
|
+ //2020-03-13 16:58:48,327 [8808] INFO IDCServer - 收到客户端指令<实时抄表>,目标设备<075510203>:{"command":"8C00000209","concentrator":"10203","region":"0755","type":"00","ports":["1","2","3"]}
|
|
|
+ //2020-03-13 16:58:48,412 [9720] INFO IDCServer - 已向设备<075510203>发送数据包:685500550068705507DB27008C7700000209000300010002000300E516
|
|
|
+ //2020-03-13 16:58:51,689 [8808] INFO IDCServer - 接收到设备<075510203>的指令<0000000200>:683100310068805507DB27000067000002004716
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //实时抄表 0108
|
|
|
+ public static String meterReading2(){
|
|
|
+ //2020-03-13 16:56:38,144 [11884] INFO IDCServer - 接收到设备<075510203>的指令<0000000200>:683100310068805507DB27000064000002004416
|
|
|
+ //2020-03-13 16:57:06,972 [9720] INFO IDCServer - 收到客户端指令<实时抄表>,目标设备<075510203>:{"command":"8C00000108","concentrator":"10203","region":"0755","type":"00","ports":["1","2","3"]}
|
|
|
+ //2020-03-13 16:57:06,977 [5332] INFO IDCServer - 已向设备<075510203>发送数据包:685500550068705507DB27008C7500000108000300010002000300E116
|
|
|
+ //2020-03-13 16:57:07,642 [9720] INFO IDCServer - 接收到设备<075510203>的指令<0000000200>:683100310068805507DB27000065000002004516
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+}
|