自动化立体仓库 - WCS系统
#
luxiaotao1123
2020-08-27 2aeea7b010e96f74a52bc4ed5873c41c177a5953
src/main/java/com/zy/core/thread/DevpThread.java
@@ -104,7 +104,7 @@
    /**
     * 读取状态 ====> 整块plc
     */
    private void read(){
    private void read() throws InterruptedException {
        OperateResultExOne<byte[]> result = melsecMcNet.Read("D101", (short) 30);
        if (result.IsSuccess) {
            for (int i = 1; i <= 8; i++) {
@@ -118,6 +118,7 @@
                staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+40));   // 目标站
            }
        }
        Thread.sleep(100);
        OperateResultExOne<boolean[]> result1 = melsecMcNet.ReadBool("M800", (short) 64);
        if (result1.IsSuccess) {
            for (int i = 1; i <= 8; i++) {
@@ -230,24 +231,27 @@
        melsecMcNet.ConnectClose();
    }
    public static void main(String[] args) {
    public static void main(String[] args) throws Exception {
        DevpSlave slave = new DevpSlave();
        slave.setIp("192.168.3.65");
        slave.setPort(6000);
        DevpThread devpThread = new DevpThread(slave);
        devpThread.connect();
        devpThread.read();
        System.out.println("第一次读");
        // 写
        StaProtocol staProtocol = devpThread.getStation().get(1);
        staProtocol.setWorkNo((short) 232);
        staProtocol.setStaNo((short) 6);
        staProtocol.setAutoing(true);
        staProtocol.setEmptyMk(true);
        staProtocol.setInEnable(true);
        devpThread.write(staProtocol);
        System.out.println("----------------------------------------");
//        StaProtocol staProtocol = devpThread.getStation().get(1);
//        staProtocol.setWorkNo((short) 232);
//        staProtocol.setStaNo((short) 6);
//        staProtocol.setAutoing(true);
//        staProtocol.setEmptyMk(true);
//        staProtocol.setInEnable(true);
//        devpThread.write(staProtocol);
//        System.out.println("----------------------------------------");
        Thread.sleep(400);
        // 读
        devpThread.read();
        System.out.println("第二次读");
        System.out.println(JSON.toJSONString(devpThread.station));
    }