| | |
| | | import com.zy.common.SpringUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.DeviceCommandMsgModel; |
| | | import com.zy.core.model.DeviceMsgModel; |
| | | import com.zy.core.model.param.UpdateFakeThreadStatusParam; |
| | | import com.zy.core.properties.DeviceConfig; |
| | | import com.zy.core.thread.FakeThread; |
| | | import com.zy.core.thread.impl.ZyForkLiftThread; |
| | | import com.zy.core.utils.DeviceMsgUtils; |
| | | import com.zy.core.utils.FakeDeviceUtils; |
| | |
| | | |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Slf4j |
| | | @SuppressWarnings("all") |
| | | public class FakeZyForkLiftThread implements ThreadHandler { |
| | | public class FakeZyForkLiftThread implements FakeThread { |
| | | |
| | | private RedisUtil redisUtil; |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"wrkNo\":0,\"lev\":1,\"protocolStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"trayList\":[0,0,0,0],\"carList\":[0,0,0,0]}"); |
| | | private HashMap<String, Thread> fakeThreadMap = new HashMap(); |
| | | private HashMap<String, JSONObject> fakeStatusMap = new HashMap(); |
| | | private HashMap<String, JSONObject> fakeCommandMap = new HashMap(); |
| | | private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeCommandMap = new ConcurrentHashMap(); |
| | | |
| | | private boolean fake = false; |
| | | |
| | |
| | | |
| | | |
| | | // init |
| | | ThreadHandler thread = new ZyForkLiftThread(device, redisUtil);; |
| | | ZyForkLiftThread thread = new ZyForkLiftThread(device, redisUtil);; |
| | | new Thread(thread).start(); |
| | | SlaveConnection.put(SlaveType.ForkLift, device.getDeviceNo(), thread); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ConcurrentHashMap<String, Thread> getFakeThreadMap() { |
| | | return this.fakeThreadMap; |
| | | } |
| | | |
| | | @Override |
| | | public ConcurrentHashMap<String, JSONObject> getFakeStatusMap() { |
| | | return this.fakeStatusMap; |
| | | } |
| | | |
| | | @Override |
| | | public ConcurrentHashMap<String, JSONObject> getFakeCommandMap() { |
| | | return this.fakeCommandMap; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateFakeStatus(UpdateFakeThreadStatusParam param) { |
| | | String key = param.getDeviceType() + param.getDeviceNo(); |
| | | JSONObject result = fakeStatusMap.get(key); |
| | | if (result == null) { |
| | | return false; |
| | | } |
| | | |
| | | JSONObject newData = JSON.parseObject(param.getData()); |
| | | this.fakeStatusMap.put(key, newData); |
| | | return true; |
| | | } |
| | | } |