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.
23 * {@link org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.impl.DeviceConsumptionSensorJob} and
24 * {@link org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.impl.DeviceOutputValueSensorJob}.
26 * In addition priorities can be assigned to jobs, but the following list shows the maximum evaluation of a
27 * {@link SensorJob} per priority.
30 * <li>low priority: read cycles before execution is set in
31 * {@link org.openhab.binding.digitalstrom.internal.lib.config.Config}</li>
32 * <li>medium priority: read cycles before execution is set in
33 * {@link org.openhab.binding.digitalstrom.internal.lib.config.Config}</li>
34 * <li>high priority: read cycles before execution 0</li>
37 * @author Michael Ochel - Initial contribution
38 * @author Matthias Siegele - Initial contribution
41 public class SensorJobExecutor extends AbstractSensorJobExecutor {
43 private final Logger logger = LoggerFactory.getLogger(SensorJobExecutor.class);
45 private final long mediumFactor = super.config.getSensorReadingWaitTime() * super.config.getMediumPriorityFactor();
46 private final long lowFactor = super.config.getSensorReadingWaitTime() * super.config.getLowPriorityFactor();
49 * Creates a new {@link SensorJobExecutor}.
51 * @param connectionManager must not be null
53 public SensorJobExecutor(ConnectionManager connectionManager) {
54 super(connectionManager);
58 public void addHighPriorityJob(SensorJob sensorJob) {
59 if (sensorJob == null) {
62 addSensorJobToCircuitScheduler(sensorJob);
63 logger.debug("Add SensorJob from device with dSID {} and high-priority to SensorJobExecutor",
68 public void addMediumPriorityJob(SensorJob sensorJob) {
69 if (sensorJob == null) {
72 sensorJob.setInitalisationTime(sensorJob.getInitalisationTime() + this.mediumFactor);
73 addSensorJobToCircuitScheduler(sensorJob);
74 logger.debug("Add SensorJob from device with dSID {} and medium-priority to SensorJobExecutor",
79 public void addLowPriorityJob(SensorJob sensorJob) {
80 if (sensorJob == null) {
83 sensorJob.setInitalisationTime(sensorJob.getInitalisationTime() + this.lowFactor);
84 addSensorJobToCircuitScheduler(sensorJob);
85 logger.debug("Add SensorJob from device with dSID {} and low-priority to SensorJobExecutor",