+ @Override
+ public void startScheduling(final DeviceInfo deviceInfo) {
+ if (isStatisticsPollingOff) {
+ LOG.info("Statistics are shutdown for device: {}", deviceInfo.getNodeId());
+ return;
+ }
+
+ final StatisticsContext statisticsContext = contexts.get(deviceInfo);
+
+ if (statisticsContext == null) {
+ LOG.warn("Statistics context not found for device: {}", deviceInfo.getNodeId());
+ return;
+ }
+
+ if (statisticsContext.isSchedulingEnabled()) {
+ LOG.debug("Statistics scheduling is already enabled for device: {}", deviceInfo.getNodeId());
+ return;
+ }
+
+ LOG.info("Scheduling statistics poll for device: {}", deviceInfo.getNodeId());
+
+ statisticsContext.setSchedulingEnabled(true);
+ scheduleNextPolling(
+ statisticsContext.gainDeviceState(),
+ deviceInfo,
+ statisticsContext,
+ new TimeCounter()
+ );
+ }
+
+ @Override
+ public void stopScheduling(final DeviceInfo deviceInfo) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stopping statistics scheduling for device: {}", deviceInfo.getNodeId());
+ }
+ final StatisticsContext statisticsContext = contexts.get(deviceInfo);
+
+ if (statisticsContext == null) {
+ LOG.warn("Statistics context not found for device: {}", deviceInfo.getNodeId());
+ return;
+ }
+ statisticsContext.setSchedulingEnabled(false);
+ }
+