]> git.basschouten.com Git - openhab-addons.git/blob
52d5b98fda92981d4a186b6adda6edb34785e09f
[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.dmx.internal.action;
14
15 import org.openhab.binding.dmx.internal.multiverse.DmxChannel;
16
17 /**
18  * The {@link BaseAction} is the base class for Actions like faders, chasers, etc..
19  *
20  * @author Davy Vanherbergen - Initial contribution
21  * @author Jan N. Klug - Refactoring for ESH
22  */
23 public abstract class BaseAction {
24
25     protected ActionState state = ActionState.WAITING;
26     protected long startTime = 0;
27
28     /**
29      * Calculate the new output value of the channel.
30      *
31      * @param channel
32      * @param currentTime UNIX timestamp to use as current time
33      * @return value as float between 0 - 65535
34      */
35     public abstract int getNewValue(DmxChannel channel, long currentTime);
36
37     /**
38      * @return the action's state
39      */
40     public final ActionState getState() {
41         return state;
42     }
43
44     /**
45      * Reset the action to start from the beginning.
46      */
47     public void reset() {
48         startTime = 0;
49         state = ActionState.WAITING;
50     }
51 }