| | |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | import java.util.List; |
| | | import com.zy.core.network.fake.ZyStationFakeSegConnect; |
| | | import com.zy.core.network.fake.ZyStationV4FakeSegConnect; |
| | | import com.zy.core.network.real.ZyStationRealConnect; |
| | | import com.zy.core.network.real.ZyStationV3RealConnect; |
| | | import com.zy.core.network.real.ZyStationV4RealConnect; |
| | | import com.zy.core.network.real.ZyStationV5RealConnect; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import java.util.Collections; |
| | | import java.util.concurrent.Executors; |
| | |
| | | public class ZyStationConnectDriver implements ThreadHandler { |
| | | |
| | | private static final ZyStationFakeSegConnect zyStationFakeSegConnect = new ZyStationFakeSegConnect(); |
| | | private static final ZyStationV4FakeSegConnect zyStationV4FakeSegConnect = new ZyStationV4FakeSegConnect(); |
| | | private static final long SEND_LOCK_WARN_MS = 500L; |
| | | private static final long SEND_COST_WARN_MS = 5_000L; |
| | | private static final long SEND_LOCK_POLL_MS = 20L; |
| | |
| | | if (deviceConfig.getFake() == 0) { |
| | | if ("ZyStationV3Thread".equals(deviceConfig.getThreadImpl())) { |
| | | connectApi = new ZyStationV3RealConnect(deviceConfig, redisUtil); |
| | | } else if ("ZyStationV4Thread".equals(deviceConfig.getThreadImpl()) |
| | | || "ZyStationV5Thread".equals(deviceConfig.getThreadImpl())) { |
| | | connectApi = new ZyStationV4RealConnect(deviceConfig, redisUtil); |
| | | } else if ("ZyStationV5Thread".equals(deviceConfig.getThreadImpl())) { |
| | | connectApi = new ZyStationV5RealConnect(deviceConfig, redisUtil); |
| | | } else { |
| | | connectApi = new ZyStationRealConnect(deviceConfig, redisUtil); |
| | | } |
| | | } else { |
| | | if ("ZyStationV3Thread".equals(deviceConfig.getThreadImpl())) { |
| | | zyStationFakeSegConnect.addFakeConnect(deviceConfig, redisUtil); |
| | | connectApi = zyStationFakeSegConnect; |
| | | } else if ("ZyStationV4Thread".equals(deviceConfig.getThreadImpl()) |
| | | || "ZyStationV5Thread".equals(deviceConfig.getThreadImpl())) { |
| | | zyStationV4FakeSegConnect.addFakeConnect(deviceConfig, redisUtil); |
| | | connectApi = zyStationV4FakeSegConnect; |
| | | } else { |
| | | fakeConfigUnsupported = true; |
| | | zyStationConnectApi = null; |
| | | log.error("旧版输送站 fake 已移除,deviceNo={}, threadImpl={}, 请切换到 ZyStationV3Thread、ZyStationV4Thread 或 ZyStationV5Thread", |
| | | deviceConfig.getDeviceNo(), deviceConfig.getThreadImpl()); |
| | | return false; |
| | | } |
| | | zyStationFakeSegConnect.addFakeConnect(deviceConfig, redisUtil); |
| | | connectApi = zyStationFakeSegConnect; |
| | | } |
| | | |
| | | boolean connect = connectApi.connect(); |