]> git.basschouten.com Git - openhab-addons.git/blob
c13d3742458a781229156fd216d332482d7c74e7
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.
23  * {@link org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.impl.SceneConfigReadingJob} and
24  * {@link org.openhab.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.impl.SceneOutputValueReadingJob}.
25  * <p>
26  * In addition priorities can be assigned to jobs therefore the {@link SceneReadingJobExecutor} offers the methods
27  * {@link #addHighPriorityJob(SensorJob)}, {@link #addMediumPriorityJob(SensorJob)} and
28  * {@link #addLowPriorityJob(SensorJob)}.
29  * </p>
30  * <p>
31  * <b>NOTE:</b><br>
32  * In contrast to the {@link SensorJobExecutor} the {@link SceneReadingJobExecutor} will execute {@link SensorJob}'s
33  * with high priority always before medium priority {@link SensorJob}s and so on.
34  *
35  * @author Michael Ochel - Initial contribution
36  * @author Matthias Siegele - Initial contribution
37  *
38  */
39 public class SceneReadingJobExecutor extends AbstractSensorJobExecutor {
40
41     private Logger logger = LoggerFactory.getLogger(SceneReadingJobExecutor.class);
42
43     /**
44      * Creates a new {@link SceneReadingJobExecutor}.
45      *
46      * @param connectionManager must not be null
47      */
48     public SceneReadingJobExecutor(ConnectionManager connectionManager) {
49         super(connectionManager);
50     }
51
52     @Override
53     public void addHighPriorityJob(SensorJob sensorJob) {
54         if (sensorJob == null) {
55             return;
56         }
57         sensorJob.setInitalisationTime(0);
58         addSensorJobToCircuitScheduler(sensorJob);
59         logger.debug("Add SceneReadingJob from device with dSID {} and high-priority to SceneReadingSobExecutor",
60                 sensorJob.getDSID());
61     }
62
63     @Override
64     public void addMediumPriorityJob(SensorJob sensorJob) {
65         if (sensorJob == null) {
66             return;
67         }
68         sensorJob.setInitalisationTime(1);
69         addSensorJobToCircuitScheduler(sensorJob);
70         logger.debug("Add SceneReadingJob from device with dSID {} and medium-priority to SceneReadingJobExecutor",
71                 sensorJob.getDSID());
72     }
73
74     @Override
75     public void addLowPriorityJob(SensorJob sensorJob) {
76         if (sensorJob == null) {
77             return;
78         }
79         sensorJob.setInitalisationTime(2);
80         addSensorJobToCircuitScheduler(sensorJob);
81         logger.debug("Add SceneReadingJob from device with dSID {} and low-priority to SceneReadingJobExecutor",
82                 sensorJob.getDSID());
83     }
84 }