| | |
| | | return testMapper == null || testMapper.hasReceivingTestForAdapter(adapterCode) > 0; |
| | | } |
| | | |
| | | /** 发现失败或返回空拓扑时,清除该适配器下已登记设备的过期运行事实。 */ |
| | | public void markUnavailable(String adapterCode) |
| | | { |
| | | detectionCabinetMapper.markRegisteredFactsUnobservable(adapterCode); |
| | | detectionCabinetMapper.markRegisteredCabinetsOffline(adapterCode); |
| | | } |
| | | |
| | | private AdapterDiscoveryResult discoverNow(DeviceAdapterRegistry registry, DiscoverySource source) |
| | | { |
| | | DiscoveryObservation observation = registry.execute(source.adapterCode(), runtime -> { |
| | |
| | | observedAt, observedAt.plus(lifetime))) |
| | | .toList(); |
| | | candidateStore.recordCabinets(candidates); |
| | | if (detected.isEmpty()) markUnavailable(source.adapterCode()); |
| | | synchronizeRegisteredFacts(source, detected, snapshots, observedAt); |
| | | return new AdapterDiscoveryResult(grouped.size(), detected.size(), observedAt); |
| | | } |
| | |
| | | detectionCabinetMapper.updateRegisteredChannelObservation(source.adapterCode(), identity.devtype(), |
| | | identity.devid(), identity.subdevid(), identity.chlid(), channel.available() ? "ONLINE" : "OFFLINE", |
| | | workStatus.name(), observedAt, successfulObservation); |
| | | if (channel.available() && !successfulObservation) |
| | | detectionCabinetMapper.touchRegisteredChannelObservation(source.adapterCode(), identity.devtype(), |
| | | identity.devid(), identity.subdevid(), identity.chlid(), observedAt); |
| | | CabinetKey cabinet = new CabinetKey(identity.devtype(), identity.devid()); |
| | | cabinetOnline.merge(cabinet, channel.available(), Boolean::logicalOr); |
| | | } |
| | |
| | | && channel.identity().devtype() == cabinet.devtype() |
| | | && channel.identity().devid() == cabinet.devid() |
| | | && snapshots.containsKey(channel.identity())))); |
| | | cabinetOnline.forEach((cabinet, online) -> { |
| | | boolean successfulSnapshot = online && detected.stream().anyMatch(channel -> channel.available() |
| | | && channel.identity().devtype() == cabinet.devtype() |
| | | && channel.identity().devid() == cabinet.devid() |
| | | && snapshots.containsKey(channel.identity())); |
| | | if (online && !successfulSnapshot) |
| | | detectionCabinetMapper.touchRegisteredCabinetObservation(source.adapterCode(), cabinet.devtype(), |
| | | cabinet.devid(), observedAt); |
| | | }); |
| | | } |
| | | |
| | | private CabinetCandidate toCandidate(DiscoverySource source, CabinetKey key, List<DetectedChannel> channels, |