123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package com.gzlh.device.plc.job;
- import cn.hutool.core.thread.ThreadUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.extra.spring.SpringUtil;
- import com.gzlh.bus.ChannelCacheManager;
- import com.gzlh.bus.EventBus;
- import com.gzlh.bus.EventDataManager;
- import com.gzlh.bus.SysConfig;
- import com.gzlh.config.ModuleEnum;
- import com.gzlh.config.dto.SerialSetting;
- import com.gzlh.config.task.Task;
- import com.gzlh.device.plc.event.PLCEvent;
- import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
- import com.gzlh.device.weighbridge.handler.impl.CommonWeighbridgeHandler;
- import com.gzlh.entity.ReqBO;
- import com.gzlh.utils.DeviceCache;
- import lombok.extern.slf4j.Slf4j;
- @Slf4j
- public class StartInitTask extends Task {
- public StartInitTask(String id, long delayInMilliseconds) {
- super(id, delayInMilliseconds);
- }
- @Override
- public void run() {
- EventBus eventBus = SpringUtil.getBean(EventBus.class);
- int count = 0;
- while (count < 20) {
- count++;
- if (!CommonWeighbridgeHandler.hsCar) {
- log.info("雷达断开,通道无车,触发初始化======");
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.IDLE);
- return;
- }
- ThreadUtil.sleep(1000);
- }
- SerialSetting.PlcDTO.StatusDTO pointInfo = SysConfig.serialSetting.getPlc().getStatus();
- String upPoint = pointInfo.getUpPoint();
- String plcStatus = DeviceCache.getPlcStatus();
- String upPointStatus = plcStatus.charAt(Integer.parseInt(upPoint)) + "";
- if (StrUtil.equals(upPointStatus, "1")) {
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.CAR_PASS);
- } else if (StrUtil.equals(upPointStatus, "0") && !CommonWeighbridgeHandler.hsCar) {
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.CAR_BACK);
- }
- }
- }
|