2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor;
15 import org.openhab.binding.digitalstrom.internal.lib.manager.ConnectionManager;
16 import org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.SensorJob;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * The {@link SensorJobExecutor} is the implementation of the {@link AbstractSensorJobExecutor} to execute
22 * digitalSTROM-Device {@link SensorJob}'s e.g. {@link DeviceConsumptionSensorJob} and
23 * {@link DeviceOutputValueSensorJob}.
25 * In addition priorities can be assigned to jobs, but the following list shows the maximum evaluation of a
26 * {@link SensorJob} per priority.
29 * <li>low priority: read cycles before execution is set in {@link Config}</li>
30 * <li>medium priority: read cycles before execution is set in {@link Config}</li>
31 * <li>high priority: read cycles before execution 0</li>
34 * @author Michael Ochel - Initial contribution
35 * @author Matthias Siegele - Initial contribution
38 public class SensorJobExecutor extends AbstractSensorJobExecutor {
40 private final Logger logger = LoggerFactory.getLogger(SensorJobExecutor.class);
42 private final long mediumFactor = super.config.getSensorReadingWaitTime() * super.config.getMediumPriorityFactor();
43 private final long lowFactor = super.config.getSensorReadingWaitTime() * super.config.getLowPriorityFactor();
46 * Creates a new {@link SensorJobExecutor}.
48 * @param connectionManager must not be null
50 public SensorJobExecutor(ConnectionManager connectionManager) {
51 super(connectionManager);
55 public void addHighPriorityJob(SensorJob sensorJob) {
56 if (sensorJob == null) {
59 addSensorJobToCircuitScheduler(sensorJob);
60 logger.debug("Add SensorJob from device with dSID {} and high-priority to SensorJobExecutor",
65 public void addMediumPriorityJob(SensorJob sensorJob) {
66 if (sensorJob == null) {
69 sensorJob.setInitalisationTime(sensorJob.getInitalisationTime() + this.mediumFactor);
70 addSensorJobToCircuitScheduler(sensorJob);
71 logger.debug("Add SensorJob from device with dSID {} and medium-priority to SensorJobExecutor",
76 public void addLowPriorityJob(SensorJob sensorJob) {
77 if (sensorJob == null) {
80 sensorJob.setInitalisationTime(sensorJob.getInitalisationTime() + this.lowFactor);
81 addSensorJobToCircuitScheduler(sensorJob);
82 logger.debug("Add SensorJob from device with dSID {} and low-priority to SensorJobExecutor",