]> git.basschouten.com Git - openhab-addons.git/blob
db2d73d501b994bd7b55a90fc2ed600353f95ae1
[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.dmxoverethernet;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * The {@link DmxOverEthernetPacket} is an abstract class for
19  * DMX over Ethernet packets (ArtNet, sACN)
20  *
21  * @author Jan N. Klug - Initial contribution
22  */
23 @NonNullByDefault
24 public abstract class DmxOverEthernetPacket {
25     protected int universeId;
26     protected int payloadSize;
27     protected byte[] rawPacket = new byte[0];
28
29     /**
30      * set payload size
31      *
32      * @param payloadSize payload size (number of DMX channels in this packet)
33      */
34     public abstract void setPayloadSize(int payloadSize);
35
36     /**
37      * sets universe, calculates sender name and broadcast-address
38      *
39      * @param universeId
40      */
41     public abstract void setUniverse(int universeId);
42
43     /**
44      * set sequence number
45      *
46      * @param sequenceNo sequence number (0-255)
47      */
48     public abstract void setSequence(int sequenceNo);
49
50     /**
51      * set DMX payload data
52      *
53      * @param payload byte array containing DMX channel data
54      */
55     public abstract void setPayload(byte[] payload);
56
57     /**
58      * set payload data
59      *
60      * @param payload byte array containing DMX channel data
61      * @param payloadSize length of data (no. of channels)
62      */
63     public abstract void setPayload(byte[] payload, int payloadSize);
64
65     /**
66      * get packet for transmission
67      *
68      * @return byte array with raw packet data
69      */
70     public byte[] getRawPacket() {
71         return rawPacket;
72     }
73
74     /**
75      * get packet length
76      *
77      * @return full packet length
78      */
79     public abstract int getPacketLength();
80
81     /**
82      * get universe of this packet
83      *
84      * @return universe number
85      *
86      */
87     public int getUniverse() {
88         return this.universeId;
89     }
90
91     /**
92      * get payload size
93      *
94      * @return number of DMX channels in this packet
95      */
96     public int getPayloadSize() {
97         return this.payloadSize;
98     }
99 }