1、几个测试模块系统的log4j.xml配置中的编码修改;
2、RTU升级模拟器增加命令行设置服务端IP和端口功能;
3、应王江海要求,井电双控协议中也实现远程升级功能,因井电双控协议、阀控器协议不同,而双方协议中的升级子协议相同,所以通信中间件做增量开发、适应性修改,以适应这种混合协议情况,同时也提高通信中间件运行效率。
| | |
| | | * org.apache.mina.core.buffer.IoBuffer, |
| | | * org.apache.mina.filter.codec.ProtocolDecoderOutput) |
| | | */ |
| | | @Override |
| | | protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) { |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr) ; |
| | | if(rtuAddr == null){ |
| | | //ä¼è¯æªè¢«ç®¡ç |
| | | //ä¼è¯ç®¡çå¨ä¸ä¸å卿¤ä¼è¯ï¼è¯´æå建ç«ç½ç»è¿æ¥ï¼ |
| | |
| | | //æä¸äºåè®®ï¼è´è´£åä¸çº¿æ°æ®ï¼ä½ä¸çº¿(æå¿è·³)æ°æ®ä¸æ Rtuå°åï¼æä»¥è¿æ ·çæ°æ®åªè½æ¾è¡ï¼èä¸ä¸è½äº§çæèº«ä»½(Rtuå°å)çç½ç»ä¼è¯ï¼å³ä¸è½æsessionæ¾å
¥ä¼è¯ç¼åä¸ |
| | | //æä¸äºåè®®ï¼Rtuè´è´£åä¸çº¿æ°æ®ï¼ä¸çº¿æ°æ®ä¸æ Rtuå°åï¼æä»¥è¿æ ·çæ°æ®æ¾è¡åï¼è½äº§çæèº«ä»½(Rtuå°å)çç½ç»ä¼è¯ï¼å³è½æsessionæ¾å
¥ä¼è¯ç¼åä¸ |
| | | //ä¸è®ºä½ç§æ
å½¢ï¼ä¸çº¿æ°æ®çæ°æ®éä¸ä¼å¾å¤§ï¼ä¸è¬ä¸ä¼äº§çæå
ï¼æä»¥è¿éåªè¿è¡ç®åæå
æ£æ¥ã |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forOnLine(in) ; |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forOnLine(session, in) ; |
| | | |
| | | if(dataStatus.protocolName != null && dataStatus.protocolVersion != null){ |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, dataStatus.protocolName) ; |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion, dataStatus.protocolVersion) ; |
| | | } |
| | | |
| | | if(dataStatus.isCompleted() || dataStatus.isAdjoined()){ |
| | | //æ£å¥½æç²å
|
| | | this.nextDeal(in, dataStatus.getDataLen(), out) ; |
| | |
| | | @SuppressWarnings("unused") |
| | | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String rtuAddr) { |
| | | //éä¸çº¿æ°æ®ï¼å¯è½ä¼åºç°æå
æç²å
ç°è±¡ |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(in) ; |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(session, in) ; |
| | | if(dataStatus == null){ |
| | | //ä¸å¯è½åç |
| | | log.error("严éé误ï¼Rtu (RTU" + rtuAddr + ")ä¸è¡æ°æ®å®æ´æ§æ£æ¥æ¶ï¼è¿åç对象为空ã") ; |
| | |
| | | package com.dy.common.mw.channel.tcp; |
| | | |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | public interface PrefixedDataAvailableHandle { |
| | | |
| | |
| | | * @param in IoBuffer |
| | | * @return ç¶æ |
| | | */ |
| | | PrefixedDataAvailableStatus forOnLine(IoBuffer in) ; |
| | | PrefixedDataAvailableStatus forOnLine(IoSession ioSession, IoBuffer in) ; |
| | | |
| | | /** |
| | | * é¢å¤çä¸è¡æ°æ® |
| | | * @param in IoBuffer |
| | | * @return ç¶æ |
| | | */ |
| | | PrefixedDataAvailableStatus forUpData(IoBuffer in) ; |
| | | PrefixedDataAvailableStatus forUpData(IoSession ioSession, IoBuffer in) ; |
| | | |
| | | } |
| | |
| | | |
| | | private Integer status ; |
| | | private Integer dataLen ; |
| | | public String protocolName; |
| | | public Short protocolVersion; |
| | | |
| | | public PrefixedDataAvailableStatus(){ |
| | | status = null ; |
| | |
| | | * @return ç¶æ |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public PrefixedDataAvailableStatus adjoined(Integer dataLen){ |
| | | public PrefixedDataAvailableStatus adjoined(Integer dataLen, String protocolName, Short protocolVersion){ |
| | | this.status = status_adjoin ; |
| | | this.dataLen = dataLen ; |
| | | this.protocolName = protocolName ; |
| | | this.protocolVersion = protocolVersion ; |
| | | return this ; |
| | | } |
| | | |
| | |
| | | * @return ç¶æ |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public PrefixedDataAvailableStatus completed(Integer dataLen){ |
| | | public PrefixedDataAvailableStatus completed(Integer dataLen, String protocolName, Short protocolVersion){ |
| | | this.status = status_complete ; |
| | | this.dataLen = dataLen ; |
| | | this.protocolName = protocolName ; |
| | | this.protocolVersion = protocolVersion ; |
| | | return this ; |
| | | } |
| | | |
| | |
| | | */ |
| | | public class TcpIoSessionAttrIdIsRtuAddr { |
| | | |
| | | public static final String sessionArrIdKey = "key_rtuAddr" ; //è¿ä¸ªkeyåå¨çæ¯Rtuå°å |
| | | public static final String sessionArrRtuAddr = "key_rtuAddr" ; //è¿ä¸ªkeyåå¨çæ¯Rtuå°å |
| | | public static final String sessionArrProtocolName = "key_pName" ; //è¿ä¸ªkeyåå¨çæ¯Rtuåè®®åç§° |
| | | public static final String sessionArrProtocolVersion = "key_pVerson" ; //è¿ä¸ªkeyåå¨çæ¯Rtuåè®®çæ¬å· |
| | | } |
| | |
| | | public static TcpUnit getInstance(){ |
| | | return instance ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æIoSessionä¼è¯çID屿§è®¾ç½®å°IoSession屿§ä¸ |
| | | * æIoSessionä¼è¯çID屿§ååè®®åç§°çæ¬å·è®¾ç½®å°IoSession屿§ä¸ |
| | | * @param session |
| | | * @param rtuAddr |
| | | * @param protocolName |
| | | * @param protocolVersion |
| | | * @throws Exception |
| | | */ |
| | | public void setIoSessionArrId(IoSession session, String id) throws Exception { |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey, id) ; |
| | | public void setIoSessionArrs(IoSession session, String rtuAddr, String protocolName, Short protocolVersion) throws Exception { |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr, rtuAddr) ; |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, protocolName) ; |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion, protocolVersion) ; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void setAdapter(UnitAdapterInterface adapter) throws Exception { |
| | | if(adapter == null){ |
| | |
| | | */ |
| | | String name() default "" ; |
| | | |
| | | /** |
| | | * åè®®çæ¬å· |
| | | */ |
| | | short version() default -1 ; |
| | | |
| | | boolean enable() default true ; |
| | | } |
| | |
| | | * æå±åè®®åç§° |
| | | */ |
| | | String protocolName() default "" ; |
| | | |
| | | /** |
| | | * æå±åè®®çæ¬å· |
| | | */ |
| | | short protocolVersion() default -1 ; |
| | | /** |
| | | * é
ç½®æ¯å¦å¯å¨ |
| | | * @return |
| | |
| | | * æå±åè®®åç§° |
| | | */ |
| | | public String protocolName ; |
| | | /** |
| | | * æå±åè®®åç§° |
| | | */ |
| | | public short protocolVersion ; |
| | | /** |
| | | * 为ä¼å
级(ä»1å¼å§ï¼æå°ä¸º1ï¼ååè®®é´ä¼å
级ç¸å·®1)ï¼æ°åè¶å°çº§å«è¶é«ã |
| | | * è¥æå¤ä¸ªåè®®ï¼å个åè®®çä¸çº¿å¤ç类以ä¼å
级è¿è¡æåºï¼ä¼å
级é«çå
å¤çä¸çº¿æ°æ®ã |
| | |
| | | * æé æ¹æ³ |
| | | * @param clazz ç±» |
| | | * @param protocolName åè®®åç§° |
| | | * @param protocolVersion åè®®çæ¬å· |
| | | * @param priority ä¼å
级 |
| | | */ |
| | | public AnnotationOnLineVo(Class<?> clazz, String protocolName, int priority){ |
| | | public AnnotationOnLineVo(Class<?> clazz, String protocolName, short protocolVersion, int priority){ |
| | | this.clazz = clazz ; |
| | | this.protocolName = protocolName ; |
| | | this.protocolVersion = protocolVersion ; |
| | | this.priority = priority ; |
| | | } |
| | | } |
| | |
| | | @Target(ElementType.TYPE) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface AnnotationPrefixedDataAvailable { |
| | | /** |
| | | * æå±åè®®åç§° |
| | | */ |
| | | /** |
| | | * æå±åè®®åç§° |
| | | */ |
| | | String protocolName() default "" ; |
| | | |
| | | /** |
| | | * æå±åè®®çæ¬å· |
| | | */ |
| | | short protocolVersion() default -1 ; |
| | | /** |
| | | * é
ç½®æ¯å¦å¯å¨ |
| | | * @return |
| | |
| | | * æå±åè®®åç§° |
| | | */ |
| | | public String protocolName ; |
| | | /** |
| | | * æå±åè®®çæ¬å· |
| | | */ |
| | | public short protocolVersion ; |
| | | /** |
| | | * 为ä¼å
级(ä»1å¼å§ï¼æå°ä¸º1ï¼ååè®®é´ä¼å
级ç¸å·®1)ï¼æ°åè¶å°çº§å«è¶é«ã |
| | | * è¥æå¤ä¸ªåè®®ï¼å个åè®®çä¸çº¿å¤ç类以ä¼å
级è¿è¡æåºï¼ä¼å
级é«çå
å¤çä¸çº¿æ°æ®ã |
| | |
| | | */ |
| | | public int errorMaxLength ; |
| | | |
| | | public AnnotationPrefixedDataAvailableVo(Class<?> clazz, String protocolName, int priority, int onLineDataMinLength, int headMinLength, int errorMaxLength){ |
| | | public AnnotationPrefixedDataAvailableVo(Class<?> clazz, String protocolName, short protocolVersion, int priority, int onLineDataMinLength, int headMinLength, int errorMaxLength){ |
| | | this.clazz = clazz ; |
| | | this.protocolName = protocolName ; |
| | | this.protocolVersion = protocolVersion ; |
| | | this.priority = priority ; |
| | | this.onLineDataMinLength = onLineDataMinLength ; |
| | | this.headMinLength = headMinLength ; |
| | |
| | | Set<Class<?>> driverClasses = reflections.getTypesAnnotatedWith(AnnotationDriver.class); |
| | | if (driverClasses != null && driverClasses.size() > 0) { |
| | | String protocolName; |
| | | short protocolVersion; |
| | | String key ; |
| | | int priority; |
| | | int onLineDataMinLength; |
| | | int headMinLength; |
| | |
| | | if (ann != null) { |
| | | if (ann.enable()) { |
| | | protocolName = ann.name(); |
| | | if (!(protocolName.trim().equals(""))) { |
| | | if (driverMap.containsKey(protocolName)) { |
| | | throw new Exception("严éé误ï¼å议驱å¨(åç§°)" + protocolName + "åºç°äºé夿³¨è§£ï¼"); |
| | | } |
| | | driverMap.put(protocolName, new AnnotationDriverVo(clazz)); |
| | | } else { |
| | | protocolVersion = ann.version() ; |
| | | if(protocolName == null || protocolName.trim().equals("")){ |
| | | throw new Exception("严éé误ï¼å议驱å¨å称注解å¼ä¸ºç©ºå符串"); |
| | | } |
| | | if(protocolVersion == -1){ |
| | | throw new Exception("严éé误ï¼å议驱å¨çæ¬å·æªé
ç½®"); |
| | | } |
| | | key = protocolName + protocolVersion ; |
| | | if (driverMap.containsKey(key)) { |
| | | throw new Exception("严éé误ï¼å议驱å¨(åç§°+çæ¬å·)" + key + "åºç°äºé夿³¨è§£ï¼"); |
| | | } |
| | | driverMap.put(key, new AnnotationDriverVo(clazz)); |
| | | } |
| | | } |
| | | } |
| | |
| | | throw new Exception("严éé误ï¼ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
åè®®é©±å¨æ³¨è§£å¼ä¸ºç©ºå符串"); |
| | | } |
| | | |
| | | protocolVersion = ann.protocolVersion(); |
| | | if (protocolVersion == -1) { |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
åè®®çæ¬å·æªé
ç½®"); |
| | | } |
| | | |
| | | priority = ann.priority(); |
| | | if (priority == 0) { |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
ä¼å
级注解ä¸è½ä¸º0"); |
| | |
| | | } |
| | | |
| | | onLineDataMinLength = ann.onLineDataMinLength(); |
| | | /*æ°è±¡å议为0 |
| | | if(onLineDataMinLength == 0){ |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
ä¸çº¿æ°æ®æå°é¿åº¦æ³¨è§£ä¸è½ä¸º0") ; |
| | | } |
| | | */ |
| | | /*æ°è±¡å议为0 |
| | | if(onLineDataMinLength == 0){ |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
ä¸çº¿æ°æ®æå°é¿åº¦æ³¨è§£ä¸è½ä¸º0") ; |
| | | } |
| | | */ |
| | | headMinLength = ann.headMinLength(); |
| | | /*æ°è±¡å议为0 |
| | | if(headMinLength == 0){ |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
䏿¥æ°æ®ç头鍿å°é¿åº¦æ³¨è§£ä¸è½ä¸º0") ; |
| | | } |
| | | */ |
| | | prefixedDataAvailableMap.put(protocolName, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength)); |
| | | /*æ°è±¡å议为0 |
| | | if(headMinLength == 0){ |
| | | throw new Exception("严ééè¯¯ï¼ ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
䏿¥æ°æ®ç头鍿å°é¿åº¦æ³¨è§£ä¸è½ä¸º0") ; |
| | | } |
| | | */ |
| | | key = protocolName + protocolVersion ; |
| | | prefixedDataAvailableMap.put(key, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, protocolVersion, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength)); |
| | | } |
| | | } |
| | | } |
| | |
| | | throw new Exception("严éé误ï¼ä¸çº¿æ°æ®åææé
åè®®é©±å¨æ³¨è§£å¼ä¸ºç©ºå符串"); |
| | | } |
| | | |
| | | protocolVersion = ann.protocolVersion(); |
| | | if (protocolVersion == -1) { |
| | | throw new Exception("严ééè¯¯ï¼ ä¸çº¿æ°æ®åææé
åè®®çæ¬å·æªé
ç½®"); |
| | | } |
| | | |
| | | priority = ann.priority(); |
| | | if (priority == 0) { |
| | | throw new Exception("严ééè¯¯ï¼ ä¸çº¿æ°æ®åææé
ä¼å
级注解ä¸è½ä¸º0"); |
| | |
| | | throw new Exception("严ééè¯¯ï¼ ä¸çº¿æ°æ®åææé
ä¼å
级注解(priority)æ°å¼" + priority + "éå¤"); |
| | | } |
| | | |
| | | onLineMap.put(protocolName, new AnnotationOnLineVo(clazz, protocolName, priority)); |
| | | key = protocolName + protocolVersion ; |
| | | onLineMap.put(key, new AnnotationOnLineVo(clazz, protocolName, protocolVersion, priority)); |
| | | } |
| | | } |
| | | } |
| | |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){ |
| | | Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values(); |
| | | for(AnnotationPrefixedDataAvailableVo vo : col){ |
| | | if(!driverMap.containsKey(vo.protocolName)){ |
| | | return "严éé误ï¼ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
驱å¨åç§°(" + vo.protocolName + ")å¨å议驱å¨ä¸æªé
ç½®" ; |
| | | if(!driverMap.containsKey(vo.protocolName + vo.protocolVersion)){ |
| | | return "严éé误ï¼ä¸è¡æ°æ®å®æ´æ§æ£æ¥æé
驱å¨åç§°(" + (vo.protocolName + vo.protocolVersion) + ")å¨å议驱å¨ä¸æªé
ç½®" ; |
| | | } |
| | | } |
| | | |
| | |
| | | HashMap<String, AnnotationOnLineVo> onLineMap){ |
| | | Collection<AnnotationOnLineVo> col = onLineMap.values(); |
| | | for(AnnotationOnLineVo vo : col){ |
| | | if(!driverMap.containsKey(vo.protocolName)){ |
| | | return "严éé误ï¼ä¸çº¿æ°æ®åææé
驱å¨åç§°(" + vo.protocolName + ")å¨å议驱å¨ä¸æªé
ç½®" ; |
| | | if(!driverMap.containsKey(vo.protocolName + vo.protocolVersion)){ |
| | | return "严éé误ï¼ä¸çº¿æ°æ®åææé
驱å¨åç§°(" + (vo.protocolName + vo.protocolVersion) + ")å¨å议驱å¨ä¸æªé
ç½®" ; |
| | | } |
| | | } |
| | | |
| | |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | |
| | | import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | public interface PrefixedDataAvailable { |
| | | |
| | |
| | | * @return 䏿¶æ¬åè®®æ°æ®æ¶è¿å空 |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | PrefixedDataAvailableStatus forOnLine(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception ; |
| | | PrefixedDataAvailableStatus forOnLine(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception ; |
| | | |
| | | /** |
| | | * åæä¸çº¿å(ç½ç»è¿æ¥åé第ä¸å
æ°æ®)æ¯å¦å¯è·å¾ |
| | |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | PrefixedDataAvailableStatus forUpData(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception; |
| | | PrefixedDataAvailableStatus forUpData(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception; |
| | | |
| | | } |
| | |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | |
| | | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.mw.channel.tcp.PrefixedDataAvailableHandle; |
| | | import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | public class PrefixedDataAvailableHandleImp implements PrefixedDataAvailableHandle { |
| | | |
| | |
| | | * @param in IoBuffer |
| | | * @return PrefixedDataAvailableStatus |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in){ |
| | | public PrefixedDataAvailableStatus forOnLine(IoSession ioSession, IoBuffer in){ |
| | | int remain = in.remaining() ; |
| | | if(remain == 0){ |
| | | return new PrefixedDataAvailableStatus().breaked() ; |
| | | }else{ |
| | | try{ |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set.size() == 0){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼å¾å°çåè®®å®æ´æ§æ£æ¥ç±»éå为空ã") ; |
| | | } |
| | | int priority = ProtocolConstant.firstPriority ; |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | PrefixedDataAvailable pda = null ; |
| | | |
| | | while(true){ |
| | | Object[] objs = this.getClassObjAndAnnotationVo(priority, set) ; |
| | | PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && priority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + priority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | }else if(pda == null){ |
| | | //说æä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»éåå·²ç»éåå®äºã |
| | | break ; |
| | | } |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forOnLine(in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).onLineDataMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | PrefixedDataAvailablePool.freeInstance(((AnnotationPrefixedDataAvailableVo)objs[1]).clazz, pda); |
| | | if(pds == null){ |
| | | //说æä¸æ¯å¯¹åºçåè®®æ°æ®ï¼éè¦å¦å¤çåè®®æ¥å¤çä¸çº¿ |
| | | //循ç¯ç»§ç» |
| | | priority++ ; |
| | | }else{ |
| | | //åæ¢å¾ªç¯ï¼è¿åç»æ |
| | | break ; |
| | | //ä»ä¼è¯ç¼åå¾å°ä¸æ¬¡ä¸è¡æ°æ®ç¡®å®çåè®® |
| | | String protocolName = (String) ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName) ; |
| | | Short protocolVersion = (Short) ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion) ; |
| | | //ç±ä¼è¯ä¸çåè®®å¾å°å¤çç±» |
| | | //å©ç¨ç¼åçåè®®ï¼è¿è对ä¸ç¬¦ååè®®çä¸è¡æ°æ®ä¹è½ç¨è¯¥åè®®å¤çäºï¼ä¾å¦RTUéç¨ä¸åæ°æ®åè®®çåµå
¥å¼è½¯ä»¶å级åè®® |
| | | //å³RTU第ä¸å
æ°æ®ç¡®å®ä¸æ¥åè®®ï¼å颿°æ®é½ç¨è¿ä¸ªåè®®å¤çï¼é£ä¹æ°æ®å¯ä»¥ååäºï¼å¯ä»¥ä¸ç¬¦å第ä¸å
æ°æ®éµå®çåè®®äº |
| | | Object[] objs = this.getClassObjAndAnnotationVo(protocolName, protocolVersion) ; |
| | | if(objs != null && objs[0] != null && objs[1] != null){ |
| | | pda = (PrefixedDataAvailable)objs[0] ; |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forOnLine(ioSession, in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).onLineDataMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda); |
| | | } |
| | | if(pds == null){ |
| | | //妿ä¼è¯ä¸ç¼åçåè®®æªè½æ£ç¡®å¤ç |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set.size() == 0){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼å¾å°çåè®®å®æ´æ§æ£æ¥ç±»éå为空ã") ; |
| | | } |
| | | } |
| | | int priority = ProtocolConstant.firstPriority ; |
| | | |
| | | while(true){ |
| | | objs = this.getClassObjAndAnnotationVo(priority, set) ; |
| | | pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && priority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + priority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | }else if(pda == null){ |
| | | //说æä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»éåå·²ç»éåå®äºã |
| | | break ; |
| | | } |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forOnLine(ioSession, in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).onLineDataMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | //2024-11-25ä¸é¢ä¸è¡è¿è¡äºä¿®æ¹ |
| | | //PrefixedDataAvailablePool.freeInstance(((AnnotationPrefixedDataAvailableVo)objs[1]).clazz, pda); |
| | | PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda); |
| | | if(pds == null){ |
| | | //说æä¸æ¯å¯¹åºçåè®®æ°æ®ï¼éè¦å¦å¤çåè®®æ¥å¤çä¸çº¿ |
| | | //循ç¯ç»§ç» |
| | | priority++ ; |
| | | }else{ |
| | | //åæ¢å¾ªç¯ï¼è¿åç»æ |
| | | break ; |
| | | } |
| | | } |
| | | } |
| | | if(pds == null){ |
| | | //è¯´ææ°æ®ä¸å±äºä»»ä½åè®®ï¼ä¸è¬ä¸ºRtuæ°æ®åºéï¼æç½ç»æ»å»æ°æ® |
| | | byte[] preByte = new byte[remain]; |
| | |
| | | * @param in IoBuffer |
| | | * @return PrefixedDataAvailableStatus |
| | | */ |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in){ |
| | | public PrefixedDataAvailableStatus forUpData(IoSession ioSession, IoBuffer in){ |
| | | int remain = in.remaining() ; |
| | | if(remain == 0){ |
| | | return new PrefixedDataAvailableStatus().breaked() ; |
| | | }else{ |
| | | try{ |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set.size() == 0){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼å¾å°çåè®®éå为空ã") ; |
| | | } |
| | | int prority = ProtocolConstant.firstPriority ; |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | PrefixedDataAvailable pda = null ; |
| | | |
| | | while(true){ |
| | | Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ; |
| | | PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && prority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + prority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | }else if(pda == null){ |
| | | //说æä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»éåå·²ç»éåå®äºã |
| | | break ; |
| | | } |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forUpData(in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).headMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda); |
| | | if(pds == null){ |
| | | //说æä¸æ¯å¯¹åºçåè®®æ°æ®ï¼éè¦å¦å¤çåè®®æ¥å¤çä¸çº¿ |
| | | //循ç¯ç»§ç» |
| | | prority++ ; |
| | | }else{ |
| | | //åæ¢å¾ªç¯ï¼è¿åç»æ |
| | | break ; |
| | | } |
| | | } |
| | | //ä»ä¼è¯ç¼åå¾å°ä¸æ¬¡ä¸è¡æ°æ®ç¡®å®çåè®® |
| | | String protocolName = (String) ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName) ; |
| | | Short protocolVersion = (Short) ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion) ; |
| | | //ç±ä¼è¯ä¸çåè®®å¾å°å¤çç±» |
| | | Object[] objs = this.getClassObjAndAnnotationVo(protocolName, protocolVersion) ; |
| | | if(objs != null && objs[0] != null && objs[1] != null){ |
| | | pda = (PrefixedDataAvailable)objs[0] ; |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forOnLine(ioSession, in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).onLineDataMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda); |
| | | } |
| | | if(pds == null) { |
| | | //妿ä¼è¯ä¸ç¼åçåè®®æªè½æ£ç¡®å¤ç |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set.size() == 0){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼å¾å°çåè®®éå为空ã") ; |
| | | } |
| | | int priority = ProtocolConstant.firstPriority ; |
| | | |
| | | while(true){ |
| | | objs = this.getClassObjAndAnnotationVo(priority, set) ; |
| | | pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && priority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + priority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | }else if(pda == null){ |
| | | //说æä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»éåå·²ç»éåå®äºã |
| | | break ; |
| | | } |
| | | //å¤ç宿´æ§æ£æ¥ |
| | | pds = pda.forUpData(ioSession, in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).headMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ; |
| | | //ç¨å®å¯¹è±¡åï¼æ¾åæ± ä¸ |
| | | PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda); |
| | | if(pds == null){ |
| | | //说æä¸æ¯å¯¹åºçåè®®æ°æ®ï¼éè¦å¦å¤çåè®®æ¥å¤çä¸çº¿ |
| | | //循ç¯ç»§ç» |
| | | priority++ ; |
| | | }else{ |
| | | //åæ¢å¾ªç¯ï¼è¿åç»æ |
| | | break ; |
| | | } |
| | | } |
| | | } |
| | | if(pds == null){ |
| | | //è¯´ææ°æ®ä¸å±äºä»»ä½åè®®ï¼ä¸è¬ä¸ºRtuæ°æ®åºéï¼æç½ç»æ»å»æ°æ® |
| | | byte[] preByte = new byte[remain]; |
| | |
| | | } |
| | | return new Object[]{obj, rVo} ; |
| | | } |
| | | /** |
| | | * å¾å°å¤ç类对象 |
| | | * @param protocolName éä¿¡åè®®åç§° |
| | | * @param protocolVersion éä¿¡åè®®çæ¬å· |
| | | * @return Object[] |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private Object[] getClassObjAndAnnotationVo(String protocolName, Short protocolVersion) throws Exception{ |
| | | PrefixedDataAvailable obj = null ; |
| | | AnnotationPrefixedDataAvailableVo rVo = null ; |
| | | if(protocolName != null && !protocolName.trim().equals("") && protocolVersion != null){ |
| | | rVo = ProtocolCache.getAnnotationPrefixedDataAvailable(protocolName, protocolVersion) ; |
| | | obj = PrefixedDataAvailablePool.getInstance(rVo.clazz) ; |
| | | } |
| | | return new Object[]{obj, rVo} ; |
| | | } |
| | | |
| | | } |
| | |
| | | List<PrefixedDataAvailable> list = pool.get(className) ; |
| | | if(list == null){ |
| | | list = new ArrayList<>() ; |
| | | }else{ |
| | | pool.put(className, list) ; |
| | | }else if(list.size() > 0){ |
| | | obj = list.get(0) ; |
| | | list.remove(0) ; |
| | | } |
| | | |
| | | if(obj != null){ |
| | | list.remove(0) ; |
| | | return obj ; |
| | | }else{ |
| | | if(obj == null){ |
| | | try { |
| | | obj = (PrefixedDataAvailable)clazz.getDeclaredConstructor().newInstance() ; |
| | | //obj = (PrefixedDataAvailable)clazz.newInstance(); |
| | | } catch (Exception e) { |
| | | throw new Exception( "ç±" + className + "çæå®ä¾å¤±è´¥ï¼"); |
| | | } |
| | | return obj ; |
| | | } |
| | | return obj ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * å¨å线ç¨ç¯å¢ä¸è¿è¡ |
| | | * éè¿å议驱å¨çç±»åï¼å¾å°ç±»åä¾ |
| | | * @param protocolName åè®®åç§° |
| | | * @param protocolVersion åè®®çæ¬å· |
| | | * @return é©±å¨ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static Driver getDriver(String protocolName) throws Exception{ |
| | | Driver dri = drivers.get(protocolName); |
| | | public static Driver getDriver(String protocolName, short protocolVersion) throws Exception{ |
| | | Driver dri = drivers.get(protocolName + protocolVersion) ; |
| | | if(dri == null){ |
| | | AnnotationDriverVo vo = driverMap.get(protocolName) ; |
| | | AnnotationDriverVo vo = driverMap.get(protocolName + protocolVersion) ; |
| | | if(vo != null && vo.clazz != null){ |
| | | dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance(); |
| | | //dri = (Driver)vo.clazz.newInstance() ; |
| | | drivers.put(protocolName, dri) ; |
| | | drivers.put(protocolName + protocolVersion, dri) ; |
| | | } |
| | | } |
| | | return dri ; |
| | | } |
| | | /** |
| | | * å¨å线ç¨ç¯å¢ä¸è¿è¡ |
| | | * éè¿å议驱å¨çç±»åï¼å¾å°ç±»åä¾ |
| | | * @param protocolNameVersion åè®®åç§°åçæ¬å· |
| | | * @return é©±å¨ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static Driver getDriver(String protocolNameVersion) throws Exception{ |
| | | Driver dri = drivers.get(protocolNameVersion) ; |
| | | if(dri == null){ |
| | | AnnotationDriverVo vo = driverMap.get(protocolNameVersion) ; |
| | | if(vo != null && vo.clazz != null){ |
| | | dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance(); |
| | | drivers.put(protocolNameVersion, dri) ; |
| | | } |
| | | } |
| | | return dri ; |
| | |
| | | return onLineMap; |
| | | } |
| | | |
| | | protected AnnotationDriverVo getAnnotationDriver(String protocolName, Short protocolVersion){ |
| | | return driverMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | protected static AnnotationPrefixedDataAvailableVo getAnnotationPrefixedDataAvailable(String protocolName, Short protocolVersion){ |
| | | return prefixedDataAvailableMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | protected static AnnotationOnLineVo getAnnotationOnLine(String protocolName, Short protocolVersion){ |
| | | return onLineMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | /* |
| | | public static void main(String[] args){ |
| | | HashMap<String, Integer> mp = new HashMap<>() ; |
| | |
| | | |
| | | //å个å议驱å¨ç±»æ«æèªå·±çåè½ç 注解 |
| | | HashMap<String, AnnotationDriverVo> drivers = ProtocolCache.getDriverMap() ; |
| | | Collection<String> colDrivers = drivers.keySet() ; |
| | | Collection<String> keys = drivers.keySet() ; |
| | | StringBuilder totalProtocols = new StringBuilder() ; |
| | | for(String protocolName : colDrivers){ |
| | | for(String protocolNameVersion : keys){ |
| | | if(!totalProtocols.isEmpty()){ |
| | | totalProtocols.append("ï¼") ; |
| | | } |
| | | totalProtocols.append(protocolName) ; |
| | | Driver dri = ProtocolCache.getDriver(protocolName) ; |
| | | totalProtocols.append(protocolNameVersion) ; |
| | | Driver dri = ProtocolCache.getDriver(protocolNameVersion) ; |
| | | if(dri != null){ |
| | | dri.scanAnnotationCode(); |
| | | dri.setNotify(adapter.getSingleRtuInfoNotify(protocolName)); |
| | | dri.setNotify(adapter.getSingleRtuInfoNotify(protocolNameVersion)); |
| | | } |
| | | } |
| | | if(adapter.getConfig().showStartInfo){ |
| | |
| | | |
| | | /** |
| | | * å线ç¨ç¯å¢ä¸è¿è¡ï¼å¾å°å个RTUä¿¡æ¯éç¥å¨ |
| | | * @param protocolName åè®®åç§° |
| | | * @param protocolNameVersion åè®®åç§°åçæ¬å· |
| | | * @return MidResultAction |
| | | */ |
| | | Notify getSingleRtuInfoNotify(String protocolName) ; |
| | | Notify getSingleRtuInfoNotify(String protocolNameVersion) ; |
| | | /** |
| | | * å线ç¨ç¯å¢ä¸è¿è¡ï¼å¾å°å个å¤çRTUä¸è¡æ°æ®çactionæ§è¡å¯¹è±¡ |
| | | * @param protocolName åè®®åç§° |
| | |
| | | package com.dy.common.mw.protocol.p206V1; |
| | | |
| | | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.CRC16; |
| | | import com.dy.common.util.CRC8_for_2_0; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | public class CommonV1 { |
| | | |
| | | |
| | | /** |
| | | * æ£æ¥å¤´ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | @AnnotationDriver(enable = true, name= ProtocolConstantV206V1.protocolName) |
| | | @AnnotationDriver(enable = true, |
| | | name= ProtocolConstantV206V1.protocolName, |
| | | version= ProtocolConstantV206V1.protocolVer) |
| | | public class DriverV1 extends Driver { |
| | | |
| | | private static String scanRootPackage = "com.dy.common.mw.protocol.p206V1" ; |
| | |
| | | @AnnotationOnLine( |
| | | enable = true, |
| | | protocolName = ProtocolConstantV206V1.protocolName, |
| | | protocolVersion = ProtocolConstantV206V1.protocolVer, |
| | | priority = ProtocolConstantV206V1.priority) |
| | | @SuppressWarnings("unused") |
| | | public class OnLineV1 implements OnLine{ |
| | |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.BufferDataException; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | @AnnotationPrefixedDataAvailable( |
| | | enable = true, |
| | | protocolName = ProtocolConstantV206V1.protocolName, |
| | | protocolVersion = ProtocolConstantV206V1.protocolVer, |
| | | priority = ProtocolConstantV206V1.priority, |
| | | onLineDataMinLength = ProtocolConstantV206V1.onLineDataMinLength, |
| | | headMinLength = ProtocolConstantV206V1.headMinLength) |
| | |
| | | private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV1.class) ; |
| | | |
| | | private static final String protocolName = ProtocolConstantV206V1.protocolName ; |
| | | |
| | | private static final short protocolVersion = ProtocolConstantV206V1.protocolVer ; |
| | | |
| | | /** |
| | | * åæä¸çº¿æ°æ®(ç½ç»è¿æ¥å第ä¸å
æ°æ®)æ¯å¦å¯è·å¾ |
| | |
| | | * @return 䏿¯æ¬åè®®æ°æ®æ¶è¿å空 |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength |
| | | ) throws Exception { |
| | | public PrefixedDataAvailableStatus forOnLine(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength |
| | | ) throws Exception { |
| | | |
| | | int oldPosition = in.position() ; |
| | | byte[] preByte = new byte[remain]; |
| | |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | @Override |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | public PrefixedDataAvailableStatus forUpData(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | int oldPosition = in.position() ; |
| | | byte[] preByte = new byte[remain]; |
| | | in.get(preByte) ; |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | |
| | | } |
| | | /** |
| | | * è¿è¡å¤æ |
| | | * @param ioSession ioSession |
| | | * @param preByte byte[] |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | private PrefixedDataAvailableStatus doForData(IoSession ioSession, byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | int remain = preByte.length ; |
| | | |
| | | if (remain < minDataLength) { |
| | |
| | | |
| | | if(remain == dataLen){ |
| | | //䏿ä¸ç² |
| | | return new PrefixedDataAvailableStatus().completed(dataLen) ; |
| | | return new PrefixedDataAvailableStatus().completed(dataLen, protocolName, protocolVersion) ; |
| | | }else if(remain > dataLen){ |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | log.warn("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½åçç²å
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().adjoined(dataLen) ; |
| | | return new PrefixedDataAvailableStatus().adjoined(dataLen, protocolName, protocolVersion) ; |
| | | }else{ |
| | | // remain < dataLen |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | |
| | | * 注解ç¸å
³ |
| | | */ |
| | | public static final String protocolName = "p206V1" ; |
| | | public static final Short protocolVer = 1 ; |
| | | public static final short protocolVer = 1 ; |
| | | public static final int priority = 2 ;//ä¼å
级 |
| | | /** |
| | | * RTUä¸çº¿æ°æ®ï¼ä¸çº¿å第ä¸å
æ°æ®ï¼æå°é¿åº¦ï¼è®¾ç½®è¯¥å±æ§ä»¥å¤è¿è¡å®æ´æ§æ£æ¥ï¼ |
| | |
| | | package com.dy.common.mw.protocol.p206V2; |
| | | |
| | | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.CRC16; |
| | | import com.dy.common.util.CRC8_for_2_0; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | public class CommonV2 { |
| | | |
| | | /** |
| | | * å¨Ioä¼è¯ä¸è®¾ç½®åè®®åç§°åçæ¬å· |
| | | * @param ioSession ä¼è¯ |
| | | */ |
| | | public void setThisProtocolArr2IoSession(IoSession ioSession){ |
| | | ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolName) ; |
| | | ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolVer) ; |
| | | } |
| | | /** |
| | | * æ£æ¥å¤´ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | |
| | | && bs[ProtocolConstantV206V2.headFlag1Index] == ProtocolConstantV206V2.P_Head_Byte |
| | | && bs[ProtocolConstantV206V2.headFlag2Index] == ProtocolConstantV206V2.P_Head_Byte){ |
| | | Short vs = this.parseVersion(bs) ; |
| | | if(vs.shortValue() == ProtocolConstantV206V2.protocolVer.shortValue()){ |
| | | if(vs.shortValue() == ProtocolConstantV206V2.protocolVer){ |
| | | return new Boolean[]{true, true}; |
| | | }else{ |
| | | return new Boolean[]{false, true}; |
| | |
| | | } |
| | | |
| | | /** |
| | | * åæåè½ç |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return åè½ç |
| | | */ |
| | | public String parseCode(byte[] bs, boolean p206TrueUgFalse){ |
| | | if(p206TrueUgFalse) { |
| | | return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.codeIndex, 1); |
| | | }else{ |
| | | return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex, 2); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªåæ£æ¥ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return éè¿nullï¼æªéè¿è¿ååå |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¡éªåæ£æ¥ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @param p206TrueUgFalse 206å议为trueï¼å级å议为false |
| | | * @return éè¿nullï¼æªéè¿è¿ååå |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String checkCrc_str(byte[] bs, boolean p206TrueUgFalse) throws Exception { |
| | | if(p206TrueUgFalse){ |
| | | byte crcCompute = (byte)new CRC8_for_2_0().CRC8(bs, ProtocolConstantV206V1.ctrlIndex, bs.length - 3) ; |
| | | byte crcInBs = bs[bs.length - 2] ; |
| | | if(crcCompute == crcInBs){ |
| | | return null ; |
| | | }else{ |
| | | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; |
| | | } |
| | | }else{ |
| | | short crcCompute = new CRC16().CRC(bs, 0, bs.length - 4) ; |
| | | short crcInBs = ByteUtil.bytes2Short_BE(bs,bs.length - 3) ; |
| | | //int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; |
| | | if(crcCompute == crcInBs){ |
| | | return null ; |
| | | }else{ |
| | | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; |
| | | } |
| | | } |
| | | } |
| | | /* |
| | | æé æ§å¶å |
| | | D7 D6 D5ï½D4 D3ï½D0 |
| | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | @AnnotationDriver(enable = true, name= ProtocolConstantV206V2.protocolName) |
| | | @AnnotationDriver(enable = true, |
| | | name= ProtocolConstantV206V2.protocolName, |
| | | version= ProtocolConstantV206V2.protocolVer) |
| | | public class DriverV2 extends Driver { |
| | | |
| | | private static String scanRootPackage = "com.dy.common.mw.protocol.p206V2" ; |
| | |
| | | Short protocolVersion = null ; |
| | | try{ |
| | | CommonV2 cp = new CommonV2() ; |
| | | Boolean p206TrueUgFalse = cp.protocolType_p206TrueUgFalse(upBuffer) ; |
| | | //å°æ¤å¤äºï¼p206TrueUgFalseä¸å¯è½ä¸ºç©ºäº |
| | | cp.checkTail(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer, p206TrueUgFalse) ; |
| | | if(crcStr != null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V2.protocolName, rtuAddr, "严éé误ï¼ä¸è¡æ°æ®CRCæ£æ¥å¤±è´¥ï¼" + crcStr, null))} ; |
| | | } |
| | | protocolVersion = cp.parseVersion(upBuffer) ; |
| | | upCode = cp.parseCode(upBuffer) ; |
| | | upCode = cp.parseCode(upBuffer, p206TrueUgFalse) ; |
| | | if(upCode == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V2.protocolName, rtuAddr, "严ééè¯¯ï¼æªè½ä»ä¸è¡æ°æ®ä¸è§£æåºåè½ç ï¼", null))} ; |
| | | } |
| | |
| | | |
| | | import com.dy.common.mw.protocol.AnnotationOnLine; |
| | | import com.dy.common.mw.protocol.OnLine; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | |
| | | @AnnotationOnLine( |
| | | enable = true, |
| | | protocolName = ProtocolConstantV206V2.protocolName, |
| | | protocolVersion = ProtocolConstantV206V2.protocolVer, |
| | | priority = ProtocolConstantV206V2.priority) |
| | | @SuppressWarnings("unused") |
| | | public class OnLineV2 implements OnLine{ |
| | |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.BufferDataException; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | @AnnotationPrefixedDataAvailable( |
| | | enable = true, |
| | | protocolName = ProtocolConstantV206V2.protocolName, |
| | | protocolVersion = ProtocolConstantV206V2.protocolVer, |
| | | priority = ProtocolConstantV206V2.priority, |
| | | onLineDataMinLength = ProtocolConstantV206V2.onLineDataMinLength, |
| | | headMinLength = ProtocolConstantV206V2.headMinLength) |
| | |
| | | private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV2.class) ; |
| | | |
| | | private static final String protocolName = ProtocolConstantV206V2.protocolName ; |
| | | |
| | | private static final short protocolVersion = ProtocolConstantV206V2.protocolVer ; |
| | | |
| | | /** |
| | | * åæä¸çº¿æ°æ®(ç½ç»è¿æ¥å第ä¸å
æ°æ®)æ¯å¦å¯è·å¾ |
| | |
| | | * @return 䏿¯æ¬åè®®æ°æ®æ¶è¿å空 |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, //对åºProtocolConstantV2_0.onLineDataMinLength |
| | | int maxDataLength //对åºProtocolConstant.errorMaxLength |
| | | ) throws Exception { |
| | | public PrefixedDataAvailableStatus forOnLine(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, //对åºProtocolConstantV2_0.onLineDataMinLength |
| | | int maxDataLength //对åºProtocolConstant.errorMaxLength |
| | | ) throws Exception { |
| | | |
| | | int oldPosition = in.position() ; |
| | | byte[] preByte = new byte[remain]; |
| | |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | @Override |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | public PrefixedDataAvailableStatus forUpData(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | int oldPosition = in.position() ; |
| | | byte[] preByte = new byte[remain]; |
| | | in.get(preByte) ; |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | |
| | | } |
| | | /** |
| | | * è¿è¡å¤æ |
| | | * @param ioSession ioSession |
| | | * @param preByte byte[] |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | private PrefixedDataAvailableStatus doForData(IoSession ioSession, byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | int remain = preByte.length ; |
| | | |
| | | if (remain < minDataLength) { |
| | | log.warn("åºäºåè®®ï¼" + protocolName + "ï¼å¤ææ°æ®å¤´é¨åçæå
ç°è±¡ã") ; |
| | | log.warn("åºäºåè®®ï¼" + (protocolName + protocolVersion) + "ï¼å¤ææ°æ®å¤´é¨åçæå
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().breaked() ; |
| | | } |
| | | |
| | |
| | | return new PrefixedDataAvailableStatus().rubbish(remain) ; |
| | | } |
| | | |
| | | |
| | | CommonV2 parseCommon = new CommonV2(); |
| | | Boolean[] isThisProtocolData = parseCommon.isThisProtocolHead(preByte) ; |
| | | if(isThisProtocolData == null || isThisProtocolData.length != 2 || !isThisProtocolData[0].booleanValue()){ |
| | |
| | | |
| | | if(remain == dataLen){ |
| | | //䏿ä¸ç² |
| | | return new PrefixedDataAvailableStatus().completed(dataLen) ; |
| | | return new PrefixedDataAvailableStatus().completed(dataLen, protocolName, protocolVersion) ; |
| | | }else if(remain > dataLen){ |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | log.warn("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½åçç²å
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().adjoined(dataLen) ; |
| | | return new PrefixedDataAvailableStatus().adjoined(dataLen, protocolName, protocolVersion) ; |
| | | }else{ |
| | | // remain < dataLen |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | |
| | | * 注解ç¸å
³ |
| | | */ |
| | | public static final String protocolName = "p206V2" ; |
| | | public static final Short protocolVer = 2 ; |
| | | public static final short protocolVer = 2 ; |
| | | public static final int priority = 3 ;//ä¼å
级 |
| | | /** |
| | | * RTUä¸çº¿æ°æ®ï¼ä¸çº¿å第ä¸å
æ°æ®ï¼æå°é¿åº¦ï¼è®¾ç½®è¯¥å±æ§ä»¥å¤è¿è¡å®æ´æ§æ£æ¥ï¼ |
| | |
| | | package com.dy.common.mw.protocol.p206V2.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V2.CodeV2; |
| | | import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | |
| | | import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.mw.protocol.p206V2.parse.global.GlCreate; |
| | | import com.dy.common.softUpgrade.Com1601Vo; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | |
| | | midRs.downCodeName = CodeV2.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, (byte[])para.attachment) ; |
| | | if(para.param == null){ |
| | | throw new Exception("åæ°ä¸ºç©º") ; |
| | | } |
| | | if(!(para.param instanceof Com1601Vo)){ |
| | | throw new Exception("åæ°ç±»åéCom1601Vo") ; |
| | | } |
| | | Com1601Vo vo = (Com1601Vo) para.param ; |
| | | byte[] bs = new byte[4] ; |
| | | ByteUtil.hex2Bytes(vo.softStoreAddr, bs, 0) ; |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | ByteUtil.int2Bytes_BE(bs, vo.totalByte, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | ByteUtil.short2Bytes_BE(bs, (short)vo.softCrc, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | ByteUtil.short2Bytes_BE(bs, (short)vo.softCrc, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | |
| | | midRs.downCodeName = CodeV2.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | if(para.param == null){ |
| | | throw new Exception("åæ°ä¸ºç©º") ; |
| | | } |
| | | Integer ramAddr = (Integer)para.param ; |
| | | |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, (byte[])para.attachment) ; |
| | | byte[] bs = new byte[4] ; |
| | | ByteUtil.int2Bytes_BE(bs, ramAddr, 0); |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, bs) ; |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ; |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | |
| | | midRs.downCodeName = CodeV2.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | public static final String cd_9C = "9C" ; //é»ååè¿ç¨å¼ºå¶å
³éæ°´æ³µ/éé¨ |
| | | public static final String cd_C2 = "C2" ; //å¼å
³æ°´æ³µ/é鍿å/å¤±è´¥ä¸æ¥ |
| | | |
| | | public static final String cd_1600 = "1600" ;//å级å¤ä½ |
| | | public static final String cd_1601 = "1601" ;//å级é
ç½® |
| | | public static final String cd_1602 = "1602" ;//åçº§æ°æ® |
| | | public static final String cd_1603 = "1603" ;//åçº§æ ¡éª |
| | | public static final String cd_9601 = "9601" ;//å级é
ç½® |
| | | public static final String cd_9602 = "9602" ;//åçº§æ°æ® |
| | | public static final String cd_9603 = "9603" ;//åçº§æ ¡éª |
| | | |
| | | public static String getCodeName(String code) { |
| | | String name = (code.equals(cd_02) ? "é¾è·¯æ£æµ" : |
| | | (code.equals(cd_10) ? "设置设å¤ç»ç«¯å°å" : |
| | |
| | | (code.equals(cd_9B) ? "æ¸
é¤è®¾å¤ç»ç«¯æ³¨åå·" : |
| | | (code.equals(cd_9C) ? "é»ååè¿ç¨å¼ºå¶å
³éæ°´æ³µ/éé¨" : |
| | | (code.equals(cd_C2) ? "å¼å
³æ°´æ³µ/éé¨ç»æä¸æ¥" : |
| | | ""))))))))))))))))))))))))))))))))))))))) ; |
| | | (code.equals(cd_1600) ? "å级å¤ä½" : |
| | | (code.equals(cd_1601) ? "å级é
ç½®" : |
| | | (code.equals(cd_1602) ? "åçº§æ°æ®" : |
| | | (code.equals(cd_1603) ? "åçº§æ ¡éª" : |
| | | (code.equals(cd_9601) ? "å级é
ç½®" : |
| | | (code.equals(cd_9602) ? "åçº§æ°æ®" : |
| | | (code.equals(cd_9603) ? "åçº§æ ¡éª" : |
| | | "")))))))))))))))))))))))))))))))))))))))))))))) ; |
| | | if(name == null || name.equals("")){ |
| | | name = code ; |
| | | } |
| | |
| | | package com.dy.common.mw.protocol.p206V202404; |
| | | |
| | | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.CRC16; |
| | | import com.dy.common.util.CRC8_for_2_0; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | public class CommonV202404 { |
| | | |
| | | /** |
| | | * å¨Ioä¼è¯ä¸è®¾ç½®åè®®åç§°åçæ¬å· |
| | | * @param ioSession ä¼è¯ |
| | | */ |
| | | public void setThisProtocolArr2IoSession(IoSession ioSession){ |
| | | ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolName) ; |
| | | ioSession.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName, ProtocolConstantV206V1.protocolVer) ; |
| | | } |
| | | /** |
| | | * æ£æ¥å¤´ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å议类å |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return å议类å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public Boolean protocolType_p206TrueUgFalse(byte[] bs){ |
| | | if(bs == null){ |
| | | return null ; |
| | | }else if(bs.length >= (ProtocolConstantV206V202404.ctrlIndex) |
| | | && bs[0] == ProtocolConstantV206V202404.P_Head_Byte |
| | | && bs[2] == ProtocolConstantV206V202404.P_Head_Byte){ |
| | | return true ; |
| | | }else if(bs.length >= (ProtocolConstantV206V202404.UG_codeIndex) |
| | | && bs[0] == ProtocolConstantV206V202404.UG_P_Head_Byte |
| | | && bs[3] == ProtocolConstantV206V202404.UG_P_Head_Byte){ |
| | | return false ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å°¾ |
| | |
| | | * @return æ°æ®é¿åº¦ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public int parseDataLen(byte[] bs)throws Exception{ |
| | | public int parseDataLen4P202404(byte[] bs)throws Exception{ |
| | | return parseFrameLen(bs) ; |
| | | } |
| | | |
| | | /** |
| | | * åæç¨æ·æ°æ®ååèæ°(å级åè®®) |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return æ°æ®é¿åº¦ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public int parseDataLen4Ug(byte[] bs)throws Exception{ |
| | | int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V2.UG_dataLenIndex_start) ; |
| | | return len - ProtocolConstantV206V2.UG_lenCmd - ProtocolConstantV206V2.UG_lenRtuAddr ; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * åæåè½ç |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return åè½ç |
| | | */ |
| | | public String parseCode(byte[] bs, boolean p202404TrueUgFalse){ |
| | | if(p202404TrueUgFalse) { |
| | | return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V202404.codeIndex, 1); |
| | | }else{ |
| | | return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V202404.UG_codeIndex, 2); |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªåæ£æ¥ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return éè¿nullï¼æªéè¿è¿ååå |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªåæ£æ¥ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @param p202404TrueUgFalse 202404å议为trueï¼å级å议为false |
| | | * @return éè¿nullï¼æªéè¿è¿ååå |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public String checkCrc_str(byte[] bs, boolean p202404TrueUgFalse) throws Exception { |
| | | if(p202404TrueUgFalse){ |
| | | byte crcCompute = (byte)new CRC8_for_2_0().CRC8(bs, ProtocolConstantV206V202404.ctrlIndex, bs.length - 3) ; |
| | | byte crcInBs = bs[bs.length - 2] ; |
| | | if(crcCompute == crcInBs){ |
| | | return null ; |
| | | }else{ |
| | | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; |
| | | } |
| | | }else{ |
| | | short crcCompute = new CRC16().CRC(bs, 0, bs.length - 4) ; |
| | | short crcInBs = ByteUtil.bytes2Short_BE(bs,bs.length - 3) ; |
| | | //int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; |
| | | if(crcCompute == crcInBs){ |
| | | return null ; |
| | | }else{ |
| | | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /* |
| | | æé æ§å¶å |
| | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | @AnnotationDriver(name= ProtocolConstantV206V202404.protocolName) |
| | | @AnnotationDriver(enable = true, |
| | | name= ProtocolConstantV206V202404.protocolName, |
| | | version= ProtocolConstantV206V202404.protocolVer) |
| | | public class DriverV202404 extends Driver { |
| | | |
| | | private static String scanRootPackage = "com.dy.common.mw.protocol.p206V202404" ; |
| | |
| | | String upCode = null ; |
| | | try{ |
| | | CommonV202404 cp = new CommonV202404() ; |
| | | Boolean p202404TrueUgFalse = cp.protocolType_p206TrueUgFalse(upBuffer) ; |
| | | cp.checkTail(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer, p202404TrueUgFalse) ; |
| | | if(crcStr != null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "严éé误ï¼ä¸è¡æ°æ®CRCæ£æ¥å¤±è´¥ï¼" + crcStr, null))} ; |
| | | } |
| | |
| | | import com.dy.common.mw.protocol.OnLine; |
| | | |
| | | @AnnotationOnLine( |
| | | enable = true, |
| | | protocolName = ProtocolConstantV206V202404.protocolName, |
| | | protocolVersion = ProtocolConstantV206V202404.protocolVer, |
| | | priority = ProtocolConstantV206V202404.priority) |
| | | @SuppressWarnings("unused") |
| | | public class OnLineV202404 implements OnLine{ |
| | |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.BufferDataException; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | |
| | | @AnnotationPrefixedDataAvailable( |
| | | protocolName = ProtocolConstantV206V202404.protocolName, |
| | | protocolVersion = ProtocolConstantV206V202404.protocolVer, |
| | | priority = ProtocolConstantV206V202404.priority, |
| | | onLineDataMinLength = ProtocolConstantV206V202404.onLineDataMinLength, |
| | | headMinLength = ProtocolConstantV206V202404.headMinLength) |
| | |
| | | private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV202404.class) ; |
| | | |
| | | private static final String protocolName = ProtocolConstantV206V202404.protocolName ; |
| | | private static final short protocolVersion = ProtocolConstantV206V202404.protocolVer ; |
| | | |
| | | |
| | | /** |
| | |
| | | * @return 䏿¯æ¬åè®®æ°æ®æ¶è¿å空 |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, //对åºProtocolConstantV2_0.onLineDataMinLength |
| | | int maxDataLength //对åºProtocolConstant.errorMaxLength |
| | | public PrefixedDataAvailableStatus forOnLine(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, //对åºProtocolConstantV2_0.onLineDataMinLength |
| | | int maxDataLength //对åºProtocolConstant.errorMaxLength |
| | | ) throws Exception { |
| | | |
| | | int oldPosition = in.position() ; |
| | |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | @Override |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | public PrefixedDataAvailableStatus forUpData(IoSession ioSession, |
| | | IoBuffer in, |
| | | int remain, |
| | | int minDataLength, |
| | | int maxDataLength) throws Exception { |
| | | int oldPosition = in.position() ; |
| | | byte[] preByte = new byte[remain]; |
| | | in.get(preByte) ; |
| | | //in.position(0) ;//éè¯¯ç¨æ³ï¼å¦æåçç²å
æ°æ®ï¼å°ä¼æ»å¾ªç¯ |
| | | in.position(oldPosition) ; |
| | | |
| | | return this.doForData(preByte, minDataLength, maxDataLength) ; |
| | | return this.doForData(ioSession, preByte, minDataLength, maxDataLength) ; |
| | | |
| | | } |
| | | /** |
| | | * è¿è¡å¤æ |
| | | * @param ioSession ioSession |
| | | * @param preByte byte[] |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | private PrefixedDataAvailableStatus doForData(IoSession ioSession, byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | int remain = preByte.length ; |
| | | |
| | | if (remain < minDataLength) { |
| | |
| | | |
| | | if(remain == frameLen){ |
| | | //䏿ä¸ç² |
| | | return new PrefixedDataAvailableStatus().completed(frameLen) ; |
| | | return new PrefixedDataAvailableStatus().completed(frameLen, protocolName, protocolVersion) ; |
| | | }else if(remain > frameLen){ |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | log.warn("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½åçç²å
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().adjoined(frameLen) ; |
| | | return new PrefixedDataAvailableStatus().adjoined(frameLen, protocolName, protocolVersion) ; |
| | | }else{ |
| | | // remain < dataLen |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | |
| | | * 注解ç¸å
³ |
| | | */ |
| | | public static final String protocolName = "p206V202404" ; |
| | | public static final Short protocolVer = 201 ; |
| | | public static final short protocolVer = 201 ; |
| | | public static final int priority = 1 ;//ä¼å
级 |
| | | /** |
| | | * RTUä¸çº¿æ°æ®ï¼ä¸çº¿å第ä¸å
æ°æ®ï¼æå°é¿åº¦ï¼è®¾ç½®è¯¥å±æ§ä»¥å¤è¿è¡å®æ´æ§æ£æ¥ï¼ |
| | |
| | | public static final int codeIndex = 12 ;//åè½ç åèæ°ç»ä¸æ |
| | | public static final int dataIndex = 13 ;//å
·ä½æ°æ®åèæ°ç»ä¸æ |
| | | |
| | | //////////////////////////////////////////////// |
| | | // |
| | | //è¿ç¨å级ç¸å
³ |
| | | // |
| | | //////////////////////////////////////////////// |
| | | public static final byte UG_P_Head_Byte = (byte)0xAA ; |
| | | public static final byte UG_P_Tail_Byte = (byte)0x16 ; |
| | | public static final int UG_codeIndex = 4 ;//åè½ç åèæ°ç»ä¸æ |
| | | public static final int UG_dataIndex = 12 ;//å
·ä½æ°æ®åèæ°ç»ä¸æ |
| | | |
| | | public static final int UG_dataLenIndex_start = 1 ;//帧é¿åº¦å¼å§æå¨ åèæ°ç»èµ·å§ä¸æ |
| | | public static final int UG_dataLenIndex_end = 2 ;//帧é¿åº¦ç»ææå¨ åèæ°ç»èµ·å§ä¸æ |
| | | |
| | | public static final int UG_rtuAddrIndex_start = 6 ;//æ§å¶å¨å°å åèæ°ç»å¼å§ä¸æ |
| | | public static final int UG_rtuAddrIndex_end = 11 ;//æ§å¶å¨å°å åèæ°ç»å¼å§ä¸æ |
| | | |
| | | public static final byte UG_lenCmd = 2 ; //åè½ç åèæ°ç»é¿åº¦ |
| | | public static final byte UG_lenRtuAddr = 6 ; //åè½ç åèæ°ç»é¿åº¦ |
| | | public static final byte UG_lenHead2Cmd = 4 ; //ä»å¤´å°åè½ç ï¼ä¸å
æ¬ï¼åèæ°ç»é¿åº¦ |
| | | public static final byte UG_lenTail = 3 ; //帧尾é¨åèæ°ç»é¿åº¦ |
| | | public static final byte UG_lenHead2RtuAddr = 12 ; //ä»å¤´å°RTUå°åï¼å
æ¬ï¼åèæ°ç»é¿åº¦ |
| | | |
| | | |
| | | } |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV202404.cd_1600 |
| | | }) |
| | | public class Cd_1600_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV202404 para = (ParseParamsForDownV202404) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtuè¿åå½ä»¤ç»æ ååç®çå°web URL |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.commandId = para.commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | midRs.downCode = para.commandCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | midRs.downCodeName = CodeV202404.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //ä½åèæ¶ï¼å°½å¿«åé |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @param midRs åæ° |
| | | * @param para åæ° |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV202404 para) throws Exception { |
| | | byte[] preBytes = new byte[ProtocolConstantV206V202404.UG_lenHead2RtuAddr] ; |
| | | byte index = 0 ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | ByteUtil.hex2Bytes(para.commandCode, preBytes, index) ; |
| | | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; |
| | | import com.dy.common.softUpgrade.Com1601Vo; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV202404.cd_1601 |
| | | }) |
| | | public class Cd_1601_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV202404 para = (ParseParamsForDownV202404) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtuè¿åå½ä»¤ç»æ ååç®çå°web URL |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.commandId = para.commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | midRs.downCode = para.commandCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | midRs.downCodeName = CodeV202404.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //ä½åèæ¶ï¼å°½å¿«åé |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @param midRs åæ° |
| | | * @param para åæ° |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV202404 para) throws Exception { |
| | | byte[] preBytes = new byte[ProtocolConstantV206V202404.UG_lenHead2RtuAddr] ; |
| | | byte index = 0 ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | ByteUtil.hex2Bytes(para.commandCode, preBytes, index) ; |
| | | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | if(para.param == null){ |
| | | throw new Exception("åæ°ä¸ºç©º") ; |
| | | } |
| | | if(!(para.param instanceof Com1601Vo)){ |
| | | throw new Exception("åæ°ç±»åéCom1601Vo") ; |
| | | } |
| | | Com1601Vo vo = (Com1601Vo) para.param ; |
| | | byte[] bs = new byte[4] ; |
| | | ByteUtil.hex2Bytes(vo.softStoreAddr, bs, 0) ; |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | ByteUtil.int2Bytes_BE(bs, vo.totalByte, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | ByteUtil.short2Bytes_BE(bs, (short)vo.softCrc, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[2] ; |
| | | ByteUtil.short2Bytes_BE(bs, (short)vo.softCrc, 0); |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | bs = new byte[4] ; |
| | | ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV202404.cd_1602 |
| | | }) |
| | | public class Cd_1602_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV202404 para = (ParseParamsForDownV202404) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtuè¿åå½ä»¤ç»æ ååç®çå°web URL |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.commandId = para.commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | midRs.downCode = para.commandCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | midRs.downCodeName = CodeV202404.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //ä½åèæ¶ï¼å°½å¿«åé |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @param midRs åæ° |
| | | * @param para åæ° |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV202404 para) throws Exception { |
| | | byte[] preBytes = new byte[ProtocolConstantV206V202404.UG_lenHead2RtuAddr] ; |
| | | byte index = 0 ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | ByteUtil.hex2Bytes(para.commandCode, preBytes, index) ; |
| | | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | if(para.param == null){ |
| | | throw new Exception("åæ°ä¸ºç©º") ; |
| | | } |
| | | Integer ramAddr = (Integer)para.param ; |
| | | |
| | | byte[] bs = new byte[4] ; |
| | | ByteUtil.int2Bytes_BE(bs, ramAddr, 0); |
| | | byte[] bytes = ByteUtil.bytesMerge(preBytes, bs) ; |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ; |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/06/12 9:30 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV202404.cd_1603 |
| | | }) |
| | | public class Cd_1603_Down implements CodeParse { |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV202404 para = (ParseParamsForDownV202404) params ; |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | byte[] bs = this.doParse(midRs, para) ; |
| | | |
| | | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtuè¿åå½ä»¤ç»æ ååç®çå°web URL |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.commandId = para.commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | midRs.downCode = para.commandCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | midRs.downCodeName = CodeV202404.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //ä½åèæ¶ï¼å°½å¿«åé |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @param midRs åæ° |
| | | * @param para åæ° |
| | | * @return åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public byte[] doParse(MidResultToRtu midRs, ParseParamsForDownV202404 para) throws Exception { |
| | | byte[] preBytes = new byte[ProtocolConstantV206V202404.UG_lenHead2RtuAddr] ; |
| | | byte index = 0 ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | index++ ; |
| | | preBytes[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | preBytes[index] = ProtocolConstantV206V202404.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | ByteUtil.hex2Bytes(para.commandCode, preBytes, index) ; |
| | | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRCåå°¾å å åèæ°ç»ä¸ |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1.CommonV1; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd80_5BVo; |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd83Vo; |
| | | import com.dy.common.mw.protocol.rtuState.ValveStateInfo; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.DateTime; |
| | | import org.apache.logging.log4j.LogManager; |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V2.upVos.DataCd93Vo; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd93_A3Vo; |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd960XVo; |
| | | import com.dy.common.mw.protocol.rtuState.UpgradeStateInfo; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/11/4 10:58 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV202404.cd_9601 |
| | | }) |
| | | public class Cd_9601_Up implements CodeParse { |
| | | |
| | | private static final Logger log = LogManager.getLogger(Cd_9601_Up.class); |
| | | |
| | | /** |
| | | * åæä¸è¡æ°æ® |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen4Ug(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("\nåæå½ä»¤åºçæ°æ®<" + CodeV202404.getCodeName(para.upCode) + " RTUå°å=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.upCode = para.upCode ;//ä¸è¡æ°æ®ä¸çåè½ç |
| | | midRs.upHex = para.upHex ;//ä¸è¡æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | | DataCd960XVo subData = (DataCd960XVo)((DataV202404)para.data.getSubData()).subData ; |
| | | callback.notify(new UpgradeStateInfo(subData.success)); |
| | | } |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | | * @param bs åèæ°ç» |
| | | * @param bsLen åèé¿åº¦ï¼æ»å
é¿ï¼å
æ¬å
头åå
å°¾ï¼ |
| | | * @param dataCode åè½ç |
| | | * @param data æ°æ® |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV202404 dV2 = (DataV202404)data.getSubData() ; |
| | | DataCd960XVo cdData = new DataCd960XVo() ; |
| | | dV2.subData = cdData ; |
| | | if(bs[ProtocolConstantV206V202404.UG_dataIndex] == (byte)0x00){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd960XVo; |
| | | import com.dy.common.mw.protocol.rtuState.UpgradeStateInfo; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/11/4 10:58 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV202404.cd_9602 |
| | | }) |
| | | public class Cd_9602_Up implements CodeParse { |
| | | |
| | | private static final Logger log = LogManager.getLogger(Cd_9602_Up.class); |
| | | |
| | | /** |
| | | * åæä¸è¡æ°æ® |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen4Ug(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("\nåæå½ä»¤åºçæ°æ®<" + CodeV202404.getCodeName(para.upCode) + " RTUå°å=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.upCode = para.upCode ;//ä¸è¡æ°æ®ä¸çåè½ç |
| | | midRs.upHex = para.upHex ;//ä¸è¡æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | | DataCd960XVo subData = (DataCd960XVo)((DataV202404)para.data.getSubData()).subData ; |
| | | callback.notify(new UpgradeStateInfo(subData.success)); |
| | | } |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | | * @param bs åèæ°ç» |
| | | * @param bsLen åèé¿åº¦ï¼æ»å
é¿ï¼å
æ¬å
头åå
å°¾ï¼ |
| | | * @param dataCode åè½ç |
| | | * @param data æ°æ® |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV202404 dV2 = (DataV202404)data.getSubData() ; |
| | | DataCd960XVo cdData = new DataCd960XVo() ; |
| | | dV2.subData = cdData ; |
| | | if(bs[ProtocolConstantV206V202404.UG_dataIndex] == (byte)0x00){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd960XVo; |
| | | import com.dy.common.mw.protocol.rtuState.UpgradeStateInfo; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/11/4 10:58 |
| | | * @Description |
| | | */ |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV202404.cd_9603 |
| | | }) |
| | | public class Cd_9603_Up implements CodeParse { |
| | | |
| | | private static final Logger log = LogManager.getLogger(Cd_9603_Up.class); |
| | | |
| | | /** |
| | | * åæä¸è¡æ°æ® |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen4Ug(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("\nåæå½ä»¤åºçæ°æ®<" + CodeV202404.getCodeName(para.upCode) + " RTUå°å=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.protocolVersion = para.protocolVersion; //åè®®çæ¬å· |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtuå°å |
| | | midRs.upCode = para.upCode ;//ä¸è¡æ°æ®ä¸çåè½ç |
| | | midRs.upHex = para.upHex ;//ä¸è¡æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | | DataCd960XVo subData = (DataCd960XVo)((DataV202404)para.data.getSubData()).subData ; |
| | | callback.notify(new UpgradeStateInfo(subData.success)); |
| | | } |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | | * @param bs åèæ°ç» |
| | | * @param bsLen åèé¿åº¦ï¼æ»å
é¿ï¼å
æ¬å
头åå
å°¾ï¼ |
| | | * @param dataCode åè½ç |
| | | * @param data æ°æ® |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV202404 dV2 = (DataV202404)data.getSubData() ; |
| | | DataCd960XVo cdData = new DataCd960XVo() ; |
| | | dV2.subData = cdData ; |
| | | if(bs[ProtocolConstantV206V202404.UG_dataIndex] == (byte)0x00){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V2.upVos.DataCd83CloseVo; |
| | | import com.dy.common.mw.protocol.p206V2.upVos.DataCd83OpenVo; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCdC2Vo; |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; |
| | | int bsLen = new CommonV202404().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.parse.global; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.mw.protocol.p206V202404.CommonV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.CRC8_for_2_0; |
| | | import com.dy.common.util.DateTime; |
| | | import com.dy.common.util.*; |
| | | |
| | | public class GlCreate { |
| | | /** |
| | |
| | | |
| | | Integer rtuAddr2Int = Integer.parseInt(rtuAddr2) ; |
| | | ByteUtilUnsigned.short2Bytes_LE(bs, rtuAddr2Int.shortValue(), index); |
| | | } |
| | | /** |
| | | * 为å级åè®® |
| | | * @param rtuAddr |
| | | * @param bs |
| | | * @param index |
| | | * @throws Exception |
| | | */ |
| | | public static void createRtuAddr4PUg(String rtuAddr, byte[] bs, int index) throws Exception { |
| | | ByteUtil.string2BCD_BE(bs, rtuAddr, index) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | return bytes ; |
| | | } |
| | | |
| | | public static byte[] createCrcTail4Ug(byte[] bsNoTail) throws Exception { |
| | | int crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ; |
| | | byte[] bytes = new byte[ProtocolConstantV206V2.UG_lenTail] ; |
| | | ByteUtilUnsigned.short2Bytes_BE(bytes, crc, 0); |
| | | bytes[2] = ProtocolConstantV206V2.P_Tail_Byte ; |
| | | return bytes ; |
| | | } |
| | | |
| | | public static void main(String[] args)throws Exception{ |
| | | byte[] bs = new byte[6] ; |
| | | createTp(bs, 0) ; |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.upVos; |
| | | |
| | | import com.dy.common.mw.protocol.UpDataVo; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/11/4 11:14 |
| | | * @Description |
| | | */ |
| | | public class DataCd960XVo implements UpDataVo { |
| | | public boolean success; |
| | | |
| | | public String toString(){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append(" å级åºç:\n"); |
| | | sb.append(" ç»æï¼"); |
| | | sb.append(success?"æ£ç¡®":"é误"); |
| | | sb.append("\n"); |
| | | |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | } |
| | |
| | | public void sessionOpened(IoSession session) throws Exception { |
| | | log.info("ç½ç»è¿æ¥å»ºç«ï¼ç»ç«¯ç½åæ¯ï¼" + session.getRemoteAddress().toString()) ; |
| | | if(session != null) { |
| | | String rtuAddr = (String) session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey); |
| | | String rtuAddr = (String) session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr); |
| | | if(rtuAddr != null && !rtuAddr.trim().equals("")){ |
| | | RtuLogDealer.log(rtuAddr, "ç½ç»æ¥å
¥"); |
| | | } |
| | |
| | | @Override |
| | | public void sessionClosed(IoSession session) throws Exception { |
| | | if(session != null){ |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr) ; |
| | | |
| | | if(rtuAddr != null && !rtuAddr.trim().equals("")){ |
| | | //è®°å½ç¶æ |
| | |
| | | */ |
| | | public void exceptionCaught(IoSession session, Throwable cause) throws Exception { |
| | | if(session != null && cause != null){ |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr) ; |
| | | log.error("ç½ç»ä¼è¯åçå¼å¸¸ï¼" |
| | | + (rtuAddr==null?"":("ç»ç«¯å°åæ¯ï¼" + rtuAddr)) |
| | | + (session==null?"":(session.getRemoteAddress() != null?("ï¼ç»ç«¯ç½åæ¯ï¼" + session.getRemoteAddress().toString()):"")) |
| | |
| | | * TCPééåé宿°æ®åï¼åè°çæ¹æ³ï¼è¿è¡åç»æ°æ®å¤ç |
| | | */ |
| | | public void messageSended(IoSession session, Object message) throws Exception { |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr) ; |
| | | log.info("ç½ç»åéäºæ°æ®ï¼" |
| | | + (rtuAddr==null?"":("ç»ç«¯å°åæ¯ï¼" + rtuAddr)) |
| | | + (session==null?"":(session.getRemoteAddress() != null?("ï¼ç»ç«¯ç½åæ¯ï¼" + session.getRemoteAddress().toString()):"")) ); |
| | |
| | | public class TcpSession { |
| | | |
| | | public IoSession ioSession ;//IoSession对象 |
| | | public String protocolName ;//éä¿¡åè®®åç§° |
| | | public Short protocolVersion ;//éä¿¡åè®®çæ¬å· |
| | | // public String protocolName ;//éä¿¡åè®®åç§° |
| | | // public Short protocolVersion ;//éä¿¡åè®®çæ¬å· |
| | | public Long lastDownComTime ;//䏿¬¡ä¸åå½ä»¤æ¶å»(æ¯«ç§æ¶å» System.currentTimeMillis()) |
| | | public Long lastUpDataTime ;//䏿¬¡æ¶å°ä¸è¡æ°æ®æ¶å»(æ¯«ç§æ¶å» System.currentTimeMillis()) |
| | | public Long lastUpDataTimeForOnlineCtrl ;//䏿¬¡æ¶å°ä¸è¡æ°æ®æ¶å»(æ¯«ç§æ¶å» System.currentTimeMillis())ï¼ç¨äºä¸çº¿æ
嵿§å¶ |
| | |
| | | import java.util.*; |
| | | import java.util.Map.Entry; |
| | | |
| | | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; |
| | | import org.apache.mina.core.session.IoSession; |
| | | |
| | | import com.dy.rtuMw.server.ServerProperties; |
| | |
| | | /** |
| | | * å å
¥æ°çIoSession |
| | | * @param rtuAddr |
| | | * @param protocolName |
| | | * @param ioSession |
| | | */ |
| | | public static void putNewTcpSession(String rtuAddr, String protocolName, Short protocolVersion, IoSession ioSession){ |
| | | //public static void putNewTcpSession(String rtuAddr, String protocolName, Short protocolVersion, IoSession ioSession){ |
| | | public static void putNewTcpSession(String rtuAddr, IoSession ioSession){ |
| | | synchronized (map){ |
| | | TcpSession tcpSe = map.get(rtuAddr) ; |
| | | if(tcpSe == null){ |
| | | tcpSe = new TcpSession() ; |
| | | tcpSe.protocolName = protocolName ; |
| | | tcpSe.protocolVersion = protocolVersion ; |
| | | //tcpSe.protocolName = protocolName ; |
| | | //tcpSe.protocolVersion = protocolVersion ; |
| | | tcpSe.ioSession = ioSession ; |
| | | map.put(rtuAddr, tcpSe) ; |
| | | }else{ |
| | |
| | | * æ´æ°IoSession对åºçrtuAddr |
| | | * @param oldRtuAddr |
| | | * @param newRtuAddr |
| | | * @param protocolName |
| | | * @param protocolVersion |
| | | * @param ioSession |
| | | */ |
| | | public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, String protocolName, Short protocolVersion, IoSession ioSession){ |
| | | //public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, String protocolName, Short protocolVersion, IoSession ioSession){ |
| | | public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, IoSession ioSession){ |
| | | if(oldRtuAddr != null && newRtuAddr != null && !oldRtuAddr.equals(newRtuAddr)){ |
| | | synchronized (map){ |
| | | TcpSession tcpSe = map.get(oldRtuAddr) ; |
| | | if(tcpSe == null){ |
| | | putNewTcpSession(newRtuAddr, protocolName, protocolVersion, ioSession) ; |
| | | putNewTcpSession(newRtuAddr, ioSession) ; |
| | | }else{ |
| | | map.remove(oldRtuAddr) ; |
| | | map.put(newRtuAddr, tcpSe) ; |
| | |
| | | * å¾å°Tcpéä¿¡åè®®åç§° |
| | | * @param rtuAddr |
| | | * @return |
| | | |
| | | public static String getTcpProtocolName(String rtuAddr){ |
| | | TcpSession tcpSe = sessionTable.get(rtuAddr) ; |
| | | if(tcpSe != null){ |
| | |
| | | * å¾å°Tcpéä¿¡åè®®åç§° |
| | | * @param rtuAddr |
| | | * @return |
| | | */ |
| | | * */ |
| | | public static Object[] getTcpProtocolNameVersion(String rtuAddr){ |
| | | TcpSession tcpSe = map.get(rtuAddr) ; |
| | | if(tcpSe != null){ |
| | | return new Object[]{tcpSe.protocolName, tcpSe.protocolVersion}; |
| | | return new Object[]{ |
| | | tcpSe.ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName), |
| | | tcpSe.ioSession.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion)}; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¾å°ææå¨çº¿ä¸ç¦»çº¿æ°éç»è®¡ |
| | | * @return [0]=å¨çº¿æ°éï¼[2]ä¸çº¿è¿ï¼ä½å½åç¦»çº¿çæ°é |
| | |
| | | TcpSession tcpSe = sessionTable.get(rtuAddr) ; |
| | | if(tcpSe == null){ |
| | | tcpSe = new TcpSession() ; |
| | | tcpSe.protocolName = protocolName ; |
| | | tcpSe.ioSession = ioSession ; |
| | | sessionTable.put(rtuAddr, tcpSe) ; |
| | | }else{ |
| | |
| | | return sessionTable.get(rtuAddr) ; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°Tcpéä¿¡åè®®åç§° |
| | | * @param rtuAddr |
| | | * @return |
| | | */ |
| | | public static String getTcpProtocolName(String rtuAddr){ |
| | | TcpSession tcpSe = sessionTable.get(rtuAddr) ; |
| | | if(tcpSe != null){ |
| | | return tcpSe.protocolName ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¾å°ææå¨çº¿æ
åµ |
| | | * @return |
| | |
| | | e.printStackTrace(); |
| | | log.error("å°æ°æ®è½¬æ¢ä¸ºåå
è¿å¶æ¶åºéï¼" ) ; |
| | | } |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | String protocolName = null ; |
| | | Short protocolVersion = null ; |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr) ; |
| | | String protocolName = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolName) ; |
| | | Short protocolVersion = (Short)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrProtocolVersion) ; |
| | | boolean isOnLine = false ; |
| | | if(rtuAddr == null){ |
| | | //说æå建ç«ç½ç»è¿æ¥ï¼æ¤æ°æ®åºè¯¥æ¯ä¸çº¿æ°æ® |
| | |
| | | protocolName = (String)rtuAddrProtocolNameVersion[1] ; |
| | | protocolVersion = (Short)rtuAddrProtocolNameVersion[2] ; |
| | | |
| | | if(rtuAddr != null && protocolName != null){ |
| | | if(rtuAddr != null && protocolName != null && protocolVersion != null){ |
| | | //设置sessionç屿§ID |
| | | TcpUnit.getInstance().setIoSessionArrId(session, rtuAddr); |
| | | TcpUnit.getInstance().setIoSessionArrs(session, rtuAddr, protocolName, protocolVersion) ; |
| | | //ç¼åsession |
| | | TcpSessionCache.putNewTcpSession(rtuAddr, protocolName, protocolVersion, session); |
| | | TcpSessionCache.putNewTcpSession(rtuAddr, session); |
| | | |
| | | log.info("RTU(å°åï¼" + rtuAddr + "ï¼åè®®ï¼" + protocolName + "ï¼åè®®çæ¬å·ï¼" + protocolVersion + ")ä¸çº¿äºã") ; |
| | | log.info("RTU(å°åï¼" + rtuAddr + "ï¼åè®®ï¼" + protocolName + "ï¼çæ¬å·ï¼" + protocolVersion + ")ä¸çº¿äºã") ; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | if(toDeal){ |
| | | /* |
| | | if(protocolName == null){ |
| | | Object[] objs = TcpSessionCache.getTcpProtocolNameVersion(rtuAddr) ; |
| | | protocolName = (String)objs[0] ; |
| | | protocolVersion = (Short)objs[1] ; |
| | | } |
| | | */ |
| | | |
| | | //设置æ¶å°æ°æ®æ¶å» |
| | | TcpSessionCache.cacheUpDataTime(rtuAddr); |
| | |
| | | boolean isOnLine, |
| | | byte[] upBuf, |
| | | String upHex) throws Exception{ |
| | | Driver dri = ProtocolCache.getDriver(protocolName) ; |
| | | Driver dri = ProtocolCache.getDriver(protocolName, protocolVersion) ; |
| | | if(dri == null){ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°åè®®" + protocolName + "驱å¨ç±»å®ä¾ï¼"); |
| | | }else{ |
| | |
| | | //æ´æ°ç»ç«¯ç¶æ |
| | | if(rtuAddrInData != null && !rtuAddrInData.equals(rtuAddrAtHead)){ |
| | | //æ°æ®å¤´ä¸çRTUå°å䏿°æ®ä¸çRTUå°åä¸ä¸è´ï¼æ´æ¢ææ°æ®ä¸çRTUå°å |
| | | TcpSessionCache.changeRtuAddr(rtuAddrAtHead, rtuAddrInData, protocolName, protocolVersion, session); |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey, rtuAddrInData) ; |
| | | TcpSessionCache.changeRtuAddr(rtuAddrAtHead, rtuAddrInData, session); |
| | | session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrRtuAddr, rtuAddrInData) ; |
| | | } |
| | | |
| | | String rtuAddr ; |
| | |
| | | Object[] objs = TcpSessionCache.getTcpProtocolNameVersion(rtuAddr) ; |
| | | if(objs == null || objs.length == 0 || objs[0] == null){ |
| | | //RTUæªæ¾ä¸çº¿ |
| | | /* 2024-11-02 å¢å äºåè®®çæ¬å·ï¼ä¸ä¸ä¸ªåè®®å¯ä»¥æå¤ä¸ªçæ¬å·ï¼æä»¥ä¸é¢å¾å°å¯ä¸å议驱å¨å®ç°æ¹å¼ä¸å¯ç¨äºï¼å 为确å®ä¸äºçæ¬å· |
| | | int count = ProtocolCache.driverCount() ; |
| | | if(count == 1){ |
| | | //åªæä¸ä¸ªåè®® |
| | | dri = ProtocolCache.getFirstDriver() ; |
| | | } |
| | | */ |
| | | }else{ |
| | | String protocolName = (String)objs[0]; |
| | | com.protocolVersion = (Short)objs[1]; |
| | | dri = ProtocolCache.getDriver(protocolName) ; |
| | | if(dri == null){ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°åè®®" + protocolName + "驱å¨ç±»å®ä¾ï¼"); |
| | | }else{ |
| | | MidResult[] actions = dri.createCommand(ServerProperties.isLowPower, com) ; |
| | | log.info("ä¸åè¿ç¨å½ä»¤" + com.getCode() + "ç±åè®®é©±å¨æé 宿"); |
| | | if(actions != null){ |
| | | for(MidResult act : actions){ |
| | | act.action(); |
| | | } |
| | | dri = ProtocolCache.getDriver(protocolName, com.protocolVersion) ; |
| | | } |
| | | if(dri == null){ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°RTU(" + rtuAddr + ")驱å¨ç±»å®ä¾ï¼"); |
| | | }else{ |
| | | MidResult[] actions = dri.createCommand(ServerProperties.isLowPower, com) ; |
| | | log.info("ä¸åè¿ç¨å½ä»¤" + com.getCode() + "ç±åè®®é©±å¨æé 宿"); |
| | | if(actions != null){ |
| | | for(MidResult act : actions){ |
| | | act.action(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | | noOneRtuUpgradeMaxDuration="1200" |
| | | failTryTimes="2" |
| | | ugMaxRtuAtOnce="5000" |
| | | rtuOffLineWaitDuration="1800" |
| | | notifyStateInterval="2" |
| | | /> |
| | | |
| | |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | | noOneRtuUpgradeMaxDuration="1200" |
| | | failTryTimes="2" |
| | | ugMaxRtuAtOnce="5000" |
| | | rtuOffLineWaitDuration="1800" |
| | | notifyStateInterval="2" |
| | | /> |
| | | |
| | |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | | noOneRtuUpgradeMaxDuration="1200" |
| | | failTryTimes="2" |
| | | ugMaxRtuAtOnce="5000" |
| | | rtuOffLineWaitDuration="1800" |
| | | notifyStateInterval="2" |
| | | /> |
| | | |
| | |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="1200" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | failTryTimes="2" |
| | | ugMaxRtuAtOnce="5000" |
| | | rtuOffLineWaitDuration="1800" |
| | | notifyStateInterval="2" |
| | | /> |
| | |
| | | |
| | | 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 ; |
| | | } |
| | | } |
| | | if(args.length == 1){ |
| | | getArg0(args) ; |
| | | }else if(args.length == 2){ |
| | | getArg0(args) ; |
| | | getArg1(args) ; |
| | | }else if(args.length == 3){ |
| | | getArg0(args) ; |
| | | getArg1(args) ; |
| | | getArg2(args) ; |
| | | }else if(args.length == 4){ |
| | | getArg0(args) ; |
| | | getArg1(args) ; |
| | | getArg2(args) ; |
| | | getArg3(args) ; |
| | | }else if(args.length == 5){ |
| | | getArg0(args) ; |
| | | getArg1(args) ; |
| | | getArg2(args) ; |
| | | getArg3(args) ; |
| | | getArg4(args) ; |
| | | } |
| | | |
| | | if(ServerProperties.argOneDie && ServerProperties.argMultiDie){ |
| | | ServerProperties.argOneDie = false ; |
| | | } |
| | | } |
| | | new SpringApplicationBuilder(PipIrrMwSimulateRtuApplication.class) |
| | | .web(WebApplicationType.NONE)//ä¸å¯å¨webæå¡ |
| | | .run(args); |
| | | } |
| | | private static void getArg0(String[] args){ |
| | | if(args[0] instanceof String){ |
| | | if(args[0] != null && !args[0].trim().equals("")){ |
| | | String rtuAddr = (String)args[0] ;//æ¬æ¨¡æå¨æ¨¡æRTUå°å |
| | | ServerProperties.argRtuAddr = rtuAddr ; |
| | | } |
| | | } |
| | | } |
| | | private static void getArg1(String[] args){ |
| | | if(args[1] != null && !args[1].trim().equals("")){ |
| | | Integer oneDie = Integer.parseInt(args[1]) ;//ä¸å
æ»ï¼1æ¯ï¼0å¦ |
| | | ServerProperties.argOneDie = oneDie == 1?true:false ; |
| | | } |
| | | } |
| | | private static void getArg2(String[] args){ |
| | | if(args[2] != null && !args[2].trim().equals("")){ |
| | | Integer multiDie = Integer.parseInt(args[2]) ;//å¤å
æ»ï¼1æ¯ï¼0å¦ |
| | | ServerProperties.argMultiDie = multiDie == 1?true:false ; |
| | | } |
| | | } |
| | | private static void getArg3(String[] args){ |
| | | if(args[3] instanceof String){ |
| | | if(args[3] != null && !args[3].trim().equals("")){ |
| | | String serverIp = (String)args[3] ;//æå¡ç«¯IP |
| | | ServerProperties.serverIp = serverIp ; |
| | | } |
| | | } |
| | | } |
| | | private static void getArg4(String[] args){ |
| | | if(args[4] != null && !args[4].trim().equals("")){ |
| | | Integer serverPort = Integer.parseInt(args[4]) ;//æå¡ç«¯port |
| | | ServerProperties.serverPort = serverPort ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Spring容å¨å¯å¨å®æåï¼æ§è¡ä¸é¢æ¹æ³ |
| | |
| | | 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) ; |
| | |
| | | // /////////////// |
| | | // TCP 模å |
| | | TcpClUnitConfigVo tcpVo = new TcpClUnitConfigVo(); |
| | | tcpVo.mwServerIp = conf.getSetAttrTxt(doc, "config.tcpCl", "mwServerIp", null, false, null); |
| | | tcpVo.mwServerPort = conf.getSetAttrPlusInt(doc, "config.tcpCl", "mwServerPort", null, 100, 65535, null); |
| | | if(ServerProperties.serverIp != null && !ServerProperties.serverIp.trim().equals("")){ |
| | | tcpVo.mwServerIp = ServerProperties.serverIp ; |
| | | }else{ |
| | | tcpVo.mwServerIp = conf.getSetAttrTxt(doc, "config.tcpCl", "mwServerIp", null, false, null); |
| | | } |
| | | if(ServerProperties.serverPort != null){ |
| | | tcpVo.mwServerPort = ServerProperties.serverPort ; |
| | | }else{ |
| | | tcpVo.mwServerPort = conf.getSetAttrPlusInt(doc, "config.tcpCl", "mwServerPort", null, 100, 65535, null); |
| | | } |
| | | tcpVo.connectTimeout = conf.getSetAttrPlusInt(doc, "config.tcpCl", "connectTimeout", null, 1000, 10000, null); |
| | | this.mwServerUrl = tcpVo.mwServerIp + ":" + tcpVo.mwServerPort ; |
| | | AdapterImp_TcpClUnit tcpAdap = new AdapterImp_TcpClUnit(); |
| | |
| | | public static Boolean argOneDie = false ; |
| | | public static Boolean argMultiDie = false ; |
| | | |
| | | public static String serverIp ; |
| | | public static Integer serverPort ; |
| | | |
| | | } |
| | |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <RollingFile name="File" fileName="logs/simRtu.log" filePattern="logs/simRtu-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/> |
| | |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <!-- |
| | | fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz" |
| | |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <!-- |
| | | fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz" |
| | |
| | | <Configuration status="OFF"> |
| | | <Appenders> |
| | | <Console name="Console" target="SYSTEM_OUT"> |
| | | <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/> |
| | | </Console> |
| | | <!-- |
| | | fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz" |