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 Luengo extends DeviceGraphicsRuntime { private boolean even = false; private final Class[] ldeviceClasses = new Class[] { JetFan.class, VentilationZone.class }; public Luengo (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 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 { 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 { VentilationZoneStatus status = (VentilationZoneStatus) svgDevice.getDeviceStatus(); 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) { } } }