| | |
| | | package com.zy.acs.manager.core.scheduler; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusRtuOverTcp; |
| | | import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp; |
| | | import com.zy.acs.charge.ChargeCoreService; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.enums.AgvStatusType; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.core.integrate.wms.TaskReportService; |
| | | import com.zy.acs.manager.core.integrate.wms.FaultReportService; |
| | | import com.zy.acs.manager.core.service.ChargeService; |
| | | import com.zy.acs.manager.core.service.MainLockWrapService; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * judge whether agv go to funcSta which be charging or standby |
| | |
| | | @Autowired |
| | | private FaultReportService faultReportService; |
| | | @Autowired |
| | | private FuncTaskService funcTaskService; |
| | | private ChargeService chargeService; |
| | | @Autowired |
| | | private ChargeCoreService chargeCoreService; |
| | | |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | |
| | | // if (agvDetailService.isPowerLoss(agv, agvDetail, agvModel)) { |
| | | // continue; |
| | | // } |
| | | // 存在充电标记,跳过 |
| | | if (redis.getMap(RedisConstant.AGV_CHARGE_FLAG, agv.getUuid()) != null) { |
| | | continue; |
| | | } |
| | | // is charging ? |
| | | if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) { |
| | | if (agvDetail.getSoc() < agvModel.getQuaBattery()) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 调度对接充电桩 |
| | | */ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private synchronized void workFuncTask() { |
| | | List<FuncTask> funcTaskList = funcTaskService.list(new LambdaQueryWrapper<FuncTask>().eq(FuncTask::getFuncTaskSts, TaskStsType.INIT.toString())); |
| | | for (FuncTask funcTask : funcTaskList) { |
| | | // 调度小车去对接充电桩 |
| | | private synchronized void startCharge() { |
| | | Set<String> mapKeys = redis.getMapKeys(RedisConstant.AGV_CHARGE_FLAG); |
| | | for (String key : mapKeys) { |
| | | Integer status = redis.getMap(RedisConstant.AGV_CHARGE_FLAG, key); |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvNo(key); |
| | | FuncSta funcSta = funcStaService.getByCodeAndType(agvDetail.getCode(), FuncStaType.CHARGE.toString()); |
| | | ModbusRtuOverTcp modbusTcp = chargeService.get(funcSta.getUuid()); |
| | | if (status != null && status == 1) { |
| | | // 后退信号消失,说明马达正在前进 |
| | | if (chargeCoreService.checkBackwardRelayOffline(modbusTcp)) { |
| | | chargeCoreService.startCharging(modbusTcp); |
| | | } |
| | | while (chargeCoreService.checkForwardRelayOnline(modbusTcp)) { |
| | | double current = chargeCoreService.getCurrent(modbusTcp); |
| | | double voltage = chargeCoreService.getVoltage(modbusTcp); |
| | | if (current > 0 && voltage > 0) { |
| | | redis.setMap(RedisConstant.AGV_CHARGE_FLAG, key, 2); |
| | | log.info("charge complete"); |
| | | }else { |
| | | log.info("read charge current and voltage: {},{}", current, voltage); |
| | | } |
| | | } |
| | | } else if (status != null && status == 2) { |
| | | // 后退信号消失,说明马达正在前进 |
| | | if (chargeCoreService.checkForwardRelayOnline(modbusTcp)) { |
| | | chargeCoreService.startCharging(modbusTcp); |
| | | } |
| | | while (chargeCoreService.checkBackwardRelayOffline(modbusTcp)) { |
| | | redis.deleteMap(RedisConstant.AGV_CHARGE_FLAG, key); |
| | | log.info("charge over"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |