]> git.basschouten.com Git - openhab-addons.git/blob
4eb79b3a883247c9ff9ee7fca6d0c7e52c7c26cb
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor;
14
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;
19
20 /**
21  * The {@link SceneReadingJobExecutor} is the implementation of the {@link AbstractSensorJobExecutor} to execute
22  * digitalSTROM-Device scene configuration {@link SensorJob}'s e.g. {@link SceneConfigReadingJob} and
23  * {@link SceneOutputValueReadingJob}.
24  * <p>
25  * In addition priorities can be assigned to jobs therefore the {@link SceneReadingJobExecutor} offers the methods
26  * {@link #addHighPriorityJob(SensorJob)}, {@link #addMediumPriorityJob(SensorJob)} and
27  * {@link #addLowPriorityJob(SensorJob)}.
28  * </p>
29  * <p>
30  * <b>NOTE:</b><br>
31  * In contrast to the {@link SensorJobExecutor} the {@link SceneReadingJobExecutor} will execute {@link SensorJob}'s
32  * with high priority always before medium priority {@link SensorJob}s and so on.
33  *
34  * @author Michael Ochel - Initial contribution
35  * @author Matthias Siegele - Initial contribution
36  *
37  */
38 public class SceneReadingJobExecutor extends AbstractSensorJobExecutor {
39
40     private Logger logger = LoggerFactory.getLogger(SceneReadingJobExecutor.class);
41
42     /**
43      * Creates a new {@link SceneReadingJobExecutor}.
44      *
45      * @param connectionManager must not be null
46      */
47     public SceneReadingJobExecutor(ConnectionManager connectionManager) {
48         super(connectionManager);
49     }
50
51     @Override
52     public void addHighPriorityJob(SensorJob sensorJob) {
53         if (sensorJob == null) {
54             return;
55         }
56         sensorJob.setInitalisationTime(0);
57         addSensorJobToCircuitScheduler(sensorJob);
58         logger.debug("Add SceneReadingJob from device with dSID {} and high-priority to SceneReadingSobExecutor",
59                 sensorJob.getDSID());
60     }
61
62     @Override
63     public void addMediumPriorityJob(SensorJob sensorJob) {
64         if (sensorJob == null) {
65             return;
66         }
67         sensorJob.setInitalisationTime(1);
68         addSensorJobToCircuitScheduler(sensorJob);
69         logger.debug("Add SceneReadingJob from device with dSID {} and medium-priority to SceneReadingJobExecutor",
70                 sensorJob.getDSID());
71     }
72
73     @Override
74     public void addLowPriorityJob(SensorJob sensorJob) {
75         if (sensorJob == null) {
76             return;
77         }
78         sensorJob.setInitalisationTime(2);
79         addSensorJobToCircuitScheduler(sensorJob);
80         logger.debug("Add SceneReadingJob from device with dSID {} and low-priority to SceneReadingJobExecutor",
81                 sensorJob.getDSID());
82     }
83 }