| | |
| | | import com.zy.core.network.api.ZyStationConnectApi; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | import java.util.List; |
| | | import com.zy.core.network.fake.ZyStationFakeConnect; |
| | | import com.zy.core.network.fake.ZyStationFakeSegConnect; |
| | | import com.zy.core.network.fake.ZyStationV4FakeSegConnect; |
| | | import com.zy.core.network.real.ZyStationRealConnect; |
| | |
| | | @Slf4j |
| | | public class ZyStationConnectDriver implements ThreadHandler { |
| | | |
| | | private static final ZyStationFakeConnect zyStationFakeConnect = new ZyStationFakeConnect(); |
| | | private static final ZyStationFakeSegConnect zyStationFakeSegConnect = new ZyStationFakeSegConnect(); |
| | | private static final ZyStationV4FakeSegConnect zyStationV4FakeSegConnect = new ZyStationV4FakeSegConnect(); |
| | | |
| | |
| | | private RedisUtil redisUtil; |
| | | private volatile ZyStationConnectApi zyStationConnectApi; |
| | | private volatile boolean closed = false; |
| | | private volatile boolean fakeConfigUnsupported = false; |
| | | private ScheduledExecutorService executor; |
| | | private final Object connectLock = new Object(); |
| | | |
| | |
| | | public boolean connect() { |
| | | synchronized (connectLock) { |
| | | if (closed) { |
| | | return false; |
| | | } |
| | | if (fakeConfigUnsupported) { |
| | | return false; |
| | | } |
| | | if (connected && zyStationConnectApi != null) { |
| | |
| | | zyStationV4FakeSegConnect.addFakeConnect(deviceConfig, redisUtil); |
| | | connectApi = zyStationV4FakeSegConnect; |
| | | } else { |
| | | zyStationFakeConnect.addFakeConnect(deviceConfig, redisUtil); |
| | | connectApi = zyStationFakeConnect; |
| | | fakeConfigUnsupported = true; |
| | | zyStationConnectApi = null; |
| | | log.error("旧版输送站 fake 已移除,deviceNo={}, threadImpl={}, 请切换到 ZyStationV3Thread 或 ZyStationV4Thread", |
| | | deviceConfig.getDeviceNo(), deviceConfig.getThreadImpl()); |
| | | return false; |
| | | } |
| | | } |
| | | |