| | |
| | | |
| | | /* |
| | | public static void main(String[] args) { |
| | | System.out.println(CreateRandom.Random(1, 0)); |
| | | System.out.println(CreateRandom.Random(2, 0)); |
| | | System.out.println(CreateRandom.Random(3, 0)); |
| | | System.out.println(CreateRandom.Random(4, 0)); |
| | | System.out.println(CreateRandom.Random(5, 0)); |
| | | System.out.println(CreateRandom.Random(100, 0)); |
| | | System.out.println(CreateRandom.Random(1256, 1234)); |
| | | System.out.println(CreateRandom.random(1, 0)); |
| | | System.out.println(CreateRandom.random(2, 0)); |
| | | System.out.println(CreateRandom.random(3, 0)); |
| | | System.out.println(CreateRandom.random(4, 0)); |
| | | System.out.println(CreateRandom.random(5, 0)); |
| | | System.out.println(CreateRandom.random(100, 0)); |
| | | System.out.println(CreateRandom.random(1256, 1234)); |
| | | System.out.println("======================="); |
| | | System.out.println(create_between(10, 100)); |
| | | } |
| | | */ |
| | | |
| | |
| | | public class PipIrrMwSimulateRtuApplication implements CommandLineRunner { |
| | | |
| | | public static void main(String[] args) { |
| | | if(args != null && args.length > 0){ |
| | | if(args.length == 3){ |
| | | if(args[0] instanceof String){ |
| | | if(args[0] != null && !args[0].trim().equals("")){ |
| | | String rtuAddr = (String)args[0] ;//æ¬æ¨¡æå¨æ¨¡æRTUå°å |
| | | ServerProperties.argRtuAddr = rtuAddr ; |
| | | } |
| | | if(args[1] != null && !args[1].trim().equals("")){ |
| | | Integer oneDie = Integer.parseInt(args[1]) ;//ä¸å
æ»ï¼1æ¯ï¼0å¦ |
| | | ServerProperties.argOneDie = oneDie == 1?true:false ; |
| | | } |
| | | if(args[2] != null && !args[2].trim().equals("")){ |
| | | Integer multiDie = Integer.parseInt(args[2]) ;//å¤å
æ»ï¼1æ¯ï¼0å¦ |
| | | ServerProperties.argMultiDie = multiDie == 1?true:false ; |
| | | } |
| | | if(ServerProperties.argOneDie && ServerProperties.argMultiDie){ |
| | | ServerProperties.argOneDie = false ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | new SpringApplicationBuilder(PipIrrMwSimulateRtuApplication.class) |
| | | .web(WebApplicationType.NONE)//ä¸å¯å¨webæå¡ |
| | | .run(args); |
| | |
| | | |
| | | this.startUnits() ; |
| | | |
| | | if(ServerProperties.argRtuAddr != null && !ServerProperties.argRtuAddr.trim().equals("")){ |
| | | System.out.println("åºç¨é
ç½®RTUå°åï¼" + ServerProperties.rtuAddr) ; |
| | | }else{ |
| | | System.out.println("åºç¨åæ°RTUå°åï¼" + ServerProperties.argRtuAddr) ; |
| | | ServerProperties.rtuAddr = ServerProperties.argRtuAddr ; |
| | | } |
| | | System.out.println("å¯å¨ä¸å
æ»ï¼" + (ServerProperties.argOneDie==null?"å¦":(ServerProperties.argOneDie?"æ¯":"å¦"))) ; |
| | | System.out.println("å¯å¨å¤å
æ»ï¼" + (ServerProperties.argMultiDie==null?"å¦":(ServerProperties.argMultiDie?"æ¯":"å¦"))) ; |
| | | |
| | | String svName ; |
| | | try{ |
| | | svName = this.conf.getSetAttrTxt(this.doc, "config.server", "name", null, false, null) ; |
| | |
| | | public class ServerProperties { |
| | | |
| | | public static String rtuAddr ; |
| | | |
| | | //ç¨åºå¯å¨åæ°ï¼ |
| | | public static String argRtuAddr ; |
| | | public static Boolean argOneDie = false ; |
| | | public static Boolean argMultiDie = false ; |
| | | |
| | | } |
| | |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.CreateRandom; |
| | | import com.dy.simRtu.ServerProperties; |
| | | import com.dy.simRtu.tcpClient.upData.*; |
| | | |
| | | /** |
| | |
| | | * @Description ä¸é´ä»¶çä¸è¡æ°æ® |
| | | */ |
| | | public class DownData { |
| | | |
| | | private static int count9602 = 0; |
| | | |
| | | public void parseData(byte[] bs){ |
| | | if(bs != null && bs.length > 0){ |
| | |
| | | String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex, 1); |
| | | if(cdPre.equals("16")){ |
| | | //å级åè½ç |
| | | UpHeartBeat.upHeartBeat = false ;//ä¸ä¸è¡å¿è·³ |
| | | UpHeartBeat.upHeartBeat = false ;//ç¦æ¢ä¸è¡å¿è·³ |
| | | if(bs.length >= ProtocolConstantV206V1.UG_lenHead2Cmd + 1){ |
| | | String cdSuf = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex + 1, 1); |
| | | String cd = cdPre + cdSuf; |
| | | if(cd.equals("1601")){ |
| | | //å级é
ç½® |
| | | if(ServerProperties.argOneDie){ |
| | | UpHeartBeat.upHeartBeat = true ;//使è½ä¸è¡å¿è·³ |
| | | } |
| | | UpCd9601.upData() ; |
| | | }else if(cd.equals("1602")){ |
| | | //åçº§æ°æ® |
| | | UpCd9602.upData() ; |
| | | count9602 ++ ; |
| | | if(ServerProperties.argMultiDie){ |
| | | if(count9602 > 10){ |
| | | int random = CreateRandom.create_between(10, 100) ; |
| | | if(random > 50){ |
| | | UpHeartBeat.upHeartBeat = true ;//使è½ä¸è¡å¿è·³ |
| | | } |
| | | } |
| | | } |
| | | }else if(cd.equals("1603")){ |
| | | //åçº§æ ¡éª |
| | | UpCd9603.upData() ; |
| | |
| | | --> |
| | | <base rtuAddr="532328000214"></base> |
| | | <!-- --> |
| | | <tcpCl mwServerIp="192.168.40.132" mwServerPort="60000" connectTimeout="3000" /> |
| | | <tcpCl mwServerIp="192.168.40.166" mwServerPort="60000" connectTimeout="3000" /> |
| | | </config> |
New file |
| | |
| | | æ¬æ¨¡åæ¯RTU模æå¨ï¼æ¨¡æRTUå级è¿ç¨ |
| | |
| | | cache.ugOverallState.allOver = true ; |
| | | } |
| | | if(cache.ugOverallState.allOver){ |
| | | cache.ugOverallState.overTotal = 0; |
| | | if(cache.ugRtuStateList != null && cache.ugRtuStateList.size() > 0){ |
| | | for(UpgradeRtu rtu : cache.ugRtuStateList){ |
| | | rtu.isOver = true ; |
| | | cache.ugOverallState.overTotal++; |
| | | } |
| | | } |
| | | } |