1、协议命令生成器增量开发,增加实现几个设置与对应的查询命令;
2、修改陈旧bug。
5 文件已复制
5 文件已重命名
4个文件已修改
5个文件已添加
| | |
| | | ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; |
| | | |
| | | index = 0 ; |
| | | byte[] bs = new byte[13] ; |
| | | String[] ipPorts = cvo.ip.split(".") ; |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[0]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[1]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[2]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[3]), index++); |
| | | byte[] bs = new byte[14] ; |
| | | String[] ip = cvo.ip.split("\\.") ; |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[0]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[1]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[2]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[3]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, cvo.port, index); |
| | | index += 2 ; |
| | | GlCreate.createPw(bs, index); |
| | |
| | | ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; |
| | | |
| | | index = 0 ; |
| | | byte[] bs = new byte[13] ; |
| | | String[] ipPorts = cvo.ip.split(".") ; |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[0]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[1]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[2]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, (byte) Integer.parseInt(ipPorts[3]), index++); |
| | | byte[] bs = new byte[14] ; |
| | | String[] ip = cvo.ip.split("\\.") ; |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[0]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[1]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[2]), index++); |
| | | ByteUtilUnsigned.byte2Byte(bs, (byte) Integer.parseInt(ip[3]), index++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, cvo.port, index); |
| | | index += 2 ; |
| | | GlCreate.createPw(bs, index); |
| | |
| | | public static int length(final CharSequence cs) { |
| | | return cs == null ? 0 : cs.length(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String ip = "1.2.3.4"; |
| | | if(internalIp(ip)){ |
| | | System.out.println("å
é¨IP"); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.dy.common.mw.protocol.p206V1.CodeV1; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.pipirrComCreator.ServerProperties; |
| | | import com.dy.pipirrComCreator.p206V1.Cd02; |
| | | import com.dy.pipirrComCreator.p206V1.Cd10; |
| | | import com.dy.pipirrComCreator.p206V1.Cd92; |
| | | import com.dy.pipirrComCreator.p206V1.Cd93; |
| | | import com.dy.pipirrComCreator.p206V1.P206V1Deal; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | public class Command { |
| | |
| | | commands = new String[]{ |
| | | "config æ¥çé
置信æ¯", |
| | | "XY ... åè®®å½ä»¤", |
| | | "XY -h åè®®å½ä»¤å¸®å©", |
| | | "exit éåº", |
| | | }; |
| | | } |
| | |
| | | }else if(command.equals("exit")){ |
| | | exit = true ; |
| | | }else if(isProtocolCom(command)){ |
| | | dealProtocolCom(command, prtWrt); |
| | | if(ServerProperties.protocolName.equals(ProtocolConstantV206V1.protocolName)){ |
| | | P206V1Deal.dealProtocolCom(command, prtWrt); |
| | | }else{ |
| | | out("å½å䏿¯æåè®®" + ServerProperties.protocolName, prtWrt) ; |
| | | } |
| | | }else { |
| | | outNoIdentify(prtWrt); |
| | | } |
| | | return exit ; |
| | | } |
| | | private static boolean isProtocolCom(String command){ |
| | | public static boolean isProtocolCom(String command){ |
| | | if(ServerProperties.protocolName.equals(ProtocolConstantV206V1.protocolName)){ |
| | | String[] coms = command.split(" "); |
| | | for (String com : coms){ |
| | |
| | | } |
| | | return false ; |
| | | } |
| | | private static void dealProtocolCom(String command, PrintWriter prtWrt) throws Exception{ |
| | | String[] coms = command.split(" "); |
| | | List<String> comList = new ArrayList<>(); |
| | | for (String com : coms){ |
| | | if(!com.equals("")){ |
| | | comList.add(com) ; |
| | | } |
| | | } |
| | | String com = comList.get(0) ; |
| | | switch (com) { |
| | | case CodeV1.cd_02: cd02(comList, prtWrt); break; |
| | | case CodeV1.cd_10: cd10(comList, prtWrt); break; |
| | | case CodeV1.cd_92: cd92(comList, prtWrt); break; |
| | | case CodeV1.cd_93: cd93(comList, prtWrt); break; |
| | | default: outNoIdentify(prtWrt); break; |
| | | } |
| | | } |
| | | |
| | | private static void cd02(List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p = comList.get(1); |
| | | if(p.equals("-h")){ |
| | | prtWrt.println("02[Enter](å¿è·³å½ä»¤åºçï¼é¾è·¯ç»´ææ¥åºçï¼)"); |
| | | }else{ |
| | | outNoIdentify(prtWrt) ; |
| | | } |
| | | }else{ |
| | | out(new Cd02().hex(ServerProperties.rtuAddr), prtWrt); |
| | | } |
| | | } |
| | | private static void cd10(List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p1 = comList.get(1); |
| | | if(p1.equals("-h")){ |
| | | prtWrt.println("10 *...*[Enter](设置æ§å¶å¨å°å)"); |
| | | }else{ |
| | | String[] ps = params2Grp(comList) ; |
| | | Cd10 cd = new Cd10() ; |
| | | String msg = cd.checkParams(ps) ; |
| | | if(msg == null){ |
| | | out(new Cd10().hex(ServerProperties.rtuAddr, ps), prtWrt); |
| | | }else{ |
| | | out(msg, prtWrt); |
| | | } |
| | | } |
| | | }else{ |
| | | outNoParams(prtWrt); ; |
| | | } |
| | | } |
| | | private static void cd92(List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p = comList.get(1); |
| | | if(p.equals("-h")){ |
| | | prtWrt.println("92[Enter](å¹³å°è¿ç¨å¼å¯éé¨)"); |
| | | }else{ |
| | | outNoIdentify(prtWrt) ; |
| | | } |
| | | }else{ |
| | | out(new Cd92().hex(ServerProperties.rtuAddr), prtWrt); |
| | | } |
| | | } |
| | | private static void cd93(List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p = comList.get(1); |
| | | if(p.equals("-h")){ |
| | | prtWrt.println("93[Enter](å¹³å°è¿ç¨å
³ééé¨)"); |
| | | }else{ |
| | | outNoIdentify(prtWrt) ; |
| | | } |
| | | }else{ |
| | | out(new Cd93().hex(ServerProperties.rtuAddr), prtWrt); |
| | | } |
| | | } |
| | | |
| | | private static String[] params2Grp(List<String> comList){ |
| | | String[] ps = new String[comList.size()-1] ; |
| | | for(int i = 1; i < comList.size(); i++){ |
| | | ps[i-1] = comList.get(i) ; |
| | | } |
| | | return ps ; |
| | | } |
| | | |
| | | private static void out(String str, PrintWriter prtWrt){ |
| | | public static void out(String str, PrintWriter prtWrt){ |
| | | prtWrt.println(str==null?"":str); |
| | | } |
| | | private static void outHelp(PrintWriter prtWrt){ |
| | |
| | | } |
| | | prtWrt.println(""); |
| | | } |
| | | private static void outConfig(PrintWriter prtWrt){ |
| | | public static void outConfig(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("é¢å
设置"); |
| | | prtWrt.println(" åè®®ï¼" + ServerProperties.protocolName); |
| | |
| | | prtWrt.println(" ICå¡ç¼å·ï¼" + ServerProperties.icCardNo); |
| | | prtWrt.println(""); |
| | | } |
| | | private static void outNoIdentify(PrintWriter prtWrt){ |
| | | public static void outNoIdentify(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("å½ä»¤ä¸å¯è¯å«ï¼"); |
| | | prtWrt.println(""); |
| | | } |
| | | private static void outNoParams(PrintWriter prtWrt){ |
| | | public static void outNoParams(PrintWriter prtWrt){ |
| | | prtWrt.println(""); |
| | | prtWrt.println("请è¾å
¥å½ä»¤åæ°ï¼"); |
| | | prtWrt.println(""); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) { |
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd.java |
| | |
| | | * @Date: 2025/5/7 8:43 |
| | | * @Description |
| | | */ |
| | | public abstract class Cd { |
| | | public abstract class P206V1Cd { |
| | | |
| | | protected static final byte CTRL = (byte)0xB0 ;//æ§å¶å |
| | | |
| | | public abstract String checkParams(String ...params) ; |
| | | public abstract String helpInfo() ; |
| | | public abstract String hex(String rtuAddr, String ...params) throws Exception ; |
| | | public abstract byte[] bs(String rtuAddr, String ...params) throws Exception ; |
| | | |
| | | public byte[] createHead(String rtuAddr, String code, byte ctrl)throws Exception { |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1.lenHead2Code] ; |
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd02 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](å¿è·³å½ä»¤åºçï¼é¾è·¯ç»´ææ¥åºçï¼)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd10.java |
| | |
| | | * @Date: 2025/5/7 9:30 |
| | | * @Description |
| | | */ |
| | | public class Cd10 extends Cd { |
| | | public class P206V1Cd10 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "10" ; |
| | | |
| | |
| | | return "æ§å¶å¨å°ååæ°å¿
é¡»æ¯12使°å" ; |
| | | } |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + " *...*[Enter](设置æ§å¶å¨å°å)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0; |
| | | byte[] bs = new byte[13]; |
New file |
| | |
| | | package com.dy.pipirrComCreator.p206V1; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.IPUtils; |
| | | import com.dy.common.util.NumUtil; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 11:25 |
| | | * @Description |
| | | */ |
| | | public class P206V1Cd21 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "21" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | if(params.length != 2){ |
| | | return "åªæIPå端å£ä¸¤ä¸ªåæ°" ; |
| | | } |
| | | if(!IPUtils.ipValid(params[0])){ |
| | | return "IPå°å䏿£ç¡®" ; |
| | | } |
| | | if(IPUtils.internalIp(params[0])){ |
| | | return "IPå°åå¿
é¡»æ¯å¤ç½IP" ; |
| | | } |
| | | if(!NumUtil.isPlusIntNumber(params[1])){ |
| | | return "端å£å·å¿
é¡»æ¯æ£æ´æ°" ; |
| | | } |
| | | int port = Integer.parseInt(params[1]) ; |
| | | if(port < 1 || port > 65535){ |
| | | return "端å£å·å¿
é¡»å¨1-65535ä¹é´" ; |
| | | } |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + " *...* *...*[Enter](设置æå¡ç«¯IPå端å£)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | | |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0 ; |
| | | byte[] bs = new byte[14] ; |
| | | String[] ip = params[0].split("\\.") ; |
| | | ByteUtilUnsigned.byte2Byte(bs, Byte.parseByte(ip[0]), n++); |
| | | ByteUtilUnsigned.byte2Byte(bs, Byte.parseByte(ip[1]), n++); |
| | | ByteUtilUnsigned.byte2Byte(bs, Byte.parseByte(ip[2]), n++); |
| | | ByteUtilUnsigned.byte2Byte(bs, Byte.parseByte(ip[3]), n++); |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, Short.parseShort(params[1]), n); |
| | | n += 2 ; |
| | | GlCreate.createPw(bs, n); |
| | | n += 2 ; |
| | | GlCreate.createTp(bs, n); |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String[] ps = new String[]{"1.2.3.4", "123"} ; |
| | | new P206V1Cd21().hex("530115059980", ps) ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipirrComCreator.p206V1; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.NumUtil; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 14:42 |
| | | * @Description |
| | | */ |
| | | public class P206V1Cd37 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "37" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | if(params.length != 1){ |
| | | return "åªææµééé卿ä¸ä¸ªåæ°" ; |
| | | } |
| | | if(!NumUtil.isPlusIntNumber(params[0])){ |
| | | return "æµééé卿å¿
é¡»æ¯æ£æ´æ°" ; |
| | | } |
| | | int cycle = Integer.parseInt(params[0]) ; |
| | | if(cycle < 1 || cycle > 32767){ |
| | | return "æµééé卿å¿
é¡»å¨1-32767ä¹é´" ; |
| | | } |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + " *...*[Enter](设置æµééé卿)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | | |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0 ; |
| | | byte[] bs = new byte[10]; |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, Short.parseShort(params[0]), n); |
| | | n += 2; |
| | | GlCreate.createPw(bs, n); |
| | | n += 2; |
| | | GlCreate.createTp(bs, n); |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String[] ps = new String[]{"1.2.3.4", "123"} ; |
| | | new P206V1Cd3C().hex("530115059980", ps) ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipirrComCreator.p206V1; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.IPUtils; |
| | | import com.dy.common.util.NumUtil; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 11:25 |
| | | * @Description |
| | | */ |
| | | public class P206V1Cd3C extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "3C" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | if(params.length != 1){ |
| | | return "åªæèªæ¥å¨æä¸ä¸ªåæ°" ; |
| | | } |
| | | if(!NumUtil.isPlusIntNumber(params[0])){ |
| | | return "èªæ¥å¨æå¿
é¡»æ¯æ£æ´æ°" ; |
| | | } |
| | | int cycle = Integer.parseInt(params[0]) ; |
| | | if(cycle < 1 || cycle > 32767){ |
| | | return "èªæ¥å¨æå¿
é¡»å¨1-32767ä¹é´" ; |
| | | } |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + " *...*[Enter](è®¾ç½®èªæ¥å¨æ)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | | |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0 ; |
| | | byte[] bs = new byte[10]; |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, Short.parseShort(params[0]), n); |
| | | n += 2; |
| | | GlCreate.createPw(bs, n); |
| | | n += 2; |
| | | GlCreate.createTp(bs, n); |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String[] ps = new String[]{"1.2.3.4", "123"} ; |
| | | new P206V1Cd3C().hex("530115059980", ps) ; |
| | | } |
| | | } |
copy from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd50.java
File was copied from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Date: 2025/5/7 14:08 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd50 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | public static final String ComCode = "50" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](æ¥è¯¢æ§å¶å¨å°å)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
copy from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd65.java
File was copied from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Date: 2025/5/7 14:08 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd65 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | public static final String ComCode = "65" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](æ¥è¯¢èªæ¥å¨æ)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
copy from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd66.java
File was copied from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Date: 2025/5/7 14:08 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd66 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | public static final String ComCode = "66" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](æ¥è¯¢æå¡ç«¯IPå端å£)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
copy from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd67.java
File was copied from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Date: 2025/5/7 14:08 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd67 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | public static final String ComCode = "67" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](æ¥è¯¢æ¥è¯¢æµééé卿)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
copy from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd91.java
File was copied from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd02.java |
| | |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 8:42 |
| | | * @Date: 2025/5/7 14:08 |
| | | * @Description |
| | | */ |
| | | public class Cd02 extends Cd { |
| | | public class P206V1Cd91 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "02" ; |
| | | public static final String ComCode = "91" ; |
| | | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](æ¸
空åå²è®°å½)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | |
| | | byte[] bs = new byte[1] ; |
| | | |
| | | bs[0] = (byte)0xF2 ;//æ°æ®åï¼ 1 个åèï¼F0 ç»å½ï¼ F1 éåºç»å½ï¼F2 å¨çº¿ä¿æã |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ |
| | | |
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd92.java |
| | |
| | | * @Date: 2025/5/7 10:36 |
| | | * @Description |
| | | */ |
| | | public class Cd92 extends Cd { |
| | | public class P206V1Cd92 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "92" ; |
| | | |
| | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](å¹³å°è¿ç¨å¼å¯éé¨)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr,params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0 ; |
| | | byte[] bs = new byte[9] ; |
File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/Cd93.java |
| | |
| | | * @Date: 2025/5/7 10:38 |
| | | * @Description |
| | | */ |
| | | public class Cd93 extends Cd { |
| | | public class P206V1Cd93 extends P206V1Cd { |
| | | |
| | | public static final String ComCode = "93" ; |
| | | |
| | |
| | | public String checkParams(String ...params){ |
| | | return null ; |
| | | } |
| | | public String helpInfo() { |
| | | return ComCode + "[Enter](å¹³å°è¿ç¨å
³ééé¨)" ; |
| | | } |
| | | /** |
| | | * æé å¿è·³æ°æ® |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String hex(String rtuAddr) throws Exception { |
| | | byte[] bytes = bs(rtuAddr) ; |
| | | public String hex(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = bs(rtuAddr, params) ; |
| | | String hex = ByteUtil.bytes2Hex(bytes, false) ; |
| | | return hex ; |
| | | } |
| | |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] bs(String rtuAddr) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, Cd.CTRL); |
| | | public byte[] bs(String rtuAddr, String ...params) throws Exception { |
| | | byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); |
| | | |
| | | byte n = 0 ; |
| | | byte[] bs = new byte[9] ; |
New file |
| | |
| | | package com.dy.pipirrComCreator.p206V1; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.CodeV1; |
| | | import com.dy.pipirrComCreator.ServerProperties; |
| | | import com.dy.pipirrComCreator.console.Command; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/7 11:17 |
| | | * @Description |
| | | */ |
| | | public class P206V1Deal { |
| | | |
| | | public static void dealProtocolCom(String command, PrintWriter prtWrt) throws Exception{ |
| | | String[] coms = command.split(" "); |
| | | List<String> comList = new ArrayList<>(); |
| | | for (String com : coms){ |
| | | if(!com.equals("")){ |
| | | comList.add(com) ; |
| | | } |
| | | } |
| | | String com = comList.get(0) ; |
| | | switch (com) { |
| | | case CodeV1.cd_02: cdWithoutParam(new P206V1Cd02(), comList, prtWrt); break; |
| | | case CodeV1.cd_10: cdWithParam(new P206V1Cd10(), comList, prtWrt); break; |
| | | case CodeV1.cd_21: cdWithParam(new P206V1Cd21(), comList, prtWrt); break; |
| | | case CodeV1.cd_37: cdWithParam(new P206V1Cd37(), comList, prtWrt); break; |
| | | case CodeV1.cd_3C: cdWithParam(new P206V1Cd3C(), comList, prtWrt); break; |
| | | case CodeV1.cd_50: cdWithoutParam(new P206V1Cd50(), comList, prtWrt); break; |
| | | case CodeV1.cd_65: cdWithoutParam(new P206V1Cd65(), comList, prtWrt); break; |
| | | case CodeV1.cd_66: cdWithoutParam(new P206V1Cd66(), comList, prtWrt); break; |
| | | case CodeV1.cd_67: cdWithoutParam(new P206V1Cd67(), comList, prtWrt); break; |
| | | case CodeV1.cd_91: cdWithoutParam(new P206V1Cd91(), comList, prtWrt); break; |
| | | case CodeV1.cd_92: cdWithoutParam(new P206V1Cd92(), comList, prtWrt); break; |
| | | case CodeV1.cd_93: cdWithoutParam(new P206V1Cd93(), comList, prtWrt); break; |
| | | default: Command.outNoIdentify(prtWrt); break; |
| | | } |
| | | } |
| | | |
| | | private static void cd02(List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | P206V1Cd cd = new P206V1Cd02() ; |
| | | if(comList.size() > 1){ |
| | | String p = comList.get(1); |
| | | if(p.equals("-h")){ |
| | | prtWrt.println(cd.helpInfo()); |
| | | }else{ |
| | | Command.outNoIdentify(prtWrt) ; |
| | | } |
| | | }else{ |
| | | Command.out(cd.hex(ServerProperties.rtuAddr), prtWrt); |
| | | } |
| | | } |
| | | |
| | | private static void cdWithoutParam(P206V1Cd cd, List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p = comList.get(1); |
| | | if(p.equals("-h")){ |
| | | prtWrt.println(cd.helpInfo()); |
| | | }else{ |
| | | Command.outNoIdentify(prtWrt) ; |
| | | } |
| | | }else{ |
| | | Command.out(cd.hex(ServerProperties.rtuAddr), prtWrt); |
| | | } |
| | | } |
| | | |
| | | private static void cdWithParam(P206V1Cd cd, List<String> comList, PrintWriter prtWrt)throws Exception{ |
| | | if(comList.size() > 1){ |
| | | String p1 = comList.get(1); |
| | | if(p1.equals("-h")){ |
| | | prtWrt.println(cd.helpInfo()); |
| | | }else{ |
| | | String[] ps = params2Grp(comList) ; |
| | | String msg = cd.checkParams(ps) ; |
| | | if(msg == null){ |
| | | Command.out(cd.hex(ServerProperties.rtuAddr, ps), prtWrt); |
| | | }else{ |
| | | Command.out(msg, prtWrt); |
| | | } |
| | | } |
| | | }else{ |
| | | Command.outNoParams(prtWrt); ; |
| | | } |
| | | } |
| | | private static String[] params2Grp(List<String> comList){ |
| | | String[] ps = new String[comList.size()-1] ; |
| | | for(int i = 1; i < comList.size(); i++){ |
| | | ps[i-1] = comList.get(i) ; |
| | | } |
| | | return ps ; |
| | | } |
| | | } |
New file |
| | |
| | | åè®®å½ä»¤çæå¨ï¼çæè¿ç¨å½ä»¤ï¼HEXï¼ä¸²ï¼ä»¥æ¹ä¾¿ä¸åéä¼ å½ä»¤ |