package M_Controller;
|
|
|
import art.library.model.devices.DeviceCommands;
|
import art.library.model.devices.DeviceGraphicsRuntime;
|
import art.library.model.devices.DeviceStatus;
|
import com.kitfox.svg.SVGDiagram;
|
import com.kitfox.svg.SVGElement;
|
|
public class M_ControllerMap extends DeviceGraphicsRuntime
|
{
|
|
public M_ControllerMap(art.library.model.devices.Device device, SVGDiagram diagram)
|
{
|
super(device, diagram);
|
}
|
|
public M_ControllerMap(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands commands, SVGDiagram diagram)
|
{
|
super(device, commands, diagram);
|
}
|
|
public void status()
|
{
|
try
|
{
|
art.library.model.devices.colors.controller.M.M_Controller controller = (art.library.model.devices.colors.controller.M.M_Controller) getDevice();
|
art.library.model.devices.colors.controller.M.M_ControllerInformation controllerInformation = controller.getDeviceInformation();
|
SVGElement background = getElement("Background");
|
SVGElement border = getElement("Border");
|
SVGElement alarm = getElement("Alarm");
|
SVGElement icon = getElement("Icon");
|
/* Initialise */ setText("Text number", String.format("%05d", controllerInformation.number));
|
setAttribute(background, "fill", "#00FF00");
|
setAttribute(border, "stroke", "#008000");
|
setAttribute(alarm, "display", "none");
|
setAttribute(icon, "fill", "#008000", 999);
|
/* Alarm */ art.library.model.devices.colors.controller.M.M_ControllerStatus controllerStatus = controller.getDeviceStatus();
|
if (controllerStatus.lsubcontroller.size() < 1)
|
{
|
paintNoStatusAvailable();
|
}
|
/* Subcontrollers */ for (int i = 0; i < controllerStatus.lsubcontroller.size(); i++)
|
{
|
statusSubcontroller(controllerStatus.lsubcontroller.get(i).number);
|
}
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
public void statusSubcontroller(int subcontroller)
|
{
|
art.library.model.devices.colors.controller.M.M_Controller controller = (art.library.model.devices.colors.controller.M.M_Controller) getDevice();
|
art.library.model.devices.colors.controller.M.M_ControllerInformation controllerInformation = controller.getDeviceInformation();
|
art.library.model.devices.colors.controller.M.M_ControllerStatus controllerStatus = controller.getDeviceStatus();
|
art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller subcontrollerStatus = null;
|
art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeSubcontroller subcontrollerRealtime = null;
|
art.library.model.devices.colors.controller.M.M_SubcontrollerConfiguration subcontrollerConfiguration = null;
|
if (controller.status != null)
|
{
|
subcontrollerStatus = controller.getDeviceStatus().getStatusSubcontroller(subcontroller);
|
}
|
if (controller.realtime != null)
|
{
|
subcontrollerRealtime = controller.getDeviceRealtime().getRealtimeSubcontroller(subcontroller);
|
}
|
if (controller.configuration != null)
|
{
|
subcontrollerConfiguration = controller.getDeviceConfiguration().getSubcontroller(subcontroller);
|
}
|
SVGElement background = getElement("Background");
|
SVGElement border = getElement("Border");
|
SVGElement alarm = getElement("Alarm");
|
SVGElement icon = getElement("Icon");
|
/* Initialise */ setText("Text number", String.format("%05d", controllerInformation.number));
|
setAttribute(background, "fill", "#FF00FF");
|
setAttribute(border, "stroke", "#800080");
|
setAttribute(border, "stroke-width", 0.75);
|
setAttribute(alarm, "display", "none");
|
setAttribute(icon, "fill", "#800080", 999);
|
/* Alarm */ double strokeopacity = Math.pow(2, controller.getDeviceAlarms().getServerityAlarm()) / 32;
|
if (controller.getDeviceAlarms().getServerityAlarm() > 0)
|
{
|
setAttribute(alarm, "stroke", "#FF0000");
|
setAttribute(alarm, "stroke-opacity", strokeopacity);
|
setAttribute(alarm, "display", "inline");
|
}
|
/* Status */ switch (subcontrollerStatus.colorsMode)
|
{
|
case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_OFF:
|
setAttribute(background, "fill", "#808080");
|
setAttribute(icon, "fill", "#404040");
|
setAttribute(border, "stroke", "#404040");
|
return;
|
case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_FLASHING:
|
setAttribute(background, "fill", "#FFFF00");
|
setAttribute(icon, "fill", "#808000");
|
setAttribute(border, "stroke", "#808000");
|
return;
|
case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_COLORS:
|
if (subcontrollerStatus.emergency == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES)
|
{
|
setAttribute(background, "fill", "#FF8000");
|
setAttribute(icon, "fill", "#804000");
|
setAttribute(border, "stroke", "#804000");
|
} else if ((subcontrollerStatus.userControlManual == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES))
|
{
|
setAttribute(background, "fill", "#0000FF");
|
setAttribute(icon, "fill", "#000080");
|
setAttribute(border, "stroke", "#000080");
|
} else if (subcontrollerStatus.localControl == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES)
|
{
|
setAttribute(background, "fill", "#0000FF");
|
setAttribute(icon, "fill", "#000080");
|
setAttribute(border, "stroke", "#000080");
|
} else
|
{
|
setAttribute(background, "fill", "#00FF00");
|
setAttribute(icon, "fill", "#008000");
|
setAttribute(border, "stroke", "#008000");
|
}
|
break;
|
}
|
|
if(subcontrollerStatus.userControlPlan > 0)
|
{
|
setAttribute(border, "stroke", "#0000FF");
|
setAttribute(border, "stroke-width", 1.5);
|
}
|
|
if (controller.getStatus() == DeviceStatus.STATUS_OFFLINE)
|
{
|
setAttribute(background, "fill", "#FF00FF");
|
setAttribute(icon, "fill", "#7C007C");
|
setAttribute(border, "stroke", "#7C007C");
|
setAttribute(alarm, "display", "none");
|
} else if (controller.getStatus() == DeviceStatus.STATUS_DISABLE)
|
{
|
setAttribute(background, "fill", "#404040");
|
setAttribute(icon, "fill", "#404040");
|
setAttribute(border, "stroke", "#808080");
|
setAttribute(alarm, "display", "none");
|
}
|
}
|
|
public void paintNoStatusAvailable()
|
{
|
SVGElement background = getElement("Background");
|
SVGElement border = getElement("Border");
|
SVGElement alarm = getElement("Alarm");
|
SVGElement icon = getElement("Icon");
|
setText("Text number", String.format("%05d", getDevice().getDeviceInformation().number));
|
setAttribute(background, "fill", "#FF00FF");
|
setAttribute(alarm, "display", "none");
|
setAttribute(icon, "fill", "#7C007C");
|
setAttribute(border, "stroke", "#7C007C");
|
}
|
|
public void commands()
|
{
|
SVGElement background = getElement("Background");
|
SVGElement border = getElement("Border");
|
SVGElement alarm = getElement("Alarm");
|
SVGElement icon = getElement("Icon");
|
try
|
{
|
art.library.model.devices.colors.controller.M.M_Controller controller = (art.library.model.devices.colors.controller.M.M_Controller) getDevice();
|
art.library.model.devices.colors.controller.M.M_ControllerInformation controllerInformation = controller.getDeviceInformation();
|
art.library.model.devices.colors.controller.M.M_ControllerCommands commands = (art.library.model.devices.colors.controller.M.M_ControllerCommands) getDeviceCommands();
|
setAttribute(background, "fill", "#FF00FF");
|
setAttribute(border, "stroke", "#800080");
|
setAttribute(alarm, "display", "none");
|
setAttribute(icon, "fill", "#800080", 999);
|
setText("Text number", String.format("%05d", controllerInformation.number));
|
DeviceCommands deviceCommands = getDeviceCommands();
|
if (!deviceCommands.isEmpty())
|
{
|
switch (commands.colorsMode)
|
{
|
case art.library.model.devices.colors.controller.M.M_ControllerCommands.COLORS_OFF:
|
setAttribute(background, "fill", "#808080");
|
setAttribute(icon, "fill", "#404040");
|
setAttribute(border, "stroke", "#404040");
|
break;
|
case art.library.model.devices.colors.controller.M.M_ControllerCommands.COLORS_FLASHING:
|
setAttribute(background, "fill", "#FFFF00");
|
setAttribute(icon, "fill", "#808000");
|
setAttribute(border, "stroke", "#808000");
|
break;
|
case art.library.model.devices.colors.controller.M.M_ControllerCommands.COLORS_COLORS:
|
setAttribute(background, "fill", "#00FF00");
|
setAttribute(icon, "fill", "#008000");
|
setAttribute(border, "stroke", "#008000");
|
break;
|
default:
|
setAttribute(background, "fill", "#00FF00");
|
setAttribute(icon, "fill", "#008000");
|
setAttribute(border, "stroke", "#008000");
|
break;
|
}
|
} else
|
{
|
setAttribute(background, "fill", "#0000FF");
|
setAttribute(icon, "fill", "#000080");
|
setAttribute(border, "stroke", "#000080");
|
}
|
} catch (Exception e)
|
{
|
setAttribute(background, "fill", "#0000FF");
|
setAttribute(border, "stroke", "#000080");
|
setAttribute(alarm, "display", "none");
|
setAttribute(icon, "fill", "#000080", 999);
|
setText("Text number", String.format("%05d", device.getDeviceInformation().number));
|
}
|
}
|
}
|
|