package art.servers.pvvserver.controller;
|
|
import art.library.interop.InteropParameter;
|
import art.library.interop.InteropParameters;
|
import art.library.interop.InteropResponse;
|
import art.library.interop.serialization.Serialization;
|
import art.library.interop.serialization.SerializationException;
|
import art.library.model.devices.DeviceAction;
|
import art.library.model.devices.DeviceActionResult;
|
import art.library.model.devices.DeviceCommands;
|
import art.library.model.devices.vms.pvv.Pvv;
|
import art.library.model.devices.vms.pvv.PvvCommands;
|
import art.library.model.devices.vms.pvv.PvvConfiguration;
|
import art.library.model.devices.vms.pvv.PvvInformation;
|
import art.library.model.devices.vms.pvv.PvvStatus;
|
import art.library.model.devices.vms.pvv.commands.PvvCommandsConfiguration;
|
import art.library.model.devices.vms.pvv.commands.PvvCommandsMessage;
|
import art.library.model.devices.vms.pvv.commands.PvvCommandsMessageBlinkings;
|
import art.library.model.devices.vms.pvv.commands.PvvCommandsMessageVisibilities;
|
import art.library.model.devices.vms.pvv.information.PvvInformationConfigurationAddressSpeed;
|
import art.library.utils.common.NumberUtils;
|
import art.library.utils.synchro.Mutex;
|
import art.servers.ServerException;
|
import art.servers.Shared;
|
import art.servers.PvvServer;
|
import art.servers.pvvserver.protocols.dgt.PvvDgtConstants;
|
import art.servers.pvvserver.protocols.dgt.PvvDgtProtocolAnalyser;
|
import java.util.Arrays;
|
import java.util.List;
|
import art.servers.pvvserver.protocols.dgt.PvvDgtProtocolConstructor;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
|
public class ControllerPvvVirtual extends ControllerPvv
|
{
|
|
private String name = null;
|
private boolean firstTime = true;
|
private Mutex mutex = new Mutex();
|
|
public ControllerPvvVirtual(Pvv pvv)
|
{
|
super(pvv);
|
this.device = pvv;
|
this.name = Shared.getMessage("Controller pvv virtual") + " " + pvv.toString();
|
|
this.setName(name);
|
if (device.getDeviceStatus() == null)
|
{
|
device.status = new PvvStatus();
|
}
|
}
|
|
public void run()
|
{
|
Shared.traceInformation(name, "Starting");
|
|
while ((isInterrupted() == false) && (exit == false))
|
{
|
long startTimestamp = System.currentTimeMillis();
|
|
try
|
{
|
if (art.servers.Shared.isServerEnabled() == true)
|
{
|
update();
|
}
|
} catch (Exception e)
|
{
|
//Shared.printstack("run ControllerPvvVirtual", e);
|
}
|
|
long timetowait = (device.getDeviceInformation().polling * 1000) - (System.currentTimeMillis() - startTimestamp);
|
timetowait = Math.min(timetowait, (device.getDeviceInformation().polling * 1000));
|
|
if (timetowait > 0)
|
{
|
try
|
{
|
sleep(timetowait);
|
} catch (Exception e)
|
{
|
//Shared.printstack("run ControllerPvvVirtual", e);
|
}
|
} else
|
{
|
try
|
{
|
sleep(50);
|
} catch (Exception e)
|
{
|
//Shared.printstack("run ControllerPvvVirtual", e);
|
}
|
}
|
|
if (Shared.model.existsDevice(device.getIdentifier()) == false)
|
{
|
exit = true;
|
}
|
}
|
|
Shared.traceInformation(name, "Finishing");
|
}
|
|
// <editor-fold defaultstate="collapsed" desc="Update">
|
private void update() throws Exception
|
{
|
mutex.lockWrite();
|
Pvv pvvVirtualClone = (Pvv) Serialization.clone(device);
|
|
try
|
{
|
List<Pvv> lisPvv = getAllValidPvvsOfVirtual(pvvVirtualClone);
|
|
//All pvvs are offline -> Virtual pvv is offline
|
if (lisPvv.isEmpty())
|
{
|
offline(pvvVirtualClone);
|
return;
|
}
|
|
readAlarms(pvvVirtualClone, lisPvv);
|
readConfigurationAndStatus(pvvVirtualClone, lisPvv);
|
online(pvvVirtualClone);
|
} catch (Exception e)
|
{
|
//Shared.printstack("Exception ControllerPvvVirtual update", e);
|
offline(pvvVirtualClone);
|
} finally
|
{
|
mutex.releaseWrite();
|
}
|
}
|
|
//Get all pvvs with status valid from virtual
|
private List<Pvv> getAllValidPvvsOfVirtual(Pvv pvvVirtualClone) throws Exception
|
{
|
List<Pvv> lisPvv = new ArrayList<>();
|
PvvInformation information = pvvVirtualClone.getDeviceInformation();
|
|
if (information.pvvs != null)
|
{
|
for (String identifierVirtualDevice : information.pvvs)
|
{
|
Pvv pvvElem = (Pvv) Shared.model.getDeviceExternal(identifierVirtualDevice);
|
if (pvvElem != null && pvvElem.getDeviceStatus().isValid())
|
{
|
lisPvv.add(pvvElem);
|
}
|
}
|
}
|
|
return lisPvv;
|
}
|
|
//Get all pvvs numbers from virtual joined by character that has enough priority
|
private String getAllPvvsNumbersOfVirtual(List<Pvv> devices, int commandPriority, String joinChars) throws Exception
|
{
|
List<String> lisPvvNumbers = new ArrayList<>();
|
|
for (Pvv pvvElem : devices)
|
{
|
if ((pvvElem.getDeviceInformation().side == false)) // && (commandPriority >= pvvElem.getDeviceStatus().priority)
|
{
|
if ((commandPriority < 0) || (commandPriority >= pvvElem.getDeviceStatus().priority))
|
{
|
pvvElem.getDeviceStatus().priority = commandPriority;
|
pvvElem.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
lisPvvNumbers.add(pvvElem.getDeviceInformation().connectionEru.pvvNumber + "");
|
}
|
}
|
}
|
|
return lisPvvNumbers.isEmpty() ? "" : String.join(joinChars, lisPvvNumbers);
|
}
|
|
private void offline(Pvv pvvVirtualClone) throws Exception
|
{
|
if ((device.alarms.alarm_offline <= 0) || (firstTime == true))
|
{
|
firstTime = false;
|
String message = art.servers.Shared.getMessage("Pvv offline");
|
art.servers.Shared.println(name, message);
|
}
|
|
pvvVirtualClone.setAlarm("alarm_offline", System.currentTimeMillis());
|
Shared.model.updateDevice(device, pvvVirtualClone);
|
}
|
|
private void online(Pvv pvvVirtualClone) throws Exception
|
{
|
if ((device.alarms.alarm_offline > 0) || (firstTime == true))
|
{
|
firstTime = false;
|
String message = art.servers.Shared.getMessage("Pvv virtual online");
|
Shared.println(this.name, message);
|
}
|
|
pvvVirtualClone.setAlarm("alarm_offline", false);
|
pvvVirtualClone.setAlarm("alarm_invalid", false);
|
Shared.model.updateDevice(device, pvvVirtualClone);
|
}
|
|
//Add alarms of all contained pvvs to virtual
|
private void readAlarms(Pvv pvvVirtualClone, List<Pvv> lisPvv) throws Exception
|
{
|
try
|
{
|
HashMap<String, String> halarms = new HashMap<String, String>();
|
for (Pvv pvvElem : lisPvv)
|
{
|
for (String alarmName : pvvElem.getDeviceAlarms().getActiveAlarms())
|
{
|
pvvVirtualClone.setAlarm(alarmName, true);
|
halarms.putIfAbsent(alarmName, alarmName);
|
}
|
}
|
|
for (Pvv pvvElem : lisPvv)
|
{
|
for (String alarmName : pvvElem.getDeviceAlarms().getAlarmsFieldsNames())
|
{
|
if (halarms.containsKey(alarmName) == false)
|
{
|
pvvVirtualClone.setAlarm(alarmName, false);
|
}
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
//Shared.printstack("exception pvvVirtual on readAlarms ConnectionEru " + Serialization.toPrettyString(pvvVirtualClone.getDeviceInformation().connectionEru), e);
|
throw e;
|
}
|
}
|
|
private void readConfigurationAndStatus(Pvv pvvVirtualClone, List<Pvv> lisPvv) throws Exception
|
{
|
try
|
{
|
|
PvvStatus minPvvStatus = null;
|
PvvConfiguration minPvvConfiguration = null;
|
int priorityVirtual = pvvVirtualClone.getDeviceStatus().priority;
|
|
for (Pvv pvvElem : lisPvv)
|
{
|
if ((pvvElem.getDeviceStatus().state == PvvStatus.STATE_ON) &&
|
(minPvvStatus == null || pvvElem.getDeviceStatus().speed < minPvvStatus.speed) &&
|
(pvvElem.getDeviceInformation().side == false))
|
{
|
minPvvStatus = pvvElem.getDeviceStatus();
|
minPvvConfiguration = pvvElem.getDeviceConfiguration();
|
}
|
}
|
|
//If all are off -> Virtual is off with speed 0
|
if (minPvvStatus == null)
|
{
|
pvvVirtualClone.getDeviceStatus().state = PvvStatus.STATE_OFF;
|
pvvVirtualClone.getDeviceStatus().speed = 0;
|
//If there are Pvv On -> Virtual has the status of element with min speed
|
} else
|
{
|
pvvVirtualClone.status = Serialization.clone(minPvvStatus);
|
}
|
|
if (minPvvConfiguration == null)
|
{
|
pvvVirtualClone.configuration = new PvvConfiguration();
|
} else
|
{
|
pvvVirtualClone.configuration = Serialization.clone(minPvvConfiguration);
|
}
|
|
pvvVirtualClone.getDeviceStatus().priority = priorityVirtual;
|
|
} catch (Exception e)
|
{
|
if (this.device.getIdentifier().equalsIgnoreCase(PvvServer.devicelog) == true)
|
{
|
e.printStackTrace();
|
}
|
throw e;
|
}
|
}
|
// </editor-fold>
|
|
// <editor-fold defaultstate="collapsed" desc="Actions">
|
public DeviceAction[] sendCommands(InteropParameters parameters) throws ServerException, SerializationException, Exception
|
{
|
try
|
{
|
List<DeviceAction> result = new ArrayList<>();
|
PvvCommands pvvCommands = (PvvCommands) parameters.getBodyContentValue(PvvCommands.class);
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, Serialization.toPrettyString(pvvCommands));
|
}
|
|
Pvv clone = (Pvv) Serialization.clone(device);
|
List<Pvv> devicesClone = new ArrayList<>();
|
for (Pvv pvv : getAllValidPvvsOfVirtual(clone))
|
{
|
devicesClone.add((Pvv) Serialization.clone(pvv));
|
}
|
|
//Liberate
|
if (pvvCommands.liberate == DeviceCommands.CONDITION_YES)
|
{
|
PvvCommands command = new PvvCommands();
|
command.liberate = pvvCommands.liberate;
|
result.add(liberate(parameters, command, clone, devicesClone));
|
}
|
|
//Turn off
|
if (pvvCommands.turnOff == DeviceCommands.CONDITION_YES)
|
{
|
PvvCommands command = new PvvCommands();
|
command.priority = pvvCommands.priority;
|
command.turnOff = pvvCommands.turnOff;
|
result.add(turnOff(parameters, command, clone, devicesClone));
|
}
|
|
//Messages
|
if (pvvCommands.message != null)
|
{
|
PvvCommands commandMep = new PvvCommands();
|
commandMep.priority = pvvCommands.priority;
|
commandMep.configuration = new PvvCommandsConfiguration();
|
commandMep.message = new PvvCommandsMessage();
|
|
if (pvvCommands.message.timeout >= 0)
|
{
|
//Timeout
|
commandMep.message.timeout = pvvCommands.message.timeout;
|
}
|
|
commandMep.message.speed = pvvCommands.message.speed;
|
commandMep.message.synchroActivation = pvvCommands.message.synchroActivation;
|
|
//Blinkings
|
if (pvvCommands.message.blinkings == null)
|
{
|
pvvCommands.message.blinkings = new PvvCommandsMessageBlinkings();
|
|
if (this.device.getDeviceStatus() != null)
|
{
|
pvvCommands.message.blinkings.blinkingCircle = this.device.getDeviceStatus().blinkingCircle ? DeviceCommands.CONDITION_YES : DeviceCommands.CONDITION_NO;
|
pvvCommands.message.blinkings.blinkingFlashes = this.device.getDeviceStatus().blinkingFlashes ? DeviceCommands.CONDITION_YES : DeviceCommands.CONDITION_NO;
|
pvvCommands.message.blinkings.blinkingSpeed = this.device.getDeviceStatus().blinkingSpeed ? DeviceCommands.CONDITION_YES : DeviceCommands.CONDITION_NO;
|
}
|
|
}
|
|
commandMep.message.blinkings = new PvvCommandsMessageBlinkings();
|
|
if (pvvCommands.message.blinkings.blinkingCircle > -1)
|
{
|
commandMep.message.blinkings.blinkingCircle = pvvCommands.message.blinkings.blinkingCircle;
|
}
|
if (pvvCommands.message.blinkings.blinkingFlashes > -1)
|
{
|
commandMep.message.blinkings.blinkingFlashes = pvvCommands.message.blinkings.blinkingFlashes;
|
}
|
if (pvvCommands.message.blinkings.blinkingSpeed > -1)
|
{
|
commandMep.message.blinkings.blinkingSpeed = pvvCommands.message.blinkings.blinkingSpeed;
|
}
|
|
//Visibilities
|
if (pvvCommands.message.visibilities == null)
|
{
|
pvvCommands.message.visibilities = new PvvCommandsMessageVisibilities();
|
|
if (this.device.getDeviceStatus() != null)
|
{
|
pvvCommands.message.visibilities.visibilityCircle = this.device.getDeviceStatus().visibilityCircle;
|
pvvCommands.message.visibilities.visibilityFlashes = this.device.getDeviceStatus().visibilityFlashes;
|
pvvCommands.message.visibilities.visibilitySpeed = this.device.getDeviceStatus().visibilitySpeed;
|
}
|
}
|
|
//Visibility
|
commandMep.message.visibilities = new PvvCommandsMessageVisibilities();
|
|
commandMep.message.visibilities.visibilityCircle = pvvCommands.message.visibilities.visibilityCircle;
|
commandMep.message.visibilities.visibilityFlashes = pvvCommands.message.visibilities.visibilityFlashes;
|
commandMep.message.visibilities.visibilitySpeed = pvvCommands.message.visibilities.visibilitySpeed;
|
|
result.add(mep(parameters, commandMep, clone, devicesClone));
|
|
//Side devices
|
PvvCommands commandMepElem = (PvvCommands) Serialization.clone(commandMep);
|
commandMepElem.message.synchroActivation = DeviceCommands.CONDITION_NO;
|
for (Pvv pvvElem : devicesClone)
|
{
|
if (pvvElem.getDeviceInformation().side)
|
{
|
result.add(mep(parameters, commandMepElem, pvvElem, devicesClone));
|
}
|
}
|
}
|
|
if (pvvCommands.configuration != null)
|
{
|
PvvCommands commandMppConfiguration = new PvvCommands();
|
commandMppConfiguration.configuration = pvvCommands.configuration;
|
|
for (Pvv pvvElem : devicesClone)
|
{
|
PvvCommands commandMppConfigurationElem = (PvvCommands) Serialization.clone(commandMppConfiguration);
|
result.add(mpp(parameters, commandMppConfigurationElem, pvvElem));
|
}
|
|
}
|
|
mutex.lockWrite();
|
{
|
Shared.model.updateDevice(device, clone);
|
|
for (Pvv pvvCloneElem : devicesClone)
|
{
|
ControllerPvvDGTEru controller = (ControllerPvvDGTEru) Shared.getDeviceController(pvvCloneElem.getIdentifier());
|
controller.updateExternal(pvvCloneElem);
|
}
|
}
|
mutex.releaseWrite();
|
|
return result.toArray(new DeviceAction[result.size()]);
|
} catch (Exception exception)
|
{
|
//Shared.printstack("PvvVirtual error", exception);
|
return (art.servers.pvvserver.Shared.responseError(device, parameters, exception));
|
}
|
|
}
|
|
private DeviceAction mpp(InteropParameters parameters, PvvCommands command, Pvv deviceclone)
|
{
|
|
String language = (String) parameters.getParameterValue("language");
|
|
DeviceAction action = new DeviceAction(deviceclone, parameters, command);
|
action.actionName = command.getActionName();
|
|
try
|
{
|
Pvv currentPvv = (Pvv) Shared.model.getDevice(deviceclone.getIdentifier());
|
int currentPriority = currentPvv.getDeviceStatus().priority;
|
|
if ((command.priority >= 0) && (command.priority < currentPriority))
|
{
|
return generateInsufficientPriorityAction(action);
|
} else
|
{
|
|
PvvCommandsConfiguration pvvCommandsConfiguration = new PvvCommandsConfiguration();
|
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", "setPvvMpp"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", deviceclone.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", "" + deviceclone.getDeviceInformation().connectionEru.pvvNumber));
|
|
int brightness = -1; // Auto
|
if (deviceclone.getDeviceConfiguration().brightnessMode != PvvStatus.BRIGHTNESS_MODE_AUTO)
|
{
|
brightness = deviceclone.getDeviceStatus().brightnessLevel;
|
}
|
|
if (command.configuration.brightness != -2)
|
{
|
brightness = command.configuration.brightness;
|
pvvCommandsConfiguration.brightnessControl = command.configuration.brightnessControl;
|
|
}
|
|
int blinkon = (int) Math.round(deviceclone.getDeviceConfiguration().blinkOn * 1000);
|
|
if (command.configuration.blinkOn > -1)
|
{
|
blinkon = (int) Math.round(command.configuration.blinkOn * 1000);
|
}
|
|
int blinkoff = (int) Math.round(deviceclone.getDeviceConfiguration().blinkOff * 1000);
|
|
if (command.configuration.blinkOff > -1)
|
{
|
blinkoff = (int) Math.round(command.configuration.blinkOff * 1000);
|
}
|
|
if (blinkon <= 0)
|
{
|
blinkon = 500;
|
}
|
if (blinkoff <= 0)
|
{
|
blinkoff = 500;
|
}
|
|
if (brightness == -1)
|
{
|
brightness = 'A';
|
} else
|
{
|
brightness = PvvDgtProtocolConstructor.getBrightnessDGTLevel(brightness, deviceclone.getDeviceInformation().maximumBrightnessLevel);
|
}
|
|
pvvCommandsConfiguration.blinkOn = blinkon;
|
pvvCommandsConfiguration.blinkOff = blinkoff;
|
pvvCommandsConfiguration.brightness = brightness;
|
|
pvvCommandsConfiguration.flashPeriod = deviceclone.getDeviceConfiguration().flashPeriod;
|
if (command.configuration.flashPeriod > -1)
|
{
|
pvvCommandsConfiguration.flashPeriod = command.configuration.flashPeriod * 10;
|
}
|
|
pvvCommandsConfiguration.flashStopTime = deviceclone.getDeviceConfiguration().flashStopTime;
|
if (command.configuration.flashStopTime > -1)
|
{
|
pvvCommandsConfiguration.flashStopTime = command.configuration.flashStopTime * 10;
|
}
|
|
pvvCommandsConfiguration.flashesOnPercentage = deviceclone.getDeviceConfiguration().flashesOnPercentage;
|
if (command.configuration.flashesOnPercentage > -1)
|
{
|
pvvCommandsConfiguration.flashesOnPercentage = command.configuration.flashesOnPercentage;
|
}
|
|
pvvCommandsConfiguration.flashesxPeriod = deviceclone.getDeviceConfiguration().flashesxPeriod;
|
if (command.configuration.flashesxPeriod > -1)
|
{
|
pvvCommandsConfiguration.flashesxPeriod = command.configuration.flashesxPeriod;
|
}
|
|
parametersOrder.addBodycontent(pvvCommandsConfiguration);
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, currentPvv.getIdentifier() + " - Configuration Body: " + Serialization.toPrettyString(pvvCommandsConfiguration));
|
}
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder, deviceclone.getDeviceInformation().connectionEru.address, deviceclone.getDeviceInformation().connectionEru.port, deviceclone.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
int numberOfPvvs = lbytes.get(0);
|
int pvvNumber = lbytes.get(1);
|
|
if (pvvNumber == deviceclone.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvv
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponsePPDgtEru(deviceclone, information);
|
}
|
|
deviceclone.getDeviceStatus().priority = command.priority;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
} catch (Exception exception)
|
{
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
private DeviceAction mpp2(InteropParameters parameters, PvvCommands command, Pvv deviceclone)
|
{
|
|
String language = (String) parameters.getParameterValue("language");
|
|
DeviceAction action = new DeviceAction(deviceclone, parameters, command);
|
action.actionName = command.getActionName();
|
|
try
|
{
|
Pvv currentPvv = (Pvv) Shared.model.getDevice(deviceclone.getIdentifier());
|
int currentPriority = currentPvv.getDeviceStatus().priority;
|
|
if ((command.priority >= 0) && (command.priority < currentPriority))
|
{
|
return generateInsufficientPriorityAction(action);
|
} else
|
{
|
|
PvvCommandsConfiguration pvvCommandsConfiguration = new PvvCommandsConfiguration();
|
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", "setPvvMpp"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", deviceclone.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", "" + deviceclone.getDeviceInformation().connectionEru.pvvNumber));
|
|
int brightness = -1; // Auto
|
if (deviceclone.getDeviceConfiguration().brightnessMode != PvvStatus.BRIGHTNESS_MODE_AUTO)
|
{
|
brightness = deviceclone.getDeviceStatus().brightnessLevel;
|
}
|
|
if (command.configuration.brightness != -2)
|
{
|
brightness = command.configuration.brightness;
|
pvvCommandsConfiguration.brightnessControl = command.configuration.brightnessControl;
|
|
}
|
|
int blinkon = (int) Math.round(deviceclone.getDeviceConfiguration().blinkOn * 1000);
|
|
if (command.configuration.blinkOn > -1)
|
{
|
blinkon = (int) Math.round(command.configuration.blinkOn * 1000);
|
}
|
|
int blinkoff = (int) Math.round(deviceclone.getDeviceConfiguration().blinkOff * 1000);
|
|
if (command.configuration.blinkOff > -1)
|
{
|
blinkoff = (int) Math.round(command.configuration.blinkOff * 1000);
|
}
|
|
if (blinkon == 0)
|
{
|
blinkon = 500;
|
}
|
if (blinkoff == 0)
|
{
|
blinkoff = 500;
|
}
|
|
if (brightness == -1)
|
{
|
brightness = 'A';
|
} else
|
{
|
brightness = PvvDgtProtocolConstructor.getBrightnessDGTLevel(brightness, deviceclone.getDeviceInformation().maximumBrightnessLevel);
|
}
|
|
pvvCommandsConfiguration.blinkOn = blinkon;
|
pvvCommandsConfiguration.blinkOff = blinkoff;
|
pvvCommandsConfiguration.brightness = brightness;
|
|
pvvCommandsConfiguration.flashPeriod = deviceclone.getDeviceConfiguration().flashPeriod;
|
if (command.configuration.flashPeriod > -1)
|
{
|
pvvCommandsConfiguration.flashPeriod = command.configuration.flashPeriod * 10;
|
}
|
|
pvvCommandsConfiguration.flashStopTime = deviceclone.getDeviceConfiguration().flashStopTime;
|
if (command.configuration.flashStopTime > -1)
|
{
|
pvvCommandsConfiguration.flashStopTime = command.configuration.flashStopTime * 10;
|
}
|
|
pvvCommandsConfiguration.flashesOnPercentage = deviceclone.getDeviceConfiguration().flashesOnPercentage;
|
if (command.configuration.flashesOnPercentage > -1)
|
{
|
pvvCommandsConfiguration.flashesOnPercentage = command.configuration.flashesOnPercentage;
|
}
|
|
pvvCommandsConfiguration.flashesxPeriod = deviceclone.getDeviceConfiguration().flashesxPeriod;
|
if (command.configuration.flashesxPeriod > -1)
|
{
|
pvvCommandsConfiguration.flashesxPeriod = command.configuration.flashesxPeriod;
|
}
|
|
parametersOrder.addBodycontent(pvvCommandsConfiguration);
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, "Configuration Body: " + Serialization.toPrettyString(pvvCommandsConfiguration));
|
}
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder, deviceclone.getDeviceInformation().connectionEru.address, deviceclone.getDeviceInformation().connectionEru.port, deviceclone.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
int numberOfPvvs = lbytes.get(0);
|
int pvvNumber = lbytes.get(1);
|
|
if (pvvNumber == deviceclone.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvv
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponsePPDgtEru(deviceclone, information);
|
}
|
|
deviceclone.getDeviceStatus().priority = command.priority;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
} catch (Exception exception)
|
{
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
private DeviceAction liberate(InteropParameters parameters, PvvCommands command, Pvv deviceclone, List<Pvv> devicesClone)
|
{
|
String language = (String) parameters.getParameterValue("language");
|
DeviceAction action = new DeviceAction(device, parameters, command);
|
action.actionName = command.getActionName();
|
|
try
|
{
|
//Liberate device
|
deviceclone.getDeviceStatus().priority = -1;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
|
boolean isVirtual = deviceclone.getDeviceInformation().pvvs != null;
|
|
//If virtual, liberate its physical devices, too
|
if (isVirtual)
|
{
|
for (Pvv pvvElem : devicesClone)
|
{
|
pvvElem.getDeviceStatus().priority = -1;
|
pvvElem.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
}
|
}
|
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
} catch (Exception exception)
|
{
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
|
private DeviceAction turnOff(InteropParameters parameters, PvvCommands command, Pvv deviceclone, List<Pvv> devicesClone)
|
{
|
boolean isVirtual = deviceclone.getDeviceInformation().pvvs != null;
|
String language = (String) parameters.getParameterValue("language");
|
String username = (String) parameters.getParameterValue("username");
|
DeviceAction action = new DeviceAction(deviceclone, parameters, command);
|
|
action.actionName = command.getActionName();
|
|
try
|
{
|
Pvv currentPvv = (Pvv) Shared.model.getDevice(deviceclone.getIdentifier());
|
int currentPriority = currentPvv.getDeviceStatus().priority;
|
|
if ((command.priority >= 0) && (command.priority < currentPriority))
|
{
|
return generateInsufficientPriorityAction(action);
|
}
|
else
|
{
|
if (isVirtual == true)
|
{
|
for (Pvv pvvElem : devicesClone)
|
{
|
try
|
{
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", "setPvvMep"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", pvvElem.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", "" + pvvElem.getDeviceInformation().connectionEru.pvvNumber));
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, pvvElem.getIdentifier() + " - " + Serialization.toPrettyString(parametersOrder));
|
}
|
|
byte[] message = getBodyContentMessage(command, pvvElem);
|
String s = "> ";
|
for (int i=0; i<message.length; i++)
|
{
|
s += String.format("%02X ", message[i]);
|
}
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, s);
|
}
|
|
parametersOrder.addBodycontent(message);
|
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder,
|
pvvElem.getDeviceInformation().connectionEru.address,
|
pvvElem.getDeviceInformation().connectionEru.port,
|
pvvElem.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
s = "< ";
|
for (int i=0; i<lbytes.size(); i++)
|
{
|
s += String.format("%02X ", lbytes.get(i));
|
}
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, s);
|
}
|
|
int pvvNumber = lbytes.get(1);
|
if (pvvNumber == pvvElem.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvvs
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponseEP(pvvElem, deviceclone, information);
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, pvvElem.getIdentifier() + " - Analyzed");
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
Shared.printstack(name, e);
|
}
|
}
|
}
|
|
deviceclone.getDeviceStatus().priority = command.priority;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, "TurnOff Ok");
|
}
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
} catch (Exception exception)
|
{
|
//Shared.printstack("PVVVirtual mep", exception);
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
|
private DeviceAction mep(InteropParameters parameters, PvvCommands command, Pvv deviceclone, List<Pvv> devicesClone)
|
{
|
boolean isVirtual = deviceclone.getDeviceInformation().pvvs != null;
|
String language = (String) parameters.getParameterValue("language");
|
String username = (String) parameters.getParameterValue("username");
|
DeviceAction action = new DeviceAction(deviceclone, parameters, command);
|
|
action.actionName = command.getActionName();
|
|
try
|
{
|
Pvv currentPvv = (Pvv) Shared.model.getDevice(deviceclone.getIdentifier());
|
int currentPriority = currentPvv.getDeviceStatus().priority;
|
|
if ((command.priority >= 0) && (command.priority < currentPriority))
|
{
|
return generateInsufficientPriorityAction(action);
|
} else
|
{
|
String pvvIdentifier = isVirtual ? getAllPvvsNumbersOfVirtual(devicesClone, command.priority, ",") : "" + currentPvv.getDeviceInformation().connectionEru.pvvNumber;
|
|
if (isVirtual && pvvIdentifier.isEmpty())
|
{
|
return generateInsufficientPriorityAction(action);
|
}
|
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", isVirtual ? "setPvvMepm" : "setPvvMep"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", currentPvv.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", pvvIdentifier));
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, currentPvv.getIdentifier() + " - " + command.message.speed + " - " + Serialization.toPrettyString(parametersOrder));
|
}
|
|
byte[] message = getBodyContentMessage(command, currentPvv);
|
String s = "> ";
|
for (int i=0; i<message.length; i++)
|
{
|
s += String.format("%02X ", message[i]);
|
}
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, s);
|
}
|
|
parametersOrder.addBodycontent(message);
|
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder, currentPvv.getDeviceInformation().connectionEru.address, currentPvv.getDeviceInformation().connectionEru.port, currentPvv.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
s = "< ";
|
for (int i=0; i<lbytes.size(); i++)
|
{
|
s += String.format("%02X ", lbytes.get(i));
|
}
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, s);
|
}
|
|
if (!isVirtual)
|
{
|
int pvvNumber = lbytes.get(1);
|
if (pvvNumber == currentPvv.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvvs
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponseEP(currentPvv, deviceclone, information);
|
}
|
}
|
|
deviceclone.getDeviceStatus().priority = command.priority;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
|
//If has sincro activation, send OPVV_SINCRO
|
if (command.message != null && command.message.synchroActivation == DeviceCommands.CONDITION_YES)
|
{
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, "Send Synchro");
|
}
|
InteropParameters parametersSynchro = new InteropParameters();
|
parametersSynchro.addParameter(new InteropParameter("operation", "setPvvSincro"));
|
parametersSynchro.addParameter(new InteropParameter("language", language));
|
parametersSynchro.addParameter(new InteropParameter("device", deviceclone.getDeviceInformation().connectionEru.eru));
|
parametersSynchro.addParameter(new InteropParameter("pvv", "" + (isVirtual ? devicesClone.get(0).getDeviceInformation().number : deviceclone.getDeviceInformation().connectionEru.pvvNumber)));
|
parametersSynchro.addParameter(new InteropParameter("sincro", "1"));
|
Serialization.invoke("set", parametersSynchro, deviceclone.getDeviceInformation().connectionEru.address, deviceclone.getDeviceInformation().connectionEru.port, deviceclone.getDeviceInformation().connectionEru.timeout);
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, "Sent Synchro");
|
}
|
}
|
|
if (this.device.getIdentifier().indexOf("08-PVV-ED") == 0)
|
{
|
Shared.println(name, "MEP Ok");
|
}
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
} catch (Exception exception)
|
{
|
//Shared.printstack("PVVVirtual mep", exception);
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
|
private DeviceAction mep2(InteropParameters parameters, PvvCommands command, Pvv deviceclone, List<Pvv> devicesClone)
|
{
|
boolean isVirtual = deviceclone.getDeviceInformation().pvvs != null;
|
String language = (String) parameters.getParameterValue("language");
|
String username = (String) parameters.getParameterValue("username");
|
DeviceAction action = new DeviceAction(deviceclone, parameters, command);
|
|
action.actionName = command.getActionName();
|
|
try
|
{
|
Pvv currentPvv = (Pvv) Shared.model.getDevice(deviceclone.getIdentifier());
|
int currentPriority = currentPvv.getDeviceStatus().priority;
|
|
if ((command.priority >= 0) && (command.priority < currentPriority))
|
{
|
return generateInsufficientPriorityAction(action);
|
} else
|
{
|
String pvvIdentifier = isVirtual ? getAllPvvsNumbersOfVirtual(devicesClone, command.priority, ",") : "" + currentPvv.getDeviceInformation().connectionEru.pvvNumber;
|
|
if (isVirtual && pvvIdentifier.isEmpty())
|
{
|
return generateInsufficientPriorityAction(action);
|
}
|
|
if (isVirtual == true)
|
{
|
for (Pvv pvvElem : devicesClone)
|
{
|
try
|
{
|
if (pvvElem.getDeviceInformation().side == true)
|
{
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", "setPvvMep"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", pvvElem.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", "" + pvvElem.getDeviceInformation().connectionEru.pvvNumber));
|
|
Shared.println(name, pvvElem.getIdentifier() + " - " + command.message.speed + " - " + Serialization.toPrettyString(parametersOrder));
|
|
byte[] message = getBodyContentMessage(command, pvvElem);
|
String s = "> ";
|
for (int i=0; i<message.length; i++)
|
{
|
s += String.format("%02X ", message[i]);
|
}
|
Shared.println(name, s);
|
|
parametersOrder.addBodycontent(message);
|
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder,
|
pvvElem.getDeviceInformation().connectionEru.address,
|
pvvElem.getDeviceInformation().connectionEru.port,
|
pvvElem.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
s = "< ";
|
for (int i=0; i<lbytes.size(); i++)
|
{
|
s += String.format("%02X ", lbytes.get(i));
|
}
|
Shared.println(name, s);
|
|
int pvvNumber = lbytes.get(1);
|
if (pvvNumber == pvvElem.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvvs
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponseEP(pvvElem, deviceclone, information);
|
Shared.println(name, pvvElem.getIdentifier() + " - " + command.message.speed + " - Analyzed");
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
Shared.printstack(name, e);
|
}
|
}
|
}
|
|
InteropParameters parametersOrder = new InteropParameters();
|
parametersOrder.addParameter(new InteropParameter("operation", isVirtual ? "setPvvMepm" : "setPvvMep"));
|
parametersOrder.addParameter(new InteropParameter("language", language));
|
parametersOrder.addParameter(new InteropParameter("device", currentPvv.getDeviceInformation().connectionEru.eru));
|
parametersOrder.addParameter(new InteropParameter("pvv", pvvIdentifier));
|
|
Shared.println(name, currentPvv.getIdentifier() + " - " + Serialization.toPrettyString(parametersOrder));
|
|
byte[] message = getBodyContentMessage(command, currentPvv);
|
parametersOrder.addBodycontent(message);
|
|
InteropResponse response = (InteropResponse) Serialization.invoke("set", parametersOrder, currentPvv.getDeviceInformation().connectionEru.address, currentPvv.getDeviceInformation().connectionEru.port, currentPvv.getDeviceInformation().connectionEru.timeout);
|
|
Object[] lobject = Arrays.copyOf(response.getValue(), response.getValue().length, Object[].class);
|
List<Integer> lbytes = new ArrayList<>();
|
for (Object o : lobject)
|
{
|
lbytes.add((Integer) o);
|
}
|
|
if (!isVirtual)
|
{
|
int pvvNumber = lbytes.get(1);
|
if (pvvNumber == currentPvv.getDeviceInformation().connectionEru.pvvNumber)
|
{
|
// Message received corresponds to pvvs
|
int[] information = new int[lbytes.size() - 2];
|
for (int i = 2; i < lbytes.size(); i++)
|
{
|
information[i - 2] = lbytes.get(i);
|
}
|
|
PvvDgtProtocolAnalyser.analyseResponseEP(currentPvv, deviceclone, information);
|
}
|
}
|
|
deviceclone.getDeviceStatus().priority = command.priority;
|
deviceclone.getDeviceStatus().timestampOrder = System.currentTimeMillis();
|
|
//If has sincro activation, send OPVV_SINCRO
|
if (command.message != null && command.message.synchroActivation == DeviceCommands.CONDITION_YES)
|
{
|
Shared.println(name, "Send Synchro");
|
InteropParameters parametersSynchro = new InteropParameters();
|
parametersSynchro.addParameter(new InteropParameter("operation", "setPvvSincro"));
|
parametersSynchro.addParameter(new InteropParameter("language", language));
|
parametersSynchro.addParameter(new InteropParameter("device", deviceclone.getDeviceInformation().connectionEru.eru));
|
parametersSynchro.addParameter(new InteropParameter("pvv", "" + (isVirtual ? devicesClone.get(0).getDeviceInformation().number : deviceclone.getDeviceInformation().connectionEru.pvvNumber)));
|
parametersSynchro.addParameter(new InteropParameter("sincro", "1"));
|
Serialization.invoke("set", parametersSynchro, deviceclone.getDeviceInformation().connectionEru.address, deviceclone.getDeviceInformation().connectionEru.port, deviceclone.getDeviceInformation().connectionEru.timeout);
|
Shared.println(name, "Sent Synchro");
|
}
|
|
Shared.println(name, "MEP2 OK");
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_CORRECT);
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
} catch (Exception exception)
|
{
|
//Shared.printstack("PVVVirtual mep", exception);
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
}
|
|
|
private byte[] getBodyContentMessage(PvvCommands command, Pvv currentPvv) throws Exception
|
{
|
try
|
{
|
if (command.turnOff == PvvCommands.CONDITION_YES || command.message.speed == 0)
|
{
|
return new byte[]
|
{
|
PvvDgtConstants.PVV_OFF
|
};
|
}
|
List<Byte> lresult = new ArrayList<>();
|
lresult.add((byte) PvvDgtConstants.PVV_FIX);
|
lresult.add((byte) PvvDgtConstants.PVV_TOPOLOGY_5);
|
lresult.add((byte) NumberUtils.IntToAscii(1));
|
|
List<Byte> lgraphicA = new ArrayList<>();
|
PvvInformationConfigurationAddressSpeed addressSpeed = currentPvv.getDeviceInformation().configuration.getBySpeed(command.message.speed);
|
if (addressSpeed == null)
|
{
|
throw new Exception(String.format("Error: Speed '%s' not found", command.message.speed));
|
}
|
|
// Subpanel 1
|
/*
|
|
Parámetros para el tipo de contenido = Memoria (31h)
|
Número de Memoria 1 Byte hexadecimal
|
Intermitencia 1 Byte ‘S’ o ‘N’.
|
(los tiempos de intermitencia son los definidos en la trama de configuración 11h)
|
|
Parámetros para el tipo de contenido = Memoria Extendido (34h)
|
Número de Memoria 1 Byte hexadecimal
|
Activar al recibir sincro 1 Byte ‘S’ o ‘N’.
|
Intermitencia Velocidad 1 Byte ‘S’ o ‘N’.
|
Intermitencia Orla 1 Byte ‘S’ o ‘N’.
|
Intermitencia Flashes 1 Byte ‘S’ o ‘N’.
|
Visibilidad Velocidad 1 Byte ‘S’ o ‘N’.
|
Visibilidad Orla 1 Byte ‘S’ o ‘N’.
|
Visibilidad Flashes 1 Byte ‘S’ o ‘N’.
|
*/
|
|
lgraphicA.add((byte) 0x31);
|
lgraphicA.add((byte) 0x34);
|
lgraphicA.add((byte) addressSpeed.address);
|
|
if (command.message.synchroActivation == DeviceCommands.CONDITION_YES)
|
{
|
lgraphicA.add((byte)'S');
|
}
|
else
|
{
|
lgraphicA.add((byte)'N');
|
}
|
lgraphicA.add((byte) (command.message.blinkings.blinkingSpeed == DeviceCommands.CONDITION_YES ? 'S' : 'N'));
|
lgraphicA.add((byte) (command.message.blinkings.blinkingCircle == DeviceCommands.CONDITION_YES ? 'S' : 'N'));
|
lgraphicA.add((byte) (command.message.blinkings.blinkingFlashes == DeviceCommands.CONDITION_YES ? 'S' : 'N'));
|
lgraphicA.add((byte) (command.message.visibilities.visibilitySpeed ? 'S' : 'N'));
|
lgraphicA.add((byte) (command.message.visibilities.visibilityCircle ? 'S' : 'N'));
|
lgraphicA.add((byte) (command.message.visibilities.visibilityFlashes ? 'S' : 'N'));
|
|
lresult.addAll(lgraphicA);
|
|
byte[] aux = new byte[lresult.size()];
|
for (int i = 0; i < aux.length; i++)
|
{
|
aux[i] = lresult.get(i);
|
}
|
|
return (aux);
|
} catch (Exception exception)
|
{
|
exception.printStackTrace();
|
throw exception;
|
}
|
}
|
|
private DeviceAction generateInsufficientPriorityAction(DeviceAction action)
|
{
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage("Insufficient priority"));
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
// </editor-fold>
|
}
|