package art.servers.etdserver.controller; import art.library.model.devices.Device; import art.library.model.devices.etd.Etd; import art.library.model.devices.etd.information.EtdClassification; import art.servers.Shared; import art.servers.controller.ControllerDevice; public class FactoryController extends art.servers.controller.FactoryController { public FactoryController() { super(); this.setName("Factory Controller"); } public ControllerDevice addController(Device device) { ControllerDevice controller = null; try { try { ControllerEtd controllerEtd = (ControllerEtd)Shared.getDeviceController(device.getIdentifier()); return(controllerEtd); } catch (Exception e) { } Etd etd = (Etd)device; if ((art.servers.etdserver.Shared.etdLog == null) || (art.servers.etdserver.Shared.etdLog.equalsIgnoreCase(etd.getIdentifier()))) { if (etd.getDeviceInformation().protocol.equalsIgnoreCase("SKP3") == true) { if (etd.getDeviceInformation().speedLimit <= 0) { etd.getDeviceInformation().speedLimit = getSpeedLimit(etd.getIdentifier()); } controller = new ControllerSKP3(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("SKP5") == true) { if (etd.getDeviceInformation().speedLimit <= 0) { etd.getDeviceInformation().speedLimit = getSpeedLimit(etd.getIdentifier()); } controller = new ControllerSKP5(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("DIAMOND") == true) { if (etd.getDeviceInformation().speedLimit <= 0) { etd.getDeviceInformation().speedLimit = getSpeedLimit(etd.getIdentifier()); } controller = new ControllerDiamond(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("DIAMOND-RAW") == true) { controller = new ControllerDiamondRaw(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("M-CONTROLLER") == true) { try { if (etd.getDeviceInformation().lLengthClassification.size() == 0) { EtdClassification classification = new EtdClassification(); classification.identifier = 1; classification.description = "Tots"; classification.lowerLimit = 0; classification.upperLimit = 9999; etd.getDeviceInformation().lLengthClassification.add(classification); } if (etd.getDeviceInformation().lSpeedClassification.size() == 0) { EtdClassification classification = new EtdClassification(); classification.identifier = 1; classification.description = "Tots"; classification.lowerLimit = 0; classification.upperLimit = 255; etd.getDeviceInformation().lSpeedClassification.add(classification); } } catch (Exception e) { } controller = new ControllerMController(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("RTMS") == true) { controller = new ControllerRTMS(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("DIAMONDV") == true) { if (etd.getDeviceInformation().speedLimit <= 0) { etd.getDeviceInformation().speedLimit = getSpeedLimit(etd.getIdentifier()); } controller = new ControllerVirtualEtd(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("DGT ERU") == true) { controller = new ControllerEtdDgtEru(etd); Shared.lcontroller.add(controller); controller.start(); } else if (etd.getDeviceInformation().protocol.equalsIgnoreCase("DPS") == true) { controller = new ControllerEtdDPS(etd); Shared.lcontroller.add(controller); controller.start(); } } } catch (Exception e) { } return controller; } public void removeController(ControllerDevice controller) { } private int getSpeedLimit(String etdIdentifier) { try { if (etdIdentifier.equalsIgnoreCase("etd-krzewica-1")) return(90); if (etdIdentifier.equalsIgnoreCase("etd-terespol-1")) return(90); if (etdIdentifier.equalsIgnoreCase("etd-wólkaokopska-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-żyrzyn-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-piaski-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-łopienniknadrzeczny-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-izbica-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-łabuniereforma-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-polanówka-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-hrebenne-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-międzyrzecpodlaski-1")) return(100); if (etdIdentifier.equalsIgnoreCase("etd-radzyńpodlaski-1")) return(90); if (etdIdentifier.equalsIgnoreCase("etd-sobieszyn-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-annopol-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-szczebrzeszyn-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-miączyn-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-łęczna-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-włodawa-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-wisznice-1")) return(70); if (etdIdentifier.equalsIgnoreCase("etd-sławatycze-1")) return(50); if (etdIdentifier.equalsIgnoreCase("etd-staraprawda-1")) return(60); } catch (Exception e) { e.printStackTrace(); } return(70); } }