2012-03-02 21:09:43 +00:00
|
|
|
package de.ctdo.bunti.dmx;
|
|
|
|
|
|
|
|
public class DMX {
|
|
|
|
|
2012-03-04 00:21:00 +00:00
|
|
|
public static final int DMX_CHANNELS_MAX = (byte) 511;
|
|
|
|
public static final int DMX_CHANNELS_MIN = 0;
|
|
|
|
public static final int DMX_CHANNEL_VALUE_MAX = (byte) 255;
|
|
|
|
public static final int DMX_CHANNEL_VALUE_MIN = 0;
|
2012-03-02 21:09:43 +00:00
|
|
|
|
2012-03-03 12:00:53 +00:00
|
|
|
/**
|
|
|
|
* Offset by which startaddress differs from DMX512 Data Array location
|
|
|
|
*/
|
2012-03-04 00:21:00 +00:00
|
|
|
public static final int DMX_STARTADDRESS_OFFSET = -1;
|
|
|
|
|
|
|
|
|
|
|
|
private DMX(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-03 12:00:53 +00:00
|
|
|
/**
|
|
|
|
* Checks the DMX Value boundaries
|
|
|
|
* @param value
|
|
|
|
* @return A valid DMX512 channel value
|
|
|
|
*/
|
2012-03-02 21:09:43 +00:00
|
|
|
public static int sanitizeDMXValue(int value) {
|
|
|
|
if(value < DMX_CHANNEL_VALUE_MIN) value = DMX_CHANNEL_VALUE_MIN;
|
|
|
|
if(value > DMX_CHANNEL_VALUE_MAX) value = DMX_CHANNEL_VALUE_MAX;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-03 12:00:53 +00:00
|
|
|
/**
|
|
|
|
* Checks the DMX Channel boundaries
|
|
|
|
* @param channel The channel to check
|
|
|
|
* @return True if channel is valid. Otherwise false.
|
|
|
|
*/
|
2012-03-02 21:09:43 +00:00
|
|
|
public static boolean checkChannelBoundaries(int channel) {
|
|
|
|
return (channel >= DMX_CHANNELS_MIN && channel <= DMX_CHANNELS_MAX);
|
|
|
|
}
|
|
|
|
|
2012-03-03 01:29:06 +00:00
|
|
|
|
|
|
|
|
2012-03-02 21:09:43 +00:00
|
|
|
}
|