private int position = 0; public void timer() { position = (position + 1) % 2; realtimeGroups(); } 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(); art.library.model.devices.colors.controller.M.M_ControllerStatus controllerStatus = controller.getDeviceStatus(); art.library.model.devices.colors.controller.M.M_ControllerAlarms controllerAlarms = controller.getDeviceAlarms(); art.library.model.devices.colors.controller.M.M_ControllerRealtime controllerRealtime = controller.getDeviceRealtime(); /* Subcontrollers */ for (int i = 0; i < controllerStatus.lsubcontroller.size(); i++) { statusSubcontroller(controllerStatus.lsubcontroller.get(i).number); } } catch (Exception e) { } } 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_ControllerStatus controllerStatus = controller.getDeviceStatus(); art.library.model.devices.colors.controller.M.M_ControllerAlarms controllerAlarms = controller.getDeviceAlarms(); art.library.model.devices.colors.controller.M.M_ControllerRealtime controllerRealtime = controller.getDeviceRealtime(); art.library.model.devices.colors.controller.M.M_ControllerConfiguration controllerConfiguration = controller.getDeviceConfiguration(); 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); } String identifier = controller.getIdentifier() + "." + subcontroller; realtimeGroups(); SVGElement thunderbolt = getElement(identifier + ".thunderbolt"); SVGElement emergency = getElement(identifier + ".emergency"); SVGElement lock = getElement(identifier + ".lock"); SVGElement calendar = getElement(identifier + ".calendar"); SVGElement run = getElement(identifier + ".run"); SVGElement remote = getElement(identifier + ".remote"); SVGElement background = getElement(identifier + ".background"); SVGElement border = getElement(identifier + ".border"); SVGElement ribbon = getElement(identifier + ".ribbon"); SVGElement textCycle = getElement(identifier + ".textCycle"); SVGElement textElpased = getElement(identifier + ".textElapsed"); SVGElement textInformation = getElement(identifier + ".textInformation"); SVGElement elapsed1 = getElement(identifier + ".elapsed1"); SVGElement elapsed2 = getElement(identifier + ".elapsed2"); /* Initialise */ setAttribute(thunderbolt, "fill-opacity", "1.0", 999); setAttribute(emergency, "fill-opacity", "1.0", 999); setAttribute(lock, "fill-opacity", "1.0", 999); setAttribute(calendar, "fill-opacity", "1.0", 999); setAttribute(run, "fill-opacity", "1.0", 999); setAttribute(remote, "fill-opacity", "1.10", 999); setAttribute(thunderbolt, "fill", "#804080", 999); setAttribute(emergency, "fill", "#804080", 999); setAttribute(lock, "fill", "#804080", 999); setAttribute(calendar, "fill", "#804080", 999); setAttribute(run, "fill", "#804080", 999); setAttribute(remote, "fill", "#804080", 999); setText(identifier + ".textInformation", ""); setText(identifier + ".textOffset", ""); setText(identifier + ".textCycle", ""); setText(identifier + ".textElapsed", ""); setAttribute(elapsed1, "display", "none"); setAttribute(elapsed2, "display", "none"); setAttribute(background, "fill", "#FF80FF"); setAttribute(border, "stroke", "#800080"); setAttribute(border, "display", "inline"); setAttribute(border, "stroke-width", 6.5); setAttribute(border, "stroke-opacity", 0.75); setAttribute(ribbon, "stroke", "#FF80FF"); setAttribute(ribbon, "stroke-opacity", "0.125"); /* User control */ if ((subcontrollerStatus.userControlManual == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES)) { setAttribute(thunderbolt, "fill-opacity", "1.0", 999); setAttribute(thunderbolt, "fill", "#0000FF", 999); } else { setAttribute(thunderbolt, "fill-opacity", "0.15", 999); setAttribute(thunderbolt, "fill", "#808080", 999); } /* Manual control */ if (subcontrollerStatus.localControl == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES) { setAttribute(lock, "fill-opacity", "1.0", 999); setAttribute(lock, "fill", "#FF0000", 999); } else if (subcontrollerStatus.localControl == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.NO) { setAttribute(lock, "fill-opacity", "0.15", 999); setAttribute(lock, "fill", "#808080", 999); } /* Emergency */ if (subcontrollerStatus.emergency == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES) { setAttribute(emergency, "fill-opacity", "1.0", 999); setAttribute(thunderbolt, "fill", "#FF0000", 999); } else if (subcontrollerStatus.emergency == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.NO) { setAttribute(emergency, "fill-opacity", "0.15", 999); setAttribute(emergency, "fill", "#808080", 999); } /* Plan selection */ switch (subcontrollerStatus.planSelection) { case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER: { setAttribute(calendar, "fill-opacity", "0.15", 999); setAttribute(calendar, "fill", "#808080", 999); break; } case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_TIMETABLE: case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_EXTERNAL_PLANS: case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_ICF: { setAttribute(calendar, "fill-opacity", "1.0", 999); setAttribute(calendar, "fill", "#0000FF", 999); break; } } /* Computer */ if ((subcontrollerStatus.planSelection == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER) || (subcontrollerStatus.centralizedMode == art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES)) { setAttribute(remote, "fill-opacity", "1.0", 999); setAttribute(remote, "fill", "#0000FF", 999); } else if ((subcontrollerStatus.planSelection != art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER) && (subcontrollerStatus.centralizedMode != art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.YES)) { setAttribute(remote, "fill-opacity", "0.15", 999); setAttribute(remote, "fill", "#808080", 999); } /* Running */ if ((controllerStatus.groupsRealtime == art.library.model.devices.colors.controller.M.M_ControllerStatus.YES) || (controllerStatus.detectorsRealtime == art.library.model.devices.colors.controller.M.M_ControllerStatus.YES)) { setAttribute(run, "fill-opacity", "1.0", 999); setAttribute(run, "fill", "#0000FF", 999); } else if ((controllerStatus.groupsRealtime == art.library.model.devices.colors.controller.M.M_ControllerStatus.NO) && (controllerStatus.detectorsRealtime == art.library.model.devices.colors.controller.M.M_ControllerStatus.NO)) { setAttribute(run, "fill-opacity", "0.15", 999); setAttribute(run, "fill", "#808080", 999); } /* Alarm */ double strokeopacity = Math.pow(2, controller.getDeviceAlarms().getServerityAlarm()) / 32; if (controller.getDeviceAlarms().getServerityAlarm() > 0) { setAttribute(border, "display", "inline"); setAttribute(border, "stroke", "#FF0000"); setAttribute(border, "stroke-opacity", strokeopacity); setAttribute(border, "stroke-width", 6.5); } else { setAttribute(border, "stroke", "#808080"); setAttribute(border, "display", "inline"); setAttribute(border, "stroke-width", 6.5); setAttribute(border, "stroke-opacity", 0.25); } /* Status */ switch (subcontrollerStatus.colorsMode) { case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_OFF: setAttribute(background, "fill", "#808080"); setAttribute(ribbon, "stroke", "#808080"); setAttribute(elapsed2, "fill", "#808080"); setText(identifier + ".textInformation", "OFF"); return; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_FLASHING: setAttribute(background, "fill", "#FFFF00"); setAttribute(ribbon, "stroke", "#FFFF00"); setAttribute(elapsed2, "fill", "#FFFF00"); setText(identifier + ".textInformation", "Y^"); return; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.COLORS_COLORS: setAttribute(background, "fill", "#FFFFFF"); setAttribute(ribbon, "stroke", "#FFFFFF"); setAttribute(elapsed2, "fill", "#0000FF"); break; } /* State, cycle */ art.library.model.devices.colors.controller.M.configuration.M_Plan plan = null; if (subcontrollerStatus.plan > 0) { try { plan = subcontrollerConfiguration.getMPlan(subcontrollerRealtime.plan); } catch (Exception e) { } } else { plan = subcontrollerStatus.recordablePlan; } if (plan != null) { String information = ""; switch (subcontrollerStatus.operationMode) { case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.OPERATIONMODE_FIXED: information = "F"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.OPERATIONMODE_SEMIACTUATED: information = "S"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.OPERATIONMODE_ACTUATED: information = "A"; break; } information = information + plan.number; switch (subcontrollerStatus.planSelection) { case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_TIMETABLE: information = information + "t"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_EXTERNAL_PLANS: information = information + "e"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_ICF: information = information + "i"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER: information = information + "c"; break; } switch (subcontrollerStatus.planSelectionComputer) { case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER_MACRO: information = information + ""; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER_PLAN_SELECTION: information = information + "+"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER_PLAN_GENERATION: information = information + "+"; break; case art.library.model.devices.colors.controller.M.M_ControllerStatusSubcontroller.PLANSELECTION_COMPUTER_ADAPTATIVE: information = information + "+"; break; } setText(identifier + ".textInformation", information); if (plan.offset > 0) { setText(identifier + ".textOffset", "" + plan.offset); } else { setText(identifier + ".textOffset", ""); } setText(identifier + ".textCycle", "" + plan.cycleTime); if (subcontrollerRealtime != null) { String text = subcontrollerRealtime.phase + ":" + subcontrollerRealtime.cycle; switch (subcontrollerRealtime.adjust) { case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeSubcontroller.ADJUST_POSITIVE: text = text + "+"; break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeSubcontroller.ADJUST_NEGATIVE: text = text + "-"; break; } setText(identifier + ".textElapsed", text); setAttribute(elapsed1, "display", "inline"); setAttribute(elapsed2, "display", "inline"); int elapsedWidth = getAttributeInteger(elapsed1, "width") - 2; float ratio = (float) subcontrollerRealtime.cycle / (float) plan.cycleTime; setAttribute(elapsed2, "width", (elapsedWidth * Math.min(1.0f, ratio))); update(elapsed2); } } } public void realtimeGroups() { 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_ControllerRealtime controllerRealtime = controller.getDeviceRealtime(); /* Realtime groups */ java.util.List groups = getElements("art.controller", controller.getIdentifier()); for (SVGElement group : groups) { int number = getAttributeInteger(group, "art.group"); setAttribute(group, "fill", "#808000"); art.library.model.devices.colors.controller.M.status.M_ControllerStatusGroup groupStatus = controller.getDeviceStatus().getStatusGroup(number); if(groupStatus.hasBlownAlarm() || controller.getAlarm("alarm_damaged_group") > 0) { setAttribute(group, "fill", "#AA7450"); continue; } try { art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup realTimeGroup = controllerRealtime.getStatusGroup(number); if (position == 0) { switch (realTimeGroup.getColor()) { case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_OFF: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_YELLOW: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_GREEN: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLAHING_YELLOW: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELLOW_DOUBLE: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_GREEN_RED: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED_YELLOW: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_GREEN_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_SLOW_FLASHING_GREEN: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_SLOW_FLASHING_RED: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_YELLOW_DOUBLE: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_RED_FLASHING_YELLOW: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_YELLOW_DOUBLE_WITH_GREEN_SIGNAL: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELOW_DOUBLE_WITH_RED_SIGNAL: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_YELLOW: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_UNKNOWN: setAttribute(group, "fill", "#E000E0"); break; default: } } else { switch (realTimeGroup.getColor()) { case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_OFF: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_YELLOW: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_GREEN: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLAHING_YELLOW: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELLOW_DOUBLE: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_GREEN_RED: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED_YELLOW: setAttribute(group, "fill", "#E0E0000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_GREEN_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_RED_FLASHING_YELLOW_PROTECTION: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_SLOW_FLASHING_GREEN: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_SLOW_FLASHING_RED: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_YELLOW_DOUBLE: setAttribute(group, "fill", "#4B4B4B"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FAST_FLASHING_RED_FLASHING_YELLOW: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_FLASHING_YELLOW_DOUBLE_WITH_GREEN_SIGNAL: setAttribute(group, "fill", "#00E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_FLASHING_YELOW_DOUBLE_WITH_RED_SIGNAL: setAttribute(group, "fill", "#E00000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_GREEN_YELLOW: setAttribute(group, "fill", "#E0E000"); break; case art.library.model.devices.colors.controller.M.realtime.M_ControllerRealtimeGroup.M_GROUP_COLOR_UNKNOWN: setAttribute(group, "fill", "#E000E0"); break; default: } } } catch (Exception e) { setAttribute(group, "fill", "#C000C0"); } } }