| | |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | |
| | | readStatus(); |
| | | break; |
| | | // // 工位1、2写入数据 |
| | | // case 2: |
| | | // write((RgvCommand) task.getData()); |
| | | // break; |
| | | case 2: |
| | | write((RgvCommand) task.getData()); |
| | | break; |
| | | //工位1写入数据 |
| | | case 4: |
| | | write1((RgvCommand) task.getData()); |
| | |
| | | rgvProtocol.setxSpeed((short) 0); |
| | | rgvProtocol.setxDistance((short) 0); |
| | | rgvProtocol.setxDuration((short) 0); |
| | | rgvProtocol.setSouSta((short)0); |
| | | rgvProtocol.setEndSta((short)0); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | private void readStatus(){ |
| | | try { |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB100.0", (short) 30); |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB100.0", (short) 16); |
| | | if (result.IsSuccess) { |
| | | if (null == rgvProtocol || rgvProtocol.getRgvNo() == null) { |
| | | rgvProtocol = new RgvProtocol(); |
| | |
| | | rgvProtocol.setAlarm(siemensNet.getByteTransform().TransInt16(result.Content, 8)); |
| | | rgvProtocol.setStatus(siemensNet.getByteTransform().TransInt16(result.Content, 10)); |
| | | rgvProtocol.setSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 12)); |
| | | rgvProtocol.setRgvPos(siemensNet.getByteTransform().TransInt32(result.Content, 14)); |
| | | rgvProtocol.setRgvPos((int) siemensNet.getByteTransform().TransInt16(result.Content, 14)); |
| | | |
| | | |
| | | OutputQueue.RGV.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), slave.getId())); |
| | | |
| | | // 工位1复位信号 |
| | | if (rgvProtocol.getStatusType1().equals(RgvStatusType.WAITING) |
| | | || rgvProtocol.getStatusType1().equals(RgvStatusType.FETCHWAITING)) { |
| | | if (resetFlag1) { |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setAckFinish1((short)1); |
| | | if (write(rgvCommand)) { |
| | | resetFlag1 = false; |
| | | } |
| | | } |
| | | } |
| | | // if (rgvProtocol.getStatusType1().equals(RgvStatusType.WAITING) |
| | | // || rgvProtocol.getStatusType1().equals(RgvStatusType.FETCHWAITING)) { |
| | | // if (resetFlag1) { |
| | | // RgvCommand rgvCommand = new RgvCommand(); |
| | | // rgvCommand.setAckFinish1((short)1); |
| | | // if (write(rgvCommand)) { |
| | | // resetFlag1 = false; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // 工位2复位信号 |
| | | // if (rgvProtocol.getStatusType2().equals(RgvStatusType.WAITING) |
| | |
| | | return false; |
| | | } |
| | | // convertRow(command); |
| | | command.setRgvNo(slave.getId()); |
| | | short[] array = new short[11]; |
| | | array[0] = command.getAckFinish1(); |
| | | array[1] = command.getTaskNo1(); |
| | | array[2] = command.getTaskMode1(); |
| | | array[3] = command.getSourceStaNo1(); |
| | | array[4] = command.getDestinationStaNo1(); |
| | | // array[0] = command.getAckFinish1(); |
| | | // array[1] = command.getTaskNo1(); |
| | | // array[2] = command.getTaskMode1(); |
| | | // array[3] = command.getSourceStaNo1(); |
| | | // array[4] = command.getDestinationStaNo1(); |
| | | // array[5] = command.getAckFinish2(); |
| | | // array[6] = command.getTaskNo2(); |
| | | // array[7] = command.getTaskMode2(); |
| | | // array[8] = command.getSourceStaNo2(); |
| | | // array[9] = command.getDestinationStaNo2(); |
| | | // array[10] = command.getCommand(); |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | OperateResult result = new OperateResult(); |
| | | boolean[] array = new boolean[1]; |
| | | array[0] = true; |
| | | if (command.isAuto()){ |
| | | result = siemensNet.Write("DB99.0.0", true); |
| | | } else if (command.isRestoreTask()) { |
| | | result = siemensNet.Write("DB99.0.1", true); |
| | | } |
| | | else if (command.isCompTask()) { |
| | | result = siemensNet.Write("DB99.0.2", true); |
| | | } |
| | | else if (command.isStop()) { |
| | | result = siemensNet.Write("DB99.0.3", true); |
| | | } |
| | | else if (command.isReset()) { |
| | | siemensNet.Write("DB99.0.3", false); |
| | | Thread.sleep(100); |
| | | result = siemensNet.Write("DB99.0.4", true); |
| | | } |
| | | else if (command.isNoStop()) { |
| | | result = siemensNet.Write("DB99.0.3", false); |
| | | } |
| | | |
| | | // if (command.getAckFinish1() == 0 && command.getAckFinish2() == 0) { |
| | | // short commandFinish = 3; //工位1、2任务同时写入 |