package art.servers.colorsserver.controller; import art.library.interop.serialization.Serialization; import art.library.model.devices.Device; import art.library.model.devices.colors.controller.M.M_Controller; import art.library.model.devices.colors.controller.M.M_ControllerConfiguration; import art.library.model.devices.colors.controller.M.M_ControllerInformation; import art.servers.Shared; import art.servers.controller.ControllerDevice; import java.io.File; public class FactoryController extends art.servers.controller.FactoryController { public FactoryController() { super(); } public ControllerDevice addController(Device device) { ControllerDevice controller = null; try { M_Controller m_controller = (M_Controller)device; if (m_controller.getDeviceConfiguration().lsubcontroller.size() == 0) { try { M_ControllerConfiguration configuration = Serialization.deserialize(M_ControllerConfiguration.class, new File("configs/" + m_controller.getDeviceInformation().number + ".json")); if (configuration != null) { m_controller.configuration = configuration; } } catch (Exception e) { e.printStackTrace(); } } try { ControllerController controllerController = (ControllerController)Shared.getDeviceController(device.getIdentifier()); if (controllerController != null) { Shared.lcontroller.remove(controllerController); } } catch (Exception e) { } if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_DYNAMIC) { controller = new ControllerDynamicController(m_controller, false); Shared.lcontroller.add(controller); controller.start(); Shared.println("Factory", "ADD: " + m_controller.getIdentifier() + " - DYNAMIC"); } else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RMY) { controller = new ControllerTelventController(m_controller, false); Shared.lcontroller.add(controller); controller.start(); Shared.println("Factory", "ADD: " + m_controller.getIdentifier() + " - RMY"); } else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RTAC) { controller = new ControllerRtacController(m_controller, true); Shared.lcontroller.add(controller); controller.start(); Shared.println("Factory", "ADD: " + m_controller.getIdentifier() + " - RTAC"); } else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_CMY) { controller = new ControllerTelventController(m_controller, true); Shared.lcontroller.add(controller); controller.start(); Shared.println("Factory", "ADD: " + m_controller.getIdentifier() + " - CMY"); } // else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_CITY) // { // controller = new ControllerDynamicController(m_controller, false); // Shared.lcontroller.add(controller); // controller.start(); // Shared.println("Factory", "ADD: " + m_controller.getIdentifier() + " - CITY"); // } } catch (Exception e) { } return controller; } public void removeController(ControllerDevice controller) { } }