| | |
| | | import com.zy.asrs.entity.DeviceDataLog; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.DeviceDataLogService; |
| | | import com.zy.asrs.service.impl.RcsServiceImpl; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | |
| | | case 2: |
| | | write((StaProtocol)task.getData()); |
| | | break; |
| | | case 3: |
| | | write1((StaProtocol)task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | //外形检测 |
| | | //外形检测 - 带防抖处理 |
| | | Integer[] arr={401,402}; |
| | | OperateResultExOne<byte[]> resultErr1 = siemensS7Net.Read("DB101.700.0", (short) (arr.length*6)); |
| | | OperateResultExOne<byte[]> resultErr1 = siemensS7Net.Read("DB101.702.0", (short) (arr.length*6)); |
| | | |
| | | for (int i = 0; i < arr.length; i++) { |
| | | StaProtocol staProtocol1 = station.get(arr[i]); |
| | | if(resultErr1.IsSuccess){ |
| | | if(resultErr1.IsSuccess && staProtocol1 != null){ |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool(resultErr1.Content, i*6, 1); |
| | | |
| | | // 【新增】保存旧的超高状态 |
| | | boolean oldHighError = staProtocol1.isHighError(); |
| | | |
| | | // 更新所有状态 |
| | | staProtocol1.setFrontError(status1[0]); |
| | | staProtocol1.setBackError(status1[1]); |
| | | staProtocol1.setHighError(status1[2]); |
| | | staProtocol1.setHighError(status1[2]); // 超高状态 |
| | | staProtocol1.setLeftError(status1[3]); |
| | | staProtocol1.setRightError(status1[4]); |
| | | staProtocol1.setWeightError(status1[5]); |
| | | staProtocol1.setBarcodeError(status1[6]); |
| | | |
| | | // 【新增】超高状态变化处理 - 只有变化时才调用 |
| | | if (oldHighError != status1[2]) { |
| | | try { |
| | | RcsServiceImpl rcsService = SpringUtils.getBean(RcsServiceImpl.class); |
| | | if (rcsService != null) { |
| | | rcsService.agvPause(staProtocol1); |
| | | log.info("超高状态变化 - 站点: {}, 状态: {} -> {}, 已调用AGV控制", |
| | | arr[i], oldHighError, status1[2]); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("调用agvPause失败 - 站点: {}, 错误: {}", arr[i], e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 扫码器触发 |
| | | */ |
| | | private void write1(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | return; |
| | | } |
| | | |
| | | int index = 0; |
| | | if(staProtocol.getSiteId() == 402){ |
| | | index = 1; |
| | | } |
| | | OperateResult writeResult1 = siemensS7Net.Write("DB100.500." + index, true); // 扫码器触发 |
| | | if (!writeResult1.IsSuccess) { |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } |
| | | } |
| | | |
| | | // 更新入出库模式 |
| | | private void updateIoMode() throws InterruptedException { |
| | | if (this.ioModeOf2F != IoModeType.NONE) { |