| | |
| | | this.clock = clock; |
| | | } |
| | | |
| | | /** 返回本实例登记的适配器编码;推送端点与通道身份都用它定位来源。 */ |
| | | @Override |
| | | public String adapterCode() |
| | | { |
| | | return config.adapterCode(); |
| | | } |
| | | |
| | | /** 返回本实例登记的能力标记;推式来源同样只观测,不提供控制能力。 */ |
| | | @Override |
| | | public AdapterCapabilities capabilities() |
| | | { |
| | |
| | | return Map.copyOf(result); |
| | | } |
| | | |
| | | /** |
| | | * 返回该通道在落地表里最近一条采样行投影成的实时观测。 |
| | | * |
| | | * @param channel 检测柜通道身份 |
| | | * @return 最近一条采样行的实时观测;该通道还没有采样行时为空 |
| | | */ |
| | | @Override |
| | | public CabinetRealtime latestCabinet(ChannelIdentity channel) |
| | | { |
| | |
| | | return List.of(); |
| | | } |
| | | |
| | | /** 返回推式来源固定的持久化槽位间隔;采样行按来源自己的落库节奏到达。 */ |
| | | @Override |
| | | public long persistenceIntervalMillis(ChannelIdentity channel) |
| | | { |
| | |
| | | java.util.Date receivedAt = records.selectHeartbeatAt(config.adapterCode()); |
| | | if (receivedAt == null) |
| | | throw new DeviceAdapterException("SOURCE_OFFLINE", |
| | | "尚未收到取数程序的推送:请确认程序已启动并指向 " + config.host() + ":" + config.port(), null); |
| | | "尚未收到取数程序的推送:请确认 " + config.host() |
| | | + " 那台机器上的取数程序已启动,并指向本系统的接收端点", null); |
| | | Duration staleAfter = staleAfter(); |
| | | Duration silent = Duration.between(receivedAt.toInstant(), clock.instant()); |
| | | if (silent.compareTo(staleAfter) > 0) |