| | |
| | | |
| | | @Value("${deviceMsgConfig.gatewayPort}") |
| | | private int gatewayPort; |
| | | @Value("${deviceMsgConfig.enableFakeAndDeviceThread}") |
| | | private boolean enableFakeAndDeviceThread; |
| | | @Value("${deviceMsgConfig.enableFake}") |
| | | private boolean enableFake; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | private void initFakeThread(){ |
| | | ThreadHandler thread = new FakeNyShuttleThread(redisUtil, gatewayPort); |
| | | if (!enableFake) { |
| | | return; |
| | | } |
| | | |
| | | ThreadHandler thread = new FakeNyShuttleThread(redisUtil, gatewayPort, enableFakeAndDeviceThread); |
| | | new Thread(thread).start(); |
| | | |
| | | ThreadHandler thread2 = new FakeZyForkLiftThread(redisUtil); |
| | |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"mode\":1,\"extend\":{\"countQuantity\":400,\"suspendState\":0,\"minCellVoltage\":3279,\"chargeCycleTimes\":0,\"maxCellVoltage\":3281,\"surplusQuantity\":204,\"voltage\":5248},\"hasLift\":false,\"hasPallet\":false,\"batteryVoltage\":5248,\"runDirection\":\"2\",\"currentCode\":\"{\\\"x\\\":19,\\\"y\\\":11,\\\"z\\\":2}\",\"errorCode\":\"0\",\"hasCharge\":false,\"batteryPower\":\"51\",\"speed\":0,\"deviceStatus\":1}"); |
| | | private ServerSocket serverSocket; |
| | | private Integer gatewayPort; |
| | | private boolean enableFakeAndDeviceThread; |
| | | private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, Socket> fakeServerMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap(); |
| | |
| | | |
| | | private boolean fake = false; |
| | | |
| | | public FakeNyShuttleThread(RedisUtil redisUtil, Integer gatewayPort) { |
| | | public FakeNyShuttleThread(RedisUtil redisUtil, Integer gatewayPort, boolean enableFakeAndDeviceThread) { |
| | | this.redisUtil = redisUtil; |
| | | this.gatewayPort = gatewayPort; |
| | | this.enableFakeAndDeviceThread = enableFakeAndDeviceThread; |
| | | } |
| | | |
| | | @Override |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (enableFakeAndDeviceThread) { |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); |
| | | if (shuttleThread == null) { |
| | | // init |
| | |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | log.info("{}:device is run,devices:{}", device.getDeviceNo(),JSON.toJSONString(fakeServerMap)); |
| | | |
| | |
| | | gatewayId: 1 |
| | | # 网关端口 |
| | | gatewayPort: 8888 |
| | | # 启动模拟器 |
| | | enableFake: true |
| | | # 启动模拟器时并启动设备线程 |
| | | enableFakeAndDeviceThread: false |