package art.servers.pvvserver.protocols.dgt;
|
|
import art.library.model.devices.vms.general.VmsGeneral;
|
|
public class PvvDgtProtocolConstructor
|
{
|
|
public PvvDgtProtocolConstructor()
|
{
|
}
|
|
public static byte[] ORDCC(VmsGeneral device) throws Exception
|
{
|
return new byte[0];
|
}
|
|
/**
|
* PVV status query.
|
*/
|
public static byte[] readAlarms(int address) throws Exception
|
{
|
|
PvvDgtPDU requestAlarms = new PvvDgtPDU();
|
requestAlarms.stx = PvvDgtConstants.PVV_STX;
|
requestAlarms.etx = PvvDgtConstants.PVV_ETX;
|
requestAlarms.address = address;
|
requestAlarms.function = PvvDgtConstants.STR_PPVV_ALR;
|
requestAlarms.information = new int[0];
|
byte[] send = requestAlarms.createMessage();
|
return (send);
|
}
|
|
/**
|
* PVV configuration query.
|
*/
|
public static byte[] readConfiguration(int address) throws Exception
|
{
|
|
PvvDgtPDU requestConfiguration = new PvvDgtPDU();
|
requestConfiguration.stx = PvvDgtConstants.PVV_STX;
|
requestConfiguration.etx = PvvDgtConstants.PVV_ETX;
|
requestConfiguration.address = address;
|
requestConfiguration.function = PvvDgtConstants.STR_PPVV_PP;
|
requestConfiguration.information = new int[0];
|
byte[] send = requestConfiguration.createMessage();
|
return (send);
|
}
|
|
/**
|
* PVV message query.
|
*/
|
public static byte[] readMessage(int address) throws Exception
|
{
|
|
PvvDgtPDU requestConfiguration = new PvvDgtPDU();
|
requestConfiguration.stx = PvvDgtConstants.PVV_STX;
|
requestConfiguration.etx = PvvDgtConstants.PVV_ETX;
|
requestConfiguration.address = address;
|
requestConfiguration.function = PvvDgtConstants.STR_PPVV_EP;
|
requestConfiguration.information = new int[0];
|
byte[] send = requestConfiguration.createMessage();
|
return (send);
|
}
|
|
public static int getBrightnessDGTLevel(int input, int maximum)
|
{
|
// Input is a 0-100 value
|
if (input > 100)
|
{
|
input = 100;
|
}
|
|
if (input < 0)
|
{
|
input = 0;
|
}
|
return ((int) Math.round(((float) input * (float) maximum) / 100f));
|
}
|
|
public static int getBrightnessClientLevel(int input, int maximum, int maximumVms)
|
{
|
// Input is a 0-7 value
|
int result = (int) Math.round(((float) input * (float) maximum) / (float) maximumVms);
|
if (result > 100)
|
{
|
result = 100;
|
}
|
return (result);
|
}
|
}
|