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