package art.runtime.maps;
|
|
import art.client.models.Shared;
|
import art.library.model.devices.DeviceGraphicsRuntime;
|
import art.library.model.devices.DeviceStatus;
|
import art.library.model.devices.tunnel.jetfan.JetFan;
|
import art.library.model.devices.tunnel.jetfan.JetFanAlarms;
|
import art.library.model.devices.tunnel.jetfan.JetFanStatus;
|
import art.library.model.devices.tunnel.ventilationzone.VentilationZone;
|
import art.library.model.devices.tunnel.ventilationzone.VentilationZoneAlarms;
|
import art.library.model.devices.tunnel.ventilationzone.VentilationZoneStatus;
|
import com.kitfox.svg.*;
|
import java.util.*;
|
|
|
public class Corridor extends DeviceGraphicsRuntime
|
{
|
private boolean even = false;
|
|
private final Class[] ldeviceClasses = new Class[]
|
{
|
JetFan.class,
|
VentilationZone.class
|
};
|
|
public Corridor(SVGDiagram diagram)
|
{
|
super(diagram);
|
}
|
|
public void status()
|
{
|
|
Calendar calendardate = java.util.Calendar.getInstance();
|
calendardate.set(java.util.Calendar.MILLISECOND, 0);
|
long seconds = calendardate.getTimeInMillis()/1000;
|
even = (seconds % 2) == 0;
|
|
try
|
{
|
List<SVGElement> lelement = getElementsContainingField("art.device");
|
|
for (SVGElement element : lelement)
|
{
|
try
|
{
|
for (Class deviceClass : ldeviceClasses)
|
if (getAttribute(element, "art.device").toLowerCase().contains(deviceClass.getSimpleName().toLowerCase()))
|
{
|
this.getClass().getMethod("status", deviceClass, SVGElement.class)
|
.invoke(this, Shared.model.modelDevices.getDevice(getAttribute(element, "art.device")), element);
|
break;
|
}
|
}
|
catch (Exception e){}
|
}
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
|
|
public void status(JetFan svgDevice, SVGElement element) throws Exception
|
{
|
//REMOVE THIS WHEN FINISHED
|
|
svgDevice = new JetFan("mocked-fan");
|
|
svgDevice.getDeviceStatus().state = (!even) ? JetFanStatus.JETFAN_STATE_REVERSE : JetFanStatus.JETFAN_STATE_DIRECT_STARTING_TIMING;
|
svgDevice.getDeviceStatus().status = (even) ? JetFanStatus.STATUS_ALARM : JetFanStatus.STATUS_ONLINE;
|
|
svgDevice.getDeviceAlarms().alarm_offline = 0;
|
svgDevice.getDeviceAlarms().alarm_local_control = (!even) ? 0 : 1 ;
|
svgDevice.getDeviceAlarms().alarm_manual_control = (even) ? 1 : 0;
|
|
//////////////////////
|
|
|
JetFanStatus status = (JetFanStatus) svgDevice.getDeviceStatus();
|
JetFanAlarms alarms = (JetFanAlarms) svgDevice.getDeviceAlarms();
|
|
String background = "#FF00FF";
|
String startingColor = "#FFFF00";
|
SVGElement componentBackground = getChildContainingField(element, "art.id", "background");
|
SVGElement componentArrowDirect = getChildContainingField(element, "art.id", "direct");
|
SVGElement componentArrowReverse = getChildContainingField(element, "art.id", "reverse");
|
SVGElement componentManSymbol = getChildContainingField(element, "art.id", "man");
|
SVGElement componentHandSymbol = getChildContainingField(element, "art.id", "hand");
|
SVGElement componentAlarmSymbol = getChildContainingField(element, "art.id", "alarm");
|
|
setAttribute(componentArrowDirect, "display", "none");
|
setAttribute(componentArrowReverse, "display", "none");
|
setAttribute(componentManSymbol, "display", "none");
|
setAttribute(componentHandSymbol, "display", "none");
|
setAttribute(componentAlarmSymbol, "display", "none");
|
|
for (int i = 0; i <= 5; i++)
|
{
|
setAttribute(getChildContainingField(element, "art.id", "Alarm_"+i), "display", (alarms.getServerityAlarm() == i) ? "none" : "none");
|
}
|
|
try
|
{
|
switch (status.status)
|
{
|
case DeviceStatus.STATUS_ONLINE:
|
background = "#00FF00";
|
break;
|
case DeviceStatus.STATUS_WARNING:
|
background = "#FFFF00";
|
break;
|
case DeviceStatus.STATUS_ALARM:
|
background = "#FF0000";
|
break;
|
case DeviceStatus.STATUS_INVALID:
|
background = "#B97A57";
|
break;
|
case DeviceStatus.STATUS_DISABLE:
|
background = "#808080";
|
break;
|
case DeviceStatus.STATUS_SIMULATION:
|
background = "#0000FF";
|
break;
|
case DeviceStatus.STATUS_OFFLINE:
|
background = "#FF00FF";
|
break;
|
case DeviceStatus.STATUS_UNKNOWN:
|
background = "#FF00FF";
|
break;
|
}
|
if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_DIRECT)
|
{
|
setAttribute(componentArrowDirect, "display", "inline");
|
setAttribute(componentArrowDirect, "fill", background);
|
} else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_REVERSE)
|
{
|
setAttribute(componentArrowReverse, "display", "inline");
|
setAttribute(componentArrowReverse, "fill", background);
|
} else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_DIRECT_STARTING_TIMING)
|
{
|
setAttribute(componentArrowDirect, "display", "inline");
|
setAttribute(componentArrowDirect, "fill", startingColor);
|
} else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_REVERSE_STARTING_TIMING)
|
{
|
setAttribute(componentArrowReverse, "display", "inline");
|
setAttribute(componentArrowReverse, "fill", startingColor);
|
}
|
setAttribute(componentHandSymbol, "display", (alarms.alarm_manual_control > 0) ? "inline" : "none");
|
setAttribute(componentManSymbol, "display", (alarms.alarm_local_control > 0) ? "inline" : "none");
|
setAttribute(componentManSymbol, "fill", "#" + Integer.toHexString(java.awt.Color.decode(background).darker().darker().getRGB()).substring(2));
|
setAttribute(componentBackground, "fill", background);
|
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
|
public void status( VentilationZone svgDevice, SVGElement element) throws Exception
|
{
|
//REMOVE THIS WHEN FINISHED
|
|
|
svgDevice = new VentilationZone("mocked-VentilationZone");
|
|
svgDevice.getDeviceStatus().mode = (!even) ? VentilationZoneStatus.VENTILATION_ZONE_MODE_AUTO :VentilationZoneStatus.VENTILATION_ZONE_MODE_FORCED;
|
svgDevice.getDeviceStatus().currentLevel = (!even) ? -150 : 50;
|
svgDevice.getDeviceStatus().calculatedLevel = (even) ? -160 : 40 ;
|
svgDevice.getDeviceStatus().forcedLevel = (even) ? -200 : 200;
|
|
|
////////////////////////////////
|
|
VentilationZoneStatus status = (VentilationZoneStatus) svgDevice.getDeviceStatus();
|
VentilationZoneAlarms alarms = (VentilationZoneAlarms) svgDevice.getDeviceAlarms();
|
|
SVGElement text1 = getChildContainingField(element, "art.id", "text1");
|
SVGElement text2 = getChildContainingField(element, "art.id", "text2");
|
SVGElement text3 = getChildContainingField(element, "art.id", "text3");
|
SVGElement direct = getChildContainingField(element, "art.id", "arrow_direct");
|
SVGElement reverse = getChildContainingField(element, "art.id", "arrow_reverse");
|
|
setAttribute(reverse, "fill", "#607560");
|
setAttribute(direct, "fill", "#607560");
|
try
|
{
|
setText(text1, String.valueOf(status.currentLevel));
|
setText(text2, String.valueOf(status.forcedLevel));
|
String statusText = "?";
|
|
if (status.mode == VentilationZoneStatus.VENTILATION_ZONE_MODE_MANUAL)
|
{
|
statusText = "M";
|
} else if (status.mode == VentilationZoneStatus.VENTILATION_ZONE_MODE_AUTO)
|
{
|
statusText = "A";
|
} else if (status.mode == VentilationZoneStatus.VENTILATION_ZONE_MODE_FORCED)
|
{
|
statusText = "F";
|
}
|
setText(text3, statusText);
|
if (status.currentLevel > 0)
|
{
|
setAttribute(direct, "fill", "#00FF00");
|
}
|
else if (status.currentLevel < 0)
|
{
|
setAttribute(reverse, "fill", "#00FF00");
|
}
|
}
|
catch (Exception ex)
|
{
|
}
|
}
|
}
|
|
|
|
|