| | |
| | | public class FakeNyLiftThread implements FakeThread { |
| | | |
| | | private RedisUtil redisUtil; |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"protocolStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"trayList\":[0,0,0,0],\"carList\":[0,0,0,0],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}"); |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"deviceStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"trayList\":[0,0,0,0],\"carList\":[0,0,0,0],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}"); |
| | | private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeCommandMap = new ConcurrentHashMap(); |
| | |
| | | if(fakeDeviceUtils == null){ |
| | | continue; |
| | | } |
| | | |
| | | FakeThread fakeThread1 = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 1); |
| | | |
| | | List<DeviceConfig> deviceConfigs = fakeDeviceUtils.getFakeDeviceConfig(); |
| | | for (DeviceConfig device : deviceConfigs) { |
| | | excuteFakeCommand(String.valueOf(SlaveType.Lift) + device.getDeviceNo()); |
| | | if (!device.getDeviceType().equals(String.valueOf(SlaveType.Lift))) { |
| | | continue; |
| | | } |
| | | |
| | | String key = String.valueOf(SlaveType.Lift) + device.getDeviceNo(); |
| | | |
| | | if(fakeThread1 != null){ |
| | | int hasCar = 0; |
| | | ConcurrentHashMap<String, JSONObject> shuttleFakeStatusMap1 = fakeThread1.getFakeStatusMap(); |
| | | for (Map.Entry<String, JSONObject> entry : shuttleFakeStatusMap1.entrySet()) { |
| | | JSONObject statusData = entry.getValue(); |
| | | String currentCode = statusData.getString("currentCode"); |
| | | JSONObject point = JSON.parseObject(currentCode); |
| | | String currentPoint = point.getInteger("x") + "-" + point.getInteger("y"); |
| | | if (device.getOtherData().toString().equals(currentPoint)) { |
| | | hasCar = 1; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | JSONObject fakeStatus = fakeStatusMap.get(key); |
| | | fakeStatus.put("hasCar", hasCar); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } |
| | | |
| | | excuteFakeCommand(key); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if (commandType == 1) { |
| | | //取放货 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//取货中 |
| | | fakeStatus.put("deviceStatus", 1);//取货中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 2) { |
| | | //小车换层 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//取货中 |
| | | fakeStatus.put("deviceStatus", 1);//取货中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 3) { |
| | | //提升机移动 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//移动中 |
| | | fakeStatus.put("deviceStatus", 1);//移动中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 9996) { |
| | | //复位 |
| | | fakeStatus.put("plcTaskNo", 0);//任务号 |
| | | fakeStatus.put("protocolStatus", 0); |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | |
| | | |
| | | device.put("model", fakeStatus.getInteger("model")); |
| | | device.put("plcTaskNo", fakeStatus.getInteger("plcTaskNo")); |
| | | device.put("protocolStatus", fakeStatus.getInteger("protocolStatus")); |
| | | device.put("deviceStatus", fakeStatus.getInteger("deviceStatus")); |
| | | device.put("taskMode", fakeStatus.getInteger("taskMode")); |
| | | device.put("pick", fakeStatus.getInteger("pick")); |
| | | device.put("put", fakeStatus.getInteger("put")); |