package art.servers.rtzserver.controller;
|
|
import art.library.interop.InteropParameters;
|
import art.library.model.devices.DeviceAction;
|
import art.library.model.devices.DeviceActionResult;
|
import art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerCommands;
|
import art.library.model.devices.colors.controller.RTZ32.commands.RTZ32_Commands_Forcings;
|
import art.library.model.devices.colors.controller.RTZ32.commands.RTZ32_Commands_Online;
|
import art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_Centralized;
|
import art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_Forcings;
|
import art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_Pendings;
|
import art.servers.Shared;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
|
public class Controller_RTZ32_Actions
|
{
|
|
public static DeviceAction[] sendCommands(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_ControllerCommands commands)
|
{
|
// Initialization
|
|
if (controller.talker.rtz32.getDeviceStatus().rtz32.forcings == null) controller.talker.rtz32.getDeviceStatus().rtz32.forcings = new RTZ32_Status_Forcings();
|
if (controller.talker.rtz32.getDeviceStatus().rtz32.pendings == null) controller.talker.rtz32.getDeviceStatus().rtz32.pendings = new RTZ32_Status_Pendings();
|
|
// Execute orders
|
|
List<DeviceAction> result = new ArrayList<DeviceAction>();
|
|
if (commands.forcings != null)
|
{
|
result.addAll(forcings(controller, parameters, commands.forcings));
|
}
|
|
if (commands.online != null)
|
{
|
result.addAll(online(controller, parameters, commands.online));
|
}
|
|
controller.forceUpdate();
|
return result.toArray(new DeviceAction[result.size()]);
|
}
|
|
|
|
|
|
public static List<DeviceAction> forcings(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings commands)
|
{
|
List<DeviceAction> result = new ArrayList<DeviceAction>();
|
|
RTZ32_Status_Forcings forcings = controller.talker.rtz32.getDeviceStatus().rtz32.forcings;
|
RTZ32_Status_Pendings pendings = controller.talker.rtz32.getDeviceStatus().rtz32.pendings;
|
|
try
|
{
|
|
// Liberation
|
|
if (forcings != null)
|
{
|
if ((commands.liberate_control != null) && (commands.liberate_control == true))
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.liberate_control = commands.liberate_control;
|
result.add(liberateControl(controller, parameters, command, forcings));
|
}
|
|
if ((commands.liberate_computer_mode != null) && (commands.liberate_computer_mode == true))
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.liberate_computer_mode = commands.liberate_computer_mode;
|
result.add(liberateComputerMode(controller, parameters, command, forcings));
|
}
|
|
if ((commands.liberate_centralized != null) && (commands.liberate_centralized == true))
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.liberate_centralized = commands.liberate_centralized;
|
result.add(liberateCentralized(controller, parameters, command, forcings));
|
}
|
|
if ((commands.liberate_colors != null) && (commands.liberate_colors == true))
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.liberate_colors = commands.liberate_colors;
|
result.add(liberateColorsMode(controller, parameters, command, forcings));
|
}
|
if ((commands.liberate_plan != null) && (commands.liberate_plan == true))
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.liberate_plan = commands.liberate_plan;
|
result.add(liberatePlan(controller, parameters, command, forcings));
|
}
|
}
|
|
// Forcings
|
|
if (commands.control != null)
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.control = commands.control;
|
DeviceAction action = control(controller, parameters, command, forcings, pendings);
|
if (action.resultCode == DeviceActionResult.RESULT_CORRECT) forcings.control = command.control;
|
result.add(action);
|
}
|
|
if (commands.computerMode != null)
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.computerMode = commands.computerMode;
|
DeviceAction action = computerMode(controller, parameters, command, forcings, pendings);
|
if (action.resultCode == DeviceActionResult.RESULT_CORRECT) forcings.computerMode = command.computerMode;
|
result.add(action);
|
}
|
|
if (commands.centralized != null)
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.centralized = commands.centralized;
|
DeviceAction action = centralized(controller, parameters, command, forcings, pendings);
|
if (action.resultCode == DeviceActionResult.RESULT_CORRECT) forcings.centralized = command.centralized;
|
result.add(action);
|
}
|
|
if (commands.colorsMode != null)
|
{
|
RTZ32_Commands_Forcings command = new RTZ32_Commands_Forcings();
|
command.colorsMode = commands.colorsMode;
|
DeviceAction action = colorsMode(controller, parameters, command, forcings, pendings);
|
if (action.resultCode == DeviceActionResult.RESULT_CORRECT) forcings.colorsMode = command.colorsMode;
|
result.add(action);
|
}
|
|
if (commands.plan != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.plan = commands.plan;
|
DeviceAction action = plan(controller, parameters, command, forcings, pendings);
|
if (action.resultCode == DeviceActionResult.RESULT_CORRECT) forcings.plan = command.plan;
|
result.add(action);
|
}
|
|
}
|
catch (Exception exception)
|
{
|
}
|
|
return result;
|
}
|
|
|
|
|
|
|
|
|
public static List<DeviceAction> online(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online commands)
|
{
|
List<DeviceAction> result = new ArrayList<DeviceAction>();
|
|
RTZ32_Status_Pendings pendings = controller.talker.rtz32.getDeviceStatus().rtz32.pendings;
|
RTZ32_Status_Forcings forcings = controller.talker.rtz32.getDeviceStatus().rtz32.forcings;
|
|
|
try
|
{
|
if ((commands.control != null) && ((forcings == null) || (forcings.control == null)))
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.control = commands.control;
|
result.add(control(controller, parameters, command, forcings, pendings));
|
}
|
|
if (commands.computerMode != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.computerMode = commands.computerMode;
|
result.add(computerMode(controller, parameters, command, forcings, pendings));
|
}
|
|
if (commands.centralized != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.centralized = commands.centralized;
|
result.add(centralized(controller, parameters, command, forcings, pendings));
|
}
|
|
if (commands.colorsMode != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.colorsMode = commands.colorsMode;
|
result.add(colorsMode(controller, parameters, command, forcings, pendings));
|
}
|
|
if (commands.plan != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.plan = commands.plan;
|
result.add(plan(controller, parameters, command, forcings, pendings));
|
}
|
|
if (commands.realtime != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.realtime = commands.realtime;
|
result.add(realtime(controller, parameters, command));
|
}
|
|
if ((commands.clearAlarms != null) && (commands.clearAlarms.booleanValue() == true))
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.clearAlarms = commands.clearAlarms;
|
result.add(clearAlarms(controller, parameters, command));
|
}
|
|
if (commands.configurationRead != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.configurationRead = commands.configurationRead;
|
result.add(configurationRead(controller, parameters, command));
|
}
|
|
if (commands.configurationWrite != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.configurationWrite = commands.configurationWrite;
|
result.add(configurationWrite(controller, parameters, command));
|
}
|
|
if (commands.timestamp != null)
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.timestamp = commands.timestamp;
|
result.add(timestamp(controller, parameters, command));
|
}
|
|
if ((commands.clearPendings != null) && (commands.clearPendings == true))
|
{
|
RTZ32_Commands_Online command = new RTZ32_Commands_Online();
|
command.clearPendings = commands.clearPendings;
|
result.add(clearPendings(controller, parameters, command));
|
}
|
}
|
catch (Exception exception)
|
{
|
}
|
|
return result;
|
}
|
|
|
|
|
|
|
private static DeviceAction liberateControl(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
forcings.control = null;
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
private static DeviceAction liberateComputerMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
forcings.computerMode = null;
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
private static DeviceAction liberateCentralized(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
forcings.centralized = null;
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
private static DeviceAction liberateColorsMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
forcings.colorsMode = null;
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
private static DeviceAction liberatePlan(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
forcings.plan = null;
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
private static DeviceAction control(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.control != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has control forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_LOCAL_ORDENADOR(command.control);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.control = command.control;
|
}
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction computerMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.computerMode != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has computer mode forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_ORDENADOR(command.computerMode);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.computerMode = command.computerMode;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.computerMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction centralized(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.centralized != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has centralized mode forced")));
|
}
|
else
|
{
|
controller.talker.rtz32.getDeviceStatus().rtz32.centralized = new RTZ32_Status_Centralized();
|
controller.talker.rtz32.getDeviceStatus().rtz32.centralized.centralized = command.centralized.centralized;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.centralized = command.centralized;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.centralized = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction colorsMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.colorsMode != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has colors mode forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_COLORES(command.colorsMode);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.colorsMode = command.colorsMode;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.colorsMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction plan(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Forcings command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.plan != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has plan forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_PLAN(command.plan);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.plan = command.plan;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.colorsMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
private static DeviceAction control(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.control != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has control forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_LOCAL_ORDENADOR(command.control);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.control = command.control;
|
}
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction computerMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.computerMode != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has computer mode forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_ORDENADOR(command.computerMode);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.computerMode = command.computerMode;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.computerMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction centralized(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.centralized != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has centralized mode forced")));
|
}
|
else
|
{
|
controller.talker.rtz32.getDeviceStatus().rtz32.centralized = new RTZ32_Status_Centralized();
|
controller.talker.rtz32.getDeviceStatus().rtz32.centralized.centralized = command.centralized.centralized;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.centralized = command.centralized;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.centralized = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction colorsMode(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.colorsMode != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has colors mode forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_COLORES(command.colorsMode);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.colorsMode = command.colorsMode;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.colorsMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
private static DeviceAction plan(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command, RTZ32_Status_Forcings forcings, RTZ32_Status_Pendings pendings)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
if ((forcings != null) && (forcings.plan != null))
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, Shared.getMessage(parameters.getParameterValue("language"), "Controller has plan forced")));
|
}
|
else
|
{
|
controller.talker.writer.ORD_PLAN(command.plan);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
pendings.plan = command.plan;
|
}
|
}
|
catch (Exception exception)
|
{
|
pendings.colorsMode = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
|
|
private static DeviceAction realtime(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
controller.talker.writer.ORD_TIEMPO_REAL_CRUCE(command.realtime);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
|
private static DeviceAction clearAlarms(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
controller.talker.writer.ORD_BORRADO_ALARMAS(command.clearAlarms);
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
|
|
|
private static DeviceAction configurationRead(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
Thread thread = new Thread(new Runnable()
|
{
|
public void run()
|
{
|
try
|
{
|
String username = (String)parameters.getParameterValue("username");
|
String description = "?";
|
if (command.configurationRead.description != null) description = command.configurationRead.description;
|
boolean update = false;
|
if (command.configurationRead.update != null) update = command.configurationRead.update;
|
controller.configurationRead(username, description, update, command.configurationRead.programsDescriptions);
|
}
|
catch (Exception exception)
|
{
|
Shared.printstack(controller.name, exception);
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
}
|
}
|
});
|
|
thread.setName("CfgReading, " + System.currentTimeMillis() + ", " + controller.name);
|
thread.start();
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage()));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
private static DeviceAction configurationWrite(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
Thread thread = new Thread(new Runnable()
|
{
|
public void run()
|
{
|
try
|
{
|
String username = (String)parameters.getParameterValue("username");
|
controller.configurationWrite(username, command.configurationWrite);
|
}
|
catch (Exception exception)
|
{
|
Shared.printstack(controller.name, exception);
|
DeviceActionResult actionResult = new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage());
|
action.setResult(actionResult);
|
Shared.model.addAction(action);
|
}
|
}
|
});
|
|
thread.setName("CfgWriting, " + System.currentTimeMillis() + ", " + controller.name);
|
thread.start();
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception.getMessage()));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
|
}
|
|
|
|
|
|
|
|
private static DeviceAction timestamp(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
controller.talker.writer.ORD_FH(System.currentTimeMillis());
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
|
private static DeviceAction clearPendings(Controller_RTZ32 controller, InteropParameters parameters, RTZ32_Commands_Online command)
|
{
|
DeviceAction action = new DeviceAction(controller.getController(), parameters, command);
|
|
try
|
{
|
controller.talker.rtz32.getDeviceStatus().rtz32.pendings = null;
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_CORRECT));
|
}
|
catch (Exception exception)
|
{
|
action.setResult(new DeviceActionResult(DeviceActionResult.RESULT_ERROR, exception));
|
}
|
|
Shared.model.addAction(action);
|
return action;
|
}
|
|
|
|
|
|
|
|
|
private static void update(Controller_RTZ32 controller)
|
{
|
Thread thread = new Thread(new Runnable()
|
{
|
public void run()
|
{
|
try { controller.update(); } catch (Exception exception) {};
|
}
|
});
|
thread.setName("Update, " + System.currentTimeMillis());
|
thread.start();
|
}
|
|
|
|
|
|
}
|