| | |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.network.api.ZyStationConnectApi; |
| | |
| | | } |
| | | |
| | | public CommandResponse sendCommand(StationCommand command) { |
| | | return zyStationConnectApi.sendCommand(deviceConfig.getDeviceNo(), command); |
| | | while (true) { |
| | | Object lock = redisUtil.get(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key); |
| | | if(lock != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | redisUtil.set(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key, "lock", 60 * 5); |
| | | break; |
| | | } |
| | | } |
| | | CommandResponse commandResponse = zyStationConnectApi.sendCommand(deviceConfig.getDeviceNo(), command); |
| | | redisUtil.del(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key); |
| | | return commandResponse; |
| | | } |
| | | |
| | | public CommandResponse sendOriginCommand(String address, short[] data) { |