commit 1f54cd9c8637daa47f648f290fa9ba5a741826e0 Author: liuhanqing Date: Wed Dec 10 10:06:55 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/FT503-WCS.iml b/FT503-WCS.iml new file mode 100644 index 0000000..33e36bd --- /dev/null +++ b/FT503-WCS.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ 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/common/TaskType.java b/src/com/wms/dss/ats/customs/abb/common/TaskType.java new file mode 100644 index 0000000..f66d1c8 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/common/TaskType.java @@ -0,0 +1,49 @@ +package com.wms.dss.ats.customs.abb.common; + +public enum TaskType { + // 定义枚举实例 + TYPE_A(1,1, "空托盘æ�¬è¿� å�–货(左侧拆盘点->RGV)"), + TYPE_F(8,1, "空托盘æ�¬è¿� 放货(RGV->左侧生产线)"), + TYPE_A_1(9,3, "空托盘æ�¬è¿� å�–货(å�³ä¾§æ‹†ç›˜ç‚¹->RGV)"), + TYPE_F_1(10,3, "空托盘æ�¬è¿� 放货(RGV->å�³ä¾§ç”Ÿäº§çº¿ï¼‰"), + TYPE_B(2,2, "托盘æ�¬è¿�(生产线->入库点)"), + TYPE_C(3,2, "托盘垛æ�¬è¿�(出库点->托盘缓存点)"), + TYPE_D(4,2, "托盘垛æ�¬è¿�(托盘缓存点->拆盘点)"), + TYPE_E(5,2, "托盘垛æ�¬è¿�(出库点->拆盘点)"), + TYPE_G(7,2, "托盘垛æ�¬è¿�(生产线->异常点)"); + + // 字段 + private final int code; + private final int xd; + private final String description; + + // 构造函数 + TaskType(int code, int xd, String description) { + this.code = code; + this.xd = xd; + this.description = description; + } + + // Getter 方法 + public int getCode() { + return code; + } + + public String getDescription() { + return description; + } + + public int getXd() { + return xd; + } + + // å�¯é€‰ï¼šæ ¹æ�® code 获å�–对应的枚举实例 + public static TaskType fromCode(int code) { + for (TaskType type : TaskType.values()) { + if (type.getCode() == code) { + return type; + } + } + throw new IllegalArgumentException("Invalid code: " + code); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/entity/RgvDevice.java b/src/com/wms/dss/ats/customs/abb/entity/RgvDevice.java new file mode 100644 index 0000000..f294b5a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/RgvDevice.java @@ -0,0 +1,49 @@ +package com.wms.dss.ats.customs.abb.entity; + +public class RgvDevice { + + public byte btId;// DDjid + public String dtype;// 类型 + public String dName; + + public int CZFS;// æ“�作方å¼�0未知1手动 2è�”机 + public int SBZT;// 设备状æ€�0ä½�ç½® 1无货待机 2有货待机 3 工作 + public long ZXRWH;// 正在执行任务å�· + public int HCZT;// è´§å�‰çжæ€�0æ— è´§1有货 + public int ZXJD;// 执行阶段1å�–货行走2å�–è´§3放货行走4放货5完æˆ� + public int YZD;// 当å‰�排 + public int MBZD;// 目标层 + public int YXXF;// å…�许下å�‘1å…�许 + public int XTXH; + public int XD; + public String trayCode; + + public RgvDevice() { + super(); + } + + public RgvDevice(byte btId, String dtype) { + super(); + this.btId = btId; + this.dtype = dtype; + } + + @Override + public String toString() { + return "DdjDevice{" + + "btId=" + btId + + ", dtype='" + dtype + '\'' + + ", dName='" + dName + '\'' + + ", CZFS=" + CZFS + + ", SBZT=" + SBZT + + ", ZXRWH=" + ZXRWH + + ", HCZT=" + HCZT + + ", ZXJD=" + ZXJD + + ", YZD=" + YZD + + ", MBZD=" + MBZD + + ", YXXF=" + YXXF + + ", XTXH=" + XTXH + + ", trayCode='" + trayCode + '\'' + + '}'; + } +} 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..3624b6b --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/SendData.java @@ -0,0 +1,43 @@ +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 SendData() { + + } + + 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/SsjDevice.java b/src/com/wms/dss/ats/customs/abb/entity/SsjDevice.java new file mode 100644 index 0000000..edd672c --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/entity/SsjDevice.java @@ -0,0 +1,51 @@ +package com.wms.dss.ats.customs.abb.entity; + +import java.util.Map; + +public class SsjDevice { + //输é€�机编å�· + public Integer btId; + //输é€�机类型 + public String dType; + //输é€�机å��ç§° + public String ssjNo; + //输é€�到ä½� + public Integer RKDW; + //任务å�· + public Integer RWH; + //输é€�状æ€� 手动 自动 报警 + public Integer Status; + //是å�¦ç©ºé—² + public Integer CKKX; + //æ–¹å�‘ + public Integer QX; + //纸箱类型 + public Integer ZXLX; + //放货接收完æˆ� + public Integer FHWC; + //是å�¦å­˜åœ¨å…¥åº“任务 0å�¦ 1是 + public Integer RKKX; + + //请求放纸箱 + public Integer FZX_QQ; + //放纸箱完æˆ� + public Integer FZX_WC; + + + public Integer YX_FZX; + + public Integer QR_FZX_WC; + + + public String QqFzxWrite; + public String QqFzxWcWrite; + + public SsjDevice() { + } + + public SsjDevice(Integer btId, String dType) { + this.btId = btId; + this.dType = dType; + } + +} 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/form/ABBMainFrame.java b/src/com/wms/dss/ats/customs/abb/form/ABBMainFrame.java new file mode 100644 index 0000000..9a79de1 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/form/ABBMainFrame.java @@ -0,0 +1,26 @@ +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..c08afce --- /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..f730096 --- /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/model/BasZxlx.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/BasZxlx.hbm.xml new file mode 100644 index 0000000..9fb0feb --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/BasZxlx.hbm.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/BasZxlx.java b/src/com/wms/dss/ats/customs/abb/model/BasZxlx.java new file mode 100644 index 0000000..019969a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/BasZxlx.java @@ -0,0 +1,61 @@ +package com.wms.dss.ats.customs.abb.model; + +import java.util.Date; + +public class BasZxlx { + + private String zxlx; + private String length; + private String width; + private String spare1; + private String spare2; + private String spare3; + + public String getZxlx() { + return zxlx; + } + + public void setZxlx(String zxlx) { + this.zxlx = zxlx; + } + + public String getLength() { + return length; + } + + public void setLength(String length) { + this.length = length; + } + + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + + 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; + } + + public String getSpare3() { + return spare3; + } + + public void setSpare3(String spare3) { + this.spare3 = spare3; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.hbm.xml new file mode 100644 index 0000000..ed3d44d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.hbm.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.java b/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.java new file mode 100644 index 0000000..77c450b --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/CarDeviceExecutionQueue.java @@ -0,0 +1,158 @@ +package com.wms.dss.ats.customs.abb.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +/** + * 空中å°�车æ�¬è¿�作业对象 car_device_execution_queue + * + * @author ruoyi + * @date 2025-05-07 + */ +public class CarDeviceExecutionQueue +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 任务编å�· */ + private String taskCode; + + /** 起始站点 */ + private String fromStation; + + /** 目标站点 */ + private String toStation; + + /** 磨具编å�· */ + private String containerCode; + + /** 任务状æ€� */ + private String status; + + private Date createTime; + + private String rwh; + + + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startTime; + + /** 结æ�Ÿæ—¶é—´ */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date finishTime; + + public String getRwh() { + return rwh; + } + + public void setRwh(String rwh) { + this.rwh = rwh; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setTaskCode(String taskCode) + { + this.taskCode = taskCode; + } + + public String getTaskCode() + { + return taskCode; + } + + public void setFromStation(String fromStation) + { + this.fromStation = fromStation; + } + + public String getFromStation() + { + return fromStation; + } + + public void setToStation(String toStation) + { + this.toStation = toStation; + } + + public String getToStation() + { + return toStation; + } + + public void setContainerCode(String containerCode) + { + this.containerCode = containerCode; + } + + public String getContainerCode() + { + return containerCode; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + + public void setFinishTime(Date finishTime) + { + this.finishTime = finishTime; + } + + public Date getFinishTime() + { + return finishTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return "CarDeviceExecutionQueue{" + + "id=" + id + + ", taskCode='" + taskCode + '\'' + + ", fromStation='" + fromStation + '\'' + + ", toStation='" + toStation + '\'' + + ", containerCode='" + containerCode + '\'' + + ", status='" + status + '\'' + + ", startTime=" + startTime + + ", finishTime=" + finishTime + + '}'; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/End.java b/src/com/wms/dss/ats/customs/abb/model/End.java new file mode 100644 index 0000000..ada6a6a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/End.java @@ -0,0 +1,27 @@ +package com.wms.dss.ats.customs.abb.model; + +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/model/KzxcSsjMsg.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/KzxcSsjMsg.hbm.xml new file mode 100644 index 0000000..2e9365d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/KzxcSsjMsg.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/KzxcSsjMsg.java b/src/com/wms/dss/ats/customs/abb/model/KzxcSsjMsg.java new file mode 100644 index 0000000..535e6f9 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/KzxcSsjMsg.java @@ -0,0 +1,67 @@ +package com.wms.dss.ats.customs.abb.model; + +public class KzxcSsjMsg { + private String ssjNo; + private Integer rkdw; + private Integer zxlx; + private String rwh; + private Integer status; + private String qx; + private Integer fhwc; + + public String getSsjNo() { + return ssjNo; + } + + public void setSsjNo(String ssjNo) { + this.ssjNo = ssjNo; + } + + public Integer getRkdw() { + return rkdw; + } + + public void setRkdw(Integer rkdw) { + this.rkdw = rkdw; + } + + public Integer getZxlx() { + return zxlx; + } + + public void setZxlx(Integer zxlx) { + this.zxlx = zxlx; + } + + public String getRwh() { + return rwh; + } + + public void setRwh(String rwh) { + this.rwh = rwh; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getQx() { + return qx; + } + + public void setQx(String qx) { + this.qx = qx; + } + + public Integer getFhwc() { + return fhwc; + } + + public void setFhwc(Integer fhwc) { + this.fhwc = fhwc; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/LineStatus.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/LineStatus.hbm.xml new file mode 100644 index 0000000..b38f2a0 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/LineStatus.hbm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/LineStatus.java b/src/com/wms/dss/ats/customs/abb/model/LineStatus.java new file mode 100644 index 0000000..6f84170 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/LineStatus.java @@ -0,0 +1,45 @@ +package com.wms.dss.ats.customs.abb.model; + +import java.util.Date; + +public class LineStatus { + + private String ssjNo; + private String status; + private String mode; + private String kx; + + + + public String getSsjNo() { + return ssjNo; + } + + public void setSsjNo(String ssjNo) { + this.ssjNo = ssjNo; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getKx() { + return kx; + } + + public void setKx(String kx) { + this.kx = kx; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.hbm.xml new file mode 100644 index 0000000..101d35a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.hbm.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.java b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.java new file mode 100644 index 0000000..da0c4b5 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueue.java @@ -0,0 +1,188 @@ +package com.wms.dss.ats.customs.abb.model; + + +/** + * rgv任务对象 rgv_device_execution_queue + * + * @author ruoyi + * @date 2025-05-07 + */ +public class RgvDeviceExecutionQueue +{ + private static final long serialVersionUID = 1L; + + /** 任务å�· */ + private Integer rwh; + + /** rgvå��ç§° */ + private String devName; + + /** rgv设备编å�· */ + private Integer devId; + + /** 任务状æ€� */ + private Integer rwzt; + + /** 托盘ç � */ + private String trayCode; + + /** */ + private Integer ydz; + + /** 原站点 */ + private Integer yzd; + + /** */ + private Integer mbdz; + + /** 目标站点 */ + private Integer mbzd; + + /** 是å�¦ä¸‹å�‘ */ + private String xf; + + /** 任务类型 */ + private Integer rwlx; + + /** 生æˆ�æ—¶é—´ */ + private String scsj; + + /** 下å�‘æ—¶é—´ */ + private String xfsj; + + /** 结æ�Ÿæ—¶é—´ */ + private String jssj; + + /** 触å�‘æ–¹å¼� */ + private Integer mlfs; + /* 所在巷é�“*/ + private int hd; + + public int getHd() { + return hd; + } + + public void setHd(int hd) { + this.hd = hd; + } + + public Integer getRwh() { + return rwh; + } + + public void setRwh(Integer rwh) { + this.rwh = rwh; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public Integer getDevId() { + return devId; + } + + public void setDevId(Integer devId) { + this.devId = devId; + } + + public Integer getRwzt() { + return rwzt; + } + + public void setRwzt(Integer rwzt) { + this.rwzt = rwzt; + } + + public String getTrayCode() { + return trayCode; + } + + public void setTrayCode(String trayCode) { + this.trayCode = trayCode; + } + + public Integer getYdz() { + return ydz; + } + + public void setYdz(Integer ydz) { + this.ydz = ydz; + } + + public Integer getYzd() { + return yzd; + } + + public void setYzd(Integer yzd) { + this.yzd = yzd; + } + + public Integer getMbdz() { + return mbdz; + } + + public void setMbdz(Integer mbdz) { + this.mbdz = mbdz; + } + + public Integer getMbzd() { + return mbzd; + } + + public void setMbzd(Integer mbzd) { + this.mbzd = mbzd; + } + + public String getXf() { + return xf; + } + + public void setXf(String xf) { + this.xf = xf; + } + + public Integer getRwlx() { + return rwlx; + } + + public void setRwlx(Integer rwlx) { + this.rwlx = rwlx; + } + + 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 Integer getMlfs() { + return mlfs; + } + + public void setMlfs(Integer mlfs) { + this.mlfs = mlfs; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.hbm.xml new file mode 100644 index 0000000..ee20b4b --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.hbm.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.java b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.java new file mode 100644 index 0000000..c1b08cc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvDeviceExecutionQueueFinish.java @@ -0,0 +1,188 @@ +package com.wms.dss.ats.customs.abb.model; + + +/** + * rgv任务对象 rgv_device_execution_queue + * + * @author ruoyi + * @date 2025-05-07 + */ +public class RgvDeviceExecutionQueueFinish +{ + private static final long serialVersionUID = 1L; + + /** 任务å�· */ + private Integer rwh; + + /** rgvå��ç§° */ + private String devName; + + /** rgv设备编å�· */ + private Integer devId; + + /** 任务状æ€� */ + private Integer rwzt; + + /** 托盘ç � */ + private String trayCode; + + /** */ + private Integer ydz; + + /** 原站点 */ + private Integer yzd; + + /** */ + private Integer mbdz; + + /** 目标站点 */ + private Integer mbzd; + + /** 是å�¦ä¸‹å�‘ */ + private String xf; + + /** 任务类型 */ + private Integer rwlx; + + /** 生æˆ�æ—¶é—´ */ + private String scsj; + + /** 下å�‘æ—¶é—´ */ + private String xfsj; + + /** 结æ�Ÿæ—¶é—´ */ + private String jssj; + + /** 触å�‘æ–¹å¼� */ + private Integer mlfs; + /* 所在巷é�“*/ + private int hd; + + public int getHd() { + return hd; + } + + public void setHd(int hd) { + this.hd = hd; + } + + public Integer getRwh() { + return rwh; + } + + public void setRwh(Integer rwh) { + this.rwh = rwh; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public Integer getDevId() { + return devId; + } + + public void setDevId(Integer devId) { + this.devId = devId; + } + + public Integer getRwzt() { + return rwzt; + } + + public void setRwzt(Integer rwzt) { + this.rwzt = rwzt; + } + + public String getTrayCode() { + return trayCode; + } + + public void setTrayCode(String trayCode) { + this.trayCode = trayCode; + } + + public Integer getYdz() { + return ydz; + } + + public void setYdz(Integer ydz) { + this.ydz = ydz; + } + + public Integer getYzd() { + return yzd; + } + + public void setYzd(Integer yzd) { + this.yzd = yzd; + } + + public Integer getMbdz() { + return mbdz; + } + + public void setMbdz(Integer mbdz) { + this.mbdz = mbdz; + } + + public Integer getMbzd() { + return mbzd; + } + + public void setMbzd(Integer mbzd) { + this.mbzd = mbzd; + } + + public String getXf() { + return xf; + } + + public void setXf(String xf) { + this.xf = xf; + } + + public Integer getRwlx() { + return rwlx; + } + + public void setRwlx(Integer rwlx) { + this.rwlx = rwlx; + } + + 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 Integer getMlfs() { + return mlfs; + } + + public void setMlfs(Integer mlfs) { + this.mlfs = mlfs; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvMsg.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/RgvMsg.hbm.xml new file mode 100644 index 0000000..423ecbd --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvMsg.hbm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/RgvMsg.java b/src/com/wms/dss/ats/customs/abb/model/RgvMsg.java new file mode 100644 index 0000000..de9cc1e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/RgvMsg.java @@ -0,0 +1,103 @@ +package com.wms.dss.ats.customs.abb.model; + +public class RgvMsg { + private int id; + private String devName; + private Integer rwh; + private Integer czfs; + private Integer yxzt; + private Integer ydz; + private Integer mbdz; + private Integer yczt; + private Integer yxxf; + private Integer jdbz; + private String trayCode; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public Integer getRwh() { + return rwh; + } + + public void setRwh(Integer rwh) { + this.rwh = rwh; + } + + public Integer getCzfs() { + return czfs; + } + + public void setCzfs(Integer czfs) { + this.czfs = czfs; + } + + public Integer getYxzt() { + return yxzt; + } + + public void setYxzt(Integer yxzt) { + this.yxzt = yxzt; + } + + public Integer getYdz() { + return ydz; + } + + public void setYdz(Integer ydz) { + this.ydz = ydz; + } + + public Integer getMbdz() { + return mbdz; + } + + public void setMbdz(Integer mbdz) { + this.mbdz = mbdz; + } + + public Integer getYczt() { + return yczt; + } + + public void setYczt(Integer yczt) { + this.yczt = yczt; + } + + public Integer getYxxf() { + return yxxf; + } + + public void setYxxf(Integer yxxf) { + this.yxxf = yxxf; + } + + public Integer getJdbz() { + return jdbz; + } + + public void setJdbz(Integer jdbz) { + this.jdbz = jdbz; + } + + public String getTrayCode() { + return trayCode; + } + + public void setTrayCode(String trayCode) { + this.trayCode = trayCode; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/SsjMsg.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/SsjMsg.hbm.xml new file mode 100644 index 0000000..776ea21 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/SsjMsg.hbm.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/model/SsjMsg.java b/src/com/wms/dss/ats/customs/abb/model/SsjMsg.java new file mode 100644 index 0000000..f1fb0b6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/SsjMsg.java @@ -0,0 +1,49 @@ +package com.wms.dss.ats.customs.abb.model; + +public class SsjMsg { + private int ssjNo; + private Integer rkdw; + private Integer ckkx; + private String rwh; + private Integer status; + + public int getSsjNo() { + return ssjNo; + } + + public void setSsjNo(int ssjNo) { + this.ssjNo = ssjNo; + } + + public Integer getRkdw() { + return rkdw; + } + + public void setRkdw(Integer rkdw) { + this.rkdw = rkdw; + } + + public Integer getCkkx() { + return ckkx; + } + + public void setCkkx(Integer ckkx) { + this.ckkx = ckkx; + } + + public String getRwh() { + return rwh; + } + + public void setRwh(String rwh) { + this.rwh = rwh; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/src/com/wms/dss/ats/customs/abb/model/end.hbm.xml b/src/com/wms/dss/ats/customs/abb/model/end.hbm.xml new file mode 100644 index 0000000..c0509a1 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/model/end.hbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + 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..9d7399e --- /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/IsoCarInteractionSsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoCarInteractionSsj.java new file mode 100644 index 0000000..c1f3b13 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoCarInteractionSsj.java @@ -0,0 +1,208 @@ +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 com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoCarInteractionSsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoCarInteractionSsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + //å�–货输é€�机 + for (int i = 0; i < 1; i++) { + String ssjId = "carInteractionSsj-" + i; + String ssjNo = "P2026"; + String address = "DB503.0"; + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("24")); + String ddsx1; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.Status = ParseUtil.optInt(0, ddsx1); + ssj.RWH = ParseUtil.optDInt(2, ddsx1); + ssj.RKDW = ParseUtil.optInt(6, ddsx1); + ssj.ZXLX = ParseUtil.optInt(8, ddsx1); + ssj.QX = ParseUtil.optInt(10, ddsx1); + ssj.FHWC = ParseUtil.optInt(22, ddsx1); + } + } + //放货输é€�机 + for (int i = 0; i < 7; i++) { + String ssjId = "carInteractionReleaseSsj-" + i; + String ssjNo = (i+1)+""; + + String address= ""; + String QqFzxWrite=""; + String QqFzxWcWrite=""; + switch (i){ + case 0: + address = "DB516.0"; + QqFzxWrite="DB516.6"; + QqFzxWcWrite="DB516.8"; + break; + case 1: + address = "DB516.12"; + QqFzxWrite="DB516.18"; + QqFzxWcWrite="DB516.20"; + break; + case 2: + address = "DB516.24"; + QqFzxWrite="DB516.30"; + QqFzxWcWrite="DB516.32"; + break; + case 3: + address = "DB516.36"; + QqFzxWrite="DB516.42"; + QqFzxWcWrite="DB516.44"; + break; + case 4: + address = "DB516.48"; + QqFzxWrite="DB516.54"; + QqFzxWcWrite="DB516.56"; + break; + case 5: + address = "DB516.60"; + QqFzxWrite="DB516.66"; + QqFzxWcWrite="DB516.68"; + break; + case 6: + address = "DB516.72"; + QqFzxWrite="DB516.78"; + QqFzxWcWrite="DB516.80"; + break; + } + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + ssj.QqFzxWcWrite=QqFzxWcWrite; + ssj.QqFzxWrite=QqFzxWrite; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.ZXLX = ParseUtil.optInt(0, ddsx1); + ssj.FZX_QQ = ParseUtil.optInt(2, ddsx1); + ssj.FZX_WC = ParseUtil.optInt(4, ddsx1); + } + + OperateResultExOne read3 = readWriteNet.Read(address, Short.parseShort("4")); + String ddsx2; + if (read3.IsSuccess){ + ddsx2= SoftBasic.ByteToHexString(read3.Content); + ssj.YX_FZX = ParseUtil.optInt(0, ddsx2); + ssj.QR_FZX_WC= ParseUtil.optInt(2, ddsx2); + } + + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoInOutTraySsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoInOutTraySsj.java new file mode 100644 index 0000000..1caef2c --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoInOutTraySsj.java @@ -0,0 +1,156 @@ +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 com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoInOutTraySsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoInOutTraySsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 1; i++) { + String ssjId = "inOutTraySsj-" + i; + String ssjNo = "1023"; + String address = "DB501.264"; + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("14")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + ssj.RKKX = ParseUtil.optInt(12, ddsx1); + } + } + for (int i = 0; i < 1; i++) { + String ssjId = "exceptionSsj-" + i; + String ssjNo = "1019"; + String address = "DB501.216"; + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("14")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + //ssj.RKKX = 1;//ParseUtil.optInt(12, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoInTraySsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoInTraySsj.java new file mode 100644 index 0000000..e073d9d --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoInTraySsj.java @@ -0,0 +1,138 @@ +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 com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoInTraySsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoInTraySsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 1; i++) { + String ssjId = "inTraySsj-" + i; + String ssjNo = "1022"; + String address = "DB501.252"; + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoOtherSsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoOtherSsj.java new file mode 100644 index 0000000..4dd66fb --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoOtherSsj.java @@ -0,0 +1,135 @@ +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.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoOtherSsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoOtherSsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 25; i++) { + String ssjId = "otherSsj-" + i; + String formattedNumber = String.format("%02d", i+1); + String ssjNo = "20"+formattedNumber; + String address = "DB506."+i*2; + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("2")); + String ddsx1; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.Status = ParseUtil.optInt(0, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoProductionLineSsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoProductionLineSsj.java new file mode 100644 index 0000000..3d7aa08 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoProductionLineSsj.java @@ -0,0 +1,215 @@ +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.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoProductionLineSsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoProductionLineSsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 7; i++) { + String ssjId = "productionLineStartSsj-" + i; + String ssjNo = ""; + String address = ""; + + switch (i){ + case 0: + ssjNo = "1001"; + address = "DB501.0"; + break; + case 1: + ssjNo = "1003"; + address = "DB501.12"; + break; + case 2: + ssjNo = "1007"; + address = "DB501.36"; + break; + case 3: + ssjNo = "1009"; + address = "DB501.48"; + break; + case 4: + ssjNo = "1011"; + address = "DB501.60"; + break; + case 5: + ssjNo = "1015"; + address = "DB501.84"; + break; + case 6: + ssjNo = "1017"; + address = "DB501.96"; + break; + } + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + for (int i = 0; i < 7; i++) { + String ssjId = "productionLineEndSsj-" + i; + String ssjNo = ""; + String address = ""; + + switch (i){ + case 0: + ssjNo = "1002"; + address = "DB501.108"; + break; + case 1: + ssjNo = "1004"; + address = "DB501.120"; + break; + case 2: + ssjNo = "1008"; + address = "DB501.144"; + break; + case 3: + ssjNo = "1010"; + address = "DB501.156"; + break; + case 4: + ssjNo = "1012"; + address = "DB501.168"; + break; + case 5: + ssjNo = "1016"; + address = "DB501.192"; + break; + case 6: + ssjNo = "1018"; + address = "DB501.204"; + break; + } + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv1.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv1.java new file mode 100644 index 0000000..f95c4ae --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv1.java @@ -0,0 +1,166 @@ +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.RgvDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTcpClientRgv1 extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsRgvParam = null; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientRgv1(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.hsRgvParam = (HashMap) this.hsComParam.get("hsRgvMap1"); + + this.strIp = (String) hsComParam.get("strIpRgv"); + this.iPort = (Integer) hsComParam.get("iPortRgv"); + this.slot = (Integer) hsComParam.get("slotRgv"); + 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("é‡�å�¯rgv1"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------线程--------读å�–堆垛机1ä¿¡æ�¯-----------开始---------------------"); + if (IsConnect()) { + String address = "0", rgvId = "rgv-1"; + address = "DB4.0"; + + RgvDevice rgv = (RgvDevice) hsRgvParam.get(rgvId); + rgv.dName = "1å�·RGV"; + rgv.CZFS = 0; //转为16进制的整型 + rgv.SBZT = 0; + rgv.ZXRWH = 0; + rgv.HCZT = 0; + rgv.ZXJD = 0; + rgv.YZD = 0; + rgv.MBZD = 0; + rgv.YXXF = 0; + rgv.XTXH = 0; + OperateResultExOne read1 = readWriteNet.Read(address, Short.parseShort("22"));//readWriteNet.Read(地å�€ï¼ŒShort的读å�–地å�€é•¿åº¦) + String ddsx = "0"; + if (read1.IsSuccess) { + ddsx = SoftBasic.ByteToHexString(read1.Content); + rgv.CZFS = ParseUtil.optInt(0, ddsx);//Integer.parseInt(ddsx.substring(0, 4), 16); + rgv.SBZT = ParseUtil.optInt(2, ddsx);//Integer.parseInt(ddsx.substring(4, 8), 16); + rgv.ZXRWH = ParseUtil.optDInt(4, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + rgv.YZD = ParseUtil.optInt(8, ddsx);//Integer.parseInt(ddsx.substring(16, 20), 16); + rgv.MBZD = ParseUtil.optInt(10, ddsx);//Integer.parseInt(ddsx.substring(36, 40), 16); + rgv.ZXJD = ParseUtil.optInt(12, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + rgv.YXXF = ParseUtil.optInt(18, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + rgv.XTXH = ParseUtil.optInt(20, ddsx);//Integer.parseInt(ddsx.substring(44, 48), 16); + }// å�˜é‡�.Substring(å�‚æ•°1,å�‚æ•°2); æ•´åž‹4个字节 é•¿æ•´åž‹8个字节 + + address = "DB81.0"; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("20"));//readWriteNet.Read(地å�€ï¼ŒShort的读å�–地å�€é•¿åº¦) + String ddsx2 = "0"; + if (read2.IsSuccess) { + ddsx2 = SoftBasic.ByteToHexString(read2.Content); + String trayCode = "9999999"; + String trayCodeL1005 = ParseUtil.optString(2, ddsx2); + String trayCodeL1013 = ParseUtil.optString(12, ddsx2); + if (!trayCodeL1005.equals("9999999")){ + trayCode= trayCodeL1005; + } + if (!trayCodeL1013.equals("9999999")){ + trayCode= trayCodeL1013; + } + rgv.trayCode = trayCode; + } + Thread.sleep(1000); + } 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 WritetoRgv(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/IsoTcpClientRgv2.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv2.java new file mode 100644 index 0000000..d447df7 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv2.java @@ -0,0 +1,152 @@ +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.RgvDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTcpClientRgv2 extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsRgvParam = null; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientRgv2(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.hsRgvParam = (HashMap) this.hsComParam.get("hsRgvMap2"); + + this.strIp = (String) hsComParam.get("strIpRgv"); + this.iPort = (Integer) hsComParam.get("iPortRgv"); + this.slot = (Integer) hsComParam.get("slotRgv"); + 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("é‡�å�¯rgv2"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------线程--------读å�–堆垛机1ä¿¡æ�¯-----------开始---------------------"); + if (IsConnect()) { + String address = "0", rgvId = "rgv-2"; + address = "DB4.0"; + + RgvDevice rgv = (RgvDevice) hsRgvParam.get(rgvId); + rgv.dName = "2å�·RGV"; + rgv.CZFS = 0; //转为16进制的整型 + rgv.SBZT = 0; + rgv.ZXRWH = 0; + rgv.HCZT = 0; + rgv.ZXJD = 0; + rgv.YZD = 0; + rgv.MBZD = 0; + rgv.YXXF = 0; + rgv.XTXH = 0; + OperateResultExOne read1 = readWriteNet.Read(address, Short.parseShort("22"));//readWriteNet.Read(地å�€ï¼ŒShort的读å�–地å�€é•¿åº¦) + String ddsx = "0"; + if (read1.IsSuccess) { + ddsx = SoftBasic.ByteToHexString(read1.Content); + + + rgv.CZFS = ParseUtil.optInt(0, ddsx);//Integer.parseInt(ddsx.substring(0, 4), 16); + rgv.SBZT = ParseUtil.optInt(2, ddsx);//Integer.parseInt(ddsx.substring(4, 8), 16); + rgv.ZXRWH = ParseUtil.optDInt(4, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + rgv.YZD = ParseUtil.optInt(8, ddsx);//Integer.parseInt(ddsx.substring(16, 20), 16); + rgv.MBZD = ParseUtil.optInt(10, ddsx);//Integer.parseInt(ddsx.substring(36, 40), 16); + rgv.ZXJD = ParseUtil.optInt(12, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + rgv.YXXF = ParseUtil.optInt(18, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + rgv.XTXH = ParseUtil.optInt(20, ddsx);//Integer.parseInt(ddsx.substring(44, 48), 16); + }// å�˜é‡�.Substring(å�‚æ•°1,å�‚æ•°2); æ•´åž‹4个字节 é•¿æ•´åž‹8个字节 + //m_dao.updateSql("update IpErrorMsg set msg='PLC:"+strIp+" 连接正常' where ip='"+strIp+"' and msg !='"+strIp+" 连接正常'"); + Thread.sleep(1000); + } 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 WritetoRgv(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/IsoTcpClientRgv3.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv3.java new file mode 100644 index 0000000..861c9ef --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTcpClientRgv3.java @@ -0,0 +1,167 @@ +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.RgvDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTcpClientRgv3 extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + public Hashtable hsSysParam = null; + public Hashtable hsComParam = null; + public SiemensS7Net siemensS7Net = null; + public static IReadWriteNet readWriteNet = null; + public boolean success = false; + public HashMap hsRgvParam = null; + public HashMap hsSSJParam = null; + public EntityDAO m_dao; + + @SuppressWarnings("unchecked") + public IsoTcpClientRgv3(Hashtable hsComParam, Hashtable hsSysParam, EntityDAO m_dao) { + this.hsComParam = hsComParam; + this.hsSysParam = hsSysParam; + this.hsRgvParam = (HashMap) this.hsComParam.get("hsRgvMap3"); + + this.strIp = (String) hsComParam.get("strIpRgv"); + this.iPort = (Integer) hsComParam.get("iPortRgv"); + this.slot = (Integer) hsComParam.get("slotRgv"); + 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("é‡�å�¯rgv3"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + //Logger.info("--------------------线程--------读å�–堆垛机1ä¿¡æ�¯-----------开始---------------------"); + if (IsConnect()) { + String address = "0", rgvId = "rgv-3"; + address = "DB4.0"; + + RgvDevice rgv = (RgvDevice) hsRgvParam.get(rgvId); + rgv.dName = "3å�·RGV"; + rgv.CZFS = 0; //转为16进制的整型 + rgv.SBZT = 0; + rgv.ZXRWH = 0; + rgv.HCZT = 0; + rgv.ZXJD = 0; + rgv.YZD = 0; + rgv.MBZD = 0; + rgv.YXXF = 0; + rgv.XTXH = 0; + OperateResultExOne read1 = readWriteNet.Read(address, Short.parseShort("22"));//readWriteNet.Read(地å�€ï¼ŒShort的读å�–地å�€é•¿åº¦) + String ddsx = "0"; + if (read1.IsSuccess) { + ddsx = SoftBasic.ByteToHexString(read1.Content); + rgv.CZFS = ParseUtil.optInt(0, ddsx);//Integer.parseInt(ddsx.substring(0, 4), 16); + rgv.SBZT = ParseUtil.optInt(2, ddsx);//Integer.parseInt(ddsx.substring(4, 8), 16); + rgv.ZXRWH = ParseUtil.optDInt(4, ddsx);//Long.parseLong(ddsx.substring(48, 64), 16); + rgv.YZD = ParseUtil.optInt(8, ddsx);//Integer.parseInt(ddsx.substring(16, 20), 16); + rgv.MBZD = ParseUtil.optInt(10, ddsx);//Integer.parseInt(ddsx.substring(36, 40), 16); + rgv.ZXJD = ParseUtil.optInt(12, ddsx);//Integer.parseInt(ddsx.substring(12, 16), 16); + rgv.YXXF = ParseUtil.optInt(18, ddsx);//Integer.parseInt(ddsx.substring(40, 44), 16); + rgv.XTXH = ParseUtil.optInt(20, ddsx);//Integer.parseInt(ddsx.substring(44, 48), 16); + }// å�˜é‡�.Substring(å�‚æ•°1,å�‚æ•°2); æ•´åž‹4个字节 é•¿æ•´åž‹8个字节 + + address = "DB81.0"; + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("20"));//readWriteNet.Read(地å�€ï¼ŒShort的读å�–地å�€é•¿åº¦) + String ddsx2 = "0"; + if (read2.IsSuccess) { + ddsx2 = SoftBasic.ByteToHexString(read2.Content); + String trayCode = "9999999"; + String trayCodeL1005 = ParseUtil.optString(2, ddsx2); + String trayCodeL1013 = ParseUtil.optString(12, ddsx2); + if (!trayCodeL1005.equals("9999999")){ + trayCode= trayCodeL1005; + } + if (!trayCodeL1013.equals("9999999")){ + trayCode= trayCodeL1013; + } + rgv.trayCode = trayCode; + } + Thread.sleep(1000); + + } 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--------------线程--------读å�–rgv3ä¿¡æ�¯-----------结æ�Ÿ0--------------------"); + reConnect(); + } + // æ¯�次循环打开关闭链接 + //reConnect(); + } + closeServer(); + } + + /// 堆垛机任务下å�‘ + public static int WritetoRgv(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/IsoTrayCacheSsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTrayCacheSsj.java new file mode 100644 index 0000000..886a04e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTrayCacheSsj.java @@ -0,0 +1,149 @@ +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 com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTrayCacheSsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoTrayCacheSsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 2; i++) { + String ssjId = "trayCacheSsj-" + i; + String ssjNo = ""; + String address = ""; + + switch (i){ + case 0: + ssjNo = "1020"; + address = "DB501.228"; + break; + case 1: + ssjNo = "1021"; + address = "DB501.240"; + break; + } + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/IsoTrayDisassembleStartSsj.java b/src/com/wms/dss/ats/customs/abb/plc/IsoTrayDisassembleStartSsj.java new file mode 100644 index 0000000..8bf5ad5 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/IsoTrayDisassembleStartSsj.java @@ -0,0 +1,176 @@ +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 com.ricosoft.common.dao.dataSource.EntityDAO; +import com.ricosoft.common.logger.Logger; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.ParseUtil; + +import java.util.HashMap; +import java.util.Hashtable; + +public class IsoTrayDisassembleStartSsj extends Thread { + /* ip地å�€ */ + String strIp = ""; + /* 端å�£å�· */ + int iPort = 102; + /* æ§½å�£å�· */ + int slot = 1; + + + 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 IsoTrayDisassembleStartSsj(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; + } 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("é‡�å�¯è¾“é€�机"); + } + + @Override + public void run() { + while (!Boolean.valueOf((String) hsSysParam.get("bStopFlag"))) { + try { + if (IsConnect()) { + for (int i = 0; i < 2; i++) { + String ssjId = "trayDisassembleStartSsj-" + i; + String ssjNo = ""; + String address = ""; + + if (i == 0){ + ssjNo = "1006"; + address = "DB501.132"; + } + + if (i == 1){ + ssjNo = "1014"; + address = "DB501.180"; + } + + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + for (int i = 0; i < 2; i++) { + String ssjId = "trayDisassembleEndSsj-" + i; + String ssjNo = ""; + String address = ""; + + if (i == 0){ + ssjNo = "1005"; + address = "DB501.24"; + } + + if (i == 1){ + ssjNo = "1013"; + address = "DB501.72"; + } + + SsjDevice ssj = (SsjDevice) hsSSJParam.get(ssjId); + OperateResultExOne read2 = readWriteNet.Read(address, Short.parseShort("12")); + String ddsx1 = "0"; + if (read2.IsSuccess) { + ddsx1 = SoftBasic.ByteToHexString(read2.Content); + ssj.ssjNo = ssjNo; + ssj.RKDW = ParseUtil.optInt(2, ddsx1); + ssj.CKKX = ParseUtil.optInt(4, ddsx1); + ssj.RWH = ParseUtil.optDInt(6, ddsx1); + ssj.Status = ParseUtil.optInt(10, ddsx1); + } + } + Thread.sleep(1000); + } else { + reConnect(); + } + } catch (Exception ex) { + 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; + } + + +} 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..11d68a6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/PLCCorrespondService.java @@ -0,0 +1,45 @@ +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); + ReadPLCRGV1.read(m_hsSysParam,m_dao); + ReadPLCRGV2.read(m_hsSysParam,m_dao); + ReadPLCRGV3.read(m_hsSysParam,m_dao); + + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV1.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV1.java new file mode 100644 index 0000000..7631823 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV1.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.RgvDevice; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCRGV1 { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + + HashMap hsDDJMap = new HashMap(); + + String strIp = "10.24.111.115";///Rgv plc对应ip地å�€ + String strPort = "102"; + String strSLot = "0"; + hsComParam.put("strIpRgv", strIp); + hsComParam.put("iPortRgv", Integer.parseInt(strPort)); + hsComParam.put("slotRgv", Integer.parseInt(strSLot)); + + + //堆垛机 + RgvDevice rgv = new RgvDevice((byte)1, "rgv"); + hsDDJMap.put(rgv.dtype + "-" + rgv.btId, rgv); + + hsComParam.put("hsRgvMap1", hsDDJMap); + m_hsSysParam.put("hsComParamRgv1", hsComParam); + // PLC通讯客户端 + IsoTcpClientRgv1 tp = new IsoTcpClientRgv1(hsComParam, m_hsSysParam,m_dao); + tp.start(); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV2.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV2.java new file mode 100644 index 0000000..17c1ac6 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV2.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.RgvDevice; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCRGV2 { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + + HashMap hsDDJMap = new HashMap(); + + String strIp = "10.24.111.120";///Rgv plc对应ip地å�€ + String strPort = "102"; + String strSLot = "0"; + hsComParam.put("strIpRgv", strIp); + hsComParam.put("iPortRgv", Integer.parseInt(strPort)); + hsComParam.put("slotRgv", Integer.parseInt(strSLot)); + + + //堆垛机 + RgvDevice rgv = new RgvDevice((byte)2, "rgv"); + hsDDJMap.put(rgv.dtype + "-" + rgv.btId, rgv); + + hsComParam.put("hsRgvMap2", hsDDJMap); + m_hsSysParam.put("hsComParamRgv2", hsComParam); + // PLC通讯客户端 + IsoTcpClientRgv2 tp = new IsoTcpClientRgv2(hsComParam, m_hsSysParam,m_dao); + tp.start(); + } +} diff --git a/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV3.java b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV3.java new file mode 100644 index 0000000..2daa2fb --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCRGV3.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.RgvDevice; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Hashtable; + +public class ReadPLCRGV3 { + + public static void read(Hashtable m_hsSysParam,EntityDAO m_dao) { + Hashtable hsComParam = new Hashtable(); + + HashMap hsDDJMap = new HashMap(); + + String strIp = "10.24.111.125";///Rgv plc对应ip地å�€ + String strPort = "102"; + String strSLot = "0"; + hsComParam.put("strIpRgv", strIp); + hsComParam.put("iPortRgv", Integer.parseInt(strPort)); + hsComParam.put("slotRgv", Integer.parseInt(strSLot)); + + + //堆垛机 + RgvDevice rgv = new RgvDevice((byte)3, "rgv"); + hsDDJMap.put(rgv.dtype + "-" + rgv.btId, rgv); + + hsComParam.put("hsRgvMap3", hsDDJMap); + m_hsSysParam.put("hsComParamRgv3", hsComParam); + // PLC通讯客户端 + IsoTcpClientRgv3 tp = new IsoTcpClientRgv3(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..78bdffc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/plc/ReadPLCSSJ.java @@ -0,0 +1,95 @@ +package com.wms.dss.ats.customs.abb.plc; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; + +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 = "10.24.111.100"; + 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 = 0; i < 1; i++) { + SsjDevice ssj = new SsjDevice(i, "carInteractionSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //空中å°�车放货输é€�机读å�– + for (int i = 0; i < 7; i++) { + SsjDevice ssj = new SsjDevice(i, "carInteractionReleaseSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //产线入å�£è¯»å�– + for (int i = 0; i < 7; i++) { + SsjDevice ssj = new SsjDevice(i, "productionLineStartSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //产线出å�£è¯»å�– + for (int i = 0; i < 7; i++) { + SsjDevice ssj = new SsjDevice(i, "productionLineEndSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //托盘拆解入å�£è¯»å�– + for (int i = 0; i < 2; i++) { + SsjDevice ssj = new SsjDevice(i, "trayDisassembleStartSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //托盘拆解出å�£è¯»å�– + for (int i = 0; i < 2; i++) { + SsjDevice ssj = new SsjDevice(i, "trayDisassembleEndSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //托盘缓存读å�– + for (int i = 0; i < 2; i++) { + SsjDevice ssj = new SsjDevice(i, "trayCacheSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //托盘入出库读å�– + for (int i = 0; i < 1; i++) { + SsjDevice ssj = new SsjDevice(i, "inOutTraySsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //托盘出库读å�– + for (int i = 0; i < 1; i++) { + SsjDevice ssj = new SsjDevice(i, "inTraySsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + //异常空输é€�机 + for (int i = 0; i < 1; i++) { + SsjDevice ssj = new SsjDevice(i, "exceptionSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + + //其余输é€�机 + for (int i = 0; i < 25; i++) { + SsjDevice ssj = new SsjDevice(i, "otherSsj"); + hsSSJMap.put(ssj.dType + "-" + ssj.btId, ssj); + } + hsComParam.put("hsSSJMap", hsSSJMap); + m_hsSysParam.put("hsComParamSSJ", hsComParam); + + IsoCarInteractionSsj isoCarInteractionSsj = new IsoCarInteractionSsj(hsComParam, m_hsSysParam,m_dao); + IsoInOutTraySsj isoInTraySsj = new IsoInOutTraySsj(hsComParam, m_hsSysParam,m_dao); + IsoInTraySsj isoOutTraySsj = new IsoInTraySsj(hsComParam, m_hsSysParam,m_dao); + IsoProductionLineSsj isoProductionLineStartSsj = new IsoProductionLineSsj(hsComParam, m_hsSysParam,m_dao); + IsoTrayCacheSsj isoTrayCacheSsj = new IsoTrayCacheSsj(hsComParam, m_hsSysParam,m_dao); + IsoTrayDisassembleStartSsj isoTrayDisassembleStartSsj = new IsoTrayDisassembleStartSsj(hsComParam, m_hsSysParam, m_dao); + IsoOtherSsj isoOtherSsj = new IsoOtherSsj(hsComParam, m_hsSysParam, m_dao); + isoCarInteractionSsj.start(); + isoInTraySsj.start(); + isoOutTraySsj.start(); + isoProductionLineStartSsj.start(); + isoTrayCacheSsj.start(); + isoTrayDisassembleStartSsj.start(); + isoOtherSsj.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..212b926 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ABBThreadSchedule.java @@ -0,0 +1,79 @@ +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 CarInteractionSsjThread carInteractionSsjThread= null; + protected OutTraySsjThread outTraySsjThread= null; + protected ProductionLineEndSsjThread productionLineEndSsjThread= null; + protected RgvThread1 rgvThread1= null; + protected RgvThread2 rgvThread2= null; + protected RgvThread3 rgvThread3= null; + protected TrayDisassembleSsjThread trayDisassembleSsjThread= null; + protected CallTraySsjThread callTraySsjThread= 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 { + carInteractionSsjThread = new CarInteractionSsjThread(m_hsSysParam); + carInteractionSsjThread.setName("空中å°�车交互输é€�机"); + carInteractionSsjThread.start(); + Thread.sleep(400); + controlThread = new ControlThread(m_hsSysParam); + controlThread.setName("控制线程组"); + controlThread.start(); + Thread.sleep(3000); + trayDisassembleSsjThread = new TrayDisassembleSsjThread(m_hsSysParam); + trayDisassembleSsjThread.setName("托盘拆解线程组"); + trayDisassembleSsjThread.start(); + Thread.sleep(400); + productionLineEndSsjThread = new ProductionLineEndSsjThread(m_hsSysParam); + productionLineEndSsjThread.setName("产线入库结æ�Ÿè¾“é€�机"); + productionLineEndSsjThread.start(); + Thread.sleep(400); + + /*productionLineStartSsjThread = new ProductionLineStartSsjThread(m_hsSysParam); + productionLineStartSsjThread.setName("产线入库开始输é€�机"); + productionLineStartSsjThread.start(); + Thread.sleep(400);*/ + outTraySsjThread = new OutTraySsjThread(m_hsSysParam); + outTraySsjThread.setName("空托盘出库输é€�机"); + outTraySsjThread.start(); + Thread.sleep(400); + callTraySsjThread = new CallTraySsjThread(m_hsSysParam); + callTraySsjThread.setName("呼å�«ç©ºæ‰˜ç›˜çº¿ç¨‹"); + callTraySsjThread.start(); + Thread.sleep(400); + + rgvThread2 = new RgvThread2(m_hsSysParam); + rgvThread2.setName("RGV2线程组"); + rgvThread2.start(); + Thread.sleep(400); + rgvThread1 = new RgvThread1(m_hsSysParam); + rgvThread1.setName("RGV1线程组"); + rgvThread1.start(); + Thread.sleep(400); + rgvThread3 = new RgvThread3(m_hsSysParam); + rgvThread3.setName("RGV3线程组"); + rgvThread3.start(); + Thread.sleep(400); + + } catch (Exception er) { + Logger.error("........设备调度线程å�¯åŠ¨å‡ºé”™........" + er.getMessage()); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/CallTraySsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/CallTraySsjThread.java new file mode 100644 index 0000000..4fbd5fc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/CallTraySsjThread.java @@ -0,0 +1,175 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +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.SendData; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.model.LineStatus; +import com.wms.dss.ats.customs.abb.plc.IsoInOutTraySsj; +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.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +import static com.wms.dss.ats.customs.abb.common.TaskType.TYPE_C; +import static com.wms.dss.ats.customs.abb.common.TaskType.TYPE_E; + +public class CallTraySsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public CallTraySsjThread(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) { + //æ—¶é—´é”� + if (QueryDbDataUtils.getEndTime(m_dao)) { + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + List trayCacheSsj = DbGet.getTrayCacheSsj(); + List inOutTraySsj = DbGet.getInOutTraySsj(); + String ssjNo = ""; + for (SsjDevice ssjDevice : trayCacheSsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatch(ssjDevice,inOutTraySsj); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + + for (SsjDevice ssjDevice : inOutTraySsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatch1(ssjDevice); + }catch (Exception e){ + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + + try { + sleep(10000); + } catch (InterruptedException e) { + Logger.error(e.getMessage()); + } + } + } + + private void dispatch1(SsjDevice ssjDevice) { + //if (ssjDevice.CKKX==1){ + List notKxCacheSsjStatus = QueryDbDataUtils.getNotKxCacheSsjStatus(m_dao, 0); + if (CollUtil.isNotEmpty(notKxCacheSsjStatus) && notKxCacheSsjStatus.size()==2){ + SendData callSuccess = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(callSuccess); + int i = IsoInOutTraySsj.WritetoSSJ("DB501.280", bytes); + if (i==1){ + //Logger.info("写入 入库模å¼� DB501.280"); + } + } + //} + } + + + private void dispatch(SsjDevice trayCacheSsj,List OutSsjList) { + Integer kx = trayCacheSsj.CKKX; + String ssjNo = trayCacheSsj.ssjNo; + if (kx==1){ + //查询当å‰�输é€�机是å�¦å‘¼å�«è¿‡æ‰˜ç›˜ + List lineStatuses = QueryDbDataUtils.getCacheSsjStatus(m_dao,ssjNo); + + if (CollUtil.isNotEmpty(lineStatuses)){ + //有空闲缓存区 + if (OutSsjList.stream().allMatch(x->x.RKKX ==1)){ + List out = QueryDbDataUtils.getCacheSsjStatus(m_dao,OutSsjList.get(0).ssjNo); + boolean out1 = out.stream().allMatch(x -> x.getMode().equals("out")); + if (!out1){ + //切æ�¢è¾“é€�机模å¼�为出库 + Map param = new HashMap<>(); + param.put("workNo","120"); + param.put("taskType","out"); + String post = HttpUtil.post("http://localhost:85/api/line/mode", JSONUtil.toJsonStr(param)); + Logger.info("切æ�¢è¾“é€�机模å¼�" + post); + JSONObject map = JSONUtil.parseObj(post); + if (map.get("code").toString().equals("0")){ + SendData callSuccess = new SendData(Tools.INT, 2); + byte[] bytes = Tools.sendData(callSuccess); + int i = IsoInOutTraySsj.WritetoSSJ("DB501.280", bytes); + if (i==1){ + Logger.info("写入 出库模å¼� DB501.280"); + } + } + } + } + } + + + List trayDisassembleStartSsj = DbGet.getTrayDisassembleStartSsj(); + List trayCacheSsj1 = DbGet.getTrayCacheSsj(); + if (trayDisassembleStartSsj.stream().allMatch(x->x.CKKX==0) && trayCacheSsj1.stream().allMatch(x->x.CKKX==0)){ + return; + } + if (CollUtil.isNotEmpty(lineStatuses)){ + //有未呼å�«æ‰˜ç›˜çš„空闲缓存区 并且 输é€�机模å¼�为出库 + for (LineStatus lineStatus : lineStatuses) { + LineStatus outTray =QueryDbDataUtils.getOutTraySsjStatus(m_dao); + if (outTray.getMode().equals("out")){ + //请求托盘出库 + Map param = new HashMap<>(); + param.put("ssjNo",lineStatus.getSsjNo()); + param.put("workNo","120"); + param.put("taskType","out"); + String post = HttpUtil.post("http://localhost:85/api/line/callEmptyOut", JSONUtil.toJsonStr(param)); + Logger.info("呼å�«ç©ºæ‰˜ç›˜"+post); + JSONObject map = JSONUtil.parseObj(post); + + if (map.get("code").toString().equals("0")){ + SendData callSuccess = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(callSuccess); + int i = IsoInOutTraySsj.WritetoSSJ("DB501.278", bytes); + if (i==1){ + Logger.info("空托盘呼å�«æˆ�功,写入完æˆ�ä¿¡å�· DB501.278"); + } + }else if (map.get("code").toString().equals("500")){ + SendData callError = new SendData(Tools.INT, 2); + byte[] bytes = Tools.sendData(callError); + int i = IsoInOutTraySsj.WritetoSSJ("DB501.278", bytes); + if (i==1){ + Logger.info("没有空托盘,写入完æˆ�ä¿¡å�· DB501.278"); + } + }else { + Logger.info("呼å�«ç©ºæ‰˜ç›˜"+post); + } + } + } + } + + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/CarInteractionSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/CarInteractionSsjThread.java new file mode 100644 index 0000000..e341f6a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/CarInteractionSsjThread.java @@ -0,0 +1,355 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.convert.Convert; +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.JSONUtil; +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.ats.customs.abb.model.BasZxlx; +import com.wms.dss.ats.customs.abb.model.CarDeviceExecutionQueue; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.plc.IsoCarInteractionSsj; +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.*; + +public class CarInteractionSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public CarInteractionSsjThread(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) { + //æ—¶é—´é”� + if (QueryDbDataUtils.getEndTime(m_dao)) { + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + List carInteractionSsj = DbGet.getCarInteractionSsj(); + List carInteractionReleaseSsj = DbGet.getCarInteractionReleaseSsj(); + String ssjNo = ""; + for (SsjDevice ssjDevice : carInteractionSsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatch(ssjDevice); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + + for (SsjDevice ssjDevice : carInteractionReleaseSsj) { + try { + ssjNo = ssjDevice.ssjNo; + carRelease(ssjDevice); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e.getMessage()); + } + } + } + + //空中å°�车放货调度 + + private void carRelease(SsjDevice ssjDevice) { + //查询空中å°�车当å‰�é…�é€�完æˆ�作业 + CarDeviceExecutionQueue carDeviceExecutionFinishQueue = QueryDbDataUtils.getCarQueueByStatus(m_dao, "DELIVERY_IN_PLACE"); + if (carDeviceExecutionFinishQueue != null) { + + if (getXnQx(carDeviceExecutionFinishQueue.getToStation()).equals(ssjDevice.ssjNo)){ + if (ssjDevice.YX_FZX==0){ + //写入信æ�¯ 放货纸箱类型 放货完æˆ�å·¥ä½� + SendData qqFzx = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(qqFzx); + int i = IsoCarInteractionSsj.WriteToSSJ(ssjDevice.QqFzxWrite, bytes); + if (i==1){ + Logger.info("空中å°�车请求放货信å�· rwh:"+carDeviceExecutionFinishQueue.getTaskCode()); + } + } + + } + } + + carDeviceExecutionFinishQueue = QueryDbDataUtils.getCarQueueByStatus(m_dao, "SEND_FINISHED"); + if (carDeviceExecutionFinishQueue != null) { + if (getXnQx(carDeviceExecutionFinishQueue.getToStation()).equals(ssjDevice.ssjNo)) { + //写入信æ�¯ 放货纸箱类型 放货完æˆ�å·¥ä½� + SendData qqFzx = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(qqFzx); + int i = IsoCarInteractionSsj.WriteToSSJ(ssjDevice.QqFzxWcWrite, bytes); + if (i == 1) { + Logger.info("空中å°�车放货完æˆ�ä¿¡å�·å�‘é€�æˆ�功 rwh:" + carDeviceExecutionFinishQueue.getTaskCode()); + } + + } + } + + if (ssjDevice.FZX_QQ==1){ + CarDeviceExecutionQueue car = QueryDbDataUtils.getCarQueueByStatusAndStation(m_dao, "DELIVERY_IN_PLACE",getQx(Convert.toInt(ssjDevice.ssjNo))); + if (car!= null){ + m_dao.updateSql("update CarDeviceExecutionQueue set status = 'ALLOW_DISTRIBUTION' where taskCode ='"+car.getTaskCode()+"'"); + } + } + + if (ssjDevice.FZX_WC==1){ + CarDeviceExecutionQueue car = QueryDbDataUtils.getCarQueueByStatusAndStation(m_dao, "SEND_FINISHED",getQx(Convert.toInt(ssjDevice.ssjNo))); + if (car!= null){ + m_dao.updateSql("update CarDeviceExecutionQueue set status = 'SEND_FINISHED_SEND_COMPLETED' where taskCode ='" + car.getTaskCode() + "'"); + car_finish(m_dao, car.getTaskCode()); + } + } + } + + //空中å°�车å�–货调度 + private void dispatch(SsjDevice ssjDevice) { + Integer zxlx = ssjDevice.ZXLX; + Integer qx = ssjDevice.QX; + Integer ssdw = ssjDevice.RKDW; + Integer rwh = ssjDevice.RWH; + if (ssdw==1 && qx!=0 && zxlx!=0 && rwh !=0){ + //查询当å‰�托盘是å�¦ç”Ÿæˆ�任务 + CarDeviceExecutionQueue carDeviceExecutionQueue = QueryDbDataUtils.getCarQueueByRwh(m_dao, rwh); + if (carDeviceExecutionQueue ==null){ + Map param = new HashMap<>(); + param.put("taskCode", IdUtil.fastSimpleUUID()); + param.put("fromStation","A01"); + param.put("toStation",getQx(qx)); + param.put("rwh",rwh); + BasZxlx zxlxMap = QueryDbDataUtils.getZxlx(m_dao,zxlx); + if (ObjUtil.isNull(zxlxMap)) { + Logger.error("ä¸�支æŒ�的纸箱类型{}",zxlx); + return; + } + param.put("containerCode",zxlxMap.getZxlx()); + param.put("containerWidth",zxlxMap.getWidth()); + param.put("containerLength",zxlxMap.getLength()); + String post = HttpUtil.post("http://localhost:85/api/car/job/add", JSONUtil.toJsonStr(param)); + Logger.info("下å�‘空中å°�车任务"+post); + }else { + //创建任务状æ€�为待下å�‘å�Žå°�车å�¯ä»¥ä¸‹å�‘夹具 + if ("TASK_STARTED".equals(carDeviceExecutionQueue.getStatus())){ + m_dao.updateSql("update CarDeviceExecutionQueue set status = 'TASK_DISTRIBUTED' where rwh ='"+rwh+"'"); + } + } + } + + //查询空中å°�车当å‰�å�–货作业 + CarDeviceExecutionQueue carDeviceExecutionTakeQueue = QueryDbDataUtils.getCarQueueByRwh(m_dao, rwh); + if (carDeviceExecutionTakeQueue !=null){ + if ("TASK_DISTRIBUTED_SEND_COMPLETED".equals(carDeviceExecutionTakeQueue.getStatus())){ + SendData carDw = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(carDw); + //写入信æ�¯ å°�车到纸箱接驳ä½� + int i = IsoCarInteractionSsj.WriteToSSJ("DB503.16", bytes); + if (i==1){ + Logger.info("空中å°�车到ä½�,空中å°�车下å�‘å�–货完æˆ� rwh:"+rwh); + } + } + + if ("TAKE_FINISHED".equals(carDeviceExecutionTakeQueue.getStatus())) { + SendData fhwc = new SendData(Tools.INT, 1); + byte[] bytes = Tools.sendData(fhwc); + //写入信æ�¯ å�–货完æˆ� + int i = IsoCarInteractionSsj.WriteToSSJ("DB503.18", bytes); + if (i==1){ + Logger.info("空中å°�车å�–货完æˆ� rwh:"+rwh); + m_dao.updateSql("update CarDeviceExecutionQueue set status = 'TAKE_FINISHED_SEND_COMPLETED' where taskCode ='" + carDeviceExecutionTakeQueue.getTaskCode() + "'"); + } + } + } + } + + private Map getZxlx(Integer zxlx) { + Map zxlxMap = new HashMap<>(); + switch (zxlx){ + case 1: + zxlxMap.put("containerCode","1"); + zxlxMap.put("containerWidth","505"); + zxlxMap.put("containerLength","660"); + break; + case 2: + zxlxMap.put("containerCode","2"); + zxlxMap.put("containerWidth","330"); + zxlxMap.put("containerLength","470"); + break; + case 3: + zxlxMap.put("containerCode","3"); + zxlxMap.put("containerWidth","315"); + zxlxMap.put("containerLength","460"); + break; + case 4: + zxlxMap.put("containerCode","4"); + zxlxMap.put("containerWidth","316"); + zxlxMap.put("containerLength","450"); + break; + case 5: + zxlxMap.put("containerCode","5"); + zxlxMap.put("containerWidth","300"); + zxlxMap.put("containerLength","390"); + break; + case 6: + zxlxMap.put("containerCode","6"); + zxlxMap.put("containerWidth","295"); + zxlxMap.put("containerLength","390"); + break; + case 7: + zxlxMap.put("containerCode","7"); + zxlxMap.put("containerWidth","630"); + zxlxMap.put("containerLength","815"); + break; + case 8: + zxlxMap.put("containerCode","8"); + zxlxMap.put("containerWidth","295"); + zxlxMap.put("containerLength","390"); + break; + case 9: + zxlxMap.put("containerCode","9"); + zxlxMap.put("containerWidth","295"); + zxlxMap.put("containerLength","385"); + break; + case 10: + zxlxMap.put("containerCode","10"); + zxlxMap.put("containerWidth","325"); + zxlxMap.put("containerLength","460"); + break; + case 11: + zxlxMap.put("containerCode","11"); + zxlxMap.put("containerWidth","320"); + zxlxMap.put("containerLength","455"); + break; + case 12: + zxlxMap.put("containerCode","12"); + zxlxMap.put("containerWidth","325"); + zxlxMap.put("containerLength","410"); + break; + case 13: + zxlxMap.put("containerCode","13"); + zxlxMap.put("containerWidth","295"); + zxlxMap.put("containerLength","385"); + break; + case 14: + zxlxMap.put("containerCode","14"); + zxlxMap.put("containerWidth","290"); + zxlxMap.put("containerLength","400"); + break; + case 15: + zxlxMap.put("containerCode","15"); + zxlxMap.put("containerWidth","288"); + zxlxMap.put("containerLength","354"); + break; + case 16: + zxlxMap.put("containerCode","16"); + zxlxMap.put("containerWidth","288"); + zxlxMap.put("containerLength","354"); + break; + default: + throw new RuntimeException("未知纸箱类型 {}"+zxlx); + } + return zxlxMap; + } + + private String getQx(Integer qx) { + switch (qx){ + case 1: + return "A03"; + case 2: + return "A04"; + case 3: + return "A05"; + case 4: + return "A06"; + case 5: + return "A07"; + case 6: + return "A08"; + case 7: + return "A09"; + default: + throw new RuntimeException("未知去å�‘ {}"+qx); + } + } + + private String getXnQx(String qx) { + switch (qx){ + case "A03": + return "1"; + case "A04": + return "2"; + case "A05": + return "3"; + case "A06": + return "4"; + case "A07": + return "5"; + case "A08": + return "6"; + case "A09": + return "7"; + default: + throw new RuntimeException("未知去å�‘ {}"+qx); + } + } + + /** + * 调用存储过程proc_car_finish 完æˆ�rgv任务 + */ + private void car_finish(EntityDAO m_dao, String taskNo) { + StoredParameters ddjhParameter = new StoredParameters(1, taskNo); + StoredParameters result = new StoredParameters(2, ""); + StoredParameters result_msg = new StoredParameters(3, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_car_finish(?,?,?)}", + 2, 3, ddjhParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_rgv_finish 无该作业,请检查,任务å�·ï¼š" + taskNo); + break; + case 9: + Logger.info("proc_rgv_finish 存储过程问题,请检查"); + break; + case 10: + Logger.info("proc_rgv_finish 执行æˆ�功 任务å�·ï¼š"+ taskNo); + break; + default: + throw new SQLException("proc_rgv_finish 未知的返回值,任务å�·ï¼š" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}",exception.getMessage()); + } + } + + +} 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..7902247 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ControlThread.java @@ -0,0 +1,135 @@ +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 hsComParamRgv1 = null; + Hashtable hsComParamRgv2 = null; + Hashtable hsComParamRgv3 = 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"); + hsComParamRgv1 = (Hashtable) m_hsSysParam.get("hsComParamRgv1"); + hsComParamRgv2 = (Hashtable) m_hsSysParam.get("hsComParamRgv2"); + hsComParamRgv3 = (Hashtable) m_hsSysParam.get("hsComParamRgv3"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + + } + + @Override + public void run() { + while (!m_bStop) { + if (QueryDbDataUtils.getEndTime(m_dao)){ + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamRgv1 = hsComParamRgv1; + DbGet.hsComParamRgv2 = hsComParamRgv2; + DbGet.hsComParamRgv3 = hsComParamRgv3; + DbGet.hsComParamSSJ = hsComParamSSJ; + try { + //rgv监控 + List rgv1 = DbGet.getRgv1(); + List rgv2 = DbGet.getRgv2(); + List rgv3 = DbGet.getRgv3(); + rgvJk(rgv1); + rgvJk(rgv2); + rgvJk(rgv3); + //ssj监控 + List allSsj = DbGet.getAllSsj(); + ssjJk(allSsj); + //空中å°�车å�–è´§å¹³å�°ç›‘控 + List carInteractionSsj = DbGet.getCarInteractionSsj(); + carInteractionSsjJk(carInteractionSsj); + } catch (RuntimeException e) { + Logger.error("ControlThread", e.getMessage()); + }finally { + try { + sleep(1500); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + } + + private void carInteractionSsjJk(List carInteractionSsj) { + for (SsjDevice ssjDevice : carInteractionSsj) { + m_dao.updateSql( + "UPDATE KzxcSsjMsg\n" + + "SET \n" + + " rkdw = "+ssjDevice.RKDW+",\n" + + " zxlx = "+ssjDevice.ZXLX+",\n" + + " rwh = '"+ssjDevice.RWH+"',\n" + + " status = "+ssjDevice.Status+",\n" + + " qx = '"+ssjDevice.QX+"',\n" + + " fhwc = "+ssjDevice.FHWC+"\n" + + "WHERE ssjNo = '"+ssjDevice.ssjNo+"'" + ); + } + } + + private void ssjJk(List allSsj) { + for (SsjDevice ssjDevice : allSsj) { + m_dao.updateSql( + "update SsjMsg set rkdw ="+ssjDevice.RKDW+",ckkx="+ssjDevice.CKKX+",rwh="+ssjDevice.RWH+",status="+ssjDevice.Status + +" where ssjNo='"+ssjDevice.ssjNo+"'" + ); + } + } + + private void rgvJk(List rgv) { + for (RgvDevice rgvDevice : rgv) { + byte btId = rgvDevice.btId; + m_dao.updateSql( + "UPDATE RgvMsg\n" + + "SET \n" + + " devName = '"+rgvDevice.dName+"',\n" + + " rwh = "+rgvDevice.ZXRWH+",\n" + + " czfs = "+rgvDevice.CZFS+",\n" + + " yxzt = "+rgvDevice.ZXJD+",\n" + + " ydz = "+rgvDevice.YZD+",\n" + + " mbdz = "+rgvDevice.MBZD+",\n" + + " yczt = "+rgvDevice.SBZT+",\n" + + " yxxf = "+rgvDevice.YXXF+",\n" + + " jdbz = "+rgvDevice.ZXJD+",\n" + + " trayCode = '"+rgvDevice.trayCode+"'\n" + + "WHERE id = "+btId + ); + } + } + +} 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..2b68abc --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/DbGet.java @@ -0,0 +1,245 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.*; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueueFinish; +import com.wms.dss.common.server.form.Logger; + +import java.util.*; + +/** + * @author 13623 + */ /* + *@Version 1.0 + * æ•°æ�®èŽ·å�– + **/ +public class DbGet { + + static Hashtable hsComParamRgv1 = null; + static Hashtable hsComParamRgv2 = null; + static Hashtable hsComParamRgv3 = null; + static Hashtable hsComParamSSJ = null; + + + public static List getCarInteractionSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 1; i++) { + ls.add((SsjDevice) hsSSJMap.get("carInteractionSsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + + public static List getProductionLineStartSsj1() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-0")); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-1")); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-2")); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-3")); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-4")); + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getProductionLineStartSsj2() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-5")); + ls.add((SsjDevice) hsSSJMap.get("productionLineStartSsj-6")); + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + + + public static List getTrayDisassembleEndSsj1() { + + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SsjDevice) hsSSJMap.get("trayDisassembleEndSsj-0")); + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getTrayDisassembleEndSsj2() { + + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SsjDevice) hsSSJMap.get("trayDisassembleEndSsj-1")); + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getTrayCacheSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 2; i++) { + ls.add((SsjDevice) hsSSJMap.get("trayCacheSsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getTrayDisassembleStartSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 2; i++) { + ls.add((SsjDevice) hsSSJMap.get("trayDisassembleStartSsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getProductionLineEndSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 3));//4 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 6));//7 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 1));//2 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 5));//6 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 4));//5 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 0));//1 + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + 2));//3 + /*for (int i = 0; i < 7; i++) { + ls.add((SsjDevice) hsSSJMap.get("productionLineEndSsj-" + i)); + }*/ + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getInTraySsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 1; i++) { + ls.add((SsjDevice) hsSSJMap.get("inTraySsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getInOutTraySsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 1; i++) { + ls.add((SsjDevice) hsSSJMap.get("inOutTraySsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getAllSsj() { + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (Object o : hsSSJMap.keySet()) { + if ("carInteractionSsj-0".equals(o.toString())) { + continue; + } + ls.add((SsjDevice) hsSSJMap.get(o)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getRgv1() { + List ls = new ArrayList<>(); + try { + HashMap hsDDJMap1 = (HashMap) hsComParamRgv1.get("hsRgvMap1"); + ls.add((RgvDevice) hsDDJMap1.get("rgv-1")); + } catch (Exception ex) { + Logger.error("获å�–RGV状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getRgv2() { + List ls = new ArrayList<>(); + try { + HashMap hsDDJMap1 = (HashMap) hsComParamRgv2.get("hsRgvMap2"); + ls.add((RgvDevice) hsDDJMap1.get("rgv-2")); + } catch (Exception ex) { + Logger.error("获å�–RGV状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + public static List getRgv3() { + List ls = new ArrayList<>(); + try { + HashMap hsDDJMap1 = (HashMap) hsComParamRgv3.get("hsRgvMap3"); + ls.add((RgvDevice) hsDDJMap1.get("rgv-3")); + } catch (Exception ex) { + Logger.error("获å�–RGV状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static List getCarInteractionReleaseSsj() { + + List ls = new ArrayList<>(); + try { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + for (int i = 0; i < 7; i++) { + ls.add((SsjDevice) hsSSJMap.get("carInteractionReleaseSsj-" + i)); + } + } catch (Exception ex) { + Logger.error("获å�–输é€�机状æ€�ä¿¡æ�¯å¼‚常" + ex.getMessage()); + } + return ls; + } + + public static SsjDevice getExceptionSsj() { + HashMap hsSSJMap = (HashMap) hsComParamSSJ.get("hsSSJMap"); + return (SsjDevice) hsSSJMap.get("exceptionSsj-" + 0); + } + +} + + + + + + + + + + + + + + + diff --git a/src/com/wms/dss/ats/customs/abb/schedule/OutTraySsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/OutTraySsjThread.java new file mode 100644 index 0000000..070a68e --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/OutTraySsjThread.java @@ -0,0 +1,104 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.db.Db; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueue; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +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.util.Hashtable; +import java.util.List; +import java.util.Optional; + +import static com.wms.dss.ats.customs.abb.common.TaskType.*; + +public class OutTraySsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public OutTraySsjThread(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) { + //æ—¶é—´é”� + if (QueryDbDataUtils.getEndTime(m_dao)) { + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + List trayCacheSsj = DbGet.getTrayCacheSsj(); + List inOutTraySsj = DbGet.getInOutTraySsj(); + List trayDisassembleStartSsj = DbGet.getTrayDisassembleStartSsj(); + String ssjNo = ""; + for (SsjDevice ssjDevice : inOutTraySsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatch(ssjDevice,trayCacheSsj,trayDisassembleStartSsj); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e.getMessage()); + } + } + } + + private void dispatch(SsjDevice ssjDevice,List trayCacheSsjList,List trayDisassembleStartSsjList) { + Integer ssdw = ssjDevice.RKDW; + Integer rwh = ssjDevice.RWH; + if (ssdw == 1){ + + Optional first = trayDisassembleStartSsjList.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice endSsj = first.get(); + String startPoint = ssjDevice.ssjNo; + String endPoint = endSsj.ssjNo; + //生æˆ�å°�车任务 + RgvDeviceExecutionQueue rgvQueue = QueryDbDataUtils.createRgvQueue(m_dao, startPoint, rwh, endPoint, TYPE_E.getXd(), TYPE_E.getCode()); + if (rgvQueue != null) { + Logger.info("生æˆ�队列æˆ�功rwh:",+rwh); + } + + }else { + + first = trayCacheSsjList.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice endSsj = first.get(); + String startPoint = ssjDevice.ssjNo; + String endPoint = endSsj.ssjNo; + //生æˆ�å°�车任务 + RgvDeviceExecutionQueue rgvQueue = QueryDbDataUtils.createRgvQueue(m_dao, startPoint, rwh, endPoint, TYPE_C.getXd(), TYPE_C.getCode()); + if (rgvQueue != null) { + Logger.info("生æˆ�队列æˆ�功rwh:",+rwh); + } + } + } + + + + } + } + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/ProductionLineEndSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/ProductionLineEndSsjThread.java new file mode 100644 index 0000000..3897020 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/ProductionLineEndSsjThread.java @@ -0,0 +1,114 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.model.LineStatus; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +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.util.Hashtable; +import java.util.List; +import java.util.Optional; + +import static com.wms.dss.ats.customs.abb.common.TaskType.*; + +public class ProductionLineEndSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public ProductionLineEndSsjThread(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) { + //æ—¶é—´é”� + if (QueryDbDataUtils.getEndTime(m_dao)) { + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + List productionLineEndSsj = DbGet.getProductionLineEndSsj(); + List inTraySsj = DbGet.getInTraySsj(); + SsjDevice exceptionSsj = DbGet.getExceptionSsj(); + productionLineEndSsj.add(exceptionSsj); + inTraySsj.addAll(DbGet.getInOutTraySsj()); + String ssjNo = ""; + for (SsjDevice ssjDevice : productionLineEndSsj) { + try { + ssjNo = ssjDevice.ssjNo; + Optional first = productionLineEndSsj.stream().filter(x -> "1010".equals(x.ssjNo) && x.RKDW==1).findFirst(); + if (first.isPresent()){ + SsjDevice startSsj = first.get(); + dispatch(startSsj,inTraySsj); + }else { + dispatch(ssjDevice,inTraySsj); + } + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e.getMessage()); + } + } + } + + private void dispatch(SsjDevice ssjDevice,List inTraySsjList) { + Integer ssdw = ssjDevice.RKDW; + String ssjNo =ssjDevice.ssjNo; + Integer rwh = ssjDevice.RWH; + if (ssdw == 1){ + Optional first = inTraySsjList.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice endSsj = first.get(); + if ("1023".equals(endSsj.ssjNo)){ + List notKxCacheSsjStatus = QueryDbDataUtils.getNotKxCacheSsjStatus(m_dao, 0); + if (CollUtil.isNotEmpty(notKxCacheSsjStatus) && notKxCacheSsjStatus.size() <2){ + Logger.info("存在空闲托盘缓存区,无法分é…�入库任务"); + return; + } + return; + } + + String startPoint = ssjDevice.ssjNo; + String endPoint = endSsj.ssjNo; + //生æˆ�Rgvå°�车任务 + QueryDbDataUtils.createRgvQueue(m_dao,startPoint, rwh, endPoint,TYPE_B.getXd(),TYPE_B.getCode()); + + } + } + if (ssdw == 2){ + SsjDevice exceptionSsj = DbGet.getExceptionSsj(); + if (exceptionSsj.CKKX==1){ + String startPoint = ssjDevice.ssjNo; + String endPoint = exceptionSsj.ssjNo; + //生æˆ�Rgvå°�车任务 + QueryDbDataUtils.createRgvQueue(m_dao,startPoint, rwh, endPoint,TYPE_G.getXd(),TYPE_G.getCode()); + } + } + } + + + + + +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/RgvThread1.java b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread1.java new file mode 100644 index 0000000..b6f0890 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread1.java @@ -0,0 +1,267 @@ +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.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.RgvDevice; +import com.wms.dss.ats.customs.abb.entity.SendData; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueue; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueueFinish; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientRgv1; +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.common.TaskType.TYPE_A; +import static com.wms.dss.ats.customs.abb.common.TaskType.TYPE_F; +import static com.wms.dss.ats.customs.abb.utils.RequestUrls.handleExceptionUrl; + +/* + *@Version 1.0 + * RGV线程 + **/ + +public class RgvThread1 extends CraneThread { + + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamRgv1 = null; + Hashtable hsComParamRgv2 = null; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public RgvThread1(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + hsComParamRgv1 = (Hashtable) m_hsSysParam.get("hsComParamRgv1"); + hsComParamRgv2 = (Hashtable) m_hsSysParam.get("hsComParamRgv2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + if (QueryDbDataUtils.getEndTime(m_dao)) { + return; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamRgv1 = hsComParamRgv1; + + int rgvh = 0; + try { + List rgv = DbGet.getRgv1(); + if (!rgv.isEmpty()) { + for (RgvDevice rgvDevice : rgv) { + rgvh = rgvDevice.btId; + rgv_dd(rgvDevice, rgvh); + } + } + + } catch (Exception ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + try { + sleep(2000); + } catch (InterruptedException ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + } + } + + + //RGV调度 + private void rgv_dd(RgvDevice rgvDevice, int bh) throws InterruptedException { + + /* + 第一部分 + RGV线程进æ�¥å�Žç¬¬ä¸€ä»¶äº‹å…ˆè¿›è¡ŒRGV正执行任务的账务处ç�† + 以防存在æ¼�处ç�†ï¼Œæ²¡å¤„ç�†çš„æƒ…况å�‘生 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.ZXJD == 5) { /// + Long rwh = rgvDevice.ZXRWH; + //RGVå��馈完æˆ�,处ç�†è´¦åŠ¡ + RgvDeviceExecutionQueue queue = QueryDbDataUtils.getRgvQueueByRwh(m_dao, rwh); + if (queue != null) { + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + 5 + " where rwh = '" + rwh + "' and hd = '"+1+"'"); + rgv_finish(m_dao, rwh,1); + } + } + + /* + 第二部分 + 跟踪队列执行阶段 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.SBZT == 3 && (rgvDevice.ZXJD == 2 || rgvDevice.ZXJD == 3 || rgvDevice.ZXJD == 4)) { + //æ ¹æ�®å †åž›æœºä¸Šä»»åŠ¡å�·ï¼Œä¿®æ”¹ä»»åŠ¡æ‰§è¡Œé˜¶æ®µ + long rwh = rgvDevice.ZXRWH; + int zxjd = rgvDevice.ZXJD; + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + zxjd + " where rwh = '" + rwh + "' and hd = '"+1+"'"); + } + + + //å�–货下å�‘ + if (rgvDevice.YXXF == 1 && rgvDevice.CZFS == 2 && rgvDevice.SBZT == 1 ) { + //去最近的ä½�ç½® + //int mbzd = rgvDevice.MBZD; + String startPoint = "1005"; + /*switch (mbzd){ + case 1009: + case 1011: + case 1015: + case 1017: + startPoint = "1013"; + break; + default: + startPoint = "1005"; + }*/ + List trayDisassembleEndSsj = DbGet.getTrayDisassembleEndSsj1(); + Optional first = trayDisassembleEndSsj.stream().filter(x -> (x.RKDW == 1 && x.ssjNo.equals(startPoint))).findFirst(); + if (first.isPresent()){ + SsjDevice startSsj = first.get(); + QueryDbDataUtils.createRgvQueue(m_dao,startSsj.ssjNo, startSsj.RWH, "1111",TYPE_A.getXd(),TYPE_A.getCode()); + }/*else { + Optional first1 = trayDisassembleEndSsj.stream().filter(x -> x.RKDW == 1).findFirst(); + if (first1.isPresent()){ + SsjDevice startSsj = first1.get(); + QueryDbDataUtils.createRgvQueue(m_dao,startSsj.ssjNo, startSsj.RWH, "1111",TYPE_A.getXd(),TYPE_A.getCode()); + } + }*/ + + //对RGV执行队列中无已下å�‘队列 + int count = QueryDbDataUtils.getRgvDeviceExecutionQueueByXF(m_dao, bh); + //å�–RGV队列中,生æˆ�时间最早的执行队列下å�‘ + if (count == 0) { + RgvDeviceExecutionQueue firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstRgvDeviceExecutionQueueByRwlx(m_dao, bh ,TYPE_A.getCode()); + if (firstWmsDeviceExecutionQueue == null) { + //Logger.error("RGV队列中无执行队列ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + return; + } + int i = issuedRgvTask(bh, firstWmsDeviceExecutionQueue, 3); + if (i == 1) { + //更新开始时间,修改xf为已下å�‘1 + String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update RgvDeviceExecutionQueue set xf = 1,tray_code='" + rgvDevice.trayCode + "',xfsj='" + dateStr + "' where rwh = '" + firstWmsDeviceExecutionQueue.getRwh() + "' and hd = '"+1+"'"); + Logger.info("RGV1下å�‘å�–货任务æˆ�功 rwh:" + firstWmsDeviceExecutionQueue.getRwh()); + } else { + Logger.error("RGV1下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + } + } + + //放货下å�‘ + if (rgvDevice.YXXF == 1 && rgvDevice.CZFS ==2 && rgvDevice.SBZT == 2 ) { + List productionLineStartSsj = DbGet.getProductionLineStartSsj1(); + /*Optional L1017 = productionLineStartSsj.stream().filter(x -> x.CKKX == 1 && "1017".equals(x.ssjNo)).findFirst(); + if (L1017.isPresent()){ + SsjDevice endPoint = L1017.get(); + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueueFinish = QueryDbDataUtils.getTrayRgvHistoryByRwhAndDevId(m_dao,Convert.toInt(rgvDevice.ZXRWH),bh); + if (rgvDeviceExecutionQueueFinish!=null){ + QueryDbDataUtils.createRgvQueue(m_dao,Convert.toStr(rgvDeviceExecutionQueueFinish.getYzd()), Convert.toInt(rgvDevice.ZXRWH), endPoint.ssjNo,TYPE_F.getXd(),TYPE_F.getCode()); + } + }else { + + }*/ + Optional first = productionLineStartSsj.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice endPoint = first.get(); + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueueFinish = QueryDbDataUtils.getTrayRgvHistoryByRwhAndDevId(m_dao,Convert.toInt(rgvDevice.ZXRWH),bh); + if (rgvDeviceExecutionQueueFinish!=null){ + QueryDbDataUtils.createRgvQueue(m_dao,Convert.toStr(rgvDeviceExecutionQueueFinish.getYzd()), Convert.toInt(rgvDevice.ZXRWH), endPoint.ssjNo,TYPE_F.getXd(),TYPE_F.getCode()); + }else { + Logger.error("RGV1下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + } + + + //对RGV执行队列中无已下å�‘队列 + int count = QueryDbDataUtils.getRgvDeviceExecutionQueueByXF(m_dao, bh); + //å�–RGV队列中,生æˆ�时间最早的执行队列下å�‘ + if (count == 0 ) { + RgvDeviceExecutionQueue firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstRgvDeviceExecutionQueueByRwlx(m_dao, bh ,TYPE_F.getCode()); + if (firstWmsDeviceExecutionQueue == null) { + return; + } + int i = issuedRgvTask(bh, firstWmsDeviceExecutionQueue, 4); + if (i == 1) { + //更新开始时间,修改xf为已下å�‘1 + String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update RgvDeviceExecutionQueue set xf = 1,tray_code='" + rgvDevice.trayCode + "',xfsj='" + dateStr + "' where rwh = '" + firstWmsDeviceExecutionQueue.getRwh() + "' and hd = '"+1+"'"); + Logger.info("RGV1下å�‘放货任务æˆ�功 rwh:" + firstWmsDeviceExecutionQueue.getRwh()); + } else { + Logger.error("RGV1下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + + } + + } + } + + + /** + * ç»™RGV下å�‘任务 + * + * @param queue RGV执行的队列 + */ + private int issuedRgvTask(int devId, RgvDeviceExecutionQueue queue, int taskModel) { + SendData rwh = new SendData(Tools.DINT, queue.getRwh()); + SendData srcZd = new SendData(Tools.INT, queue.getYzd()); + SendData taskMode = new SendData(Tools.INT, taskModel); + SendData dstZd = new SendData(Tools.INT, queue.getMbzd()); + SendData xfwc = new SendData(Tools.INT,1); + int jym = Tools.getJYM( rwh.getNum2(), srcZd.getNum2(), dstZd.getNum2(), taskMode.getNum2()); + SendData checkData = new SendData(Tools.INT, jym); + byte[] bytes = Tools.sendData(rwh,srcZd,dstZd,taskMode,xfwc,checkData); + return IsoTcpClientRgv1.WritetoRgv("DB5.0", bytes); + } + + /** + * 调用存储过程proc_rgv_finish 完æˆ�rgv任务 + */ + private void rgv_finish(EntityDAO m_dao, long taskNo,int xd) { + StoredParameters ddjhParameter = new StoredParameters(1, String.valueOf(taskNo)); + StoredParameters xdParameter = new StoredParameters(2, String.valueOf(xd)); + StoredParameters result = new StoredParameters(3, ""); + StoredParameters result_msg = new StoredParameters(4, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_rgv_finish(?,?,?,?)}", + 3, 4, ddjhParameter,xdParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_rgv_finish 无该作业,请检查,任务å�·ï¼š" + taskNo); + break; + case 9: + Logger.info("proc_rgv_finish 存储过程问题,请检查"); + break; + case 10: + Logger.info("proc_rgv_finish 执行æˆ�功 任务å�·ï¼š" + taskNo); + break; + default: + throw new SQLException("proc_rgv_finish 未知的返回值,任务å�·ï¼š" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}", exception.getMessage()); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/RgvThread2.java b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread2.java new file mode 100644 index 0000000..33dd85a --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread2.java @@ -0,0 +1,208 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.RgvDevice; +import com.wms.dss.ats.customs.abb.entity.SendData; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueue; +import com.wms.dss.ats.customs.abb.model.RgvMsg; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientRgv1; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientRgv2; +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.*; + +/* + *@Version 1.0 + * RGV线程 + **/ + +public class RgvThread2 extends CraneThread { + + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamRgv1 = null; + Hashtable hsComParamRgv2 = null; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public RgvThread2(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + hsComParamRgv1 = (Hashtable) m_hsSysParam.get("hsComParamRgv1"); + hsComParamRgv2 = (Hashtable) m_hsSysParam.get("hsComParamRgv2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + if (QueryDbDataUtils.getEndTime(m_dao)) { + return; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamRgv2 = hsComParamRgv2; + + int rgvh = 0; + try { + /*List availableRgv = QueryDbDataUtils.getAvailableRgv(m_dao, 2); + if (CollUtil.isNotEmpty(availableRgv)){ + RgvMsg rgvMsg = availableRgv.get(0); + + if (rgvMsg.getId()==2){ + rgv = DbGet.getRgv2(); + }else if (rgvMsg.getId()==3){ + rgv = DbGet.getRgv3(); + }else { + rgv = new ArrayList<>(); + } + + }*/ + List rgv = DbGet.getRgv2(); + if (!rgv.isEmpty()) { + for (RgvDevice rgvDevice : rgv) { + rgvh = rgvDevice.btId; + rgv_dd(rgvDevice, rgvh); + } + } + + } catch (Exception ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + try { + sleep(2000); + } catch (InterruptedException ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + } + } + + + //RGV调度 + private void rgv_dd(RgvDevice rgvDevice, int bh) throws InterruptedException { + + /* + 第一部分 + RGV线程进æ�¥å�Žç¬¬ä¸€ä»¶äº‹å…ˆè¿›è¡ŒRGV正执行任务的账务处ç�† + 以防存在æ¼�处ç�†ï¼Œæ²¡å¤„ç�†çš„æƒ…况å�‘生 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.ZXJD == 5) { /// + Long rwh = rgvDevice.ZXRWH; + //RGVå��馈完æˆ�,处ç�†è´¦åŠ¡ + RgvDeviceExecutionQueue queue = QueryDbDataUtils.getRgvQueueByRwh(m_dao, rwh); + if (queue != null) { + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + 5 + " where rwh = '" + rwh + "' and hd='"+2+"'"); + rgv_finish(m_dao, rwh,2); + if (queue.getRwlx()==5){ + List trayCacheSsj = DbGet.getTrayCacheSsj(); + Optional first = trayCacheSsj.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice ssjDevice = first.get(); + m_dao.updateSql("update LineStatus set status = 0 where ssjNo="+ssjDevice.ssjNo+" and kx =1"); + } + } + //Thread.sleep(3000); + } + } + + /* + 第二部分 + 跟踪队列执行阶段 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.SBZT == 3 && (rgvDevice.ZXJD == 2 || rgvDevice.ZXJD == 3 || rgvDevice.ZXJD == 4)) { + //æ ¹æ�®å †åž›æœºä¸Šä»»åŠ¡å�·ï¼Œä¿®æ”¹ä»»åŠ¡æ‰§è¡Œé˜¶æ®µ + long rwh = rgvDevice.ZXRWH; + int zxjd = rgvDevice.ZXJD; + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + zxjd + " where rwh = '" + rwh + "' and hd ='"+2+"'"); + } + + + //正常下å�‘ + if (rgvDevice.YXXF == 1 && rgvDevice.CZFS == 2 && rgvDevice.SBZT == 1) { + //对RGV执行队列中无已下å�‘队列 + int count = QueryDbDataUtils.getRgvDeviceExecutionQueueByXF(m_dao, bh); + //å�–RGV队列中,生æˆ�时间最早的执行队列下å�‘ + if (count == 0) { + RgvDeviceExecutionQueue firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstRgvDeviceExecutionQueue(m_dao, bh); + if (firstWmsDeviceExecutionQueue == null) { + //Logger.error("RGV队列中无执行队列ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + return; + } + int i = issuedRgvTask(bh, firstWmsDeviceExecutionQueue,5); + if (i == 1) { + //更新开始时间,修改xf为已下å�‘1 + String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update RgvDeviceExecutionQueue set xf = 1,tray_code='"+rgvDevice.trayCode+"',xfsj='"+dateStr+"' where rwh = '" + firstWmsDeviceExecutionQueue.getRwh() + "' and hd='"+2+"'"); + Logger.info("RGV2下å�‘任务æˆ�功 rwh:" + firstWmsDeviceExecutionQueue.getRwh()); + } else { + Logger.error("RGV2下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + } + } + } + + + /** + * ç»™RGV下å�‘任务 + * + * @param queue RGV执行的队列 + */ + private int issuedRgvTask(int devId, RgvDeviceExecutionQueue queue, int taskModel) { + SendData rwh = new SendData(Tools.DINT, queue.getRwh()); + SendData srcZd = new SendData(Tools.INT, queue.getYzd()); + SendData dstZd = new SendData(Tools.INT, queue.getMbzd()); + SendData taskMode = new SendData(Tools.INT, taskModel); + SendData xfwc = new SendData(Tools.INT,1); + int jym = Tools.getJYM( rwh.getNum2(), srcZd.getNum2(), dstZd.getNum2(), taskMode.getNum2()); + SendData checkData = new SendData(Tools.INT, jym); + byte[] bytes = Tools.sendData(rwh,srcZd,dstZd,taskMode,xfwc,checkData); + return IsoTcpClientRgv2.WritetoRgv("DB5.0", bytes); + } + + /** + * 调用存储过程proc_rgv_finish 完æˆ�rgv任务 + */ + private void rgv_finish(EntityDAO m_dao, long taskNo,int xd) { + StoredParameters ddjhParameter = new StoredParameters(1, String.valueOf(taskNo)); + StoredParameters xdParameter = new StoredParameters(2, String.valueOf(xd)); + StoredParameters result = new StoredParameters(3, ""); + StoredParameters result_msg = new StoredParameters(4, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_rgv_finish(?,?,?,?)}", + 3, 4, ddjhParameter,xdParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_rgv_finish 无该作业,请检查,任务å�·ï¼š" + taskNo); + break; + case 9: + Logger.info("proc_rgv_finish 存储过程问题,请检查"); + break; + case 10: + Logger.info("proc_rgv_finish 执行æˆ�功 任务å�·ï¼š" + taskNo); + break; + default: + throw new SQLException("proc_rgv_finish 未知的返回值,任务å�·ï¼š" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}", exception.getMessage()); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/RgvThread3.java b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread3.java new file mode 100644 index 0000000..2c8415c --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/RgvThread3.java @@ -0,0 +1,265 @@ +package com.wms.dss.ats.customs.abb.schedule; + +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.RgvDevice; +import com.wms.dss.ats.customs.abb.entity.SendData; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.entity.StoredParameters; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueue; +import com.wms.dss.ats.customs.abb.model.RgvDeviceExecutionQueueFinish; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientRgv1; +import com.wms.dss.ats.customs.abb.plc.IsoTcpClientRgv3; +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.Date; +import java.util.Hashtable; +import java.util.List; +import java.util.Optional; + +import static com.wms.dss.ats.customs.abb.common.TaskType.*; + +/* + *@Version 1.0 + * RGV线程 + **/ + +public class RgvThread3 extends CraneThread { + + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamRgv1 = null; + Hashtable hsComParamRgv2 = null; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public RgvThread3(Hashtable hsSysParam) { + super(hsSysParam); + m_bStop = false; + m_hsSysParam = hsSysParam; + m_dao = (EntityDAO) hsSysParam.get("dao"); + hsComParamRgv1 = (Hashtable) m_hsSysParam.get("hsComParamRgv1"); + hsComParamRgv2 = (Hashtable) m_hsSysParam.get("hsComParamRgv2"); + hsComParamSSJ = (Hashtable) m_hsSysParam.get("hsComParamSSJ"); + strConfigPath = ((WMSDDSConfig) hsSysParam.get("config")).getConfigPath(); + } + + @Override + public void run() { + while (!m_bStop) { + if (QueryDbDataUtils.getEndTime(m_dao)) { + return; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamRgv1 = hsComParamRgv1; + + int rgvh = 0; + try { + List rgv = DbGet.getRgv3(); + if (!rgv.isEmpty()) { + for (RgvDevice rgvDevice : rgv) { + rgvh = rgvDevice.btId; + rgv_dd(rgvDevice, rgvh); + } + } + + } catch (Exception ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + try { + sleep(2000); + } catch (InterruptedException ex) { + Logger.info("RGV线程组调度执行异常" + rgvh + ex.getMessage()); + } + } + } + + + //RGV调度 + private void rgv_dd(RgvDevice rgvDevice, int bh) throws InterruptedException { + + /* + 第一部分 + RGV线程进æ�¥å�Žç¬¬ä¸€ä»¶äº‹å…ˆè¿›è¡ŒRGV正执行任务的账务处ç�† + 以防存在æ¼�处ç�†ï¼Œæ²¡å¤„ç�†çš„æƒ…况å�‘生 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.ZXJD == 5) { /// + Long rwh = rgvDevice.ZXRWH; + //RGVå��馈完æˆ�,处ç�†è´¦åŠ¡ + RgvDeviceExecutionQueue queue = QueryDbDataUtils.getRgvQueueByRwh(m_dao, rwh); + if (queue != null) { + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + 5 + " where rwh = '" + rwh + "' and hd = '"+1+"'"); + rgv_finish(m_dao, rwh,3); + } + } + + /* + 第二部分 + 跟踪队列执行阶段 + */ + if (rgvDevice.CZFS == 2 && rgvDevice.SBZT == 3 && (rgvDevice.ZXJD == 2 || rgvDevice.ZXJD == 3 || rgvDevice.ZXJD == 4)) { + //æ ¹æ�®å †åž›æœºä¸Šä»»åŠ¡å�·ï¼Œä¿®æ”¹ä»»åŠ¡æ‰§è¡Œé˜¶æ®µ + long rwh = rgvDevice.ZXRWH; + int zxjd = rgvDevice.ZXJD; + m_dao.updateSql("update RgvDeviceExecutionQueue set rwzt = " + zxjd + " where rwh = '" + rwh + "' and hd = '"+1+"'"); + } + + + //å�–货下å�‘ + if (rgvDevice.YXXF == 1 && rgvDevice.CZFS == 2 && rgvDevice.SBZT == 1 ) { + //去最近的ä½�ç½® + //int mbzd = rgvDevice.MBZD; + String startPoint = "1013"; + /*switch (mbzd){ + case 1009: + case 1011: + case 1015: + case 1017: + startPoint = "1013"; + break; + default: + startPoint = "1005"; + }*/ + List trayDisassembleEndSsj = DbGet.getTrayDisassembleEndSsj2(); + Optional first = trayDisassembleEndSsj.stream().filter(x -> (x.RKDW == 1 && x.ssjNo.equals(startPoint))).findFirst(); + if (first.isPresent()){ + SsjDevice startSsj = first.get(); + QueryDbDataUtils.createRgvQueue(m_dao,startSsj.ssjNo, startSsj.RWH, "1111",TYPE_A_1.getXd(),TYPE_A_1.getCode()); + }/*else { + Optional first1 = trayDisassembleEndSsj.stream().filter(x -> x.RKDW == 1).findFirst(); + if (first1.isPresent()){ + SsjDevice startSsj = first1.get(); + QueryDbDataUtils.createRgvQueue(m_dao,startSsj.ssjNo, startSsj.RWH, "1111",TYPE_A.getXd(),TYPE_A.getCode()); + } + }*/ + + //对RGV执行队列中无已下å�‘队列 + int count = QueryDbDataUtils.getRgvDeviceExecutionQueueByXF(m_dao, bh); + //å�–RGV队列中,生æˆ�时间最早的执行队列下å�‘ + if (count == 0) { + RgvDeviceExecutionQueue firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstRgvDeviceExecutionQueueByRwlx(m_dao, bh ,TYPE_A_1.getCode()); + if (firstWmsDeviceExecutionQueue == null) { + //Logger.error("RGV队列中无执行队列ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + return; + } + int i = issuedRgvTask(bh, firstWmsDeviceExecutionQueue, 3); + if (i == 1) { + //更新开始时间,修改xf为已下å�‘1 + String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update RgvDeviceExecutionQueue set xf = 1,tray_code='" + rgvDevice.trayCode + "',xfsj='" + dateStr + "' where rwh = '" + firstWmsDeviceExecutionQueue.getRwh() + "' and hd = '"+3+"'"); + Logger.info("RGV3下å�‘å�–货任务æˆ�功 rwh:" + firstWmsDeviceExecutionQueue.getRwh()); + } else { + Logger.error("RGV3下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + } + } + + //放货下å�‘ + if (rgvDevice.YXXF == 1 && rgvDevice.CZFS ==2 && rgvDevice.SBZT == 2 ) { + List productionLineStartSsj = DbGet.getProductionLineStartSsj2(); + /*Optional L1017 = productionLineStartSsj.stream().filter(x -> x.CKKX == 1 && "1017".equals(x.ssjNo)).findFirst(); + if (L1017.isPresent()){ + SsjDevice endPoint = L1017.get(); + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueueFinish = QueryDbDataUtils.getTrayRgvHistoryByRwhAndDevId(m_dao,Convert.toInt(rgvDevice.ZXRWH),bh); + if (rgvDeviceExecutionQueueFinish!=null){ + QueryDbDataUtils.createRgvQueue(m_dao,Convert.toStr(rgvDeviceExecutionQueueFinish.getYzd()), Convert.toInt(rgvDevice.ZXRWH), endPoint.ssjNo,TYPE_F.getXd(),TYPE_F.getCode()); + } + }else { + + }*/ + Optional first = productionLineStartSsj.stream().filter(x -> x.CKKX == 1).findFirst(); + if (first.isPresent()){ + SsjDevice endPoint = first.get(); + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueueFinish = QueryDbDataUtils.getTrayRgvHistoryByRwhAndDevId1(m_dao,Convert.toInt(rgvDevice.ZXRWH),bh); + if (rgvDeviceExecutionQueueFinish!=null){ + QueryDbDataUtils.createRgvQueue(m_dao,Convert.toStr(rgvDeviceExecutionQueueFinish.getYzd()), Convert.toInt(rgvDevice.ZXRWH), endPoint.ssjNo,TYPE_F_1.getXd(),TYPE_F_1.getCode()); + }else { + Logger.error("RGV3下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + } + + + //对RGV执行队列中无已下å�‘队列 + int count = QueryDbDataUtils.getRgvDeviceExecutionQueueByXF(m_dao, bh); + //å�–RGV队列中,生æˆ�时间最早的执行队列下å�‘ + if (count == 0 ) { + RgvDeviceExecutionQueue firstWmsDeviceExecutionQueue = QueryDbDataUtils.getFirstRgvDeviceExecutionQueueByRwlx(m_dao, bh ,TYPE_F_1.getCode()); + if (firstWmsDeviceExecutionQueue == null) { + return; + } + int i = issuedRgvTask(bh, firstWmsDeviceExecutionQueue, 4); + if (i == 1) { + //更新开始时间,修改xf为已下å�‘1 + String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + m_dao.updateSql("update RgvDeviceExecutionQueue set xf = 1,tray_code='" + rgvDevice.trayCode + "',xfsj='" + dateStr + "' where rwh = '" + firstWmsDeviceExecutionQueue.getRwh() + "' and hd = '"+3+"'"); + Logger.info("RGV3下å�‘放货任务æˆ�功 rwh:" + firstWmsDeviceExecutionQueue.getRwh()); + } else { + Logger.error("RGV3下å�‘失败ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�ï¼�"); + } + + } + + } + } + + + /** + * ç»™RGV下å�‘任务 + * + * @param queue RGV执行的队列 + */ + private int issuedRgvTask(int devId, RgvDeviceExecutionQueue queue, int taskModel) { + SendData rwh = new SendData(Tools.DINT, queue.getRwh()); + SendData srcZd = new SendData(Tools.INT, queue.getYzd()); + SendData taskMode = new SendData(Tools.INT, taskModel); + SendData dstZd = new SendData(Tools.INT, queue.getMbzd()); + SendData xfwc = new SendData(Tools.INT,1); + int jym = Tools.getJYM( rwh.getNum2(), srcZd.getNum2(), dstZd.getNum2(), taskMode.getNum2()); + SendData checkData = new SendData(Tools.INT, jym); + byte[] bytes = Tools.sendData(rwh,srcZd,dstZd,taskMode,xfwc,checkData); + //todo 新的下å�‘地å�€ + return IsoTcpClientRgv3.WritetoRgv("DB5.0", bytes); + } + + /** + * 调用存储过程proc_rgv_finish 完æˆ�rgv任务 + */ + private void rgv_finish(EntityDAO m_dao, long taskNo,int xd) { + StoredParameters ddjhParameter = new StoredParameters(1, String.valueOf(taskNo)); + StoredParameters xdParameter = new StoredParameters(2, String.valueOf(xd)); + StoredParameters result = new StoredParameters(3, ""); + StoredParameters result_msg = new StoredParameters(4, ""); + + try { + ProcedureResult procedureResult = Tools.storedProcedureMsg(m_dao, "{call proc_rgv_finish(?,?,?,?)}", + 3, 4, ddjhParameter,xdParameter, result, result_msg); + switch (procedureResult.getResult()) { + case 1: + Logger.info("proc_rgv_finish 无该作业,请检查,任务å�·ï¼š" + taskNo); + break; + case 9: + Logger.info("proc_rgv_finish 存储过程问题,请检查"); + break; + case 10: + Logger.info("proc_rgv_finish 执行æˆ�功 任务å�·ï¼š" + taskNo); + break; + default: + throw new SQLException("proc_rgv_finish 未知的返回值,任务å�·ï¼š" + taskNo); + } + } catch (SQLException exception) { + Logger.error("e{}", exception.getMessage()); + } + } +} diff --git a/src/com/wms/dss/ats/customs/abb/schedule/TrayDisassembleSsjThread.java b/src/com/wms/dss/ats/customs/abb/schedule/TrayDisassembleSsjThread.java new file mode 100644 index 0000000..e596a4f --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/schedule/TrayDisassembleSsjThread.java @@ -0,0 +1,101 @@ +package com.wms.dss.ats.customs.abb.schedule; + +import com.ricosoft.common.dao.dataSource.EntityDAO; +import com.wms.dss.ats.customs.abb.entity.SsjDevice; +import com.wms.dss.ats.customs.abb.utils.QueryDbDataUtils; +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.util.Hashtable; +import java.util.List; +import java.util.Optional; + +import static com.wms.dss.ats.customs.abb.common.TaskType.TYPE_D; + +public class TrayDisassembleSsjThread extends CraneThread { + protected byte btid = 0; + String strConfigPath = ""; + Hashtable hsComParamSSJ = null; + + + @Override + public void setStop(boolean b) { + m_bStop = b; + } + + public TrayDisassembleSsjThread(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) { + //æ—¶é—´é”� + if (QueryDbDataUtils.getEndTime(m_dao)) { + continue; + } + //获å�–DBå�—中的信æ�¯ + DbGet.hsComParamSSJ = hsComParamSSJ; + List trayCacheSsj = DbGet.getTrayCacheSsj(); + List trayDisassembleStartSsj = DbGet.getTrayDisassembleStartSsj(); + String ssjNo = ""; + for (SsjDevice ssjDevice : trayDisassembleStartSsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatch(ssjDevice,trayCacheSsj); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + for (SsjDevice ssjDevice : trayCacheSsj) { + try { + ssjNo = ssjDevice.ssjNo; + dispatchCache(ssjDevice); + } catch (RuntimeException e) { + Logger.error("输é€�机调度异常ssjNo:" + ssjNo + " " + e.getMessage()); + } + } + try { + sleep(1500); + } catch (InterruptedException e) { + Logger.error(e.getMessage()); + } + } + } + + private void dispatchCache(SsjDevice ssjDevice) { + Integer dw = ssjDevice.RKDW; + Integer kx = ssjDevice.CKKX; + if (dw==1){ + m_dao.updateSql("update LineStatus set kx = 0,status=2 where ssjNo="+ssjDevice.ssjNo); + } + if (kx==1){ + m_dao.updateSql("update LineStatus set kx = 1,status=0 where ssjNo="+ssjDevice.ssjNo+" and status != 1"); + } + } + + private void dispatch(SsjDevice ssjDevice,List trayCacheSsjList) { + Integer kx = ssjDevice.CKKX; + if (kx ==1){ + //生æˆ�空托盘æ�¬è¿�任务, 从托盘缓冲区拿 + Optional first = trayCacheSsjList.stream().filter(x -> x.RKDW == 1).findFirst(); + if (first.isPresent()){ + SsjDevice startSsj = first.get(); + String startPoint = startSsj.ssjNo; + String endPoint = ssjDevice.ssjNo; + Integer rwh = startSsj.RWH; + //生æˆ�å°�车任务 + QueryDbDataUtils.createRgvQueue(m_dao,startPoint, rwh, endPoint,TYPE_D.getXd(),TYPE_D.getCode()); + } + } + + } + + +} 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..d09f2c5 --- /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 { + 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请求 + } +} 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..c2ae9c2 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/ParseUtil.java @@ -0,0 +1,596 @@ +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 + 7) * 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) { + + } + + +} 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..8dabeb2 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/QueryDbDataUtils.java @@ -0,0 +1,309 @@ +package com.wms.dss.ats.customs.abb.utils; + +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.model.*; +import com.wms.dss.common.server.form.Logger; + +import java.util.*; + +/* + *@Version 1.0 + * æ•°æ�®èŽ·å�– + **/ +public class QueryDbDataUtils { + + public static boolean getEndTime(EntityDAO mDao){ + 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) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + return false; + } + } + + public static CarDeviceExecutionQueue getCarQueueByTaskCode(EntityDAO mDao, Integer taskCode) { + CarDeviceExecutionQueue carDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from CarDeviceExecutionQueue where taskCode = '" + taskCode + "'"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + carDeviceExecutionQueue = (CarDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return carDeviceExecutionQueue; + } + + public static CarDeviceExecutionQueue getCarQueueByStatus(EntityDAO mDao, String status) { + CarDeviceExecutionQueue carDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from CarDeviceExecutionQueue where status = '" + status + "' order by create_time desc"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + carDeviceExecutionQueue = (CarDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return carDeviceExecutionQueue; + } + public static CarDeviceExecutionQueue getCarQueueByStatusAndStation(EntityDAO mDao, String status,String station) { + CarDeviceExecutionQueue carDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from CarDeviceExecutionQueue where status = '" + status + "' and toStation = '"+station+"' order by create_time"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + carDeviceExecutionQueue = (CarDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return carDeviceExecutionQueue; + } + + public static RgvDeviceExecutionQueue getRgvQueueByStartPoint(EntityDAO mDao,String startPoint,String endPoint) { + RgvDeviceExecutionQueue rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where yzd = '" + startPoint + "' and mbzd = '"+endPoint+"' order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } + + public static int getRgvQueueCountByHd(EntityDAO mDao,int xd) { + int count = 0; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where hd = '" + xd + "' order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + count = ls.size(); + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return count; + } + + public static List getAvailableRgv(EntityDAO mDao,int xd) { + List list = new ArrayList<>(); + try { + List ls = mDao.searchEntities("from RgvMsg where xd = '" + xd + "' and czfs = 2 "); + if (CollUtil.isNotEmpty(ls)){ + for (Object l : ls) { + RgvMsg rgvMsg = (RgvMsg) l; + list.add(rgvMsg); + } + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return list; + } + + public static RgvDeviceExecutionQueue createRgvQueue(EntityDAO mDao,String startPoint, Integer rwh, String endPoint,int xd,int rwlx) { + if (rwh>0){ + //查询一下当å‰�å··é�“是å�¦å­˜åœ¨ä»»åŠ¡ + int count = QueryDbDataUtils.getRgvQueueCountByHd(mDao,xd); + if (count==0){ + //查询当å‰�å··é�“å�¯ç”¨RGV + List availableRgv = QueryDbDataUtils.getAvailableRgv(mDao,xd); + if (CollUtil.isNotEmpty(availableRgv)){ + RgvDeviceExecutionQueue rgvDeviceExecutionQueue = QueryDbDataUtils.getRgvQueueByStartPoint(mDao, startPoint,endPoint); + if (rgvDeviceExecutionQueue == null){ + RgvMsg rgvMsg = availableRgv.get(0); + rgvDeviceExecutionQueue = new RgvDeviceExecutionQueue(); + rgvDeviceExecutionQueue.setRwh(rwh); + rgvDeviceExecutionQueue.setDevName(rgvMsg.getDevName()); + rgvDeviceExecutionQueue.setDevId(rgvMsg.getId()); + rgvDeviceExecutionQueue.setRwzt(0); + rgvDeviceExecutionQueue.setYzd(Convert.toInt(startPoint)); + rgvDeviceExecutionQueue.setMbzd(Convert.toInt(endPoint)); + rgvDeviceExecutionQueue.setXf("0"); + rgvDeviceExecutionQueue.setRwlx(rwlx); + rgvDeviceExecutionQueue.setMlfs(5); + rgvDeviceExecutionQueue.setHd(xd); + rgvDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); + mDao.save(rgvDeviceExecutionQueue); + Logger.info("生æˆ�rgv任务:" +rgvDeviceExecutionQueue.getRwh()+"xd:"+rgvDeviceExecutionQueue.getHd()+" 任务类型:"+rgvDeviceExecutionQueue.getRwlx()); + return rgvDeviceExecutionQueue; + } + } + + } + } + + return null; + } + + public static int getRgvDeviceExecutionQueueByXF(EntityDAO mDao, int rgvId) { + int count = 0; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where xf = 1 and devId = " + rgvId + " order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + count = ls.size(); + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return count; + } + + public static RgvDeviceExecutionQueue getFirstRgvDeviceExecutionQueue(EntityDAO mDao, int bh) { + RgvDeviceExecutionQueue rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where xf=0 and devId= '"+bh+"' order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } + + public static RgvDeviceExecutionQueue getFirstRgvDeviceExecutionQueueByRwlx(EntityDAO mDao, int bh,int rwlx) { + RgvDeviceExecutionQueue rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where xf=0 and devId= '"+bh+"' and rwlx = "+rwlx+" order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } + + public static RgvDeviceExecutionQueue getRgvQueueByRwh(EntityDAO mDao, Long rwh) { + RgvDeviceExecutionQueue rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueue where xf=1 and rwh= '"+rwh+"' order by scsj"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } + + public static List getCacheSsjStatus(EntityDAO mDao,String ssjNo) { + List res = new ArrayList<>(); + try { + List ls = mDao.searchEntities("from LineStatus where status = '0' and kx = '1' and ssjNo = '"+ssjNo+"'"); + if (CollUtil.isNotEmpty(ls)){ + for (Object l : ls) { + LineStatus l1 = (LineStatus) l; + res.add(l1); + } + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return res; + } + + public static List getNotKxCacheSsjStatus(EntityDAO mDao,int kx) { + List res = new ArrayList<>(); + try { + List ls = mDao.searchEntities("from LineStatus where kx = '"+kx+"' and ssjNo in ('1020','1021')"); + if (CollUtil.isNotEmpty(ls)){ + for (Object l : ls) { + LineStatus l1 = (LineStatus) l; + res.add(l1); + } + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return res; + } + + public static LineStatus getOutTraySsjStatus(EntityDAO mDao) { + LineStatus lineStatus = null; + try { + List ls = mDao.searchEntities("from LineStatus where ssjNo = '1023'"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + lineStatus = (LineStatus) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return lineStatus; + } + + public static CarDeviceExecutionQueue getCarQueueByRwh(EntityDAO m_dao, Integer rwh) { + CarDeviceExecutionQueue carDeviceExecutionQueue = null; + try { + List ls = m_dao.searchEntities("from CarDeviceExecutionQueue where rwh = '" + rwh + "'"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + carDeviceExecutionQueue = (CarDeviceExecutionQueue) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return carDeviceExecutionQueue; + } + + public static BasZxlx getZxlx(EntityDAO m_dao, Integer zxlx) { + BasZxlx basZxlx = null; + try { + List ls = m_dao.searchEntities("from BasZxlx where zxlx = '" + zxlx + "'"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + basZxlx = (BasZxlx) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return basZxlx; + } + + + public static RgvDeviceExecutionQueueFinish getTrayRgvHistoryByRwhAndDevId(EntityDAO mDao, Integer rwh, int bh) { + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueueFinish where rwh='"+rwh+"' and devId= '"+bh+"' and rwlx = 1 order by scsj desc"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueueFinish) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } + + public static RgvDeviceExecutionQueueFinish getTrayRgvHistoryByRwhAndDevId1(EntityDAO mDao, Integer rwh, int bh) { + RgvDeviceExecutionQueueFinish rgvDeviceExecutionQueue = null; + try { + List ls = mDao.searchEntities("from RgvDeviceExecutionQueueFinish where rwh='"+rwh+"' and devId= '"+bh+"' and rwlx = 9 order by scsj desc"); + if (CollUtil.isNotEmpty(ls)){ + Object o = ls.get(0); + rgvDeviceExecutionQueue = (RgvDeviceExecutionQueueFinish) o; + } + } catch (RuntimeException e) { + Logger.error("获å�–结æ�Ÿæ—¶é—´é”™è¯¯ï¼š" + e.getMessage()); + } + return rgvDeviceExecutionQueue; + } +} 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..58b43d8 --- /dev/null +++ b/src/com/wms/dss/ats/customs/abb/utils/Tools.java @@ -0,0 +1,515 @@ +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步骤,直到八ä½�全部移出,最å�Žå¯„存器中的值就是表格中的数æ�®ï¼Œé«˜å…«ä½�ã€�低八ä½�分别å�•独一个表。*/ + + + /** + * 全部校验ç �å�¯ç”¨è¿™ä¸ªèŽ·å�– + * + * @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((char)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/log4j.properties b/src/log4j.properties new file mode 100644 index 0000000..d14544e --- /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..7dc6e91 --- /dev/null +++ b/wmsdssconfig/abb/hibernate.cfg.xml @@ -0,0 +1,37 @@ + + + + + + + + + + com.mysql.cj.jdbc.Driver + jdbc:mysql://172.16.2.170:3306/ft503 + root + Flrd0914. + 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..cd1204c --- /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:// + localhost + 3306 + ft503 + 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/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