commit b6bb923b6ec6dda7bf26818077cbb6bf47a798ea Author: liuhanqing Date: Wed Dec 10 10:02:43 2025 +0800 项目åˆ�å§‹ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d491011 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# idea +/.idea/ +**/target/ +**/out/ + +/log/ diff --git a/465wcs-master.iml b/465wcs-master.iml new file mode 100644 index 0000000..edf826c --- /dev/null +++ b/465wcs-master.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FT465-WCS.iml b/FT465-WCS.iml new file mode 100644 index 0000000..fb8e866 --- /dev/null +++ b/FT465-WCS.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/WCS.iml b/WCS.iml new file mode 100644 index 0000000..011fdee --- /dev/null +++ b/WCS.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/images/0.jpg b/images/0.jpg new file mode 100644 index 0000000..da49dc9 Binary files /dev/null and b/images/0.jpg differ diff --git a/images/1.gif b/images/1.gif new file mode 100644 index 0000000..5dda508 Binary files /dev/null and b/images/1.gif differ diff --git a/images/11.gif b/images/11.gif new file mode 100644 index 0000000..957260f Binary files /dev/null and b/images/11.gif differ diff --git a/images/12.gif b/images/12.gif new file mode 100644 index 0000000..9b27448 Binary files /dev/null and b/images/12.gif differ diff --git a/images/a.gif b/images/a.gif new file mode 100644 index 0000000..a6e3b77 Binary files /dev/null and b/images/a.gif differ diff --git a/images/calendar.jpg b/images/calendar.jpg new file mode 100644 index 0000000..4baf8c5 Binary files /dev/null and b/images/calendar.jpg differ diff --git a/images/excel.gif b/images/excel.gif new file mode 100644 index 0000000..3bde70b Binary files /dev/null and b/images/excel.gif differ diff --git a/images/his.gif b/images/his.gif new file mode 100644 index 0000000..5499d98 Binary files /dev/null and b/images/his.gif differ diff --git a/images/login.gif b/images/login.gif new file mode 100644 index 0000000..7cf798c Binary files /dev/null and b/images/login.gif differ diff --git a/images/mar.gif b/images/mar.gif new file mode 100644 index 0000000..d92c432 Binary files /dev/null and b/images/mar.gif differ diff --git a/images/now.gif b/images/now.gif new file mode 100644 index 0000000..d4b18a5 Binary files /dev/null and b/images/now.gif differ diff --git a/images/tr.gif b/images/tr.gif new file mode 100644 index 0000000..3fd6c20 Binary files /dev/null and b/images/tr.gif differ diff --git a/images/任务查询.gif b/images/任务查询.gif new file mode 100644 index 0000000..7650c71 Binary files /dev/null and b/images/任务查询.gif differ diff --git a/images/作业查询.gif b/images/作业查询.gif new file mode 100644 index 0000000..b051803 Binary files /dev/null and b/images/作业查询.gif differ diff --git a/images/堆垛机.gif b/images/堆垛机.gif new file mode 100644 index 0000000..b57fad2 Binary files /dev/null and b/images/堆垛机.gif differ diff --git a/images/å°�车.gif b/images/å°�车.gif new file mode 100644 index 0000000..f14f92b Binary files /dev/null and b/images/å°�车.gif differ diff --git a/images/红.gif b/images/红.gif new file mode 100644 index 0000000..1a992ae Binary files /dev/null and b/images/红.gif differ diff --git a/images/红22.gif b/images/红22.gif new file mode 100644 index 0000000..58a90ff Binary files /dev/null and b/images/红22.gif differ diff --git a/images/红22.jpg b/images/红22.jpg new file mode 100644 index 0000000..5b47694 Binary files /dev/null and b/images/红22.jpg differ diff --git a/images/红23.gif b/images/红23.gif new file mode 100644 index 0000000..67e92d6 Binary files /dev/null and b/images/红23.gif differ diff --git a/images/红25.gif b/images/红25.gif new file mode 100644 index 0000000..0906e98 Binary files /dev/null and b/images/红25.gif differ diff --git a/images/绿.gif b/images/绿.gif new file mode 100644 index 0000000..48d618b Binary files /dev/null and b/images/绿.gif differ diff --git a/images/绿23.gif b/images/绿23.gif new file mode 100644 index 0000000..b70a6e3 Binary files /dev/null and b/images/绿23.gif differ diff --git a/images/绿23.jpg b/images/绿23.jpg new file mode 100644 index 0000000..251bf55 Binary files /dev/null and b/images/绿23.jpg differ diff --git a/images/绿24.gif b/images/绿24.gif new file mode 100644 index 0000000..4e1bd23 Binary files /dev/null and b/images/绿24.gif differ diff --git a/images/绿25.gif b/images/绿25.gif new file mode 100644 index 0000000..ddadb26 Binary files /dev/null and b/images/绿25.gif differ diff --git a/images/设备监控.gif b/images/设备监控.gif new file mode 100644 index 0000000..9af5a6d Binary files /dev/null and b/images/设备监控.gif differ diff --git a/images/调度æ“�作.gif b/images/调度æ“�作.gif new file mode 100644 index 0000000..1ecbe02 Binary files /dev/null and b/images/调度æ“�作.gif differ diff --git a/images/调度日志.gif b/images/调度日志.gif new file mode 100644 index 0000000..55d1a76 Binary files /dev/null and b/images/调度日志.gif differ diff --git a/images/黄.gif b/images/黄.gif new file mode 100644 index 0000000..8ac7847 Binary files /dev/null and b/images/黄.gif differ diff --git a/images/黄25.gif b/images/黄25.gif new file mode 100644 index 0000000..eaa46ea Binary files /dev/null and b/images/黄25.gif differ diff --git a/images/黄25.jpg b/images/黄25.jpg new file mode 100644 index 0000000..5e82e78 Binary files /dev/null and b/images/黄25.jpg differ diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ed20214 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.wms.dss.ats.customs.abb.form.ABBMainFrame + diff --git a/src/com/wms/dss/ats/customs/abb/common/Constant.java b/src/com/wms/dss/ats/customs/abb/common/Constant.java new file mode 100644 index 0000000..c36b442 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/common/Constant.java @@ -0,0 +1,18 @@ +package com.wms.dss.ats.customs.abb.common; + +/* +* 使用的常é‡� +* */ +public class Constant { + + /* + * 视频盘点库在的ç»�对路径 + * */ + //public static final String VIDEO_LIB_PATH = "E:\\rj\\wcs410\\HCNetSDK\\HCNetSDK.dll"; + public static final String VIDEO_LIB_PATH = "C:\\Program Files\\HCNetSDK\\HCNetSDK.dll"; + + + + + +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.hbm.xml new file mode 100644 index 0000000..c094eb7 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.hbm.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.java b/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.java new file mode 100644 index 0000000..cb9866d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/BasFaultRecord.java @@ -0,0 +1,87 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class BasFaultRecord { + private String id; + private String deviceId; + private String deviceName; + + private String deviceType; + private String taskNo; + private String jobId; + private String fault; + private String startTime; + private String finishTime; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getTaskNo() { + return taskNo; + } + + public void setTaskNo(String taskNo) { + this.taskNo = taskNo; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getFault() { + return fault; + } + + public void setFault(String fault) { + this.fault = fault; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.hbm.xml new file mode 100644 index 0000000..d938492 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.hbm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.java b/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.java new file mode 100644 index 0000000..bca4a21 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/BasRollerBed.java @@ -0,0 +1,94 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class BasRollerBed { + + private String equCode; + + private Integer equStatus; + + private String yp; + + private String yl; + + private String yc; + + private String standby1; + + private String standby2; + + private String standby3; + + private String standby4; + + public String getEquCode() { + return equCode; + } + + public void setEquCode(String equCode) { + this.equCode = equCode; + } + + public Integer getEquStatus() { + return equStatus; + } + + public void setEquStatus(Integer equStatus) { + this.equStatus = equStatus; + } + + public String getYp() { + return yp; + } + + public void setYp(String yp) { + this.yp = yp; + } + + public String getYl() { + return yl; + } + + public void setYl(String yl) { + this.yl = yl; + } + + public String getYc() { + return yc; + } + + public void setYc(String yc) { + this.yc = yc; + } + + public String getStandby1() { + return standby1; + } + + public void setStandby1(String standby1) { + this.standby1 = standby1; + } + + public String getStandby2() { + return standby2; + } + + public void setStandby2(String standby2) { + this.standby2 = standby2; + } + + public String getStandby3() { + return standby3; + } + + public void setStandby3(String standby3) { + this.standby3 = standby3; + } + + public String getStandby4() { + return standby4; + } + + public void setStandby4(String standby4) { + this.standby4 = standby4; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device.java b/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device.java new file mode 100644 index 0000000..087cb61 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device.java @@ -0,0 +1,54 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class DDJ_Device { + + public byte btId;// DDjid + public String dtype;// ÀàÐÍ + public String dName; + + public int CZFS;// ²Ù×÷·½Ê½0δ֪1δѡÔñ2ÊÖ¶¯3°ë×Ô¶¯4µ¥»ú×Ô¶¯5Áª»ú + public int SBZT;// É豸״̬0´ý»ú1ÕýÔÚÖ´ÐÐ2 ÆäËû±àºÅ¼û¹ÊÕÏ´úÂë±í + public long ZXRWH;// ÕýÔÚÖ´ÐÐÈÎÎñºÅ + public int HCZT;// »õ²æ×´Ì¬0ÎÞ»õ1Óлõ + public int ZXJD;// Ö´Ðн׶Î1È¡»õÐÐ×ß2È¡»õ3·Å»õÐÐ×ß4·Å»õ5Íê³É + public int DQP;// µ±Ç°ÅÅ + public int DQL;// µ±Ç°ÁÐ + public int DQC;// µ±Ç°²ã + public int MBPH;// Ä¿±êÅÅ + public int MBLH;// Ä¿±êÁÐ + public int MBCH;// Ä¿±ê²ã + public int YXXF;// ÔÊÐíÏ·¢1ÔÊÐí + public int XTXH; + public String trayCode; + + public DDJ_Device() { + super(); + } + + public DDJ_Device(byte btId, String dtype) { + super(); + this.btId = btId; + this.dtype = dtype; + } + + @Override + public String toString() { + return "DDJDevice{" + + "btId=" + btId + + ", dtype='" + dtype + '\'' + + ", CZFS=" + CZFS + + ", SBZT=" + SBZT + + ", ZXRWH=" + ZXRWH + + ", HCZT=" + HCZT + + ", ZXJD=" + ZXJD + + ", DQP=" + DQP + + ", DQL=" + DQL + + ", DQC=" + DQC + + ", MBPH=" + MBPH + + ", MBLH=" + MBLH + + ", MBCH=" + MBCH + + ", YXXF=" + YXXF + + ", trayCode=" + trayCode + + '}'; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device_2.java b/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device_2.java new file mode 100644 index 0000000..e82fc63 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/DDJ_Device_2.java @@ -0,0 +1,52 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class DDJ_Device_2 { + + public int YXXF_2; + public byte btId;// DDjid + public String dtype;// ÀàÐÍ + public String dName; + + public int CZFS;// ²Ù×÷·½Ê½0δ֪1δѡÔñ2ÊÖ¶¯3°ë×Ô¶¯4µ¥»ú×Ô¶¯5Áª»ú + public int SBZT;// É豸״̬0´ý»ú1ÕýÔÚÖ´ÐÐ2 ÆäËû±àºÅ¼û¹ÊÕÏ´úÂë±í + public long ZXRWH_1;// ÕýÔÚÖ´ÐÐÈÎÎñºÅ + public int HCZT;// »õ²æ×´Ì¬0ÎÞ»õ1Óлõ + public int ZXJD;// Ö´Ðн׶Î1È¡»õÐÐ×ß2È¡»õ3·Å»õÐÐ×ß4·Å»õ5Íê³É + public int DQP;// µ±Ç°ÅÅ + public int DQL;// µ±Ç°ÁÐ + public int DQC;// µ±Ç°²ã + public int MBPH;// Ä¿±êÅÅ + public int MBLH;// Ä¿±êÁÐ + public int MBCH;// Ä¿±ê²ã + public int YXXF;// ÔÊÐíÏ·¢1ÔÊÐí + public long ZXRWH_2;// ÕýÔÚÖ´ÐÐÈÎÎñºÅ + public int ZXJD_2;// Ö´Ðн׶Î1È¡»õÐÐ×ß2È¡»õ3·Å»õÐÐ×ß4·Å»õ5Íê³É + public int XTXH; + public String trayCode; + + public DDJ_Device_2() { + super(); + } + + public DDJ_Device_2(byte btId, String dtype) { + super(); + this.btId = btId; + this.dtype = dtype; + } + + @Override + public String toString() { + return "DDJ_Device_2{" + + "btId=" + btId + + ", dtype='" + dtype + '\'' + + ", dName='" + dName + '\'' + + ", CZFS=" + CZFS + + ", SBZT=" + SBZT + + ", ZXRWH_1=" + ZXRWH_1 + + ", ZXRWH_2=" + ZXRWH_2 + + ", ZXJD_2=" + ZXJD_2 + + ", XTXH=" + XTXH + + ", trayCode='" + trayCode + '\'' + + '}'; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/End.java b/src/com/wms/dss/ats/customs/abb/entity/End.java new file mode 100644 index 0000000..4dbcd34 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/End.java @@ -0,0 +1,27 @@ +package com.wms.dss.ats.customs.abb.entity; + +import java.util.Date; + +public class End { + + public Date finishTime; + + private Integer id; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.hbm.xml new file mode 100644 index 0000000..1ed1e4e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.hbm.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.java b/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.java new file mode 100644 index 0000000..8d8e734 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/ExceptionInfo.java @@ -0,0 +1,63 @@ +package com.wms.dss.ats.customs.abb.entity; + + + +import java.util.Date; + + +public class ExceptionInfo { + private Integer taskNo; + private String trayCode; + private String exceptionId; + private Date createTime; + private String sendCompleted; + private String ssjNo; + + public String getSsjNo() { + return ssjNo; + } + + public void setSsjNo(String ssjNo) { + this.ssjNo = ssjNo; + } + + public Integer getTaskNo() { + return taskNo; + } + + public void setTaskNo(Integer taskNo) { + this.taskNo = taskNo; + } + + public String getTrayCode() { + return trayCode; + } + + public void setTrayCode(String trayCode) { + this.trayCode = trayCode; + } + + public String getExceptionId() { + return exceptionId; + } + + public void setExceptionId(String exceptionId) { + this.exceptionId = exceptionId; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getSendCompleted() { + return sendCompleted; + } + + public void setSendCompleted(String sendCompleted) { + this.sendCompleted = sendCompleted; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.hbm.xml new file mode 100644 index 0000000..42e14f5 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.hbm.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.java b/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.java new file mode 100644 index 0000000..3cc79d7 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgDdj.java @@ -0,0 +1,139 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class MsgDdj { + private int id; + private String name; + private int rwh; + private int jdbz; + private int sbzt; + private int czfs; + private int yxxf; + private int yp; + private int yl; + private int yc; + private int mbp; + private int mbl; + private int mbc; + private int xtxh; + private int dqxd; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getRwh() { + return rwh; + } + + public void setRwh(int rwh) { + this.rwh = rwh; + } + + public int getJdbz() { + return jdbz; + } + + public void setJdbz(int jdbz) { + this.jdbz = jdbz; + } + + public int getSbzt() { + return sbzt; + } + + public void setSbzt(int sbzt) { + this.sbzt = sbzt; + } + + public int getCzfs() { + return czfs; + } + + public void setCzfs(int czfs) { + this.czfs = czfs; + } + + public int getYxxf() { + return yxxf; + } + + public void setYxxf(int yxxf) { + this.yxxf = yxxf; + } + + public int getYp() { + return yp; + } + + public void setYp(int yp) { + this.yp = yp; + } + + public int getYl() { + return yl; + } + + public void setYl(int yl) { + this.yl = yl; + } + + public int getYc() { + return yc; + } + + public void setYc(int yc) { + this.yc = yc; + } + + public int getMbp() { + return mbp; + } + + public void setMbp(int mbp) { + this.mbp = mbp; + } + + public int getMbl() { + return mbl; + } + + public void setMbl(int mbl) { + this.mbl = mbl; + } + + public int getMbc() { + return mbc; + } + + public void setMbc(int mbc) { + this.mbc = mbc; + } + + public int getXtxh() { + return xtxh; + } + + public void setXtxh(int xtxh) { + this.xtxh = xtxh; + } + + public int getDqxd() { + return dqxd; + } + + public void setDqxd(int dqxd) { + this.dqxd = dqxd; + } +} \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.hbm.xml new file mode 100644 index 0000000..b928c5e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.hbm.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.java b/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.java new file mode 100644 index 0000000..d32a3c6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgRkSsj.java @@ -0,0 +1,85 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class MsgRkSsj { + private String id; + private String name; + private String rwh; + private String height; + private String ckkx; + private String rkqq; + private String bjxx; + private String tpjc; + private String ljxh; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRwh() { + return rwh; + } + + public void setRwh(String rwh) { + this.rwh = rwh; + } + + public String getHeight() { + return height; + } + + public void setHeight(String height) { + this.height = height; + } + + public String getCkkx() { + return ckkx; + } + + public void setCkkx(String ckkx) { + this.ckkx = ckkx; + } + + public String getRkqq() { + return rkqq; + } + + public void setRkqq(String rkqq) { + this.rkqq = rkqq; + } + + public String getBjxx() { + return bjxx; + } + + public void setBjxx(String bjxx) { + this.bjxx = bjxx; + } + + public String getTpjc() { + return tpjc; + } + + public void setTpjc(String tpjc) { + this.tpjc = tpjc; + } + + public String getLjxh() { + return ljxh; + } + + public void setLjxh(String ljxh) { + this.ljxh = ljxh; + } +} \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.hbm.xml new file mode 100644 index 0000000..fee340c --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.hbm.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.java b/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.java new file mode 100644 index 0000000..4d494f3 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MsgXdkSsj.java @@ -0,0 +1,112 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class MsgXdkSsj { + private String id; + private String location; + private String name; + private String ckkx; + private String ckdw; + private String ckrwh; + private String rkdw; + private String rkkx; + private String rkrwh; + private String floor; + private String platoon; + private String column; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCkkx() { + return ckkx; + } + + public void setCkkx(String ckkx) { + this.ckkx = ckkx; + } + + public String getCkdw() { + return ckdw; + } + + public void setCkdw(String ckdw) { + this.ckdw = ckdw; + } + + public String getCkrwh() { + return ckrwh; + } + + public void setCkrwh(String ckrwh) { + this.ckrwh = ckrwh; + } + + public String getRkdw() { + return rkdw; + } + + public void setRkdw(String rkdw) { + this.rkdw = rkdw; + } + + public String getRkkx() { + return rkkx; + } + + public void setRkkx(String rkkx) { + this.rkkx = rkkx; + } + + public String getRkrwh() { + return rkrwh; + } + + public void setRkrwh(String rkrwh) { + this.rkrwh = rkrwh; + } + + public String getFloor() { + return floor; + } + + public void setFloor(String floor) { + this.floor = floor; + } + + public String getPlatoon() { + return platoon; + } + + public void setPlatoon(String platoon) { + this.platoon = platoon; + } + + public String getColumn() { + return column; + } + + public void setColumn(String column) { + this.column = column; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/MydoJob.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/MydoJob.hbm.xml new file mode 100644 index 0000000..f7bb553 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MydoJob.hbm.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/MydoJob.java b/src/com/wms/dss/ats/customs/abb/entity/MydoJob.java new file mode 100644 index 0000000..3014d3a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/MydoJob.java @@ -0,0 +1,332 @@ +package com.wms.dss.ats.customs.abb.entity; + +import java.sql.Timestamp; + +public class MydoJob { + private String job_id; + private String status; + private String on_line_type; + private String task_no; + private String supplier_id; + private String customer_id; + private String department_id; + private String tray_code; + private String roadway_id; + private String cargo_space_id; + private String target_roadway_id; + private String target_cargo_space_id; + private String line_id; + private String workshop_id; + private Integer priority; + private String execution_phase; + private String in_or_out; + private String create_time; + private String start_time; + private String finish_time; + private String entrance_id; + private String Exit_id; + private String class_now_name; + private String class_workshop_name; + private String classgroup_number; + private String class_workshop_date_time; + private String class_id; + private String class_now_date_time; + private String warehouse_id; + private String out_id; + private Integer site_id; + private String car_number; + private String fault_flag; + private String Dev_id; + private String stock_source; + private String floor; + + + public String getJob_id() { + return job_id; + } + + public void setJob_id(String job_id) { + this.job_id = job_id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getOn_line_type() { + return on_line_type; + } + + public void setOn_line_type(String on_line_type) { + this.on_line_type = on_line_type; + } + + public String getTask_no() { + return task_no; + } + + public void setTask_no(String task_no) { + this.task_no = task_no; + } + + public String getSupplier_id() { + return supplier_id; + } + + public void setSupplier_id(String supplier_id) { + this.supplier_id = supplier_id; + } + + public String getCustomer_id() { + return customer_id; + } + + public void setCustomer_id(String customer_id) { + this.customer_id = customer_id; + } + + public String getDepartment_id() { + return department_id; + } + + public void setDepartment_id(String department_id) { + this.department_id = department_id; + } + + public String getTray_code() { + return tray_code; + } + + public void setTray_code(String tray_code) { + this.tray_code = tray_code; + } + + public String getRoadway_id() { + return roadway_id; + } + + public void setRoadway_id(String roadway_id) { + this.roadway_id = roadway_id; + } + + public String getCargo_space_id() { + return cargo_space_id; + } + + public void setCargo_space_id(String cargo_space_id) { + this.cargo_space_id = cargo_space_id; + } + + public String getTarget_roadway_id() { + return target_roadway_id; + } + + public void setTarget_roadway_id(String target_roadway_id) { + this.target_roadway_id = target_roadway_id; + } + + public String getTarget_cargo_space_id() { + return target_cargo_space_id; + } + + public void setTarget_cargo_space_id(String target_cargo_space_id) { + this.target_cargo_space_id = target_cargo_space_id; + } + + public String getLine_id() { + return line_id; + } + + public void setLine_id(String line_id) { + this.line_id = line_id; + } + + public String getWorkshop_id() { + return workshop_id; + } + + public void setWorkshop_id(String workshop_id) { + this.workshop_id = workshop_id; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public String getExecution_phase() { + return execution_phase; + } + + public void setExecution_phase(String execution_phase) { + this.execution_phase = execution_phase; + } + + public String getIn_or_out() { + return in_or_out; + } + + public void setIn_or_out(String in_or_out) { + this.in_or_out = in_or_out; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public String getStart_time() { + return start_time; + } + + public void setStart_time(String start_time) { + this.start_time = start_time; + } + + public String getFinish_time() { + return finish_time; + } + + public void setFinish_time(String finish_time) { + this.finish_time = finish_time; + } + + public String getEntrance_id() { + return entrance_id; + } + + public void setEntrance_id(String entrance_id) { + this.entrance_id = entrance_id; + } + + public String getExit_id() { + return Exit_id; + } + + public void setExit_id(String exit_id) { + Exit_id = exit_id; + } + + public String getClass_now_name() { + return class_now_name; + } + + public void setClass_now_name(String class_now_name) { + this.class_now_name = class_now_name; + } + + public String getClass_workshop_name() { + return class_workshop_name; + } + + public void setClass_workshop_name(String class_workshop_name) { + this.class_workshop_name = class_workshop_name; + } + + public String getClassgroup_number() { + return classgroup_number; + } + + public void setClassgroup_number(String classgroup_number) { + this.classgroup_number = classgroup_number; + } + + public String getClass_workshop_date_time() { + return class_workshop_date_time; + } + + public void setClass_workshop_date_time(String class_workshop_date_time) { + this.class_workshop_date_time = class_workshop_date_time; + } + + public String getClass_id() { + return class_id; + } + + public void setClass_id(String class_id) { + this.class_id = class_id; + } + + public String getClass_now_date_time() { + return class_now_date_time; + } + + public void setClass_now_date_time(String class_now_date_time) { + this.class_now_date_time = class_now_date_time; + } + + public String getWarehouse_id() { + return warehouse_id; + } + + public void setWarehouse_id(String warehouse_id) { + this.warehouse_id = warehouse_id; + } + + public String getOut_id() { + return out_id; + } + + public void setOut_id(String out_id) { + this.out_id = out_id; + } + + public Integer getSite_id() { + return site_id; + } + + public void setSite_id(Integer site_id) { + this.site_id = site_id; + } + + public String getCar_number() { + return car_number; + } + + public void setCar_number(String car_number) { + this.car_number = car_number; + } + + public String getFault_flag() { + return fault_flag; + } + + public void setFault_flag(String fault_flag) { + this.fault_flag = fault_flag; + } + + public String getDev_id() { + return Dev_id; + } + + public void setDev_id(String dev_id) { + Dev_id = dev_id; + } + + public String getStock_source() { + return stock_source; + } + + public void setStock_source(String stock_source) { + this.stock_source = stock_source; + } + + + public String getFloor() { + return floor; + } + + public void setFloor(String floor) { + this.floor = floor; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/SSJ_Device.java b/src/com/wms/dss/ats/customs/abb/entity/SSJ_Device.java new file mode 100644 index 0000000..183f934 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/SSJ_Device.java @@ -0,0 +1,53 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class SSJ_Device { + + public int CKDW ; + public int CKKX ; + public int SSZT; + //1-Õý³£ 2-Òì³£ + public int RKQQ; + public int RKGD; + public byte btId;// DDjid + public String dtype;// ÀàÐÍ + public String ssjNo; + + public int BH; + + public int DW;// µ½Î» + + public int ZT;//1SÊÖ¶¯ 2-×Ô¶¯ 3-±¨¾¯ + + public int KX;// ¿ÕÏÐ + + public int QQ;//ÇëÇó + + + public long RWH;// ÈÎÎñºÅ + public String writeDB; //Ï·¢µØÖ· + public String trayCode;//ÁÏÏäÂë + public int height;//¸ß¶È + //0Õý³£ 1ÍâÐÎÒì³£ 2ÖØÁ¿Òì³£ 3·Å»õλÖÃÓлõ 4È¡»õλÖÃÎÞ»õ 5ɨ²»µ½Âë + public int exceptionId; + + //ÁϼÜÐźŠ0δÂú 1Âú + public int LJXH; + //ÊÕµ½ÈÎÎñºÅ + public int BY1; + //ÊÕµ½agv·Å»õÍê³É + public int BY2; + + + + public SSJ_Device() { + super(); + } + + public SSJ_Device(byte btId, String dtype) { + super(); + this.btId = btId; + this.dtype = dtype; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/SendData.java b/src/com/wms/dss/ats/customs/abb/entity/SendData.java new file mode 100644 index 0000000..02446b9 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/SendData.java @@ -0,0 +1,39 @@ +package com.wms.dss.ats.customs.abb.entity; + +/** + * ·¢ËÍÊý¾ÝµÄʵÌåÀà + * @num ³¤¶È + * @num2 Öµ + */ +public class SendData { + private static final int DINT = 4; + private static final int INT = 2; + private int num; + private int num2; + + public SendData(int num, int num2) { + this.num = num; + this.num2 = num2; + } + + public SendData(int num, String num2) { + this.num = num; + this.num2 = Integer.parseInt(num2); + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } + + public int getNum2() { + return num2; + } + + public void setNum2(int num2) { + this.num2 = num2; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/StoredParameters.java b/src/com/wms/dss/ats/customs/abb/entity/StoredParameters.java new file mode 100644 index 0000000..46f6af0 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/StoredParameters.java @@ -0,0 +1,37 @@ +package com.wms.dss.ats.customs.abb.entity; + +/** + * ´æ´¢¹ý³ÌµÄʵÌåÀà + * @num µÚ¼¸¸ö²ÎÊý + * @num2 ²ÎÊý¶ÔÓ¦µÄÖµ + */ +public class StoredParameters { + private int num; + private String parameter; + + public StoredParameters(int num, String num2) { + this.num = num; + this.parameter = num2; + } + + public StoredParameters(int num, int permitIssuedBy) { + this.num = num; + this.parameter = String.valueOf(permitIssuedBy); + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.hbm.xml new file mode 100644 index 0000000..714d463 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.hbm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.java b/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.java new file mode 100644 index 0000000..c3cb4cc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/TaskPriority.java @@ -0,0 +1,31 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class TaskPriority { + private int id; + private String priority; + private String type; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.hbm.xml new file mode 100644 index 0000000..461c41f --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.hbm.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.java b/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.java new file mode 100644 index 0000000..39fee1e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/WcsPortState.java @@ -0,0 +1,58 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class WcsPortState { + private String portName; + private Integer occupationState; + private String description; + private String spare1; + private String spare2; + private String spare3; + + public String getSpare3() { + return spare3; + } + + public void setSpare3(String spare3) { + this.spare3 = spare3; + } + + public String getPortName() { + return portName; + } + + public void setPortName(String portName) { + this.portName = portName; + } + + public Integer getOccupationState() { + return occupationState; + } + + public void setOccupationState(Integer occupationState) { + this.occupationState = occupationState; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSpare1() { + return spare1; + } + + public void setSpare1(String spare1) { + this.spare1 = spare1; + } + + public String getSpare2() { + return spare2; + } + + public void setSpare2(String spare2) { + this.spare2 = spare2; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.hbm.xml new file mode 100644 index 0000000..8fcc273 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.hbm.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.java b/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.java new file mode 100644 index 0000000..2b58d1d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/WmsDeviceExecutionQueue.java @@ -0,0 +1,243 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class WmsDeviceExecutionQueue { + + private int id; //Ö÷¼ü±êʶ + private String Rwh; //ÈÎÎñºÅ + private String DevName; //É豸Ãû³Æ + private int DevId; //É豸ºÅ + private int rwzt; //ÈÎÎñ״̬ + private int yph; //¶Ñ¶â»úÔ´ÅÅ + private int ylh; //¶Ñ¶â»úÔ´ÁÐ + private int ych; //¶Ñ¶â»úÔ´²ã + private int mbph; //¶Ñ¶â»úÄ¿±êÅÅ + private int mblh; //¶Ñ¶â»úÄ¿±êÁÐ + private int mbch; //¶Ñ¶â»úÄ¿±ê²ã + private int xcykh; //С³µÔ´¿ÚºÅ + private int xcmbkh; //С³µÄ¿±ê¿ÚºÅ + private String xdh; //ÈÎÎñÏïµÀºÅ + private String sbzxxdh; //É豸ִÐÐÏïµÀºÅ + private int xczlgs; //С³µÖ¸Áî¸ñʽ + private int ddjzlgs; //¶Ñ¶â»úÖ¸Áî¸ñʽ + private String ddjxf; //¶Ñ¶â»úÏ·¢ + private int rwlx; //ÈÎÎñÀàÐÍ + private int ddjzxkh; //¶Ñ¶â»úÖ´ÐпںŠ+ private String scsj; //Éú³Éʱ¼ä + private String xfsj; //Ï·¢Ê±¼ä + private String jssj; //½áÊøÊ±¼ä + private String tray_code; + private Integer space_height; + private Integer tray_size; + + public WmsDeviceExecutionQueue() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getRwh() { + return Rwh; + } + + public void setRwh(String rwh) { + Rwh = rwh; + } + + public String getDevName() { + return DevName; + } + + public void setDevName(String devName) { + DevName = devName; + } + + public int getDevId() { + return DevId; + } + + public void setDevId(int devId) { + DevId = devId; + } + + public int getRwzt() { + return rwzt; + } + + public void setRwzt(int rwzt) { + this.rwzt = rwzt; + } + + public int getYph() { + return yph; + } + + public void setYph(int yph) { + this.yph = yph; + } + + public int getYlh() { + return ylh; + } + + public void setYlh(int ylh) { + this.ylh = ylh; + } + + public int getYch() { + return ych; + } + + public void setYch(int ych) { + this.ych = ych; + } + + public int getMbph() { + return mbph; + } + + public void setMbph(int mbph) { + this.mbph = mbph; + } + + public int getMblh() { + return mblh; + } + + public void setMblh(int mblh) { + this.mblh = mblh; + } + + public int getMbch() { + return mbch; + } + + public void setMbch(int mbch) { + this.mbch = mbch; + } + + public int getXcykh() { + return xcykh; + } + + public void setXcykh(int xcykh) { + this.xcykh = xcykh; + } + + public int getXcmbkh() { + return xcmbkh; + } + + public void setXcmbkh(int xcmbkh) { + this.xcmbkh = xcmbkh; + } + + public String getXdh() { + return xdh; + } + + public void setXdh(String xdh) { + this.xdh = xdh; + } + + public String getSbzxxdh() { + return sbzxxdh; + } + + public void setSbzxxdh(String sbzxxdh) { + this.sbzxxdh = sbzxxdh; + } + + public int getXczlgs() { + return xczlgs; + } + + public void setXczlgs(int xczlgs) { + this.xczlgs = xczlgs; + } + + public int getDdjzlgs() { + return ddjzlgs; + } + + public void setDdjzlgs(int ddjzlgs) { + this.ddjzlgs = ddjzlgs; + } + + public String getDdjxf() { + return ddjxf; + } + + public void setDdjxf(String ddjxf) { + this.ddjxf = ddjxf; + } + + public int getRwlx() { + return rwlx; + } + + public void setRwlx(int rwlx) { + this.rwlx = rwlx; + } + + public int getDdjzxkh() { + return ddjzxkh; + } + + public void setDdjzxkh(int ddjzxkh) { + this.ddjzxkh = ddjzxkh; + } + + public String getScsj() { + return scsj; + } + + public void setScsj(String scsj) { + this.scsj = scsj; + } + + public String getXfsj() { + return xfsj; + } + + public void setXfsj(String xfsj) { + this.xfsj = xfsj; + } + + public String getJssj() { + return jssj; + } + + public void setJssj(String jssj) { + this.jssj = jssj; + } + + public String getTray_code() { + return tray_code; + } + + public void setTray_code(String tray_code) { + this.tray_code = tray_code; + } + + public Integer getSpace_height() { + return space_height; + } + + public void setSpace_height(Integer space_height) { + this.space_height = space_height; + } + + public Integer getTray_size() { + return tray_size; + } + + public void setTray_size(Integer tray_size) { + this.tray_size = tray_size; + } +} + diff --git a/src/com/wms/dss/ats/customs/abb/entity/end.hbm.xml b/src/com/wms/dss/ats/customs/abb/entity/end.hbm.xml new file mode 100644 index 0000000..13de765 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/end.hbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/form/ABBMainFrame.java b/src/com/wms/dss/ats/customs/abb/form/ABBMainFrame.java new file mode 100644 index 0000000..0ea2e67 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/form/ABBMainFrame.java @@ -0,0 +1,25 @@ +package com.wms.dss.ats.customs.abb.form; + +import com.wms.dss.common.server.form.ServerMainFrame; + +/** + * ÃèÊö: ÏÃÃÅABBÉ豸ͨÐŵ÷¶Èϵͳ + * @author + * @since WMS 3.0 + */ +public class ABBMainFrame extends ServerMainFrame { + + public ABBMainFrame() throws Exception { + super(); + } + public static void main(String[] arg) + { + try{ + new ABBMainFrame(); + } + catch(Exception ex){ + ex.printStackTrace(); + System.exit(-1); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/form/StartCorrespond.java b/src/com/wms/dss/ats/customs/abb/form/StartCorrespond.java new file mode 100644 index 0000000..cfcc0f4 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/form/StartCorrespond.java @@ -0,0 +1,154 @@ +package com.wms.dss.ats.customs.abb.form; + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import com.wms.dss.common.server.config.DSSMenu; +import com.wms.dss.common.server.config.DSSMenuItem; +import com.wms.dss.common.server.form.FormObject; +import com.wms.dss.common.server.schedule.ThreadSchedule; + +/** + * ÃèÊö: Æô¶¯É豸ͨÐÅ + * @author hug 2013-4-12 + * @since WMS 3.0 + */ +public class StartCorrespond extends FormObject{ + protected JFrame gcf; + protected DSSMenuItem opMenuItem; + + public StartCorrespond() + {} + @Override + public void init(DSSMenuItem menuItem) { + gcf = new JFrame("¡ï¡ïÆô¶¯É豸ͨÐÅ¡ï¡ï"); + ImageIcon img = new ImageIcon("images\\a.gif"); + opMenuItem = menuItem; + + JPanel jPanel1 = new JPanel(); + JPanel jPanel2 = new JPanel(); + JPanel jPanel3 = new JPanel(); + JPanel jPanel4 = new JPanel(); + JPanel jPanel5 = new JPanel(); + + JTextArea jTextArea = new JTextArea(1,1); + Font ft = new Font("ËÎÌå",Font.BOLD,18); + //JLabel l1 = new JLabel(""); + + JButton jbtn1 = new JButton("ÊÇ"); + JButton jbtn2 = new JButton("·ñ"); + + gcf.getContentPane().add("North",jPanel1); + gcf.getContentPane().add("South",jPanel2); + gcf.getContentPane().add("East",jPanel3); + gcf.getContentPane().add("West",jPanel4); + gcf.getContentPane().add("Center",jPanel5); + + jPanel1.setBackground(new Color(240,248,255)); + jPanel2.setBackground(new Color(240,248,255)); + jPanel3.setBackground(new Color(240,248,255)); + jPanel4.setBackground(new Color(240,248,255)); + jPanel5.setBackground(new Color(240,248,255)); + + jPanel5.setBorder(BorderFactory.createLineBorder(new Color(43,166,197),1)); + + jTextArea.setText("ÊÇ ·ñ Æô ¶¯ Éè ±¸ ͨ ÐÅ ?"); + jTextArea.setForeground(Color.blue); + jTextArea.setFont(ft); + jPanel5.setLayout(new FlowLayout(FlowLayout.CENTER,25,20)); + jPanel5.add(jTextArea); + + jPanel5.add(jbtn1); + jPanel5.add(jbtn2); + + jbtn1.addActionListener(new JButtonH("ok")); + jbtn2.addActionListener(new JButtonH("exit")); + gcf.addWindowListener(new windows()); + + double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + double h = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + + gcf.setSize(300,200); + gcf.setIconImage(img.getImage()); + gcf.setLocation((int)((w-330)/2)+20,(int)((h-240)/2)); + gcf.setResizable(false); + gcf.setVisible(true); + } + public class JButtonH implements ActionListener{ + private String btnName; + public JButtonH(String bName) + { + this.btnName = bName; + } + public void actionPerformed(ActionEvent e) + { + if(btnName.equals("exit")) + { + exitSch(); + }if(btnName.equals("ok")) + { try{ + startSch(); + } + catch(Exception ex){ + ex.printStackTrace(); + } + + }else + { + parentJFrame.setEnabled(true); + gcf.setVisible(false); + } + } + + public void exitSch(){ + parentJFrame.setEnabled(true); + gcf.setVisible(false); + } + + /** + * ¹¦ÄÜ:Æô¶¯É豸ͨÐÅ + * + */ + public void startSch() throws Exception + { + parentJFrame.setEnabled(true); + gcf.setVisible(false); + + //²Ëµ¥×´Ì¬ÏÔʾ + opMenuItem.jmenuItem.setEnabled(false); + DSSMenu tempMenu = opMenuItem.getDssMenu(); //»ñµÃ²Ëµ¥ + String secondMenuKey = (String)tempMenu.lsSecondMenuKey.get(2);//µÚ¶þ¸ö²Ëµ¥µÄµÚ¶þ¸ö²Ëµ¥Ïî + DSSMenuItem tempMenuItem = (DSSMenuItem)tempMenu.hsSecondMenu.get(secondMenuKey); + tempMenuItem.jmenuItem.setEnabled(true); + + ThreadSchedule threadSch = (ThreadSchedule)Class.forName(opMenuItem.menu11ThreadClass).newInstance(); + threadSch.setHashtable(m_serverMainFrame.m_hsSysParam); + //Ïß³ÌÖ´ÐÐ + threadSch.threadExec(); + tempMenuItem.threadSch = threadSch; + } + } + + + public class windows extends WindowAdapter + { + public void windowClosing(WindowEvent e) + { + parentJFrame.setEnabled(true); + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/form/StopCorrespond.java b/src/com/wms/dss/ats/customs/abb/form/StopCorrespond.java new file mode 100644 index 0000000..0a43066 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/form/StopCorrespond.java @@ -0,0 +1,146 @@ +package com.wms.dss.ats.customs.abb.form; + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import com.wms.dss.common.server.config.DSSMenu; +import com.wms.dss.common.server.config.DSSMenuItem; +import com.wms.dss.common.server.form.FormObject; + +/** + * ÃèÊö: Í£Ö¹É豸ͨÐÅ + * @author hug 2013-4-15 + * @since WMS 3.0 + */ +public class StopCorrespond extends FormObject{ + protected JFrame gcf; + protected DSSMenuItem opMenuItem; + public StopCorrespond() + {} + @Override + public void init(DSSMenuItem menuItem) { + + gcf = new JFrame("¡ï¡ïÍ£Ö¹É豸ͨÐÅ¡ï¡ï"); + ImageIcon img = new ImageIcon("images\\a.gif"); + opMenuItem = menuItem; + + JPanel JPanel1 = new JPanel(); + JPanel JPanel2 = new JPanel(); + JPanel JPanel3 = new JPanel(); + JPanel JPanel4 = new JPanel(); + JPanel JPanel5 = new JPanel(); + + JTextArea jta = new JTextArea(1,1); + Font ft = new Font("ËÎÌå",Font.BOLD,18); + + //JLabel l1 = new JLabel(""); + JButton jbtn1 = new JButton("ÊÇ"); + JButton jbtn2 = new JButton("·ñ"); + + gcf.getContentPane().add("North",JPanel1); + gcf.getContentPane().add("South",JPanel2); + gcf.getContentPane().add("East",JPanel3); + gcf.getContentPane().add("West",JPanel4); + gcf.getContentPane().add("Center",JPanel5); + + JPanel1.setBackground(new Color(240,248,255)); + JPanel2.setBackground(new Color(240,248,255)); + JPanel3.setBackground(new Color(240,248,255)); + JPanel4.setBackground(new Color(240,248,255)); + JPanel5.setBackground(new Color(240,248,255)); + + JPanel5.setBorder(BorderFactory.createLineBorder(new Color(43,166,197),1)); + + jta.setText("ÊÇ ·ñ Í£ Ö¹ Éè ±¸ ͨ ÐÅ ?"); + jta.setForeground(Color.blue); + jta.setFont(ft); + JPanel5.setLayout(new FlowLayout(FlowLayout.CENTER,25,20)); + JPanel5.add(jta); + + JPanel5.add(jbtn1); + JPanel5.add(jbtn2); + + jbtn1.addActionListener(new JButtonH("ok")); + jbtn2.addActionListener(new JButtonH("exit")); + gcf.addWindowListener(new windows()); + + double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + double h = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + + gcf.setSize(300,200); + gcf.setIconImage(img.getImage()); + gcf.setLocation((int)((w-330)/2)+20,(int)((h-240)/2)); + gcf.setResizable(false); + gcf.setVisible(true); + } + public class JButtonH implements ActionListener + { + private String btnName; + + public JButtonH(String bName) + { + this.btnName = bName; + } + + public void actionPerformed(ActionEvent e) + { + if(btnName.equals("exit")) + { + cancelStop(); + }if(btnName.equals("ok")) + { + stopSch(); + }else + { + parentJFrame.setEnabled(true); + gcf.setVisible(false); + } + } + + public void cancelStop(){ + parentJFrame.setEnabled(true); + gcf.setVisible(false); + } + + /** + * ¹¦ÄÜ:Í£Ö¹É豸ͨÐÅ + * + */ + public void stopSch() + { + parentJFrame.setEnabled(true); + gcf.setVisible(false); + + //²Ëµ¥×´Ì¬´¦Àí + opMenuItem.jmenuItem.setEnabled(false); + DSSMenu tempMenu = opMenuItem.getDssMenu();//»ñµÃ²Ëµ¥ + String secondMenuKey = (String)tempMenu.lsSecondMenuKey.get(0); + DSSMenuItem tempMenuItem = (DSSMenuItem)tempMenu.hsSecondMenu.get(secondMenuKey); + tempMenuItem.jmenuItem.setEnabled(true); + + opMenuItem.threadSch.stopAll(true); + opMenuItem.threadSch = null; + } + } + public class windows extends WindowAdapter + { + public void windowClosing(WindowEvent e) + { + parentJFrame.setEnabled(true); + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/HslRead.java b/src/com/wms/dss/ats/customs/abb/plc/HslRead.java new file mode 100644 index 0000000..abb63fc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/HslRead.java @@ -0,0 +1,105 @@ +package com.wms.dss.ats.customs.abb.plc; + +import HslCommunication.BasicFramework.SoftBasic; +import HslCommunication.Core.Net.IReadWriteNet; +import HslCommunication.Core.Types.OperateResult; +import HslCommunication.Core.Types.OperateResultExOne; + +import javax.swing.*; +import java.awt.*; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class HslRead { + + private static SimpleDateFormat dateFormat = new SimpleDateFormat("[HH:mm:ss] "); + + /** + * ½«½á¹ûÐÅÏ¢ÏÔʾ³öÀ´£¬ÔÚ½çÃæÀï½øÐÐÏÔʾ + * @param result µÈ´ýÏÔʾµÄ½á¹ûÐÅÏ¢ + * @param x + * @param address ¶ÁÈ¡µÄµØÖ·Êý¾Ý + * @param textBox ÏÔʾ½á¹ûµÄÎı¾¿ò + * @param scrollPane Ö§³Ö¹ö¶¯ÌõµÄ¿Ø¼þ + * @param ÀàÐͶÔÏó + * @return + * @return + * @return + * @return + * @return + */ + public static T ReadResultRender(OperateResultExOne result ) { + + T x = null ; + if (result.IsSuccess) { + if (result.Content.getClass().isArray()) { + + } else { + x= (T) result.Content; + } + } else { + + JOptionPane.showMessageDialog( + null, + dateFormat.format(new Date()) + "] Read Failed\r\nReason:" + result.ToMessageShowString(), + "Result", + JOptionPane.WARNING_MESSAGE); + } + return x; + } + + public static int WriteResultRender(OperateResult result, String address ) { //void + int x=0; + if (result.IsSuccess) { +// JOptionPane.showMessageDialog( +// null, +// dateFormat.format(new Date()) + "[" + address + "] Write Success", +// "Result", +// JOptionPane.PLAIN_MESSAGE); + x=1; + } else { +// JOptionPane.showMessageDialog( +// null, +// dateFormat.format(new Date()) + "[" + address + "] Write Failed\r\nReason:" + result.ToMessageShowString(), +// "Result", +// JOptionPane.WARNING_MESSAGE); + x=2; + } + return x; + } + + public static void BulkReadRenderResult(IReadWriteNet readWrite, JTextField addTextBox, JTextField lengthTextBox, JTextArea resultTextBox ) { + try { + OperateResultExOne read = readWrite.Read(addTextBox.getText(), Short.parseShort(lengthTextBox.getText())); + if (read.IsSuccess) { + resultTextBox.setText("Result£º" + SoftBasic.ByteToHexString(read.Content)); + } else { + JOptionPane.showMessageDialog(null, "Read Failed£º" + read.ToMessageShowString(), "Result", JOptionPane.WARNING_MESSAGE); + } + } catch (Exception ex) { + JOptionPane.showMessageDialog(null, "Read Failed£º" + ex.getMessage(), "Result", JOptionPane.ERROR_MESSAGE); + } + } + + public static void SetPanelEnabled(JPanel panel, boolean enable) { + Component[] components = panel.getComponents(); + + //System.out.println("Component Length:" + components.length); + for (Component component : components) { + if (component instanceof JPanel) { + SetPanelEnabled((JPanel) component, enable); + } else { + component.setEnabled(enable); + } + } + + } + + public static String IpAddressInputWrong = "IpAddress input wrong"; + public static String PortInputWrong = "Port input wrong"; + public static String SlotInputWrong = "Slot input wrong"; + public static String BaudRateInputWrong = "Baud rate input wrong"; + public static String DataBitsInputWrong = "Data bit input wrong"; + public static String StopBitInputWrong = "Stop bit input wrong"; + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ1.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ1.java new file mode 100644 index 0000000..a644441 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ1.java @@ -0,0 +1,182 @@ +package com.wms.dss.ats.customs.abb.plc; + +import HslCommunication.BasicFramework.SoftBasic; +import HslCommunication.Core.Net.IReadWriteNet; +import HslCommunication.Core.Types.OperateResult; +import HslCommunication.Core.Types.OperateResultExOne; +import HslCommunication.Profinet.Siemens.SiemensPLCS; +import HslCommunication.Profinet.Siemens.SiemensS7Net; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTcpClientDDJ1 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsDDJParam = null; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientDDJ1(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.hsDDJParam = (HashMap) this.hsComParam.get("hsDDJMap1"); + + this.strIp = (String) hsComParam.get("strIpddj"); + this.iPort = (Integer) hsComParam.get("iPortddj"); + this.slot = (Integer) hsComParam.get("slotddj"); + this.m_dao = m_dao; + } + + void ConnectServer() { + siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500); + try { + siemensS7Net.setIpAddress(this.strIp); + siemensS7Net.setPort(this.iPort); + siemensS7Net.setRack((byte) Integer.parseInt("0")); + siemensS7Net.setSlot((byte) this.slot); + + OperateResult connect = siemensS7Net.ConnectServer(); + if (connect.IsSuccess) { + setIsConnect(true); + readWriteNet = siemensS7Net; + } else { + + } + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (success != true) { + success = bflag; + } + } + + public boolean IsConnect() { + if (success == true) { + return success; + } + return false; + } + + void closeServer() { + if (readWriteNet != null) { + OperateResult connectclose = siemensS7Net.ConnectClose(); + } + setIsConnect(false); + } + + void reConnect() { + closeServer(); + ConnectServer(); + Logger.info("ÖØÆô¶Ñ¶â»ú1"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------Ïß³Ì--------¶ÁÈ¡¶Ñ¶â»ú1ÐÅÏ¢-----------¿ªÊ¼---------------------"); + if (IsConnect()) { + String address = "0", ddj_id = "0"; + ddj_id = "ddj-1"; + address = "DB60.0"; + + DDJ_Device ddj = (DDJ_Device) hsDDJParam.get(ddj_id); + ddj.dName = "1ºÅ¶Ñ¶â»ú"; + ddj.CZFS = 0; //תΪ16½øÖƵÄÕûÐÍ + ddj.SBZT = 0; + ddj.ZXRWH = 0; + ddj.HCZT = 0; + ddj.ZXJD = 0; + ddj.DQP = 0; + ddj.DQL = 0; + ddj.DQC = 0; + ddj.MBPH = 0; + ddj.MBLH = 0; + ddj.MBCH = 0; + ddj.YXXF = 0; + ddj.XTXH = 0; + OperateResultExOne read1 = readWriteNet.Read(address, Short.parseShort("38"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx = "0"; + if (read1.IsSuccess) { + ddsx = SoftBasic.ByteToHexString(read1.Content); + }// ±äÁ¿.Substring(²ÎÊý1,²ÎÊý2); ÕûÐÍ4¸ö×Ö½Ú ³¤ÕûÐÍ8¸ö×Ö½Ú + + + + ddj.CZFS = ParseUtil.optInt(0, ddsx);//Integer.parseInt(ddsx.substring(0, 4), 16); + ddj.SBZT = ParseUtil.optInt(2, ddsx);//Integer.parseInt(ddsx.substring(4, 8), 16); + ddj.ZXRWH = ParseUtil.optDInt(4, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + ddj.HCZT = ParseUtil.optInt(8, ddsx);//Integer.parseInt(ddsx.substring(8, 12), 16); + ddj.ZXJD = ParseUtil.optInt(10, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + ddj.DQP = ParseUtil.optInt(12, ddsx);//Integer.parseInt(ddsx.substring(16, 20), 16); + ddj.DQL = ParseUtil.optInt(14, ddsx);//Integer.parseInt(ddsx.substring(20, 24), 16); + ddj.DQC = ParseUtil.optInt(16, ddsx);//Integer.parseInt(ddsx.substring(24, 28), 16); + ddj.MBPH = ParseUtil.optInt(18, ddsx);//Integer.parseInt(ddsx.substring(28, 32), 16); + ddj.MBLH = ParseUtil.optInt(20, ddsx);//Integer.parseInt(ddsx.substring(32, 36), 16); + ddj.MBCH = ParseUtil.optInt(22, ddsx);//Integer.parseInt(ddsx.substring(36, 40), 16); + ddj.YXXF = ParseUtil.optInt(24, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + ddj.XTXH = ParseUtil.optInt(26, ddsx);//Integer.parseInt(ddsx.substring(44, 48), 16); + //ddj.trayCode = ParseUtil.optString(30, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + + //m_dao.updateSql("update IpErrorMsg set msg='PLC:"+strIp+" Á¬½ÓÕý³£' where ip='"+strIp+"' and msg !='"+strIp+" Á¬½ÓÕý³£'"); + Thread.sleep(800); + } else { + //m_dao.updateSql("update IpErrorMsg set msg='PLC:"+strIp+" Á¬½Ó³¬Ê±' where ip='"+strIp+"' and msg !='"+strIp+" Á¬½Ó³¬Ê±'"); + reConnect(); + } + } catch (Exception ex) { + ex.printStackTrace(); + Logger.info("------catch--------------Ïß³Ì--------¶ÁÈ¡¶Ñ¶â»ú1ÐÅÏ¢-----------½áÊø0--------------------"); + reConnect(); + } + // ÿ´ÎÑ­»·´ò¿ª¹Ø±ÕÁ´½Ó + //reConnect(); + } + closeServer(); + } + + /// ¶Ñ¶â»úÈÎÎñÏ·¢ + public static int WritetoDDJ(String address, byte[] tsak) { + int a = 0; + if (readWriteNet != null) { + a = HslRead.WriteResultRender(readWriteNet.Write(address, tsak), address); + } + return a; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ2.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ2.java new file mode 100644 index 0000000..478413e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientDDJ2.java @@ -0,0 +1,183 @@ +package com.wms.dss.ats.customs.abb.plc; + +import HslCommunication.BasicFramework.SoftBasic; +import HslCommunication.Core.Net.IReadWriteNet; +import HslCommunication.Core.Types.OperateResult; +import HslCommunication.Core.Types.OperateResultExOne; +import HslCommunication.Profinet.Siemens.SiemensPLCS; +import HslCommunication.Profinet.Siemens.SiemensS7Net; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device_2; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTcpClientDDJ2 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsDDJParam = null; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientDDJ2(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.hsDDJParam = (HashMap) this.hsComParam.get("hsDDJMap2"); + + this.strIp = (String) hsComParam.get("strIpddj"); + this.iPort = (Integer) hsComParam.get("iPortddj"); + this.slot = (Integer) hsComParam.get("slotddj"); + this.m_dao = m_dao; + } + + void ConnectServer() { + siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500); + try { + siemensS7Net.setIpAddress(this.strIp); + siemensS7Net.setPort(this.iPort); + siemensS7Net.setRack((byte) Integer.parseInt("0")); + siemensS7Net.setSlot((byte) this.slot); + + OperateResult connect = siemensS7Net.ConnectServer(); + if (connect.IsSuccess) { + setIsConnect(true); + readWriteNet = siemensS7Net; + } else { + + } + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (success != true) { + success = bflag; + } + } + + public boolean IsConnect() { + if (success == true) { + return success; + } + return false; + } + + void closeServer() { + if (readWriteNet != null) { + OperateResult connectclose = siemensS7Net.ConnectClose(); + } + setIsConnect(false); + } + + void reConnect() { + closeServer(); + ConnectServer(); + Logger.info("ÖØÆô¶Ñ¶â»ú2"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------Ïß³Ì--------¶ÁÈ¡¶Ñ¶â»ú1ÐÅÏ¢-----------¿ªÊ¼---------------------"); + if (IsConnect()) { + String address = "0", ddj_id = "0"; + ddj_id = "ddj-2"; + address = "DB4.0"; + + DDJ_Device_2 ddj = (DDJ_Device_2) hsDDJParam.get(ddj_id); + ddj.dName = "2ºÅ¶Ñ¶â»ú"; + ddj.CZFS = 0; //תΪ16½øÖƵÄÕûÐÍ + ddj.SBZT = 0; + ddj.ZXRWH_1 = 0; + ddj.HCZT = 0; + ddj.ZXJD = 0; + ddj.DQP= 0; + ddj.DQL = 0; + ddj.DQC = 0; + ddj.MBPH = 0; + ddj.MBLH = 0; + ddj.MBCH = 0; + ddj.YXXF = 0; + ddj.ZXRWH_2 = 0; + ddj.ZXJD_2 = 0; + ddj.XTXH = 0; + OperateResultExOne read1 = readWriteNet.Read(address, Short.parseShort("60"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx = "0"; + if (read1.IsSuccess) { + ddsx = SoftBasic.ByteToHexString(read1.Content); + }// ±äÁ¿.Substring(²ÎÊý1,²ÎÊý2); ÕûÐÍ4¸ö×Ö½Ú ³¤ÕûÐÍ8¸ö×Ö½Ú + ddj.CZFS = ParseUtil.optInt(0, ddsx);//Integer.parseInt(ddsx.substring(0, 4), 16); + ddj.SBZT = ParseUtil.optInt(2, ddsx);//Integer.parseInt(ddsx.substring(4, 8), 16); + ddj.ZXRWH_1 = ParseUtil.optDInt(4, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + ddj.ZXRWH_2 = ParseUtil.optDInt(8, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + ddj.HCZT = ParseUtil.optInt(12, ddsx);//Integer.parseInt(ddsx.substring(8, 12), 16); + ddj.ZXJD = ParseUtil.optInt(14, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + ddj.ZXJD_2 = ParseUtil.optInt(16, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + ddj.DQP = ParseUtil.optInt(18, ddsx);//Integer.parseInt(ddsx.substring(16, 20), 16); + ddj.DQL = ParseUtil.optInt(20, ddsx);//Integer.parseInt(ddsx.substring(20, 24), 16); + ddj.DQC = ParseUtil.optInt(22, ddsx);//Integer.parseInt(ddsx.substring(24, 28), 16); + ddj.MBPH = ParseUtil.optInt(24, ddsx);//Integer.parseInt(ddsx.substring(28, 32), 16); + ddj.MBLH = ParseUtil.optInt(26, ddsx);//Integer.parseInt(ddsx.substring(32, 36), 16); + ddj.MBCH = ParseUtil.optInt(28, ddsx);//Integer.parseInt(ddsx.substring(36, 40), 16); + ddj.YXXF = ParseUtil.optInt(32, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + ddj.YXXF_2 = ParseUtil.optInt(32, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + ddj.XTXH = ParseUtil.optInt(38, ddsx);//Integer.parseInt(ddsx.substring(44, 48), 16); + //m_dao.updateSql("update IpErrorMsg set msg='PLC:"+strIp+" Á¬½ÓÕý³£' where ip='"+strIp+"' and msg !='"+strIp+" Á¬½ÓÕý³£'"); + Thread.sleep(800); + } else { + //m_dao.updateSql("update IpErrorMsg set msg='PLC:"+strIp+" Á¬½Ó³¬Ê±' where ip='"+strIp+"' and msg !='"+strIp+" Á¬½Ó³¬Ê±'"); + reConnect(); + } + } catch (Exception ex) { + Logger.info("------catch--------------Ïß³Ì--------¶ÁÈ¡¶Ñ¶â»ú1ÐÅÏ¢-----------ʧ°Üex{}--------------------",ex); + reConnect(); + } + // ÿ´ÎÑ­»·´ò¿ª¹Ø±ÕÁ´½Ó + //reConnect(); + } + closeServer(); + } + + ///¶Ñ¶â»úÈÎÎñÏ·¢ + public static int WritetoDDJ(String address, byte[] task) { + int a = 0; + if (readWriteNet != null) { + a = HslRead.WriteResultRender(readWriteNet.Write(address, task), address); + + } + return a; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientSSJ.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientSSJ.java new file mode 100644 index 0000000..74bb7dc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientSSJ.java @@ -0,0 +1,789 @@ +package com.wms.dss.ats.customs.abb.plc; + +import HslCommunication.BasicFramework.SoftBasic; +import HslCommunication.Core.Net.IReadWriteNet; +import HslCommunication.Core.Types.OperateResult; +import HslCommunication.Core.Types.OperateResultExOne; +import HslCommunication.Profinet.Siemens.SiemensPLCS; +import HslCommunication.Profinet.Siemens.SiemensS7Net; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.StrUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; +import com.wms.dss.ats.customs.abb.utils.Tools; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.*; + +public class IsoTcpClientSSJ extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientSSJ(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + + this.hsSSJParam = (HashMap) this.hsComParam.get("hsSSJMap"); + this.strIp = (String) hsComParam.get("strIpddj"); + this.iPort = (Integer) hsComParam.get("iPortddj"); + this.slot = (Integer) hsComParam.get("slotddj"); + this.m_dao = m_dao; + + } + + void ConnectServer() { + siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500); + try { + siemensS7Net.setIpAddress(this.strIp); + siemensS7Net.setPort(this.iPort); + siemensS7Net.setRack((byte) Integer.parseInt("0")); + siemensS7Net.setSlot((byte) this.slot); + + OperateResult connect = siemensS7Net.ConnectServer(); + if (connect.IsSuccess) { + setIsConnect(true); + readWriteNet = siemensS7Net; + //Logger.info("q"); + } else { +// JOptionPane.showMessageDialog( +// null, +// "Connect Failed:" + connect.ToMessageShowString(), +// "Result", +// JOptionPane.WARNING_MESSAGE); + } + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + + } + + public void setIsConnect(boolean bflag) { + if (success != true) { + success = bflag; + } + } + + public boolean IsConnect() { + if (success == true) { + return success; + } + return false; + } + + void closeServer() { + if (readWriteNet != null) { + OperateResult connectclose = siemensS7Net.ConnectClose(); + } + setIsConnect(false); + + } + + void reConnect() { + closeServer(); + ConnectServer(); + Logger.info("ÖØÆôÊäËÍ»ú"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------Ïß³Ì--------¶ÁÈ¡·¢»õÇøÊäËÍ»úÐÅÏ¢-----------¿ªÊ¼---------------------"); + if (IsConnect()) { + + //Logger.info("ÊäËÍ»úÐÅÏ¢¶ÁÈ¡¿ªÊ¼"); + //Èë¿âÊäËÍ»ú + for (int i = 1; i <= 10; i++) { + String prefix = "inStockSsj-"; + String ssj_id = prefix + i, ssjNo = "", address = "",writeDB = ""; + //һ¥ÍÐÅÌÈë¿â¿Ú COMPLETED + if (i == 1) { + address = "DB510.0"; + //writeDB = "DB502.0"; + ssjNo = "L1009"; + } + //һ¥ÁÏÏäÈë¿â¿Ú + if (i == 2) { + address = "DB510.72"; + //writeDB = "DB502.30"; + ssjNo = "G1011-7"; + } + //һ¥ÍÐÅ̳ö¿â¿Ú COMPLETED + if (i == 3) { + address = "DB510.54"; + // writeDB = "DB502.60"; + ssjNo = "L1004"; + } + //һ¥ÁÏÏä³ö¿â¿Ú + if (i == 4) { + address = "DB510.90"; + //writeDB = "DB502.90"; + ssjNo = "G1012-5"; + } + //¶þÂ¥²à±ßÍÐÅÌÈë³ö¿â¿Ú COMPLETED + if (i == 5) { + address = "DB510.234"; + //writeDB = "DB502.120"; + ssjNo = "G2050"; + } + //¶þÂ¥²à±ßÍÐÅÌÈë³ö¿â¿Ú COMPLETED + if (i == 6) { + address = "DB510.252"; + //writeDB = "DB502.150"; + ssjNo = "G2051"; + } + //¶þÂ¥ÁÏÏäÈë³ö¿â¿Ú + if (i == 7) { + address = "DB510.396"; + //writeDB = "DB502.180"; + ssjNo = "G2049"; + } + //¶þÂ¥²à±ßÍÐÅÌÈë³ö¿â¿Ú COMPLETED + if (i == 8) { + address = "DB510.144"; + //writeDB = "DB502.210"; + ssjNo = "G2003"; + } + //¶þÂ¥²à±ßÍÐÅÌÈë³ö¿â¿Ú COMPLETED + if (i == 9) { + address = "DB510.162"; + //writeDB = "DB502.240"; + ssjNo = "G2006"; + } + //¶þÂ¥²à±ßÍÐÅÌÈë³ö¿â¿Ú COMPLETED + if (i == 10) { + address = "DB510.180"; + //writeDB = "DB502.270"; + ssjNo = "G2007"; + } + + + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.ssjNo = ssjNo; + ssj.BH= 0; + ssj.ZT = 0; + ssj.KX = 0; + ssj.DW = 0; + ssj.QQ=0; + ssj.RWH = 0; + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.BH = ParseUtil.optInt(0,ddsx1); + ssj.ZT = ParseUtil.optInt(2,ddsx1); + if (i==8){ + SSJ_Device ssj1 = (SSJ_Device) hsSSJParam.get("G2002-1"); + OperateResultExOne read21 = readWriteNet.Read("DB510.560", Short.parseShort("2"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx11 = SoftBasic.ByteToHexString(read21.Content); + ssj1.KX = ParseUtil.optInt(0,ddsx11); + int kx = ParseUtil.optInt(4, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + if (ssj1.KX==1 && kx==1){ + ssj.KX = 1; + }else { + ssj.KX = 0; + } + }else { + ssj.KX = ParseUtil.optInt(4,ddsx1); + } + + ssj.DW = ParseUtil.optInt(6,ddsx1); + ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + } + } + + //ÏïµÀ¿ÚÊäËÍ»ú + for (int i = 1; i <= 14; i++) { + String prefix = "roadwaySsj-"; + String ssj_id = prefix + i, ssjNo = "", address = "",writeDB = ""; + //һ¥ÍÐÅ̳ö¿âÏïµÀ¿Ú COMPLETED + if (i == 1) { + address = "DB510.36"; + ssjNo = "L1001"; + // writeDB = "DB502.300"; + } + //һ¥ÍÐÅÌÈë¿âÏïµÀ¿Ú COMPLETED + if (i == 2) { + address = "DB510.18"; + ssjNo = "L1006"; + //writeDB = "DB502.330"; + } + //һ¥ÁÏÏäÈë¿âÏïµÀ¿Ú COMPLETED + if (i == 3) { + address = "DB510.108"; + ssjNo = "G1011-1-1"; + //writeDB = "DB502.360"; + } + //һ¥ÁÏÏäÈë¿âÏïµÀ¿Ú + if (i == 11) { + address = "DB510.520"; + ssjNo = "G1011-1-2"; + //writeDB = "DB502.810"; + } + //һ¥ÁÏÏä³ö¿âÏïµÀ¿Ú COMPLETED + if (i == 4) { + address = "DB510.126"; + ssjNo = "G1012-1-1"; + //writeDB = "DB502.390"; + } + //һ¥ÁÏÏä³ö¿âÏïµÀ¿Ú + if (i == 12) { + address = "DB501.840"; + ssjNo = "G1012-1-2"; + //writeDB = "DB502.840"; + } + //¶þÂ¥ÍÐÅ̳ö¿âÏïµÀ¿Ú COMPLETED + if (i == 5) { + address = "DB510.198"; + ssjNo = "L2001"; + //writeDB = "DB502.420"; + } + //¶þÂ¥ÍÐÅÌÈë¿âÏïµÀ¿Ú COMPLETED + if (i == 6) { + address = "DB510.216"; + ssjNo = "L2014"; + //writeDB = "DB502.450"; + } + //¶þÂ¥ÁÏÏä³ö¿âÏïµÀ¿Ú + if (i == 7) { + address = "DB510.270"; + ssjNo = "G2015-1-1"; + //writeDB = "DB502.480"; + } + //¶þÂ¥ÁÏÏä³ö¿âÏïµÀ¿Ú ÎÞÓà + if (i == 13) { + address = "DB501.870"; + ssjNo = "G2015-1-2"; + //writeDB = "DB502.870"; + } + //¶þÂ¥ÁÏÏäÈë¿âÏïµÀ¿Ú + if (i == 8) { + address = "DB510.288"; + ssjNo = "G2016-1-1"; + //writeDB = "DB502.510"; + } + //¶þÂ¥ÁÏÏäÈë¿âÏïµÀ¿Ú + if (i == 14) { + address = "DB510.538"; + ssjNo = "G2016-1-2"; + //writeDB = "DB502.900"; + } + //¶þÂ¥ÍÐÅ̲à±ßÈë³ö¿âÏïµÀ¿Ú COMPLETED + if (i == 9) { + address = "DB510.234"; + ssjNo = "G2050-2"; + //writeDB = "DB502.540"; + } + //¶þÂ¥ÍÐÅ̲à±ßÈë³ö¿âÏïµÀ¿Ú COMPLETED + if (i == 10) { + address = "DB510.252"; + ssjNo = "G2051-2"; + //writeDB = "DB502.570"; + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.ssjNo = ssjNo; + ssj.BH= 0; + ssj.ZT = 0; + ssj.KX = 0; + ssj.DW = 0; + ssj.QQ=0; + ssj.RWH = 0; + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.BH = ParseUtil.optInt(0,ddsx1); + ssj.ZT = ParseUtil.optInt(2,ddsx1); + ssj.KX = ParseUtil.optInt(4,ddsx1); + ssj.DW = ParseUtil.optInt(6,ddsx1); + ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + } + } + + //ÇëÇóÁÏÏäÊäËÍ»úÐźŠ+ for (int i = 1; i <= 5; i++) { + String prefix = "boxSsj-"; + String ssj_id = prefix + i, ssjNo = "", address = "",writeDB = ""; + //¶þÂ¥ÇëÇóÁÏÏäÈ¥Ïò + if (i == 1) { + address = "DB510.306"; + writeDB = "DB511.12"; + ssjNo = "G2019"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥Ïò + if (i == 2) { + address = "DB510.342"; + writeDB = "DB511.36"; + ssjNo = "G2032"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥Ïò + if (i == 3) { + address = "DB510.360"; + writeDB = "DB511.48"; + ssjNo = "G2034"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥Ïò + if (i == 4) { + address = "DB510.414"; + writeDB = "DB511.84"; + ssjNo = "G2043"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥Ïò + if (i == 5) { + address = "DB510.432"; + writeDB = "DB511.96"; + ssjNo = "G2028"; + } + + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.ssjNo = ssjNo; + ssj.BH= 0; + ssj.ZT = 0; + ssj.KX = 0; + ssj.DW = 0; + ssj.QQ=0; + ssj.RWH = 0; + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.BH = ParseUtil.optInt(0,ddsx1); + ssj.ZT = ParseUtil.optInt(2,ddsx1); + ssj.KX = ParseUtil.optInt(4,ddsx1); + ssj.DW = ParseUtil.optInt(6,ddsx1); + ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + ssj.BY1 = ParseUtil.optInt(14,ddsx1); + ssj.BY2 = ParseUtil.optInt(16,ddsx1); + } + } + //ÇëÇóÁÏÏäÊäËÍ»úÐźŠÁÏÏäÂëÐÅÏ¢ + for (int i = 1; i <= 5; i++) { + String prefix = "boxSsj-"; + String ssj_id = prefix + i, address = ""; + //¶þÂ¥ÇëÇóÁÏÏäÈ¥ÏòG2019 + if (i == 1) { + address = "DB510.450"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥ÏòG2032 + if (i == 2) { + address = "DB510.464"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥ÏòG2034 + if (i == 3) { + address = "DB510.478"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥ÏòG2043 + if (i == 4) { + address = "DB510.492"; + } + //¶þÂ¥ÇëÇóÁÏÏäÈ¥ÏòG2028 + if (i == 5) { + address = "DB510.506"; + } + + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("14"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.trayCode = ParseUtil.optString(2,ddsx1); + if ("000000000000".equals(ssj.trayCode)){ + ssj.trayCode=null; + }else if ("111111111111".equals(ssj.trayCode) && ssj.DW==1){ + ssj.trayCode =null; + ssj.exceptionId = 7; + }else { + ssj.exceptionId = 0; + } + } + } + + //×ªÒÆÍÐÅÌÊäËÍ»ú + for (int i = 1; i <= 1; i++) { + String prefix = "transferSsj-"; + String ssj_id = prefix + i, ssjNo = "", address = "",writeDB = ""; + if (i == 1) { + //¶þÂ¥ÍÐÅÌ×ªÒÆSSJ COMPLETED + address = "DB510.198"; + writeDB = "DB511.0"; + ssjNo = "L2001"; + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.ssjNo = ssjNo; + ssj.BH= 0; + ssj.ZT = 0; + ssj.KX = 0; + ssj.DW = 0; + ssj.QQ=0; + ssj.RWH = 0; + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.BH = ParseUtil.optInt(0,ddsx1); + ssj.ZT = ParseUtil.optInt(2,ddsx1); + ssj.KX = ParseUtil.optInt(4,ddsx1); + ssj.DW = ParseUtil.optInt(6,ddsx1); + ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + } + } + + //ÁϼÜÐźŠ+ for (int i = 1; i <= 2; i++) { + String prefix = "rack-"; + String ssj_id = prefix + i, address = "", ssjNo = "",writeDB = ""; + if (i == 1) { + address = "DB510.574"; + writeDB = "DB502.800"; + ssjNo = "ZJ001"; + } + if (i == 2) { + address = "DB510.576"; + writeDB = "DB502.805"; + ssjNo = "ZJ002"; + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("2"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.LJXH = ParseUtil.optInt(0, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + } + } + + for (int i = 1; i <= 8; i++) { + String prefix = "smSsj-"; + String ssj_id = prefix + i, address = "", ssjNo = "",writeDB = ""; + String trayCodeReadAddress = null; + if (i == 1) { + //һ¥ÍÐÅÌɨÂëSsj COMPLETED + address = "DB501.0"; + writeDB = "DB502.0"; + ssjNo = "L1009"; + trayCodeReadAddress = "DB510.592"; + } + if (i == 2) { + //һ¥ÁÏÏäɨÂëSsj COMPLETED + address = "DB501.34"; + writeDB = "DB502.16"; + ssjNo = "G1011-7"; + trayCodeReadAddress = "DB510.578"; + } + if (i == 3){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.0"; + writeDB = "DB504.0"; + ssjNo = "G2003"; + trayCodeReadAddress = "DB510.606"; + } + if (i == 4){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.34"; + writeDB = "DB504.16"; + ssjNo = "G2006"; + trayCodeReadAddress = "DB503.34"; + } + if (i == 5){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.68"; + writeDB = "DB504.32"; + ssjNo = "G2007"; + trayCodeReadAddress = "DB503.68"; + } + if (i == 6){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.102"; + writeDB = "DB504.48"; + ssjNo = "G2050"; + trayCodeReadAddress = "DB510.634"; + } + if (i == 7){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.136"; + writeDB = "DB504.64"; + ssjNo = "G2051"; + trayCodeReadAddress = "DB510.648"; + } + if (i == 8){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB512.0"; + writeDB = "DB512.34"; + ssjNo = "G2049"; + trayCodeReadAddress = "DB510.620"; + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("34"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.CKDW = ParseUtil.optInt(0, ddsx1); + //(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.CKKX = ParseUtil.optInt(2, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.RWH = ParseUtil.optDInt(4, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.SSZT = ParseUtil.optInt(8, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.RKQQ = ParseUtil.optInt(10, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.RKGD = ParseUtil.optInt(12, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + if (ssj.RKGD == 1){ + ssj.height=0; + }else if (ssj.RKGD == 2){ + ssj.height = 1; + }else if (ssj.RKGD == 3){ + ssj.height = 2; + }else { + ssj.height = -1; + } + + //ssj.trayCode = ParseUtil.optString(16, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + ssj.exceptionId = ParseUtil.optInt(28, ddsx1);//(int) Long.parseLong(ddsx1.substring(0, 4), 16); + /*if (ssj.exceptionId == 7){ + ssj.trayCode = null; + }*/ + ssj.BY1 = ParseUtil.optInt(30, ddsx1); + ssj.BY2 = ParseUtil.optInt(32, ddsx1); + OperateResultExOne read = readWriteNet.Read(trayCodeReadAddress, Short.parseShort("14")); + String trayXx = "0"; + if (read.IsSuccess){ + trayXx = SoftBasic.ByteToHexString(read.Content); + String trayCode = ParseUtil.optString(2, trayXx); + if ("000000000000".equals(trayCode)){ + ssj.trayCode=null; + }else if ("111111111111".equals(trayCode)){ + ssj.trayCode =null; + }else { + if (ssjNo.equals("G2006")|| ssjNo.equals("G2007")){ + ssj.trayCode =null; + + }else { + ssj.trayCode = trayCode; + + } + + } + } + } + } + + /*for (int i = 1; i <= 8; i++) { + String prefix = "smSsj-"; + String ssj_id = prefix + i, address = "", ssjNo = "",writeDB = ""; + if (i == 1) { + //һ¥ÍÐÅÌɨÂëSsj COMPLETED + address = "DB501.0"; + + } + if (i == 2) { + //һ¥ÁÏÏäɨÂëSsj COMPLETED + address = "DB501.34"; + + } + if (i == 3){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.0"; + + } + if (i == 4){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.34"; + + } + if (i == 5){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.68"; + + } + if (i == 6){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.102"; + + } + if (i == 7){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.136"; + + } + if (i == 8){ + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB512.0"; + + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("34")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + String trayCode = ParseUtil.optString(16, ddsx1); + if ("000000000000".equals(trayCode)){ + ssj.trayCode=null; + }else if ("111111111111".equals(trayCode)){ + ssj.trayCode =null; + }else { + ssj.trayCode = trayCode; + } + } + }*/ + + for (int i = 1; i <= 2; i++) { + String prefix = "jxSsj-"; + String ssj_id = prefix + i, ssjNo = "", address = "",writeDB = ""; + //һ¥ÍÐÅ̳ö¿âÏïµÀ¿Ú COMPLETED + if (i == 1) { + address = "DB510.324"; + ssjNo = "G2026"; + // writeDB = "DB502.300"; + } + //һ¥ÍÐÅÌÈë¿âÏïµÀ¿Ú COMPLETED + if (i == 2) { + address = "DB510.378"; + ssjNo = "G2041"; + //writeDB = "DB502.330"; + } + SSJ_Device ssj = (SSJ_Device) hsSSJParam.get(ssj_id); + ssj.ssjNo = ssjNo; + ssj.BH= 0; + ssj.ZT = 0; + ssj.KX = 0; + ssj.DW = 0; + ssj.QQ=0; + ssj.RWH = 0; + ssj.writeDB = writeDB; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.BH = ParseUtil.optInt(0,ddsx1); + ssj.ZT = ParseUtil.optInt(2,ddsx1); + ssj.KX = ParseUtil.optInt(4,ddsx1); + ssj.DW = ParseUtil.optInt(6,ddsx1); + ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + } + } + + + + + //m_dao.updateSql("update IpErrorMsg set msg='PLC:" + strIp + " Á¬½ÓÕý³£' where ip='" + strIp + "' and msg !='" + strIp + " Á¬½ÓÕý³£'"); + Thread.sleep(800); + } else { + // m_dao.updateSql("update IpErrorMsg set msg='PLC:" + strIp + " Á¬½Ó³¬Ê±' where ip='" + strIp + "' and msg !='" + strIp + " Á¬½Ó³¬Ê±'"); + reConnect(); + } + //Logger.info("--------------------Ïß³Ì--------¶ÁÈ¡PLCÐÅÏ¢-----------½áÊø---------------------"); + //Thread.sleep(800); + } catch (Exception ex) { + //Logger.info("------catch--------------Ïß³Ì--------¶ÁÈ¡PLCÐÅÏ¢-----------½áÊø0--------------------"); + Logger.error("------catch--------------Ïß³Ì--------¶ÁÈ¡PLCÐÅÏ¢-----------ʧ°Üe{}--------------------",ex); + reConnect(); + } + } + closeServer(); + } + + /// ÊäËÍ»úÈÎÎñÏ·¢ + public static int WritetoSSJ(String address, byte[] tsak) { + int a = 0; + if (readWriteNet != null) { + a = HslRead.WriteResultRender(readWriteNet.Write(address, tsak), address); + } + return a; + } + + //¶ÁÈ¡ÈÎÎñÊÇ·ñÏ·¢ + public static SSJ_Device readSsjRwh(String ssjNo) { + String address = ""; + String writeDB = ""; + switch (ssjNo) { + case "L1009": + //һ¥ÍÐÅÌɨÂëSsj COMPLETED + address = "DB510.0"; + break; + case "G1011-7": + //һ¥ÁÏÏäɨÂëSsj COMPLETED + address = "DB510.72"; + break; + case "G2003": + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB510.556"; + break; + case "G2006": + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.34"; + break; + case "G2007": + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB503.68"; + break; + case "G2032": + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB510.342"; + break; + case "G2043": + //¶þÂ¥ÍÐÅÌɨÂëÊäËÍ»ú COMPLETED + address = "DB510.414"; + break; + default: + return new SSJ_Device(); + } + String taskNo = ""; + SSJ_Device ssj = new SSJ_Device(); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("18"));//readWriteNet.Read(µØÖ·£¬ShortµÄ¶ÁÈ¡µØÖ·³¤¶È) + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + //ssj.BH = ParseUtil.optInt(0,ddsx1); + //ssj.ZT = ParseUtil.optInt(2,ddsx1); + //ssj.KX = ParseUtil.optInt(4,ddsx1); + //ssj.DW = ParseUtil.optInt(6,ddsx1); + //ssj.QQ=ParseUtil.optInt(8,ddsx1); + ssj.RWH = ParseUtil.optDInt(10,ddsx1); + } + return ssj; + + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/PLCCorrespondService.java b/src/com/wms/dss/ats/customs/abb/plc/PLCCorrespondService.java new file mode 100644 index 0000000..b7e7d02 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/PLCCorrespondService.java @@ -0,0 +1,44 @@ +package com.wms.dss.ats.customs.abb.plc; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.schedule.ThreadSchedule; + +import java.util.HashMap; +import java.util.Hashtable; + + +/** + * ÃèÊö: É豸ͨÐÅ·þÎñ + * + * @author zhu 2020-3-20 + * @since WCS 3.0 + */ +public class PLCCorrespondService extends ThreadSchedule { + + + @Override + public void stopAll(boolean bVal) { + //¹Ø±Õ + m_hsSysParam.put("bStopFlag", "true"); + } + + @Override + public void threadExec() { + // Ö´ÐÐÉ豸ͨÐÅÏß³Ì + startcomm(m_hsSysParam); + } + + public static void initDevice(HashMap hsDDJMap) { // + + } + + public void startcomm(Hashtable m_hsSysParam) { + m_hsSysParam.put("bStopFlag", "false"); + EntityDAO m_dao = (EntityDAO) m_hsSysParam.get("dao"); + + ReadPLCSSJ.read(m_hsSysParam,m_dao); + ReadPLCDDJ1.read(m_hsSysParam,m_dao); + ReadPLCDDJ2.read(m_hsSysParam,m_dao); + + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ1.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ1.java new file mode 100644 index 0000000..37a51ca --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ1.java @@ -0,0 +1,35 @@ +package com.wms.dss.ats.customs.abb.plc; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCDDJ1 { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + + HashMap hsDDJMap = new HashMap(); + + String strIp = "192.168.56.11";///DDJ plc¶ÔÓ¦ipµØÖ· + String strPort = "102"; + String strSLot = "1"; + hsComParam.put("strIpddj", strIp); + hsComParam.put("iPortddj", Integer.parseInt(strPort)); + hsComParam.put("slotddj", Integer.parseInt(strSLot)); + + + //¶Ñ¶â»ú + DDJ_Device ddj = new DDJ_Device((byte)1, "ddj"); + hsDDJMap.put(ddj.dtype + "-" + ddj.btId, ddj); + + hsComParam.put("hsDDJMap1", hsDDJMap); + m_hsSysParam.put("hsComParamDDJ1", hsComParam); + // PLCͨѶ¿Í»§¶Ë + IsoTcpClientDDJ1 tp = new IsoTcpClientDDJ1(hsComParam, m_hsSysParam,m_dao); + tp.start(); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ2.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ2.java new file mode 100644 index 0000000..c8fe8a2 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCDDJ2.java @@ -0,0 +1,37 @@ +package com.wms.dss.ats.customs.abb.plc; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device_2; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCDDJ2 { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + + HashMap hsDDJMap = new HashMap(); + + String strIp = "192.168.56.21";///DDJ plc¶ÔÓ¦ipµØÖ· + String strPort = "102"; + String strSLot = "1"; + hsComParam.put("strIpddj", strIp); + hsComParam.put("iPortddj", Integer.parseInt(strPort)); + hsComParam.put("slotddj", Integer.parseInt(strSLot)); + + + //¶Ñ¶â»ú + DDJ_Device_2 ddj = new DDJ_Device_2((byte)2, "ddj"); + hsDDJMap.put(ddj.dtype + "-" + ddj.btId, ddj); + + hsComParam.put("hsDDJMap2", hsDDJMap); + m_hsSysParam.put("hsComParamDDJ2", hsComParam); + // PLCͨѶ¿Í»§¶Ë + IsoTcpClientDDJ2 tp = new IsoTcpClientDDJ2(hsComParam, m_hsSysParam,m_dao); + tp.start(); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCSSJ.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCSSJ.java new file mode 100644 index 0000000..c2cd27b --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCSSJ.java @@ -0,0 +1,73 @@ +package com.wms.dss.ats.customs.abb.plc; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.DDJ_Device; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCSSJ { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + HashMap hsSSJMap = new HashMap(); + + String strIp = "192.168.56.41";///DDJ plc¶ÔÓ¦ipµØÖ· + String strPort = "102"; + String strSLot = "1"; + hsComParam.put("strIpddj", strIp); + hsComParam.put("iPortddj", Integer.parseInt(strPort)); + hsComParam.put("slotddj", Integer.parseInt(strSLot)); + + //Èë¿âÊäËÍ»ú + for(int i = 1; i <= 10; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "inStockSsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + //ÏïµÀ¿ÚÊäËÍ»ú + for(int i = 1; i <= 14; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "roadwaySsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + + //×ªÒÆÊäËÍ»ú + for(int i = 1; i <= 1; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "transferSsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + + //ÇëÇóÁÏÏäÊäËÍ»ú + for(int i = 1; i <= 5; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "boxSsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + + //ÁÏÏä¼ðѡλ + for(int i = 1; i <= 2; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "jxSsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + + //ÁϼÜÐźŠ+ for(int i = 1; i <= 2; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "rack"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + for(int i = 1; i <= 10; i++){ + SSJ_Device ssj = new SSJ_Device((byte)i, "smSsj"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + } + + SSJ_Device ssj = new SSJ_Device((byte)1, "G2002"); + hsSSJMap.put(ssj.dtype + "-" + ssj.btId, ssj); + + hsComParam.put("hsSSJMap", hsSSJMap); + m_hsSysParam.put("hsComParamSSJ", hsComParam); + // PLCͨѶ¿Í»§¶Ë + IsoTcpClientSSJ ssjTp = new IsoTcpClientSSJ(hsComParam, m_hsSysParam,m_dao); + ssjTp.start(); + + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/备注.txt b/src/com/wms/dss/ats/customs/abb/plc/备注.txt new file mode 100644 index 0000000..fa6f9a1 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/备注.txt @@ -0,0 +1 @@ +ÓëPLCͨÐÅ,¶ÁÈ¡PLC±äÁ¿,±£´æÔÚÊý¾Ý¿âÖÐ \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/schedule/ABBThreadSchedule.java b/src/com/wms/dss/ats/customs/abb/schedule/ABBThreadSchedule.java new file mode 100644 index 0000000..9951d44 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ABBThreadSchedule.java @@ -0,0 +1,82 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import com.ricosoft.common.logger.Logger; +import com.wms.dss.common.server.schedule.ThreadSchedule; + +/** + * ÃèÊö: µ÷¶È×ÜÏß³Ì + * + * @since WMS 3.1 ZGWµÚÒ»´ÎÌá½» + */ +public class ABBThreadSchedule extends ThreadSchedule { + + protected DDJThread ddjThread = null; + protected DDJThread2 ddjThread2 = null; + protected BoxSsjThread boxSsjThread= null; + protected InOutStockSsjThread inOutStockSsjThread= null; + protected RoadwaySsjThread roadwaySsjThread= null; + protected TransferSsjThread transferSsjThread= null; + protected AGVThread agvThread = null; +// protected OCRThread ocrThread = null; + protected ExceptionUploadThread exceptionUploadThread= null; + protected ControlThread controlThread = null; + @Override + public void stopAll(boolean bVal) { + m_hsSysParam.put("bDStopFlag", "true"); + //crane1.setStop(bVal); + } + + @Override + public void threadExec() { + m_hsSysParam.put("bDStopFlag", "false"); + try { + //³öÈë¿â¿ÚÊäËÍ»ú + inOutStockSsjThread = new InOutStockSsjThread( m_hsSysParam); + inOutStockSsjThread.setName("³öÈë¿â¿ÚÊäËÍ»ú"); + inOutStockSsjThread.start(); + Thread.sleep(400); + //Òì³£Éϱ¨ µ÷ÕûÉϱ¨¼ä¸ôʱ¼ä£¬·ÀֹƵ·±Éϱ¨ÊäËÍ»úÒì³£ + exceptionUploadThread = new ExceptionUploadThread( m_hsSysParam); + exceptionUploadThread.setName("Òì³£Éϱ¨"); + exceptionUploadThread.start(); + Thread.sleep(400); + + //ÏïµÀ¿ÚÊäËÍ»ú + roadwaySsjThread = new RoadwaySsjThread( m_hsSysParam); + roadwaySsjThread.setName("ÏïµÀ¿ÚÊäËÍ»ú"); + roadwaySsjThread.start(); + Thread.sleep(400); + //¶Ñ¶â»ú1 + ddjThread = new DDJThread( m_hsSysParam); + ddjThread.setName("¶Ñ¶â»úÏß³Ì×é1"); + ddjThread.start();//¶Ñ¶â»úµ÷¶È + Thread.sleep(400); + ddjThread2 = new DDJThread2( m_hsSysParam); + ddjThread2.setName("¶Ñ¶â»úÏß³Ì×é2"); + ddjThread2.start();//¶Ñ¶â»úµ÷¶È + Thread.sleep(400); + + agvThread = new AGVThread(m_hsSysParam); + agvThread.setName("AGV½»»¥Ïß³Ì"); + agvThread.start(); + Thread.sleep(400); + //ÍÐÅ̳ö¿âÇëÇóÊäËÍ»ú+ÁϼÜÐźÅÅÐ¶Ï + transferSsjThread = new TransferSsjThread( m_hsSysParam); + transferSsjThread.setName("ÍÐÅ̳ö¿âÇëÇóÊäËÍ»ú+ÁϼÜÐźÅÅжÏ"); + transferSsjThread.start(); + Thread.sleep(400); + //ÁÏÏä·´À¡ÊäËÍ»ú + boxSsjThread = new BoxSsjThread( m_hsSysParam); + boxSsjThread.setName("ÁÏÏä·´À¡ÊäËÍ»ú"); + boxSsjThread.start(); + Thread.sleep(400); + controlThread = new ControlThread( m_hsSysParam); + controlThread.setName("É豸¼à¿ØÏß³Ì"); + controlThread.start(); + //¼à¿Ø + Thread.sleep(400); + } catch (Exception er) { + Logger.error("........É豸µ÷¶ÈÏß³ÌÆô¶¯³ö´í........" + er.getMessage()); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/AGVThread.java b/src/com/wms/dss/ats/customs/abb/schedule/AGVThread.java new file mode 100644 index 0000000..efe01f6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/AGVThread.java @@ -0,0 +1,106 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.log.Log; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.ExceptionInfo; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; +import com.wms.dss.ats.customs.abb.entity.WcsPortState; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientSSJ; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; +import org.hibernate.cfg.annotations.QueryBinder; + +import java.util.Date; +import java.util.Hashtable; +import java.util.List; +import java.util.Optional; + +public class AGVThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public AGVThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e.getMessage()); + } + try { + List portState = QueryDbDataUtils.getPortState(m_dao); + if (CollUtil.isNotEmpty(portState)){ + for (WcsPortState wcsPortState : portState) { + //Èë¿â + if (wcsPortState.getOccupationState() == 1 && "1".equals(wcsPortState.getSpare1())) { + //todo дÈëÈë¿âÈÎÎñ + List inStockSsj = DbGet.getSmSsj(); + Optional first = inStockSsj.stream().filter(ssj_device -> ssj_device.ssjNo.equals(wcsPortState.getPortName())).findFirst(); + if (first.isPresent()) { + SSJ_Device ssjDevice = first.get(); + byte[] sendData = Tools.sendDataToDevice(0, null, 0, 0, 1); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + /*if (ssjDevice.ssjNo.equals("L1009")){ + IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + }*/ + //todo ÅжÏÒ»ÏÂÊÇ·ñ½ÓÊÕµ½ + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Æô¶¯ÈÎÎñ³É¹¦£¡"); + /*if (ssjDevice.ssjNo.equals("G2003")){ + QueryDbDataUtils.updateWcsPortState(m_dao, ssjDevice.ssjNo, "1"); + }*/ + //QueryDbDataUtils.updateWcsPortState(m_dao, wcsPortState.getPortName(), "1"); + } + } + } + //³ö¿â + if (wcsPortState.getOccupationState()==0 && "2".equals(wcsPortState.getSpare1()) && "0".equals(wcsPortState.getSpare2())){ + //È¡»õÍê³ÉÒÔºó 10Ãë×Ô¶¯Çå³ýÈÎÎñ + /*List inStockSsj = DbGet.getInStockSsj(); + Optional first = inStockSsj.stream().filter(ssj_device -> ssj_device.ssjNo.equals(wcsPortState.getPortName())).findFirst(); + if (first.isPresent()){ + SSJ_Device ssjDevice = first.get(); + byte[] sendData = Tools.sendDataToDevice(0, "", 1 ); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("Ïò³ö¿ÚÊäËÍ»ú" + ssjDevice.ssjNo + "дÈëÇå¿Õ±êÖ¾³É¹¦"); + QueryDbDataUtils.updateWcsPortState(m_dao, wcsPortState.getPortName(), "1"); + } + }*/ + } + } + } + } catch (Exception e) { + Logger.error(e.getMessage()); + }finally { + try { + sleep(1500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/BoxSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/BoxSsjThread.java new file mode 100644 index 0000000..1017562 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/BoxSsjThread.java @@ -0,0 +1,306 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.MydoJob; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientSSJ; +import com.wms.dss.ats.customs.abb.utils.ProcedureResult; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.RequestUrls; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.util.*; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.taskExceptionUpload; + +public class BoxSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public BoxSsjThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + //throw new RuntimeException(e); + } + try { + //Logger.info("=======================ÊäËÍ»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamSSJ = hsComParamSSJ; + + int ssjH = 0; //¶Ñ¶â»úºÅ + try { ///¶Ñ¶â»úµ÷¶È + List ssj = DbGet.getFirstBoxSsj(); + if (!ssj.isEmpty()) { + for (SSJ_Device ssj_device : ssj) { + //¶Ñ¶â»úÑ­»· + ssj_dd(ssj_device,DbGet.getJxSsj()); + } + } + List requestSsj = DbGet.getRequestBoxSsj(); + + if (!requestSsj.isEmpty()) { + for (SSJ_Device ssj_device : requestSsj) { + //¶Ñ¶â»úÑ­»· + ssj_request_dd(ssj_device,DbGet.getJxSsj()); + } + } + } catch (Exception ex) { + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssjH + ex.getMessage()); + }///¶Ñ¶â»úµ÷¶È + } catch (Exception e) { + //Logger.info("==========ÊäËÍ»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + Logger.error(e); + } finally { + //Logger.info("=======================ÊäËÍ»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e); + } + } + } + } + + private void ssj_request_dd(SSJ_Device ssjDevice, List jxSsj) throws Exception { + if (ssjDevice.exceptionId == 0 && ssjDevice.DW == 1 && StrUtil.isNotBlank(ssjDevice.trayCode)) { + + + MydoJob mydoJob = QueryDbDataUtils.getMyDoJobByTrayCode(m_dao, String.valueOf(ssjDevice.trayCode)); + if (mydoJob != null){ + DateTime startTime = DateUtil.parse(mydoJob.getStart_time()); + DateTime currentTime = DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + if (DateUtil.between(startTime, currentTime, DateUnit.SECOND) > 20) { + //´¦Àí»ØÁ÷ÈÎÎñ Èë¿âÈÎÎñ ·¢ËÍÈ¥Ïò + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + long taskNo = Convert.toInt(mydoJob.getTask_no()); + int qx=1; + int sendCompleted=1; + byte[] sendData = Tools.sendDataToDevice( taskNo, null,sendCompleted,qx); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + MydoJob slotJobByTask = QueryDbDataUtils.getSlotJobByTask(m_dao, ssjDevice.RWH, null); + if (slotJobByTask != null) { + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢»ØÁ÷ÈÎÎñ" + taskNo + "³É¹¦£¡"); + //×÷Òµ¿ªÊ¼ + m_dao.updateSql("update MydoJob set status=3, class_now_name='"+qx+"', start_time='" + format + "',execution_phase= 2,car_number='"+ ssjDevice.ssjNo+"' where task_no='" + slotJobByTask.getTask_no() + "'"); + } + + } + } + }else { + Map map = new HashMap<>(); + map.put("trayCode", ssjDevice.trayCode); + map.put("ssjNo", ssjDevice.ssjNo); + String requestParam = JSONUtil.toJsonStr(map); + //ÇëÇówms½Ó¿Ú + String post = HttpUtil.post(RequestUrls.TrayCodeDirection.getUrl(), requestParam); + JSONObject entries = JSONUtil.parseObj(post); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + //Thread.sleep(10000); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + JSONObject data = JSONUtil.parseObj(post).getJSONObject("data"); + int whereAbouts = data.getInt("whereAbouts"); + sendWhereAbouts(ssjDevice,whereAbouts); + } + + + } + } + + /** + * ÊäËÍ»úµ÷¶È + * + * @param ssjDevice + */ + private void ssj_dd(SSJ_Device ssjDevice,List jxList) throws Exception { + if (ssjDevice.exceptionId == 0 && ssjDevice.DW == 1 && ssjDevice.RWH > 0 && StrUtil.isNotBlank(ssjDevice.trayCode) ) { + + + + //ÅжÏÊdzö¿âÈÎÎñ »¹ÊǼðÑ¡ÈÎÎñ + MydoJob mydoJob = QueryDbDataUtils.getMyDoJobByTrayCode(m_dao, String.valueOf(ssjDevice.trayCode)); + + if (mydoJob != null) { + if ("G2049".equals(mydoJob.getExit_id())) { + //Ö´Ðгö¿âÈÎÎñ + int taskNo; + int jym; + byte[] sendData; + int isSend; + int qx=2 ; + int sendCompleted=1; + //ͨ¹ý×÷Òµ³ö¿ÚºÅÅÐ¶Ï + //Ï·¢ÊäËÍ»úÇëÇó ÖÁ¼ðÑ¡¿Ú + taskNo = Convert.toInt(ssjDevice.RWH); + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted,qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢G2049³ö¿âÈÎÎñ" + taskNo + "³É¹¦£¡"); + m_dao.updateSql("update MydoJob set class_now_name='"+qx+"' where task_no='" + taskNo + "'"); + + } + } else if ( + Convert.toInt(mydoJob.getIn_or_out())>9 && ("G2026".equals(mydoJob.getExit_id()) ||"G2041".equals(mydoJob.getExit_id())) + ) { + + if (mydoJob.getExecution_phase().equals("5")){ + DateTime startTime = DateUtil.parse(mydoJob.getStart_time()); + DateTime currentTime = DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + if (DateUtil.between(startTime, currentTime, DateUnit.SECOND) > 20) { + String exitId = mydoJob.getExit_id(); + int whereAbouts = 0; + if (exitId.equals("G2026")){ + whereAbouts = 1 ; + }else if (exitId.equals("G2041")){ + whereAbouts = 2 ; + } + sendWhereAbouts(ssjDevice, whereAbouts); + } + + }else { + String exitId = mydoJob.getExit_id(); + int whereAbouts = 0; + if (exitId.equals("G2026")){ + whereAbouts = 1 ; + }else if (exitId.equals("G2041")){ + whereAbouts = 2 ; + } + sendWhereAbouts(ssjDevice, whereAbouts); + } + + } + } + } + + catchException(ssjDevice); + } + + private static void catchException(SSJ_Device ssjDevice) throws Exception { + if (ssjDevice.exceptionId == 7 && ssjDevice.DW == 1 && ssjDevice.RWH > 0 && StrUtil.isBlank(ssjDevice.trayCode)){ + //µ÷ÓÃÓÃÒì³£Éϱ¨½Ó¿Ú + //ÇëÇówms½Ó¿Ú + Map map = new HashMap<>(); + map.put("trayCode", ssjDevice.trayCode); + map.put("errorType", ssjDevice.exceptionId); + map.put("jobId", IdUtil.getSnowflakeNextIdStr()); + String post = HttpUtil.post(taskExceptionUpload.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(post); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("·¢ËÍɨÃèÒì³£" + ssjDevice.ssjNo+":" + post ); + } + } + + private void sendWhereAbouts(SSJ_Device ssjDevice, int whereAbouts) throws Exception { + int qx; + int isSend; + int taskNo; + byte[] sendData; + int sendCompleted; + switch (whereAbouts) { + case 1: + //ͨ¹ý×÷Òµ³ö¿ÚºÅÅÐ¶Ï + //Ï·¢ÊäËÍ»úÇëÇó ÖÁ¼ðÑ¡¿Ú + sendCompleted = 1; + qx = 33; + taskNo = Convert.toInt(ssjDevice.RWH); + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted, qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢¼ðÑ¡¿Ú1ÈÎÎñ" + taskNo + "³É¹¦£¡"); + m_dao.updateSql("update MydoJob set class_now_name='" + qx + "', execution_phase=5,car_number='" + ssjDevice.ssjNo + "' where task_no='" + taskNo + "'"); + /*if (ssjDevice.RWH==taskNo){ + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢¼ðÑ¡¿Ú1ÈÎÎñ" + taskNo + "³É¹¦£¡"); + + }*/ + + } + + break; + case 2: + //ͨ¹ý×÷Òµ³ö¿ÚºÅÅÐ¶Ï + //Ï·¢ÊäËÍ»úÇëÇó ÖÁ¼ðÑ¡¿Ú + taskNo = Convert.toInt(ssjDevice.RWH); + sendCompleted = 1; + qx = 34; + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted, qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢¼ðÑ¡¿Ú2ÈÎÎñ" + taskNo + "³É¹¦£¡"); + m_dao.updateSql("update MydoJob set class_now_name='" + qx + "', execution_phase=5,car_number='" + ssjDevice.ssjNo + "' where task_no='" + taskNo + "'"); + /*if (ssjDevice.RWH==taskNo){ + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢¼ðÑ¡¿Ú2ÈÎÎñ" + taskNo + "³É¹¦£¡"); + + }*/ + + } + + break; + case 3: + //»Ø¿â ´¦Àí³ö¿â×÷Òµ + //Ï·¢ÊäËÍ»úÇëÇó »Ø¿â + //²éѯ»ØÁ÷×÷Òµ + MydoJob job = QueryDbDataUtils.getHlMyDoJobByTaskNo(m_dao, ssjDevice.trayCode); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + taskNo = Convert.toInt(job.getTask_no()); + qx = 1; + sendCompleted = 1; + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted, qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + Logger.info("ÏòÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢»ØÁ÷ÈÎÎñ" + taskNo + "³É¹¦£¡"); + //×÷Òµ¿ªÊ¼ + m_dao.updateSql("update MydoJob set status=3, class_now_name='" + qx + "', start_time='" + format + "',execution_phase= 2,car_number='" + ssjDevice.ssjNo + "' where task_no='" + job.getTask_no() + "'"); + + } + break; + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/ControlThread.java b/src/com/wms/dss/ats/customs/abb/schedule/ControlThread.java new file mode 100644 index 0000000..2fcacbd --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ControlThread.java @@ -0,0 +1,287 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.List; +import java.text.*; + +/* + ����߳� + *@Version 1.0 + **/ +public class ControlThread extends CraneThread { + + String strConfigPath = ""; + Hashtable hsComParamDDJ1 = null; + Hashtable hsComParamDDJ2 = null; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public ControlThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + hsComParamDDJ1 = (Hashtable) m_hsSysParam.get("hsComParamDDJ1"); + hsComParamDDJ2 = (Hashtable) m_hsSysParam.get("hsComParamDDJ2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("-------------------�豸����߳�-------����-------------------------------------"); + DbGet.hsComParamDDJ1 = hsComParamDDJ1; + DbGet.hsComParamDDJ2 = hsComParamDDJ2; + DbGet.hsComParamSSJ = hsComParamSSJ; + + //�Ѷ����� + List ddjList = DbGet.getDDJ_Tp_Devices(); + if (CollUtil.isNotEmpty(ddjList)) { + ddj_tp_jk(m_dao, ddjList); + } + List ddjLxDevices = DbGet.getDDJ_LX_Devices(); + if (CollUtil.isNotEmpty(ddjLxDevices)){ + ddj_lx_jk(m_dao, ddjLxDevices); + } + //���ͻ���� + List roadwaySsj = DbGet.getRoadwaySsj(); + if (CollUtil.isNotEmpty(roadwaySsj)){ + roadwaySsjJk(m_dao, roadwaySsj); + } + inStockSsjJk(m_dao, DbGet.getSmSsj(),2); + inStockSsjJk(m_dao,DbGet.getJKSsj(),1); + inStockSsjJk(m_dao,DbGet.getOutExitStockSsj(),3); + + + + + } catch (Exception e) { + e.printStackTrace(); + Logger.info("----------�豸����̳߳��쳣----�쳣��Ϣ��" + e.getMessage() + "��"); + } finally { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + //Logger.info("-------------------�豸����߳�-------����-------------------------------------"); + } + } + + private void ddj_lx_jk(EntityDAO m_dao, List ddjList) { + for (int i = 0; i < ddjList.size(); i++) { + DDJ_Device_2 ddj = ddjList.get(i); + int xtxh = 0; + if (ddj.CZFS==5){ + xtxh = ddj.XTXH; + } + int yl = 0; + int ml = 0; + if (ddj.DQL-1>=0){ + yl = ddj.DQL-1; + } + if (ddj.MBLH-1>=0){ + ml = ddj.MBLH-1; + } + //String errMsg = getZt(sbzt); + m_dao.updateSql("UPDATE MsgDdj " + + "SET " + + " rwh = "+ddj.ZXRWH_1+"," + + " jdbz = "+ddj.ZXJD+"," + + " sbzt = "+ddj.SBZT+"," + + " czfs = "+ddj.CZFS+"," + + " yxxf ="+ddj.YXXF+"," + + " yp = "+ddj.DQP+"," + + " yl = "+yl+"," + + " yc = "+ddj.DQC+"," + + " mbp = "+ddj.MBPH+"," + + " mbl = "+ml+"," + + " mbc = "+ddj.MBCH+"," + + " xtxh = "+xtxh+"," + + " rwh_2 = "+ddj.ZXRWH_2+"," + + " hczt = "+ddj.HCZT+"," + + " yxxf_2 = "+ddj.YXXF_2+"," + + " zxjd_2 = "+ddj.ZXJD_2+ + " WHERE" + + " id = "+ddj.btId); + + //�ж϶Ѷ��ִ�������Ƿ��쳣�����쳣���ұ�����¼�����޸����ñ±¨¾ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ + //���Ѷ��ִ�������������жϸ������Ƿ��б���δ��λ����������� + if (ddj.SBZT >1000){ + List list = m_dao.searchEntities("from BasFaultRecord where taskNo = " + ddj.ZXRWH_1 + " and jobId = 0"); + if (CollUtil.isEmpty(list)){ + if (ddj.ZXRWH_1!=0){ + BasFaultRecord basFaultRecord = new BasFaultRecord(); + basFaultRecord.setId(IdUtil.getSnowflakeNextIdStr()); + basFaultRecord.setDeviceId(String.valueOf(ddj.btId)); + basFaultRecord.setDeviceName(ddj.dName); + basFaultRecord.setDeviceType(String.valueOf(ddj.dtype)); + basFaultRecord.setTaskNo(String.valueOf(ddj.ZXRWH_1)); + basFaultRecord.setJobId("0"); + basFaultRecord.setFault(String.valueOf(ddj.SBZT)); + basFaultRecord.setStartTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + m_dao.save(basFaultRecord); + } + if (ddj.ZXRWH_2!=0){ + BasFaultRecord basFaultRecord = new BasFaultRecord(); + basFaultRecord.setId(IdUtil.getSnowflakeNextIdStr()); + basFaultRecord.setDeviceId(String.valueOf(ddj.btId)); + basFaultRecord.setDeviceName(ddj.dName); + basFaultRecord.setDeviceType(String.valueOf(ddj.dtype)); + basFaultRecord.setTaskNo(String.valueOf(ddj.ZXRWH_1)); + basFaultRecord.setJobId("0"); + basFaultRecord.setFault(String.valueOf(ddj.SBZT)); + basFaultRecord.setStartTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + m_dao.save(basFaultRecord); + } + + }else { + BasFaultRecord basFaultRecord = (BasFaultRecord) list.get(0); + basFaultRecord.setFinishTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + basFaultRecord.setJobId("1"); + m_dao.update(basFaultRecord); + } + } + + } + } + + private void inStockSsjJk(EntityDAO mDao, List inStockSsj,int type) { + for (SSJ_Device ssjDevice : inStockSsj) { + + int height = 0; + switch (ssjDevice.height){ + case 0: + height=800; + break; + case 1: + height=1000; + break; + case 2: + height=1300; + break; + } + if (type==1){ + mDao.updateSql( + "UPDATE MsgRkSsj SET rwh = '"+ssjDevice.RWH+"', rkqq = '"+ssjDevice.DW+"' "+", bjxx = '"+ssjDevice.exceptionId+"',tpjc='"+ssjDevice.trayCode+"' WHERE id = '"+ssjDevice.ssjNo+"'"); + }else if (type==2){ + mDao.updateSql( + "UPDATE MsgRkSsj SET rwh = '"+ssjDevice.RWH+"', height = '"+height+"', rkqq = '"+ssjDevice.RKQQ+"' "+", tpjc = '"+ssjDevice.trayCode+"', ljxh = '"+ssjDevice.LJXH+"',bjxx='"+ssjDevice.exceptionId+"' WHERE id = '"+ssjDevice.ssjNo+"'"); + }else if (type==3){ + mDao.updateSql( + "UPDATE MsgRkSsj SET rwh = '"+ssjDevice.RWH+"', ckkx = '"+ssjDevice.KX+"', rkqq = '"+ssjDevice.DW+"' "+", ljxh = '"+ssjDevice.LJXH+"' WHERE id = '"+ssjDevice.ssjNo+"'"); + + } + + + } + } + + private void roadwaySsjJk(EntityDAO mDao, List roadwaySsj) { + for (SSJ_Device ssjDevice : roadwaySsj) { + mDao.updateSql("UPDATE MsgXdkSsj " + + "SET " + + "ckkx = '"+ssjDevice.KX+"'," + + "ckdw = '"+ssjDevice.DW+"'," + + "ckrwh = '"+ssjDevice.RWH+"'," + + "rkdw = '"+ssjDevice.DW+"'," + + "location = '"+ssjDevice.trayCode+"'," + + "rkkx = '"+ssjDevice.KX +"'," + + "rkrwh = '"+ssjDevice.RWH+"' " + + "WHERE" + + " id = '"+ssjDevice.ssjNo+"'"); + } + } + + + + + + private void ddj_tp_jk(EntityDAO m_dao, List ddjList) throws Exception { + for (int i = 0; i < ddjList.size(); i++) { + DDJ_Device ddj = ddjList.get(i); + //String errMsg = getZt(sbzt); + int xtxh = 0; + if (ddj.CZFS==5){ + xtxh = ddj.XTXH; + } + + m_dao.updateSql("UPDATE MsgDdj " + + "SET " + + " rwh = "+ddj.ZXRWH+"," + + " hczt = "+ddj.HCZT+"," + + " jdbz = "+ddj.ZXJD+"," + + " sbzt = "+ddj.SBZT+"," + + " czfs = "+ddj.CZFS+"," + + " yxxf ="+ddj.YXXF+"," + + " yp = "+ddj.DQP+"," + + " yl = "+ddj.DQL+"," + + " yc = "+ddj.DQC+"," + + " mbp = "+ddj.MBPH+"," + + " mbl = "+ddj.MBLH+"," + + " mbc = "+ddj.MBCH+"," + + " xtxh = "+xtxh + + " WHERE" + + " id = "+ddj.btId); + + //�ж϶Ѷ��ִ�������Ƿ��쳣�����쳣���ұ�����¼�����޸����ñ±¨¾ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ + //���Ѷ��ִ�������������жϸ������Ƿ��б���δ��λ����������� + List list = m_dao.searchEntities("from BasFaultRecord where taskNo = " + ddj.ZXRWH + " and jobId = 0"); + if (ddj.SBZT >1000){ + if (CollUtil.isEmpty(list)){ + BasFaultRecord basFaultRecord = new BasFaultRecord(); + basFaultRecord.setId(IdUtil.getSnowflakeNextIdStr()); + basFaultRecord.setDeviceId(String.valueOf(ddj.btId)); + basFaultRecord.setDeviceName(ddj.dName); + basFaultRecord.setDeviceType(String.valueOf(ddj.dtype)); + basFaultRecord.setTaskNo(String.valueOf(ddj.ZXRWH)); + basFaultRecord.setJobId("0"); + basFaultRecord.setFault(String.valueOf(ddj.SBZT)); + basFaultRecord.setStartTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + m_dao.save(basFaultRecord); + } + }else{ + if (CollUtil.isNotEmpty(list)){ + BasFaultRecord basFaultRecord = (BasFaultRecord) list.get(0); + basFaultRecord.setFinishTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + basFaultRecord.setJobId("1"); + m_dao.update(basFaultRecord); + } + + } + + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/DDJThread.java b/src/com/wms/dss/ats/customs/abb/schedule/DDJThread.java new file mode 100644 index 0000000..269fa8d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/DDJThread.java @@ -0,0 +1,376 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientDDJ1; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientDDJ2; +import com.wms.dss.ats.customs.abb.utils.ProcedureResult; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.handleExceptionUrl; + +/* + *@Version 1.0 + * ¶Ñ¶â»úÏß³Ì + **/ +public class DDJThread extends CraneThread { + + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamDDJ1 = null; + Hashtable hsComParamDDJ2 = null; + Hashtable hsComParamSSJ = null; + + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public DDJThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + hsComParamDDJ1 = (Hashtable) m_hsSysParam.get("hsComParamDDJ1"); + hsComParamDDJ2 = (Hashtable) m_hsSysParam.get("hsComParamDDJ2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + return; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("=======================¶Ñ¶â»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamDDJ1 = hsComParamDDJ1; + DbGet.hsComParamDDJ2 = hsComParamDDJ2; + DbGet.hsComParamSSJ = hsComParamSSJ; + + int ddjh = 0; //¶Ñ¶â»úºÅ + try { ///¶Ñ¶â»úµ÷¶È + List ddj = DbGet.getDDJ_Tp_Devices(); + List tpOutRoadwaySsj = DbGet.getOutRoadwaySsj(); + if (!ddj.isEmpty()) { + for (DDJ_Device ddjDevice : ddj) { + //ÍÐÅ̶Ѷâ»ú + ddjh = ddjDevice.btId; + ddj_dd(ddjDevice, ddjh,tpOutRoadwaySsj); + } + } + + } catch (Exception ex) { + //conn.close(); + Logger.info("¶Ñ¶â»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ddjh + ex.getMessage()); + }///¶Ñ¶â»úµ÷¶È + } catch (Exception e) { + Logger.info("==========¶Ñ¶â»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + e.printStackTrace(); + } finally { + //Logger.info("=======================¶Ñ¶â»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(1500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + } + + + + + + + //¶Ñ¶â»úµ÷¶È + private void ddj_dd(DDJ_Device ddj_c, int ddjh,List tpOutRoadSsj) throws SQLException { + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + /* + µÚÒ»²¿·Ö + ¶Ñ¶â»úÏ߳̽øÀ´ºóµÚÒ»¼þÊÂÏȽøÐжѶâ»úÕýÖ´ÐÐÈÎÎñµÄÕËÎñ´¦Àí + ÒÔ·À´æÔÚ©´¦Àí£¬Ã»´¦ÀíµÄÇé¿ö·¢Éú + */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT==0 && ddj_c.ZXJD == 5) { /// + Long rwh = ddj_c.ZXRWH; + //¶Ñ¶â»ú·´À¡Íê³É£¬´¦ÀíÕËÎñ + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh); + if(queue != null){ + ddj_finish(m_dao, Long.parseLong(queue.getRwh())); + } + } + + /* + µÚ¶þ²¿·Ö + ¸ú×Ù¶ÓÁÐÖ´Ðн׶Π+ */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT==1 && (ddj_c.ZXJD == 2 || ddj_c.ZXJD == 3 || ddj_c.ZXJD == 4)) { + //¸ù¾Ý¶Ñ¶â»úÉÏÈÎÎñºÅ£¬ÐÞ¸ÄÈÎÎñÖ´Ðн׶Π+ long rwh = ddj_c.ZXRWH; + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh,null); + if (mydoJob!=null){ + m_dao.updateSql("update MydoJob set execution_phase = 6 where task_no = '" + rwh + "'"); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 10 where rwh= '"+rwh+"'"); + Logger.info("ÍÐÅ̶Ѷâ»ú¸ú×ÙÈÎÎñ״̬ rwh:"+rwh+",ZXJD:"+ddj_c.ZXJD); + } + } + + /* + µÚÈý²¿·Ö + ´¦Àí·½Ê½£ºÖØÐ·ÖÅ䴢λ + */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT == 1052 && ddj_c.ZXJD < 5 && ddj_c.YXXF ==1) { + //Åж϶Ѷâ»úÉÏÈÎÎñÊÇ·ñÒÑÖØ·Ö£¬ÈôÎ´ÖØ·Ö£¬Ôòµ÷Óýӿڣ¬ÇëÇóÖØ·Ö»õλ + long rwh = ddj_c.ZXRWH; + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh,Arrays.asList("1","3","21")); + if (queue != null && queue.getXcykh()==10 && mydoJob != null) { + if ("0".equals(mydoJob.getFault_flag())){ + m_dao.updateSql("update MydoJob set fault_flag = 1 where job_id = '"+mydoJob.getJob_id()+"'"); + } + mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh,Arrays.asList("1","3")); + if ("1".equals(mydoJob.getFault_flag())){ + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1052); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("ÍÐÅ̶Ѷâ»úrwh:"+rwh+",·Å»õÓлõÉϱ¨£º" + resultStr); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 1 where rwh= '"+rwh+"'"); + + } + } + } + + /* + µÚËIJ¿·Ö + Ö´Ðгö¿â×÷ҵʱȡ»õÔ´ÎÞ»õ + */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT == 1053 && ddj_c.ZXJD < 5) { + long rwh = ddj_c.ZXRWH; + //ÎÞ»õÒì³£´¦Àí + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh, Collections.singletonList("10")); + + if (queue != null && mydoJob != null) { + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1053); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("ÍÐÅ̶Ѷâ»úrwh:"+rwh+",È¡»õÎÞ»õÉϱ¨£º" + resultStr); + //Ö±½ÓÍê³É×÷Òµ + proc_wcs_ddj_info_ywh(m_dao,Convert.toLong(mydoJob.getTask_no())); + } + } + + + + + /* + µÚÁù²¿·Ö + ¸ø¶Ñ¶â»úÏ·¢ÈÎÎñ + */ + //·Å»õÄ¿±êÓлõÖØÐÂÏ·¢ + if (ddj_c.YXXF == 1 && ddj_c.CZFS == 5 && ddj_c.SBZT == 1052) { + long rwh = ddj_c.ZXRWH; + //Åж϶Ѷâ»úÉÏÈÎÎñºÅÊÇ·ñÒÑÖØ·ÖÍ꣬ÈôÖØ·ÖÍê³É£¬Ôò½«¶Ñ¶â»úÈÎÎñºÅ¶ÔÓ¦¶ÓÁÐÏ·¢ + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh,Arrays.asList("1","3","21")); + if(mydoJob!=null && "2".equals(mydoJob.getFault_flag())){ + WmsDeviceExecutionQueue queueByTask0 = QueryDbDataUtils.getQueueByTask0(m_dao, rwh); + int i = issuedDDJTask(1, queueByTask0); + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(queueByTask0.getRwh())); + //³õʼ»¯ Fault_flag 0 + m_dao.updateSql("update MydoJob set Fault_flag=0 where task_no='" + mydoJob.getTask_no() + "'"); + Logger.info("ÍÐÅ̶Ѷâ»úÖØÐÂÏ·¢ÈÎÎñ³É¹¦ rwh:"+rwh); + }else{ + Logger.error("¶Ñ¶â»úÖØÐÂÏ·¢Ê§°Ü£¡£¡£¡£¡£¡£¡£¡"); + } + } + } + //Õý³£Ï·¢ + if (ddj_c.YXXF == 1 && ddj_c.CZFS == 5 && ddj_c.SBZT == 0) { + long rwh = ddj_c.ZXRWH; + //¶Ô¶Ñ¶â»úÖ´ÐжÓÁÐÖÐÎÞÒÑÏ·¢¶ÓÁÐ + int count = QueryDbDataUtils.getWmsDeviceExecutionQueueByXF(m_dao,ddjh); + //È¡¶Ñ¶â»ú¶ÓÁÐÖУ¬Éú³Éʱ¼ä×îÔçµÄÖ´ÐжÓÁÐÏ·¢ + if(count==0){ + TaskPriority taskPriority = QueryDbDataUtils.getTaskPriority(m_dao,ddjh); + WmsDeviceExecutionQueue firstWmsDeviceExecutionQueue = null; + if (taskPriority.getPriority().equals("1")){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + }else if (taskPriority.getPriority().equals("2")){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"2"); + List allOutWmsDeviceExecutionQueueOrderbyRwlx = QueryDbDataUtils.getAllOutWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh); + if (CollUtil.isNotEmpty(allOutWmsDeviceExecutionQueueOrderbyRwlx)){ + for (WmsDeviceExecutionQueue outWmsDeviceExecutionQueueOrderbyRwlx : allOutWmsDeviceExecutionQueueOrderbyRwlx) { + int rwlx = outWmsDeviceExecutionQueueOrderbyRwlx.getRwlx(); + if (rwlx==10){ + Optional first = tpOutRoadSsj.stream().filter(x -> x.ssjNo.equals("L1001") && x.KX == 1).findFirst(); + if (first.isPresent()){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh, 10); + break; + } + } else if (rwlx==14) { + Optional first = tpOutRoadSsj.stream().filter(x -> x.ssjNo.equals("L2001") && x.KX == 1).findFirst(); + if (first.isPresent()){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh, 14); + break; + } + } else if (rwlx==12) { + Optional first = tpOutRoadSsj.stream().filter(x -> x.ssjNo.equals("G2050-2") && x.KX == 1).findFirst(); + if (first.isPresent()){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh, 12); + break; + } + } else if (rwlx==13) { + Optional first = tpOutRoadSsj.stream().filter(x -> x.ssjNo.equals("G2051-2") && x.KX == 1).findFirst(); + if (first.isPresent()){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh, 13); + break; + } + } + } + if (firstWmsDeviceExecutionQueue==null){ + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + } + }else { + firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + } + + } + if(firstWmsDeviceExecutionQueue==null){ + //Logger.error("¶Ñ¶â»ú¶ÓÁÐÖÐÎÞÖ´ÐжÓÁУ¡£¡£¡£¡£¡£¡£¡"); + return; + } + int i = issuedDDJTask(ddjh, firstWmsDeviceExecutionQueue); + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(firstWmsDeviceExecutionQueue.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+firstWmsDeviceExecutionQueue.getRwh()); + Logger.info("ÍÐÅ̶Ѷâ»úÏ·¢ÈÎÎñ³É¹¦ rwh:"+rwh); + }else{ + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¡£¡£¡£¡£¡£¡£¡"); + } + } + } + + } catch (Exception e) { + Logger.error(e); + } + } + + + /** + * µ÷Óô洢¹ý³Ìproc_ddj_finish Íê³ÉddjÈÎÎñ + */ + private void ddj_finish(EntityDAO m_dao, long taskNo) { + StoredParameters ddjhParameter = new StoredParameters(1, String.valueOf(taskNo)); + StoredParameters result = new StoredParameters(2, ""); + StoredParameters result_msg = new StoredParameters(3, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_ddj_finish(?,?,?)}", + 2, 3, ddjhParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_ddj_finish ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + taskNo); + break; + case 9: + Logger.info("proc_ddj_finish ´æ´¢¹ý³ÌÎÊÌ⣬Çë¼ì²é"); + break; + case 10: + Logger.info("proc_ddj_finish Ö´Ðгɹ¦ ÈÎÎñºÅ£º"+ taskNo); + break; + default: + throw new SQLException("proc_ddj_finish δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}",exception.getMessage()); + } + } + + + private void proc_wcs_ddj_info_ywh(EntityDAO m_dao, Long rwh) { + StoredParameters taskParameter = new StoredParameters(1, String.valueOf(rwh)); + try { + int back = Tools.storedProcedure(m_dao, "{call proc_wcs_ddj_info_ywh(?,?)}", 2, taskParameter); + switch (back) { + case 10: + Logger.info("proc_wcs_ddj_info_ywh Ö´Ðгɹ¦£¬ÈÎÎñºÅ£º" + rwh); + break; + case 1: + Logger.info("proc_wcs_ddj_info_ywh ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + rwh); + break; + default: + throw new SQLException("proc_wcs_ddj_info_ywh δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + rwh); + } + } catch (SQLException throwables) { + Logger.error(throwables); + } + } + + /** + * ¸ø¶Ñ¶â»úÏ·¢ÈÎÎñ + * @param queue ¶Ñ¶â»úÖ´ÐеĶÓÁÐ + */ + private int issuedDDJTask(int devId, WmsDeviceExecutionQueue queue) { + long taskNo =Integer.parseInt(queue.getRwh()) ; + int yph = queue.getYph(); + int ylh = queue.getYlh(); + int ych = queue.getYch(); + int mbph = queue.getMbph(); + int mblh = queue.getMblh(); + int mbch = queue.getMbch(); + int mlfs = 5; + int xfwc = 1; + int jym = Tools.getJYM((int) taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc,jym); + + + return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/DDJThread2.java b/src/com/wms/dss/ats/customs/abb/schedule/DDJThread2.java new file mode 100644 index 0000000..e3ebbf3 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/DDJThread2.java @@ -0,0 +1,643 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.convert.Convert; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientDDJ1; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientDDJ2; +import com.wms.dss.ats.customs.abb.utils.ProcedureResult; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.handleExceptionUrl; + +/* + *@Version 1.0 + * ¶Ñ¶â»úÏß³Ì + **/ +public class DDJThread2 extends CraneThread { + + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamDDJ1 = null; + Hashtable hsComParamDDJ2 = null; + Hashtable hsComParamSSJ = null; + int count = 0; + int count1 = 0; + + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public DDJThread2(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + hsComParamDDJ1 = (Hashtable) m_hsSysParam.get("hsComParamDDJ1"); + hsComParamDDJ2 = (Hashtable) m_hsSysParam.get("hsComParamDDJ2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + return; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("=======================¶Ñ¶â»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamDDJ1 = hsComParamDDJ1; + DbGet.hsComParamDDJ2 = hsComParamDDJ2; + DbGet.hsComParamSSJ = hsComParamSSJ; + + int ddjh = 0; //¶Ñ¶â»úºÅ + try { ///¶Ñ¶â»úµ÷¶È + + List ddjLxDevices = DbGet.getDDJ_LX_Devices(); + List doubleRoadway = DbGet.getDoubleRoadway(); + List jxSsj = DbGet.getJxSsj(); + if (!ddjLxDevices.isEmpty()) { + for (DDJ_Device_2 ddjLxDevice : ddjLxDevices) { + ddjh = ddjLxDevice.btId; + ddj_lx_dd(ddjLxDevice, ddjh,doubleRoadway,jxSsj); + } + } + } catch (Exception ex) { + //conn.close(); + Logger.info("¶Ñ¶â»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ddjh + ex.getMessage()); + }///¶Ñ¶â»úµ÷¶È + } catch (Exception e) { + Logger.info("==========¶Ñ¶â»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + e.printStackTrace(); + } finally { + //Logger.info("=======================¶Ñ¶â»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(1500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + } + + /** + * ÁÏÏä¶Ñ¶â»úµ÷¶È + */ + private void ddj_lx_dd(DDJ_Device_2 ddj_c, int ddjh,List doubleRoadway,List jx) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + /* + µÚÒ»²¿·Ö + ¶Ñ¶â»úÏ߳̽øÀ´ºóµÚÒ»¼þÊÂÏȽøÐжѶâ»úÕýÖ´ÐÐÈÎÎñµÄÕËÎñ´¦Àí + ÒÔ·À´æÔÚ©´¦Àí£¬Ã»´¦ÀíµÄÇé¿ö·¢Éú + */ + if (ddj_c.CZFS == 5 && ddj_c.ZXJD == 5) { /// + long zwh1 = ddj_c.ZXRWH_1; + //¶Ñ¶â»ú·´À¡Íê³É£¬´¦ÀíÕËÎñ + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, zwh1); + if(queue != null){ + ddj_finish(m_dao, Long.parseLong(queue.getRwh())); + } + } + if (ddj_c.CZFS == 5 && ddj_c.ZXJD_2 == 5) { /// + long zwh2 = ddj_c.ZXRWH_2; + //¶Ñ¶â»ú·´À¡Íê³É£¬´¦ÀíÕËÎñ + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, zwh2); + if(queue != null){ + ddj_finish(m_dao, Long.parseLong(queue.getRwh())); + } + } + + /* + µÚ¶þ²¿·Ö + ¸ú×Ù¶ÓÁÐÖ´Ðн׶Π+ */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT==1 && (ddj_c.ZXJD == 2 || ddj_c.ZXJD == 3 || ddj_c.ZXJD == 4)) { + long zwh1 = ddj_c.ZXRWH_1; + //¸ù¾Ý¶Ñ¶â»úÉÏÈÎÎñºÅ£¬ÐÞ¸ÄÈÎÎñÖ´Ðн׶Π+ MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, zwh1,null); + if (mydoJob!=null){ + m_dao.updateSql("update MydoJob set execution_phase = 6 where task_no = '"+zwh1+"'"); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 10 where rwh= '"+zwh1+"'"); + } + } + if (ddj_c.CZFS == 5 && ddj_c.SBZT == 1 && (ddj_c.ZXJD_2 == 2 || ddj_c.ZXJD_2 == 3 || ddj_c.ZXJD_2 == 4)) { + long zwh2 = ddj_c.ZXRWH_2; + //¸ù¾Ý¶Ñ¶â»úÉÏÈÎÎñºÅ£¬ÐÞ¸ÄÈÎÎñÖ´Ðн׶Π+ MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, zwh2, null); + if (mydoJob != null) { + m_dao.updateSql("update MydoJob set execution_phase = 6 where task_no = '" + zwh2 + "'"); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 10 where rwh= '"+zwh2+"'"); + + } + } + + /* + µÚÈý²¿·Ö + ¶Ñ¶â»ú·Å»õÄ¿±êÓлõ + ´¦Àí·½Ê½£ºÖØÐ·ÖÅ䴢λ + */ + if (ddj_c.CZFS == 5 && (ddj_c.SBZT == 1046 || ddj_c.SBZT == 1065) && ddj_c.ZXJD < 5) { + if (count<10){ + count++; + return; + } + long rwh1 =ddj_c.ZXRWH_1; + //Åж϶Ѷâ»úÉÏÈÎÎñÊÇ·ñÒÑÖØ·Ö£¬ÈôÎ´ÖØ·Ö£¬Ôòµ÷Óýӿڣ¬ÇëÇóÖØ·Ö»õλ + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh1); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh1,Arrays.asList("1","3","21")); + if (queue != null && queue.getXcykh()==10 && mydoJob != null) { + if ("0".equals(mydoJob.getFault_flag())){ + m_dao.updateSql("update MydoJob set fault_flag = 1 where job_id = '"+mydoJob.getJob_id()+"'"); + } + mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh1,Arrays.asList("1","3","21")); + if ("1".equals(mydoJob.getFault_flag())){ + + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1052); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("¹¤Î»1ÖØ·Ö»õλ rwh:"+rwh1); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 1 where rwh= '"+rwh1+"'"); + + //Logger.info("½Ó¿Ú·µ»Ø½á¹û{}" + resultStr); + } + } + } + if (ddj_c.CZFS == 5 && (ddj_c.SBZT == 1062 || ddj_c.SBZT == 1066) && ddj_c.ZXJD_2 < 5) { + if (count1<10){ + count1++; + return; + } + long rwh2 = ddj_c.ZXRWH_2; + //Åж϶Ѷâ»úÉÏÈÎÎñÊÇ·ñÒÑÖØ·Ö£¬ÈôÎ´ÖØ·Ö£¬Ôòµ÷Óýӿڣ¬ÇëÇóÖØ·Ö»õλ + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh2); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh2,Arrays.asList("1","3","21")); + if (queue != null && queue.getXcykh()==10 && mydoJob != null) { + if ("0".equals(mydoJob.getFault_flag())){ + m_dao.updateSql("update MydoJob set fault_flag = 1 where job_id = '"+mydoJob.getJob_id()+"'"); + } + mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh2,Arrays.asList("1","3","21")); + if ("1".equals(mydoJob.getFault_flag())){ + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1052); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("¹¤Î»2ÖØ·Ö»õλ rwh:"+rwh2); + m_dao.updateSql("update WmsDeviceExecutionQueue set xcykh = 1 where rwh= '"+rwh2+"'"); + + Logger.info("½Ó¿Ú·µ»Ø½á¹û{}" + resultStr); + } + } + } + + /* + µÚËIJ¿·Ö + Ö´Ðгö¿â×÷ҵʱȡ»õÔ´ÎÞ»õ + */ + if (ddj_c.CZFS == 5 && ddj_c.SBZT == 1047 && ddj_c.ZXJD < 5) { + long rwh1 = ddj_c.ZXRWH_1; + //ÎÞ»õÒì³£´¦Àí + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh1); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh1, Collections.singletonList("10")); + + if (queue != null && mydoJob != null) { + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1053); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("½Ó¿Ú·µ»Ø½á¹û{}" + resultStr); + //Ö±½ÓÍê³É×÷Òµ + proc_wcs_ddj_info_ywh(m_dao,Convert.toLong(mydoJob.getTask_no())); + } + } + if (ddj_c.CZFS == 5 && ddj_c.SBZT == 1063 && ddj_c.ZXJD_2 < 5) { + long rwh2 = ddj_c.ZXRWH_2; + //ÎÞ»õÒì³£´¦Àí + WmsDeviceExecutionQueue queue = QueryDbDataUtils.getQueueByTask(m_dao, rwh2); + MydoJob mydoJob = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh2, Collections.singletonList("10")); + + if (queue != null && mydoJob != null) { + //ÐÞ¸ÄÖ´ÐжÓÁÐ + //m_dao.updateSql("update wms_Device_execution_queue set rwzt ='" + ddj_c.SBZT + "' where rwh='" + mydoJob.getTask_no() + "'"); + Map map = new HashMap<>(); + map.put("jobId",mydoJob.getClass_id()); + map.put("errorType",1053); + map.put("trayCode",mydoJob.getTray_code()); + //½âÎö·µ»Ø½á¹û + String resultStr = HttpUtil.post(handleExceptionUrl.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + Logger.info("½Ó¿Ú·µ»Ø½á¹û{}" + resultStr); + //Ö±½ÓÍê³É×÷Òµ + proc_wcs_ddj_info_ywh(m_dao,Convert.toLong(mydoJob.getTask_no())); + } + } + + + + + /* + µÚÁù²¿·Ö + ¸ø¶Ñ¶â»úÏ·¢ÈÎÎñ + */ + //·Å»õÄ¿±êÓлõÖØÐÂÏ·¢ + if (ddj_c.YXXF == 1 && ddj_c.CZFS == 5 && (ddj_c.SBZT == 1046|| ddj_c.SBZT == 1062 || ddj_c.SBZT == 1065 || ddj_c.SBZT==1066)) { + long rwh1 = ddj_c.ZXRWH_1; + long rwh2 = ddj_c.ZXRWH_2; + Thread.sleep(100); + //´¦Àí»õ²æ1µÄÖØÐÂÏ·¢ + if (ddj_c.ZXJD == 3 && (ddj_c.SBZT == 1046|| ddj_c.SBZT == 1065)){ + MydoJob mydoJob1 = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh1,Arrays.asList("1","3","21")); + if (mydoJob1 != null && mydoJob1.getFault_flag().equals("2")) { + WmsDeviceExecutionQueue queueBegin = QueryDbDataUtils.findDeviceQueueByTaskNo(m_dao, ddjh, rwh1, 1); + WmsDeviceExecutionQueue queueSecond = QueryDbDataUtils.findDeviceQueueByTaskNo(m_dao, ddjh, rwh2, 1); + if (queueBegin !=null && queueSecond ==null){ + int i = issuedDDJTaskTwoWork(ddjh, queueBegin,queueSecond); + if (i == 1) { + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao, Long.valueOf(queueBegin.getRwh())); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + count = 0; + //³õʼ»¯ Fault_flag 0 + m_dao.updateSql("update MydoJob set Fault_flag=0 where task_no='" + queueBegin.getRwh() + "'"); + } else { + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¡£¡£¡£¡£¡£¡£¡"); + } + } + + if (queueSecond !=null && queueBegin!=null){ + //Á½¸öλÖö¼¿ÕÏУ¬¶¼¿ÉÒÔÏ·¢,±ØÐë¸ù¾Ý»õ²æÄ£Ê½Ï·¢ + int i = issuedDDJTaskTwoWork(ddjh, queueBegin, queueSecond); + + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(queueBegin.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4,Fault_flag=0 where task_no="+queueBegin.getRwh()); + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(queueSecond.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+queueSecond.getRwh()); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + count = 0; + + }else{ + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¬ÖØÐÂÏ·¢£¡£¡£¡£¡£¡£¡£¡"); + } + } + } + + } + + + if (ddj_c.ZXJD_2 == 3 && (ddj_c.SBZT == 1062 || ddj_c.SBZT == 1066)){ + MydoJob mydoJob2 = QueryDbDataUtils.getSlotJobByTask(m_dao, rwh2,Arrays.asList("1","3","21")); + if (mydoJob2 != null && mydoJob2.getFault_flag().equals("2")) { + WmsDeviceExecutionQueue queueBegin = QueryDbDataUtils.findDeviceQueueByTaskNo(m_dao, ddjh, rwh1, 1); + WmsDeviceExecutionQueue queueSecond = QueryDbDataUtils.findDeviceQueueByTaskNo(m_dao, ddjh, rwh2, 1); + if (queueSecond !=null && queueBegin == null){ + int i = issuedDDJTaskTwoWork(ddjh, null, queueSecond); + if (i == 1) { + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao, Long.valueOf(queueSecond.getRwh())); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + count1 = 0; + //³õʼ»¯ Fault_flag 0 + m_dao.updateSql("update MydoJob set Fault_flag=0 where task_no='" + queueSecond.getRwh() + "'"); + } else { + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¡£¡£¡£¡£¡£¡£¡"); + } + } + + if (queueSecond !=null && queueBegin!=null){ + //Á½¸öλÖö¼¿ÕÏУ¬¶¼¿ÉÒÔÏ·¢,±ØÐë¸ù¾Ý»õ²æÄ£Ê½Ï·¢ + int i = issuedDDJTaskTwoWork(ddjh, queueBegin,queueSecond ); + + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(queueBegin.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+queueBegin.getRwh()); + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(queueSecond.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4,Fault_flag=0 where task_no="+queueSecond.getRwh()); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + count1 = 0; + }else{ + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¬ÖØÐÂÏ·¢£¡£¡£¡£¡£¡£¡£¡"); + } + } + } + + } + } + + //Õý³£Ï·¢ + if (ddj_c.YXXF == 1 && ddj_c.CZFS == 5) { + int count = QueryDbDataUtils.getWmsDeviceExecutionQueueByXF(m_dao,ddjh); + + if(count==0 ){ + WmsDeviceExecutionQueue firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh,6); + if (firstQueue !=null){ + sendRw(ddjh, doubleRoadway, firstQueue); + }else { + TaskPriority taskPriority = QueryDbDataUtils.getTaskPriority(m_dao,ddjh); + if (taskPriority.getPriority().equals("1")){ + //RK + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + sendRw(ddjh, doubleRoadway, firstQueue); + }else if (taskPriority.getPriority().equals("2")){ + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"2"); + if (firstQueue !=null){ + if (firstQueue.getRwlx() == 16){ + //ÓÅÏÈÒÆ¿â + sendRw(ddjh, doubleRoadway, firstQueue); + }else if (firstQueue.getRwlx()==15){ + //¶þ²ã³ö¿â + if (jx.stream().anyMatch(x->x.KX==1)){ + //CK 2015 + sendRw(ddjh, doubleRoadway, firstQueue); + }else { + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh,11); + if (firstQueue !=null){ + //CK 1012 + sendRw(ddjh, doubleRoadway, firstQueue); + }else { + //RK + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + sendRw(ddjh, doubleRoadway, firstQueue); + } + } + }else { + //Ò»²ã³ö¿â + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueByRwlx(m_dao, ddjh,11); + if (firstQueue !=null){ + //CK 1012 + sendRw(ddjh, doubleRoadway, firstQueue); + }else { + //RK + firstQueue = QueryDbDataUtils.getFirstWmsDeviceExecutionQueueOrderbyRwlx(m_dao, ddjh,"1"); + sendRw(ddjh, doubleRoadway, firstQueue); + } + } + + } + } + } + } + } + + } catch (Exception e) { + Logger.error(e); + } + } + + private void sendRw(int ddjh, List doubleRoadway, WmsDeviceExecutionQueue firstQueue) throws Exception { + if (firstQueue!=null){ + //¸ù¾ÝÈÎÎñÀàÐͲéѯÊÇ·ñ´æÔÚµÚ¶þ¶ÓÁÐ + WmsDeviceExecutionQueue secondQueue = QueryDbDataUtils.getSecondQueueByDdjhAndRwlx(m_dao, ddjh, firstQueue.getRwlx(), firstQueue.getRwh()); + + if (secondQueue != null){ + WmsDeviceExecutionQueue firstRunningQueue = null; + WmsDeviceExecutionQueue secondRunningQueue = null; + //È¡³öË«¹¤Î»ÈÎÎñºÅ£¬°´ÕÕ1-1 1-2ÅÅÐòÏ·¢ÈÎÎñ + if (firstQueue.getRwlx() ==2){ + //G1011-1-1 + Optional first = doubleRoadway.stream().filter(x -> x.ssjNo.equals("G1011-1-1")).findFirst(); + if (first.isPresent()){ + if (firstQueue.getRwh().equals(Convert.toStr(first.get().RWH))){ + firstRunningQueue = firstQueue; + secondRunningQueue = secondQueue; + }else if (secondQueue.getRwh().equals(Convert.toStr(first.get().RWH))){ + firstRunningQueue = secondQueue; + secondRunningQueue = firstQueue; + }else { + firstRunningQueue = firstQueue; + secondRunningQueue = secondQueue; + } + }else { + Logger.error("δÕÒµ½Ë«¹¤Î»ÊäËÍ»úÐÅÏ¢"); + throw new RuntimeException("δÕÒµ½Ë«¹¤Î»ÊäËÍ»úÐÅÏ¢"); + } + }else if (firstQueue.getRwlx() ==6){ + //G2016-1-1 + Optional first = doubleRoadway.stream().filter(x -> x.ssjNo.equals("G2016-1-1")).findFirst(); + if (first.isPresent()){ + if (firstQueue.getRwh().equals(Convert.toStr(first.get().RWH))){ + firstRunningQueue = firstQueue; + secondRunningQueue = secondQueue; + }else if (secondQueue.getRwh().equals(Convert.toStr(first.get().RWH))){ + firstRunningQueue = secondQueue; + secondRunningQueue = firstQueue; + }else { + firstRunningQueue = firstQueue; + secondRunningQueue = secondQueue; + } + }else { + Logger.error("δÕÒµ½Ë«¹¤Î»ÊäËÍ»úÐÅÏ¢"); + throw new RuntimeException("δÕÒµ½Ë«¹¤Î»ÊäËÍ»úÐÅÏ¢"); + } + }else { + //³ö¿âÈÎÎñÏ·¢ + firstRunningQueue = firstQueue; + secondRunningQueue = secondQueue; + } + + //Á½¸öλÖö¼¿ÕÏУ¬¶¼¿ÉÒÔÏ·¢,±ØÐë¸ù¾Ý»õ²æÄ£Ê½Ï·¢ + int i = issuedDDJTaskTwoWork(ddjh, firstRunningQueue, secondRunningQueue); + + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(firstQueue.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+ firstQueue.getRwh()); + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(secondQueue.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+secondQueue.getRwh()); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + }else{ + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¬ÖØÐÂÏ·¢£¡£¡£¡£¡£¡£¡£¡"); + } + }else { + //Ö»ÓÐÒ»¸öÈÎÎñ + int i = issuedDDJTaskTwoWork(ddjh, firstQueue,null); + + if (i==1){ + //¸üпªÊ¼Ê±¼ä£¬ÐÞ¸ÄddjxfΪÒÑÏ·¢1 + QueryDbDataUtils.updateWmsDeviceExecutionQueueTime(m_dao,Long.valueOf(firstQueue.getRwh())); + //¸ü¸ÄÖ´Ðн׶ÎΪ4 + m_dao.updateSql("update MydoJob set execution_phase= 4 where task_no="+ firstQueue.getRwh()); + Logger.info("¶Ñ¶â»úÏ·¢³É¹¦£¡£¡£¡£¡"); + }else{ + Logger.error("¶Ñ¶â»úÏ·¢Ê§°Ü£¬ÖØÐÂÏ·¢£¡£¡£¡£¡£¡£¡£¡"); + } + } + } + } + + + private int issuedDDJTaskTwoWork(int devId, WmsDeviceExecutionQueue queueFirst, WmsDeviceExecutionQueue queueSecond) { + int type = 0; + if (queueFirst != null && queueSecond ==null){ + type = 1; + queueSecond = new WmsDeviceExecutionQueue(); + queueSecond.setRwh("0"); + queueSecond.setYph(0); + queueSecond.setYlh(0); + queueSecond.setYch(0); + queueSecond.setMbch(0); + queueSecond.setMblh(0); + queueSecond.setMbch(0); + }else if (queueSecond !=null && queueFirst ==null){ + type = 2; + queueFirst = new WmsDeviceExecutionQueue(); + queueFirst.setRwh("0"); + queueFirst.setYph(0); + queueFirst.setYlh(0); + queueFirst.setYch(0); + queueFirst.setMbch(0); + queueFirst.setMblh(0); + queueFirst.setMbch(0); + }else { + type =3; + } + SendData task1Data = new SendData(Tools.DINT, queueFirst.getRwh()); + SendData yp1Data = new SendData(Tools.INT, queueFirst.getYph()); + SendData yl1Data = new SendData(Tools.INT, queueFirst.getYlh()); + SendData yc1Data = new SendData(Tools.INT, queueFirst.getYch()); + SendData mbp1Data = new SendData(Tools.INT, queueFirst.getMbph()); + SendData mbl1Data = new SendData(Tools.INT, queueFirst.getMblh()); + SendData mbc1Data = new SendData(Tools.INT, queueFirst.getMbch()); + SendData task2Data = new SendData(Tools.DINT, queueSecond.getRwh()); + SendData yp2Data = new SendData(Tools.INT, queueSecond.getYph()); + SendData yl2Data = new SendData(Tools.INT, queueSecond.getYlh()); + SendData yc2Data = new SendData(Tools.INT, queueSecond.getYch()); + SendData mbp2Data = new SendData(Tools.INT, queueSecond.getMbph()); + SendData mbl2Data = new SendData(Tools.INT, queueSecond.getMblh()); + SendData mbc2Data = new SendData(Tools.INT, queueSecond.getMbch()); + SendData hcmsData = new SendData(Tools.INT, type); + SendData mlfsData = new SendData(Tools.INT, 5); + SendData gw1 = new SendData(Tools.INT, 0); + SendData gw2 = new SendData(Tools.INT, 0); + SendData xfData = new SendData(Tools.INT, 1); + + int jym = Tools.getJYM(task1Data.getNum2(), yp1Data.getNum2(), yl1Data.getNum2(), yc1Data.getNum2(), mbp1Data.getNum2(), + mbl1Data.getNum2(), mbc1Data.getNum2(), task2Data.getNum2(), yp2Data.getNum2(), yl2Data.getNum2(), yc2Data.getNum2(), mbp2Data.getNum2(), + mbl2Data.getNum2(), mbc2Data.getNum2(), hcmsData.getNum2(), mlfsData.getNum2(),gw1.getNum2(),gw2.getNum2()); + SendData checkData = new SendData(Tools.INT, jym); + //ת»¯ÎªbyteÊý×é + byte[] sendData = Tools.sendData(task1Data, yp1Data, yl1Data, yc1Data, mbp1Data, + mbl1Data, mbc1Data, task2Data, yp2Data, yl2Data, yc2Data, mbp2Data, + mbl2Data, mbc2Data, hcmsData, mlfsData,gw1,gw2, xfData, checkData); + //·¢Ë͸øÉ豸 + return IsoTcpClientDDJ2.WritetoDDJ("DB5.0", sendData); + } + + + + /** + * µ÷Óô洢¹ý³Ìproc_ddj_finish Íê³ÉddjÈÎÎñ + */ + private void ddj_finish(EntityDAO m_dao, long taskNo) { + StoredParameters ddjhParameter = new StoredParameters(1, String.valueOf(taskNo)); + StoredParameters result = new StoredParameters(2, ""); + StoredParameters result_msg = new StoredParameters(3, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_ddj_finish(?,?,?)}", + 2, 3, ddjhParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_ddj_finish ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + taskNo); + break; + case 9: + Logger.info("proc_ddj_finish ´æ´¢¹ý³ÌÎÊÌ⣬Çë¼ì²é"); + break; + case 10: + Logger.info("proc_ddj_finish Ö´Ðгɹ¦ ÈÎÎñºÅ£º"+ taskNo); + break; + default: + throw new SQLException("proc_ddj_finish δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}",exception.getMessage()); + } + } + + + private void proc_wcs_ddj_info_ywh(EntityDAO m_dao, Long rwh) { + StoredParameters taskParameter = new StoredParameters(1, String.valueOf(rwh)); + try { + int back = Tools.storedProcedure(m_dao, "{call proc_wcs_ddj_info_ywh(?,?)}", 2, taskParameter); + switch (back) { + case 10: + Logger.info("proc_wcs_ddj_info_ywh Ö´Ðгɹ¦£¬ÈÎÎñºÅ£º" + rwh); + break; + case 1: + Logger.info("proc_wcs_ddj_info_ywh ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + rwh); + break; + default: + throw new SQLException("proc_wcs_ddj_info_ywh δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + rwh); + } + } catch (SQLException throwables) { + Logger.error(throwables); + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/DbGet.java b/src/com/wms/dss/ats/customs/abb/schedule/DbGet.java new file mode 100644 index 0000000..dfe99f7 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/DbGet.java @@ -0,0 +1,286 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.common.server.form.Logger; + +import java.util.*; + +/** + * @author 13623 + */ /* + *@Version 1.0 + * Êý¾Ý»ñÈ¡ + **/ +public class DbGet { + + static Hashtable hsComParamDDJ1 = null; + static Hashtable hsComParamDDJ2 = null; + static Hashtable hsComParamSSJ = null; + + + //»ñÈ¡¶Ñ¶â»ú״̬ + public static List getDDJ_Tp_Devices() { + List ls = new ArrayList<>(); + try { + HashMap hsDDJMap1 = (HashMap) hsComParamDDJ1.get("hsDDJMap1"); + ls.add((DDJ_Device) hsDDJMap1.get("ddj-1")); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡¶Ñ¶â»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + + public static List getDDJ_LX_Devices() { + List ls = new ArrayList<>(); + try { + HashMap hsDDJMap2 = (HashMap) hsComParamDDJ2.get("hsDDJMap2"); + ls.add((DDJ_Device_2) hsDDJMap2.get("ddj-2")); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡¶Ñ¶â»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + public static List getOutExitStockSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 1; i <= 10; i++) { + ls.add((SSJ_Device) hsSSJMap.get("inStockSsj-"+i)); + } + for (int i = 1; i <= 2; i++) { + ls.add((SSJ_Device) hsSSJMap.get("jxSsj-" + i)); + } + + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + /** + * »ñÈ¡¶þÂ¥×ó²àÊäËÍ»úÊÇ·ñ¿ÕÏÐ + * @return + */ + public static Map> getOutZtStockSsj() { + HashMap> kxOut = new HashMap<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + List L2001 = new ArrayList<>(); + L2001.add((SSJ_Device)hsSSJMap.get("inStockSsj-"+8)); + L2001.add((SSJ_Device)hsSSJMap.get("inStockSsj-"+9)); + L2001.add((SSJ_Device)hsSSJMap.get("inStockSsj-"+10)); + kxOut.put("L2001",L2001); + List G2050 = new ArrayList<>(); + G2050.add((SSJ_Device)hsSSJMap.get("inStockSsj-"+5)); + kxOut.put("G2050",G2050); + List G2051 = new ArrayList<>(); + G2051.add((SSJ_Device)hsSSJMap.get("inStockSsj-"+6)); + kxOut.put("G2051",G2051); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return kxOut; + } + + + public static List getRoadwaySsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 1; i <= 14; i++) { + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+i)); + } + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + + public static List getTransferSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 1; i <= 1; i++) { + ls.add((SSJ_Device) hsSSJMap.get("transferSsj-"+i)); + } + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getRackXh() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 1; i <= 2; i++) { + ls.add((SSJ_Device) hsSSJMap.get("rack-"+i)); + } + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÁϼÜ״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getSmSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 1; i <= 8; i++) { + ls.add((SSJ_Device) hsSSJMap.get("smSsj-"+i)); + } + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÁϼÜ״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getCbOutSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("smSsj-"+6)); + ls.add((SSJ_Device) hsSSJMap.get("smSsj-"+7)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÁϼÜ״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getJxSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("jxSsj-"+1)); + ls.add((SSJ_Device) hsSSJMap.get("jxSsj-"+2)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÁϼÜ״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getDoubleRoadway() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+3)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+11)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+8)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+14)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÁϼÜ״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + /** + * ÁÏÏä×ªÒÆÊäËÍ»ú + * @return + */ + public static List getFirstBoxSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+1)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + /** + * ÁÏÏäÇëÇóÈ¥ÏòÊäËÍ»ú + * @return + */ + public static List getRequestBoxSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+5)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+4)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + + public static List getJKSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("inStockSsj-"+4)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+1)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+2)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+3)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+4)); + ls.add((SSJ_Device) hsSSJMap.get("boxSsj-"+5)); + ls.add((SSJ_Device) hsSSJMap.get("inStockSsj-"+3)); + ls.add((SSJ_Device) hsSSJMap.get("transferSsj-"+1)); + + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getOutRoadwaySsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+1)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+5)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+9)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+10)); + + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } + + public static List getLxOutRoadwaySsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+7)); + ls.add((SSJ_Device) hsSSJMap.get("roadwaySsj-"+4)); + } catch (Exception ex) { + ex.printStackTrace(); + Logger.error("»ñÈ¡ÊäËÍ»ú״̬ÐÅÏ¢Òì³£" + ex.getMessage()); + } + return ls; + } +} + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/schedule/ExceptionUploadThread.java b/src/com/wms/dss/ats/customs/abb/schedule/ExceptionUploadThread.java new file mode 100644 index 0000000..46fec78 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ExceptionUploadThread.java @@ -0,0 +1,264 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientSSJ; +import com.wms.dss.ats.customs.abb.utils.ProcedureResult; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.util.*; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.getInStorageInformation; +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.taskExceptionUpload; + +public class ExceptionUploadThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public ExceptionUploadThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("=======================ÊäËÍ»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamSSJ = hsComParamSSJ; + int ssjH = 0; //¶Ñ¶â»úºÅ + + List smSsj = DbGet.getSmSsj(); + + + + if (!smSsj.isEmpty()) { + for (SSJ_Device ssj_device : smSsj) { + try { ///ÊäËÍ»úµ÷¶È + //ÊäËÍ»úÑ­»· + ssj_exception_dd(ssj_device); + } catch (Exception ex) { + //conn.close(); + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssj_device.ssjNo + ex.getMessage()); + } + } + } + } catch (Exception e) { + Logger.info("==========ÊäËÍ»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + Logger.error(e); + } finally { + //Logger.info("=======================ÊäËÍ»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(3000); + } catch (InterruptedException e) { + Logger.error(e); + } + } + } + } + + + + private void ssj_exception_dd(SSJ_Device ssjDevice) throws Exception { + + + if (ssjDevice.exceptionId != 0 && ssjDevice.CKKX ==0) { + + if (ssjDevice.ssjNo.equals("G2050")||ssjDevice.ssjNo.equals("G2051")){ + if (ssjDevice.exceptionId==7){ + return; + } + } + + //µ÷ÓÃÓÃÒì³£Éϱ¨½Ó¿Ú + //ÇëÇówms½Ó¿Ú + Map map = new HashMap<>(); + map.put("trayCode", ssjDevice.trayCode); + map.put("errorType", ssjDevice.exceptionId); + map.put("jobId", IdUtil.getSnowflakeNextIdStr()); + String post = HttpUtil.post(taskExceptionUpload.getUrl(), JSONUtil.toJsonStr(map)); + JSONObject entries = JSONUtil.parseObj(post); + if (!"0".equals(entries.get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } +// HashMap bean = JSONUtil.toBean(post, HashMap.class); + int exceptionId = ssjDevice.exceptionId; + if ((exceptionId>0&& exceptionId <=5) || exceptionId ==8){ + String trayCode = ssjDevice.trayCode; + if (StrUtil.isNotEmpty(trayCode)){ + //ÍâÐÎÒì³£1-5 ÖØÁ¿Òì³£8 + if ("L1009".equals(ssjDevice.ssjNo)) { + sleep(5000); + //Ï·¢ÐÅÏ¢ÖÁÒì³£¿Ú 1 + //ûÓÐÉú³ÉÈÎÎñµ½Òì³£¿Ú Ö¸¶¨ÈÎÎñºÅΪ500 + Map map1 = new HashMap<>(); + map1.put("trayCode", trayCode); + map1.put("exceptionId", ssjDevice.exceptionId); + map1.put("ssjNo", ssjDevice.ssjNo); + String post1 = HttpUtil.post("http://localhost:8089/external/log/exceptionInfoAdd", JSONUtil.toJsonStr(map1)); + if (!"0".equals(JSONUtil.parseObj(post1).get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + int taskNo = Convert.toInt(JSONUtil.parseObj(post1).get("data")); + //1 ΪÒì³£¿Ú + int qx = 99; + int sendCompleted = 1; + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx,sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢Òì³£¿ÚÈÎÎñ" + taskNo + "³É¹¦£¡"); + //m_dao.updateSql("update WcsPortState set occupationState=0,spare1=null,spare2='0' where portName='" + ssjDevice.ssjNo + "'"); + //m_dao.updateSql("update WcsPortState set spare3='"+ssjDevice.trayCode+"' where portName='L1004'"); + }else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷ҵʧ°Ü£¡£¡£¡"); + + } + } + if ("G2003".equals(ssjDevice.ssjNo)||"G2006".equals(ssjDevice.ssjNo)||"G2007".equals(ssjDevice.ssjNo) + ) { + sleep(5000); + String ssjNo = ssjDevice.ssjNo; + Map map1 = new HashMap<>(); + map1.put("trayCode", trayCode); + map1.put("exceptionId", ssjDevice.exceptionId); + map1.put("ssjNo", ssjNo); + String post1 = HttpUtil.post("http://localhost:8089/external/log/exceptionInfoAdd", JSONUtil.toJsonStr(map1)); + if (!"0".equals(JSONUtil.parseObj(post1).get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + int taskNo = Convert.toInt(JSONUtil.parseObj(post1).get("data")); + //Éϱ¨wms + ExceptionInfo exceptionInfo = QueryDbDataUtils.selectExceptionByPort(m_dao, ssjNo); + if (exceptionInfo != null) { + + if ("G2006".equals(ssjNo) || "G2007".equals(ssjNo)) { + MydoJob mydoJob = QueryDbDataUtils.selectJobByEntranceId(m_dao, ssjNo); + if (mydoJob != null) { + trayCode = mydoJob.getTray_code(); + } + } + + if (exceptionInfo.getSendCompleted().equals("0")) { + //Éϱ¨Òì³£ + Map mapError = new HashMap<>(); + mapError.put("trayCode", trayCode); + mapError.put("height", 3); + mapError.put("entranceId", ssjNo); + + String requestParam = JSONUtil.toJsonStr(mapError); + //ÇëÇówms½Ó¿Ú + String post2 = HttpUtil.post(getInStorageInformation.getUrl(), requestParam); + + //HashMap bean = JSONUtil.toBean(post2, HashMap.class); + + if (!"0".equals(JSONUtil.parseObj(post2).get("code").toString())){ + Logger.info("ÇëÇówms½Ó¿ÚÒì³£"); + throw new Exception("ÇëÇówms½Ó¿ÚÒì³£"); + } + QueryDbDataUtils.updateWcsPortState(m_dao, ssjNo, "1"); + m_dao.updateSql("update ExceptionInfo set sendCompleted = '1' where taskNo=" + taskNo); + + } + + + } + } + } + } + + } + + } + + + + /** + * ³ö¿â´æ´¢Á÷³Ì + * + */ + private void callCkProcess(long rwh) { + StoredParameters taskNoParameter = new StoredParameters(1, String.valueOf(rwh)); + StoredParameters result = new StoredParameters(2, ""); + StoredParameters result_msg = new StoredParameters(3, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_job_finish(?,?,?)}", + 2, 3, taskNoParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_job_finish ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + rwh); + break; + case 9: + Logger.info("proc_job_finish ´æ´¢¹ý³ÌÎÊÌ⣬Çë¼ì²é"); + break; + case 10: + Logger.info("proc_job_finish Ö´Ðгɹ¦ ÈÎÎñºÅ£º" + rwh); + break; + default: + throw new SQLException("proc_job_finish δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + rwh); + } + } catch (SQLException exception) { + Logger.error("e{}", exception.getMessage()); + } + + + } + + private void ssj_hldd(SSJ_Device ssjDevice) throws Exception { + //¼ì²âµ½ µ½Î»×´Ì¬ ÇëÇówmsÉú³ÉÈë¿â×÷Òµ + if (ssjDevice.DW == 1 && ssjDevice.exceptionId == 0) { + MydoJob job = QueryDbDataUtils.getHlMyDoJobByEntranceId(m_dao, ssjDevice.ssjNo); + if (ObjUtil.isNotNull(job)) { + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú + int taskNo = Integer.parseInt(job.getTask_no()); + int qx = 12; + //int jym = Tools.getJYM(taskNo); + byte[] sendData = Tools.sendDataToDevice(taskNo, ssjDevice.trayCode, qx); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢Èë¿âÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2 where task_no='" + taskNo + "'"); + } + } + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/InOutStockSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/InOutStockSsjThread.java new file mode 100644 index 0000000..d5c7f2a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/InOutStockSsjThread.java @@ -0,0 +1,420 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientSSJ; +import com.wms.dss.ats.customs.abb.utils.ProcedureResult; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.util.*; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.getInStorageInformation; +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.taskExceptionUpload; + +public class InOutStockSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public InOutStockSsjThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + //throw new RuntimeException(e); + } + try { + //Logger.info("=======================ÊäËÍ»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamSSJ = hsComParamSSJ; + int ssjH = 0; //¶Ñ¶â»úºÅ + List ckSsj = DbGet.getOutExitStockSsj(); + List smSsj = DbGet.getSmSsj(); + List cbSsj = DbGet.getCbOutSsj(); + if (!ckSsj.isEmpty()) { + for (SSJ_Device ssj_device : ckSsj) { + try { ///ÊäËÍ»úµ÷¶È + //ÊäËÍ»úÑ­»· + ssj_ck_dd(ssj_device); + } catch (Exception ex) { + //conn.close(); + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssj_device.ssjNo + ex.getMessage()); + } + } + } + + if (!cbSsj.isEmpty()) { + for (SSJ_Device ssj_device : cbSsj) { + try { ///ÊäËÍ»úµ÷¶È + //ÊäËÍ»úÑ­»· + ssj_cb_ck_dd(ssj_device); + } catch (Exception ex) { + //conn.close(); + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssj_device.ssjNo + ex.getMessage()); + } + } + } + + if (!smSsj.isEmpty()) { + for (SSJ_Device ssj_device : smSsj) { + try { ///ÊäËÍ»úµ÷¶È + //ÊäËÍ»úÑ­»· + ssj_rk_dd(ssj_device); + } catch (Exception ex) { + //conn.close(); + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssj_device.ssjNo + ex.getMessage()); + } + } + } + } catch (Exception e) { + Logger.info("==========ÊäËÍ»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + Logger.error(e); + } finally { + //Logger.info("=======================ÊäËÍ»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e); + } + } + } + } + + private void ssj_cb_ck_dd(SSJ_Device ssjDevice) { + //¼ì²âµ½Õý³£³ö¿â³ö¿âµ½Î» + if (ssjDevice.CKDW == 1 && ssjDevice.KX ==0 && ssjDevice.RWH > 0) { + // Íê³É³ö¿â×÷Òµ ²åÈë³É¹¦»Ø´« + callCkProcess(ssjDevice.RWH); + } + } + + private void ssj_rk_dd(SSJ_Device ssjDevice) throws Exception { + //¼ì²âµ½ µ½Î»×´Ì¬ ÇëÇówmsÉú³ÉÈë¿â×÷Òµ + if (ssjDevice.RKQQ == 1 && ssjDevice.exceptionId == 0) { + + + if (StrUtil.isNotBlank(ssjDevice.trayCode)) { + + MydoJob job = QueryDbDataUtils.getRKMyDoJobByTrayCode(m_dao, ssjDevice.trayCode, Collections.singletonList("1")); + if (ObjUtil.isNull(job)) { + + //²éѯÊÇ·ñÈÎÎñÒÑÔÚÔËÐÐ + MydoJob runningJob = QueryDbDataUtils.getRKMyDoJobByTrayCode(m_dao, ssjDevice.trayCode, Collections.singletonList("3")); + if (runningJob == null) { + + Map map = new HashMap<>(); + map.put("trayCode", ssjDevice.trayCode); + map.put("height", ssjDevice.height); + map.put("entranceId", ssjDevice.ssjNo); + + String requestParam = JSONUtil.toJsonStr(map); + //ÇëÇówms½Ó¿Ú + String post = HttpUtil.post(getInStorageInformation.getUrl(), requestParam); + + HashMap bean = JSONUtil.toBean(post, HashMap.class); + if ("0".equals(Convert.toStr(bean.get("code")))) { + //¸ù¾ÝÍÐÅÌÂë»òÕßÁÏÏäÂë²éѯ¶ÔÓ¦taskNo + job = QueryDbDataUtils.getRKMyDoJobByTrayCode(m_dao, ssjDevice.trayCode, Collections.singletonList("1")); + //³É¹¦ + if (ObjUtil.isNotNull(job) && "1".equals(job.getStatus()) && "1".equals(job.getExecution_phase())) { + int qx = 1; + int sendCompleted = 1; + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú 2 + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int taskNo = Integer.parseInt(job.getTask_no()); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + //ÅжÏÒ»ÏÂÊÇ·ñ½ÓÊÕµ½ + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2,class_now_name='" + qx + "' where task_no='" + taskNo + "'"); + if (ssjDevice.ssjNo.equals("L1009") || ssjDevice.ssjNo.equals("G1011-7") || ssjDevice.ssjNo.equals("G2003")){ + QueryDbDataUtils.updateWcsPortState(m_dao, ssjDevice.ssjNo, "1"); + } + + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "·¢ËÍÈ¥Ïòʧ°Ü£¡£¡£¡"); + + } + } + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷ҵʧ°Ü£¡£¡£¡"); + } + }else { + if (runningJob.getExecution_phase().equals("2")) { + DateTime startTime = DateUtil.parse(runningJob.getStart_time()); + DateTime currentTime = DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + if (DateUtil.between(startTime, currentTime, DateUnit.SECOND) > 20) { + int qx = 1; + int sendCompleted = 1; + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú 2 + //Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int taskNo = Integer.parseInt(runningJob.getTask_no()); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + //ÅжÏÒ»ÏÂÊÇ·ñ½ÓÊÕµ½ + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2,class_now_name='" + qx + "' where task_no='" + taskNo + "'"); + + + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "·¢ËÍÈ¥Ïòʧ°Ü£¡£¡£¡"); + + } + } + } + } + } else { + if (job.getExecution_phase().equals("1")) { + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int qx = 1; + int sendCompleted = 1; + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú 2 + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int taskNo = Integer.parseInt(job.getTask_no()); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + Logger.info("204ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2,class_now_name='" + qx + "' where task_no='" + taskNo + "'"); + SSJ_Device currentStatus = IsoTcpClientSSJ.readSsjRwh(ssjDevice.ssjNo); + + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "·¢ËÍÈ¥Ïòʧ°Ü£¡£¡£¡"); + + } + } + + } + + + } else { + if ("G2006".equals(ssjDevice.ssjNo) || "G2007".equals(ssjDevice.ssjNo)) { + MydoJob mydoJob = QueryDbDataUtils.selectJobByEntranceId(m_dao, ssjDevice.ssjNo); + if (mydoJob != null) { + if (mydoJob.getExecution_phase().equals("1")){ + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú + int qx = 1; + int sendCompleted = 1; + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú 2 + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int taskNo = Integer.parseInt(mydoJob.getTask_no()); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + Logger.info("231ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2 ,class_now_name='" + qx + "' where task_no='" + taskNo + "'"); + SSJ_Device currentStatus = IsoTcpClientSSJ.readSsjRwh(ssjDevice.ssjNo); + + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "·¢ËÍÈ¥Ïòʧ°Ü£¡£¡£¡"); + + } + } + + if (mydoJob.getExecution_phase().equals("2")){ + DateTime startTime = DateUtil.parse(mydoJob.getStart_time()); + DateTime currentTime = DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + if (DateUtil.between(startTime,currentTime, DateUnit.SECOND)>20){ + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú + int qx = 1; + int sendCompleted = 1; + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú 2 + //Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "µ÷ÓýӿÚÉú³É×÷Òµ³É¹¦£¡£¡£¡"); + int taskNo = Integer.parseInt(mydoJob.getTask_no()); + byte[] sendData = Tools.sendDataToDevice(taskNo, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + + Logger.info("231ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2 ,class_now_name='" + qx + "' where task_no='" + taskNo + "'"); + SSJ_Device currentStatus = IsoTcpClientSSJ.readSsjRwh(ssjDevice.ssjNo); + //if (currentStatus.RWH >60000){ + IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + Logger.info("231ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "ÖØ¸´Ï·¢ÏïµÀ¿Ú·½ÏòÈÎÎñ" + taskNo + "³É¹¦£¡"); + + //} + } else { + Logger.info("ÍÐÅÌ" + ssjDevice.trayCode + "·¢ËÍÈ¥Ïòʧ°Ü£¡£¡£¡"); + + } + } + } + + } else { + //Ï·¢ + int qx = 1; + int sendCompleted = 2; + byte[] sendData = Tools.sendDataToDevice(0, null, qx, sendCompleted); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info(ssjDevice.ssjNo + "ÎÞ»ØÁ÷ÈÎÎñ,·¢ËÍÍË»ØÈ¥Ïò³É¹¦"); + } + } + } + + } + } + } + + /** + * ÊäËÍ»úµ÷¶È + * + */ + private void ssj_ck_dd(SSJ_Device ssjDevice) throws Exception { + //¼ì²âµ½Õý³£³ö¿â³ö¿âµ½Î» + if (ssjDevice.DW == 1 && ssjDevice.KX == 0 && ssjDevice.RWH > 0) { + long rwh = ssjDevice.RWH; + if (ssjDevice.ssjNo.equals("L1004") ) { + ExceptionInfo exceptionInfo = QueryDbDataUtils.selectException(m_dao, rwh); + if (exceptionInfo == null){ + // Íê³É³ö¿â×÷Òµ ²åÈë³É¹¦»Ø´« + callCkProcess(ssjDevice.RWH); + }else { + WcsPortState portStateByName = QueryDbDataUtils.getPortStateByName(m_dao, ssjDevice.ssjNo); + if (portStateByName !=null ) { + + + if (exceptionInfo.getSendCompleted().equals("0")) { + //Éϱ¨Òì³£ + Map map = new HashMap<>(); + map.put("trayCode", exceptionInfo.getTrayCode()); + map.put("height", 3); + map.put("entranceId", "L1004"); + + String requestParam = JSONUtil.toJsonStr(map); + //ÇëÇówms½Ó¿Ú + String post = HttpUtil.post(getInStorageInformation.getUrl(), requestParam); + + HashMap bean = JSONUtil.toBean(post, HashMap.class); + if ("0".equals(Convert.toStr(bean.get("code")))) { + Logger.info(bean.get("msg").toString()); + QueryDbDataUtils.updateWcsPortState(m_dao, portStateByName.getPortName(), "1"); + m_dao.updateSql("update ExceptionInfo set sendCompleted = '1' where taskNo=" + rwh); + } + } + + + } + } + + + + + + } else { + // Íê³É³ö¿â×÷Òµ ²åÈë³É¹¦»Ø´« + callCkProcess(ssjDevice.RWH); + } + + + } + // ÐÞ¸ÄÈë¿Ú±êÖ¾ + if (ssjDevice.KX == 0){ + m_dao.updateSql("update WcsPortState set occupationState=1 where portName='" + ssjDevice.ssjNo + "'"); + } + + if (ssjDevice.KX == 1){ + m_dao.updateSql("update WcsPortState set occupationState=0,spare1=null,spare2=0,spare3=null where portName='" + ssjDevice.ssjNo + "'"); + } + } + + /** + * ³ö¿â´æ´¢Á÷³Ì + * + */ + private void callCkProcess(long rwh) { + StoredParameters taskNoParameter = new StoredParameters(1, String.valueOf(rwh)); + StoredParameters result = new StoredParameters(2, ""); + StoredParameters result_msg = new StoredParameters(3, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_job_finish(?,?,?)}", + 2, 3, taskNoParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + //Logger.info("proc_job_finish ÎÞ¸Ã×÷Òµ£¬Çë¼ì²é£¬ÈÎÎñºÅ£º" + rwh); + break; + case 9: + Logger.info("proc_job_finish ´æ´¢¹ý³ÌÎÊÌ⣬Çë¼ì²é"); + break; + case 10: + Logger.info("proc_job_finish Ö´Ðгɹ¦ ÈÎÎñºÅ£º" + rwh); + break; + default: + throw new SQLException("proc_job_finish δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + rwh); + } + } catch (SQLException exception) { + Logger.error("e{}", exception.getMessage()); + } + + + } + + private void ssj_hldd(SSJ_Device ssjDevice) throws Exception { + //¼ì²âµ½ µ½Î»×´Ì¬ ÇëÇówmsÉú³ÉÈë¿â×÷Òµ + if (ssjDevice.DW == 1 && ssjDevice.exceptionId == 0) { + MydoJob job = QueryDbDataUtils.getHlMyDoJobByEntranceId(m_dao, ssjDevice.ssjNo); + if (ObjUtil.isNotNull(job)) { + //Ï·¢ÐÅÏ¢ÖÁÏïµÀ¿Ú + int taskNo = Integer.parseInt(job.getTask_no()); + int qx = 12; + //int jym = Tools.getJYM(taskNo); + byte[] sendData = Tools.sendDataToDevice(taskNo, ssjDevice.trayCode, qx); + int isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("ÏòÈë¿âÊäËÍ»ú" + ssjDevice.ssjNo + "Ï·¢Èë¿âÈÎÎñ" + taskNo + "³É¹¦£¡"); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "',execution_phase=2 where task_no='" + taskNo + "'"); + } + } + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/RoadwaySsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/RoadwaySsjThread.java new file mode 100644 index 0000000..1f0afb9 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/RoadwaySsjThread.java @@ -0,0 +1,348 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; + +import java.sql.SQLException; +import java.util.*; +import java.util.stream.Collectors; + +public class RoadwaySsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public RoadwaySsjThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("=======================ÊäËÍ»úÏß³ÌÆô¶¯==========================="); + //»ñÈ¡DB¿éÖеÄÐÅÏ¢ + DbGet.hsComParamSSJ = hsComParamSSJ; + + int ssjH = 0; //ÊäËÍ»ú + try { ///ÊäËÍ»úµ÷¶È + List ssjXdk = DbGet.getRoadwaySsj(); + Map> outStockSsj = DbGet.getOutZtStockSsj(); + if (!ssjXdk.isEmpty()) { + for (SSJ_Device ssj_device : ssjXdk) { + //ÊäËÍ»úÑ­»· + ssj_dd(ssj_device,outStockSsj); + } + } + } catch (Exception ex) { + //conn.close(); + Logger.info("ÊäËÍ»úÏß³Ì×éµ÷¶ÈÖ´ÐÐÒì³£" + ssjH + ex.getMessage()); + }///¶Ñ¶â»úµ÷¶È + } catch (Exception e) { + Logger.info("==========ÊäËÍ»úÏß³Ì×éÒì³£,Òì³£ÐÅÏ¢¡¾" + e.getMessage() + "¡¿========"); + Logger.error(e); + } finally { + //Logger.info("=======================ÊäËÍ»úÏß³Ì×éÐÝÃß==========================="); + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e); + } + } + } + } + + /** + * ÊäËÍ»úµ÷¶È + */ + private void ssj_dd(SSJ_Device ssjDevice,Map> outStatus) throws Exception { + //·ÖÈÎÎñÀàÐÍ + if (ssjDevice.DW == 1 && ssjDevice.RWH>0) { + //¸Ã¿ÚÊÇ·ñÓÐÕýÖ´ÐÐÈë¿âÈÎÎñ + MydoJob mydoJob = QueryDbDataUtils.getRKMydoJobByTaskNoAndEp(m_dao, String.valueOf(ssjDevice.RWH),"2"); + if (mydoJob != null) { + + //delete exception + m_dao.deleteSql("delete from ExceptionInfo where trayCode = '" + mydoJob.getTray_code() + "'"); + + + //ÈôÈë¿âÈÎÎñ´æÔÚ£¬ÅжÏÈë¿â¶ÓÁÐÊÇ·ñ´æÔÚ£¬ÎÞÈë¿â¶ÓÁУ¬ÔòÉú³ÉÈë¿â¶ÓÁÐ + MsgDdj msg = QueryDbDataUtils.getDevIdByRoadwayId(m_dao, mydoJob.getRoadway_id()); + int count; + if ("G2050-2".equals(ssjDevice.ssjNo) || "G2051-2".equals(ssjDevice.ssjNo)) { + count = QueryDbDataUtils.getWmsDeviceExecutionQueueByRwlxAndDev(m_dao, msg.getId(), getRKRwlx(ssjDevice), getCKRwlx(ssjDevice)); + } else { + count = QueryDbDataUtils.getWmsDeviceExecutionQueueByRwlxAndDev(m_dao, msg.getId(), getRKRwlx(ssjDevice)); + } + if (count == 0 /*&& ("G2016-1-1".equals(ssjDevice.ssjNo) || "G1011-1-1".equals(ssjDevice.ssjNo))*/) { + //Ð޸ĶÓÁÐ״̬ + m_dao.updateSql("update MydoJob set execution_phase=3 where task_no='" + ssjDevice.RWH + "'"); + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getRKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + + } + + //ÁÏÏäË«¹¤Î»¿ÉÉú³ÉÁ½¸öÈë¿â¶ÓÁÐ + if (count > 0 && msg.getId() == 2 && ("G2016-1-1".equals(ssjDevice.ssjNo) || ("G1011-1-1".equals(ssjDevice.ssjNo)) || ("G2016-1-2".equals(ssjDevice.ssjNo)) || ("G1011-1-2".equals(ssjDevice.ssjNo)))) { + List wmsDeviceExecutionQueueInfoByRwlxAndDev = QueryDbDataUtils.getWmsDeviceExecutionQueueInfoByRwlxAndDev(m_dao, msg.getId(), getRKRwlx(ssjDevice)); + if (ssjDevice.RWH != Convert.toLong(wmsDeviceExecutionQueueInfoByRwlxAndDev.get(0).getRwh())) { + //Ð޸ĶÓÁÐ״̬ + m_dao.updateSql("update MydoJob set execution_phase=3 where task_no='" + ssjDevice.RWH + "'"); + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getRKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + + } + } + } + mydoJob = QueryDbDataUtils.getRKMydoJobByTaskNoAndEp(m_dao, String.valueOf(ssjDevice.RWH),"3"); + if (mydoJob!=null){ + //pan duan shi fou sheng cheng ren wu + int count = QueryDbDataUtils.getWmsDeviceExecutionQueueByRwh(m_dao, String.valueOf(ssjDevice.RWH)); + //ÈôÈë¿âÈÎÎñ´æÔÚ£¬ÅжÏÈë¿â¶ÓÁÐÊÇ·ñ´æÔÚ£¬ÎÞÈë¿â¶ÓÁУ¬ÔòÉú³ÉÈë¿â¶ÓÁÐ + MsgDdj msg = QueryDbDataUtils.getDevIdByRoadwayId(m_dao, mydoJob.getRoadway_id()); + if (count==0){ + //m_dao.updateSql("update MydoJob set execution_phase=3 where task_no='" + ssjDevice.RWH + "'"); + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getRKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + } + } + } + if (ssjDevice.KX == 1 && ssjDevice.RWH == 0) { + //ÅжϸÃÊäËÍ»úËùÊôµÄ³ö¿â¿ÚÊÇ·ñÓгö¿âÈÎÎñ + MydoJob mydoJob = null; + List outList; + List outKxList; + switch (ssjDevice.ssjNo){ + case "L1001": + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao, Collections.singletonList("L1004")); + break; + case "G1012-1-1": + case "G1012-1-2": + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao, Collections.singletonList("G1012-5")); + break; + case "G2015-1-2": + case "G2015-1-1": + List out1 = new ArrayList<>(); + List out3 = new ArrayList<>(); + //out1.add("G2049"); + out1.add("G2026"); + out3.add("G2041"); + + int ckCountMydoJobRunningG2026 = QueryDbDataUtils.getCKCountMydoJobByExitId(m_dao, out1); + int ckCountMydoJobRunningG2041 = QueryDbDataUtils.getCKCountMydoJobByExitId(m_dao, out3); + if (ckCountMydoJobRunningG2026 >= 0 && ckCountMydoJobRunningG2026<5) { + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao,out1); + } + if (mydoJob==null && ckCountMydoJobRunningG2041 >=0 && ckCountMydoJobRunningG2041<9) { + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao,out3); + } + + break; + case "G2050-2": + outList = outStatus.get("G2050"); + outKxList = outList.stream().filter(x -> x.KX == 1).collect(Collectors.toList()); + if (CollUtil.isEmpty(outKxList)){ + Logger.info("G2050 ÎÞ¿ÕÏÐλ"); + mydoJob = null; + }else { + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao, Collections.singletonList("G2050")); + } + break; + case "G2051-2": + outList = outStatus.get("G2051"); + outKxList = outList.stream().filter(x -> x.KX == 1).collect(Collectors.toList()); + if (CollUtil.isEmpty(outKxList)){ + Logger.info("G2051 ÎÞ¿ÕÏÐλ"); + mydoJob = null; + }else { + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao, Collections.singletonList("G2051")); + } + break; + case "L2001": + outList = outStatus.get("L2001"); + outKxList = outList.stream().filter(x -> x.KX == 1).collect(Collectors.toList()); + if (CollUtil.isEmpty(outKxList)){ + Logger.info("G2003,G2006,G2007 ÎÞ¿ÕÏÐλ"); + mydoJob = null; + }else { + List out2 = new ArrayList<>(); + for (SSJ_Device ssj_device : outKxList) { + if (ssj_device.KX==1){ + out2.add(ssj_device.ssjNo); + } + } + mydoJob = QueryDbDataUtils.getCKMydoJobByExitId(m_dao,out2); + } + break; + default: + mydoJob = null; + } + //Èç¹û´æÔÚÈÎÎñ£¬ÔòÏ·¢¶Ñ¶â»úÈÎÎñ + if (mydoJob != null) { + if ("1".equals(mydoJob.getExecution_phase())) { + if (ssjDevice.ssjNo.equals("L2001")){ + List out3 = new ArrayList<>(); + out3.add(mydoJob.getExit_id()); + MydoJob ckRunningMydoJobByExitId = QueryDbDataUtils.getCKRunningMydoJobByExitId(m_dao, out3); + if (ckRunningMydoJobByExitId !=null){ + Logger.error("ck "+mydoJob.getExit_id()+" exists job "+ckRunningMydoJobByExitId.getTask_no()); + return; + } + } + + + String rwh = mydoJob.getTask_no(); + String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + //Èô³ö¿âÈÎÎñ´æÔÚ£¬Åжϳö¿â¶ÓÁÐÊÇ·ñ´æÔÚ£¬ÎÞ³ö¿â¶ÓÁУ¬ÔòÉú³É³ö¿â¶ÓÁÐ + MsgDdj msg = QueryDbDataUtils.getDevIdByRoadwayId(m_dao, mydoJob.getRoadway_id()); + int count; + if ("G2050-2".equals(ssjDevice.ssjNo) || "G2051-2".equals(ssjDevice.ssjNo)) { + //ÅжÏÈë³ö¿ÚÊÇ·ñ´æÔÚÈë¿âÈÎÎñ»ò³ö¿âÈÎÎñ + count = QueryDbDataUtils.getWmsDeviceExecutionQueueByRwlxAndDev(m_dao, msg.getId(), getCKRwlx(ssjDevice), getRKRwlx(ssjDevice)); + } else { + //ÅжÏÊÇ·ñ´æÔÚÈÎÎñ + count = QueryDbDataUtils.getWmsDeviceExecutionQueueByRwlxAndDev(m_dao, msg.getId(), getCKRwlx(ssjDevice)); + } + if (count == 0) { + //Èç¹û²»´æÔÚ£¬Ôò´´½¨¶Ñ¶â»úÈÎÎñ + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getCKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "' where task_no='" + rwh + "'"); + } + if (count>0 && msg.getId() == 2 && ( ("G1012-1-1".equals(ssjDevice.ssjNo)) || ("G1012-1-2".equals(ssjDevice.ssjNo)))) { + //Èç¹ûÊÇÁÏÏä¶Ñ¶â»ú,Ë«¹¤Î»£¬¿ÉÉú³É¶à¸ö¶Ñ¶â»úÈÎÎñ + List wmsDeviceExecutionQueueInfoByRwlxAndDev = QueryDbDataUtils.getWmsDeviceExecutionQueueInfoByRwlxAndDev(m_dao, msg.getId(), getCKRwlx(ssjDevice)); + if (wmsDeviceExecutionQueueInfoByRwlxAndDev.size() <=5) { + Optional first = wmsDeviceExecutionQueueInfoByRwlxAndDev.stream().filter(x -> x.getRwh().equals(ssjDevice.RWH + "")).findFirst(); + if (!first.isPresent()) { + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getCKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "' where task_no='" + rwh + "'"); + } + } + } + + if (count>0 && msg.getId() == 2 && ("G2015-1-1".equals(ssjDevice.ssjNo) || ("G2015-1-2".equals(ssjDevice.ssjNo)) )) { + //Èç¹ûÊÇÁÏÏä¶Ñ¶â»ú,Ë«¹¤Î»£¬¿ÉÉú³É¶à¸ö¶Ñ¶â»úÈÎÎñ + List wmsDeviceExecutionQueueInfoByRwlxAndDev = QueryDbDataUtils.getWmsDeviceExecutionQueueInfoByRwlxAndDev(m_dao, msg.getId(), getCKRwlx(ssjDevice)); + if (wmsDeviceExecutionQueueInfoByRwlxAndDev.size() <= 14) { + Optional first = wmsDeviceExecutionQueueInfoByRwlxAndDev.stream().filter(x -> x.getRwh().equals(ssjDevice.RWH + "")).findFirst(); + if (!first.isPresent()) { + createDDJQueue(m_dao, mydoJob.getTask_no(), msg.getId(), getCKRwlx(ssjDevice), ssjDevice.ssjNo, mydoJob.getRoadway_id()); + m_dao.updateSql("update MydoJob set status=3,start_time='" + format + "' where task_no='" + rwh + "'"); + } + } + } + + } + } + } + } + + + public static int getRKRwlx(SSJ_Device ssjDevice) { + int rwlx = 0; + switch (ssjDevice.ssjNo){ + case "L1006": + rwlx =1; + break; + case "G1011-1-1": + case "G1011-1-2": + rwlx =2; + break; + case "G2050-2": + rwlx =3; + break; + case "G2051-2": + rwlx =4; + break; + case "L2014": + rwlx =5; + break; + case "G2016-1-1": + case "G2016-1-2": + rwlx =6; + break; + default: + throw new IllegalStateException("δ֪µÄÏïµÀ¿Ú"); + } + return rwlx; + } + + public static int getCKRwlx(SSJ_Device ssjDevice) { + int rwlx = 0; + switch (ssjDevice.ssjNo){ + case "L1001": + rwlx =10; + break; + case "G1012-1-1": + case "G1012-1-2": + rwlx =11; + break; + case "G2050-2": + rwlx =12; + break; + case "G2051-2": + rwlx =13; + break; + case "L2001": + rwlx =14; + break; + case "G2015-1-1": + case "G2015-1-2": + rwlx =15; + break; + default: + throw new IllegalStateException("δ֪µÄÏïµÀ¿Ú"); + } + return rwlx; + } + + private synchronized void createDDJQueue(EntityDAO m_dao,String taskNo, int devId, int rwlx,String ssjNo,String hd) { + StoredParameters taskParameter = new StoredParameters(1, taskNo); + StoredParameters devParameter = new StoredParameters(2, devId); + StoredParameters ssjNoParameter = new StoredParameters(3, ssjNo); + StoredParameters typeParameter = new StoredParameters(4, rwlx); + StoredParameters roadwayParameter = new StoredParameters(5, Integer.parseInt(hd)); + StoredParameters vResult = new StoredParameters(6, 0); + + try { + int back = Tools.storedProcedure(m_dao, "{call proc_add_zxdl(?,?,?,?,?,?)}", + 6, taskParameter, devParameter,ssjNoParameter,typeParameter, roadwayParameter,vResult); + switch (back) { + case 10: + Logger.info(" proc_add_zxdl_ddj Ö´Ðгɹ¦£¬ÈÎÎñºÅ£º" + taskNo); + break; + case 1: + Logger.info("proc_add_zxdl_ddj ÎÞ¸ÃÈÎÎñ£¬ÈÎÎñºÅ£º" + taskNo); + break; + default: + throw new SQLException("proc_add_zxdl_ddj δ֪µÄ·µ»ØÖµ£¬ÈÎÎñºÅ£º" + taskNo); + } + } catch (SQLException e) { + Logger.error(e.getMessage()); + } + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/TransferSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/TransferSsjThread.java new file mode 100644 index 0000000..91b42d8 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/TransferSsjThread.java @@ -0,0 +1,204 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.MydoJob; +import com.wms.dss.ats.customs.abb.entity.SSJ_Device; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.ats.customs.abb.entity.WcsPortState; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientSSJ; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +import com.wms.dss.ats.customs.abb.utils.Tools; +import com.wms.dss.common.server.config.WMSDDSConfig; +import com.wms.dss.common.server.form.Logger; +import com.wms.dss.common.server.schedule.CraneThread; +import org.hibernate.HibernateException; + +import java.sql.SQLException; +import java.util.*; + +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.CLEAR_RACK; + +public class TransferSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public TransferSsjThread(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + hsComParamSSJ = (Hashtable) hsSysParam.get("hsComParamSSJ"); + m_dao = (EntityDAO) hsSysParam.get("dao"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + try { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + } catch (Exception e) { + Logger.error(e); + } + try { + //Logger.info("=========输é€�机线程å�¯åЍ========="); + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + + int ssjH = 0; //输é€�机 + try { ///输é€�机调度 + List ssjXdk = DbGet.getTransferSsj(); + if (!ssjXdk.isEmpty()) { + for (SSJ_Device ssj_device : ssjXdk) { + //输é€�机循环 + ssj_dd(ssj_device); + } + } + List rackXh = DbGet.getRackXh(); + if (!rackXh.isEmpty()) { + for (SSJ_Device ssj_device : rackXh) { + //输é€�机循环 + rack_dd(ssj_device); + } + } + } catch (Exception ex) { + //conn.close(); + Logger.info("输é€�机线程组调度执行异常" + ssjH + ex.getMessage()); + }///堆垛机调度 + } catch (Exception e) { + Logger.info("==========输é€�机线程组异常,异常信æ�¯ã€�" + e.getMessage() + "】========"); + Logger.error(e); + } finally { + //Logger.info("==========输é€�机线程组休眠============"); + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e); + } + } + } + } + + /** + * 料架信å�·è°ƒåº¦ + * @param ssjDevice + */ + private void rack_dd(SSJ_Device ssjDevice) { + if (ssjDevice.LJXH ==1){ + m_dao.updateSql("update WcsPortState set occupationState = 1 where portName = '"+ssjDevice.ssjNo+"'"); + try { + String portName =""; + if ("ZJ001".equals(ssjDevice.ssjNo)){ + portName = "2FTPSJ01"; + }else if ("ZJ002".equals(ssjDevice.ssjNo)){ + portName = "2FTPSJ02"; + } + WcsPortState portStateByName = QueryDbDataUtils.getPortStateByName(m_dao, ssjDevice.ssjNo); + if (portStateByName != null && portStateByName.getSpare2().equals("0")) { + Map map = new HashMap<>(); + map.put("rackPosition",portName); + //è§£æž�返回结果 + String resultStr = HttpUtil.post(CLEAR_RACK.getUrl(), JSONUtil.toJsonStr(map)); + Logger.info("接å�£è¿”回结果{}" + resultStr); + JSONObject entries = JSONUtil.parseObj(resultStr); + if (!"0".equals(entries.get("code").toString())){ + throw new Exception("请求wms接å�£ç©ºæ‰˜ç›˜åž›å¼‚常"); + } + QueryDbDataUtils.updateWcsPortState(m_dao, ssjDevice.ssjNo, "1"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + }else { + m_dao.updateSql("update WcsPortState set occupationState = 0,spare1=0,spare2=0,spare3=0 where portName = '"+ssjDevice.ssjNo+"'"); + } + + } + + /** + * 输é€�机调度 + * @param ssjDevice + */ + private void ssj_dd(SSJ_Device ssjDevice) throws Exception { + if (ssjDevice.DW == 1 && ssjDevice.QQ==1 && ssjDevice.RWH > 0 ) { + + MydoJob myDoJobByTaskNo = QueryDbDataUtils.getMyDoJobByTaskNo(m_dao, String.valueOf(ssjDevice.RWH)); + if (myDoJobByTaskNo != null) { + //执行出库任务 + int taskNo = Convert.toInt(myDoJobByTaskNo.getTask_no()); + int jym; + byte[] sendData; + int isSend; + int qx; + int sendCompleted; + + + switch (myDoJobByTaskNo.getExit_id()){ + case "G2003": + //执行出库任务 + //通过作业出å�£å�·åˆ¤æ–­ + //下å�‘输é€�机请求 至拣选å�£ + //taskNo = Convert.toInt(ssjDevice.RWH); + qx=30; + sendCompleted=1; + //jym = Tools.getJYM(taskNo); + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted,qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("å�‘输é€�机" + ssjDevice.ssjNo + "下å�‘G2003出库任务" + taskNo + "æˆ�功ï¼�"); + } + break; + case "G2006": + //下å�‘输é€�机请求 至拣选å�£ + //taskNo = Convert.toInt(ssjDevice.RWH); + //jym = Tools.getJYM(taskNo); + sendCompleted=1; + qx=31; + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted,qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("å�‘输é€�机" + ssjDevice.ssjNo + "下å�‘G2006出库任务" + taskNo + "æˆ�功ï¼�"); + } + break; + case "G2007": + //下å�‘输é€�机请求 至拣选å�£ + //taskNo = Convert.toInt(ssjDevice.RWH); + //jym = Tools.getJYM(taskNo); + sendCompleted=1; + qx=32; + sendData = Tools.sendDataToDevice(taskNo, null, sendCompleted,qx); + isSend = IsoTcpClientSSJ.WritetoSSJ(ssjDevice.writeDB, sendData); + if (isSend == 1) { + Logger.info("å�‘输é€�机" + ssjDevice.ssjNo + "下å�‘G2007出库任务" + taskNo + "æˆ�功ï¼�"); + } + break; + default: + qx = 0; + break; + } + try { + m_dao.updateSql("update MydoJob set class_now_name='"+qx+"' where task_no='" + taskNo + "'"); + } catch (HibernateException e) { + Logger.error(e); + } + } + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/AGV_GET.java b/src/com/wms/dss/ats/customs/abb/utils/AGV_GET.java new file mode 100644 index 0000000..c75d6ba --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/AGV_GET.java @@ -0,0 +1,218 @@ +package com.wms.dss.ats.customs.abb.utils; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Date; + + +public class AGV_GET { + + /** + * µ÷ÓöԷ½½Ó¿Ú·½·¨ + * @param path ¶Ô·½»òµÚÈý·½ÌṩµÄ·¾¶ + * @param data Ïò¶Ô·½»òµÚÈý·½·¢Ë͵ÄÊý¾Ý£¬´ó¶àÊýÇé¿öϸø¶Ô·½·¢ËÍJSONÊý¾ÝÈöԷ½½âÎö + * @return + */ + public static String interfaceUtil(String path,String data) { + + String str = ""; + StringBuffer sb = new StringBuffer(); + String success=""; + try { + URL url = new URL(path); + //´ò¿ªºÍurlÖ®¼äµÄÁ¬½Ó + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + PrintWriter out = null; + + /**ÉèÖÃURLConnectionµÄ²ÎÊýºÍÆÕͨµÄÇëÇóÊôÐÔ****start***/ + + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); + + conn.setDoOutput(true); + conn.setDoInput(true); + + conn.setRequestMethod("POST");//GETºÍPOST±ØÐëÈ«´óд + + // ÉèÖÃÎļþ³¤¶È + conn.setRequestProperty("Content-Length", String.valueOf(data.length())); + // ÉèÖÃÎļþÀàÐÍ: + conn.setRequestProperty("Content-Type", "text/xml");// ¿ªÊ¼Á¬½ÓÇëÇó + + + + conn.connect(); + + OutputStream out1 = conn.getOutputStream(); + // дÈëÇëÇóµÄ×Ö·û´® + out1.write(data.getBytes()); + out1.flush(); + out1.close(); + + //»ñÈ¡URLConnection¶ÔÏó¶ÔÓ¦µÄÊäÈëÁ÷ + InputStream is = conn.getInputStream(); + //¹¹ÔìÒ»¸ö×Ö·ûÁ÷»º´æ + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + + while ((str = br.readLine()) != null) { + str=new String(str.getBytes(),"UTF-8");//½â¾öÖÐÎÄÂÒÂëÎÊÌâ + + + sb.append(str); + //System.out.println(str); + JSONObject jsonObject = JSONObject.fromObject(str); + success=jsonObject.getString("message"); + int code=jsonObject.getInt("code"); + + + } + //¹Ø±ÕÁ÷ + is.close(); + //¶Ï¿ªÁ¬½Ó£¬×îºÃдÉÏ£¬disconnectÊÇÔڵײãtcp socketÁ´½Ó¿ÕÏÐʱ²ÅÇжϡ£Èç¹ûÕýÔÚ±»ÆäËûÏß³ÌʹÓþͲ»Çжϡ£ + //¹Ì¶¨¶àÏ̵߳ϰ£¬Èç¹û²»disconnect£¬Á´½Ó»áÔö¶à£¬Ö±µ½ÊÕ·¢²»³öÐÅÏ¢¡£Ð´ÉÏdisconnectºóÕý³£Ò»Ð©¡£ + conn.disconnect(); + System.out.println("ÍêÕû½áÊø"); + + } catch (Exception e) { + e.printStackTrace(); + } + + + return success; +// return sb.toString(); + } + + /** + * ½Ó¿Úµ÷Óà GET + */ + public static void httpURLConectionGET(String path) { + try { + URL url = new URL(path); // °Ñ×Ö·û´®×ª»»ÎªURLÇëÇóµØÖ· + HttpURLConnection connection = (HttpURLConnection) url.openConnection();// ´ò¿ªÁ¬½Ó + connection.connect();// Á¬½Ó»á»° + // »ñÈ¡ÊäÈëÁ÷ + BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder sb = new StringBuilder(); + while ((line = br.readLine()) != null) {// Ñ­»·¶ÁÈ¡Á÷ + sb.append(line); + } + br.close();// ¹Ø±ÕÁ÷ + connection.disconnect();// ¶Ï¿ªÁ¬½Ó + //System.out.println(sb.toString()); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("ʧ°Ü!"); + } + } + + /** + * ½Ó¿Úµ÷Óà POST + */ + public static void httpURLConnectionPOST (String path) { + try { + URL url = new URL(path); + + // ½«urlÒÔopen·½·¨·µ»ØµÄurlConnectionÁ¬½ÓǿתΪHttpURLConnectionÁ¬½Ó(±êʶһ¸öurlËùÒýÓõÄÔ¶³Ì¶ÔÏóÁ¬½Ó) + // ´ËʱcnnectionÖ»ÊÇΪһ¸öÁ¬½Ó¶ÔÏó,´ýÁ¬½ÓÖÐ + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + // ÉèÖÃÁ¬½ÓÊä³öÁ÷Ϊtrue,ĬÈÏfalse (post ÇëÇóÊÇÒÔÁ÷µÄ·½Ê½ÒþʽµÄ´«µÝ²ÎÊý) + connection.setDoOutput(true); + + // ÉèÖÃÁ¬½ÓÊäÈëÁ÷Ϊtrue + connection.setDoInput(true); + + // ÉèÖÃÇëÇó·½Ê½Îªpost + connection.setRequestMethod("POST"); + + // postÇëÇ󻺴æÉèΪfalse + connection.setUseCaches(false); + + // ÉèÖøÃHttpURLConnectionʵÀýÊÇ·ñ×Ô¶¯Ö´ÐÐÖØ¶¨Ïò + connection.setInstanceFollowRedirects(true); + + // ÉèÖÃÇëÇóÍ·ÀïÃæµÄ¸÷¸öÊôÐÔ (ÒÔÏÂΪÉèÖÃÄÚÈݵÄÀàÐÍ,ÉèÖÃΪ¾­¹ýurlEncoded±àÂë¹ýµÄfrom²ÎÊý) + // application/x-javascript text/xml->xmlÊý¾Ý + //¡¡application/x-javascript->json¶ÔÏó + //¡¡application/x-www-form-urlencoded->±íµ¥Êý¾Ý + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + + // ½¨Á¢Á¬½Ó (ÇëÇóδ¿ªÊ¼,Ö±µ½connection.getInputStream()·½·¨µ÷ÓÃʱ²Å·¢Æð,ÒÔÉϸ÷¸ö²ÎÊýÉèÖÃÐèÔÚ´Ë·½·¨Ö®Ç°½øÐÐ) + connection.connect(); + + // ´´½¨ÊäÈëÊä³öÁ÷,ÓÃÓÚÍùÁ¬½ÓÀïÃæÊä³öЯ´øµÄ²ÎÊý,(Êä³öÄÚÈÝΪ?ºóÃæµÄÄÚÈÝ) + DataOutputStream dataout = new DataOutputStream(connection.getOutputStream()); + //URLEncoder.encode()·½·¨ Ϊ×Ö·û´®½øÐбàÂë(¾ßÌå±àÂë¸ñʽÒÀ¾ÝÏîÄ¿Îĵµ¶ø¶¨) + String parm = "storeId=" + URLEncoder.encode("32", "utf-8"); + // ½«²ÎÊýÊä³öµ½Á¬½Ó + dataout.writeBytes(parm); + + // Êä³öÍê³Éºóˢв¢¹Ø±ÕÁ÷ + dataout.flush(); + dataout.close(); // ÖØÒªÇÒÒ׺öÂÔ²½Öè (¹Ø±ÕÁ÷,ÇмÇ!) + + //System.out.println(connection.getResponseCode()); + + // Á¬½Ó·¢ÆðÇëÇó,´¦Àí·þÎñÆ÷ÏìÓ¦ (´ÓÁ¬½Ó»ñÈ¡µ½ÊäÈëÁ÷²¢°üװΪbufferedReader) + BufferedReader bf = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder sb = new StringBuilder(); // ÓÃÀ´´æ´¢ÏìÓ¦Êý¾Ý + + // Ñ­»·¶ÁÈ¡Á÷,Èô²»µ½½áβ´¦ + while ((line = bf.readLine()) != null) { + sb.append(bf.readLine()); + } + bf.close(); // ÖØÒªÇÒÒ׺öÂÔ²½Öè (¹Ø±ÕÁ÷,ÇмÇ!) + connection.disconnect(); // Ïú»ÙÁ¬½Ó + //System.out.println(sb.toString()); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { +// String url = "http://IP:PORT/rcms/services/rest/hikRpcService/genAgvSchedulingTask"; + +// String url="http://192.168.37.99:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask"; +// String url="http://www.baidu.com"; + Timestamp currentTime = new Timestamp(new Date().getTime()); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = formatter.format(currentTime); + JSONObject json = new JSONObject(); + + json.put("reqCode", "156896");//ÇëÇó±àÂë + json.put("reqTime", time);//ÇëÇóʱ¼ä + json.put("taskTyp", "F01");//ÈÎÎñÀàÐÍ£¬³§ÄÚ»õ¼Ü°áÔË: F01; ÏïµÀµ½¹¤×÷̨: F13; ¹¤×÷̨µ½ÏïµÀ: F14 +// json.put("wbCode", "¹¤×÷λ"); + JSONArray array = new JSONArray(); + for(int p=0 ; p < 2; p++) { + JSONObject tjson = new JSONObject(); + if(p==0) { + tjson.put("positionCode","L1005");//λÖñàºÅ, + tjson.put("type", "00");//λÖÃÀàÐÍ˵Ã÷: + array.add(tjson); + }else if(p==1) { + tjson.put("positionCode","L2003");//λÖñàºÅ, + tjson.put("type", "00");//λÖÃÀàÐÍ˵Ã÷: + array.add(tjson); + } + } + json.put("positionCodePath",array); + json.put("priority","");//ÓÅÏȼ¶£¬ +// json.put("priority", MydoJob_Rkd_Md.getPriority());//ÓÅÏȼ¶£¬ + json.put("agvCode","");//AGV ±àºÅ + json.put("taskCode", "99999");//ÈÎÎñµ¥ºÅ + json.put("data","");//ÈÎÎñÖ´Ðн׶Π+ //System.out.println(json.toString()); + String url= interfaceUtil("http://192.168.37.205:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask",json.toString());//getÇëÇó + } +} \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/utils/AllocatePropUtils.java b/src/com/wms/dss/ats/customs/abb/utils/AllocatePropUtils.java new file mode 100644 index 0000000..49b5f05 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/AllocatePropUtils.java @@ -0,0 +1,526 @@ +package com.wms.dss.ats.customs.abb.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Hashtable; +import com.wms.dss.ats.common.command.CarCommand; +import com.wms.dss.ats.common.command.CraneCommand; + +/** + * ÃèÊö: ÈÎÎñ»òÖ¸ÁîµÄÎļþ²Ù×÷ + * + * @author yao 2017-5-8 + * @since WMS 3.0 + */ +public class AllocatePropUtils { + /** + * ¹¦ÄÜ:»ñȡС³µÖ¸Áî + * + * @author hug 2013-5-8 + * @param strConfigPath + * @param bit + * @return + */ + public static CarCommand getLastCarCmd(String strConfigPath, byte bit, String xctype) { + FileInputStream fin = null; + ObjectInputStream in = null; + + try { + File file = new File(strConfigPath + "carcommand" + xctype + bit + ".dat"); + if (file.exists()) { + fin = new FileInputStream(file); + in = new ObjectInputStream(fin); + Object obj = in.readObject(); + if (obj != null) { + return (CarCommand) obj; + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fin != null) { + try { + fin.close(); + } catch (Exception e) { + } + } + if (in != null) { + try { + in.close(); + } catch (Exception e) { + } + } + } + return null; + } + + /** + * ¹¦ÄÜ:±£´æÐ¡³µÖ¸Áî + * + * @author hug 2013-5-8 + * @param strConfigPath + * @param carCommand + * @param bit + */ + public static void saveCarCommand(String strConfigPath, CarCommand carCommand, byte bit, String xctype) { + FileOutputStream fos = null; + ObjectOutputStream out = null; + + try { + fos = new FileOutputStream(strConfigPath + "carcommand" + xctype + bit + ".dat"); + out = new ObjectOutputStream(fos); + out.writeObject(carCommand); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception e) { + } + } + if (out != null) { + try { + out.close(); + } catch (Exception e) { + } + } + } + } + + /** + * ¹¦ÄÜ:±£´æ¶Ñ¶â»ú×îºóÏ·¢µÄÖ¸Áî + * + * @param strConfigPath + * @param bit + * @param craneCmd + */ + public static void saveCraneCommand(String strConfigPath, byte bit, CraneCommand craneCmd) { + FileOutputStream fos = null; + ObjectOutputStream out = null; + + try { + fos = new FileOutputStream(strConfigPath + "cranecommand" + bit + ".dat"); + out = new ObjectOutputStream(fos); + out.writeObject(craneCmd); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception e) { + } + } + if (out != null) { + try { + out.close(); + } catch (Exception e) { + } + } + } + } + + /** + * ¹¦ÄÜ:±£´æÊäËÍÏß×îºóÏ·¢µÄÖ¸Áî + * + * @param strConfigPath + * @param bit + * @param craneCmd + */ + public static void saveSSXCommand(String strConfigPath, byte bit, Hashtable ssjcmd) { + FileOutputStream fos = null; + ObjectOutputStream out = null; + + try { + fos = new FileOutputStream(strConfigPath + "ssxcommand" + bit + ".dat"); + out = new ObjectOutputStream(fos); + out.writeObject(ssjcmd); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception e) { + } + } + if (out != null) { + try { + out.close(); + } catch (Exception e) { + } + } + } + } + + /** + * ¹¦ÄÜ:±£´æÊäËÍÏß×îºóÏ·¢µÄÖ¸Áî + * + * @param strConfigPath + * @param bit + * @param craneCmd + */ + public static void saveSSXLCCommand(String strConfigPath, byte bit, Hashtable ssjcmd) { + FileOutputStream fos = null; + ObjectOutputStream out = null; + + try { + fos = new FileOutputStream(strConfigPath + "ssxcommandLC" + bit + ".dat"); + out = new ObjectOutputStream(fos); + out.writeObject(ssjcmd); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception e) { + } + } + if (out != null) { + try { + out.close(); + } catch (Exception e) { + } + } + } + } + + /** + * ¹¦ÄÜ:±£´æ¸Ã¶Ñ¶â»úÈÎÎñ + * + * @param strConfigPath + * @param bit + * @param hsExecTask + */ +// public static void saveExecTask(String strConfigPath, byte bit, Hashtable hsExecTask) { +// FileOutputStream fos = null; +// ObjectOutputStream out = null; +// try { +// fos = new FileOutputStream(strConfigPath + "exectask" + bit + ".dat"); +// out = new ObjectOutputStream(fos); +// out.writeObject(hsExecTask); +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fos != null) { +// try { +// fos.close(); +// } catch (Exception e) { +// } +// } +// if (out != null) { +// try { +// out.close(); +// } catch (Exception e) { +// } +// } +// } +// } + + /** + * ¹¦ÄÜ:¶ÁÈ¡¶Ñ¶â»úδÍê³ÉµÄÈÎÎñ + * + * @param strConfigPath + * @param bit + * ¶Ñ¶â»úºÅ + * @return + */ +// public static Hashtable getLastExecTask(String strConfigPath, byte bit) { +// FileInputStream fin = null; +// ObjectInputStream in = null; +// try { +// File file = new File(strConfigPath + "exectask" + bit + ".dat"); +// if (file.exists()) { +// fin = new FileInputStream(file); +// in = new ObjectInputStream(fin); +// Object obj = in.readObject(); +// if (obj != null) { +// return (Hashtable) obj; +// } +// } +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fin != null) { +// try { +// fin.close(); +// } catch (Exception e) { +// } +// } +// if (in != null) { +// try { +// in.close(); +// } catch (Exception e) { +// } +// } +// } +// return null; +// } + + /** + * ¹¦ÄÜ:»ñÈ¡¶Ñ¶â»ú×îºóÖ¸Áî + * + * @param strConfigPath + * @param bit + * @return + */ +// public static CraneCommand getLastCraneCmd(String strConfigPath, byte bit) { +// FileInputStream fin = null; +// ObjectInputStream in = null; +// try { +// File file = new File(strConfigPath + "cranecommand" + bit + ".dat"); +// if (file.exists()) { +// fin = new FileInputStream(file); +// in = new ObjectInputStream(fin); +// Object obj = in.readObject(); +// if (obj != null) { +// return (CraneCommand) obj; +// } +// } +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fin != null) { +// try { +// fin.close(); +// } catch (Exception e) { +// } +// } +// if (in != null) { +// try { +// in.close(); +// } catch (Exception e) { +// } +// } +// } +// return null; +// } + + /** + * ¹¦ÄÜ:³ö¿â¶ËÈë¿ÚÊäËÍ»ú×îºóÖ¸Áî + * + * @param strConfigPath + * @param bit + * @return + */ + public static Hashtable getLastCKDRKSSJcmd(String strConfigPath, byte bit) { + FileInputStream fin = null; + ObjectInputStream in = null; + + try { + File file = new File(strConfigPath + "CKDRKSSJcmd" + bit + ".dat"); + if (file.exists()) { + fin = new FileInputStream(file); + in = new ObjectInputStream(fin); + Object obj = in.readObject(); + if (obj != null) { + return (Hashtable) obj; + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fin != null) { + try { + fin.close(); + } catch (Exception e) { + } + } + if (in != null) { + try { + in.close(); + } catch (Exception e) { + } + } + } + + return null; + } + + /** + * ¹¦ÄÜ:»ñÈ¡ÊäËÍÏß×îºóÖ¸Áî + * + * @param strConfigPath + * @param bit + * @return + */ + public static Hashtable getLastCKDRKSSJcmdLC(String strConfigPath, byte bit) { + FileInputStream fin = null; + ObjectInputStream in = null; + + try { + File file = new File(strConfigPath + "CKDRKSSJcmdLC" + bit + ".dat"); + if (file.exists()) { + fin = new FileInputStream(file); + in = new ObjectInputStream(fin); + Object obj = in.readObject(); + if (obj != null) { + return (Hashtable) obj; + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (fin != null) { + try { + fin.close(); + } catch (Exception e) { + } + } + if (in != null) { + try { + in.close(); + } catch (Exception e) { + } + } + } + + return null; + } + + /** + * ¹¦ÄÜ:¶ÁÈ¡³öÍÐÅÌδÍê³ÉµÄÈÎÎñ + * + * @param strConfigPath + * @return + */ +// public static Hashtable getOutTrayExecTask(String strConfigPath) { +// FileInputStream fin = null; +// ObjectInputStream in = null; +// try { +// File file = new File(strConfigPath + "outtraytask.dat"); +// if (file.exists()) { +// fin = new FileInputStream(file); +// in = new ObjectInputStream(fin); +// Object obj = in.readObject(); +// if (obj != null) { +// return (Hashtable) obj; +// } +// } +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fin != null) { +// try { +// fin.close(); +// } catch (Exception e) { +// } +// } +// if (in != null) { +// try { +// in.close(); +// } catch (Exception e) { +// } +// } +// } +// return null; +// } + + /** + * ¹¦ÄÜ:±£´æ³öÍÐÅÌδÍê³ÉµÄÈÎÎñ + * + * @param strConfigPath + * @param bit + * @param hsExecTask + */ +// public static void saveOutTrayExecTask(String strConfigPath, Hashtable hsExecTask) { +// FileOutputStream fos = null; +// ObjectOutputStream out = null; +// try { +// fos = new FileOutputStream(strConfigPath + "outtraytask.dat"); +// out = new ObjectOutputStream(fos); +// out.writeObject(hsExecTask); +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fos != null) { +// try { +// fos.close(); +// } catch (Exception e) { +// } +// } +// if (out != null) { +// try { +// out.close(); +// } catch (Exception e) { +// } +// } +// } +// } + + /** + * ¹¦ÄÜ:¶ÁÈ¡³é¼ì³ö¿â»ò·µ°ü³ö¿âδÍê³ÉµÄÈÎÎñ + * + * @param strConfigPath + * @return + */ +// public static Hashtable getCJOutExecTask(String strConfigPath) { +// FileInputStream fin = null; +// ObjectInputStream in = null; +// try { +// File file = new File(strConfigPath + "cjouttask.dat"); +// if (file.exists()) { +// fin = new FileInputStream(file); +// in = new ObjectInputStream(fin); +// Object obj = in.readObject(); +// if (obj != null) { +// return (Hashtable) obj; +// } +// } +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fin != null) { +// try { +// fin.close(); +// } catch (Exception e) { +// } +// } +// if (in != null) { +// try { +// in.close(); +// } catch (Exception e) { +// } +// } +// } +// return null; +// } + + /** + * ¹¦ÄÜ:±£´æ³é¼ì³ö¿â»ò·µ°ü³ö¿âδÍê³ÉµÄÈÎÎñ + * + * @param strConfigPath + * @param bit + * @param hsExecTask + */ +// public static void saveCJOutExecTask(String strConfigPath, Hashtable hsExecTask) { +// FileOutputStream fos = null; +// ObjectOutputStream out = null; +// try { +// fos = new FileOutputStream(strConfigPath + "cjouttask.dat"); +// out = new ObjectOutputStream(fos); +// out.writeObject(hsExecTask); +// } catch (Exception ex) { +// ex.printStackTrace(); +// } finally { +// if (fos != null) { +// try { +// fos.close(); +// } catch (Exception e) { +// } +// } +// if (out != null) { +// try { +// out.close(); +// } catch (Exception e) { +// } +// } +// } +// } + +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/HttpClientUtility.java b/src/com/wms/dss/ats/customs/abb/utils/HttpClientUtility.java new file mode 100644 index 0000000..8b50d4b --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/HttpClientUtility.java @@ -0,0 +1,196 @@ +package com.wms.dss.ats.customs.abb.utils; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +//import com.sap.me.frame.BasicBOBeanException; +//import com.sap.me.frame.Data; + +/** + * @author zhihao.sang + * @Description: restful请求工具类 + * @date 2020å¹´6月25æ—¥ 上å�ˆ11:14:31 + */ +public class HttpClientUtility { + + /** + * @Description: å�‘é€�带jsonå�‚æ•°ã€�Headerçš„post请求至ThingWorx + * @param url + * @param jsonString + * @param paramHeader + * @return + * @throws IOException + * @throws BasicBOBeanException + */ +// public static String thingWorxPost(String url, String jsonString, Map paramHeader) throws IOException, BasicBOBeanException { +// // 创建请求客户端 +// CloseableHttpClient httpClient = HttpClients.custom().build(); +// // 创建post请求 +// HttpPost httpPost = new HttpPost(url); +// // 设置headerä¿¡æ�¯ +// setHeader(httpPost, paramHeader); +// // 设置JSONæ•°æ�® +// StringEntity entityStr = new StringEntity(jsonString, ContentType.APPLICATION_JSON); +// httpPost.setEntity(entityStr); +// // 设置连接超时时间:15ç§’ +// httpPost.setConfig(RequestConfig.custom().setConnectTimeout(15000).build()); +// // 执行并获å�–返回 +// CloseableHttpResponse response = httpClient.execute(httpPost); +// HttpEntity entity = response.getEntity(); +// String resp = EntityUtils.toString(entity, StandardCharsets.UTF_8); +// EntityUtils.consume(entity); +// // 关闭连接 +// response.close(); +// if (response.getStatusLine().getStatusCode() != 200) { +// // 20226.simple = 调用Thingworx接å�£å¤±è´¥ï¼š%MESSAGE% +// throw new BasicBOBeanException(20226, new Data("MESSAGE", resp)); +// } +// return resp; +// } + + /** + * @Description: 请求头赋值 + * @param request + * @param paramHeader + */ + private static void setHeader(HttpRequestBase request, Map paramHeader) { + // 设置Header + if (paramHeader != null) { + paramHeader.forEach(request::addHeader); + } + } + + + /** + * + * @Description: 带æ�ƒé™�的请求 + * @param url + * @param jsonString + * @param paramHeader + * @param userName + * @param password + * @return + * @throws IOException + */ + public static String sendPost(String url, String jsonString, Map paramHeader, String userName, String password) throws IOException { + CredentialsProvider provider = new BasicCredentialsProvider(); + UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userName, password); + provider.setCredentials(AuthScope.ANY, credentials); + CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(provider).build(); + String resp = ""; + HttpPost httpPost = new HttpPost(url); + setHeader(httpPost, paramHeader); + StringEntity entityStr = new StringEntity(jsonString, ContentType.create("text/plain", "UTF-8")); + httpPost.setEntity(entityStr); + CloseableHttpResponse response = null; + response = httpClient.execute(httpPost); + HttpEntity entity = response.getEntity(); + resp = EntityUtils.toString(entity, "UTF-8"); + EntityUtils.consume(entity); + response.close(); + if (resp == null || resp.equals("")) { + return ""; + } + return resp; + } + + /** + * + * @Description: å�‘é€�带jsonå�‚æ•°ã€�Headerçš„post请求 + * @param url + * @param jsonString + * @param paramHeader + * @return + * @throws IOException + */ + public static String sendPost(String url, String jsonString, Map paramHeader) throws IOException { + if (jsonString == null || jsonString.isEmpty()) { + return sendPost(url, paramHeader); + } + String resp = ""; + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + httpPost.setHeader("Authorization",paramHeader.get("Authorization")); + setHeader(httpPost, paramHeader); + StringEntity entityStr = new StringEntity(jsonString, ContentType.create("application/json", "UTF-8")); + httpPost.setEntity(entityStr); + CloseableHttpResponse response = null; + response = httpClient.execute(httpPost); + HttpEntity entity = response.getEntity(); + resp = EntityUtils.toString(entity, "UTF-8"); + EntityUtils.consume(entity); + response.close(); + if (resp == null || resp.equals("")) { + return ""; + } + return resp; + } + + /** + * + * @Description: å�‘é€�带Headerçš„HttpPost请求 + * @param url + * @param paramHeader + * @return + * @throws IOException + */ + public static String sendPost(String url, Map paramHeader) throws IOException { + // 1.获得一个httpclient对象 + CloseableHttpClient httpclient = HttpClients.createDefault(); + // 2.生æˆ�一个post请求 + HttpPost httpPost = new HttpPost(url); + // setHeader(httpPost, paramHeader); + CloseableHttpResponse response = null; + //创建å�‚数列表 + if(paramHeader!=null){ + List paramValueList = new ArrayList(); + for (String key : paramHeader.keySet()) { + Object value = paramHeader.get(key); + if(value!=null){ + paramValueList.add(new NameValuePair() { + + @Override + public String getValue() { + return value + ""; + } + + @Override + public String getName() { + return key; + } + }); + + } + } + //模拟表å�• + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramValueList, "UTF-8"); + httpPost.setEntity(entity); + } + // 3.执行post请求并返回结果 + response = httpclient.execute(httpPost); + // 4.处ç�†ç»“果,这里将结果返回为字符串 + HttpEntity entity = response.getEntity(); + String result = null; + result = EntityUtils.toString(entity); + return result; + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/HttpConnection.java b/src/com/wms/dss/ats/customs/abb/utils/HttpConnection.java new file mode 100644 index 0000000..2a60aa4 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/HttpConnection.java @@ -0,0 +1,85 @@ +package com.wms.dss.ats.customs.abb.utils; + +import com.ricosoft.common.logger.Logger; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * @author zn kai + * @create 2020-06-02 17:49 + */ +public class HttpConnection { + + /** + * µ÷ÓÃwms½Ó¿Ú + * + * @param uri µØÖ· + * @param data ÇëÇóÊý¾Ý + */ + public static String httpConn(String uri, String data) { + String le = null; + HttpURLConnection conn = null; + try { + URL url = new URL(uri); + conn = (HttpURLConnection) url.openConnection(); + //µ±´´½¨ÁËÒ»¸öHttpURLConnectionºó,Æäʵµ×²ã´´½¨ÁËÒ»¸ösocket¶ÔÏó + conn.setConnectTimeout(3000);//ÉèÖÃÁ¬½ÓÖ÷»ú³¬Ê±Ê±¼ä + conn.setReadTimeout(2000);//ÉèÖôÓÖ÷»ú¶ÁÈ¡Êý¾Ý³¬Ê±Ê±¼ä + conn.setRequestMethod("POST");//ÇëÇó·½Ê½ + conn.setDoOutput(true);//¶ÁÈ¡Êä³öÁ÷£¬ÔÚʹÓÃPOSTÏò·þÎñÆ÷Ìá½»Êý¾Ýʱ±ØÐëÒª½«¸Ã·½·¨ÉèÖÃΪtrue + conn.setDoInput(true);// ÉèÖÃÊÇ·ñ´ÓhttpUrlConnection¶ÁÈ룬ĬÈÏÇé¿öÏÂÊÇtrue; + conn.setUseCaches(false);//postÇëÇó²»ÄÜʹÓûº´æ + //conn.setRequestProperty("Connection", "Keep-Alive"); + //É趨´«Ë͵ÄÄÚÈÝÀàÐÍÊÇ¿ÉÐòÁл¯µÄjava¶ÔÏó + //conn.setRequestProperty("Content-type", "application/x-java-serialized-object"); + // Á¬½Ó£¬´ÓÉÏÊöurl.openConnection()ÖÁ´ËµÄÅäÖñØÐëÒªÔÚconnect֮ǰÍê³É£¬ + conn.connect(); + //дÈëÐèÒª·¢Ë͵ÄÊý¾Ý + String body = "job=job1&jobGroup=jobGroup1"; + + //par p = new par(); + //p.setJob("1"); + //p.setJobGroup("1"); + //String json = JsonUtil.getJson(p); + + //´Ë´¦getOutputStream»áÒþº¬µÄ½øÐÐconnect(¼´£ºÈçͬµ÷ÓÃÉÏÃæµÄconnect()·½·¨, ËùÒÔ²»µ÷ÓÃÉÏÊöµÄconnect()Ò²¿ÉÒÔ + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream(), "UTF-8")); + writer.write(data); + writer.close();//closeÖ´Ðлáflush + //·þÎñÆ÷·µ»ØµÄ״̬Âë + int responseCode = conn.getResponseCode(); + + //¶ÁÈ¡·þÎñÆ÷·µ»ØµÄÊý¾Ý + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + //¶ÁÈ¡ÍêÏìÓ¦Êý¾ÝÖ®ºó,µ÷ÓÃclose·½·¨¹Ø±ÕÊäÈëÁ÷, + // JDK httpЭÒé´¦ÀíÆ÷»á½«Õâ¸öÁ¬½Ó·Åµ½Ò»¸öÁ¬½Ó»º´æÖУ¬ÒÔ±ãÖ®ºóµÄHTTPÇëÇó½øÐи´Óà + reader.close(); + //System.err.println("statusCode:"+responseCode+"------status:"+response.toString()); + le = response.toString(); + } catch (Exception e) { + Logger.info("wms½Ó¿ÚÁ¬½Óʧ°Ü::" + e.getMessage()); + try { + Thread.sleep(500); + } catch (InterruptedException e1) { + + } + } finally { + if (conn != null) { + //¹Ø±Õ Http Á¬½Ó,ÊÍ·Å×ÊÔ´ + conn.disconnect(); //±íʾ¹Ø±Õµ×²ãsocketÁ¬½Ó£¬²»»áÆôÓÃkeepAlive + } + } + return le; + } + +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/ParseUtil.java b/src/com/wms/dss/ats/customs/abb/utils/ParseUtil.java new file mode 100644 index 0000000..55b0740 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/ParseUtil.java @@ -0,0 +1,600 @@ +package com.wms.dss.ats.customs.abb.utils; + +import HslCommunication.BasicFramework.SoftBasic; +import com.alibaba.fastjson.JSON; +import org.apache.commons.codec.binary.Base64; +import org.libnodave.Nodave; + +import java.math.BigInteger; +import java.util.List; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author zn kai + * @create 2021-06-28 14:04 + */ +public class ParseUtil { + + + /** + * Õ¾µãÅÅÐò + * + * @param offset + * @param valueSize + * @return + */ + public static int[] getWriteValueSite(int offset, int valueSize) { + int[] stieArray = new int[valueSize]; + stieArray[0] = offset; + for (int i = 1; i < valueSize; i++) { + stieArray[i] = offset += 1; + } + return stieArray; + } + + /** + * Ï·¢ Êý×é´¦Àí DWORD + * + * @param values + * @param type ÀàÐÍ + * @return + */ + public static String[] getWriteValueDWORD(String[] values) { + String[] data = new String[values.length * 2]; + int index = 0; + for (int i = 0; i < values.length; i++) { + data[index] = String.valueOf(Integer.parseInt(values[i]) % 65536); + data[index + 1] = String.valueOf(Integer.parseInt(values[i]) / 65536); + index += 2; + } + return data; + } + + /** + * »ñȡȡµÃµ½µÄÖµ DWORD + * + * @param start + * @param end + * @param site 0 ²»ÐèҪƴ½Ó ²¹Áã 6λ + * @return + */ + + public static Object getReadValue(byte[] start, byte[] end, int site) { + int wordStart = getWORD(start, 0); + int wordEnd = getWORD(end, 0); + int value = wordStart == 0 || (wordStart != 0 && wordEnd != 0) ? wordStart + wordEnd * 65536 : wordStart; + if (site == 0) { + return value; + } + return String.format("%06d", value); + } + + + public static String byte2Base64StringFun(byte[] b) { + return Base64.encodeBase64String(b); + } + + public static String getSTRING30(byte[] bt, int pos) { + return Nodave.SBEString30(bt, pos).toString(); + } + + public static float getFloat(byte[] bt, int pos) { + return Nodave.BEFloat(bt, pos); + } + + public static long getDWORD(byte[] bt, int pos) { + return Nodave.USBELong(bt, pos); + } + + public static long getDINT(byte[] bt, int pos) { + return Nodave.SBELong(bt, pos); + } + + public static String getSTRING(byte[] bt, int pos) { + return Nodave.SBEString(bt, pos).toString(); + } + + public static int getWORD(byte[] bt, int pos) { + return Nodave.USBEWord(bt, pos); + } + + public static int getINT(byte[] bt, int pos) { + return Nodave.SBEWord(bt, pos); + } + + public static int getBYTE(byte[] bt, int pos) { + return Nodave.SByte(bt, pos); + } + + public static int getCHAR(byte[] bt, int pos) { + return Nodave.SByte(bt, pos); + } + + public static long getUS32(byte[] bt, int pos) { + return Nodave.USBELong(bt, pos); + } + + public static long getS32(byte[] bt, int pos) { + return Nodave.SBELong(bt, pos); + } + + public static int getUS16(byte[] bt, int pos) { + return Nodave.USBEWord(bt, pos); + } + + public static int getS16(byte[] bt, int pos) { + return Nodave.SBEWord(bt, pos); + } + + public static int getUS8(byte[] bt, int pos) { + return Nodave.USByte(bt, pos); + } + + public static int getS8(byte[] bt, int pos) { + return Nodave.SByte(bt, pos); + } + + public static byte[] byteConcatArray(String[] arr) { + int length = 0; + for (String a : arr) { + byte[] x = Nodave.bswap_16(Integer.parseInt(a)); + length += x.length; + } + byte[] bt6 = new byte[length]; + + int len = 0; + for (String a : arr) { + byte[] b = Nodave.bswap_16(Integer.parseInt(a)); + System.arraycopy(b, 0, bt6, len, b.length); + if (len < bt6.length) { + len += b.length; + } + } + return bt6; + } + + /** + * ½«¶þ½øÖÆ×ª»»³É16½øÖÆ + * + * @param buf + * @return + */ + public static String parseByte2HexStr(byte buf[]) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < buf.length; i++) { + String hex = Integer.toHexString(buf[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + sb.append(hex.toUpperCase()); + } + return sb.toString(); + } + + /** + * ½«16½øÖÆ×ª»»Îª¶þ½øÖÆ + * + * @param hexStr + * @return + */ + public static byte[] parseHexStr2Byte(String hexStr) { + if (hexStr.length() < 1) { + return null; + } + byte[] result = new byte[hexStr.length() / 2]; + for (int i = 0; i < hexStr.length() / 2; i++) { + int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); + int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), + 16); + result[i] = (byte) (high * 16 + low); + } + return result; + } + + + /** + * ·¢ËÍ16½øÖÆ×Ö·û´® + * + * @param hexString + * @return + */ + public static byte[] hexStringToBytes(String hexString) { + if (hexString == null || hexString.equals("")) { + return null; + } + // toUpperCase½«×Ö·û´®ÖеÄËùÓÐ×Ö·ûת»»Îª´óд + hexString = hexString.toUpperCase(); + int length = hexString.length() / 2; + // toCharArray½«´Ë×Ö·û´®×ª»»ÎªÒ»¸öеÄ×Ö·ûÊý×é¡£ + char[] hexChars = hexString.toCharArray(); + byte[] d = new byte[length]; + for (int i = 0; i < length; i++) { + int pos = i * 2; + d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); + } + return d; + } + + //charToByte·µ»ØÔÚÖ¸¶¨×Ö·ûµÄµÚÒ»¸ö·¢ÉúµÄ×Ö·û´®ÖеÄË÷Òý£¬¼´·µ»ØÆ¥Åä×Ö·û + private static byte charToByte(char c) { + return (byte) "0123456789ABCDEF".indexOf(c); + } + + /** + * ½«×Ö½ÚÊý×éת»»Îª16½øÖÆ×Ö·û´® + * + * @param bytes + * @param len + * @return + */ + public static String binaryToHexString(byte[] bytes, int len) { + String hexStr = "0123456789ABCDEF"; + String result = ""; + String hex = ""; + for (int i = 0; i < len; i++) { + hex = String.valueOf(hexStr.charAt((bytes[i] & 0xF0) >> 4)); + hex += String.valueOf(hexStr.charAt(bytes[i] & 0x0F)); + result += hex; + } + /*for (byte b : bytes) { + hex = String.valueOf(hexStr.charAt((b & 0xF0) >> 4)); + hex += String.valueOf(hexStr.charAt(b & 0x0F)); + result += hex + " "; + }*/ + return result; + } + + public static String getCRC2(byte[] bytes) { +// ModBus ͨÐÅЭÒéµÄ CRC ( ÈßÓàÑ­»·Ð£ÑéÂ뺬2¸ö×Ö½Ú, ¼´ 16 λ¶þ½øÖÆÊý¡£ +// CRC ÂëÓÉ·¢ËÍÉ豸¼ÆËã, ·ÅÖÃÓÚËù·¢ËÍÐÅÏ¢Ö¡µÄβ²¿¡£ +// ½ÓÊÕÐÅÏ¢É豸ÔÙÖØÐ¼ÆËãËù½ÓÊÕÐÅÏ¢ (³ý CRC Ö®ÍâµÄ²¿·Ö£©µÄ CRC, +// ±È½Ï¼ÆËãµÃµ½µÄ CRC ÊÇ·ñÓë½ÓÊÕµ½CRCÏà·û, Èç¹ûÁ½Õß²»Ïà·û, ÔòÈÏΪÊý¾Ý³ö´í¡£ +// +// 1) Ô¤Öà 1 ¸ö 16 λµÄ¼Ä´æÆ÷ΪʮÁù½øÖÆFFFF(¼´È«Îª 1) , ³Æ´Ë¼Ä´æÆ÷Ϊ CRC¼Ä´æÆ÷¡£ +// 2) °ÑµÚÒ»¸ö 8 λ¶þ½øÖÆÊý¾Ý (ͨÐÅÐÅÏ¢Ö¡µÄµÚÒ»¸ö×Ö½Ú) Óë 16 λµÄ CRC¼Ä´æÆ÷µÄµÍ 8 λÏàÒì»ò, °Ñ½á¹û·ÅÓÚ CRC¼Ä´æÆ÷¡£ +// 3) °Ñ CRC ¼Ä´æÆ÷µÄÄÚÈÝÓÒÒÆÒ»Î»( ³¯µÍλ)Óà 0 Ìî²¹×î¸ßλ, ²¢¼ì²éÓÒÒÆºóµÄÒÆ³öλ¡£ +// 4) Èç¹ûÒÆ³öλΪ 0, ÖØ¸´µÚ 3 ²½ ( ÔÙ´ÎÓÒÒÆÒ»Î»); Èç¹ûÒÆ³öλΪ 1, CRC ¼Ä´æÆ÷Óë¶àÏîʽA001 ( 1010 0000 0000 0001) ½øÐÐÒì»ò¡£ +// 5) ÖØ¸´²½Öè 3 ºÍ²½Öè 4, Ö±µ½ÓÒÒÆ 8 ´Î,ÕâÑùÕû¸ö8λÊý¾ÝÈ«²¿½øÐÐÁË´¦Àí¡£ +// 6) ÖØ¸´²½Öè 2 µ½²½Öè 5, ½øÐÐͨÐÅÐÅÏ¢Ö¡ÏÂÒ»¸ö×ֽڵĴ¦Àí¡£ +// 7) ½«¸ÃͨÐÅÐÅÏ¢Ö¡ËùÓÐ×Ö½Ú°´ÉÏÊö²½Öè¼ÆËãÍê³Éºó,µÃµ½µÄ16λCRC¼Ä´æÆ÷µÄ¸ß¡¢µÍ×Ö½Ú½øÐн»»»¡£ +// 8) ×îºóµÃµ½µÄ CRC¼Ä´æÆ÷ÄÚÈݼ´Îª CRCÂë¡£ + + int CRC = 0x0000ffff; + int POLYNOMIAL = 0x0000a001; + + int i, j; + for (i = 0; i < bytes.length; i++) { + CRC ^= (int) bytes[i]; + for (j = 0; j < 8; j++) { + if ((CRC & 0x00000001) == 1) { + CRC >>= 1; + CRC ^= POLYNOMIAL; + } else { + CRC >>= 1; + } + } + } + //¸ßµÍλת»»£¬¿´Çé¿öʹÓã¨Æ©Èç±¾ÈËÕâ´Î¶Ôled²ÊÆÁµÄͨѶ¿ª·¢¾Í¹æ¶¨Ð£ÑéÂë¸ßλÔÚǰµÍλÔÚºó£¬Ò²¾Í²»ÐèҪת»»¸ßµÍλ) + //CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); + return Integer.toHexString(CRC); + } + + public static String getCRC(String data) { + data = data.replace(" ", ""); + int len = data.length(); + if (!(len % 2 == 0)) { + return "0000"; + } + int num = len / 2; + byte[] para = new byte[num]; + for (int i = 0; i < num; i++) { + int value = Integer.valueOf(data.substring(i * 2, 2 * (i + 1)), 16); + para[i] = (byte) value; + } + return getCRC(para); + } + + /** + * ¼ÆËãCRC16УÑéÂë + * + * @param bytes ×Ö½ÚÊý×é + * @return {@link String} УÑéÂë + * @since 1.0 + */ + public static String getCRC(byte[] bytes) { + // CRC¼Ä´æÆ÷ȫΪ1 + int CRC = 0x0000ffff; + // ¶àÏîʽУÑéÖµ + int POLYNOMIAL = 0x0000a001; + int i, j; + for (i = 0; i < bytes.length; i++) { + CRC ^= ((int) bytes[i] & 0x000000ff); + for (j = 0; j < 8; j++) { + if ((CRC & 0x00000001) != 0) { + CRC >>= 1; + CRC ^= POLYNOMIAL; + } else { + CRC >>= 1; + } + } + } + // ½á¹ûת»»Îª16½øÖÆ + String result = Integer.toHexString(CRC).toUpperCase(); + if (result.length() != 4) { + StringBuffer sb = new StringBuffer("0000"); + result = sb.replace(4 - result.length(), 4, result).toString(); + } + //¸ßλÔÚǰµØÎ»ÔÚºó + //return result.substring(2, 4) + " " + result.substring(0, 2); + // ½»»»¸ßµÍ룬µÍλÔÚǰ¸ßλÔÚºó + return result.substring(2, 4) + result.substring(0, 2); + } + + + /** + * byteÊý×éת»»Îª¶þ½øÖÆ×Ö·û´®,ÿ¸ö×Ö½ÚÒÔ","¸ô¿ª + **/ + public static char[] byteArrToBinStr(byte[] b) { + StringBuffer result = new StringBuffer(); + for (int i = 0; i < b.length; i++) { + result.append(Long.toString(b[i] & 0xff, 2) + ","); + } + //Öµ + String compCode = result.toString().substring(0, result.length() - 1); + String myStr = "0000000000000000"; + String str = compCode + myStr.substring(0, myStr.length() - compCode.length()); + + return str.toCharArray(); + } + + /** + * 16½øÖÆ×ª10½øÖÆ + * + * @param content + * @return + */ + public static int hex16To10(String content) { + BigInteger integer = new BigInteger(content, 16); + return integer.intValue(); + } + + /** + * 10½øÖÆ×ª16½øÖÆ + * + * @param numb + * @return + */ + public static String encode10ToHEX16(Integer numb) { + + String hex = Integer.toHexString(numb); + return hex; + } + + /** + * 10ת16 2λ + * + * @param n + * @return + */ + public static String intToHex(int n) { + if (n == 0) { + return "00"; + } + StringBuilder sb = new StringBuilder(8); + String a; + char[] b = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + while (n != 0) { + sb = sb.append(b[n % 16]); + n = n / 16; + } + a = sb.reverse().toString(); + return a.length() < 2 ? "0" + a : a; + } + + //16½øÖÆÊýת¶þ½øÖÆ + public static void toHex(int num) { + + //& Á½Á½Îª1¼´Îª1 + //>>>ÎÞ·ûºÅÓÒÒÆ + /** + * eg.60 + * 0000-0000 0000-0000 0000-0000 0011-1100 60µÄ¶þ½øÖƱíʾ + * & 0000-0000 0000-0000 0000-0000 0000-1111 15µÄ¶þ½øÖƱíʾ + * &ºóµÄÖµ 0000-0000 0000-0000 0000-0000 0000-1100 ֵΪ12¼´16½øÖƵÄC + */ + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 8; i++) { + int temp = num & 15; + if (temp > 9) { + sb.append((char) (temp - 10 + 'A'));//ǿת³É16½øÖÆ + + } else { + sb.append(temp); + } + num = num >>> 4; + } + System.out.println(sb.reverse());//0000003C + + } + + + /** + * 16½øÖÆ×ª2½øÖÆ ÓÃÓÚÌáÉý»ú״̬ + * + * @param num + * @return + */ + public static int[] hex16ToBinary(String num) { + String str = Integer.toBinaryString(hex16To10(num)); + char[] chars = str.toCharArray(); + + int[] in = new int[16]; + for (int i = 0; i < chars.length; i++) { + in[i] = chars[chars.length - i - 1] - '0'; + } + return in; + } + + + /** + * ¶à¸öbyte ºÏ²¢³ÉÒ»¸öbyte + * + * @param values + * @return + */ + public static byte[] byteMerge(byte[]... values) { + int length_byte = 0; + for (int i = 0; i < values.length; i++) { + length_byte += values[i].length; + } + byte[] all_byte = new byte[length_byte]; + int countLength = 0; + for (int i = 0; i < values.length; i++) { + byte[] b = values[i]; + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + + public static String[] stringMerge(String[]... values) { + int length_byte = 0; + for (int i = 0; i < values.length; i++) { + length_byte += values[i].length; + } + String[] all_byte = new String[length_byte]; + int countLength = 0; + for (int i = 0; i < values.length; i++) { + String[] b = values[i]; + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + + public static int[] intMerge(int[]... values) { + int length_byte = 0; + for (int i = 0; i < values.length; i++) { + length_byte += values[i].length; + } + int[] all_byte = new int[length_byte]; + int countLength = 0; + for (int i = 0; i < values.length; i++) { + int[] b = values[i]; + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + + + /** + * int תbyte + * + * @param value + * @param len + * @return + */ + public static byte[] int2Bytes(int value, int len) { + byte[] b = new byte[len]; + for (int i = 0; i < len; i++) { + b[len - i - 1] = (byte) ((value >> 8 * i) & 0xff); + } + return b; + } + + public static String uuids() { + UUID uuid = UUID.randomUUID(); + String a = uuid.toString().replace("-", "").toUpperCase(); + return a; + } + + /** + * ´Ó¶ÔÏóA copyµ½ ¶ÔÏóB + * + * @param ob A + * @param clazz B.class + * @return B + */ + public static T copy(Object ob, Class clazz) { + String oldOb = JSON.toJSONString(ob); + return JSON.parseObject(oldOb, clazz); + } + + /** + * ´ÓList copyµ½List + * + * @param list + * @param clazz + * @param + * @return + */ + public static List copy(List list, Class clazz) { + String oldOb = JSON.toJSONString(list); + return JSON.parseArray(oldOb, clazz); + } + + /** + * short 16λתint + * @param start + * @param data + * @return + */ + public static int optInt(int start, String data) { + return Integer.parseInt(data.substring(start * 2, (start + 2) * 2), 16); + } + /** + * int 16λתint + * @param start + * @param data + * @return + */ + public static int optDInt(int start, String data) { + return Integer.parseInt(data.substring(start * 2, (start + 4) * 2), 16); + } + /** + * long 16λתlong + * @param start + * @param data + * @return + */ + public static Long optLong(int start, String data) { + return Long.parseLong(data.substring(start * 2, (start + 8) * 2), 16); + } + /** + * string 16λתstring + * @param start + * @param data + * @return + */ + + public static String optString(int start, String data) { + byte[] bytes = SoftBasic.HexStringToBytes(data.substring(start * 2, (start + 12) * 2)); + return Tools.bytetostringtool(bytes); + } + + /** + * Æ¥Åä×Ö·û´®ÊÇ·ñÊý×Ö¿ªÍ· + * @param str + * @return + */ + public static boolean isNumeric(String str) { + Pattern pattern = Pattern.compile("[0-9]*"); + Matcher isNum = pattern.matcher(str.charAt(0)+""); + if (!isNum.matches()) { + return false; + } + return true; + } + public static void main(String[] args) { + + } + + + public static String optSpeString(int start, String data) { + byte[] bytes = SoftBasic.HexStringToBytes(data.substring(start * 2, (start + 14) * 2)); + return Tools.bytetostringtool(bytes); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/ProcedureResult.java b/src/com/wms/dss/ats/customs/abb/utils/ProcedureResult.java new file mode 100644 index 0000000..a6d65ad --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/ProcedureResult.java @@ -0,0 +1,51 @@ +package com.wms.dss.ats.customs.abb.utils; + + +/* +* 存储过程返回结果 +* */ +public class ProcedureResult { + + + private Integer result; + + private String msg; + + private ProcedureResult(Integer result, String msg) { + this.result = result; + this.msg = msg; + } + + public static ProcedureResult result(){ + ProcedureResult procedureResult = new ProcedureResult(0,"åˆ�始值,未知"); + return procedureResult; + } + + public static ProcedureResult result(Integer result,String msg){ + ProcedureResult procedureResult = new ProcedureResult(0,"åˆ�始值,未知"); + if(result!=null){ + procedureResult.setResult(result); + } + if(msg!=null){ + procedureResult.setMsg(msg); + } + return procedureResult; + } + + + public Integer getResult() { + return result; + } + + private void setResult(Integer result) { + this.result = result; + } + + public String getMsg() { + return msg; + } + + private void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/QueryDbDataUtils.java b/src/com/wms/dss/ats/customs/abb/utils/QueryDbDataUtils.java new file mode 100644 index 0000000..85d2279 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/QueryDbDataUtils.java @@ -0,0 +1,618 @@ +package com.wms.dss.ats.customs.abb.utils; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.common.server.form.Logger; + +import java.util.*; + +/* + *@Version 1.0 + * Êý¾Ý»ñÈ¡ + **/ +public class QueryDbDataUtils { + + public static WmsDeviceExecutionQueue getQueueByTask(EntityDAO dao, Long rwh) throws Exception { + WmsDeviceExecutionQueue queue = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from WmsDeviceExecutionQueue where rwzt=1 and rwh=").append(rwh); + List ls = dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + queue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetQueueByTask»ñÈ¡¶ÓÁÐÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return queue; + } + public static WmsDeviceExecutionQueue findDeviceQueueByTaskNo(EntityDAO dao, int devId, long taskNo, int xf) { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from WmsDeviceExecutionQueue where rwh = '").append(taskNo).append("' "); + + List ls = dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + Logger.info("Ö´ÐÐfindDeviceQueueByTaskNoѰÕÒ"+devId+"ºÅ¶Ñ¶â»úÖØÐÂÏ·¢¶ÓÁÐÓÐÎ󣡣¡£¡£¡ÈÎÎñºÅΪ£º" + taskNo); + } + return wmsDeviceExecutionQueue; + } + + public static MydoJob getRKMydoJobBySSJNo(EntityDAO m_dao, String ssjNo) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out<10 and status=1 and cargo_space_id='" + ssjNo + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJobÈë¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static MydoJob getRKMydoJobByTaskNo(EntityDAO m_dao, String taskNo) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out<10 and status=3 and task_no='" + taskNo + "' order by create_time asc "); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJobÈë¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static MydoJob getCKMydoJob(EntityDAO m_dao) throws Exception { + MydoJob mydoJob = new MydoJob(); + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out>9 and status=1 order by create_time asc limit 1"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" +e.getMessage()); + } + return mydoJob; + } + + public static int getWmsDeviceExecutionQueueByRwlx(EntityDAO m_dao,int rwlx) throws Exception { + int count = 0; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where rwlx="+rwlx+" and DevId= 1"); + if (ls != null && ls.size() > 0) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ¶ÓÁÐWmsDeviceExecutionQueueÖÐÈë¿â¶Ñ¶â»ú¶ÓÁÐÊýÁ¿´íÎó£º" + e.getMessage()); + } + return count; + } + + public static int getWmsDeviceExecutionQueueByRwlxAndDev(EntityDAO m_dao,int devId,int rwlx) throws Exception { + int count = 0; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where rwlx="+rwlx+" and DevId= "+devId); + if (ls != null && ls.size() > 0) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ¶ÓÁÐWmsDeviceExecutionQueueÖÐÈë¿â¶Ñ¶â»ú¶ÓÁÐÊýÁ¿´íÎó£º" + e.getMessage()); + } + return count; + } + + public static List getWmsDeviceExecutionQueueInfoByRwlxAndDev(EntityDAO m_dao,int devId,int rwlx) throws Exception { + List wmsDeviceExecutionQueue = new ArrayList<>(); + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where rwlx="+rwlx+" and DevId= "+devId); + if (ls != null && ls.size() > 0) { + for (Object l : ls) { + wmsDeviceExecutionQueue.add( (WmsDeviceExecutionQueue) l); + } + + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ¶ÓÁÐWmsDeviceExecutionQueueÖÐÈë¿â¶Ñ¶â»ú¶ÓÁÐÊýÁ¿´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueue; + } + + + public static int getWmsDeviceExecutionQueueByRwlxAndDev(EntityDAO m_dao,int devId,int... rwlx) throws Exception { + int count = 0; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from WmsDeviceExecutionQueue where rwlx in ("); + for (int i = 0; i < rwlx.length; i++) { + strBud.append(rwlx[i]).append(","); + } + strBud.deleteCharAt(strBud.length() - 1); + strBud.append(") and DevId= ").append(devId); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && !ls.isEmpty()) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ¶ÓÁÐWmsDeviceExecutionQueueÖÐÈë¿â¶Ñ¶â»ú¶ÓÁÐÊýÁ¿´íÎó£º" + e.getMessage()); + } + return count; + } + + public static MydoJob getCKMydoJobBySSJNo(EntityDAO m_dao, String ssjNo) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out>9 and status=1 and target_cargo_space_id='" + ssjNo + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static MydoJob getRKMyDoJobByTrayCode(EntityDAO m_dao, String trayCode,List status) throws Exception { + MydoJob mydoJob = null; + try { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("from MydoJob where in_or_out<10 and status in ("); + stringBuilder.append(StrUtil.join(",", status)) ; + stringBuilder.append(") and tray_code='").append(trayCode).append("'"); + List ls = m_dao.searchEntities(stringBuilder.toString()); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + e.printStackTrace(); + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + + public static MydoJob selectJobByEntranceId(EntityDAO m_dao, String entranceId) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out<10 and status=1 and entrance_id='" + entranceId + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾ÝÈë¿Ú»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + public static MydoJob getCKMyDoJobByTrayCode(EntityDAO m_dao, String trayCode) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out>9 and tray_code='" + trayCode + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static MydoJob getHlMyDoJobByTaskNo(EntityDAO m_dao, String trayCode) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out=3 and tray_code='" + trayCode + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static MydoJob getMyDoJobByTaskNo(EntityDAO m_dao, String taskNo) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where task_no='" + taskNo + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static int getWmsDeviceExecutionQueueByXF(EntityDAO m_dao,int ddjH) throws Exception{ + int count = 0; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where ddjxf=1 and DevId= "+ddjH); + if (ls != null && ls.size() > 0) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ¶ÓÁÐWmsDeviceExecutionQueueÖжѶâ»úÒÑÏ·¢¶ÓÁÐÊýÁ¿´íÎó£º" + e.getMessage()); + } + return count; + } + + public static WmsDeviceExecutionQueue getFirstWmsDeviceExecutionQueue(EntityDAO m_dao,int ddjH) throws Exception { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = null; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 order by scsj asc"); + if (ls != null && ls.size() > 0) { + wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueue; + } + + public static WmsDeviceExecutionQueue getFirstWmsDeviceExecutionQueueByRwlx(EntityDAO m_dao,int ddjH,int rwlx) throws Exception { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = null; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 and rwlx="+rwlx+" order by scsj asc"); + if (ls != null && ls.size() > 0) { + wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueue; + } + + public static WmsDeviceExecutionQueue getFirstWmsDeviceExecutionQueueOrderbyRwlx(EntityDAO m_dao,int ddjH,String type) throws Exception { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = null; + try { + List ls = null; + if (type.equals("1")) { + ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 order by rwlx asc, scsj asc"); + }else if (type.equals("2")) { + ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 order by rwlx desc, scsj asc"); + } + if (ls != null && ls.size() > 0) { + wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueue; + } + + public static WmsDeviceExecutionQueue getQueueByTask0(EntityDAO dao, Long rwh) throws Exception { + WmsDeviceExecutionQueue queue = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from WmsDeviceExecutionQueue where rwh=").append(rwh); + List ls = dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + queue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetQueueByTask»ñÈ¡¶ÓÁÐÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return queue; + } + + + public static MydoJob getSlotJobByTask(EntityDAO dao, Long zxrwh,List inOrOut) throws Exception { + MydoJob job = null; + try { + StringBuilder strBud = new StringBuilder(); + + if (CollUtil.isNotEmpty(inOrOut)){ + String join = CollUtil.join(inOrOut, ","); + strBud.append("from MydoJob where task_no=").append(zxrwh).append(" and in_or_out in (").append(join).append(")"); + }else { + strBud.append("from MydoJob where task_no=").append(zxrwh); + } + List ls = dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + job = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return job; + } + + public static void updateWmsDeviceExecutionQueueTime(EntityDAO m_dao, Long rwh){ + try { + String date = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update WmsDeviceExecutionQueue set xfsj= '"+date+"',ddjxf=1,xcykh=1 where rwh="+rwh); + } catch (Exception e) { + Logger.info("Ö´ÐÐupdateWmsDeviceExecutionQueueTime¸üжÓÁпªÊ¼Ê±¼ä´íÎó£º" + e.getMessage()); + } + } + + public static MydoJob getCKMydoJobByExitId(EntityDAO m_dao,List exitIdList) throws Exception { + + MydoJob job = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from MydoJob where exit_id in ('"); + String exitIdListStr = StrUtil.join("','", (Object) exitIdList); + strBud.append(exitIdListStr).append("')"); + strBud.append(" and in_or_out>9 and status=1 order by create_time asc limit 1"); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + job = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return job; + } + + public static int getCKCountMydoJobByExitId(EntityDAO m_dao,List exitIdList) throws Exception { + + int count = 0; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from MydoJob where exit_id in ('"); + String exitIdListStr = StrUtil.join("','", (Object) exitIdList); + strBud.append(exitIdListStr).append("')"); + strBud.append(" and in_or_out>9 and status=3"); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return count; + } + + public static MydoJob getCKRunningMydoJobByExitId(EntityDAO m_dao,List exitIdList) throws Exception { + + MydoJob job = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from MydoJob where exit_id in ('"); + String exitIdListStr = StrUtil.join("','", (Object) exitIdList); + strBud.append(exitIdListStr).append("')"); + strBud.append(" and in_or_out>9 and status=3 order by create_time asc limit 1"); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + job = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return job; + } + + public static List getCKMydoJobListByExitId(EntityDAO m_dao,String... exitIdList) throws Exception { + + List jobList = new ArrayList<>(); + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from MydoJob where exit_id in ('"); + String exitIdListStr = StrUtil.join("','", (Object) exitIdList); + strBud.append(exitIdListStr).append("')"); + strBud.append(" and in_or_out>9 and status=1 order by create_time asc limit 1"); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + for (Object l : ls) { + jobList.add((MydoJob) l); + } + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return jobList; + } + + + public static MsgDdj getDevIdByRoadwayId(EntityDAO mDao, String roadwayId) throws Exception{ + MsgDdj msgDdj=null; + try { + List ls = mDao.searchEntities("from MsgDdj where dqxd='" + roadwayId + "'"); + if (ls != null && ls.size() > 0) { + msgDdj = (MsgDdj) ls.get(0); + } + }catch (Exception e){ + throw new Exception("Ö´ÐÐggetDevIdByRoadwayId»ñÈ¡DevId´íÎó£º" + e.getMessage()); + } + return msgDdj; + } + + public static MydoJob getHlMyDoJobByEntranceId(EntityDAO m_dao, String ssjNo) throws Exception { + MydoJob job = null; + try { + StringBuilder strBud = new StringBuilder(); + strBud.append("from MydoJob where status =1 and in_or_out = 3 and entrance_id = '").append(ssjNo).append("'"); + List ls = m_dao.searchEntities(strBud.toString()); + if (ls != null && ls.size() > 0) { + job = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´ÐÐgetJobByTask»ñÈ¡×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return job; + } + + public static MydoJob getMyDoJobByTrayCode(EntityDAO mDao, String trayCode) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = mDao.searchEntities("from MydoJob where tray_code='" + trayCode + "'"); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJob³ö¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static WmsDeviceExecutionQueue getSecondQueueByDdjhAndRwlx(EntityDAO m_dao, int ddjH, int rwlx,String rwh) throws Exception { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = null; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 and rwh !='"+rwh+"' and rwlx = "+rwlx+" order by scsj asc"); + if (ls != null && ls.size() > 0) { + wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueue; + } + + public static MydoJob getRKMydoJobByTaskNoAndEp(EntityDAO m_dao, String taskNo, String execution_phase) throws Exception { + MydoJob mydoJob = null; + try { + + List ls = m_dao.searchEntities("from MydoJob where in_or_out<10 and status=3 and task_no='" + taskNo + "' and execution_phase = "+execution_phase+" order by create_time asc "); + if (ls != null && ls.size() > 0) { + mydoJob = (MydoJob) ls.get(0); + } + } catch (Exception e) { + throw new Exception("Ö´Ðиù¾Ý¹õ´²±àÂë»ñÈ¡MydoJobÈë¿â×÷ÒµÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return mydoJob; + } + + public static List getPortState(EntityDAO m_dao) throws Exception { + List wcsPortState = new ArrayList<>(); + try { + List ls = m_dao.searchEntities("from WcsPortState where spare2 = '0' and spare1 !='0' "); + for (Object l : ls) { + wcsPortState.add((WcsPortState) l); + } + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wcsPortState; + } + + public static void updateWcsPortState(EntityDAO mDao, String portName, String status) { + try { + mDao.updateSql("update WcsPortState set spare2 = '"+status+"' where portName = '"+portName+"'"); + } catch (Exception e) { + Logger.info("Ö´ÐÐupdateWcsPortState¸üжÓÁпªÊ¼Ê±¼ä´íÎó£º" + e.getMessage()); + } + } + + public static boolean getEndTime(EntityDAO mDao) throws Exception { + try { + List ls = mDao.searchEntities("from End "); + Object o = ls.get(0); + End end = (End) o; + if (DateUtil.compare(new Date(), end.getFinishTime()) > 0){ + return true; + } + return false; + } catch (RuntimeException e) { + throw new Exception("»ñȡʱ¼ä³ö´í£º" + e.getMessage()); + } + } + + public static ExceptionInfo selectException(EntityDAO mDao,long rwh) throws Exception { + ExceptionInfo exceptionInfo = null; + try { + List ls = mDao.searchEntities("from ExceptionInfo where taskNo="+rwh+""); + if (ls != null && !ls.isEmpty()) { + exceptionInfo = (ExceptionInfo) ls.get(0); + } + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return exceptionInfo; + } + + public static int selectCountExceptionNoSend(EntityDAO mDao,String ssjNo) throws Exception { + int count = 0; + try { + List ls = mDao.searchEntities("from ExceptionInfo where sendCompleted =0 and ssjNo = '"+ssjNo+"'"); + if (ls != null && !ls.isEmpty()) { + count = ls.size(); + } + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return count; + } + + public static WcsPortState getPortStateByName(EntityDAO mDao, String ssjNo) throws Exception { + WcsPortState wcsPortState = null; + try { + List ls = mDao.searchEntities("from WcsPortState where portName = '"+ssjNo+"'"); + wcsPortState = (WcsPortState) ls.get(0); + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wcsPortState; + } + + public static TaskPriority getTaskPriority(EntityDAO mDao, int ddjh) throws Exception { + TaskPriority taskPriority = null; + try { + List ls = mDao.searchEntities("from TaskPriority where type = '"+ddjh+"'"); + taskPriority = (TaskPriority) ls.get(0); + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return taskPriority; + } + + public static List getAllOutWmsDeviceExecutionQueueOrderbyRwlx(EntityDAO mDao, int ddjH) throws Exception { + List wmsDeviceExecutionQueues = new ArrayList<>(); + try { + List ls = null; + ls = mDao.searchEntities("from WmsDeviceExecutionQueue where DevId = "+ddjH+" and ddjxf=0 and rwlx>=10 order by rwlx asc, scsj asc"); + if (ls != null && ls.size() > 0) { + for (Object l : ls) { + WmsDeviceExecutionQueue wmsDeviceExecutionQueue = (WmsDeviceExecutionQueue) l; + wmsDeviceExecutionQueues.add(wmsDeviceExecutionQueue); + } + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return wmsDeviceExecutionQueues; + } + + public static ExceptionInfo selectExceptionByPort(EntityDAO mDao, String ssjNo) throws Exception { + ExceptionInfo exceptionInfo = null; + try { + List ls = mDao.searchEntities("from ExceptionInfo where ssjNo='"+ssjNo+"' and sendCompleted ='0' "); + if (ls != null && !ls.isEmpty()) { + exceptionInfo = (ExceptionInfo) ls.get(0); + } + } catch (RuntimeException e) { + throw new Exception("»ñÈ¡³öÈë¿Ú״̬ÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return exceptionInfo; + } + + public static int getWmsDeviceExecutionQueueByRwh(EntityDAO m_dao, String rwh) throws Exception { + int count = 0; + try { + List ls = m_dao.searchEntities("from WmsDeviceExecutionQueue where rwh = " + rwh + " order by scsj asc"); + if (ls != null && ls.size() > 0) { + count = ls.size(); + } + } catch (Exception e) { + throw new Exception("Ö´Ðвéѯ´´½¨Ê±¼ä×îÔçÖ´ÐжÓÁÐWmsDeviceExecutionQueueÐÅÏ¢´íÎó£º" + e.getMessage()); + } + return count; + + } +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/RequestUrls.java b/src/com/wms/dss/ats/customs/abb/utils/RequestUrls.java new file mode 100644 index 0000000..f28a83a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/RequestUrls.java @@ -0,0 +1,19 @@ +package com.wms.dss.ats.customs.abb.utils; + +public enum RequestUrls { + CLEAR_RACK("http://localhost:8089/external/log/clearRack"), + TrayCodeDirection("http://localhost:8089/external/log/getTrayCodeDirection"), + getInStorageInformation("http://localhost:8089/external/log/getInStorageInformation"), + taskExceptionUpload("http://localhost:8089/external/log/taskExceptionUpload"), + handleExceptionUrl("http://localhost:8089/external/log/taskExceptionUpload"); + + private final String url; + + RequestUrls(String url) { + this.url = url; + } + + public String getUrl() { + return url; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/SnowflakeIdWorker.java b/src/com/wms/dss/ats/customs/abb/utils/SnowflakeIdWorker.java new file mode 100644 index 0000000..312d8d6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/SnowflakeIdWorker.java @@ -0,0 +1,193 @@ +package com.wms.dss.ats.customs.abb.utils; + + +/** + * Twitter_Snowflake
+ * SnowFlake的结构如下(�部分用-分开):
+ * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000
+ * 1�标识,由于long基本类型在Java中是带符�的,最高�是符��,正数是0,负数是1,所以id一般是正数,最高�是0
+ * 41�时间截(毫秒级),注�,41�时间截�是存储当�时间的时间截,而是存储时间截的差值(当�时间截 - 开始时间截) + * 得到的值),这里的的开始时间截,一般是我们的id生�器开始使用的时间,由我们程��指定的(如下下�程�IdWorker类的startTime属性)。41�的时间截,�以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69
+ * 10�的数�机器�,�以部署在1024个节点,包括5�datacenterId和5�workerId
+ * 12��列,毫秒内的计数,12�的计数顺��支��个节点�毫秒(�一机器,�一时间截)产生4096个ID��
+ * 加起�刚好64�,为一个Long型。
+ * SnowFlake的优点是,整体上按照时间自增排åº�,并且整个分布å¼�系统内ä¸�会产生ID碰撞(由数æ�®ä¸­å¿ƒID和机器ID作区分),并且效率较高,ç»�测试,SnowFlakeæ¯�秒能够产生26万IDå·¦å�³ã€‚ + */ + + +import java.util.Random; + +/** + * @ClassName: SnowflakeIdWorker + * @Description: + * @Author: Kucha + * @Date: 2021/10/10 15:07 + */ +public class SnowflakeIdWorker { + + // ==============================Fields=========================================== + /** 开始时间截 (2015-01-01) */ + private final long twepoch = 1420041600000L; + + /** 机器id所å� çš„ä½�æ•° */ + private final long workerIdBits = 5L; + + /** æ•°æ�®æ ‡è¯†id所å� çš„ä½�æ•° */ + private final long datacenterIdBits = 5L; + + /** 支æŒ�的最大机器id,结果是31 (这个移ä½�算法å�¯ä»¥å¾ˆå¿«çš„计算出几ä½�二进制数所能表示的最大å��进制数) */ + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + + /** 支æŒ�的最大数æ�®æ ‡è¯†id,结果是31 */ + private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + + /** åº�列在id中å� çš„ä½�æ•° */ + private final long sequenceBits = 12L; + + /** 机器IDå�‘左移12ä½� */ + private final long workerIdShift = sequenceBits; + + /** æ•°æ�®æ ‡è¯†idå�‘左移17ä½�(12+5) */ + private final long datacenterIdShift = sequenceBits + workerIdBits; + + /** 时间截å�‘左移22ä½�(5+5+12) */ + private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + + /** 生æˆ�åº�列的掩ç �,这里为4095 (0b111111111111=0xfff=4095) */ + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + + /** 工作机器ID(0~31) */ + private long workerId; + + /** æ•°æ�®ä¸­å¿ƒID(0~31) */ + private long datacenterId; + + /** 毫秒内åº�列(0~4095) */ + private long sequence = 0L; + + /** 上次生æˆ�ID的时间截 */ + private long lastTimestamp = -1L; + + public SnowflakeIdWorker() { + } + + //==============================Constructors===================================== + /** + * 构造函数 + * @param workerId 工作ID (0~31) + * @param datacenterId æ•°æ�®ä¸­å¿ƒID (0~31) + */ + public SnowflakeIdWorker(long workerId, long datacenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); + } + if (datacenterId > maxDatacenterId || datacenterId < 0) { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + } + this.workerId = workerId; + this.datacenterId = datacenterId; + } + + //==============================Constructors===================================== + /** + * åˆ�始化函数 + * @param workerId 工作ID (0~31) + * @param datacenterId æ•°æ�®ä¸­å¿ƒID (0~31) + */ + public void initSnowflake(long workerId, long datacenterId){ + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); + } + if (datacenterId > maxDatacenterId || datacenterId < 0) { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + } + this.workerId = workerId; + this.datacenterId = datacenterId; + } + + + // ==============================Methods========================================== + /** + * 获得下一个ID (该方法是线程安全的) + * @return SnowflakeId + */ + public synchronized long nextId() { + long timestamp = timeGen(); + + //如果当å‰�æ—¶é—´å°�于上一次ID生æˆ�的时间戳,说明系统时钟回退过这个时候应当抛出异常 + if (timestamp < lastTimestamp) { + throw new RuntimeException( + String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); + } + + //如果是å�Œä¸€æ—¶é—´ç”Ÿæˆ�的,则进行毫秒内åº�列 + if (lastTimestamp == timestamp) { + sequence = (sequence + 1) & sequenceMask; + //毫秒内åº�列溢出 + if (sequence == 0) { + //阻塞到下一个毫秒,获得新的时间戳 + timestamp = tilNextMillis(lastTimestamp); + } + } + //时间戳改å�˜ï¼Œæ¯«ç§’内åº�列é‡�ç½® + else { + sequence = 0L; + } + + //上次生æˆ�ID的时间截 + lastTimestamp = timestamp; + + //ç§»ä½�并通过或è¿�算拼到一起组æˆ�64ä½�çš„ID + return ((timestamp - twepoch) << timestampLeftShift) // + | (datacenterId << datacenterIdShift) // + | (workerId << workerIdShift) // + | sequence; + } + + /** + * 阻塞到下一个毫秒,直到获得新的时间戳 + * @param lastTimestamp 上次生æˆ�ID的时间截 + * @return 当å‰�时间戳 + */ + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + /** + * 返回以毫秒为å�•ä½�的当å‰�æ—¶é—´ + * @return 当å‰�æ—¶é—´(毫秒) + */ + protected long timeGen() { + return System.currentTimeMillis(); + } + + /** + * 获å�–2^31-1 + * @return + */ + public int getRandomId(){ + return new Random().nextInt(1000000000)+1000000000; + } + + //==============================Test============================================= + /** 测试 */ + public static void main(String[] args) { +// SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0); +// +// for (int i = 0; i < 100; i++) { +// long id = idWorker.nextId(); +// System.out.println(Long.toBinaryString(id)); +// System.out.println(id); +// } + String substring = "L1002".substring(1,5); + System.err.println(substring); + } + + public static SnowflakeIdWorker getSnowflakeIdWorker(){ + return new SnowflakeIdWorker(0,0); + } +} \ No newline at end of file diff --git a/src/com/wms/dss/ats/customs/abb/utils/Tools.java b/src/com/wms/dss/ats/customs/abb/utils/Tools.java new file mode 100644 index 0000000..2401c1d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/Tools.java @@ -0,0 +1,513 @@ +package com.wms.dss.ats.customs.abb.utils; + +import HslCommunication.BasicFramework.SoftBasic; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.SendData; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.common.server.form.Logger; +import org.libnodave.Nodave; + +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Types; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; + +/** + * ÃèÊö:cyc16УÑéÂë + * + * @author zhu + */ +public class Tools implements Serializable { + public static int Debug = 0x20; + public final static int DEBUG_CONVERSIONS = 0x1000; + public static final int DINT = 4; + + public static final int INT = 2; + + public static void main(String[] arg) { + int jym = getJYM(1, 2, 3); + System.out.println(jym); + } + + /*4¡¢CRC-16УÑéÂë¼ÆËã·½·¨£º + ³£Óòé±í·¨ºÍ¼ÆËã·¨¡£¼ÆËã·½·¨Ò»°ã¶¼ÊÇ£º + £¨1£©¡¢Ô¤ÖÃ1¸ö16λµÄ¼Ä´æÆ÷ΪʮÁù½øÖÆFFFF£¨¼´È«Îª1£©£¬³Æ´Ë¼Ä´æÆ÷ΪCRC¼Ä´æÆ÷£» + £¨2£©¡¢°ÑµÚÒ»¸ö8λ¶þ½øÖÆÊý¾Ý£¨¼ÈͨѶÐÅÏ¢Ö¡µÄµÚÒ»¸ö×Ö½Ú£©Óë16λµÄCRC¼Ä´æÆ÷µÄµÍ + 8λÏàÒì»ò£¬°Ñ½á¹û·ÅÓÚCRC¼Ä´æÆ÷£¬¸ß°ËλÊý¾Ý²»±ä£» + £¨3£©¡¢°ÑCRC¼Ä´æÆ÷µÄÄÚÈÝÓÒÒÆÒ»Î»£¨³¯µÍ룩ÓÃ0Ìî²¹×î¸ß룬²¢¼ì²éÓÒÒÆºóµÄÒÆ³öλ£» + £¨4£©¡¢Èç¹ûÒÆ³öλΪ0£ºÖظ´µÚ3²½£¨ÔÙ´ÎÓÒÒÆÒ»Î»£©£»Èç¹ûÒÆ³öλΪ1£¬CRC¼Ä´æÆ÷Óë¶à + ÏîʽA001£¨1010 0000 0000 0001£©½øÐÐÒì»ò£» + £¨5£©¡¢Öظ´²½Öè3ºÍ4£¬Ö±µ½ÓÒÒÆ8´Î£¬ÕâÑùÕû¸ö8λÊý¾ÝÈ«²¿½øÐÐÁË´¦Àí£» + £¨6£©¡¢Öظ´²½Öè2µ½²½Öè5£¬½øÐÐͨѶÐÅÏ¢Ö¡ÏÂÒ»¸ö×ֽڵĴ¦Àí£» + £¨7£©¡¢½«¸ÃͨѶÐÅÏ¢Ö¡ËùÓÐ×Ö½Ú°´ÉÏÊö²½Öè¼ÆËãÍê³Éºó£¬µÃµ½µÄ16λCRC¼Ä´æÆ÷µÄ¸ß¡¢µÍ + ×Ö½Ú½øÐн»»»£» + £¨8£©¡¢×îºóµÃµ½µÄCRC¼Ä´æÆ÷ÄÚÈݼ´Îª£ºCRCÂë¡£ + ÒÔÉϼÆËã²½ÖèÖеĶàÏîʽA001ÊÇ8005°´Î»µßµ¹ºóµÄ½á¹û¡£ + ²é±í·¨Êǽ«ÒÆÎ»Òì»òµÄ¼ÆËã½á¹û×ö³ÉÁËÒ»¸ö±í£¬¾ÍÊǽ«0~256·ÅÈëÒ»¸ö³¤¶ÈΪ16λµÄ¼Ä´æÆ÷ÖеĵͰË룬¸ß°ËλÌî³ä0£¬È»ºó½«¸Ã¼Ä´æÆ÷Óë¶àÏîʽ0XA001°´ÕÕÉÏÊö3¡¢4²½Ö裬ֱµ½°Ëλȫ²¿ÒƳö£¬×îºó¼Ä´æÆ÷ÖеÄÖµ¾ÍÊDZí¸ñÖеÄÊý¾Ý£¬¸ß°Ëλ¡¢µÍ°Ëλ·Ö±ðµ¥¶ÀÒ»¸ö±í¡£*/ + + + /** + * È«²¿Ð£ÑéÂë¿ÉÓÃÕâ¸ö»ñÈ¡ + * + * @param ints ´«ÈëµÄУÑéÂë + * @return ·µ»ØµÄint + */ + public static int getJYM(int... ints) { + //½«ÕûÐÎÈÎÎñºÅתΪ32룬ÄܺóתΪËĸö×Ö½Ú£¬×îºóתΪÕûÐÎ×é4 + int[] ints1 = new int[ints.length * 4]; + for (int i = 0; i < ints.length; i++) { + int[] son; + son = binaryTints(printBits(ints[i])); + for (int j = 0; j < 4; j++) { + int s = j + i * 4; + ints1[s] = son[j]; + System.out.println(Arrays.toString(ints1)); + } + } + int a = 0; + for (int j : ints1) { + a = a + j; + } + return a; + } + + /** + * @param hex ×Ö·û´® + * @return a ÕûÐÍ + */ + public static int[] binaryTints(String hex) { + int[] a = new int[4]; + String hexString = change32(hex); + a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//½« + a[1] = Integer.parseInt(hexString.substring(8, 16), 2); + a[2] = Integer.parseInt(hexString.substring(16, 24), 2); + a[3] = Integer.parseInt(hexString.substring(24, 32), 2); + return a; + } + + public static int[] binaryTints16(String hex) { + int[] a = new int[2]; + String hexString = change16(hex); + a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//½«¶þ½øÖÆ×Ö·û´®×ªÎªÕûÐÎ + a[1] = Integer.parseInt(hexString.substring(8, 16), 2); + return a; + } + + public static int binaryTints8(String hex) { + int a; + String hexString = change8(hex); + a = Integer.parseInt(hexString.substring(0, 8), 2);//½«¶þ½øÖÆ×Ö·û´®×ªÎªÕûÐÎ + return a; + } + + public static int BytesToInt(int[] ss) { + if (ss != null) { + StringBuilder lString = new StringBuilder(); + for (int s : ss) { + lString.append(change8(printBits(s))); + } + return Integer.parseInt(lString.toString(), 2); + } else { + return 0; + } + } + + /** + * ½«×Ö·ûתΪÕûÐÎ + **/ + public static int showAscii(char x) { + return x; + } + + /** + * ½«ÕûÐÎתΪ×Ö·û + **/ + public static char showChar(int x) { + return (char) x; + } + + /** + * ÍÐÅÌÌõÂë½âÎö + **/ + public static String byteToStringTool(byte[] aaa) { + StringBuilder builder = new StringBuilder(); + for (byte b : aaa) { + String x = Character.toString(showChar(b)); + builder.append(x); + } + return builder.toString(); + } + + /** + * ½«ÕûÐÎתΪ¶þ½øÖÆ×Ö·û´® + */ + public static String printBits(int n) { + return Integer.toBinaryString(n); + } + + /** + * ½«ÕûÐÎתΪ¸¡µãÐÍ + */ + public static Float printFloat(int n) { + return Float.intBitsToFloat(n); + } + + /** + * ²»Âú8λ¼Ó¸ßλ¼Ó0 + **/ + public static String change8(String value) { + if (value != null && !value.equals("")) { + StringBuilder ss = new StringBuilder(value); + for (int i = 0; i < 8 - value.length(); i++) { + ss.insert(0, "0"); + } + return ss.toString(); + } else { + return "00000000"; + } + } + + /** + * ²»Âú32λ¼Ó¸ßλ¼Ó0 4¸ö×Ö½Ú + **/ + public static String change32(String value) { + if (value != null && !value.equals("")) { + StringBuilder ss = new StringBuilder(value); + for (int i = 0; i < 32 - value.length(); i++) { + ss.insert(0, "0"); + } + return ss.toString(); + } else { + return "00000000000000000000000000000000"; + } + } + + /** + * ²»Âú16λ¼Ó¸ßλ¼Ó0 4¸ö×Ö½Ú + **/ + public static String change16(String value) { + if (value != null && !value.equals("")) { + StringBuilder ss = new StringBuilder(value); + for (int i = 0; i < 16 - value.length(); i++) { + ss.insert(0, "0"); + } + return ss.toString(); + } else { + return "0000000000000000"; + } + } + + + ///×Ö½ÚתÕûÐÍ + public static int get(byte a1, byte a2, byte a3, byte a4, byte a5, byte a6, byte a7, byte a8, + byte a9, byte a10, byte a11, byte a12, byte a13, byte a14, byte a15, byte a16, + byte a17, byte a18, byte a19, byte a20, byte a21, byte a22, byte a23, byte a24, byte a25) { + int[] ints = new int[25]; + ints[0] = binaryTints8(printBits(a1)); + ints[1] = binaryTints8(printBits(a2)); + ints[2] = binaryTints8(printBits(a3)); + ints[3] = binaryTints8(printBits(a4)); + ints[4] = binaryTints8(printBits(a5)); + ints[5] = binaryTints8(printBits(a6)); + ints[6] = binaryTints8(printBits(a7)); + ints[7] = binaryTints8(printBits(a8)); + ints[8] = binaryTints8(printBits(a9)); + ints[9] = binaryTints8(printBits(a10)); + ints[10] = binaryTints8(printBits(a11)); + ints[11] = binaryTints8(printBits(a12)); + ints[12] = binaryTints8(printBits(a13)); + ints[13] = binaryTints8(printBits(a14)); + ints[14] = binaryTints8(printBits(a15)); + ints[15] = binaryTints8(printBits(a16)); + ints[16] = binaryTints8(printBits(a17)); + ints[17] = binaryTints8(printBits(a18)); + ints[18] = binaryTints8(printBits(a19)); + ints[19] = binaryTints8(printBits(a20)); + ints[20] = binaryTints8(printBits(a21)); + ints[21] = binaryTints8(printBits(a22)); + ints[22] = binaryTints8(printBits(a23)); + ints[23] = binaryTints8(printBits(a24)); + ints[24] = binaryTints8(printBits(a25)); + for (int anInt : ints) System.out.print(anInt + " "); + System.out.println(); + return BytesToInt(ints); + } + + /** + * ×Ö·û´®°²»ê»»³É FLOAT + * + * @param a String + * @return FLOAT + */ + public static float BEFloat(String a) { + byte[] b = SoftBasic.HexStringToBytes(a); + int pos = 0; + int i = 0; + // System.out.println("pos" + pos); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("C " + i); + } + i |= Nodave.USByte(b, pos); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Co " + i); + } + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Con " + i); + } + i |= Nodave.USByte(b, pos + 1); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Conv " + i); + } + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Conve " + i); + } + i |= Nodave.USByte(b, pos + 2); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Conver " + i); + } + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Convert " + i); + } + i |= Nodave.USByte(b, pos + 3); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Converte " + i); + } + float f = Float.intBitsToFloat(i); + if ((Debug & DEBUG_CONVERSIONS) != 0) { + System.out.println("Converted " + f); + } + return (f); + } + + // + public static byte[] int2byte(int res) {///JavaÖÐ10½øÖÆ×ªbyte[] + byte[] targets = new byte[4]; + + targets[3] = (byte) (res & 0xff);// ×îµÍλ + targets[2] = (byte) ((res >> 8) & 0xff);// ´ÎµÍλ + targets[1] = (byte) ((res >> 16) & 0xff);// ´Î¸ßλ + targets[0] = (byte) (res >>> 24);// ×î¸ßλ,ÎÞ·ûºÅÓÒÒÆ¡£ + return targets; + } + + /** + * ¶à¸öbyte ºÏ²¢³ÉÒ»¸öbyte + */ + public static byte[] byteMerge(byte[]... values) { + int length_byte = 0; + for (byte[] value : values) { + length_byte += value.length; + } + byte[] all_byte = new byte[length_byte]; + int countLength = 0; + for (byte[] b : values) { + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + + /** ???????????**/ + public static String bytetostringtool(byte[] aaa) { + String tptm = ""; + for(int i=0;i> 8 * i) & 0xff); + } + return b; + } + + /** + * Ï·¢µ½PLCµÄ·´À¡×Ö½Ú + */ + public static byte[] sendData(SendData... list) { + byte[][] values = new byte[list.length][0]; + for (int i = 0; i < list.length; i++) { + byte[] bytes = Tools.intToBytes(list[i].getNum2(), list[i].getNum()); + //System.out.println(bytes.length); + values[i] = bytes; + } + int length_byte = 0; + for (byte[] value : values) { + length_byte += value.length; + } + byte[] all_byte = new byte[length_byte]; + int countLength = 0; + for (byte[] b : values) { + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + + //Ï·¢×Ö½ÚÊý×é + public static byte[] sendDataToDevice(long taskNo,String trayCode, int...ints){ + int length = 0; + byte[] xfData = null; + if (trayCode == null){ + length = 4 + (ints.length * 2); + xfData = new byte[length]; + byte[] RWH = new byte[4]; + RWH = Tools.int2byte((int) taskNo); + for (int i = 0; i < length; i++){ + if (i < 4){ + xfData[i] = RWH[i]; + } else { + if (i % 2 == 0){ + byte[] param = new byte[2]; + param = intbyte(ints[(i - 4) / 2]); + xfData[i] = param[0]; + xfData[i + 1] = param[1]; + } + } + } + } else { + length = 12 + (ints.length * 2); + xfData = new byte[length]; + byte[] RWH = new byte[4]; + RWH = Tools.int2byte((int) taskNo); + byte[] tCode = new byte[8]; + if ("".equals(trayCode)){ + for (int i = 0;i < tCode.length;i++){ + tCode[i] = 0; + } + }else { + byte[] code = trayCode.getBytes(); + for (int i = 0; i < tCode.length; i++) { + tCode[i] = code[i]; + } + } + for (int i = 0; i< length; i++){ + if (i < 4){ + xfData[i] = RWH[i]; + } else if (i > 3 && i< 12) { + xfData[i] = tCode[i - 4]; + } else { + if (i % 2 == 0){ + byte[] param = new byte[2]; + param = intbyte(ints[(i - 12) / 2]); + xfData[i] = param[0]; + xfData[i + 1] = param[1]; + } + } + } + } + return xfData; + } + + /** + * ×Ö½ÚÊý×éת×Ö·û´¬ + */ + public static String byteToString(String substring) { + return new String(SoftBasic.HexStringToBytes(substring), StandardCharsets.UTF_8); + } + + /** + * µ÷Óô洢¹ý³Ì·â×° + */ + public static int storedProcedure(EntityDAO m_dao, String name, Integer out, StoredParameters... storedParameters) throws SQLException { + Connection conn = null; + int back = 0; + try { + conn = m_dao.getConnection(); + CallableStatement cs = conn.prepareCall(name); + for (StoredParameters sendDatum : storedParameters) { + cs.setString(sendDatum.getNum(), sendDatum.getParameter()); + } + cs.registerOutParameter(out, java.sql.Types.INTEGER); + cs.execute(); + back = cs.getInt(out); + } catch (Exception e) { + e.printStackTrace(); + Logger.info(name + "-failed execution of stored procedure:" + e.getMessage()); + } finally { + if (conn != null) { + conn.close(); + } + } + Logger.info(name + "-Successful execution of stored procedure"); + return back; + } + + public static ProcedureResult storedProcedureMsg(EntityDAO m_dao, String name, Integer result, Integer resultMsg, StoredParameters... storedParameters){ + Connection conn = null; + int back = 0; + String msg = "³õʼ"; + try { + conn = m_dao.getConnection(); + CallableStatement cs = conn.prepareCall(name); + for (StoredParameters sendDatum : storedParameters) { + cs.setString(sendDatum.getNum(), sendDatum.getParameter()); + } + cs.registerOutParameter(result, Types.INTEGER); + cs.registerOutParameter(resultMsg, Types.VARCHAR); + cs.execute(); + back = cs.getInt(result); + msg = cs.getString(resultMsg); + } catch (Exception e) { + e.printStackTrace(); + Logger.info(name + "-failed execution of stored procedure:" + e.getMessage()); + } finally { + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + } + //Logger.info(name + "-Successful execution of stored procedure,return ¡¾"+back+"¡¿"); + + + return ProcedureResult.result(back,msg); + } + + public static String getDate() { + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return df.format(t); + } + + //int ת2×Ö½Ú + public static byte[] intbyte(int res) {///JavaÖÐ10½øÖÆ×ªbyte[] + byte[] targets = new byte[2]; + targets[1] = (byte) ((res >> 0) & 0xff);// ´Î¸ßλ + targets[0] = (byte) (res >>> 8);// ×î¸ßλ,ÎÞ·ûºÅÓÒÒÆ¡£ + return targets; + } + + public static int[] binarysToints(String hex){ + int[] a = new int[4]; + String hexString = change32(hex); + a[0] = Integer.parseInt(hexString.substring(0,8),2);//½«¶þ½øÖÆ×Ö·û´®×ªÎªÕûÐÎ + a[1] = Integer.parseInt(hexString.substring(8,16),2); + a[2] = Integer.parseInt(hexString.substring(16,24),2); + a[3] = Integer.parseInt(hexString.substring(24,32),2); + return a; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/utils/UtilId.java b/src/com/wms/dss/ats/customs/abb/utils/UtilId.java new file mode 100644 index 0000000..2136730 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/UtilId.java @@ -0,0 +1,13 @@ +package com.wms.dss.ats.customs.abb.utils; + +import java.util.UUID; + +public class UtilId { + + public static String uuids(){ + UUID uuid = UUID.randomUUID();//ç›� + String a=uuid.toString().replace("-", "").toUpperCase(); + return a; + } + +} diff --git a/src/log4j.properties b/src/log4j.properties new file mode 100644 index 0000000..ecb2bae --- /dev/null +++ b/src/log4j.properties @@ -0,0 +1,41 @@ +# Configure logging for testing +# 日志输出级别为INFO,debug1 */ + /* This code seems to be specific to 200 family. */ + + public final static int RESULT_ITEM_NOT_AVAILABLE = 10; + /* means a a piece of data is not available in the CPU, e.g. */ + /* when trying to read a non existing DB */ + + public final static int RESULT_ADDRESS_OUT_OF_RANGE = 5; + /* means the data address is beyond the CPUs address range */ + public final static int RESULT_WRITE_DATA_SIZE_MISMATCH = 7; + /* means the write data size doesn't fit item size */ + public final static int RESULT_CANNOT_EVALUATE_PDU = -123; + public final static int RESULT_CPU_RETURNED_NO_DATA = -124; + + public final static int RESULT_UNKNOWN_ERROR = -125; + public final static int RESULT_EMPTY_RESULT_ERROR = -126; + public final static int RESULT_EMPTY_RESULT_SET_ERROR = -127; + public final static int RESULT_UNEXPECTED_FUNC = -128; + public final static int RESULT_UNKNOWN_DATA_UNIT_SIZE = -129; + + public final static int RESULT_SHORT_PACKET = -1024; + public final static int RESULT_TIMEOUT = -1025; + + public static byte[] toPLCfloat(float f) { + int i = Float.floatToIntBits(f); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("i: " + i); + return bswap_32(i); + } + + public static byte[] toPLCfloat(double d) { + float f = (float) d; + return toPLCfloat(f); + } + + public static byte[] bswap_32(int a) { + byte[] b = new byte[4]; + b[3] = (byte) (a & 0xff); + a = a >> 8; + b[2] = (byte) (a & 0xff); + a = a >> 8; + b[1] = (byte) (a & 0xff); + a = a >> 8; + b[0] = (byte) (a & 0xff); + if ((Debug & DEBUG_CONVERSIONS) != 0) + dump("In: " + a + " out:", b, 0, 4); + return b; + } + + public static byte[] bswap_32(long a) { + byte[] b = new byte[4]; + b[3] = (byte) (a & 0xff); + a = a >> 8; + b[2] = (byte) (a & 0xff); + a = a >> 8; + b[1] = (byte) (a & 0xff); + a = a >> 8; + b[0] = (byte) (a & 0xff); + if ((Debug & DEBUG_CONVERSIONS) != 0) + dump("In: " + a + " out:", b, 0, 4); + return b; + } + + public static byte[] bswap_64(int a) { + byte[] b = new byte[8]; + b[7] = (byte) (a & 0xff); + a = a >> 8; + b[6] = (byte) (a & 0xff); + a = a >> 8; + b[5] = (byte) (a & 0xff); + a = a >> 8; + b[4] = (byte) (a & 0xff); + a = a >> 8; + b[3] = (byte) (a & 0xff); + a = a >> 8; + b[2] = (byte) (a & 0xff); + a = a >> 8; + b[1] = (byte) (a & 0xff); + a = a >> 8; + b[0] = (byte) (a & 0xff); + + if ((Debug & DEBUG_CONVERSIONS) != 0) + dump("In: " + a + " out:", b, 0, 8); + return b; + } + + public static byte[] bswap_64(long a) { + byte[] b = new byte[8]; + // b[7] = (byte) (a & 0xff); + // a = a >> 8; + // b[6] = (byte) (a & 0xff); + // a = a >> 8; + // b[5] = (byte) (a & 0xff); + // a = a >> 8; + // b[4] = (byte) (a & 0xff); + // a = a >> 8; + // b[3] = (byte) (a & 0xff); + // a = a >> 8; + // b[2] = (byte) (a & 0xff); + // a = a >> 8; + // b[1] = (byte) (a & 0xff); + // a = a >> 8; + // b[0] = (byte) (a & 0xff); + + b[0] = (byte) (a & 0xff); + a = a >> 8; + b[1] = (byte) (a & 0xff); + a = a >> 8; + b[2] = (byte) (a & 0xff); + a = a >> 8; + b[3] = (byte) (a & 0xff); + a = a >> 8; + b[4] = (byte) (a & 0xff); + a = a >> 8; + b[5] = (byte) (a & 0xff); + a = a >> 8; + b[6] = (byte) (a & 0xff); + a = a >> 8; + b[7] = (byte) (a & 0xff); + + if ((Debug & DEBUG_CONVERSIONS) != 0) + dump("In: " + a + " out:", b, 0, 8); + return b; + } + + public static byte[] bswap_16(int a) { + byte[] b = new byte[2]; + b[1] = (byte) (a & 0xff); + a = a >> 8; + b[0] = (byte) (a & 0xff); + if ((Debug & DEBUG_CONVERSIONS) != 0) + dump("In: " + a + " out:", b, 0, 2); + return b; + } + + /** + * This doesn't swap anything, but the name fits into the series + * + * @param a + * @return + */ + public static byte[] bswap_8(int a) { + byte[] b = new byte[1]; + b[0] = (byte) (a & 0xff); + return b; + } + + /** + * Dumps len hex codes from byte array mem beginning at index start. + * + * @param text: + * a text to print before the list + * @return + */ + public static void dump(String text, byte[] mem, int start, int len) { + System.out.print(text + " "); + for (int i = start; i < start + len; i++) { + int j = mem[i]; + if (j < 0) + j += 256; + String s = Integer.toHexString(j); + if (s.length() < 2) + s = "0" + s; + System.out.print(s + ","); + } + System.out.println(" "); + } + + public static long USBELong(byte[] b, int pos) { + int i = b[pos]; + int j = b[pos + 1]; + int k = b[pos + 2]; + int l = b[pos + 3]; + // System.out.println( + // pos + " 0:" + i + " 1:" + j + " 2:" + k + " 3:" + l); + if (i < 0) + i += 256; + if (j < 0) + j += 256; + if (k < 0) + k += 256; + if (l < 0) + l += 256; + return (256 * k + l) + 65536L * (256 * i + j); + } + + public static long SBELong(byte[] b, int pos) { + int i = b[pos]; + int j = b[pos + 1]; + int k = b[pos + 2]; + int l = b[pos + 3]; + // if (i < 0) + // i += 256; + if (j < 0) + j += 256; + if (k < 0) + k += 256; + if (l < 0) + l += 256; + return (256 * k + l) + 65536L * (256 * i + j); + } + + /////////////////////////////////////////////// + public static StringBuffer SBEString(byte[] b, int pos) { + StringBuffer sbu = new StringBuffer(); + sbu.append((char) b[pos]); + sbu.append((char) b[pos + 1]); + sbu.append((char) b[pos + 2]); + sbu.append((char) b[pos + 3]); + sbu.append((char) b[pos + 4]); + sbu.append((char) b[pos + 5]); + sbu.append((char) b[pos + 6]); + sbu.append((char) b[pos + 7]); + + return sbu; + } + + /** + * ½«b[pos]¼°b[pos + 1] »»Ëã³É10½øÖÆÖµ + * + * @param b + * @param pos + * @return + */ + public static int USBEWord(byte[] b, int pos) { + int i = b[pos]; + int k = b[pos + 1]; + if (i < 0) + i += 256; + if (k < 0) + k += 256; + return (256 * i + k); + } + + /** + * ½«valֵת»»³É×Ö½Úb[pos]¼°b[pos + 1] + * + * @param b + * @param pos + * @param val + */ + public static void setUSBEWord(byte[] b, int pos, int val) { + b[pos] = ((byte) (val / 0x100)); + b[pos + 1] = ((byte) (val % 0x100)); + } + + /** + * ½«valֵת»»³ÉÒ»¸ö×Ö½Ú + * + * @param b + * @param pos + * @param val + */ + public static void setUSByte(byte[] b, int pos, int val) { + b[pos] = ((byte) (val & 0xff)); + } + + /** + * ½«³¤ÕûÐÎaת»»³É4¸ö×Ö½Ú + * + * @param b + * @param pos + * @param a + */ + public static void setUSBELong(byte[] b, int pos, long a) { + b[pos + 3] = (byte) (a & 0xff); + a = a >> 8; + b[pos + 2] = (byte) (a & 0xff); + a = a >> 8; + b[pos + 1] = (byte) (a & 0xff); + a = a >> 8; + b[pos] = (byte) (a & 0xff); + } + + /** + * + * @param b + * @param pos + * @param f + */ + public static void setBEFloat(byte[] b, int pos, float f) { + /* + * ÁíÍâÐèÒªÖªµÀµÄÊÇ£¬floatÀàÐÍÕ¼ÓÃ4¸ö×Ö½Ú£¬´Ó×îµÍ루×îÓұߣ©µ½×î¸ß루×î×ó±ß£©µÄ±àºÅÊÇ´Ó0-31¡£ÕâÑùµÄ»°£¬ÉÏÃæµÄ½âÊ;ÍÈÝÒ׿´¶®ÁË¡£ + * Ò²¾ÍÊÇ˵£¬×ª»»³ÉµÄ32¸ö0¡¢1×Ö·û´®ÖУ¬31ºÅ±íʾ·ûºÅ£¬30-23±íʾָÊý£¬22-0±íʾβÊý¡£ °´ÕÕIEEE + * 754±ê×¼£¬32λ¸¡µãÊýÔÚ¼ÆËã»úÖжþ½øÖÆ´æ´¢ÐÎʽ¹²Èý²¿·Ö£ºS(1룬·ûºÅ) E(8룬½×Âë) M(23λ£¬Î²Êý) + * ¸øÄã¾Ù¸öÀý×Ó°É£¬Float.floatToIntBits(20.5f)°´ÕÕÈçÏ·½Ê½¼ÆË㣺 + * 20.59D=10100.1B=1.01001*2^4B Ö¸Êýe=4 S=0-->ÕýÊý + * E=4+127=131D=10000011B-->ÕæÊµÖ¸Êýe±ä³É½×ÂëEʱÐè¼Ó127 M=01001B Ôò32λ2½øÖÆ´æ´¢ÐÎʽΪ£º0 + * 10000011 01001000000000000000000 ת»»³É10½øÖƼ´1101266944 + */ + int a = Float.floatToIntBits(f); + b[pos + 3] = (byte) (a & 0xff); + a = a >> 8; + b[pos + 2] = (byte) (a & 0xff); + a = a >> 8; + b[pos + 1] = (byte) (a & 0xff); + a = a >> 8; + b[pos] = (byte) (a & 0xff); + } + + public static int SBEWord(byte[] b, int pos) { + int i = b[pos]; + int k = b[pos + 1]; + // if (i < 0) + // i += 256; + if (k < 0) + k += 256; + return (256 * i + k); + } + + public static int USByte(byte[] b, int pos) { + int i = b[pos]; + if (i < 0) + i += 256; + return (i); + } + + public static int SByte(byte[] b, int pos) { + int i = b[pos]; + return (i); + } + + public static float BEFloat(byte[] b, int pos) { + int i = 0; + // System.out.println("pos" + pos); + + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("C " + i); + i |= Nodave.USByte(b, pos); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Co " + i); + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Con " + i); + i |= Nodave.USByte(b, pos + 1); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Conv " + i); + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Conve " + i); + i |= Nodave.USByte(b, pos + 2); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Conver " + i); + i <<= 8; + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Convert " + i); + i |= Nodave.USByte(b, pos + 3); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Converte " + i); + float f = Float.intBitsToFloat(i); + if ((Debug & DEBUG_CONVERSIONS) != 0) + System.out.println("Converted " + f); + return (f); + } + + public static String areaName(int area) { + switch (area) { + case DB: + return "DB"; + case INPUTS: + return "E"; + case OUTPUTS: + return "A"; + case FLAGS: + return "M"; + default: + return "unknown area!"; + } + } + + public static String strerror(int code) { + switch (code) { + case RESULT_OK: + return "ok"; + case RESULT_MULTIPLE_BITS_NOT_SUPPORTED: + return "the CPU does not support reading a bit block of length<>1"; + case RESULT_ITEM_NOT_AVAILABLE: + return "the desired item is not available in the PLC"; + case RESULT_ITEM_NOT_AVAILABLE200: + return "the desired item is not available in the PLC (200 family)"; + case RESULT_ADDRESS_OUT_OF_RANGE: + return "the desired address is beyond limit for this PLC"; + case RESULT_CPU_RETURNED_NO_DATA: + return "the PLC returned a packet with no result data"; + case Nodave.RESULT_UNKNOWN_ERROR: + return "the PLC returned an error code not understood by this library"; + case Nodave.RESULT_EMPTY_RESULT_ERROR: + return "this result contains no data"; + case Nodave.RESULT_EMPTY_RESULT_SET_ERROR: + return "cannot work with an undefined result set"; + case Nodave.RESULT_CANNOT_EVALUATE_PDU: + return "cannot evaluate the received PDU"; + case Nodave.RESULT_WRITE_DATA_SIZE_MISMATCH: + return "Write data size error"; + case Nodave.RESULT_NO_PERIPHERAL_AT_ADDRESS: + return "No data from I/O module"; + case Nodave.RESULT_UNEXPECTED_FUNC: + return "Unexpected function code in answer"; + case Nodave.RESULT_UNKNOWN_DATA_UNIT_SIZE: + return "PLC responds wit an unknown data type"; + case Nodave.RESULT_SHORT_PACKET: + return "Short packet from PLC"; + case Nodave.RESULT_TIMEOUT: + return "Timeout when waiting for PLC response"; + case 0x8000: + return "function already occupied."; + case 0x8001: + return "not allowed in current operating status."; + case 0x8101: + return "hardware fault."; + case 0x8103: + return "object access not allowed."; + case 0x8104: + return "context is not supported."; + case 0x8105: + return "invalid address."; + case 0x8106: + return "data type not supported."; + case 0x8107: + return "data type not consistent."; + case 0x810A: + return "object does not exist."; + case 0x8500: + return "incorrect PDU size."; + case 0x8702: + return "address invalid."; + case 0xd201: + return "block name syntax error."; + case 0xd202: + return "syntax error function parameter."; + case 0xd203: + return "syntax error block type."; + case 0xd204: + return "no linked block in storage medium."; + case 0xd205: + return "object already exists."; + case 0xd206: + return "object already exists."; + case 0xd207: + return "block exists in EPROM."; + case 0xd209: + return "block does not exist."; + case 0xd20e: + return "no block does not exist."; + case 0xd210: + return "block number too big."; + case 0xd240: + return "unfinished block transfer in progress?"; + case 0xd241: + return "protected by password."; + default: + return "no message defined for code: " + code + "!"; + } + } + + ///×Ö·û´® ת»» + public static StringBuffer SBEString30(byte[] b, int pos) { + StringBuffer sbu = new StringBuffer(); + sbu.append((char) b[pos]); + sbu.append((char) b[pos + 1]); + sbu.append((char) b[pos + 2]); + sbu.append((char) b[pos + 3]); + sbu.append((char) b[pos + 4]); + sbu.append((char) b[pos + 5]); + sbu.append((char) b[pos + 6]); + sbu.append((char) b[pos + 7]); + sbu.append((char) b[pos + 8]); + sbu.append((char) b[pos + 9]); + sbu.append((char) b[pos + 10]); + sbu.append((char) b[pos + 11]); + sbu.append((char) b[pos + 12]); + sbu.append((char) b[pos + 13]); + sbu.append((char) b[pos + 14]); + sbu.append((char) b[pos + 15]); + sbu.append((char) b[pos + 16]); + sbu.append((char) b[pos + 17]); + sbu.append((char) b[pos + 18]); + sbu.append((char) b[pos + 19]); + sbu.append((char) b[pos + 20]); + + + + return sbu; + } + +} \ No newline at end of file diff --git a/src/org/libnodave/PDU.java b/src/org/libnodave/PDU.java new file mode 100644 index 0000000..0a689e3 --- /dev/null +++ b/src/org/libnodave/PDU.java @@ -0,0 +1,520 @@ +/* + Part of Libnodave, a free communication libray for Siemens S7 300/400 via + the MPI adapter 6ES7 972-0CA22-0XAC + or MPI adapter 6ES7 972-0CA33-0XAC + or MPI adapter 6ES7 972-0CA11-0XAC. + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002. + + Libnodave is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Libnodave is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave; +public class PDU { + /* + typedef struct { + uc P; // allways 0x32 + uc type; // a type? type 2 and 3 headers are two bytes longer. + uc a,b; // currently unknown + us number; // Number, can be used to identify answers corresponding to requests + us plen; // length of parameters which follow this header + us dlen; // length of data which follows the parameters + uc x[2]; // only present in type 2 and 3 headers. This may contain error information. + } PDUHeader; + */ + /** + * return the number of the PDU + */ + public int getNumber() { + return Nodave.USBEWord(mem, header + 4); + } + /** + * set the number of the PDU + */ + public void setNumber(int n) { + Nodave.setUSBEWord(mem, header + 4, n); + } + /** + * return the function code of the PDU + */ + public int getFunc() { + return Nodave.USByte(mem, param + 0); + } + /** + * known function codes + */ + public final static byte FUNC_READ = 4; + public final static byte FUNC_WRITE = 5; + + int header; // the position of the header; + public int param; // ²ÎÊýλÖÃ; + byte[] mem;//±¨ÎÄÊý×é + int hlen;//Õû¸ö±¨Îij¤¶È ¼õÈ¥ £¨±¨ÎÄÍ·+²ÎÊý³¤¶È£© µÄ½á¹ûÖµ + public int plen;//²ÎÊý³¤¶È + int dlen;//ÓÃÀ´¶¨ÒåÆäËû³¤¶ÈÖµ + public int udlen;//DB¿éÊý¾Ý³¤¶È + public int data;//±¨ÎÄʵ¼Ê³¤¶È + public int udata;//¶ÁDB¿éÊý¾ÝλÖà + /** + * set up the PDU information + */ + public PDU(byte[] mem, int pos) { + this.mem = mem; + this.header = pos; + } + + public int addVarToReadRequest(int area, int DBnum, int start, int len) { + byte[] pa = { 0x12, 0x0a, 0x10, 0x02, 0x00, 0x1A, + // insert length in bytes here + 0x00, 0x0B, // insert DB number here + (byte) 0x84, // change this to real area code + 0x00, 0x00, (byte) 0xC0 // insert start address in bits + }; + + if ((area == Nodave.ANALOGINPUTS200) + || (area == Nodave.ANALOGOUTPUTS200)) { + pa[3] = 4; + start *= 8; /* bits */ + } else if ( + (area == Nodave.TIMER) + || (area == Nodave.COUNTER) + || (area == Nodave.TIMER200) + || (area == Nodave.COUNTER200)) { + pa[3] = (byte) area; + } else { + start *= 8; /* bits */ + } + + Nodave.setUSBEWord(pa, 4, len); + Nodave.setUSBEWord(pa, 6, DBnum); + Nodave.setUSBELong(pa, 8, start); + Nodave.setUSByte(pa, 8, area); + + mem[param + 1]++; + System.arraycopy(pa, 0, mem, param + plen, pa.length); + plen += pa.length; + Nodave.setUSBEWord(mem, header + 6, plen); + /** + * TODO calc length of result. Do not add variable if it would exceed max. result length. + */ + return 0; + } + + public int addBitVarToReadRequest( + int area, + int DBnum, + int start, + int len) { + byte pa[] = { 0x12, 0x0a, 0x10, 0x01, /* single bits */ + 0x00, 0x1A, /* insert length in bytes here */ + 0x00, 0x0B, /* insert DB number here */ + (byte) 0x84, /* change this to real area code */ + 0x00, 0x00, (byte) 0xC0 /* insert start address in bits */ + }; + Nodave.setUSBEWord(pa, 4, len); + Nodave.setUSBEWord(pa, 6, DBnum); + Nodave.setUSBELong(pa, 8, start); + Nodave.setUSByte(pa, 8, area); + + mem[param + 1]++; + System.arraycopy(pa, 0, mem, param + plen, pa.length); + plen += pa.length; + Nodave.setUSBEWord(mem, header + 6, plen); + return 0; + + } + + /** + * prepare a read request with no item. + */ + public void prepareReadRequest() { + byte pa[] = new byte[2]; + pa[0] = PDU.FUNC_READ; + pa[1] = (byte) 0x00; + initHeader(1); + addParam(pa); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } + + /** + * prepare a write request with no item. + */ + public void prepareWriteRequest() { + byte pa[] = new byte[2]; + pa[0] = PDU.FUNC_WRITE; + pa[1] = (byte) 0x00; + initHeader(1); + addParam(pa); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } + + /** + * construct a write request for a single item in PLC memory. + */ +/* + void constructWriteRequest( + int area, + int DBnum, + int start, + int len, + byte[] buffer) { + byte pa[] = new byte[14]; + byte da[] = { 0, 4, 0, 0 }; + pa[0] = PDU.FUNC_WRITE; + pa[1] = (byte) 0x01; + pa[2] = (byte) 0x12; + pa[3] = (byte) 0x0a; + pa[4] = (byte) 0x10; + pa[5] = (byte) 0x02; + + Nodave.setUSBEWord(pa, 6, len); + Nodave.setUSBEWord(pa, 8, DBnum); + Nodave.setUSBELong(pa, 10, 8 * start); // the bit address + Nodave.setUSByte(pa, 10, area); + initHeader(1); + addParam(pa); + addData(da); + addValue(buffer); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } +*/ + /** + * display information about a PDU + */ + public void dump() { + Nodave.dump("PDU header ", mem, header, hlen); + System.out.println("plen: " + plen + " dlen: " + dlen); + Nodave.dump("Parameter", mem, param, plen); + if (dlen > 0) + Nodave.dump("Data ", mem, data, dlen); + if (udlen > 0) + Nodave.dump("result Data ", mem, udata, udlen); + } + /** + * reserve space for the header of a new PDU + */ + public void initHeader(int type) { + if (type == 2 || type == 3) + hlen = 12; + else + hlen = 10; + for (int i = 0; i < hlen; i++) { + mem[header + i] = 0; + } + param = header + hlen; + mem[header] = (byte) 0x32; + mem[header + 1] = (byte) type; + dlen = 0; + plen = 0; + udlen = 0; + data = 0; + udata = 0; + } + + public void addParam(byte[] pa) { + plen = pa.length; + System.arraycopy(pa, 0, mem, param, plen); + Nodave.setUSBEWord(mem, header + 6, plen);//¶¨Òå×Ö·ûÊý×émemÖеĵÚheader+6¼°header+7 Õâ¸öÓÃÀ´´æ·ÅplenµÄ³¤¶ÈÖµ + // mem[header + 6] = (byte) (pa.length / 256); + // mem[header + 7] = (byte) (pa.length % 256); + data = param + plen; + dlen = 0; + } + /** + Add data after parameters, set dlen as needed. + Needs valid header and parameters + */ + void addData(byte[] newData) { + int appPos = data + dlen; //append to this position + dlen += newData.length; + System.arraycopy(newData, 0, mem, appPos, newData.length); + Nodave.setUSBEWord(mem, header + 8, dlen); + } + /** + Add len bytes of len after parameters from a maybe longer block of bytes. + Set dlen as needed. + Needs valid header and parameters + */ + public void addData(byte[] newData, int len) { + int appPos = data + dlen; //append to this position + dlen += len; + System.arraycopy(newData, 0, mem, appPos, len); + Nodave.setUSBEWord(mem, header + 8, dlen); + } + /** + Add values after value header in data, adjust dlen and data count. + Needs valid header,parameters,data,dlen + */ + void addValue(byte[] values) { + int valCount = 0x100 * mem[data + 2] + mem[data + 3]; + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + System.out.println("valCount: " + valCount); + if (mem[data + 1] == 4) { // bit data, length is in bits + valCount += 8 * values.length; + } else if (mem[data + 1] == 9) { // byte data, length is in bytes + valCount += values.length; + } else { + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + System.out.println( + "unknown data type/length: " + mem[data + 1]); + } + if (udata == 0) + udata = data + 4; + udlen += values.length; + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + System.out.println("valCount: " + valCount); + Nodave.setUSBEWord(mem, data + 2, valCount); + addData(values); + } + + int error; + + public int getError() { + return error; + } + /** + Setup a PDU instance to reflect the structure of data present in + the memory area given to initHeader. + Needs valid header. + */ + + public int setupReceivedPDU() { + int res = Nodave.RESULT_CANNOT_EVALUATE_PDU; // just assume the worst + if (mem[header + 1] == 2 || mem[header + 1] == 3) { + hlen = 12; + res = Nodave.USBEWord(mem, header + 10); + } else { + error = 0; + hlen = 10; + res = 0; + } + param = header + hlen; + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + Nodave.dump("PDU header", mem, header, hlen); + plen = Nodave.USBEWord(mem, header + 6); + data = param + plen; + dlen = Nodave.USBEWord(mem, header + 8); + udlen = 0; + udata = 0; + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + dump(); + return res; + } + + /* + + */ + int testResultData() { + int res = Nodave.RESULT_CANNOT_EVALUATE_PDU; // just assume the worst + if ((mem[data] == (byte)255) && (dlen > 4)) { + res = Nodave.RESULT_OK; + udata = data + 4; + // udlen=data[2]*0x100+data[3]; + udlen = Nodave.USBEWord(mem, data + 2); + if (mem[data + 1] == 4) { + udlen >>= 3; /* len is in bits, adjust */ + } else if (mem[data + 1] == 9) { + /* len is already in bytes, ok */ + } else if (mem[data + 1] == 3) { + /* len is in bits, but there is a byte per result bit, ok */ + } else { + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + System.out.println( + "fixme: what to do with data type " + mem[data + 1]); + res = Nodave.RESULT_UNKNOWN_DATA_UNIT_SIZE; + } + } else { + res = mem[data]; + } + return res; + } + + int testReadResult() { + if (mem[param] != FUNC_READ) + return Nodave.RESULT_UNEXPECTED_FUNC; + return testResultData(); + } + + public int testPGReadResult() { + if (mem[param] != 0) + return Nodave.RESULT_UNEXPECTED_FUNC; + return testResultData(); + } + + int testWriteResult() { + int res = Nodave.RESULT_CANNOT_EVALUATE_PDU; + if (mem[param] != FUNC_WRITE) + return Nodave.RESULT_UNEXPECTED_FUNC; + if ((mem[data] == 255)) { + res = Nodave.RESULT_OK; + } else + res = mem[data]; + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + return res; + } + + /* + add data in user data. Add a user data header, if not yet present. + */ + public void addUserData(byte[] da) { + byte udh[] = {(byte) 0xff, 9, 0, 0 }; + if (dlen == 0) { + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) + System.out.println("adding user data header."); + addData(udh); + } + addValue(da); + }; + + public void initReadRequest() { + byte pa[] = new byte[2]; + pa[0] = PDU.FUNC_READ; + pa[1] = (byte) 0x00; + initHeader(1); + addParam(pa); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } + + public void addVarToWriteRequest( + int area, + int DBnum, + int start, + int byteCount, + byte[] buffer) { + byte da[] = { 0, 4, 0, 0, }; + byte pa[] = { 0x12, 0x0a, 0x10, 0x02, + /* unit (for count?, for consistency?) byte */ + 0, 0, /* length in bytes */ + 0, 0, /* DB number */ + 0, /* area code */ + 0, 0, 0 /* start address in bits */ + }; + if ((area == Nodave.TIMER) + || (area == Nodave.COUNTER) + || (area == Nodave.TIMER200) + || (area == Nodave.COUNTER200)) { + pa[3] = (byte) area; + pa[4] = (byte) (((byteCount + 1) / 2) / 0x100); + pa[5] = (byte) (((byteCount + 1) / 2) & 0xff); + } else if ( + (area == Nodave.ANALOGINPUTS200) + || (area == Nodave.ANALOGOUTPUTS200)) { + pa[3] = 4; + pa[4] = (byte) (((byteCount + 1) / 2) / 0x100); + pa[5] = (byte) (((byteCount + 1) / 2) & 0xff); + } else { + pa[4] = (byte) (byteCount / 0x100); + pa[5] = (byte) (byteCount & 0xff); + } + pa[6] = (byte) (DBnum / 256); + pa[7] = (byte) (DBnum & 0xff); + pa[8] = (byte) (area); + start *= 8; /* number of bits */ + pa[11] = (byte) (start & 0xff); + pa[10] = (byte) ((start / 0x100) & 0xff); + pa[9] = (byte) (start / 0x10000); + if ((dlen % 2) != 0) { + addData(da, 1); + } + mem[param + 1]++; + if (dlen > 0) { + byte[] saveData = new byte[dlen]; + System.arraycopy(mem, data, saveData, 0, dlen); + System.arraycopy(saveData, 0, mem, data + pa.length, dlen); + } + System.arraycopy(pa, 0, mem, param + plen, pa.length); + plen += pa.length; + Nodave.setUSBEWord(mem, header + 6, plen); + data = param + plen; + addData(da); + addValue(buffer); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } + + public void addBitVarToWriteRequest( + int area, + int DBnum, + int start, + int byteCount, + byte[] buffer) { + byte da[] = { 0, 3, 0, 0, }; + byte pa[] = { 0x12, 0x0a, 0x10, 0x01, /* single bit */ + 0, 0, /* insert length in bytes here */ + 0, 0, /* insert DB number here */ + 0, /* change this to real area code */ + 0, 0, 0 /* insert start address in bits */ + }; + if ((area == Nodave.TIMER) + || (area == Nodave.COUNTER) + || (area == Nodave.TIMER200) + || (area == Nodave.COUNTER200)) { + pa[3] = (byte) area; + pa[4] = (byte) (((byteCount + 1) / 2) / 0x100); + pa[5] = (byte) (((byteCount + 1) / 2) & 0xff); + } else if ( + (area == Nodave.ANALOGINPUTS200) + || (area == Nodave.ANALOGOUTPUTS200)) { + pa[3] = 4; + pa[4] = (byte) (((byteCount + 1) / 2) / 0x100); + pa[5] = (byte) (((byteCount + 1) / 2) & 0xff); + } else { + pa[4] = (byte) (byteCount / 0x100); + pa[5] = (byte) (byteCount & 0xff); + } + pa[6] = (byte) (DBnum / 256); + pa[7] = (byte) (DBnum & 0xff); + pa[8] = (byte) area; + pa[11] = (byte) (start & 0xff); + pa[10] = (byte) ((start / 0x100) & 0xff); + pa[9] = (byte) (start / 0x10000); + + if ((dlen % 2) != 0) { + addData(da, 1); + } + + mem[param + 1]++; + if (dlen > 0) { + byte[] saveData = new byte[dlen]; + System.arraycopy(mem, data, saveData, 0, dlen); + System.arraycopy(saveData, 0, mem, data + pa.length, dlen); + } + System.arraycopy(pa, 0, mem, param + plen, pa.length); + plen += pa.length; + Nodave.setUSBEWord(mem, header + 6, plen); + data = param + plen; + + addData(da); + addValue(buffer); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + dump(); + } + } + +} diff --git a/src/org/libnodave/PLCinterface.java b/src/org/libnodave/PLCinterface.java new file mode 100644 index 0000000..3f5446c --- /dev/null +++ b/src/org/libnodave/PLCinterface.java @@ -0,0 +1,108 @@ +package org.libnodave; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class PLCinterface { + int localMPI; // the adapter's MPI address + String name; + int timeout; // Timeout in milliseconds used in transort. + int protocol; // The kind of transport used on this interface. + OutputStream out; + InputStream in; + public boolean isConnect=false; + int wp, rp; + + public PLCinterface( + OutputStream out, + InputStream in, + String name, + int localMPI, + int protocol) { + init(out, in, name, localMPI, protocol); + } + + public PLCinterface() { + } + + public void init( + OutputStream oStream, + InputStream iStream, + String name, + int localMPI, + int protocol) { + this.out = oStream; + this.in = iStream; + this.name = name; + this.localMPI = localMPI; + this.protocol = protocol; + timeout=50000;//timeout/100ºÁÃë + switch (protocol) { + case Nodave.PROTOCOL_ISOTCP:timeout=50000; break; + case Nodave.PROTOCOL_ISOTCP243:timeout=50000; break; + } + } + + public void write(byte[] b, int start, int len) { + if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) + Nodave.dump("Interface.write", b, start, len); + try { + out.write(b, start, len); + } catch (IOException e) { + isConnect = false; + System.err.println("Interface.write: " + e); + } + } + public int read(byte[] b, int start, int len) { + int res; + int ilen = len; + if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) + System.out.println("Interface.read"); + try { + int retry = 0; + while ((in.available() <= 0) && (retry < 50)) { + try { + if(retry>0)Thread.sleep(timeout / 2000); + retry++; + if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) + System.out.println("Interface.read delayed"); + } catch (InterruptedException e) { + System.out.println(e); + } + } + res=0; + if(len<0){//YAO 2017-09-23 + len = 256+len; + } + while ((in.available() > 0) && (len > 0)) { + res = in.read(b, start, len); + start+=res; + len-=res; + } + if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) + System.out.println("got "+res+"bytes"); + if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) { + Nodave.dump("Interface.read", b, start, ilen); + } + return res; + } catch (IOException e) { + isConnect = false; + System.out.println(e); + return 0; + } + } + public int initAdapter() { + return 0; + } + public int disconnectAdapter() { + return 0; + } + public void finalize() throws Throwable{ + //System.out.println("this is finalize"); + disconnectAdapter(); + } + public static void main(String arg[]){ + Nodave.Debug = 0x00;//²»µ÷ʽ + System.out.println((Nodave.Debug & Nodave.DEBUG_IFACE) != 0); + } +} diff --git a/src/org/libnodave/Result.java b/src/org/libnodave/Result.java new file mode 100644 index 0000000..0bafc0f --- /dev/null +++ b/src/org/libnodave/Result.java @@ -0,0 +1,35 @@ +/* + Part of Libnodave, a free communication libray for Siemens S7 300/400 via + the MPI adapter 6ES7 972-0CA22-0XAC + or MPI adapter 6ES7 972-0CA33-0XAC + or MPI adapter 6ES7 972-0CA11-0XAC. + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002. + + Libnodave is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Libnodave is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave; + +/** + * @author Thomas Hergenhahn + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class Result { +public int error; +public int length; +public int bufferStart; +} diff --git a/src/org/libnodave/ResultSet.java b/src/org/libnodave/ResultSet.java new file mode 100644 index 0000000..8495858 --- /dev/null +++ b/src/org/libnodave/ResultSet.java @@ -0,0 +1,47 @@ +/* + Part of Libnodave, a free communication libray for Siemens S7 300/400 via + the MPI adapter 6ES7 972-0CA22-0XAC + or MPI adapter 6ES7 972-0CA33-0XAC + or MPI adapter 6ES7 972-0CA11-0XAC. + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002. + + Libnodave is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Libnodave is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave; + +/** + * @author Thomas Hergenhahn + * + */ +public class ResultSet { + private int errorState, numResults; + public Result[] results; + public void setErrorState(int error) { + errorState = error; + } + + public int getErrorState() { + return errorState; + }; + + public void setNumResults(int nr) { + numResults = nr; + } + + public int getNumResults() { + return numResults; + }; +} diff --git a/src/org/libnodave/S7Connection.java b/src/org/libnodave/S7Connection.java new file mode 100644 index 0000000..c310d6d --- /dev/null +++ b/src/org/libnodave/S7Connection.java @@ -0,0 +1,590 @@ +/* + Part of Libnodave, a free communication libray for Siemens S7 300/400 via + the MPI adapter 6ES7 972-0CA22-0XAC + or MPI adapter 6ES7 972-0CA33-0XAC + or MPI adapter 6ES7 972-0CA11-0XAC. + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002. + + Libnodave is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Libnodave is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave; + +/** + * + * @author Thomas Hergenhahn + * + * This class comprises the variables and methods common to connections to an S7 PLC + * regardless of the type of transport. + */ +public abstract class S7Connection { + PLCinterface iface; // pointer to used interface + int answLen; // length of last message + PDU rcvdPDU; + public byte[] msgIn; + public byte[] msgOut; + /** + * position in result data, incremented when variables are extracted without position + */ + int dataPointer; + /** + * absolut begin of result data + */ + int udata; + public int packetNumber = 0; // packetNumber in transport layer + public byte messageNumber = 0; + + static int tmo_normal = 150; + public int PDUstartIn; + public int PDUstartOut; + public Semaphore semaphore; + public int maxPDUlength;//ºÏ×÷»ï°éÌṩµÄPDUµÄ³¤¶È + + private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5','6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + private static final char[] DIGITS_UPPER = { '0', '1', '2', '3', '4', '5','6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + public S7Connection(PLCinterface ifa) { + iface = ifa; + msgIn = new byte[Nodave.MAX_RAW_LEN]; + msgOut = new byte[Nodave.MAX_RAW_LEN]; + PDUstartIn = 0; + PDUstartOut = 0; + semaphore = new Semaphore(1); + } + public int getUdata(){ + return udata; + } + public byte[] getMsgIn(){ + return msgIn; + } + /** + * get a float value from the current position in result bytes + */ + public float getFloat() { + dataPointer += 4; + return Nodave.BEFloat(msgIn, dataPointer - 4); + } + /* + * The following methods are here to give Siemens users their usual data types: + */ + /** + * get a float value from the specified position in result bytes + */ + public float getFloat(int pos) { + // System.out.println("getFloat pos " + pos); + return Nodave.BEFloat(msgIn, udata + pos); + } + /** + * get an unsigned 32bit value from the specified position in result bytes + */ + public long getDWORD(int pos) { + // System.out.println("getDWORD pos " + pos); + return Nodave.USBELong(msgIn, udata + pos); + } + /** + * get an unsigned 32bit value from the current position in result bytes + */ + public long getU32() { + dataPointer += 4; + return Nodave.USBELong(msgIn, dataPointer - 4); + } + /** + * get an signed 32bit value from the current position in result bytes + */ + public long getDINT() { + dataPointer += 4; + return Nodave.SBELong(msgIn, dataPointer - 4); + } + /** + * get an signed 32bit value from the specified position in result bytes + */ + public long getDINT(int pos) { + return Nodave.SBELong(msgIn, udata + pos); + } + /** + * get an unsigned 16bit value from the specified position in result bytes + */ + public int getWORD(int pos) { + return Nodave.USBEWord(msgIn, udata + pos); + } + /** + * get an unsigned 16bit value from the current position in result bytes + */ + public int getWORD() { + dataPointer += 2; + return Nodave.USBEWord(msgIn, dataPointer - 2); + } + + public int getINT(int pos) { + return Nodave.SBEWord(msgIn, udata + pos); + } + + public int getINT() { + dataPointer += 2; + return Nodave.SBEWord(msgIn, dataPointer - 2); + } + + public int getBYTE(int pos) { + return Nodave.SByte(msgIn, udata + pos); + } + + public int getBYTE() { + dataPointer += 1; + return Nodave.SByte(msgIn, dataPointer - 1); + } + public int getCHAR(int pos) { + return Nodave.SByte(msgIn, udata + pos); + } + + public int getCHAR() { + dataPointer += 1; + return Nodave.SByte(msgIn, dataPointer - 1); + } + + public long getUS32(int pos) { + return Nodave.USBELong(msgIn, udata + pos); + } + + public long getS32(int pos) { + return Nodave.SBELong(msgIn, udata + pos); + } + + public int getUS16(int pos) { + return Nodave.USBEWord(msgIn, udata + pos); + } + + public int getS16(int pos) { + return Nodave.SBEWord(msgIn, udata + pos); + } + + public int getUS8(int pos) { + return Nodave.USByte(msgIn, udata + pos); + } + public int getS8(int pos) { + return Nodave.SByte(msgIn, udata + pos); + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·ûÊý×é + * @param data byte[] + * @return Ê®Áù½øÖÆchar[] + */ + public char[] encodeHex(byte[] data) { + return encodeHex(data, true); + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·ûÊý×é + * @param data byte[] + * @param toLowerCase true ´«»»³ÉСд¸ñʽ £¬ false ´«»»³É´óд¸ñʽ + * @return Ê®Áù½øÖÆchar[] + */ + public char[] encodeHex(byte[] data, boolean toLowerCase) { + return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·ûÊý×é + * @param data byte[] + * @param toDigits ÓÃÓÚ¿ØÖÆÊä³öµÄchar[] + * @return Ê®Áù½øÖÆchar[] + */ + protected char[] encodeHex(byte[] data, char[] toDigits) { + int l = data.length; + char[] out = new char[l << 1]; + for (int i = 0, j = 0; i < l; i++) { + out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; + out[j++] = toDigits[0x0F & data[i]]; + } + return out; + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @return Ê®Áù½øÖÆString + */ + public String encodeHexStr(byte[] data) { + return encodeHexStr(data, true); + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @param toLowerCase true ´«»»³ÉСд¸ñʽ £¬ false ´«»»³É´óд¸ñʽ + * @return Ê®Áù½øÖÆString + */ + public String encodeHexStr(byte[] data, boolean toLowerCase) { + return encodeHexStr(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @param toDigits ÓÃÓÚ¿ØÖÆÊä³öµÄchar[] + * @return Ê®Áù½øÖÆString + */ + protected String encodeHexStr(byte[] data, char[] toDigits) { + return new String(encodeHex(data, toDigits)); + } + /** + * ½«Ê®Áù½øÖÆ×Ö·ûÊý×éת»»Îª×Ö½ÚÊý×é + * @param data Ê®Áù½øÖÆchar[] + * @return byte[] + * @throws RuntimeException Èç¹ûÔ´Ê®Áù½øÖÆ×Ö·ûÊý×éÊÇÒ»¸öÆæ¹ÖµÄ³¤¶È£¬½«Å׳öÔËÐÐʱÒì³£ + */ + public byte[] decodeHex(char[] data) { + int len = data.length; + if ((len & 0x01) != 0) { + throw new RuntimeException("Odd number of characters."); + } + byte[] out = new byte[len >> 1]; + for (int i = 0, j = 0; j < len; i++) { + int f = toDigit(data[j], j) << 4; + j++; + f = f | toDigit(data[j], j); + j++; + out[i] = (byte) (f & 0xFF); + } + return out; + } + /** + * ½«Ê®Áù½øÖÆ×Ö·ûת»»³ÉÒ»¸öÕûÊý + * @param chÊ®Áù½øÖÆchar + * @param indexÊ®Áù½øÖÆ×Ö·ûÔÚ×Ö·ûÊý×éÖеÄλÖà + * @return Ò»¸öÕûÊý + * @throws RuntimeException µ±ch²»ÊÇÒ»¸öºÏ·¨µÄÊ®Áù½øÖÆ×Ö·ûʱ£¬Å׳öÔËÐÐʱÒì³£ + */ + protected int toDigit(char ch, int index) { + int digit = Character.digit(ch, 16); + if (digit == -1) { + throw new RuntimeException("Illegal hexadecimal character " + ch + + " at index " + index); + } + return digit; + } + /** + * ½«byteת»»ÎªÒ»¸ö³¤¶ÈΪ8µÄbyteÊý×飬Êý×éÿ¸öÖµ´ú±íbit + * @param b + * @return + */ + public byte[] getBooleanArray_high_low(byte b) { + byte[] array = new byte[8]; + for (int i = 7; i >= 0; i--) { + array[i] = (byte) (b & 1); + b = (byte) (b >> 1); + } + return array; + } + public byte[] getBooleanArray_low_high(byte b) { + byte[] array = new byte[8]; + for (int i = 0; i <=7 ; i++) { + array[i] = (byte) (b & 1); + b = (byte) (b >> 1); + } + return array; + } + /** + * °ÑbyteתΪ×Ö·û´®µÄbit + * @param b + * @return + */ + public String byteToBit(byte b) { + return "" + (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1) + + (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1) + + (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1) + + (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1); + + } + public String bytesToHexString(byte[] src) { + StringBuilder stringBuilder = new StringBuilder(""); + if (src == null || src.length <= 0) { + return null; + } + for (int i = 0; i < src.length; i++) { + int v = src[i] & 0xFF; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + stringBuilder.append(0); + } + stringBuilder.append(hv); + } + return stringBuilder.toString(); + } + abstract public int exchange(PDU p1); + //¶ÁÈ¡³¤¶Èlen ×ֻÄÜ256¸ö×Ö½Ú + public int readBytes( + int area, + int DBnum, + int start, + int len, + byte[] buffer) { + int res = 0; + semaphore.enter(); + PDU p1 = new PDU(msgOut, PDUstartOut); + p1.initReadRequest(); + p1.addVarToReadRequest(area, DBnum, start, len); + + res = exchange(p1); + if (res != Nodave.RESULT_OK) { + semaphore.leave(); + return res; + } + PDU p2 = new PDU(msgIn, PDUstartIn); + res = p2.setupReceivedPDU(); + if ((Nodave.Debug & Nodave.DEBUG_CONN) != 0) + System.out.println( + "setupReceivedPDU() returned: " + res + Nodave.strerror(res)); + if (res != Nodave.RESULT_OK) { + semaphore.leave(); + return res; + } + + res = p2.testReadResult(); + if ((Nodave.Debug & Nodave.DEBUG_CONN) != 0) + System.out.println( + "testReadResult() returned: " + res + Nodave.strerror(res)); + if (res != Nodave.RESULT_OK) { + semaphore.leave(); + return res; + } + if (p2.udlen == 0) { + semaphore.leave(); + return Nodave.RESULT_CPU_RETURNED_NO_DATA; + } + if (buffer != null) + System.arraycopy(p2.mem, p2.udata, buffer, 0, p2.udlen); + + dataPointer = p2.udata; + udata = p2.udata; + answLen = p2.udlen; + semaphore.leave(); + return res; + } + + public PDU prepareReadRequest() { + int errorState = 0; + semaphore.enter(); + PDU p1 = new PDU(msgOut, PDUstartOut); + p1.prepareReadRequest(); + return p1; + } + + /* + Write len bytes to PLC memory area "area", data block DBnum. + */ + public int writeBytes( + int area, + int DBnum, + int start, + int len, + byte[] buffer) { + int errorState = 0; + semaphore.enter(); + PDU p1 = new PDU(msgOut, PDUstartOut); + p1.prepareWriteRequest(); + p1.addVarToWriteRequest(area, DBnum, start, len, buffer); + + errorState = exchange(p1); + + if (errorState == 0) { + PDU p2 = new PDU(msgIn, PDUstartIn); + p2.setupReceivedPDU(); + + if (p2.mem[p2.param + 0] == PDU.FUNC_WRITE) { + if (p2.mem[p2.data + 0] == (byte) 0xFF) { + if ((Nodave.Debug & Nodave.DEBUG_CONN) != 0) + System.out.println("writeBytes: success"); + semaphore.leave(); + return 0; + } + } else { + errorState |= 4096; + } + } + semaphore.leave(); + return errorState; + } + + /* + public int readByteBlock(int area, int areaNumber, int start, int len) { + return readBytes(area, areaNumber, start, len, null); + } + */ + public int disconnectPLC() { + return 0; + } + public int connectPLC() { + return 0; + } + + public class Semaphore { + private int value; + + public Semaphore(int value) { + this.value = value; + } + + public synchronized void enter() { + --value; + if (value < 0) { + try { + wait(); + } catch (Exception e) { + } + } + } + + public synchronized void leave() { + ++value; + notify(); + } + } + /* + public void sendYOURTURN() { + } + */ + public int getResponse() { + return 0; + } + + public int getPPIresponse() { + return 0; + } + + public int sendMsg(PDU p) { + return 0; + } + public void sendRequestData(int alt) { + } + + // int numResults; + /* + class Result { + int error; + byte[] data; + } + */ + /* + Read a predefined set of values from the PLC. + Return ok or an error state + If a buffer pointer is provided, data will be copied into this buffer. + If it's NULL you can get your data from the resultPointer in daveConnection long + as you do not send further requests. + */ + public ResultSet execReadRequest(PDU p) { + PDU p2; + int errorState; + errorState = exchange(p); + + p2 = new PDU(msgIn, PDUstartIn); + p2.setupReceivedPDU(); + /* + if (p2.udlen == 0) { + dataPointer = 0; + answLen = 0; + return Nodave.RESULT_CPU_RETURNED_NO_DATA; + } + */ + ResultSet rs = new ResultSet(); + if (p2.mem[p2.param + 0] == PDU.FUNC_READ) { + int numResults = p2.mem[p2.param + 1]; + // System.out.println("Results " + numResults); + rs.results = new Result[numResults]; + int pos = p2.data; + for (int i = 0; i < numResults; i++) { + Result r = new Result(); + r.error = Nodave.USByte(p2.mem, pos); + if (r.error == 255) { + + int type = Nodave.USByte(p2.mem, pos + 1); + int len = Nodave.USBEWord(p2.mem, pos + 2); + r.error = 0; + // System.out.println("Raw length " + len); + if (type == 4) + len /= 8; + else if (type == 3); //length is ok + + // System.out.println("Byte length " + len); + // r.data = new byte[len]; + + // System.arraycopy(p2.mem, pos + 4, r.data, 0, len); + // Nodave.dump("Result " + i + ":", r.data, 0, len); + r.bufferStart = pos + 4; + pos += len; + if ((len % 2) == 1) + pos++; + } else { + System.out.println("Error " + r.error); + } + pos += 4; + rs.results[i] = r; + } + numResults = p2.mem[p2.param + 1]; + rs.setNumResults(numResults); + dataPointer = p2.udata; + answLen = p2.udlen; + // } + } else { + errorState |= 2048; + } + semaphore.leave(); + rs.setErrorState(errorState); + return rs; + } + + public int useResult(ResultSet rs, int number) { + System.out.println( + "rs.getNumResults: " + rs.getNumResults() + " number: " + number); + if (rs.getNumResults() > number) { + dataPointer = rs.results[number].bufferStart; + return 0; + // udata=rs.results[number].bufferStart; + } + return -33; + }; + + /* + build the PDU for a PDU length negotiation + */ + public int negPDUlengthRequest() { + int res; + PDU p = new PDU(msgOut, PDUstartOut); + byte pa[] = + {(byte) 0xF0, 0, 0x00, 0x01, 0x00, 0x01, 0x03, (byte) 0xC0, }; + p.initHeader(1); + p.addParam(pa); + if ((Nodave.Debug & Nodave.DEBUG_PDU) != 0) { + p.dump(); + } + res = exchange(p); + if (res != 0) + return res; + PDU p2 = new PDU(msgIn, PDUstartIn); + res = p2.setupReceivedPDU(); + if (res != 0) + return res; + maxPDUlength = Nodave.USBEWord(msgIn, p2.param + 6); + if ((Nodave.Debug & Nodave.DEBUG_CONNECT) != 0) { + System.out.println( + "*** Partner offered PDU length: " + maxPDUlength); + } + return res; + } + /* + build the PDU for a PDU length negotiation + */ + + public void finalize() throws Throwable { + //System.out.println("this is finalize S7Connection"); + disconnectPLC(); + iface.finalize(); + } + +} diff --git a/src/org/libnodave/TCPConnection.java b/src/org/libnodave/TCPConnection.java new file mode 100644 index 0000000..7e7cbbe --- /dev/null +++ b/src/org/libnodave/TCPConnection.java @@ -0,0 +1,108 @@ +/* + Part of Libnodave, a free communication libray for Siemens S7 300/400 via + the MPI adapter 6ES7 972-0CA22-0XAC + or MPI adapter 6ES7 972-0CA33-0XAC + or MPI adapter 6ES7 972-0CA11-0XAC. + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002. + + Libnodave is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Libnodave is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave; +public class TCPConnection extends S7Connection { + int rack; + int slot; + + public TCPConnection(PLCinterface ifa, int rack, int slot) { + super(ifa); + this.rack=rack; + this.slot=slot; + PDUstartIn = 7; + PDUstartOut = 7; + } + + protected int readISOPacket() { + int res = iface.read(msgIn, 0, 4); + if (res == 4) { + int len = 0x100 * msgIn[2] + msgIn[3]; + res += iface.read(msgIn, 4, len); + } else return 0; + return res; + } + protected int sendISOPacket(int size) { + size += 4; + msgOut[0] = (byte)0x03; + msgOut[1] = (byte)0x0; + msgOut[2] = (byte) (size / 0x100); + msgOut[3] = (byte) (size % 0x100); + iface.write(msgOut, 0, size); + return 0; + } + public static void main(String arg[]){ + System.out.println(0x100); + } + public int exchange(PDU p1) { + int res; + PDU p2; + if ((Nodave.Debug & Nodave.DEBUG_EXCHANGE) != 0) { + System.out.println(" enter TCP.Exchange"); + } + msgOut[4] = (byte)0x02; + msgOut[5] = (byte)0xf0; + msgOut[6] = (byte)0x80; + sendISOPacket(3 + p1.hlen + p1.plen + p1.dlen); + res = readISOPacket(); + return 0; + } + /** + * We have our own connectPLC(), but no disconnect() + * Open connection to a PLC. This assumes that dc is initialized by + * daveNewConnection and is not yet used. + * (or reused for the same PLC ?) + */ + public int connectPLC() { + int res; + byte[] b4 ={ + (byte)0x11, + (byte)0xE0, + (byte)0x00, + (byte)0x00, + (byte)0x00, + (byte)0x01, + (byte)0x00, + (byte)0xC1, + (byte)0x02, + (byte)0x01, + (byte)0x00, + (byte)0xC2, + (byte)0x02, + (byte)0x01, + (byte)0x02, + (byte)0xC0, + (byte)0x01, + (byte)0x09 }; + + if ((Nodave.Debug & Nodave.DEBUG_CONNECT) != 0) + System.out.println("daveConnectPLC() step 1. rack:"+rack+" slot:"+slot); + System.arraycopy(b4, 0, msgOut, 4, b4.length); + msgOut[17]=(byte)(rack+1); + msgOut[18]=(byte)slot; + sendISOPacket(b4.length); + readISOPacket(); + if ((Nodave.Debug & Nodave.DEBUG_CONNECT) != 0) + System.out.println("daveConnectPLC() step 1."); + return negPDUlengthRequest(); + } +} diff --git a/src/org/libnodave/tests/PlcTcpClient.java b/src/org/libnodave/tests/PlcTcpClient.java new file mode 100644 index 0000000..e37ba45 --- /dev/null +++ b/src/org/libnodave/tests/PlcTcpClient.java @@ -0,0 +1,83 @@ +package org.libnodave.tests; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +public class PlcTcpClient { + int i, j; + long a, b, c; + float d, e, f; + byte buf1[]; + PLCinterface di; + TCPConnection dc; + Socket sock; + PlcTcpClient(String host) { + buf1 = new byte[Nodave.PartnerListSize]; + try { + sock = new Socket(host, 102); + } catch (IOException e) { + System.out.println(e); + } + } + void run() { + OutputStream oStream = null; + InputStream iStream = null; + byte[] by; + if (sock != null) { + try { + oStream = sock.getOutputStream(); + } catch (IOException e) { + } + try { + iStream = sock.getInputStream(); + } catch (IOException e) { + } + di = new PLCinterface( + oStream, + iStream, + "PLCName", + 0, + Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + int res = dc.connectPLC(); + if(di.isConnect){ + while(true){ + dc.readBytes(Nodave.DB, 102, 0, 50, null); + dc.getDINT(22); + System.out.println("111:"+dc.getDINT(22)); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } else + System.out.println("Couldn't open connection"); + } + + static boolean doWrite = true; + static boolean doBenchmark = false; + static boolean doLentest = false; + static int useProtocol = Nodave.PROTOCOL_ISOTCP; + static int slot=1; + + public static void main(String[] args) { +// PlcTcpClient tp = new PlcTcpClient("192.168.8.102"); +// tp.run(); + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dqsj; + dqsj= "2019-10-19 22:01:48";//df.format(t); + long longstr1 = Long.valueOf(dqsj.replaceAll("[-\\s:]","")); + System.out.println(longstr1); + System.out.println(longstr1+4043); + System.out.println(dqsj); + } +} \ No newline at end of file diff --git a/src/org/libnodave/tests/TestISOTCP2.java b/src/org/libnodave/tests/TestISOTCP2.java new file mode 100644 index 0000000..704a042 --- /dev/null +++ b/src/org/libnodave/tests/TestISOTCP2.java @@ -0,0 +1,269 @@ +/* + Test and demo program for Libnodave, a free communication libray for Siemens S7. + + ********************************************************************** + * WARNING: This and other test programs overwrite data in your PLC. * + * DO NOT use it on PLC's when anything is connected to their outputs.* + * This is alpha software. Use entirely on your own risk. * + ********************************************************************** + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002, 2004. + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with Visual; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.libnodave.tests; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.wms.dss.ats.customs.abb.utils.Tools; +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.wms.dss.common.server.form.Logger; +//YAO-2017-09-06 ����ͨ���� +public class TestISOTCP2 { + int i, j; + long a, b, c; + float d, e, f; + byte buf1[]; + String strIp=""; + int iPort = 102; + PLCinterface di; + TCPConnection dc; + Socket sock; + OutputStream oStream = null; + InputStream iStream = null; + protected byte btid = 1; //�Ѷ���� + public Hashtable writePlcHs = null; + TestISOTCP2(String strIp,int iPort) { + buf1 = new byte[Nodave.PartnerListSize]; + this.strIp = strIp; + this.iPort = iPort; + } + public void setIsConnect(boolean bflag){ + if(di!=null){ + di.isConnect = bflag; + } + } + public boolean IsConnect(){ + if(di!=null){ + return di.isConnect; + }else{ + return false; + } + } + void ConnectServer(){ + try { + System.out.println(new Date()+"********��ʼ��IP:"+strIp+" �˿�:"+iPort+"����socket���ӿ�ʼ!************************************"); + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); //���ó�ʱʱ��6�� + System.out.println(new Date()+"********��ʼ��IP:"+strIp+" �˿�:"+iPort+"����socket���ӳɹ�!************************************"); + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + System.out.println(new Date()+"********��ʼ��IP:"+strIp+" �˿�:"+iPort+"����-������-���ӳɹ�!************************************"); + di = new PLCinterface( + oStream, + iStream, + "PLCName", + 0, + Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + System.out.println(new Date()+"����TCPConnection�������ɹ�! "); + }else{ + System.out.println(new Date()+"����TCPConnection������ʧ��! "); + } + } catch (IOException ioex) { + System.out.println(new Date()+"����ʧ�� "+ioex.getMessage()); + } catch (Exception ex) { + System.out.println(new Date()+"�����쳣 "+ex.getMessage()); + } + } + void closeServer(){ + try + { + setIsConnect(false); + if (iStream != null){ + System.out.println(new Date()+"�������رտ�ʼ "); + iStream.close(); + iStream = null; + System.out.println(new Date()+"�������رս��� "); + } + }catch (IOException e){ + System.out.println(new Date()+"�������ر��쳣 "+e.getMessage()); + } + try + { + if (oStream != null) + { + System.out.println(new Date()+"������رտ�ʼ "); + oStream.close(); + oStream = null; + System.out.println(new Date()+"������رս��� "); + } + }catch (IOException e){ + System.out.println(new Date()+"������ر��쳣 "+e.getMessage()); + } + try + { + if(sock != null) + { + System.out.println(new Date()+"socket�ͻ��˹رտ�ʼ"); + sock.close(); + sock = null; + System.out.println(new Date()+"socket�ͻ��˹رս���"); + } + }catch (IOException e){ + System.out.println(new Date()+"socket�ͻ��˹ر��쳣 "+e.getMessage()); + } + } + void reConnect(){ + closeServer(); + ConnectServer(); + } + public int sendtoCrane(byte btid,int new_cmd, Hashtable hsSysParam) throws Exception + { + //super(hsSysParam); + try{ + + //m_hsSysParam = hsSysParam; + Hashtable hsComParam1 = (Hashtable)hsSysParam.get("hsComParam"); + Hashtable writePlcHs = (Hashtable)hsSysParam.get("writePlcHs"); + WriteDotPlcInterface ddjcmd = (WriteDotPlcInterface)writePlcHs.get("11-1"); + if(btid == 1){ + + /*JSONArray orderEntitys = new JSONArray(); + orderEntitys.add(JsonTool.updateJson(WritePlcCmd.XMCJ2_QQDQ, 1)); + return ddjcmd.Analysis(orderEntitys.toString());*/ + } + }catch(Exception ex){ + Logger.error("��Ѷ������ָ���쳣"+ex.getMessage()); + } + return -1; + } + void run() { + long t1 = 0,t2 = 0; + //List groups = {0,1,1,1,[1,1]}; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + Iterator iterW = null; + Map.Entry entry = null; + // + while(true){ + try{ + if(IsConnect()){ + //257-25= + //��ȡDB��510�������ļ� + t1 = System.currentTimeMillis(); + dc.readBytes(Nodave.DB, 101, 0, 40, null); + if(IsConnect()){ + System.out.println(dc.getINT(20)); + System.out.println(dc.getDINT(22)); + }else{ + continue; + } + //��ȡDB��511�������ļ� + //protected byte btid = 0; //�Ѷ���� + +// dc.readBytes(Nodave.DB, 301, 0, 2, null); +// if(IsConnect()){ +// System.out.println(dc.getINT(0)); +// }else{ +// continue; +// } + //�DB��301 + Hashtable hsComParam = new Hashtable();//ͨѶ���� + Hashtable writePlcHs = new Hashtable(); + WriteDotPlcInterface ddjcmd1 = new WriteDotPlcInterface("11",1+"");//11Ϊ�Ѷ��ָ������ + writePlcHs.put(ddjcmd1.cmdtype+"-"+ddjcmd1.cmdvalue, ddjcmd1); + hsComParam.put("writePlcHs", writePlcHs); + + + int iSend = sendtoCrane(btid, 1,hsComParam); + + + iterW = writePlcHs.entrySet().iterator(); + if(iterW != null){ + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface)entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for(i=0;itrue ´«»»³ÉСд¸ñʽ £¬ false ´«»»³É´óд¸ñʽ + * @return Ê®Áù½øÖÆchar[] + */ + public char[] encodeHex(byte[] data, boolean toLowerCase) { + return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·ûÊý×é + * @param data byte[] + * @param toDigits ÓÃÓÚ¿ØÖÆÊä³öµÄchar[] + * @return Ê®Áù½øÖÆchar[] + */ + protected char[] encodeHex(byte[] data, char[] toDigits) { + int l = data.length; + char[] out = new char[l << 1]; + for (int i = 0, j = 0; i < l; i++) { + out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; + out[j++] = toDigits[0x0F & data[i]]; + } + return out; + } + + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @return Ê®Áù½øÖÆString + */ + public String encodeHexStr(byte[] data) { + return encodeHexStr(data, true); + } + + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @param toLowerCase true ´«»»³ÉСд¸ñʽ £¬ false ´«»»³É´óд¸ñʽ + * @return Ê®Áù½øÖÆString + */ + public String encodeHexStr(byte[] data, boolean toLowerCase) { + return encodeHexStr(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + + /** + * ½«×Ö½ÚÊý×éת»»ÎªÊ®Áù½øÖÆ×Ö·û´® + * @param data byte[] + * @param toDigits ÓÃÓÚ¿ØÖÆÊä³öµÄchar[] + * @return Ê®Áù½øÖÆString + */ + protected String encodeHexStr(byte[] data, char[] toDigits) { + return new String(encodeHex(data, toDigits)); + } + + /** + * ½«Ê®Áù½øÖÆ×Ö·ûÊý×éת»»Îª×Ö½ÚÊý×é + * @param data Ê®Áù½øÖÆchar[] + * @return byte[] + * @throws RuntimeException Èç¹ûÔ´Ê®Áù½øÖÆ×Ö·ûÊý×éÊÇÒ»¸öÆæ¹ÖµÄ³¤¶È£¬½«Å׳öÔËÐÐʱÒì³£ + */ + public byte[] decodeHex(char[] data) { + int len = data.length; + if ((len & 0x01) != 0) { + throw new RuntimeException("Odd number of characters."); + } + byte[] out = new byte[len >> 1]; + for (int i = 0, j = 0; j < len; i++) { + int f = toDigit(data[j], j) << 4; + j++; + f = f | toDigit(data[j], j); + j++; + out[i] = (byte) (f & 0xFF); + } + return out; + } + + /** + * ½«Ê®Áù½øÖÆ×Ö·ûת»»³ÉÒ»¸öÕûÊý + * @param chÊ®Áù½øÖÆchar + * @param indexÊ®Áù½øÖÆ×Ö·ûÔÚ×Ö·ûÊý×éÖеÄλÖà + * @return Ò»¸öÕûÊý + * @throws RuntimeException µ±ch²»ÊÇÒ»¸öºÏ·¨µÄÊ®Áù½øÖÆ×Ö·ûʱ£¬Å׳öÔËÐÐʱÒì³£ + */ + protected int toDigit(char ch, int index) { + int digit = Character.digit(ch, 16); + if (digit == -1) { + throw new RuntimeException("Illegal hexadecimal character " + ch + + " at index " + index); + } + return digit; + } + + /** + * ½«byteת»»ÎªÒ»¸ö³¤¶ÈΪ8µÄbyteÊý×飬Êý×éÿ¸öÖµ´ú±íbit + * @param b + * @return + */ + public byte[] getBooleanArray_high_low(byte b) { + byte[] array = new byte[8]; + for (int i = 7; i >= 0; i--) { + array[i] = (byte) (b & 1); + b = (byte) (b >> 1); + } + return array; + } + + public byte[] getBooleanArray_low_high(byte b) { + byte[] array = new byte[8]; + for (int i = 0; i <=7 ; i++) { + array[i] = (byte) (b & 1); + b = (byte) (b >> 1); + } + return array; + } + + /** + * °ÑbyteתΪ×Ö·û´®µÄbit + * @param b + * @return + */ + public String byteToBit(byte b) { + return "" + (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1) + + (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1) + + (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1) + + (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1); + + } + + public String bytesToHexString(byte[] src) { + StringBuilder stringBuilder = new StringBuilder(""); + if (src == null || src.length <= 0) { + return null; + } + for (int i = 0; i < src.length; i++) { + int v = src[i] & 0xFF; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + stringBuilder.append(0); + } + stringBuilder.append(hv); + } + return stringBuilder.toString(); + } + + + //ÏäÂë²É¼¯ + public abstract void analysisDb50_1(); + public abstract void analysisDb50_2(); + public abstract void analysisDb50_3(); + public abstract void analysisDb50_4(); + public abstract void analysisDb50_5(); + public abstract void analysisDb50_6(); + public abstract void analysisDb50_7(); + public abstract void analysisDb50_8(); + public abstract void analysisDb50_9(); + public abstract void analysisDb50_10(); + public abstract void analysisDb50_11(); + public abstract void analysisDb50_12(); + public abstract void analysisDb50_13(); + public abstract void analysisDb50_14(); + public abstract void analysisDb50_15(); + public abstract void analysisDb50_16(); + + public abstract void analysisDb49_1(); + public abstract void analysisDb49_2(); + public abstract void analysisDb49_3(); + public abstract void analysisDb49_4(); + public abstract void analysisDb49_5(); + public abstract void analysisDb49_6(); + public abstract void analysisDb49_7(); + public abstract void analysisDb49_8(); + public abstract void analysisDb49_9(); + public abstract void analysisDb49_10(); + public abstract void analysisDb49_11(); + public abstract void analysisDb49_12(); + public abstract void analysisDb49_13(); + public abstract void analysisDb49_14(); + public abstract void analysisDb49_15(); + public abstract void analysisDb49_16(); + + + + public abstract void analysisDb48_1(); + public abstract void analysisDb48_2(); + public abstract void analysisDb48_3(); + public abstract void analysisDb48_4(); + public abstract void analysisDb48_5(); + public abstract void analysisDb48_6(); + public abstract void analysisDb48_7(); + public abstract void analysisDb48_8(); + public abstract void analysisDb48_9(); + public abstract void analysisDb48_10(); + public abstract void analysisDb48_11(); + public abstract void analysisDb48_12(); + public abstract void analysisDb48_13(); + public abstract void analysisDb48_14(); + public abstract void analysisDb48_15(); + public abstract void analysisDb48_16(); + + + public abstract void analysisDb47_1(); + public abstract void analysisDb47_2(); + public abstract void analysisDb47_3(); + public abstract void analysisDb47_4(); + public abstract void analysisDb47_5(); + public abstract void analysisDb47_6(); + public abstract void analysisDb47_7(); + public abstract void analysisDb47_8(); + public abstract void analysisDb47_9(); + public abstract void analysisDb47_10(); + public abstract void analysisDb47_11(); + public abstract void analysisDb47_12(); + public abstract void analysisDb47_13(); + public abstract void analysisDb47_14(); + public abstract void analysisDb47_15(); + public abstract void analysisDb47_16(); + + + + public abstract void analysisDb46_1(); + public abstract void analysisDb46_2(); + public abstract void analysisDb46_3(); + public abstract void analysisDb46_4(); + public abstract void analysisDb46_5(); + public abstract void analysisDb46_6(); + public abstract void analysisDb46_7(); + public abstract void analysisDb46_8(); + public abstract void analysisDb46_9(); + public abstract void analysisDb46_10(); + public abstract void analysisDb46_11(); + public abstract void analysisDb46_12(); + public abstract void analysisDb46_13(); + public abstract void analysisDb46_14(); + public abstract void analysisDb46_15(); + public abstract void analysisDb46_16(); + + + public abstract void analysisDb45_1(); + public abstract void analysisDb45_2(); + public abstract void analysisDb45_3(); + public abstract void analysisDb45_4(); + public abstract void analysisDb45_5(); + public abstract void analysisDb45_6(); + public abstract void analysisDb45_7(); + public abstract void analysisDb45_8(); + public abstract void analysisDb45_9(); + public abstract void analysisDb45_10(); + public abstract void analysisDb45_11(); + public abstract void analysisDb45_12(); + public abstract void analysisDb45_13(); + public abstract void analysisDb45_14(); + public abstract void analysisDb45_15(); + public abstract void analysisDb45_16(); + + + public abstract void analysisDb44_1(); + public abstract void analysisDb44_2(); + public abstract void analysisDb44_3(); + public abstract void analysisDb44_4(); + public abstract void analysisDb44_5(); + public abstract void analysisDb44_6(); + public abstract void analysisDb44_7(); + public abstract void analysisDb44_8(); + public abstract void analysisDb44_9(); + public abstract void analysisDb44_10(); + public abstract void analysisDb44_11(); + public abstract void analysisDb44_12(); + public abstract void analysisDb44_13(); + public abstract void analysisDb44_14(); + public abstract void analysisDb44_15(); + public abstract void analysisDb44_16(); + + public abstract void analysisDb43_1(); + public abstract void analysisDb43_2(); + public abstract void analysisDb43_3(); + public abstract void analysisDb43_4(); + public abstract void analysisDb43_5(); + public abstract void analysisDb43_6(); + public abstract void analysisDb43_7(); + public abstract void analysisDb43_8(); + public abstract void analysisDb43_9(); + public abstract void analysisDb43_10(); + public abstract void analysisDb43_11(); + public abstract void analysisDb43_12(); + public abstract void analysisDb43_13(); + public abstract void analysisDb43_14(); + public abstract void analysisDb43_15(); + public abstract void analysisDb43_16(); + + + public abstract void analysisDb42_1(); + public abstract void analysisDb42_2(); + public abstract void analysisDb42_3(); + public abstract void analysisDb42_4(); + public abstract void analysisDb42_5(); + public abstract void analysisDb42_6(); + public abstract void analysisDb42_7(); + public abstract void analysisDb42_8(); + public abstract void analysisDb42_9(); + public abstract void analysisDb42_10(); + public abstract void analysisDb42_11(); + public abstract void analysisDb42_12(); + public abstract void analysisDb42_13(); + public abstract void analysisDb42_14(); + public abstract void analysisDb42_15(); + public abstract void analysisDb42_16(); + + + public abstract void analysisDb41_1(); + public abstract void analysisDb41_2(); + public abstract void analysisDb41_3(); + public abstract void analysisDb41_4(); + public abstract void analysisDb41_5(); + public abstract void analysisDb41_6(); + public abstract void analysisDb41_7(); + public abstract void analysisDb41_8(); + public abstract void analysisDb41_9(); + public abstract void analysisDb41_10(); + public abstract void analysisDb41_11(); + public abstract void analysisDb41_12(); + public abstract void analysisDb41_13(); + public abstract void analysisDb41_14(); + public abstract void analysisDb41_15(); + public abstract void analysisDb41_16(); + + + + + + + public String getSTRING30(int pos) { + return Nodave.SBEString30(msgIn, udata + pos).toString(); + } + +} diff --git a/src/org/s7/standard/ynuo/ReadDotPlcInterface.java b/src/org/s7/standard/ynuo/ReadDotPlcInterface.java new file mode 100644 index 0000000..117787b --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadDotPlcInterface.java @@ -0,0 +1,49 @@ +package org.s7.standard.ynuo; +import java.util.ArrayList; +import java.util.List; +import org.libnodave.Nodave; +/** + * ¶ÁÈ¡db¿éµãÒµÎñ±ê×¼Àà + * @author yao + */ +public abstract class ReadDotPlcInterface implements PlcInterface{ + public List lsReadGroupPlc = new ArrayList(); + /*½«¶ÁÈ¡PLCµÄdb¿éÊý¾ÝÍùÊý¾Ý¿âÖÐдÈë*/ + public abstract void analysisDb(); + public class groupPlcObj { + /*Öµ*/ + public Object obj = null; + /*DB*/ + private int DB=Nodave.DB; + /*¶ÁÈ¡DBµØÖ·*/ + private int DBnum=0; + /*¶ÁÈ¡DBÆðʼλÖà */ + private int start=0; + /*¶ÁÈ¡Êý¾ÝÀàÐÍ*/ + private int dtype = BYTE; + public groupPlcObj(int DB,int DBnum,int start,int dtype){ + this.DB = DB; + this.DBnum = DBnum; + this.start = start; + this.dtype = dtype; + } + public String key(){ + return DB+"-"+DBnum+"-"+start+"-"+dtype; + } + public Object getObj() { + return obj; + } + public int getDB() { + return DB; + } + public int getDBnum() { + return DBnum; + } + public int getStart() { + return start; + } + public int getDtype() { + return dtype; + } + } +} diff --git a/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer101.java b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer101.java new file mode 100644 index 0000000..26c5bc2 --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer101.java @@ -0,0 +1,248 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import org.s7.standard.ynuo.client.IsoTcpClient101; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.config.DSSTabSel; + +/** + * ¸ÃÏ߳̽«´Ó¡¶¶Á»º´æÇø¡·£¨´Óplc¶ÁÈ¡µ½µÄÊý¾Ý´æ·ÅµÄλÖã©¶¨Ê±Ð´µ½Êý¾Ý¿âÖÐ + * + * @author admin + * + */ +public class ReadPlcDBAnalyServer101 implements Runnable { + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHsMD101 = null; + public Hashtable readAreaPlcHsMD102 = null; + public Hashtable readAreaPlcHsMD103 = null; + public Hashtable readAreaPlcHsMD104 = null; + public Hashtable readAreaPlcHsMD105 = null; + public Hashtable readAreaPlcHsMD106 = null; + public Hashtable readAreaPlcHsMD107 = null; + public Hashtable readAreaPlcHsMD108 = null; + public Hashtable readAreaPlcHsMD109 = null; + public Hashtable readAreaPlcHsMD110 = null; +// public Hashtable readAreaPlcHs2 = null; +// public Hashtable readAreaPlcHs3 = null; +// public Hashtable readAreaPlcHs4 = null; +// public Hashtable readAreaPlcHs5 = null; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readDotPlcHs = null; + Hashtable hsSysParam = null; + Hashtable hsComParam = null; + IsoTcpClient101 client = null; + + public EntityDAO dao; + + public ReadPlcDBAnalyServer101(Hashtable hsComParam, IsoTcpClient101 client) { + this.hsComParam = hsComParam; + this.hsSysParam = client.hsSysParam; + this.readAreaPlcHsMD101 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_101"); + this.readAreaPlcHsMD102 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_102"); + this.readAreaPlcHsMD103 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_103"); + this.readAreaPlcHsMD104 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_104"); + this.readAreaPlcHsMD105 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_105"); + this.readAreaPlcHsMD106 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_106"); + this.readAreaPlcHsMD107 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_107"); + this.readAreaPlcHsMD108 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_108"); + this.readAreaPlcHsMD109 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_109"); + this.readAreaPlcHsMD110 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_110"); +// this.readAreaPlcHs2 = (Hashtable) hsComParam.get("readAreaPlcHs1_2"); +// this.readAreaPlcHs3 = (Hashtable) hsComParam.get("readAreaPlcHs1_3"); +// this.readAreaPlcHs4 = (Hashtable) hsComParam.get("readAreaPlcHs1_4"); +// this.readAreaPlcHs5 = (Hashtable) hsComParam.get("readAreaPlcHs1_5"); + this.client = client; + } + + public void run() { + Iterator iterobj; + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.setCaretPosition( + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.getText().length() + - 20); + try { + + if (readAreaPlcHsMD101 != null) { + iterobj = readAreaPlcHsMD101.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb101_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD102 != null) { + iterobj = readAreaPlcHsMD102.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb102_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD103 != null) { + iterobj = readAreaPlcHsMD103.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb103_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD104 != null) { + iterobj = readAreaPlcHsMD104.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb104_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD105 != null) { + iterobj = readAreaPlcHsMD105.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb105_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD106 != null) { + iterobj = readAreaPlcHsMD106.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb106_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD107 != null) { + iterobj = readAreaPlcHsMD107.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb107_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + if (readAreaPlcHsMD108 != null) { + iterobj = readAreaPlcHsMD108.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb108_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHsMD109 != null) { + iterobj = readAreaPlcHsMD109.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb109_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHsMD110 != null) { + iterobj = readAreaPlcHsMD110.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb110_MD(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer102.java b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer102.java new file mode 100644 index 0000000..6cc60f6 --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer102.java @@ -0,0 +1,247 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import org.s7.standard.ynuo.client.IsoTcpClient102; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.config.DSSTabSel; + +/** + * ¸ÃÏ߳̽«´Ó¡¶¶Á»º´æÇø¡·£¨´Óplc¶ÁÈ¡µ½µÄÊý¾Ý´æ·ÅµÄλÖã©¶¨Ê±Ð´µ½Êý¾Ý¿âÖÐ + * + * @author admin + * + */ +public class ReadPlcDBAnalyServer102 implements Runnable { + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs101 = null; + public Hashtable readAreaPlcHs102 = null; + public Hashtable readAreaPlcHs104 = null; + public Hashtable readAreaPlcHs105 = null; + public Hashtable readAreaPlcHs106 = null; + public Hashtable readAreaPlcHs107 = null; + public Hashtable readAreaPlcHs103 = null; + public Hashtable readAreaPlcHs105_2 = null; + public Hashtable readAreaPlcHs151 = null; + + public Hashtable readAreaPlcHs108 = null; + + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readDotPlcHs = null; + Hashtable hsSysParam = null; + Hashtable hsComParam = null; + IsoTcpClient102 client = null; + + public EntityDAO dao; + + public ReadPlcDBAnalyServer102(Hashtable hsComParam, IsoTcpClient102 tp2) { + this.hsComParam = hsComParam; + this.hsSysParam = tp2.hsSysParam; + this.readAreaPlcHs101 = (Hashtable) hsComParam.get("readAreaPlcHsDB101"); + this.readAreaPlcHs102 = (Hashtable) hsComParam.get("readAreaPlcHsDB102"); + this.readAreaPlcHs104 = (Hashtable) hsComParam.get("readAreaPlcHsDB104"); + this.readAreaPlcHs105 = (Hashtable) hsComParam.get("readAreaPlcHsDB105"); + this.readAreaPlcHs106 = (Hashtable) hsComParam.get("readAreaPlcHsDB106"); + this.readAreaPlcHs107 = (Hashtable) hsComParam.get("readAreaPlcHsDB107"); + this.readAreaPlcHs103 = (Hashtable) hsComParam.get("readAreaPlcHsDB103"); + this.readAreaPlcHs105_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB105_2"); + this.readAreaPlcHs151 = (Hashtable) hsComParam.get("readAreaPlcHsDB151"); + + + this.readAreaPlcHs108 = (Hashtable) hsComParam.get("readAreaPlcHsDB108"); + this.client = tp2; + } + + public void run() { + + Iterator iterobj; + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.setCaretPosition( + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.getText().length() + - 20); + try { + + if (readAreaPlcHs101 != null) { + iterobj = readAreaPlcHs101.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb101(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs102 != null) { + iterobj = readAreaPlcHs102.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDb102(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs104 != null) { + iterobj = readAreaPlcHs104.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb104(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs105 != null) { + iterobj = readAreaPlcHs105.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb105(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs105_2 != null) { + iterobj = readAreaPlcHs105_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb105_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs106 != null) { + iterobj = readAreaPlcHs106.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb106(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs107 != null) { + iterobj = readAreaPlcHs107.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb107(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs103 != null) { + iterobj = readAreaPlcHs103.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb103(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs151 != null) { + iterobj = readAreaPlcHs151.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb151(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + //2021-2-10 + if (readAreaPlcHs108 != null) { + iterobj = readAreaPlcHs108.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb108(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer103.java b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer103.java new file mode 100644 index 0000000..e7cc15e --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer103.java @@ -0,0 +1,76 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import org.s7.standard.ynuo.client.IsoTcpClient103; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.config.DSSTabSel; + +/** + * ¸ÃÏ߳̽«´Ó¡¶¶Á»º´æÇø¡·£¨´Óplc¶ÁÈ¡µ½µÄÊý¾Ý´æ·ÅµÄλÖã©¶¨Ê±Ð´µ½Êý¾Ý¿âÖÐ + * + * @author admin + * + */ +public class ReadPlcDBAnalyServer103 implements Runnable { + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + //public Hashtable readAreaPlcHs = null; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + //public Hashtable readDotPlcHs = null; + Hashtable hsSysParam = null; + Hashtable hsComParam = null; + IsoTcpClient103 client = null; + + public EntityDAO dao; + + public ReadPlcDBAnalyServer103(Hashtable hsComParam, IsoTcpClient103 client) { + this.hsComParam = hsComParam; + this.hsSysParam = client.hsSysParam; + //this.readAreaPlcHs = (Hashtable) hsComParam.get("readAreaPlcHs3"); + this.client = client; + } + + public void run() { + Iterator iterobj; + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.setCaretPosition( + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.getText().length() + - 20); + try { + + for (int i = 201, x = 1; i <= 215; i++,x++) { + Hashtable readAreaPlcHs = null; + readAreaPlcHs = (Hashtable) hsComParam.get("readAreaPlcHsDB"+i); + if (readAreaPlcHs != null) { + iterobj = readAreaPlcHs.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + String key = (String) entry.getKey(); + if (client != null && client.IsConnect()) { + try { + plcVar.analysisDbDDJ("21-"+x); + } catch (Exception ex) { + } + } else { + break; + } + } + } + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer104.java b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer104.java new file mode 100644 index 0000000..76285bc --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer104.java @@ -0,0 +1,425 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import org.s7.standard.ynuo.client.IsoTcpClient104; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.config.DSSTabSel; + +/** + * ¸ÃÏ߳̽«´Ó¡¶¶Á»º´æÇø¡·£¨´Óplc¶ÁÈ¡µ½µÄÊý¾Ý´æ·ÅµÄλÖã©¶¨Ê±Ð´µ½Êý¾Ý¿âÖÐ + * + * @author admin + * + */ +public class ReadPlcDBAnalyServer104 implements Runnable { + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs1 = null; + public Hashtable readAreaPlcHs2 = null; + public Hashtable readAreaPlcHs2s = null; + public Hashtable readAreaPlcHs3 = null; + public Hashtable readAreaPlcHs4 = null; + public Hashtable readAreaPlcHs5 = null; + public Hashtable readAreaPlcHs6 = null; + public Hashtable readAreaPlcHs7 = null; + public Hashtable readAreaPlcHs8 = null; + public Hashtable readAreaPlcHs9 = null; + public Hashtable readAreaPlcHs10 = null; + public Hashtable readAreaPlcHs11 = null; + public Hashtable readAreaPlcHs12 = null; + public Hashtable readAreaPlcHs13 = null; + public Hashtable readAreaPlcHs14 = null; + public Hashtable readAreaPlcHs15 = null; + public Hashtable readAreaPlcHs16 = null; + public Hashtable readAreaPlcHs17 = null; + public Hashtable readAreaPlcHs18 = null; + public Hashtable readAreaPlcHs19 = null; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readDotPlcHs = null; + Hashtable hsSysParam = null; + Hashtable hsComParam = null; + IsoTcpClient104 client = null; + + public EntityDAO dao; + + public ReadPlcDBAnalyServer104(Hashtable hsComParam, IsoTcpClient104 tp2) { + this.hsComParam = hsComParam; + this.hsSysParam = tp2.hsSysParam; + this.readAreaPlcHs1 = (Hashtable) hsComParam.get("readAreaPlcHs4_1"); + this.readAreaPlcHs2 = (Hashtable) hsComParam.get("readAreaPlcHs4_2"); + this.readAreaPlcHs2s = (Hashtable) hsComParam.get("readAreaPlcHs4_2s"); + this.readAreaPlcHs3 = (Hashtable) hsComParam.get("readAreaPlcHs4_3"); + this.readAreaPlcHs4 = (Hashtable) hsComParam.get("readAreaPlcHs4_4"); + this.readAreaPlcHs5 = (Hashtable) hsComParam.get("readAreaPlcHs4_5"); + this.readAreaPlcHs6 = (Hashtable) hsComParam.get("readAreaPlcHs4_6"); + this.readAreaPlcHs7 = (Hashtable) hsComParam.get("readAreaPlcHs4_7"); + this.readAreaPlcHs8 = (Hashtable) hsComParam.get("readAreaPlcHs4_8"); + this.readAreaPlcHs9 = (Hashtable) hsComParam.get("readAreaPlcHs4_9"); + this.readAreaPlcHs10 = (Hashtable) hsComParam.get("readAreaPlcHs4_10"); + this.readAreaPlcHs11 = (Hashtable) hsComParam.get("readAreaPlcHs4_11"); + this.readAreaPlcHs12 = (Hashtable) hsComParam.get("readAreaPlcHs4_12"); + this.readAreaPlcHs13 = (Hashtable) hsComParam.get("readAreaPlcHs4_13"); + this.readAreaPlcHs14 = (Hashtable) hsComParam.get("readAreaPlcHs4_14"); + this.readAreaPlcHs15 = (Hashtable) hsComParam.get("readAreaPlcHs4_15"); + this.readAreaPlcHs16 = (Hashtable) hsComParam.get("readAreaPlcHs4_16"); + this.readAreaPlcHs17 = (Hashtable) hsComParam.get("readAreaPlcHs4_17"); + this.readAreaPlcHs18 = (Hashtable) hsComParam.get("readAreaPlcHs4_18"); + this.readAreaPlcHs19 = (Hashtable) hsComParam.get("readAreaPlcHs4_19"); + this.client = tp2; + } + + public void run() { + Iterator iterobj; + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.setCaretPosition( + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.getText().length() + - 20); + try { + + if (readAreaPlcHs1 != null) { + iterobj = readAreaPlcHs1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs2 != null) { + iterobj = readAreaPlcHs2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs2s != null) { + iterobj = readAreaPlcHs2s.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_2s(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs3 != null) { + iterobj = readAreaPlcHs3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs4 != null) { + iterobj = readAreaPlcHs4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs5 != null) { + iterobj = readAreaPlcHs5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs6 != null) { + iterobj = readAreaPlcHs6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs7 != null) { + iterobj = readAreaPlcHs7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs8 != null) { + iterobj = readAreaPlcHs8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs9 != null) { + iterobj = readAreaPlcHs9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + //System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs10 != null) { + iterobj = readAreaPlcHs10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + //ÒÔÏÂΪ»ñÈ¡²ð¶â»úÐÅÏ¢ + if (readAreaPlcHs11 != null) { + iterobj = readAreaPlcHs11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs12 != null) { + iterobj = readAreaPlcHs12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs13 != null) { + iterobj = readAreaPlcHs13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs14 != null) { + iterobj = readAreaPlcHs14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + }if (readAreaPlcHs15 != null) { + iterobj = readAreaPlcHs15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs16 != null) { + iterobj = readAreaPlcHs16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs17 != null) { + iterobj = readAreaPlcHs17.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_17(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs18 != null) { + iterobj = readAreaPlcHs18.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_18(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs19 != null) { + iterobj = readAreaPlcHs19.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + // System.out.println("------------------·Ö¸îÏß-------------------"); + plcVar.analysisDb4_19(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + // + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer171.java b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer171.java new file mode 100644 index 0000000..34c6120 --- /dev/null +++ b/src/org/s7/standard/ynuo/ReadPlcDBAnalyServer171.java @@ -0,0 +1,3054 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import org.s7.standard.ynuo.client.IsoTcpClient171; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.common.server.config.DSSTabSel; + +/** + * ¸ÃÏ߳̽«´Ó¡¶¶Á»º´æÇø¡·£¨´Óplc¶ÁÈ¡µ½µÄÊý¾Ý´æ·ÅµÄλÖã©¶¨Ê±Ð´µ½Êý¾Ý¿âÖÐ + * + * @author admin + * + */ +public class ReadPlcDBAnalyServer171 implements Runnable { + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + + public Hashtable readAreaPlcHs50_1 = null; + public Hashtable readAreaPlcHs50_2 = null; + public Hashtable readAreaPlcHs50_3 = null; + public Hashtable readAreaPlcHs50_4 = null; + public Hashtable readAreaPlcHs50_5 = null; + public Hashtable readAreaPlcHs50_6 = null; + public Hashtable readAreaPlcHs50_7 = null; + public Hashtable readAreaPlcHs50_8 = null; + public Hashtable readAreaPlcHs50_9 = null; + public Hashtable readAreaPlcHs50_10 = null; + public Hashtable readAreaPlcHs50_11 = null; + public Hashtable readAreaPlcHs50_12 = null; + public Hashtable readAreaPlcHs50_13 = null; + public Hashtable readAreaPlcHs50_14 = null; + public Hashtable readAreaPlcHs50_15 = null; + public Hashtable readAreaPlcHs50_16 = null; + + public Hashtable readAreaPlcHs49_1 = null; + public Hashtable readAreaPlcHs49_2 = null; + public Hashtable readAreaPlcHs49_3 = null; + public Hashtable readAreaPlcHs49_4 = null; + public Hashtable readAreaPlcHs49_5 = null; + public Hashtable readAreaPlcHs49_6 = null; + public Hashtable readAreaPlcHs49_7 = null; + public Hashtable readAreaPlcHs49_8 = null; + public Hashtable readAreaPlcHs49_9 = null; + public Hashtable readAreaPlcHs49_10 = null; + public Hashtable readAreaPlcHs49_11 = null; + public Hashtable readAreaPlcHs49_12 = null; + public Hashtable readAreaPlcHs49_13 = null; + public Hashtable readAreaPlcHs49_14 = null; + public Hashtable readAreaPlcHs49_15 = null; + public Hashtable readAreaPlcHs49_16 = null; + + + public Hashtable readAreaPlcHs48_1 = null; + public Hashtable readAreaPlcHs48_2 = null; + public Hashtable readAreaPlcHs48_3 = null; + public Hashtable readAreaPlcHs48_4 = null; + public Hashtable readAreaPlcHs48_5 = null; + public Hashtable readAreaPlcHs48_6 = null; + public Hashtable readAreaPlcHs48_7 = null; + public Hashtable readAreaPlcHs48_8 = null; + public Hashtable readAreaPlcHs48_9 = null; + public Hashtable readAreaPlcHs48_10 = null; + public Hashtable readAreaPlcHs48_11 = null; + public Hashtable readAreaPlcHs48_12 = null; + public Hashtable readAreaPlcHs48_13 = null; + public Hashtable readAreaPlcHs48_14 = null; + public Hashtable readAreaPlcHs48_15 = null; + public Hashtable readAreaPlcHs48_16 = null; + + + + public Hashtable readAreaPlcHs47_1 = null; + public Hashtable readAreaPlcHs47_2 = null; + public Hashtable readAreaPlcHs47_3 = null; + public Hashtable readAreaPlcHs47_4 = null; + public Hashtable readAreaPlcHs47_5 = null; + public Hashtable readAreaPlcHs47_6 = null; + public Hashtable readAreaPlcHs47_7 = null; + public Hashtable readAreaPlcHs47_8 = null; + public Hashtable readAreaPlcHs47_9 = null; + public Hashtable readAreaPlcHs47_10 = null; + public Hashtable readAreaPlcHs47_11 = null; + public Hashtable readAreaPlcHs47_12 = null; + public Hashtable readAreaPlcHs47_13 = null; + public Hashtable readAreaPlcHs47_14 = null; + public Hashtable readAreaPlcHs47_15 = null; + public Hashtable readAreaPlcHs47_16 = null; + + public Hashtable readAreaPlcHs46_1 = null; + public Hashtable readAreaPlcHs46_2 = null; + public Hashtable readAreaPlcHs46_3 = null; + public Hashtable readAreaPlcHs46_4 = null; + public Hashtable readAreaPlcHs46_5 = null; + public Hashtable readAreaPlcHs46_6 = null; + public Hashtable readAreaPlcHs46_7 = null; + public Hashtable readAreaPlcHs46_8 = null; + public Hashtable readAreaPlcHs46_9 = null; + public Hashtable readAreaPlcHs46_10 = null; + public Hashtable readAreaPlcHs46_11 = null; + public Hashtable readAreaPlcHs46_12 = null; + public Hashtable readAreaPlcHs46_13 = null; + public Hashtable readAreaPlcHs46_14 = null; + public Hashtable readAreaPlcHs46_15 = null; + public Hashtable readAreaPlcHs46_16 = null; + + + public Hashtable readAreaPlcHs45_1 = null; + public Hashtable readAreaPlcHs45_2 = null; + public Hashtable readAreaPlcHs45_3 = null; + public Hashtable readAreaPlcHs45_4 = null; + public Hashtable readAreaPlcHs45_5 = null; + public Hashtable readAreaPlcHs45_6 = null; + public Hashtable readAreaPlcHs45_7 = null; + public Hashtable readAreaPlcHs45_8 = null; + public Hashtable readAreaPlcHs45_9 = null; + public Hashtable readAreaPlcHs45_10 = null; + public Hashtable readAreaPlcHs45_11 = null; + public Hashtable readAreaPlcHs45_12 = null; + public Hashtable readAreaPlcHs45_13 = null; + public Hashtable readAreaPlcHs45_14 = null; + public Hashtable readAreaPlcHs45_15 = null; + public Hashtable readAreaPlcHs45_16 = null; + + public Hashtable readAreaPlcHs44_1 = null; + public Hashtable readAreaPlcHs44_2 = null; + public Hashtable readAreaPlcHs44_3 = null; + public Hashtable readAreaPlcHs44_4 = null; + public Hashtable readAreaPlcHs44_5 = null; + public Hashtable readAreaPlcHs44_6 = null; + public Hashtable readAreaPlcHs44_7 = null; + public Hashtable readAreaPlcHs44_8 = null; + public Hashtable readAreaPlcHs44_9 = null; + public Hashtable readAreaPlcHs44_10 = null; + public Hashtable readAreaPlcHs44_11 = null; + public Hashtable readAreaPlcHs44_12 = null; + public Hashtable readAreaPlcHs44_13 = null; + public Hashtable readAreaPlcHs44_14 = null; + public Hashtable readAreaPlcHs44_15 = null; + public Hashtable readAreaPlcHs44_16 = null; + + public Hashtable readAreaPlcHs43_1 = null; + public Hashtable readAreaPlcHs43_2 = null; + public Hashtable readAreaPlcHs43_3 = null; + public Hashtable readAreaPlcHs43_4 = null; + public Hashtable readAreaPlcHs43_5 = null; + public Hashtable readAreaPlcHs43_6 = null; + public Hashtable readAreaPlcHs43_7 = null; + public Hashtable readAreaPlcHs43_8 = null; + public Hashtable readAreaPlcHs43_9 = null; + public Hashtable readAreaPlcHs43_10 = null; + public Hashtable readAreaPlcHs43_11 = null; + public Hashtable readAreaPlcHs43_12 = null; + public Hashtable readAreaPlcHs43_13 = null; + public Hashtable readAreaPlcHs43_14 = null; + public Hashtable readAreaPlcHs43_15 = null; + public Hashtable readAreaPlcHs43_16 = null; + + + public Hashtable readAreaPlcHs42_1 = null; + public Hashtable readAreaPlcHs42_2 = null; + public Hashtable readAreaPlcHs42_3 = null; + public Hashtable readAreaPlcHs42_4 = null; + public Hashtable readAreaPlcHs42_5 = null; + public Hashtable readAreaPlcHs42_6 = null; + public Hashtable readAreaPlcHs42_7 = null; + public Hashtable readAreaPlcHs42_8 = null; + public Hashtable readAreaPlcHs42_9 = null; + public Hashtable readAreaPlcHs42_10 = null; + public Hashtable readAreaPlcHs42_11 = null; + public Hashtable readAreaPlcHs42_12 = null; + public Hashtable readAreaPlcHs42_13 = null; + public Hashtable readAreaPlcHs42_14 = null; + public Hashtable readAreaPlcHs42_15 = null; + public Hashtable readAreaPlcHs42_16 = null; + + + public Hashtable readAreaPlcHs41_1 = null; + public Hashtable readAreaPlcHs41_2 = null; + public Hashtable readAreaPlcHs41_3 = null; + public Hashtable readAreaPlcHs41_4 = null; + public Hashtable readAreaPlcHs41_5 = null; + public Hashtable readAreaPlcHs41_6 = null; + public Hashtable readAreaPlcHs41_7 = null; + public Hashtable readAreaPlcHs41_8 = null; + public Hashtable readAreaPlcHs41_9 = null; + public Hashtable readAreaPlcHs41_10 = null; + public Hashtable readAreaPlcHs41_11 = null; + public Hashtable readAreaPlcHs41_12 = null; + public Hashtable readAreaPlcHs41_13 = null; + public Hashtable readAreaPlcHs41_14 = null; + public Hashtable readAreaPlcHs41_15 = null; + public Hashtable readAreaPlcHs41_16 = null; + + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readDotPlcHs = null; + Hashtable hsSysParam = null; + Hashtable hsComParam = null; + IsoTcpClient171 client = null; + + public EntityDAO dao; + + public ReadPlcDBAnalyServer171(Hashtable hsComParam, IsoTcpClient171 tp) { + this.hsComParam = hsComParam; + this.hsSysParam = tp.hsSysParam; + + this.readAreaPlcHs50_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_1"); + this.readAreaPlcHs50_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_2"); + this.readAreaPlcHs50_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_3"); + this.readAreaPlcHs50_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_4"); + this.readAreaPlcHs50_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_5"); + this.readAreaPlcHs50_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_6"); + this.readAreaPlcHs50_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_7"); + this.readAreaPlcHs50_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_8"); + this.readAreaPlcHs50_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_9"); + this.readAreaPlcHs50_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_10"); + this.readAreaPlcHs50_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_11"); + this.readAreaPlcHs50_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_12"); + this.readAreaPlcHs50_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_13"); + this.readAreaPlcHs50_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_14"); + this.readAreaPlcHs50_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_15"); + this.readAreaPlcHs50_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_16"); + + this.readAreaPlcHs49_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_1"); + this.readAreaPlcHs49_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_2"); + this.readAreaPlcHs49_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_3"); + this.readAreaPlcHs49_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_4"); + this.readAreaPlcHs49_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_5"); + this.readAreaPlcHs49_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_6"); + this.readAreaPlcHs49_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_7"); + this.readAreaPlcHs49_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_8"); + this.readAreaPlcHs49_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_9"); + this.readAreaPlcHs49_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_10"); + this.readAreaPlcHs49_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_11"); + this.readAreaPlcHs49_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_12"); + this.readAreaPlcHs49_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_13"); + this.readAreaPlcHs49_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_14"); + this.readAreaPlcHs49_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_15"); + this.readAreaPlcHs49_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_16"); + + this.readAreaPlcHs48_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_1"); + this.readAreaPlcHs48_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_2"); + this.readAreaPlcHs48_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_3"); + this.readAreaPlcHs48_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_4"); + this.readAreaPlcHs48_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_5"); + this.readAreaPlcHs48_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_6"); + this.readAreaPlcHs48_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_7"); + this.readAreaPlcHs48_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_8"); + this.readAreaPlcHs48_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_9"); + this.readAreaPlcHs48_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_10"); + this.readAreaPlcHs48_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_11"); + this.readAreaPlcHs48_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_12"); + this.readAreaPlcHs48_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_13"); + this.readAreaPlcHs48_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_14"); + this.readAreaPlcHs48_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_15"); + this.readAreaPlcHs48_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_16"); + + this.readAreaPlcHs47_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_1"); + this.readAreaPlcHs47_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_2"); + this.readAreaPlcHs47_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_3"); + this.readAreaPlcHs47_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_4"); + this.readAreaPlcHs47_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_5"); + this.readAreaPlcHs47_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_6"); + this.readAreaPlcHs47_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_7"); + this.readAreaPlcHs47_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_8"); + this.readAreaPlcHs47_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_9"); + this.readAreaPlcHs47_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_10"); + this.readAreaPlcHs47_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_11"); + this.readAreaPlcHs47_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_12"); + this.readAreaPlcHs47_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_13"); + this.readAreaPlcHs47_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_14"); + this.readAreaPlcHs47_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_15"); + this.readAreaPlcHs47_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_16"); + + + + this.readAreaPlcHs46_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_1"); + this.readAreaPlcHs46_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_2"); + this.readAreaPlcHs46_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_3"); + this.readAreaPlcHs46_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_4"); + this.readAreaPlcHs46_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_5"); + this.readAreaPlcHs46_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_6"); + this.readAreaPlcHs46_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_7"); + this.readAreaPlcHs46_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_8"); + this.readAreaPlcHs46_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_9"); + this.readAreaPlcHs46_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_10"); + this.readAreaPlcHs46_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_11"); + this.readAreaPlcHs46_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_12"); + this.readAreaPlcHs46_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_13"); + this.readAreaPlcHs46_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_14"); + this.readAreaPlcHs46_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_15"); + this.readAreaPlcHs46_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_16"); + + + this.readAreaPlcHs45_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_1"); + this.readAreaPlcHs45_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_2"); + this.readAreaPlcHs45_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_3"); + this.readAreaPlcHs45_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_4"); + this.readAreaPlcHs45_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_5"); + this.readAreaPlcHs45_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_6"); + this.readAreaPlcHs45_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_7"); + this.readAreaPlcHs45_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_8"); + this.readAreaPlcHs45_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_9"); + this.readAreaPlcHs45_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_10"); + this.readAreaPlcHs45_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_11"); + this.readAreaPlcHs45_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_12"); + this.readAreaPlcHs45_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_13"); + this.readAreaPlcHs45_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_14"); + this.readAreaPlcHs45_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_15"); + this.readAreaPlcHs45_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_16"); + + this.readAreaPlcHs44_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_1"); + this.readAreaPlcHs44_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_2"); + this.readAreaPlcHs44_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_3"); + this.readAreaPlcHs44_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_4"); + this.readAreaPlcHs44_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_5"); + this.readAreaPlcHs44_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_6"); + this.readAreaPlcHs44_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_7"); + this.readAreaPlcHs44_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_8"); + this.readAreaPlcHs44_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_9"); + this.readAreaPlcHs44_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_10"); + this.readAreaPlcHs44_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_11"); + this.readAreaPlcHs44_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_12"); + this.readAreaPlcHs44_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_13"); + this.readAreaPlcHs44_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_14"); + this.readAreaPlcHs44_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_15"); + this.readAreaPlcHs44_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_16"); + + + this.readAreaPlcHs43_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_1"); + this.readAreaPlcHs43_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_2"); + this.readAreaPlcHs43_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_3"); + this.readAreaPlcHs43_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_4"); + this.readAreaPlcHs43_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_5"); + this.readAreaPlcHs43_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_6"); + this.readAreaPlcHs43_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_7"); + this.readAreaPlcHs43_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_8"); + this.readAreaPlcHs43_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_9"); + this.readAreaPlcHs43_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_10"); + this.readAreaPlcHs43_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_11"); + this.readAreaPlcHs43_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_12"); + this.readAreaPlcHs43_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_13"); + this.readAreaPlcHs43_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_14"); + this.readAreaPlcHs43_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_15"); + this.readAreaPlcHs43_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_16"); + + + this.readAreaPlcHs42_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_1"); + this.readAreaPlcHs42_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_2"); + this.readAreaPlcHs42_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_3"); + this.readAreaPlcHs42_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_4"); + this.readAreaPlcHs42_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_5"); + this.readAreaPlcHs42_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_6"); + this.readAreaPlcHs42_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_7"); + this.readAreaPlcHs42_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_8"); + this.readAreaPlcHs42_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_9"); + this.readAreaPlcHs42_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_10"); + this.readAreaPlcHs42_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_11"); + this.readAreaPlcHs42_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_12"); + this.readAreaPlcHs42_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_13"); + this.readAreaPlcHs42_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_14"); + this.readAreaPlcHs42_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_15"); + this.readAreaPlcHs42_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_16"); + + this.readAreaPlcHs41_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_1"); + this.readAreaPlcHs41_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_2"); + this.readAreaPlcHs41_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_3"); + this.readAreaPlcHs41_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_4"); + this.readAreaPlcHs41_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_5"); + this.readAreaPlcHs41_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_6"); + this.readAreaPlcHs41_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_7"); + this.readAreaPlcHs41_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_8"); + this.readAreaPlcHs41_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_9"); + this.readAreaPlcHs41_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_10"); + this.readAreaPlcHs41_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_11"); + this.readAreaPlcHs41_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_12"); + this.readAreaPlcHs41_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_13"); + this.readAreaPlcHs41_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_14"); + this.readAreaPlcHs41_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_15"); + this.readAreaPlcHs41_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_16"); + + this.client = tp; + } + + public void run() { + + Iterator iterobj; + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.setCaretPosition( + ((DSSTabSel) (((ArrayList) hsSysParam.get("DSSTabSel")).get(0))).jTextArea.getText().length() + - 20); + try { + + if (readAreaPlcHs50_1 != null) { + iterobj = readAreaPlcHs50_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs50_2 != null) { + iterobj = readAreaPlcHs50_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_3 != null) { + iterobj = readAreaPlcHs50_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs50_4 != null) { + iterobj = readAreaPlcHs50_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_5 != null) { + iterobj = readAreaPlcHs50_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_6 != null) { + iterobj = readAreaPlcHs50_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs50_7 != null) { + iterobj = readAreaPlcHs50_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_8 != null) { + iterobj = readAreaPlcHs50_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_9 != null) { + iterobj = readAreaPlcHs50_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_10 != null) { + iterobj = readAreaPlcHs50_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_11 != null) { + iterobj = readAreaPlcHs50_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_12 != null) { + iterobj = readAreaPlcHs50_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs50_13 != null) { + iterobj = readAreaPlcHs50_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_14 != null) { + iterobj = readAreaPlcHs50_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs50_15 != null) { + iterobj = readAreaPlcHs50_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs50_16 != null) { + iterobj = readAreaPlcHs50_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb50_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + //---------------------------------------- + if (readAreaPlcHs49_1 != null) { + iterobj = readAreaPlcHs49_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs49_2 != null) { + iterobj = readAreaPlcHs49_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_3 != null) { + iterobj = readAreaPlcHs49_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs49_4 != null) { + iterobj = readAreaPlcHs49_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_5 != null) { + iterobj = readAreaPlcHs49_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_6 != null) { + iterobj = readAreaPlcHs49_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs49_7 != null) { + iterobj = readAreaPlcHs49_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_8 != null) { + iterobj = readAreaPlcHs49_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_9 != null) { + iterobj = readAreaPlcHs49_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_10 != null) { + iterobj = readAreaPlcHs49_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_11 != null) { + iterobj = readAreaPlcHs49_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_12 != null) { + iterobj = readAreaPlcHs49_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs49_13 != null) { + iterobj = readAreaPlcHs49_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_14 != null) { + iterobj = readAreaPlcHs49_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs49_15 != null) { + iterobj = readAreaPlcHs49_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs49_16 != null) { + iterobj = readAreaPlcHs49_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb49_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + //=========================================================== + if (readAreaPlcHs48_1 != null) { + iterobj = readAreaPlcHs48_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs48_2 != null) { + iterobj = readAreaPlcHs48_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_3 != null) { + iterobj = readAreaPlcHs48_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs48_4 != null) { + iterobj = readAreaPlcHs48_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_5 != null) { + iterobj = readAreaPlcHs48_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_6 != null) { + iterobj = readAreaPlcHs48_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs48_7 != null) { + iterobj = readAreaPlcHs48_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_8 != null) { + iterobj = readAreaPlcHs48_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_9 != null) { + iterobj = readAreaPlcHs48_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_10 != null) { + iterobj = readAreaPlcHs48_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_11 != null) { + iterobj = readAreaPlcHs48_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_12 != null) { + iterobj = readAreaPlcHs48_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs48_13 != null) { + iterobj = readAreaPlcHs48_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_14 != null) { + iterobj = readAreaPlcHs48_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs48_15 != null) { + iterobj = readAreaPlcHs48_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs48_16 != null) { + iterobj = readAreaPlcHs48_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb48_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + + //=========================================================== + if (readAreaPlcHs47_1 != null) { + iterobj = readAreaPlcHs47_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs47_2 != null) { + iterobj = readAreaPlcHs47_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_3 != null) { + iterobj = readAreaPlcHs47_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs47_4 != null) { + iterobj = readAreaPlcHs47_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_5 != null) { + iterobj = readAreaPlcHs47_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_6 != null) { + iterobj = readAreaPlcHs47_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs47_7 != null) { + iterobj = readAreaPlcHs47_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_8 != null) { + iterobj = readAreaPlcHs47_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_9 != null) { + iterobj = readAreaPlcHs47_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_10 != null) { + iterobj = readAreaPlcHs47_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_11 != null) { + iterobj = readAreaPlcHs47_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_12 != null) { + iterobj = readAreaPlcHs47_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs47_13 != null) { + iterobj = readAreaPlcHs47_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_14 != null) { + iterobj = readAreaPlcHs47_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs47_15 != null) { + iterobj = readAreaPlcHs47_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs47_16 != null) { + iterobj = readAreaPlcHs47_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb47_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + //=========================================================== + if (readAreaPlcHs46_1 != null) { + iterobj = readAreaPlcHs46_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs46_2 != null) { + iterobj = readAreaPlcHs46_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_3 != null) { + iterobj = readAreaPlcHs46_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs46_4 != null) { + iterobj = readAreaPlcHs46_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_5 != null) { + iterobj = readAreaPlcHs46_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_6 != null) { + iterobj = readAreaPlcHs46_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs46_7 != null) { + iterobj = readAreaPlcHs46_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_8 != null) { + iterobj = readAreaPlcHs46_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_9 != null) { + iterobj = readAreaPlcHs46_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_10 != null) { + iterobj = readAreaPlcHs46_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_11 != null) { + iterobj = readAreaPlcHs46_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_12 != null) { + iterobj = readAreaPlcHs46_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs46_13 != null) { + iterobj = readAreaPlcHs46_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_14 != null) { + iterobj = readAreaPlcHs46_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs46_15 != null) { + iterobj = readAreaPlcHs46_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs46_16 != null) { + iterobj = readAreaPlcHs46_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb46_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + + + + //=========================================================== + if (readAreaPlcHs45_1 != null) { + iterobj = readAreaPlcHs45_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs45_2 != null) { + iterobj = readAreaPlcHs45_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_3 != null) { + iterobj = readAreaPlcHs45_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs45_4 != null) { + iterobj = readAreaPlcHs45_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_5 != null) { + iterobj = readAreaPlcHs45_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_6 != null) { + iterobj = readAreaPlcHs45_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs45_7 != null) { + iterobj = readAreaPlcHs45_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_8 != null) { + iterobj = readAreaPlcHs45_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_9 != null) { + iterobj = readAreaPlcHs45_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_10 != null) { + iterobj = readAreaPlcHs45_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_11 != null) { + iterobj = readAreaPlcHs45_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_12 != null) { + iterobj = readAreaPlcHs45_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs45_13 != null) { + iterobj = readAreaPlcHs45_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_14 != null) { + iterobj = readAreaPlcHs45_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs45_15 != null) { + iterobj = readAreaPlcHs45_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs45_16 != null) { + iterobj = readAreaPlcHs45_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb45_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + + + //=========================================================== + if (readAreaPlcHs44_1 != null) { + iterobj = readAreaPlcHs44_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs44_2 != null) { + iterobj = readAreaPlcHs44_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_3 != null) { + iterobj = readAreaPlcHs44_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs44_4 != null) { + iterobj = readAreaPlcHs44_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_5 != null) { + iterobj = readAreaPlcHs44_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_6 != null) { + iterobj = readAreaPlcHs44_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs44_7 != null) { + iterobj = readAreaPlcHs44_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_8 != null) { + iterobj = readAreaPlcHs44_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_9 != null) { + iterobj = readAreaPlcHs44_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_10 != null) { + iterobj = readAreaPlcHs44_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_11 != null) { + iterobj = readAreaPlcHs44_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_12 != null) { + iterobj = readAreaPlcHs44_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs44_13 != null) { + iterobj = readAreaPlcHs44_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_14 != null) { + iterobj = readAreaPlcHs44_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs44_15 != null) { + iterobj = readAreaPlcHs44_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs44_16 != null) { + iterobj = readAreaPlcHs44_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb44_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + + + + //=========================================================== + if (readAreaPlcHs43_1 != null) { + iterobj = readAreaPlcHs43_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs43_2 != null) { + iterobj = readAreaPlcHs43_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_3 != null) { + iterobj = readAreaPlcHs43_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs43_4 != null) { + iterobj = readAreaPlcHs43_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_5 != null) { + iterobj = readAreaPlcHs43_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_6 != null) { + iterobj = readAreaPlcHs43_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs43_7 != null) { + iterobj = readAreaPlcHs43_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_8 != null) { + iterobj = readAreaPlcHs43_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_9 != null) { + iterobj = readAreaPlcHs43_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_10 != null) { + iterobj = readAreaPlcHs43_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_11 != null) { + iterobj = readAreaPlcHs43_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_12 != null) { + iterobj = readAreaPlcHs43_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs43_13 != null) { + iterobj = readAreaPlcHs43_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_14 != null) { + iterobj = readAreaPlcHs43_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs43_15 != null) { + iterobj = readAreaPlcHs43_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs43_16 != null) { + iterobj = readAreaPlcHs43_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb43_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + //=========================================================== + if (readAreaPlcHs42_1 != null) { + iterobj = readAreaPlcHs42_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs42_2 != null) { + iterobj = readAreaPlcHs42_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_3 != null) { + iterobj = readAreaPlcHs42_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs42_4 != null) { + iterobj = readAreaPlcHs42_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_5 != null) { + iterobj = readAreaPlcHs42_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_6 != null) { + iterobj = readAreaPlcHs42_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs42_7 != null) { + iterobj = readAreaPlcHs42_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_8 != null) { + iterobj = readAreaPlcHs42_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_9 != null) { + iterobj = readAreaPlcHs42_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_10 != null) { + iterobj = readAreaPlcHs42_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_11 != null) { + iterobj = readAreaPlcHs42_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_12 != null) { + iterobj = readAreaPlcHs42_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs42_13 != null) { + iterobj = readAreaPlcHs42_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_14 != null) { + iterobj = readAreaPlcHs42_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs42_15 != null) { + iterobj = readAreaPlcHs42_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs42_16 != null) { + iterobj = readAreaPlcHs42_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb42_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + //=========================================================== + if (readAreaPlcHs41_1 != null) { + iterobj = readAreaPlcHs41_1.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_1(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs41_2 != null) { + iterobj = readAreaPlcHs41_2.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_2(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_3 != null) { + iterobj = readAreaPlcHs41_3.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_3(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs41_4 != null) { + iterobj = readAreaPlcHs41_4.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_4(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_5 != null) { + iterobj = readAreaPlcHs41_5.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_5(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_6 != null) { + iterobj = readAreaPlcHs41_6.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_6(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs41_7 != null) { + iterobj = readAreaPlcHs41_7.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_7(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_8 != null) { + iterobj = readAreaPlcHs41_8.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_8(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_9 != null) { + iterobj = readAreaPlcHs41_9.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_9(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_10 != null) { + iterobj = readAreaPlcHs41_10.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_10(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_11 != null) { + iterobj = readAreaPlcHs41_11.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_11(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_12 != null) { + iterobj = readAreaPlcHs41_12.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_12(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs41_13 != null) { + iterobj = readAreaPlcHs41_13.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_13(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_14 != null) { + iterobj = readAreaPlcHs41_14.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_14(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + if (readAreaPlcHs41_15 != null) { + iterobj = readAreaPlcHs41_15.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_15(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + if (readAreaPlcHs41_16 != null) { + iterobj = readAreaPlcHs41_16.entrySet().iterator(); + while (iterobj.hasNext()) { + Map.Entry entry = (Map.Entry) iterobj.next(); + ReadAreaPlcInterface plcVar = (ReadAreaPlcInterface) entry.getValue(); + if (client != null && client.IsConnect()) { + try { + + plcVar.analysisDb41_16(); + } catch (Exception ex) { + } + } else { + break; + } + } + } + + + + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} diff --git a/src/org/s7/standard/ynuo/WriteDotPlcInterface.java b/src/org/s7/standard/ynuo/WriteDotPlcInterface.java new file mode 100644 index 0000000..94fd9ba --- /dev/null +++ b/src/org/s7/standard/ynuo/WriteDotPlcInterface.java @@ -0,0 +1,155 @@ +package org.s7.standard.ynuo; + +import java.util.ArrayList; +import java.util.List; +import org.libnodave.Nodave; +import com.ricosoft.common.logger.Logger; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * ½«Êý¾ÝдÈëµ½PLC»º´æÖÐ £¨±ê×¼Àࣩ + * + * @author admin + */ +public class WriteDotPlcInterface implements PlcInterface { + /* ×¢£ºÖ¸ÁîÀàÐÍ+ÀàÐÍÖµ ÊÇΨһµÄ */ + /* Ö¸ÁîÀàÐÍ */ + public String cmdtype = ""; + /* ÀàÐÍÖµ */ + public String cmdvalue = ""; + /* дÈëÍê³É±êʶ */ + public volatile boolean bflag = false; + + /* ½«Êý¾Ý¿âÖеÄÊý¾Ý¶ÁÈ¡µ½Ð´ÈëlsWriteGroupPlcÖÐ Ö»Óе±lsWriteGroupPlc.size()Ϊ0ʱ£¬²ÅÐèÒª´ÓÊý¾Ý¿âÖжÁÈ¡ */ + public List lsWriteGroupPlc = new ArrayList(); + + public WriteDotPlcInterface(String cmdtype, String cmdvalue) { + this.cmdtype = cmdtype; + this.cmdvalue = cmdvalue; + } + + public WriteDotPlcInterface() { + super(); + } + + /* ´ÓÊý¾Ý¿âÖжÁÈ¡Ïà¹ØµÄÖ¸ÁÉú³ÉPLC¿Éʶ±ðµÄÖ¸ÁWritePlcInterface.groupPlcObj£© */ + public int Analysis(String json) { + int back_msg = -1; + if (lsWriteGroupPlc != null && lsWriteGroupPlc.size() < 1) { + try { + JSONArray content = JSONArray.fromObject(json); + if (content != null && content.size() > 0) {// ½âÎöÊý¾ÝÌå + bflag = false;// дÈ뿪ʼ + for (int i = 0; i < content.size(); i++) { + JSONObject jo = content.getJSONObject(i); + WriteDotPlcInterface.groupPlcObj group = new WriteDotPlcInterface.groupPlcObj(); + group.DBnum = jo.getInt("DBnum"); + group.dtype = jo.getInt("dtype"); + group.len = jo.getInt("len"); + group.start = jo.getInt("start"); + group.value = jo.get("value"); + group.buffer = group.getBuffer(group.value, group.dtype, group.len); + lsWriteGroupPlc.add(group); + } + } + back_msg = 1;// ÍÆËͳɹ¦ + } catch (Exception e) { + Logger.error("дÈëÖ¸Áî" + json + "Òì³£" + e.getMessage()); + } finally { + bflag = true;// дÈëÍê³É + } + } + return back_msg; + } + + public class groupPlcObj { + int area = Nodave.DB; + /* DBºÅ */ + public int DBnum; + /* ¿ªÊ¼Î»Öà */ + public int start; + /* ×Ö½Ú³¤¶È */ + public int len; + /* Öµ */ + public Object value; + /* ÊýÖµÀàÐÍ */ + public int dtype; + /* ±äÁ¿Ãû³Æ */ + public String name; + /* ֵתΪ×Ö½Ú */ + public byte[] buffer; + + public groupPlcObj() { + } + + public groupPlcObj(int DBnum, int dtype, int len, int start, Object value) { + this.DBnum = DBnum; + this.dtype = dtype; + this.len = len; + this.start = start; + this.value = value; + this.buffer = getBuffer(value, dtype, len); + } + + public int getArea() { + return area; + } + + public int getDBnum() { + return DBnum; + } + + public int getStart() { + return start; + } + + public int getLen() { + return len; + } + + public Object getValue() { + return value; + } + + public int getDtype() { + return dtype; + } + + public String getName() { + return name; + } + + public byte[] getBuffer() { + return buffer; + } + + /** + * @param value + * ת»»Öµ + * @param dtype + * ÀàÐÍ + * @param len + * ×Ö½ÚÊý + * @return byte[] + */ + public byte[] getBuffer(Object value, int dtype, int len) { + + byte[] buffer = null; + if (dtype == BYTE) { + buffer = Nodave.bswap_8(Byte.parseByte(value.toString())); + } else if (dtype == FLOAT) { + buffer = Nodave.toPLCfloat(Float.parseFloat(value.toString())); + } else if (dtype == INT) { + buffer = Nodave.bswap_16(Integer.parseInt(value.toString())); + } else if (dtype == DINT) { + buffer = Nodave.bswap_32(Integer.parseInt(value.toString())); + } else if (dtype == CHAR) { + buffer = Nodave.bswap_8(Byte.parseByte(value.toString())); + } else if (dtype == STRING) { + buffer = Nodave.bswap_64(Long.parseLong(value.toString())); + } + return buffer; + } + } +} diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient100.java b/src/org/s7/standard/ynuo/client/IsoTcpClient100.java new file mode 100644 index 0000000..61d4061 --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient100.java @@ -0,0 +1,776 @@ +package org.s7.standard.ynuo.client; + +import com.ricosoft.common.logger.Logger; +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.*; + +public class IsoTcpClient100 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHsMD101 = null; + public Hashtable readAreaPlcHsMD102 = null; + public Hashtable readAreaPlcHsMD103 = null; + public Hashtable readAreaPlcHsMD104 = null; + public Hashtable readAreaPlcHsMD105 = null; + public Hashtable readAreaPlcHsMD106 = null; + public Hashtable readAreaPlcHsMD107 = null; + public Hashtable readAreaPlcHsMD108 = null; + public Hashtable readAreaPlcHsMD109 = null; + public Hashtable readAreaPlcHsMD110 = null; +// public Hashtable readAreaPlcHs2 = null; +// public Hashtable readAreaPlcHs3 = null; +// public Hashtable readAreaPlcHs4 = null; +// public Hashtable readAreaPlcHs5 = null; + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + public IsoTcpClient100(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.readAreaPlcHsMD101 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_101"); + this.readAreaPlcHsMD102 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_102"); + this.readAreaPlcHsMD103 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_103"); + this.readAreaPlcHsMD104 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_104"); + this.readAreaPlcHsMD105 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_105"); + this.readAreaPlcHsMD106 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_106"); + this.readAreaPlcHsMD107 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_107"); + this.readAreaPlcHsMD108 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_108"); + this.readAreaPlcHsMD109 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_109"); + this.readAreaPlcHsMD110 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_110"); +// this.readAreaPlcHs2 = (Hashtable) hsComParam.get("readAreaPlcHs1_2"); +// this.readAreaPlcHs3 = (Hashtable) hsComParam.get("readAreaPlcHs1_3"); +// this.readAreaPlcHs4 = (Hashtable) hsComParam.get("readAreaPlcHs1_4"); +// this.readAreaPlcHs5 = (Hashtable) hsComParam.get("readAreaPlcHs1_5"); + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs1"); + this.strIp = (String) hsComParam.get("strIp1"); + this.iPort = (Integer) hsComParam.get("iPort1"); + this.slot = (Integer) hsComParam.get("slot1"); + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + void clearReadDB() { + if (readAreaPlcHsMD101 != null) { + Iterator iterR = readAreaPlcHsMD101.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD102 != null) { + Iterator iterR = readAreaPlcHsMD102.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD103 != null) { + Iterator iterR = readAreaPlcHsMD103.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD104 != null) { + Iterator iterR = readAreaPlcHsMD104.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD105 != null) { + Iterator iterR = readAreaPlcHsMD105.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD106 != null) { + Iterator iterR = readAreaPlcHsMD106.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD107 != null) { + Iterator iterR = readAreaPlcHsMD107.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD108 != null) { + Iterator iterR = readAreaPlcHsMD108.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD109 != null) { + Iterator iterR = readAreaPlcHsMD109.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHsMD110 != null) { + Iterator iterR = readAreaPlcHsMD110.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + } + + void reConnect() { + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + Map.Entry entry = null; + int i = 0; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + // ¶ÁÈ¡DB101¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ + ///Thread.sleep(100); + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss.SSS"); + //System.out.println("101:----" + df.format(t)); + + try { + if (readAreaPlcHsMD101 != null) { + iterR = readAreaPlcHsMD101.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try{ + if (readAreaPlcHsMD102 != null) { + iterR = readAreaPlcHsMD102.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + // System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD103 != null) { + iterR = readAreaPlcHsMD103.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD104 != null) { + iterR = readAreaPlcHsMD104.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD105 != null) { + iterR = readAreaPlcHsMD105.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + // System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD106 != null) { + iterR = readAreaPlcHsMD106.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD107 != null) { + iterR = readAreaPlcHsMD107.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD108 != null) { + iterR = readAreaPlcHsMD108.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD109 != null) { + iterR = readAreaPlcHsMD109.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + + } catch (Exception ex) { + reConnect(); + //ex.printStackTrace(); + } + + try{ + if (readAreaPlcHsMD110 != null) { + iterR = readAreaPlcHsMD110.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + + } catch (Exception ex) { + reConnect(); + //ex.printStackTrace(); + } + + + // дÈëµ½DB¿éÖÐÖ¸¶¨µÄλÖà + try { + if (IsConnect()) { + if (writePlcHs != null) { + t1 = System.currentTimeMillis(); + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½DB101¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + // ÿ´ÎÑ­»·´ò¿ª¹Ø±ÕÁ´½Ó + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + +} \ No newline at end of file diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient101.java b/src/org/s7/standard/ynuo/client/IsoTcpClient101.java new file mode 100644 index 0000000..16724f7 --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient101.java @@ -0,0 +1,804 @@ +package org.s7.standard.ynuo.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.ricosoft.common.logger.Logger; + +public class IsoTcpClient101 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHsMD101 = null; + public Hashtable readAreaPlcHsMD102 = null; + public Hashtable readAreaPlcHsMD103 = null; + public Hashtable readAreaPlcHsMD104 = null; + public Hashtable readAreaPlcHsMD105 = null; + public Hashtable readAreaPlcHsMD106 = null; + public Hashtable readAreaPlcHsMD107 = null; + public Hashtable readAreaPlcHsMD108 = null; + public Hashtable readAreaPlcHsMD109 = null; + public Hashtable readAreaPlcHsMD110 = null; +// public Hashtable readAreaPlcHs2 = null; +// public Hashtable readAreaPlcHs3 = null; +// public Hashtable readAreaPlcHs4 = null; +// public Hashtable readAreaPlcHs5 = null; + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + public IsoTcpClient101(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.readAreaPlcHsMD101 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_101"); + this.readAreaPlcHsMD102 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_102"); + this.readAreaPlcHsMD103 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_103"); + this.readAreaPlcHsMD104 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_104"); + this.readAreaPlcHsMD105 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_105"); + this.readAreaPlcHsMD106 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_106"); + this.readAreaPlcHsMD107 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_107"); + this.readAreaPlcHsMD108 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_108"); + this.readAreaPlcHsMD109 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_109"); + this.readAreaPlcHsMD110 = (Hashtable) hsComParam.get("readAreaPlcHs1MD_110"); +// this.readAreaPlcHs2 = (Hashtable) hsComParam.get("readAreaPlcHs1_2"); +// this.readAreaPlcHs3 = (Hashtable) hsComParam.get("readAreaPlcHs1_3"); +// this.readAreaPlcHs4 = (Hashtable) hsComParam.get("readAreaPlcHs1_4"); +// this.readAreaPlcHs5 = (Hashtable) hsComParam.get("readAreaPlcHs1_5"); + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs1"); + this.strIp = (String) hsComParam.get("strIp1"); + this.iPort = (Integer) hsComParam.get("iPort1"); + this.slot = (Integer) hsComParam.get("slot1"); + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + void clearReadDB() { + if (readAreaPlcHsMD101 != null) { + Iterator iterR = readAreaPlcHsMD101.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD102 != null) { + Iterator iterR = readAreaPlcHsMD102.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD103 != null) { + Iterator iterR = readAreaPlcHsMD103.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD104 != null) { + Iterator iterR = readAreaPlcHsMD104.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD105 != null) { + Iterator iterR = readAreaPlcHsMD105.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD106 != null) { + Iterator iterR = readAreaPlcHsMD106.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD107 != null) { + Iterator iterR = readAreaPlcHsMD107.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD108 != null) { + Iterator iterR = readAreaPlcHsMD108.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHsMD109 != null) { + Iterator iterR = readAreaPlcHsMD109.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHsMD110 != null) { + Iterator iterR = readAreaPlcHsMD110.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + } + + void reConnect() { + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + Map.Entry entry = null; + int i = 0; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + // ¶ÁÈ¡DB101¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ + ///Thread.sleep(100); + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss.SSS"); + //System.out.println("101:----" + df.format(t)); + + try { + if (readAreaPlcHsMD101 != null) { + iterR = readAreaPlcHsMD101.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try{ + if (readAreaPlcHsMD102 != null) { + iterR = readAreaPlcHsMD102.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + // System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD103 != null) { + iterR = readAreaPlcHsMD103.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD104 != null) { + iterR = readAreaPlcHsMD104.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD105 != null) { + iterR = readAreaPlcHsMD105.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + // System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD106 != null) { + iterR = readAreaPlcHsMD106.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD107 != null) { + iterR = readAreaPlcHsMD107.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD108 != null) { + iterR = readAreaPlcHsMD108.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + //System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try{ + if (readAreaPlcHsMD109 != null) { + iterR = readAreaPlcHsMD109.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + + } catch (Exception ex) { + reConnect(); + //ex.printStackTrace(); + } + + try{ + if (readAreaPlcHsMD110 != null) { + iterR = readAreaPlcHsMD110.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + + } catch (Exception ex) { + reConnect(); + //ex.printStackTrace(); + } + + + // дÈëµ½DB¿éÖÐÖ¸¶¨µÄλÖà + try { + if (IsConnect()) { + if (writePlcHs != null) { + t1 = System.currentTimeMillis(); + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½DB101¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + // ÿ´ÎÑ­»·´ò¿ª¹Ø±ÕÁ´½Ó + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + public static void main(String arg[]) { + byte[] ss = new byte[5]; + ss[0] = 1; + ss[1] = 0; + ss[2] = 16; + ss[3] = 0; + ss[4] = 0; + int length = ss.length; + for (int i = ss.length - 1; i > 0; i--) { + if (ss[i] != 0) { + length = i + 1; + break; + } + } + + // ¶ÁÈ¡Á÷03 00 00 2B 02 F0 80 32 03 00 00 00 00 00 02 00 16 00 00 04 01 FF + // 04 00 90 + // 89 02 00 80 37 01 02 37 01 00 18 5E 03 78 05 02 03 + byte[] ssz = Nodave.bswap_16(6238);// 18 5E ÈÎÎñºÅ + System.out.println(printHexString(ssz, ssz.length)); + byte[] msgIn = new byte[90]; + msgIn[10] = (byte) 0x18; // µÚ36 + msgIn[11] = (byte) 0x5E; // µÚ37 + System.out.println(Nodave.SBEWord(msgIn, 10)); + } +} \ No newline at end of file diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient102.java b/src/org/s7/standard/ynuo/client/IsoTcpClient102.java new file mode 100644 index 0000000..ee440e3 --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient102.java @@ -0,0 +1,860 @@ +/* + Test and demo program for Libnodave, a free communication libray for Siemens S7. + + ********************************************************************** + * WARNING: This and other test programs overwrite data in your PLC. * + * DO NOT use it on PLC's when anything is connected to their outputs.* + * This is alpha software. Use entirely on your own risk. * + ********************************************************************** + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002, 2004. + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with Visual; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.s7.standard.ynuo.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.ReadDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.ricosoft.common.logger.Logger; + +public class IsoTcpClient102 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + // String strIp2 = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + // int iPort2 = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + // int slot2 = 1; + PLCinterface di; + // PLCinterface di2; + TCPConnection dc; + // TCPConnection dc2; + /* socket¿Í»§¶Ë */ + Socket sock; + // Socket sock2; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + // OutputStream oStream2 = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + // InputStream iStream2 = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs101 = null; + public Hashtable readAreaPlcHs102 = null; + public Hashtable readAreaPlcHs104 = null; + public Hashtable readAreaPlcHs105 = null; + public Hashtable readAreaPlcHs106 = null; + public Hashtable readAreaPlcHs107 = null; + public Hashtable readAreaPlcHs103 = null; + public Hashtable readAreaPlcHs105_2 = null; + public Hashtable readAreaPlcHs151 = null; + + public Hashtable readAreaPlcHs108 = null; + /* ´æ·Å¶ÁÈ¡µÄDBÉ¢×Ö½ÚÐÅÏ¢ */ + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + public IsoTcpClient102(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + + this.readAreaPlcHs104 = (Hashtable) hsComParam.get("readAreaPlcHsDB104"); + this.readAreaPlcHs102 = (Hashtable) hsComParam.get("readAreaPlcHsDB102"); + this.readAreaPlcHs101 = (Hashtable) hsComParam.get("readAreaPlcHsDB101"); + + this.readAreaPlcHs106 = (Hashtable) hsComParam.get("readAreaPlcHsDB106"); + this.readAreaPlcHs107 = (Hashtable) hsComParam.get("readAreaPlcHsDB107"); + this.readAreaPlcHs103 = (Hashtable) hsComParam.get("readAreaPlcHsDB103"); + this.readAreaPlcHs105 = (Hashtable) hsComParam.get("readAreaPlcHsDB105"); + this.readAreaPlcHs105_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB105_2"); + + this.readAreaPlcHs151 = (Hashtable) hsComParam.get("readAreaPlcHsDB151"); + + this.readAreaPlcHs108 = (Hashtable) hsComParam.get("readAreaPlcHsDB108"); + + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs2"); + this.strIp = (String) hsComParam.get("strIp2"); + this.iPort = (Integer) hsComParam.get("iPort2"); + this.slot = (Integer) hsComParam.get("slot2"); + + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + @SuppressWarnings("rawtypes") + void clearReadDB() { + + if (readAreaPlcHs101 != null) { + Iterator iterR = readAreaPlcHs101.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs102 != null) { + Iterator iterR = readAreaPlcHs102.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs104 != null) { + + Iterator iterR = readAreaPlcHs104.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs105 != null) { + Iterator iterR = readAreaPlcHs105.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs106 != null) { + Iterator iterR = readAreaPlcHs106.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs107 != null) { + Iterator iterR = readAreaPlcHs107.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs105_2 != null) { + Iterator iterR = readAreaPlcHs105_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs103 != null) { + Iterator iterR = readAreaPlcHs103.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs151 != null) { + Iterator iterR = readAreaPlcHs151.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + //2021-2-10 + if (readAreaPlcHs108 != null) { + Iterator iterR = readAreaPlcHs108.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + } + + void reConnect() { + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + ReadDotPlcInterface plcRDotVar = null; + Map.Entry entry = null; + int i = 0, j = 0; + boolean ReConn = false; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + //Thread.sleep(200); + + + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); + //System.out.println("102:----" + df.format(t)); + // ¶ÁÈ¡DB101¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ + + try{ + if (readAreaPlcHs105_2 != null) { + iterR = readAreaPlcHs105_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs107 != null) { + iterR = readAreaPlcHs107.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs103 != null) { + iterR = readAreaPlcHs103.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs106 != null) { + iterR = readAreaPlcHs106.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs101 != null) { + iterR = readAreaPlcHs101.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs102 != null) { + iterR = readAreaPlcHs102.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs104 != null) { + iterR = readAreaPlcHs104.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs105 != null) { + iterR = readAreaPlcHs105.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs105_2 != null) { + iterR = readAreaPlcHs105_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + try{ + if (readAreaPlcHs151 != null) { + iterR = readAreaPlcHs151.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + + } catch (Exception ex) { + reConnect(); + } + + try { + if (IsConnect()) { + if (writePlcHs != null) { + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½DB"+group.getDBnum()+"¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + //2021-2-10 + try{ + if (readAreaPlcHs108 != null) { + iterR = readAreaPlcHs108.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + + + + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + public static void main(String arg[]) { + byte[] ss = new byte[5]; + ss[0] = 1; + ss[1] = 0; + ss[2] = 16; + ss[3] = 0; + ss[4] = 0; + int length = ss.length; + for (int i = ss.length - 1; i > 0; i--) { + if (ss[i] != 0) { + length = i + 1; + break; + } + } + + // ¶ÁÈ¡Á÷03 00 00 2B 02 F0 80 32 03 00 00 00 00 00 02 00 16 00 00 04 01 FF + // 04 00 90 + // 89 02 00 80 37 01 02 37 01 00 18 5E 03 78 05 02 03 + byte[] ssz = Nodave.bswap_16(6238);// 18 5E ÈÎÎñºÅ + System.out.println(printHexString(ssz, ssz.length)); + byte[] msgIn = new byte[90]; + msgIn[10] = (byte) 0x18; // µÚ36 + msgIn[11] = (byte) 0x5E; // µÚ37 + System.out.println(Nodave.SBEWord(msgIn, 10)); + } +} \ No newline at end of file diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient103.java b/src/org/s7/standard/ynuo/client/IsoTcpClient103.java new file mode 100644 index 0000000..b9d0f63 --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient103.java @@ -0,0 +1,371 @@ +/* + Test and demo program for Libnodave, a free communication libray for Siemens S7. + + ********************************************************************** + * WARNING: This and other test programs overwrite data in your PLC. * + * DO NOT use it on PLC's when anything is connected to their outputs.* + * This is alpha software. Use entirely on your own risk. * + ********************************************************************** + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002, 2004. + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with Visual; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.s7.standard.ynuo.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.PlcBus; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.ReadDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.ricosoft.common.logger.Logger; + +public class IsoTcpClient103 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs201 = null; + public Hashtable readAreaPlcHs202 = null; + public Hashtable readAreaPlcHs203 = null; + public Hashtable readAreaPlcHs204 = null; + public Hashtable readAreaPlcHs205 = null; + public Hashtable readAreaPlcHs206 = null; + public Hashtable readAreaPlcHs207 = null; + public Hashtable readAreaPlcHs208 = null; + public Hashtable readAreaPlcHs209 = null; + public Hashtable readAreaPlcHs210 = null; + public Hashtable readAreaPlcHs211 = null; + public Hashtable readAreaPlcHs212 = null; + public Hashtable readAreaPlcHs213 = null; + public Hashtable readAreaPlcHs214 = null; + public Hashtable readAreaPlcHs215 = null; + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + // public Hashtable writePlcHs2 = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + @SuppressWarnings("unchecked") + public IsoTcpClient103(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.readAreaPlcHs201 = (Hashtable) hsComParam.get("readAreaPlcHsDB201"); + this.readAreaPlcHs202 = (Hashtable) hsComParam.get("readAreaPlcHsDB202"); + this.readAreaPlcHs203 = (Hashtable) hsComParam.get("readAreaPlcHsDB203"); + this.readAreaPlcHs204 = (Hashtable) hsComParam.get("readAreaPlcHsDB204"); + this.readAreaPlcHs205 = (Hashtable) hsComParam.get("readAreaPlcHsDB205"); + this.readAreaPlcHs206 = (Hashtable) hsComParam.get("readAreaPlcHsDB206"); + this.readAreaPlcHs207 = (Hashtable) hsComParam.get("readAreaPlcHsDB207"); + this.readAreaPlcHs208 = (Hashtable) hsComParam.get("readAreaPlcHsDB208"); + this.readAreaPlcHs209 = (Hashtable) hsComParam.get("readAreaPlcHsDB209"); + this.readAreaPlcHs210 = (Hashtable) hsComParam.get("readAreaPlcHsDB210"); + this.readAreaPlcHs211 = (Hashtable) hsComParam.get("readAreaPlcHsDB211"); + this.readAreaPlcHs212 = (Hashtable) hsComParam.get("readAreaPlcHsDB212"); + this.readAreaPlcHs213 = (Hashtable) hsComParam.get("readAreaPlcHsDB213"); + this.readAreaPlcHs214 = (Hashtable) hsComParam.get("readAreaPlcHsDB214"); + this.readAreaPlcHs215 = (Hashtable) hsComParam.get("readAreaPlcHsDB215"); + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs3"); + this.strIp = (String) hsComParam.get("strIp3"); + this.iPort = (Integer) hsComParam.get("iPort3"); + this.slot = (Integer) hsComParam.get("slot3"); + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + void clearReadDB() { + + for (int i = 201; i <= 215; i++) { + Hashtable readAreaPlcHs = null; + readAreaPlcHs = (Hashtable) hsComParam.get("readAreaPlcHsDB"+i); + if (readAreaPlcHs != null) { + Iterator iterR = readAreaPlcHs.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + } + + + } + + void reConnect() { + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + ReadDotPlcInterface plcRDotVar = null; + Map.Entry entry = null; + int i = 0, j = 0; + boolean ReConn = false; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + //Thread.sleep(300); + + + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); + //System.out.println("103:----" + df.format(t)); + // ¶ÁÈ¡DB101¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ + try { + for (int dbk =201; dbk <=215; dbk++) { + Hashtable readAreaPlcHs = null; + readAreaPlcHs = (Hashtable) hsComParam.get("readAreaPlcHsDB"+dbk); + try{ + if (readAreaPlcHs != null) { + iterR = readAreaPlcHs.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + // Logger.info("¶ÁÈ¡DB" + + // plcRVar.DBnum + ",start" + + // plcRVar.start + ",len" + // + plcRVar.len + "\n¶ÁÈ¡Á÷" + + // printHexString(dc.getMsgIn(), + // length)); + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + } + } catch (Exception ex) { + reConnect(); + } + + // дÈëµ½DB¿éÖÐÖ¸¶¨µÄλÖà + try { + if (IsConnect()) { + if (writePlcHs != null) { + t1 = System.currentTimeMillis(); + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½"+ group.getDBnum() +"¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + // ÿ´ÎÑ­»·´ò¿ª¹Ø±ÕÁ´½Ó + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + public static void main(String arg[]) { + byte[] ss = new byte[5]; + ss[0] = 1; + ss[1] = 0; + ss[2] = 16; + ss[3] = 0; + ss[4] = 0; + int length = ss.length; + for (int i = ss.length - 1; i > 0; i--) { + if (ss[i] != 0) { + length = i + 1; + break; + } + } + + // ¶ÁÈ¡Á÷03 00 00 2B 02 F0 80 32 03 00 00 00 00 00 02 00 16 00 00 04 01 FF + // 04 00 90 + // 89 02 00 80 37 01 02 37 01 00 18 5E 03 78 05 02 03 + byte[] ssz = Nodave.bswap_16(6238);// 18 5E ÈÎÎñºÅ + System.out.println(printHexString(ssz, ssz.length)); + byte[] msgIn = new byte[90]; + msgIn[10] = (byte) 0x18; // µÚ36 + msgIn[11] = (byte) 0x5E; // µÚ37 + System.out.println(Nodave.SBEWord(msgIn, 10)); + } +} \ No newline at end of file diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient104.java b/src/org/s7/standard/ynuo/client/IsoTcpClient104.java new file mode 100644 index 0000000..3da3a75 --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient104.java @@ -0,0 +1,1371 @@ +/* + Test and demo program for Libnodave, a free communication libray for Siemens S7. + + ********************************************************************** + * WARNING: This and other test programs overwrite data in your PLC. * + * DO NOT use it on PLC's when anything is connected to their outputs.* + * This is alpha software. Use entirely on your own risk. * + ********************************************************************** + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002, 2004. + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with Visual; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.s7.standard.ynuo.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.ReadDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.ricosoft.common.logger.Logger; + +public class IsoTcpClient104 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + // Socket sock2; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs1 = null; + public Hashtable readAreaPlcHs2 = null; + public Hashtable readAreaPlcHs2s = null; + public Hashtable readAreaPlcHs3 = null; + public Hashtable readAreaPlcHs4 = null; + public Hashtable readAreaPlcHs5 = null; + public Hashtable readAreaPlcHs6 = null; + public Hashtable readAreaPlcHs7 = null; + public Hashtable readAreaPlcHs8 = null; + public Hashtable readAreaPlcHs9 = null; + public Hashtable readAreaPlcHs10 = null; + + public Hashtable readAreaPlcHs11 = null; + public Hashtable readAreaPlcHs12 = null; + public Hashtable readAreaPlcHs13 = null; + public Hashtable readAreaPlcHs14 = null; + public Hashtable readAreaPlcHs15 = null; + public Hashtable readAreaPlcHs16 = null; + public Hashtable readAreaPlcHs17 = null; + public Hashtable readAreaPlcHs18 = null; + public Hashtable readAreaPlcHs19 = null; + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + public IsoTcpClient104(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.readAreaPlcHs1 = (Hashtable) hsComParam.get("readAreaPlcHs4_1"); + this.readAreaPlcHs2 = (Hashtable) hsComParam.get("readAreaPlcHs4_2"); + this.readAreaPlcHs2s = (Hashtable) hsComParam.get("readAreaPlcHs4_2s"); + this.readAreaPlcHs3 = (Hashtable) hsComParam.get("readAreaPlcHs4_3"); + this.readAreaPlcHs4 = (Hashtable) hsComParam.get("readAreaPlcHs4_4"); + this.readAreaPlcHs5 = (Hashtable) hsComParam.get("readAreaPlcHs4_5"); + this.readAreaPlcHs6 = (Hashtable) hsComParam.get("readAreaPlcHs4_6"); + this.readAreaPlcHs7 = (Hashtable) hsComParam.get("readAreaPlcHs4_7"); + this.readAreaPlcHs8 = (Hashtable) hsComParam.get("readAreaPlcHs4_8"); + this.readAreaPlcHs9 = (Hashtable) hsComParam.get("readAreaPlcHs4_9"); + this.readAreaPlcHs10 = (Hashtable) hsComParam.get("readAreaPlcHs4_10"); + this.readAreaPlcHs11 = (Hashtable) hsComParam.get("readAreaPlcHs4_11"); + this.readAreaPlcHs12 = (Hashtable) hsComParam.get("readAreaPlcHs4_12"); + this.readAreaPlcHs13 = (Hashtable) hsComParam.get("readAreaPlcHs4_13"); + this.readAreaPlcHs14 = (Hashtable) hsComParam.get("readAreaPlcHs4_14"); + this.readAreaPlcHs15 = (Hashtable) hsComParam.get("readAreaPlcHs4_15"); + this.readAreaPlcHs16 = (Hashtable) hsComParam.get("readAreaPlcHs4_16"); + this.readAreaPlcHs17 = (Hashtable) hsComParam.get("readAreaPlcHs4_17"); + this.readAreaPlcHs18 = (Hashtable) hsComParam.get("readAreaPlcHs4_18"); + this.readAreaPlcHs19= (Hashtable) hsComParam.get("readAreaPlcHs4_19"); + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs4"); + this.strIp = (String) hsComParam.get("strIp4"); + this.iPort = (Integer) hsComParam.get("iPort4"); + this.slot = (Integer) hsComParam.get("slot4"); + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + void clearReadDB() { + + if (readAreaPlcHs1 != null) { + Iterator iterR = readAreaPlcHs1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs2 != null) { + Iterator iterR = readAreaPlcHs2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs2s != null) { + Iterator iterR = readAreaPlcHs2s.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs3 != null) { + Iterator iterR = readAreaPlcHs3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs4 != null) { + Iterator iterR = readAreaPlcHs4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs5 != null) { + Iterator iterR = readAreaPlcHs5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs6 != null) { + Iterator iterR = readAreaPlcHs6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs7 != null) { + Iterator iterR = readAreaPlcHs7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs8 != null) { + Iterator iterR = readAreaPlcHs8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs9 != null) { + Iterator iterR = readAreaPlcHs9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs10 != null) { + Iterator iterR = readAreaPlcHs10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + /// + if (readAreaPlcHs11 != null) { + Iterator iterR = readAreaPlcHs11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs12 != null) { + Iterator iterR = readAreaPlcHs12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs13 != null) { + Iterator iterR = readAreaPlcHs13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs14 != null) { + Iterator iterR = readAreaPlcHs14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs15 != null) { + Iterator iterR = readAreaPlcHs15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs16 != null) { + Iterator iterR = readAreaPlcHs16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs17 != null) { + Iterator iterR = readAreaPlcHs17.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs18 != null) { + Iterator iterR = readAreaPlcHs18.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs19 != null) { + Iterator iterR = readAreaPlcHs19.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + /// + } + + void reConnect() { +// Date t = new Date(); +// SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); +// System.out.println("104:Òì³£---------------reConnect-----------------------------------" + df.format(t)); + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + ReadDotPlcInterface plcRDotVar = null; + Map.Entry entry = null; + int i = 0, j = 0; + boolean ReConn = false; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + //Thread.sleep(400); + + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); + //System.out.println("104:----" + df.format(t)); + try { + if (readAreaPlcHs1 != null) { + iterR = readAreaPlcHs1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs2 != null) { + iterR = readAreaPlcHs2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs2-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try { + if (readAreaPlcHs2s != null) { + iterR = readAreaPlcHs2s.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs2s-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + try { + if (readAreaPlcHs3 != null) { + iterR = readAreaPlcHs3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs3-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs4 != null) { + iterR = readAreaPlcHs4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs4-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs5 != null) { + iterR = readAreaPlcHs5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs5-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs6 != null) { + iterR = readAreaPlcHs6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs6-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + + } + + try { + if (readAreaPlcHs7 != null) { + iterR = readAreaPlcHs7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs7-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs8 != null) { + iterR = readAreaPlcHs8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs8-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs9 != null) { + iterR = readAreaPlcHs9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs9-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs10 != null) { + iterR = readAreaPlcHs10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------10----------------------------------------------" + df.format(t)); + reConnect(); + } + //¶ÁÈ¡²ð¶â»úÐÅÏ¢ + try { + if (readAreaPlcHs11 != null) { + iterR = readAreaPlcHs11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------11----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs12 != null) { + iterR = readAreaPlcHs12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------12----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs13 != null) { + iterR = readAreaPlcHs13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------13----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs14 != null) { + iterR = readAreaPlcHs14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------14----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs15 != null) { + iterR = readAreaPlcHs15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------15----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs16 != null) { + iterR = readAreaPlcHs16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------16----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs17 != null) { + iterR = readAreaPlcHs17.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------17----------------------------------------------" + df.format(t)); + reConnect(); + } + try { + if (readAreaPlcHs18 != null) { + iterR = readAreaPlcHs18.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------18----------------------------------------------" + df.format(t)); + reConnect(); + } + // + try { + if (readAreaPlcHs19 != null) { + iterR = readAreaPlcHs19.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£-------18----------------------------------------------" + df.format(t)); + reConnect(); + } + // + try { + if (IsConnect()) { + if (writePlcHs != null) { + t1 = System.currentTimeMillis(); + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½DB1¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------writePlcHs-----------------------------------" + df.format(t)); + reConnect(); + } + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + public static void main(String arg[]) { + byte[] ss = new byte[5]; + ss[0] = 1; + ss[1] = 0; + ss[2] = 16; + ss[3] = 0; + ss[4] = 0; + int length = ss.length; + for (int i = ss.length - 1; i > 0; i--) { + if (ss[i] != 0) { + length = i + 1; + break; + } + } + + // ¶ÁÈ¡Á÷03 00 00 2B 02 F0 80 32 03 00 00 00 00 00 02 00 16 00 00 04 01 FF + // 04 00 90 + // 89 02 00 80 37 01 02 37 01 00 18 5E 03 78 05 02 03 + byte[] ssz = Nodave.bswap_16(6238);// 18 5E ÈÎÎñºÅ + System.out.println(printHexString(ssz, ssz.length)); + byte[] msgIn = new byte[90]; + msgIn[10] = (byte) 0x18; // µÚ36 + msgIn[11] = (byte) 0x5E; // µÚ37 + System.out.println(Nodave.SBEWord(msgIn, 10)); + } +} \ No newline at end of file diff --git a/src/org/s7/standard/ynuo/client/IsoTcpClient171.java b/src/org/s7/standard/ynuo/client/IsoTcpClient171.java new file mode 100644 index 0000000..5d6e92d --- /dev/null +++ b/src/org/s7/standard/ynuo/client/IsoTcpClient171.java @@ -0,0 +1,9204 @@ +/* + Test and demo program for Libnodave, a free communication libray for Siemens S7. + + ********************************************************************** + * WARNING: This and other test programs overwrite data in your PLC. * + * DO NOT use it on PLC's when anything is connected to their outputs.* + * This is alpha software. Use entirely on your own risk. * + ********************************************************************** + + (C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002, 2004. + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with Visual; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package org.s7.standard.ynuo.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.libnodave.Nodave; +import org.libnodave.PLCinterface; +import org.libnodave.TCPConnection; +import org.s7.standard.ynuo.ReadAreaPlcInterface; +import org.s7.standard.ynuo.ReadDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface; +import org.s7.standard.ynuo.WriteDotPlcInterface.groupPlcObj; + +import com.ricosoft.common.logger.Logger; + +public class IsoTcpClient171 extends Thread { + /* ʱ¼ä´Á */ + long t1, t2; + /* ipµØÖ· */ + String strIp = ""; + /* ¶Ë¿ÚºÅ */ + int iPort = 102; + /* ²Û¿ÚºÅ */ + int slot = 1; + PLCinterface di; + TCPConnection dc; + /* socket¿Í»§¶Ë */ + Socket sock; + // Socket sock2; + /* Êä³öÁ÷ */ + OutputStream oStream = null; + /* ÊäÈëÁ÷ */ + InputStream iStream = null; + /* дÈ뻺´æÊý¾Ý */ + byte[] by; + /* ´æ·Å¶ÁÈ¡µÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable readAreaPlcHs50_1 = null; + public Hashtable readAreaPlcHs50_2 = null; + public Hashtable readAreaPlcHs50_3 = null; + public Hashtable readAreaPlcHs50_4 = null; + public Hashtable readAreaPlcHs50_5 = null; + public Hashtable readAreaPlcHs50_6 = null; + public Hashtable readAreaPlcHs50_7 = null; + public Hashtable readAreaPlcHs50_8 = null; + public Hashtable readAreaPlcHs50_9 = null; + public Hashtable readAreaPlcHs50_10 = null; + public Hashtable readAreaPlcHs50_11 = null; + public Hashtable readAreaPlcHs50_12 = null; + public Hashtable readAreaPlcHs50_13 = null; + public Hashtable readAreaPlcHs50_14 = null; + public Hashtable readAreaPlcHs50_15 = null; + public Hashtable readAreaPlcHs50_16 = null; + + public Hashtable readAreaPlcHs49_1 = null; + public Hashtable readAreaPlcHs49_2 = null; + public Hashtable readAreaPlcHs49_3 = null; + public Hashtable readAreaPlcHs49_4 = null; + public Hashtable readAreaPlcHs49_5 = null; + public Hashtable readAreaPlcHs49_6 = null; + public Hashtable readAreaPlcHs49_7 = null; + public Hashtable readAreaPlcHs49_8 = null; + public Hashtable readAreaPlcHs49_9 = null; + public Hashtable readAreaPlcHs49_10 = null; + public Hashtable readAreaPlcHs49_11 = null; + public Hashtable readAreaPlcHs49_12 = null; + public Hashtable readAreaPlcHs49_13 = null; + public Hashtable readAreaPlcHs49_14 = null; + public Hashtable readAreaPlcHs49_15 = null; + public Hashtable readAreaPlcHs49_16 = null; + + + + public Hashtable readAreaPlcHs48_1 = null; + public Hashtable readAreaPlcHs48_2 = null; + public Hashtable readAreaPlcHs48_3 = null; + public Hashtable readAreaPlcHs48_4 = null; + public Hashtable readAreaPlcHs48_5 = null; + public Hashtable readAreaPlcHs48_6 = null; + public Hashtable readAreaPlcHs48_7 = null; + public Hashtable readAreaPlcHs48_8 = null; + public Hashtable readAreaPlcHs48_9 = null; + public Hashtable readAreaPlcHs48_10 = null; + public Hashtable readAreaPlcHs48_11 = null; + public Hashtable readAreaPlcHs48_12 = null; + public Hashtable readAreaPlcHs48_13 = null; + public Hashtable readAreaPlcHs48_14 = null; + public Hashtable readAreaPlcHs48_15 = null; + public Hashtable readAreaPlcHs48_16 = null; + + + + + public Hashtable readAreaPlcHs47_1 = null; + public Hashtable readAreaPlcHs47_2 = null; + public Hashtable readAreaPlcHs47_3 = null; + public Hashtable readAreaPlcHs47_4 = null; + public Hashtable readAreaPlcHs47_5 = null; + public Hashtable readAreaPlcHs47_6 = null; + public Hashtable readAreaPlcHs47_7 = null; + public Hashtable readAreaPlcHs47_8 = null; + public Hashtable readAreaPlcHs47_9 = null; + public Hashtable readAreaPlcHs47_10 = null; + public Hashtable readAreaPlcHs47_11 = null; + public Hashtable readAreaPlcHs47_12 = null; + public Hashtable readAreaPlcHs47_13 = null; + public Hashtable readAreaPlcHs47_14 = null; + public Hashtable readAreaPlcHs47_15 = null; + public Hashtable readAreaPlcHs47_16 = null; + + + + public Hashtable readAreaPlcHs46_1 = null; + public Hashtable readAreaPlcHs46_2 = null; + public Hashtable readAreaPlcHs46_3 = null; + public Hashtable readAreaPlcHs46_4 = null; + public Hashtable readAreaPlcHs46_5 = null; + public Hashtable readAreaPlcHs46_6 = null; + public Hashtable readAreaPlcHs46_7 = null; + public Hashtable readAreaPlcHs46_8 = null; + public Hashtable readAreaPlcHs46_9 = null; + public Hashtable readAreaPlcHs46_10 = null; + public Hashtable readAreaPlcHs46_11 = null; + public Hashtable readAreaPlcHs46_12 = null; + public Hashtable readAreaPlcHs46_13 = null; + public Hashtable readAreaPlcHs46_14 = null; + public Hashtable readAreaPlcHs46_15 = null; + public Hashtable readAreaPlcHs46_16 = null; + + + + public Hashtable readAreaPlcHs45_1 = null; + public Hashtable readAreaPlcHs45_2 = null; + public Hashtable readAreaPlcHs45_3 = null; + public Hashtable readAreaPlcHs45_4 = null; + public Hashtable readAreaPlcHs45_5 = null; + public Hashtable readAreaPlcHs45_6 = null; + public Hashtable readAreaPlcHs45_7 = null; + public Hashtable readAreaPlcHs45_8 = null; + public Hashtable readAreaPlcHs45_9 = null; + public Hashtable readAreaPlcHs45_10 = null; + public Hashtable readAreaPlcHs45_11 = null; + public Hashtable readAreaPlcHs45_12 = null; + public Hashtable readAreaPlcHs45_13 = null; + public Hashtable readAreaPlcHs45_14 = null; + public Hashtable readAreaPlcHs45_15 = null; + public Hashtable readAreaPlcHs45_16 = null; + + + + + public Hashtable readAreaPlcHs44_1 = null; + public Hashtable readAreaPlcHs44_2 = null; + public Hashtable readAreaPlcHs44_3 = null; + public Hashtable readAreaPlcHs44_4 = null; + public Hashtable readAreaPlcHs44_5 = null; + public Hashtable readAreaPlcHs44_6 = null; + public Hashtable readAreaPlcHs44_7 = null; + public Hashtable readAreaPlcHs44_8 = null; + public Hashtable readAreaPlcHs44_9 = null; + public Hashtable readAreaPlcHs44_10 = null; + public Hashtable readAreaPlcHs44_11 = null; + public Hashtable readAreaPlcHs44_12 = null; + public Hashtable readAreaPlcHs44_13 = null; + public Hashtable readAreaPlcHs44_14 = null; + public Hashtable readAreaPlcHs44_15 = null; + public Hashtable readAreaPlcHs44_16 = null; + + + + public Hashtable readAreaPlcHs43_1 = null; + public Hashtable readAreaPlcHs43_2 = null; + public Hashtable readAreaPlcHs43_3 = null; + public Hashtable readAreaPlcHs43_4 = null; + public Hashtable readAreaPlcHs43_5 = null; + public Hashtable readAreaPlcHs43_6 = null; + public Hashtable readAreaPlcHs43_7 = null; + public Hashtable readAreaPlcHs43_8 = null; + public Hashtable readAreaPlcHs43_9 = null; + public Hashtable readAreaPlcHs43_10 = null; + public Hashtable readAreaPlcHs43_11 = null; + public Hashtable readAreaPlcHs43_12 = null; + public Hashtable readAreaPlcHs43_13 = null; + public Hashtable readAreaPlcHs43_14 = null; + public Hashtable readAreaPlcHs43_15 = null; + public Hashtable readAreaPlcHs43_16 = null; + + + + public Hashtable readAreaPlcHs42_1 = null; + public Hashtable readAreaPlcHs42_2 = null; + public Hashtable readAreaPlcHs42_3 = null; + public Hashtable readAreaPlcHs42_4 = null; + public Hashtable readAreaPlcHs42_5 = null; + public Hashtable readAreaPlcHs42_6 = null; + public Hashtable readAreaPlcHs42_7 = null; + public Hashtable readAreaPlcHs42_8 = null; + public Hashtable readAreaPlcHs42_9 = null; + public Hashtable readAreaPlcHs42_10 = null; + public Hashtable readAreaPlcHs42_11 = null; + public Hashtable readAreaPlcHs42_12 = null; + public Hashtable readAreaPlcHs42_13 = null; + public Hashtable readAreaPlcHs42_14 = null; + public Hashtable readAreaPlcHs42_15 = null; + public Hashtable readAreaPlcHs42_16 = null; + + + + public Hashtable readAreaPlcHs41_1 = null; + public Hashtable readAreaPlcHs41_2 = null; + public Hashtable readAreaPlcHs41_3 = null; + public Hashtable readAreaPlcHs41_4 = null; + public Hashtable readAreaPlcHs41_5 = null; + public Hashtable readAreaPlcHs41_6 = null; + public Hashtable readAreaPlcHs41_7 = null; + public Hashtable readAreaPlcHs41_8 = null; + public Hashtable readAreaPlcHs41_9 = null; + public Hashtable readAreaPlcHs41_10 = null; + public Hashtable readAreaPlcHs41_11 = null; + public Hashtable readAreaPlcHs41_12 = null; + public Hashtable readAreaPlcHs41_13 = null; + public Hashtable readAreaPlcHs41_14 = null; + public Hashtable readAreaPlcHs41_15 = null; + public Hashtable readAreaPlcHs41_16 = null; + + + + + /* ´æ·ÅдÈëµÄDB×Ö½ÚÐÅÏ¢ */ + public Hashtable writePlcHs = null; + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + + public IsoTcpClient171(Hashtable hsComParam, Hashtable hsSysParam) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + + this.readAreaPlcHs50_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_1"); + this.readAreaPlcHs50_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_2"); + this.readAreaPlcHs50_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_3"); + this.readAreaPlcHs50_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_4"); + this.readAreaPlcHs50_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_5"); + this.readAreaPlcHs50_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_6"); + this.readAreaPlcHs50_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_7"); + this.readAreaPlcHs50_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_8"); + this.readAreaPlcHs50_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_9"); + this.readAreaPlcHs50_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_10"); + this.readAreaPlcHs50_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_11"); + this.readAreaPlcHs50_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_12"); + this.readAreaPlcHs50_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_13"); + this.readAreaPlcHs50_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_14"); + this.readAreaPlcHs50_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_15"); + this.readAreaPlcHs50_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB50_16"); + + this.readAreaPlcHs49_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_1"); + this.readAreaPlcHs49_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_2"); + this.readAreaPlcHs49_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_3"); + this.readAreaPlcHs49_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_4"); + this.readAreaPlcHs49_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_5"); + this.readAreaPlcHs49_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_6"); + this.readAreaPlcHs49_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_7"); + this.readAreaPlcHs49_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_8"); + this.readAreaPlcHs49_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_9"); + this.readAreaPlcHs49_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_10"); + this.readAreaPlcHs49_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_11"); + this.readAreaPlcHs49_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_12"); + this.readAreaPlcHs49_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_13"); + this.readAreaPlcHs49_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_14"); + this.readAreaPlcHs49_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_15"); + this.readAreaPlcHs49_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB49_16"); + + this.readAreaPlcHs48_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_1"); + this.readAreaPlcHs48_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_2"); + this.readAreaPlcHs48_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_3"); + this.readAreaPlcHs48_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_4"); + this.readAreaPlcHs48_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_5"); + this.readAreaPlcHs48_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_6"); + this.readAreaPlcHs48_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_7"); + this.readAreaPlcHs48_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_8"); + this.readAreaPlcHs48_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_9"); + this.readAreaPlcHs48_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_10"); + this.readAreaPlcHs48_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_11"); + this.readAreaPlcHs48_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_12"); + this.readAreaPlcHs48_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_13"); + this.readAreaPlcHs48_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_14"); + this.readAreaPlcHs48_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_15"); + this.readAreaPlcHs48_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB48_16"); + + this.readAreaPlcHs47_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_1"); + this.readAreaPlcHs47_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_2"); + this.readAreaPlcHs47_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_3"); + this.readAreaPlcHs47_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_4"); + this.readAreaPlcHs47_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_5"); + this.readAreaPlcHs47_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_6"); + this.readAreaPlcHs47_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_7"); + this.readAreaPlcHs47_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_8"); + this.readAreaPlcHs47_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_9"); + this.readAreaPlcHs47_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_10"); + this.readAreaPlcHs47_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_11"); + this.readAreaPlcHs47_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_12"); + this.readAreaPlcHs47_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_13"); + this.readAreaPlcHs47_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_14"); + this.readAreaPlcHs47_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_15"); + this.readAreaPlcHs47_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB47_16"); + + this.readAreaPlcHs46_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_1"); + this.readAreaPlcHs46_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_2"); + this.readAreaPlcHs46_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_3"); + this.readAreaPlcHs46_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_4"); + this.readAreaPlcHs46_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_5"); + this.readAreaPlcHs46_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_6"); + this.readAreaPlcHs46_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_7"); + this.readAreaPlcHs46_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_8"); + this.readAreaPlcHs46_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_9"); + this.readAreaPlcHs46_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_10"); + this.readAreaPlcHs46_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_11"); + this.readAreaPlcHs46_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_12"); + this.readAreaPlcHs46_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_13"); + this.readAreaPlcHs46_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_14"); + this.readAreaPlcHs46_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_15"); + this.readAreaPlcHs46_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB46_16"); + + this.readAreaPlcHs45_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_1"); + this.readAreaPlcHs45_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_2"); + this.readAreaPlcHs45_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_3"); + this.readAreaPlcHs45_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_4"); + this.readAreaPlcHs45_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_5"); + this.readAreaPlcHs45_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_6"); + this.readAreaPlcHs45_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_7"); + this.readAreaPlcHs45_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_8"); + this.readAreaPlcHs45_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_9"); + this.readAreaPlcHs45_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_10"); + this.readAreaPlcHs45_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_11"); + this.readAreaPlcHs45_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_12"); + this.readAreaPlcHs45_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_13"); + this.readAreaPlcHs45_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_14"); + this.readAreaPlcHs45_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_15"); + this.readAreaPlcHs45_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB45_16"); + + this.readAreaPlcHs44_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_1"); + this.readAreaPlcHs44_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_2"); + this.readAreaPlcHs44_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_3"); + this.readAreaPlcHs44_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_4"); + this.readAreaPlcHs44_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_5"); + this.readAreaPlcHs44_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_6"); + this.readAreaPlcHs44_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_7"); + this.readAreaPlcHs44_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_8"); + this.readAreaPlcHs44_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_9"); + this.readAreaPlcHs44_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_10"); + this.readAreaPlcHs44_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_11"); + this.readAreaPlcHs44_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_12"); + this.readAreaPlcHs44_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_13"); + this.readAreaPlcHs44_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_14"); + this.readAreaPlcHs44_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_15"); + this.readAreaPlcHs44_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB44_16"); + + this.readAreaPlcHs43_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_1"); + this.readAreaPlcHs43_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_2"); + this.readAreaPlcHs43_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_3"); + this.readAreaPlcHs43_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_4"); + this.readAreaPlcHs43_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_5"); + this.readAreaPlcHs43_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_6"); + this.readAreaPlcHs43_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_7"); + this.readAreaPlcHs43_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_8"); + this.readAreaPlcHs43_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_9"); + this.readAreaPlcHs43_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_10"); + this.readAreaPlcHs43_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_11"); + this.readAreaPlcHs43_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_12"); + this.readAreaPlcHs43_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_13"); + this.readAreaPlcHs43_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_14"); + this.readAreaPlcHs43_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_15"); + this.readAreaPlcHs43_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB43_16"); + + this.readAreaPlcHs42_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_1"); + this.readAreaPlcHs42_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_2"); + this.readAreaPlcHs42_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_3"); + this.readAreaPlcHs42_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_4"); + this.readAreaPlcHs42_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_5"); + this.readAreaPlcHs42_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_6"); + this.readAreaPlcHs42_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_7"); + this.readAreaPlcHs42_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_8"); + this.readAreaPlcHs42_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_9"); + this.readAreaPlcHs42_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_10"); + this.readAreaPlcHs42_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_11"); + this.readAreaPlcHs42_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_12"); + this.readAreaPlcHs42_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_13"); + this.readAreaPlcHs42_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_14"); + this.readAreaPlcHs42_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_15"); + this.readAreaPlcHs42_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB42_16"); + + + this.readAreaPlcHs41_1 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_1"); + this.readAreaPlcHs41_2 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_2"); + this.readAreaPlcHs41_3 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_3"); + this.readAreaPlcHs41_4 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_4"); + this.readAreaPlcHs41_5 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_5"); + this.readAreaPlcHs41_6 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_6"); + this.readAreaPlcHs41_7 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_7"); + this.readAreaPlcHs41_8 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_8"); + this.readAreaPlcHs41_9 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_9"); + this.readAreaPlcHs41_10 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_10"); + this.readAreaPlcHs41_11 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_11"); + this.readAreaPlcHs41_12 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_12"); + this.readAreaPlcHs41_13 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_13"); + this.readAreaPlcHs41_14 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_14"); + this.readAreaPlcHs41_15 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_15"); + this.readAreaPlcHs41_16 = (Hashtable) hsComParam.get("readAreaPlcHsDB41_16"); + + + + + this.writePlcHs = (Hashtable) hsComParam.get("writePlcHs5"); + this.strIp = (String) hsComParam.get("strIp5"); + this.iPort = (Integer) hsComParam.get("iPort5"); + this.slot = (Integer) hsComParam.get("slot5"); + + } + + void ConnectServer() { + try { + sock = new Socket(strIp, iPort); + sock.setSoTimeout(6000); // ÉèÖó¬Ê±Ê±¼ä6Ãë + oStream = sock.getOutputStream(); + iStream = sock.getInputStream(); + + Nodave.Debug = 0x00;// ²»µ÷ʽ + di = new PLCinterface(oStream, iStream, "PLCName", 0, Nodave.PROTOCOL_ISOTCP); + dc = new TCPConnection(di, 0, slot); + + int res = dc.connectPLC(); + if (0 == res) { + setIsConnect(true); + } else { + } + } catch (IOException ioex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½Óʧ°Ü " + ioex.getMessage()); + } catch (Exception ex) { + Logger.info("********IP:" + strIp + " ¶Ë¿Ú:" + iPort + "Á¬½ÓÒì³£ " + ex.getMessage()); + } + } + + public void setIsConnect(boolean bflag) { + if (di != null) { + di.isConnect = bflag; + } + } + + public boolean IsConnect() { + if (di != null) { + return di.isConnect; + } + return false; + } + + void closeServer() { + try { + setIsConnect(false); + clearReadDB(); + if (iStream != null) { + iStream.close(); + iStream = null; + } + } catch (IOException e) { + Logger.info("ÊäÈëÁ÷¹Ø±ÕÒì³£ " + e.getMessage() + strIp + " ¶Ë¿Ú£º" + iPort); + } + try { + if (oStream != null) { + oStream.close(); + oStream = null; + } + } catch (IOException e) { + Logger.error("Êä³öÁ÷¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + " " + e.getMessage()); + } + try { + if (sock != null) { + sock.close(); + sock = null; + } + + } catch (IOException e) { + Logger.error("socket¿Í»§¶Ë¹Ø±ÕÒì³£ IP£º" + strIp + " ¶Ë¿Ú£º" + iPort + e.getMessage()); + } + } + + void clearReadDB() { + + if (readAreaPlcHs49_1 != null) { + Iterator iterR = readAreaPlcHs49_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs49_2 != null) { + Iterator iterR = readAreaPlcHs49_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_3 != null) { + Iterator iterR = readAreaPlcHs49_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_4 != null) { + Iterator iterR = readAreaPlcHs49_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs49_5 != null) { + Iterator iterR = readAreaPlcHs49_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_6 != null) { + Iterator iterR = readAreaPlcHs49_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_7 != null) { + Iterator iterR = readAreaPlcHs49_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_8 != null) { + Iterator iterR = readAreaPlcHs49_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_9 != null) { + Iterator iterR = readAreaPlcHs49_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_10 != null) { + Iterator iterR = readAreaPlcHs49_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_11 != null) { + Iterator iterR = readAreaPlcHs49_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_12 != null) { + Iterator iterR = readAreaPlcHs49_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_13 != null) { + Iterator iterR = readAreaPlcHs49_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_14 != null) { + Iterator iterR = readAreaPlcHs49_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_15 != null) { + Iterator iterR = readAreaPlcHs49_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs49_16 != null) { + Iterator iterR = readAreaPlcHs49_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + //========================================================================== + + if (readAreaPlcHs48_1 != null) { + Iterator iterR = readAreaPlcHs48_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs48_2 != null) { + Iterator iterR = readAreaPlcHs48_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_3 != null) { + Iterator iterR = readAreaPlcHs48_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_4 != null) { + Iterator iterR = readAreaPlcHs48_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs48_5 != null) { + Iterator iterR = readAreaPlcHs48_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_6 != null) { + Iterator iterR = readAreaPlcHs48_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_7 != null) { + Iterator iterR = readAreaPlcHs48_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_8 != null) { + Iterator iterR = readAreaPlcHs48_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_9 != null) { + Iterator iterR = readAreaPlcHs48_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_10 != null) { + Iterator iterR = readAreaPlcHs48_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_11 != null) { + Iterator iterR = readAreaPlcHs48_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_12 != null) { + Iterator iterR = readAreaPlcHs48_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_13 != null) { + Iterator iterR = readAreaPlcHs48_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_14 != null) { + Iterator iterR = readAreaPlcHs48_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_15 != null) { + Iterator iterR = readAreaPlcHs48_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs48_16 != null) { + Iterator iterR = readAreaPlcHs48_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + + //========================================================================== + if (readAreaPlcHs47_1 != null) { + Iterator iterR = readAreaPlcHs47_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs47_2 != null) { + Iterator iterR = readAreaPlcHs47_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_3 != null) { + Iterator iterR = readAreaPlcHs47_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_4 != null) { + Iterator iterR = readAreaPlcHs47_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs47_5 != null) { + Iterator iterR = readAreaPlcHs47_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_6 != null) { + Iterator iterR = readAreaPlcHs47_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_7 != null) { + Iterator iterR = readAreaPlcHs47_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_8 != null) { + Iterator iterR = readAreaPlcHs47_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_9 != null) { + Iterator iterR = readAreaPlcHs47_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_10 != null) { + Iterator iterR = readAreaPlcHs47_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_11 != null) { + Iterator iterR = readAreaPlcHs47_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_12 != null) { + Iterator iterR = readAreaPlcHs47_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_13 != null) { + Iterator iterR = readAreaPlcHs47_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_14 != null) { + Iterator iterR = readAreaPlcHs47_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_15 != null) { + Iterator iterR = readAreaPlcHs47_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs47_16 != null) { + Iterator iterR = readAreaPlcHs47_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + //========================================================================== + if (readAreaPlcHs46_1 != null) { + Iterator iterR = readAreaPlcHs46_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs46_2 != null) { + Iterator iterR = readAreaPlcHs46_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_3 != null) { + Iterator iterR = readAreaPlcHs46_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_4 != null) { + Iterator iterR = readAreaPlcHs46_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs46_5 != null) { + Iterator iterR = readAreaPlcHs46_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_6 != null) { + Iterator iterR = readAreaPlcHs46_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_7 != null) { + Iterator iterR = readAreaPlcHs46_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_8 != null) { + Iterator iterR = readAreaPlcHs46_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_9 != null) { + Iterator iterR = readAreaPlcHs46_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_10 != null) { + Iterator iterR = readAreaPlcHs46_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_11 != null) { + Iterator iterR = readAreaPlcHs46_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_12 != null) { + Iterator iterR = readAreaPlcHs46_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_13 != null) { + Iterator iterR = readAreaPlcHs46_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_14 != null) { + Iterator iterR = readAreaPlcHs46_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_15 != null) { + Iterator iterR = readAreaPlcHs46_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs46_16 != null) { + Iterator iterR = readAreaPlcHs46_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + + //========================================================================== + if (readAreaPlcHs45_1 != null) { + Iterator iterR = readAreaPlcHs45_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs45_2 != null) { + Iterator iterR = readAreaPlcHs45_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_3 != null) { + Iterator iterR = readAreaPlcHs45_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_4 != null) { + Iterator iterR = readAreaPlcHs45_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs45_5 != null) { + Iterator iterR = readAreaPlcHs45_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_6 != null) { + Iterator iterR = readAreaPlcHs45_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_7 != null) { + Iterator iterR = readAreaPlcHs45_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_8 != null) { + Iterator iterR = readAreaPlcHs45_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_9 != null) { + Iterator iterR = readAreaPlcHs45_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_10 != null) { + Iterator iterR = readAreaPlcHs45_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_11 != null) { + Iterator iterR = readAreaPlcHs45_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_12 != null) { + Iterator iterR = readAreaPlcHs45_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_13 != null) { + Iterator iterR = readAreaPlcHs45_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_14 != null) { + Iterator iterR = readAreaPlcHs45_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_15 != null) { + Iterator iterR = readAreaPlcHs45_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs45_16 != null) { + Iterator iterR = readAreaPlcHs45_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + //========================================================================== + if (readAreaPlcHs44_1 != null) { + Iterator iterR = readAreaPlcHs44_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs44_2 != null) { + Iterator iterR = readAreaPlcHs44_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_3 != null) { + Iterator iterR = readAreaPlcHs44_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_4 != null) { + Iterator iterR = readAreaPlcHs44_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs44_5 != null) { + Iterator iterR = readAreaPlcHs44_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_6 != null) { + Iterator iterR = readAreaPlcHs44_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_7 != null) { + Iterator iterR = readAreaPlcHs44_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_8 != null) { + Iterator iterR = readAreaPlcHs44_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_9 != null) { + Iterator iterR = readAreaPlcHs44_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_10 != null) { + Iterator iterR = readAreaPlcHs44_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_11 != null) { + Iterator iterR = readAreaPlcHs44_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_12 != null) { + Iterator iterR = readAreaPlcHs44_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_13 != null) { + Iterator iterR = readAreaPlcHs44_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_14 != null) { + Iterator iterR = readAreaPlcHs44_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_15 != null) { + Iterator iterR = readAreaPlcHs44_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs44_16 != null) { + Iterator iterR = readAreaPlcHs44_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + + + + //========================================================================== + if (readAreaPlcHs43_1 != null) { + Iterator iterR = readAreaPlcHs43_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs43_2 != null) { + Iterator iterR = readAreaPlcHs43_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_3 != null) { + Iterator iterR = readAreaPlcHs43_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_4 != null) { + Iterator iterR = readAreaPlcHs43_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs43_5 != null) { + Iterator iterR = readAreaPlcHs43_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_6 != null) { + Iterator iterR = readAreaPlcHs43_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_7 != null) { + Iterator iterR = readAreaPlcHs43_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_8 != null) { + Iterator iterR = readAreaPlcHs43_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_9 != null) { + Iterator iterR = readAreaPlcHs43_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_10 != null) { + Iterator iterR = readAreaPlcHs43_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_11 != null) { + Iterator iterR = readAreaPlcHs43_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_12 != null) { + Iterator iterR = readAreaPlcHs43_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_13 != null) { + Iterator iterR = readAreaPlcHs43_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_14 != null) { + Iterator iterR = readAreaPlcHs43_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_15 != null) { + Iterator iterR = readAreaPlcHs43_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs43_16 != null) { + Iterator iterR = readAreaPlcHs43_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + + //========================================================================== + if (readAreaPlcHs42_1 != null) { + Iterator iterR = readAreaPlcHs42_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs42_2 != null) { + Iterator iterR = readAreaPlcHs42_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_3 != null) { + Iterator iterR = readAreaPlcHs42_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_4 != null) { + Iterator iterR = readAreaPlcHs42_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs42_5 != null) { + Iterator iterR = readAreaPlcHs42_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_6 != null) { + Iterator iterR = readAreaPlcHs42_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_7 != null) { + Iterator iterR = readAreaPlcHs42_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_8 != null) { + Iterator iterR = readAreaPlcHs42_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_9 != null) { + Iterator iterR = readAreaPlcHs42_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_10 != null) { + Iterator iterR = readAreaPlcHs42_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_11 != null) { + Iterator iterR = readAreaPlcHs42_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_12 != null) { + Iterator iterR = readAreaPlcHs42_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_13 != null) { + Iterator iterR = readAreaPlcHs42_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_14 != null) { + Iterator iterR = readAreaPlcHs42_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_15 != null) { + Iterator iterR = readAreaPlcHs42_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs42_16 != null) { + Iterator iterR = readAreaPlcHs42_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + //========================================================================== + if (readAreaPlcHs41_1 != null) { + Iterator iterR = readAreaPlcHs41_1.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs41_2 != null) { + Iterator iterR = readAreaPlcHs41_2.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_3 != null) { + Iterator iterR = readAreaPlcHs41_3.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_4 != null) { + Iterator iterR = readAreaPlcHs41_4.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + if (readAreaPlcHs41_5 != null) { + Iterator iterR = readAreaPlcHs41_5.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_6 != null) { + Iterator iterR = readAreaPlcHs41_6.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_7 != null) { + Iterator iterR = readAreaPlcHs41_7.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_8 != null) { + Iterator iterR = readAreaPlcHs41_8.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_9 != null) { + Iterator iterR = readAreaPlcHs41_9.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_10 != null) { + Iterator iterR = readAreaPlcHs41_10.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_11 != null) { + Iterator iterR = readAreaPlcHs41_11.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_12 != null) { + Iterator iterR = readAreaPlcHs41_12.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_13 != null) { + Iterator iterR = readAreaPlcHs41_13.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_14 != null) { + Iterator iterR = readAreaPlcHs41_14.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_15 != null) { + Iterator iterR = readAreaPlcHs41_15.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + if (readAreaPlcHs41_16 != null) { + Iterator iterR = readAreaPlcHs41_16.entrySet().iterator(); + Map.Entry entry = null; + ReadAreaPlcInterface plcRVar = null; + if (iterR != null) { + byte[] nByte = new byte[2048]; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + plcRVar.udata = 0; + System.arraycopy(nByte, 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + } + } + } + + + } + + void reConnect() { +// Date t = new Date(); +// SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); +// System.out.println("104:Òì³£---------------reConnect-----------------------------------" + df.format(t)); + closeServer(); + ConnectServer(); + } + + public void run() { + Iterator iterR = null; + Iterator iterW = null; + List groups = null; + WriteDotPlcInterface.groupPlcObj group = null; + WriteDotPlcInterface plcWVar = null; + ReadAreaPlcInterface plcRVar = null; + ReadDotPlcInterface plcRDotVar = null; + Map.Entry entry = null; + int i = 0, j = 0; + boolean ReConn = false; + int iPrintcount = 5;// 5´Î½øÐдòÓ¡ + int currDecRun = 0;// µ±Ç°Ö´ÐдÎÊý + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + //Thread.sleep(400); + + Date t = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SSS"); + System.out.println("171:----" + df.format(t)); + + + //System.out.println(currDecRun); + //============================================================= + try { + if (readAreaPlcHs50_1 != null) { + iterR = readAreaPlcHs50_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_2 != null) { + iterR = readAreaPlcHs50_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_3 != null) { + iterR = readAreaPlcHs50_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_4 != null) { + iterR = readAreaPlcHs50_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_5 != null) { + iterR = readAreaPlcHs50_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_6 != null) { + iterR = readAreaPlcHs50_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs50_7 != null) { + iterR = readAreaPlcHs50_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs50_8 != null) { + iterR = readAreaPlcHs50_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_9 != null) { + iterR = readAreaPlcHs50_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_10 != null) { + iterR = readAreaPlcHs50_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs50_11 != null) { + iterR = readAreaPlcHs50_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs50_12 != null) { + iterR = readAreaPlcHs50_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_13 != null) { + iterR = readAreaPlcHs50_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_14 != null) { + iterR = readAreaPlcHs50_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_15 != null) { + iterR = readAreaPlcHs50_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs50_16 != null) { + iterR = readAreaPlcHs50_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + //------------ + try { + if (readAreaPlcHs49_1 != null) { + iterR = readAreaPlcHs49_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_2 != null) { + iterR = readAreaPlcHs49_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_3 != null) { + iterR = readAreaPlcHs49_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_4 != null) { + iterR = readAreaPlcHs49_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_5 != null) { + iterR = readAreaPlcHs49_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_6 != null) { + iterR = readAreaPlcHs49_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs49_7 != null) { + iterR = readAreaPlcHs49_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs49_8 != null) { + iterR = readAreaPlcHs49_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_9 != null) { + iterR = readAreaPlcHs49_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_10 != null) { + iterR = readAreaPlcHs49_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs49_11 != null) { + iterR = readAreaPlcHs49_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs49_12 != null) { + iterR = readAreaPlcHs49_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_13 != null) { + iterR = readAreaPlcHs49_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_14 != null) { + iterR = readAreaPlcHs49_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_15 != null) { + iterR = readAreaPlcHs49_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs49_16 != null) { + iterR = readAreaPlcHs49_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + //============================================================= + try { + if (readAreaPlcHs48_1 != null) { + iterR = readAreaPlcHs48_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_2 != null) { + iterR = readAreaPlcHs48_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_3 != null) { + iterR = readAreaPlcHs48_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_4 != null) { + iterR = readAreaPlcHs48_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_5 != null) { + iterR = readAreaPlcHs48_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_6 != null) { + iterR = readAreaPlcHs48_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs48_7 != null) { + iterR = readAreaPlcHs48_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs48_8 != null) { + iterR = readAreaPlcHs48_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_9 != null) { + iterR = readAreaPlcHs48_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_10 != null) { + iterR = readAreaPlcHs48_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs48_11 != null) { + iterR = readAreaPlcHs48_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs48_12 != null) { + iterR = readAreaPlcHs48_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_13 != null) { + iterR = readAreaPlcHs48_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_14 != null) { + iterR = readAreaPlcHs48_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_15 != null) { + iterR = readAreaPlcHs48_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs48_16 != null) { + iterR = readAreaPlcHs48_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + //============================================================= + try { + if (readAreaPlcHs47_1 != null) { + iterR = readAreaPlcHs47_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_2 != null) { + iterR = readAreaPlcHs47_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_3 != null) { + iterR = readAreaPlcHs47_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_4 != null) { + iterR = readAreaPlcHs47_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_5 != null) { + iterR = readAreaPlcHs47_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_6 != null) { + iterR = readAreaPlcHs47_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs47_7 != null) { + iterR = readAreaPlcHs47_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs47_8 != null) { + iterR = readAreaPlcHs47_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_9 != null) { + iterR = readAreaPlcHs47_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_10 != null) { + iterR = readAreaPlcHs47_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs47_11 != null) { + iterR = readAreaPlcHs47_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs47_12 != null) { + iterR = readAreaPlcHs47_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_13 != null) { + iterR = readAreaPlcHs47_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_14 != null) { + iterR = readAreaPlcHs47_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_15 != null) { + iterR = readAreaPlcHs47_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs47_16 != null) { + iterR = readAreaPlcHs47_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + + + //============================================================= + try { + if (readAreaPlcHs46_1 != null) { + iterR = readAreaPlcHs46_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_2 != null) { + iterR = readAreaPlcHs46_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_3 != null) { + iterR = readAreaPlcHs46_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_4 != null) { + iterR = readAreaPlcHs46_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_5 != null) { + iterR = readAreaPlcHs46_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_6 != null) { + iterR = readAreaPlcHs46_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs46_7 != null) { + iterR = readAreaPlcHs46_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs46_8 != null) { + iterR = readAreaPlcHs46_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_9 != null) { + iterR = readAreaPlcHs46_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_10 != null) { + iterR = readAreaPlcHs46_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs46_11 != null) { + iterR = readAreaPlcHs46_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs46_12 != null) { + iterR = readAreaPlcHs46_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_13 != null) { + iterR = readAreaPlcHs46_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_14 != null) { + iterR = readAreaPlcHs46_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_15 != null) { + iterR = readAreaPlcHs46_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs46_16 != null) { + iterR = readAreaPlcHs46_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + + //============================================================= + try { + if (readAreaPlcHs45_1 != null) { + iterR = readAreaPlcHs45_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_2 != null) { + iterR = readAreaPlcHs45_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_3 != null) { + iterR = readAreaPlcHs45_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_4 != null) { + iterR = readAreaPlcHs45_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_5 != null) { + iterR = readAreaPlcHs45_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_6 != null) { + iterR = readAreaPlcHs45_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs45_7 != null) { + iterR = readAreaPlcHs45_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs45_8 != null) { + iterR = readAreaPlcHs45_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_9 != null) { + iterR = readAreaPlcHs45_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_10 != null) { + iterR = readAreaPlcHs45_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs45_11 != null) { + iterR = readAreaPlcHs45_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs45_12 != null) { + iterR = readAreaPlcHs45_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_13 != null) { + iterR = readAreaPlcHs45_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_14 != null) { + iterR = readAreaPlcHs45_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_15 != null) { + iterR = readAreaPlcHs45_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs45_16 != null) { + iterR = readAreaPlcHs45_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + //============================================================= + try { + if (readAreaPlcHs44_1 != null) { + iterR = readAreaPlcHs44_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_2 != null) { + iterR = readAreaPlcHs44_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_3 != null) { + iterR = readAreaPlcHs44_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_4 != null) { + iterR = readAreaPlcHs44_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_5 != null) { + iterR = readAreaPlcHs44_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_6 != null) { + iterR = readAreaPlcHs44_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs44_7 != null) { + iterR = readAreaPlcHs44_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs44_8 != null) { + iterR = readAreaPlcHs44_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_9 != null) { + iterR = readAreaPlcHs44_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_10 != null) { + iterR = readAreaPlcHs44_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs44_11 != null) { + iterR = readAreaPlcHs44_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs44_12 != null) { + iterR = readAreaPlcHs44_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_13 != null) { + iterR = readAreaPlcHs44_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_14 != null) { + iterR = readAreaPlcHs44_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_15 != null) { + iterR = readAreaPlcHs44_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs44_16 != null) { + iterR = readAreaPlcHs44_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + + //============================================================= + try { + if (readAreaPlcHs43_1 != null) { + iterR = readAreaPlcHs43_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_2 != null) { + iterR = readAreaPlcHs43_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_3 != null) { + iterR = readAreaPlcHs43_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_4 != null) { + iterR = readAreaPlcHs43_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_5 != null) { + iterR = readAreaPlcHs43_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_6 != null) { + iterR = readAreaPlcHs43_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs43_7 != null) { + iterR = readAreaPlcHs43_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs43_8 != null) { + iterR = readAreaPlcHs43_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_9 != null) { + iterR = readAreaPlcHs43_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_10 != null) { + iterR = readAreaPlcHs43_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs43_11 != null) { + iterR = readAreaPlcHs43_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs43_12 != null) { + iterR = readAreaPlcHs43_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_13 != null) { + iterR = readAreaPlcHs43_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_14 != null) { + iterR = readAreaPlcHs43_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_15 != null) { + iterR = readAreaPlcHs43_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs43_16 != null) { + iterR = readAreaPlcHs43_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + + + //============================================================= + try { + if (readAreaPlcHs42_1 != null) { + iterR = readAreaPlcHs42_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_2 != null) { + iterR = readAreaPlcHs42_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_3 != null) { + iterR = readAreaPlcHs42_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_4 != null) { + iterR = readAreaPlcHs42_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_5 != null) { + iterR = readAreaPlcHs42_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_6 != null) { + iterR = readAreaPlcHs42_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs42_7 != null) { + iterR = readAreaPlcHs42_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs42_8 != null) { + iterR = readAreaPlcHs42_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_9 != null) { + iterR = readAreaPlcHs42_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_10 != null) { + iterR = readAreaPlcHs42_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs42_11 != null) { + iterR = readAreaPlcHs42_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs42_12 != null) { + iterR = readAreaPlcHs42_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_13 != null) { + iterR = readAreaPlcHs42_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_14 != null) { + iterR = readAreaPlcHs42_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_15 != null) { + iterR = readAreaPlcHs42_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs42_16 != null) { + iterR = readAreaPlcHs42_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + + + + + //============================================================= + try { + if (readAreaPlcHs41_1 != null) { + iterR = readAreaPlcHs41_1.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_2 != null) { + iterR = readAreaPlcHs41_2.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_3 != null) { + iterR = readAreaPlcHs41_3.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_4 != null) { + iterR = readAreaPlcHs41_4.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_5 != null) { + iterR = readAreaPlcHs41_5.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_6 != null) { + iterR = readAreaPlcHs41_6.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + + try { + if (readAreaPlcHs41_7 != null) { + iterR = readAreaPlcHs41_7.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs41_8 != null) { + iterR = readAreaPlcHs41_8.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_9 != null) { + iterR = readAreaPlcHs41_9.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_10 != null) { + iterR = readAreaPlcHs41_10.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs41_11 != null) { + iterR = readAreaPlcHs41_11.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + + try { + if (readAreaPlcHs41_12 != null) { + iterR = readAreaPlcHs41_12.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_13 != null) { + iterR = readAreaPlcHs41_13.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_14 != null) { + iterR = readAreaPlcHs41_14.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_15 != null) { + iterR = readAreaPlcHs41_15.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + try { + if (readAreaPlcHs41_16 != null) { + iterR = readAreaPlcHs41_16.entrySet().iterator(); + if (iterR != null) { + boolean isprint = false; + currDecRun = currDecRun % iPrintcount; + if (currDecRun == 0) { + isprint = true; + } + currDecRun++; + while (iterR.hasNext()) { + entry = (Map.Entry) iterR.next(); + plcRVar = (ReadAreaPlcInterface) entry.getValue(); + dc.readBytes(plcRVar.DB, plcRVar.DBnum, plcRVar.start, plcRVar.len, null); + if (IsConnect()) { + plcRVar.udata = dc.getUdata(); + System.arraycopy(dc.getMsgIn(), 0, plcRVar.msgIn, 0, plcRVar.msgIn.length); + if (isprint) { + int length = plcRVar.msgIn.length; + for (int k = plcRVar.msgIn.length - 1; k > 0; k--) { + if (plcRVar.msgIn[k] != 0) { + length = k + 1; + break; + } + } + } + } else { + Logger.error("¶ÁÈ¡DB¿éÖÐÁ¬ÐøÇøÓòÐÅÏ¢ ÖжÏ"); + break; + } + } + } + } + } catch (Exception ex) { + System.out.println("104:Òì³£---------------readAreaPlcHs1-----------------------------------" + df.format(t)); + + //ex.printStackTrace(); + reConnect(); + } + + // дÈëµ½DB¿éÖÐÖ¸¶¨µÄλÖà + try { + if (IsConnect()) { + if (writePlcHs != null) { + t1 = System.currentTimeMillis(); + iterW = writePlcHs.entrySet().iterator(); + if (iterW != null) { + while (iterW.hasNext()) { + entry = (Map.Entry) iterW.next(); + plcWVar = (WriteDotPlcInterface) entry.getValue(); + groups = plcWVar.lsWriteGroupPlc; + for (i = 0; i < groups.size(); i++) { + group = groups.get(i); + dc.writeBytes(group.getArea(), group.getDBnum(), group.getStart(), + group.getLen(), group.getBuffer()); + Logger.info(" DB" + group.getDBnum() + ":¿ªÊ¼-" + group.getStart() + " ³¤¶È-" + + group.getLen() + " Ï·¢Öµ-" + group.getValue()); + if (IsConnect()) { + plcWVar.lsWriteGroupPlc.remove(i); + i--; + } else { + Logger.error("дÈëµ½DB101¿éÖÐÖ¸¶¨µÄλÖà ÖжÏ"); + break; + } + } + } + } + } + } + } catch (Exception ex) { + reConnect(); + } + + } else { + reConnect(); + } + Thread.sleep(1000); + } catch (Exception ex) { + reConnect(); + } + //reConnect(); + } + closeServer(); + } + + // ½«Ö¸¶¨byteÊý×éÒÔ16½øÖƵÄÐÎʽ´òÓ¡µ½¿ØÖÆÌ¨ + public static String printHexString(byte[] b, int length) { + String re = ""; + for (int i = 0; i < length; i++) { + String hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + re += hex.toUpperCase() + " "; + } + return re; + } + + public static void main(String arg[]) { + byte[] ss = new byte[5]; + ss[0] = 1; + ss[1] = 0; + ss[2] = 16; + ss[3] = 0; + ss[4] = 0; + int length = ss.length; + for (int i = ss.length - 1; i > 0; i--) { + if (ss[i] != 0) { + length = i + 1; + break; + } + } + + // ¶ÁÈ¡Á÷03 00 00 2B 02 F0 80 32 03 00 00 00 00 00 02 00 16 00 00 04 01 FF + // 04 00 90 + // 89 02 00 80 37 01 02 37 01 00 18 5E 03 78 05 02 03 + byte[] ssz = Nodave.bswap_16(6238);// 18 5E ÈÎÎñºÅ + System.out.println(printHexString(ssz, ssz.length)); + byte[] msgIn = new byte[90]; + msgIn[10] = (byte) 0x18; // µÚ36 + msgIn[11] = (byte) 0x5E; // µÚ37 + System.out.println(Nodave.SBEWord(msgIn, 10)); + } +} \ No newline at end of file diff --git a/wmsdssconfig/abb/actionRelation.xml b/wmsdssconfig/abb/actionRelation.xml new file mode 100644 index 0000000..fc6e50c --- /dev/null +++ b/wmsdssconfig/abb/actionRelation.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/wmsdssconfig/abb/carcommand31.dat b/wmsdssconfig/abb/carcommand31.dat new file mode 100644 index 0000000..fafc4f3 Binary files /dev/null and b/wmsdssconfig/abb/carcommand31.dat differ diff --git a/wmsdssconfig/abb/cranecommand1.dat b/wmsdssconfig/abb/cranecommand1.dat new file mode 100644 index 0000000..fafc4f3 Binary files /dev/null and b/wmsdssconfig/abb/cranecommand1.dat differ diff --git a/wmsdssconfig/abb/cranecommand2.dat b/wmsdssconfig/abb/cranecommand2.dat new file mode 100644 index 0000000..fafc4f3 Binary files /dev/null and b/wmsdssconfig/abb/cranecommand2.dat differ diff --git a/wmsdssconfig/abb/exectask1.dat b/wmsdssconfig/abb/exectask1.dat new file mode 100644 index 0000000..0581a71 Binary files /dev/null and b/wmsdssconfig/abb/exectask1.dat differ diff --git a/wmsdssconfig/abb/exectask2.dat b/wmsdssconfig/abb/exectask2.dat new file mode 100644 index 0000000..0581a71 Binary files /dev/null and b/wmsdssconfig/abb/exectask2.dat differ diff --git a/wmsdssconfig/abb/hibernate.cfg.xml b/wmsdssconfig/abb/hibernate.cfg.xml new file mode 100644 index 0000000..430bb2f --- /dev/null +++ b/wmsdssconfig/abb/hibernate.cfg.xml @@ -0,0 +1,34 @@ + + + + + + + + + org.hibernate.dialect.MySQLInnoDBDialect + + com.mysql.cj.jdbc.Driver + jdbc:mysql://10.214.18.64:3306/FT465-2 + root + root@123 + 10 + + + false + true + 50 + + + + + + + + + + + + diff --git a/wmsdssconfig/abb/opcItemconfig.xml b/wmsdssconfig/abb/opcItemconfig.xml new file mode 100644 index 0000000..a3ba846 --- /dev/null +++ b/wmsdssconfig/abb/opcItemconfig.xml @@ -0,0 +1,442 @@ + + + + + + + + + + Yld.yldDevice.XC1.fromcar.RWH + Yld.yldDevice.XC1.fromcar.CZFS + Yld.yldDevice.XC1.fromcar.DQZT + Yld.yldDevice.XC1.fromcar.JDBZ + Yld.yldDevice.XC1.fromcar.ZYFS + Yld.yldDevice.XC1.fromcar.DQLH + Yld.yldDevice.XC1.fromcar.SSDJCS + Yld.yldDevice.XC1.fromcar.SSDJ + Yld.yldDevice.XC1.fromcar.WXBJ + + Yld.yldDevice.XC1.fromcar.CJCW + Yld.yldDevice.XC1.fromcar.YXJPCW + Yld.yldDevice.XC1.fromcar.YXBPBJ + Yld.yldDevice.XC1.fromcar.YXCS + Yld.yldDevice.XC1.fromcar.YXCJ + Yld.yldDevice.XC1.fromcar.SSBPBJ + Yld.yldDevice.XC1.fromcar.SSCS + Yld.yldDevice.XC1.fromcar.KGYW + Yld.yldDevice.XC1.fromcar.WXBJ + Yld.yldDevice.XC1.fromcar.QCCBJ + Yld.yldDevice.XC1.fromcar.HCCBJ + Yld.yldDevice.XC1.fromcar.CGBJ + Yld.yldDevice.XC1.fromcar.ZCKBJ + Yld.yldDevice.XC1.fromcar.YCKBJ + Yld.yldDevice.XC1.fromcar.QHWBWH + Yld.yldDevice.XC1.fromcar.FHWBYH + Yld.yldDevice.XC1.fromcar.SDCX + + + Yld.yldDevice.XC1.tocar.XCRWH + Yld.yldDevice.XC1.tocar.XCZLGS + Yld.yldDevice.XC1.tocar.XCYLH + Yld.yldDevice.XC1.tocar.XCMLH + Yld.yldDevice.XC1.tocar.XCZLXDBZ + Yld.yldDevice.XC1.tocar.XCJYM + + + + + + + + + Yld.yldDevice.DDJ1.fromddj.RWH + Yld.yldDevice.DDJ1.fromddj.CZFS + Yld.yldDevice.DDJ1.fromddj.DQZT + Yld.yldDevice.DDJ1.fromddj.JDBZ + Yld.yldDevice.DDJ1.fromddj.ZYFS + Yld.yldDevice.DDJ1.fromddj.DQPH + Yld.yldDevice.DDJ1.fromddj.DQLH + Yld.yldDevice.DDJ1.fromddj.DQCH + Yld.yldDevice.DDJ1.fromddj.QHWH + Yld.yldDevice.DDJ1.fromddj.FHYH + + Yld.yldDevice.DDJ1.fromddj.YXCJCW + Yld.yldDevice.DDJ1.fromddj.YXJPCW + Yld.yldDevice.DDJ1.fromddj.YXBPBJ + Yld.yldDevice.DDJ1.fromddj.YXCSBJ + Yld.yldDevice.DDJ1.fromddj.YXCJBJ + Yld.yldDevice.DDJ1.fromddj.QSCJCW + Yld.yldDevice.DDJ1.fromddj.QSJPCW + Yld.yldDevice.DDJ1.fromddj.QSBPBJ + Yld.yldDevice.DDJ1.fromddj.QSCSBJ + Yld.yldDevice.DDJ1.fromddj.QSCJBJ + Yld.yldDevice.DDJ1.fromddj.HCBMCW + Yld.yldDevice.DDJ1.fromddj.HCXHYW + Yld.yldDevice.DDJ1.fromddj.HCBPBJ + Yld.yldDevice.DDJ1.fromddj.HCCSBJ + Yld.yldDevice.DDJ1.fromddj.HCBZZW + Yld.yldDevice.DDJ1.fromddj.HWWXBJ + Yld.yldDevice.DDJ1.fromddj.FWWBYH + Yld.yldDevice.DDJ1.fromddj.QHWBWH + Yld.yldDevice.DDJ1.fromddj.SSGZ + + + Yld.yldDevice.DDJ1.toddj.DDJ01RWH + Yld.yldDevice.DDJ1.toddj.DDJ01ZLGS + Yld.yldDevice.DDJ1.toddj.DDJ01MBP + Yld.yldDevice.DDJ1.toddj.DDJ01MBL + Yld.yldDevice.DDJ1.toddj.DDJ01MBC + Yld.yldDevice.DDJ1.toddj.DDJ01ZLXDBZ + Yld.yldDevice.DDJ1.toddj.DDJ01JYM + + + + + Yld.yldDevice.DDJ2.fromddj.RWH + Yld.yldDevice.DDJ2.fromddj.CZFS + Yld.yldDevice.DDJ2.fromddj.DQZT + Yld.yldDevice.DDJ2.fromddj.JDBZ + Yld.yldDevice.DDJ2.fromddj.ZYFS + Yld.yldDevice.DDJ2.fromddj.DQPH + Yld.yldDevice.DDJ2.fromddj.DQLH + Yld.yldDevice.DDJ2.fromddj.DQCH + Yld.yldDevice.DDJ2.fromddj.QHWH + Yld.yldDevice.DDJ2.fromddj.FHYH + + Yld.yldDevice.DDJ2.fromddj.YXCJCW + Yld.yldDevice.DDJ2.fromddj.YXJPCW + Yld.yldDevice.DDJ2.fromddj.YXBPBJ + Yld.yldDevice.DDJ2.fromddj.YXCSBJ + Yld.yldDevice.DDJ2.fromddj.YXCJBJ + Yld.yldDevice.DDJ2.fromddj.QSCJCW + Yld.yldDevice.DDJ2.fromddj.QSJPCW + Yld.yldDevice.DDJ2.fromddj.QSBPBJ + Yld.yldDevice.DDJ2.fromddj.QSCSBJ + Yld.yldDevice.DDJ2.fromddj.QSCJBJ + Yld.yldDevice.DDJ2.fromddj.HCBMCW + Yld.yldDevice.DDJ2.fromddj.HCXHYW + Yld.yldDevice.DDJ2.fromddj.HCBPBJ + Yld.yldDevice.DDJ2.fromddj.HCCSBJ + Yld.yldDevice.DDJ2.fromddj.HCBZZW + Yld.yldDevice.DDJ2.fromddj.HWWXBJ + Yld.yldDevice.DDJ2.fromddj.FWWBYH + Yld.yldDevice.DDJ2.fromddj.QHWBWH + Yld.yldDevice.DDJ2.fromddj.SSGZ + + + Yld.yldDevice.DDJ2.toddj.DDJ02RWH + Yld.yldDevice.DDJ2.toddj.DDJ02ZLGS + Yld.yldDevice.DDJ2.toddj.DDJ02MBP + Yld.yldDevice.DDJ2.toddj.DDJ02MBL + Yld.yldDevice.DDJ2.toddj.DDJ02MBC + Yld.yldDevice.DDJ2.toddj.DDJ02ZLXDBZ + Yld.yldDevice.DDJ2.toddj.DDJ02JYM + + + + + + + + + Yld.yldDevice.SSJ.SSJI.SS1RKDW + Yld.yldDevice.SSJ.SSJI.SS1KXBZ + Yld.yldDevice.SSJ.SSJI.SS1TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS2RKDW + Yld.yldDevice.SSJ.SSJI.SS2KXBZ + Yld.yldDevice.SSJ.SSJI.SS2TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS3RKDW + Yld.yldDevice.SSJ.SSJI.SS3KXBZ + Yld.yldDevice.SSJ.SSJI.SS3TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS4RKDW + Yld.yldDevice.SSJ.SSJI.SS4KXBZ + Yld.yldDevice.SSJ.SSJI.SS4TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS5RKDW + Yld.yldDevice.SSJ.SSJI.SS5KXBZ + Yld.yldDevice.SSJ.SSJI.SS5TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS6RKDW + Yld.yldDevice.SSJ.SSJI.SS6KXBZ + Yld.yldDevice.SSJ.SSJI.SS6TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS16DDBZ + Yld.yldDevice.SSJ.SSJI.SS16TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS18DDBZ + Yld.yldDevice.SSJ.SSJI.SS18TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS20DDBZ + Yld.yldDevice.SSJ.SSJI.SS20TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS22DDBZ + Yld.yldDevice.SSJ.SSJI.SS22TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS24DDBZ + Yld.yldDevice.SSJ.SSJI.SS24TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS26DDBZ + Yld.yldDevice.SSJ.SSJI.SS26TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS28DDBZ + Yld.yldDevice.SSJ.SSJI.SS28TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS30DDBZ + Yld.yldDevice.SSJ.SSJI.SS30TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS9RKDW + Yld.yldDevice.SSJ.SSJI.SS9TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS13RKDW + Yld.yldDevice.SSJ.SSJI.SS13TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS15RKDW + Yld.yldDevice.SSJ.SSJI.SS15TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS17RKDW + Yld.yldDevice.SSJ.SSJI.SS17TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS19RKDW + Yld.yldDevice.SSJ.SSJI.SS19TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS21RKDW + Yld.yldDevice.SSJ.SSJI.SS21TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS23RKDW + Yld.yldDevice.SSJ.SSJI.SS23TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS25RKDW + Yld.yldDevice.SSJ.SSJI.SS25TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS27RKDW + Yld.yldDevice.SSJ.SSJI.SS27TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS29RKDW + Yld.yldDevice.SSJ.SSJI.SS29TASK + + + + + + + Yld.yldDevice.SSJ.SSJI.SS10KXBZ + + + + + Yld.yldDevice.SSJ.SSJI.SS14KXBZ + + + + + + + Yld.yldDevice.SSJ.SSJI.SS7KXBZ + + + + + Yld.yldDevice.SSJ.SSJI.SS11KXBZ + + + + + + + Yld.yldDevice.SSJ.SSJI.SS15KXBZ + + + + + Yld.yldDevice.SSJ.SSJI.SS19KXBZ + + + + + + + Yld.yldDevice.SSJ.SSJI.SS23KXBZ + + + + + Yld.yldDevice.SSJ.SSJI.SS27KXBZ + + + + + + + Yld.yldDevice.SSJ.SSJI.SS8CKDW + Yld.yldDevice.SSJ.SSJI.SS8TASK + + + + + Yld.yldDevice.SSJ.SSJI.SS12CKDW + Yld.yldDevice.SSJ.SSJI.SS12TASK + + + + + + + Yld.yldDevice.XC1.tocar.JSSWQCSSDJ + + + + + + + Yld.yldDevice.SSJ.SSJI.SS16RWH + Yld.yldDevice.SSJ.SSJI.SS16XFBZ + Yld.yldDevice.SSJ.SSJI.SS16CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS18RWH + Yld.yldDevice.SSJ.SSJI.SS18XFBZ + Yld.yldDevice.SSJ.SSJI.SS18CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS20RWH + Yld.yldDevice.SSJ.SSJI.SS20XFBZ + Yld.yldDevice.SSJ.SSJI.SS20CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS22RWH + Yld.yldDevice.SSJ.SSJI.SS22XFBZ + Yld.yldDevice.SSJ.SSJI.SS22CRC + + + + + + + Yld.yldDevice.SSJ.SSJI.SS24RWH + Yld.yldDevice.SSJ.SSJI.SS24XFBZ + Yld.yldDevice.SSJ.SSJI.SS24CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS26RWH + Yld.yldDevice.SSJ.SSJI.SS26XFBZ + Yld.yldDevice.SSJ.SSJI.SS26CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS28RWH + Yld.yldDevice.SSJ.SSJI.SS28XFBZ + Yld.yldDevice.SSJ.SSJI.SS28CRC + + + + + Yld.yldDevice.SSJ.SSJI.SS30RWH + Yld.yldDevice.SSJ.SSJI.SS30XFBZ + Yld.yldDevice.SSJ.SSJI.SS30CRC + + + + + + + diff --git a/wmsdssconfig/abb/ssxcommand1.dat b/wmsdssconfig/abb/ssxcommand1.dat new file mode 100644 index 0000000..fafc4f3 Binary files /dev/null and b/wmsdssconfig/abb/ssxcommand1.dat differ diff --git a/wmsdssconfig/abb/ssxcommand2.dat b/wmsdssconfig/abb/ssxcommand2.dat new file mode 100644 index 0000000..0581a71 Binary files /dev/null and b/wmsdssconfig/abb/ssxcommand2.dat differ diff --git a/wmsdssconfig/abb/ssxcommandLC1.dat b/wmsdssconfig/abb/ssxcommandLC1.dat new file mode 100644 index 0000000..fafc4f3 Binary files /dev/null and b/wmsdssconfig/abb/ssxcommandLC1.dat differ diff --git a/wmsdssconfig/abb/wmsdssconfig.xml b/wmsdssconfig/abb/wmsdssconfig.xml new file mode 100644 index 0000000..e79d756 --- /dev/null +++ b/wmsdssconfig/abb/wmsdssconfig.xml @@ -0,0 +1,255 @@ + + + + + + + hzDsTest3 + + + + hzDs1 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 192.168.8.172 + 1521 + orcl + zsjr + root + 50 + 5000 + select sysdate from dual + + + + + hzDs2 + + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver:// + 192.168.10.180 + + 1433 + + DatabaseName=FT321 + sa + 123456 + 10 + 9000 + + + + + + hzDs99 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + localhost + 1433 + DatabaseName=FT321 + sa + root + 30 + 9000 + select 1 + + + + + + hzDs3 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + 172.16.2.170 + 1433 + DatabaseName=FT460 + sa + Flrd0914. + 30 + 9000 + select 1 + + + + + hzDsTest3 + + com.mysql.cj.jdbc.Driver + jdbc:mysql:// + 10.214.18.64 + 3306 + FT465-2 + root + root@123 + 30 + 9000 + SELECT 1 + + + + + + + hzDs8 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + 127.0.0.1 + 1433 + DatabaseName=work + sa + 123456 + 30 + 9000 + select 1 + + + + + hzDs4 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 192.168.8.26 + 1521 + zsjr2 + zsjr + zsjr123456 + 50 + 5000 + select sysdate from dual + + + + + hzDs5 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 127.0.0.1 + 1521 + orcl + system + 123456 + 50 + 5000 + select sysdate from dual + + + + + + actionRelation.xml + opcItemconfig.xml + + + + + 9003 + 50 + 5 + 20 + 50 + 6000 + + + + + 172.20.21.201 + 102 + 1 + + + + + + WORKÉ豸ͨÐŵ÷¶Èϵͳ + images\\1.gif + 850 + 600 + + + É豸ͨÐÅ + 1 + + 16 + + Æô¡¡¡¡¶¯ + 1 + + 12 + 0 + com.wms.dss.ats.customs.abb.form.StartCorrespond + com.wms.dss.ats.customs.abb.plc.PLCCorrespondService + + + ·Ö¸ôÏß + + + + 1 + + + + Í£¡¡¡¡Ö¹ + 0 + + 14 + 0 + com.wms.dss.ats.customs.yld.form.StopCorrespond + + + + É豸µ÷¶È + 1 + + 16 + + Æô¡¡¡¡¶¯ + 1 + + 12 + 0 + com.wms.dss.common.server.form.StartSchedule + com.wms.dss.ats.customs.abb.schedule.ABBThreadSchedule + + + ·Ö¸ôÏß + + + + 1 + + + + Í£¡¡¡¡Ö¹ + 0 + + 14 + 0 + com.wms.dss.common.server.form.StopSchedule + + + + + + + ÊäËÍ»úͨÐÅÈÕÖ¾ + 16 + images\\now.gif + ÊäËÍ»úͨÐÅÈÕÖ¾ + 0 + + + ÊäËÍ»úµ÷¶ÈÈÕÖ¾ + 16 + images\\now.gif + ÊäËÍ»úµ÷¶ÈÈÕÖ¾ + 2 + + + + diff --git a/wmsdssconfig/abb/wmsdssconfig_1.xml b/wmsdssconfig/abb/wmsdssconfig_1.xml new file mode 100644 index 0000000..f46606c --- /dev/null +++ b/wmsdssconfig/abb/wmsdssconfig_1.xml @@ -0,0 +1,255 @@ + + + + + + + hzDsTest3 + + + + hzDs1 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 192.168.8.172 + 1521 + orcl + zsjr + root + 50 + 5000 + select sysdate from dual + + + + + hzDs2 + + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver:// + 192.168.10.180 + + 1433 + + DatabaseName=FT321 + sa + 123456 + 10 + 9000 + + + + + + hzDs99 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + localhost + 1433 + DatabaseName=FT321 + sa + root + 30 + 9000 + select 1 + + + + + + hzDs3 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + 172.16.2.170 + 1433 + DatabaseName=FT460 + sa + Flrd0914. + 30 + 9000 + select 1 + + + + + hzDsTest3 + + com.mysql.cj.jdbc.Driver + jdbc:mysql:// + 172.16.2.170 + 3306 + FT465-2 + root + Flrd0914. + 30 + 9000 + SELECT 1 + + + + + + + hzDs8 + + com.microsoft.jdbc.sqlserver.SQLServerDriver + jdbc:microsoft:sqlserver:// + 127.0.0.1 + 1433 + DatabaseName=work + sa + 123456 + 30 + 9000 + select 1 + + + + + hzDs4 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 192.168.8.26 + 1521 + zsjr2 + zsjr + zsjr123456 + 50 + 5000 + select sysdate from dual + + + + + hzDs5 + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@ + 127.0.0.1 + 1521 + orcl + system + 123456 + 50 + 5000 + select sysdate from dual + + + + + + actionRelation.xml + opcItemconfig.xml + + + + + 9003 + 50 + 5 + 20 + 50 + 6000 + + + + + 172.20.21.201 + 102 + 1 + + + + + + WORKÉ豸ͨÐŵ÷¶Èϵͳ + images\\1.gif + 850 + 600 + + + É豸ͨÐÅ + 1 + + 16 + + Æô¡¡¡¡¶¯ + 1 + + 12 + 0 + com.wms.dss.ats.customs.abb.form.StartCorrespond + com.wms.dss.ats.customs.abb.plc.PLCCorrespondService + + + ·Ö¸ôÏß + + + + 1 + + + + Í£¡¡¡¡Ö¹ + 0 + + 14 + 0 + com.wms.dss.ats.customs.yld.form.StopCorrespond + + + + É豸µ÷¶È + 1 + + 16 + + Æô¡¡¡¡¶¯ + 1 + + 12 + 0 + com.wms.dss.common.server.form.StartSchedule + com.wms.dss.ats.customs.abb.schedule.ABBThreadSchedule + + + ·Ö¸ôÏß + + + + 1 + + + + Í£¡¡¡¡Ö¹ + 0 + + 14 + 0 + com.wms.dss.common.server.form.StopSchedule + + + + + + + ÊäËÍ»úͨÐÅÈÕÖ¾ + 16 + images\\now.gif + ÊäËÍ»úͨÐÅÈÕÖ¾ + 0 + + + ÊäËÍ»úµ÷¶ÈÈÕÖ¾ + 16 + images\\now.gif + ÊäËÍ»úµ÷¶ÈÈÕÖ¾ + 2 + + + + diff --git a/wmsdssconfig/dssconfig.properties b/wmsdssconfig/dssconfig.properties new file mode 100644 index 0000000..720aa3f --- /dev/null +++ b/wmsdssconfig/dssconfig.properties @@ -0,0 +1,4 @@ +#Copyright (c) ricosoft +#2011-04-19 +wmsdssconfig=abb +wmsdssconfigxml=wmsdssconfig.xml