package art.servers;
|
|
import art.servers.colorsserver.controller.ListenerImplementation;
|
import art.servers.colorsserver.Shared;
|
import art.library.gui.flat.FlatDialog;
|
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_ControllerInformation;
|
import art.library.utils.licence.Licence;
|
import art.servers.colorsserver.controller.ControllerConnection;
|
import art.servers.colorsserver.controller.ControllerDynamicController;
|
import art.servers.colorsserver.controller.ControllerRtacController;
|
import art.servers.colorsserver.controller.ControllerTelventController;
|
import art.servers.controller.ControllerDevice;
|
import java.io.PrintWriter;
|
import java.io.StringWriter;
|
import java.util.ArrayList;
|
import java.util.Collection;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
|
|
public class ColorsServer extends art.servers.Server
|
{
|
public static boolean ACTIVATE_REALTIME = false;
|
|
|
public static void main(String[] args)
|
{
|
try
|
{
|
String user = "7dLkfR5ZjYTOYvVrVeeihQ==";
|
String UserBD = "A/zYtigVU7uJN/pJjR1y0A==";
|
String PasswordBD = "cTSO+EwtFDjTE5l40R+s8w==";
|
String Readuser = "jH+/Jk+P3gdtZDOOwoqnNQ==";
|
String Readpassword = "jH+/Jk+P3gdtZDOOwoqnNQ==";
|
System.out.println(Licence.decrypt(Readuser));
|
System.out.println(Licence.decrypt(Readpassword));
|
// System.out.println(Licence.decrypt(user));
|
// System.out.println(Licence.decrypt(UserBD));
|
// System.out.println(Licence.decrypt(PasswordBD));
|
ACTIVATE_REALTIME = existParameter(args, "-activaterealtime");
|
Shared.setApplicationCode("FsEhD8Bp4LqdRHtbrg5ykzmqwmtDQP3m");
|
Shared.setApplicationName("art.servers.colorsserver");
|
preinitialise(args);
|
Shared.model = new art.servers.colorsserver.Model(Shared.configuration);
|
postinitialise(args);
|
Shared.controllerListener.setListenerImplementation(new ListenerImplementation());
|
|
HashMap<String, List<M_Controller>> hcontrollers = new HashMap<String, List<M_Controller>>();
|
System.out.println("MODEL.LDEVICE: " + Shared.model.ldevice.size());
|
for (Device device : Shared.model.ldevice)
|
{
|
try
|
{
|
System.out.println("DEVICE: " + device.getIdentifier());
|
M_Controller m_controller = (M_Controller)device;
|
List<M_Controller> lcontrollers = hcontrollers.get(m_controller.getDeviceInformation().address + ":" + m_controller.getDeviceInformation().portM);
|
if (lcontrollers == null)
|
{
|
boolean hasCRC = false;
|
if ((m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RTAC) ||
|
(m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_CMY))
|
hasCRC = true;
|
|
ControllerConnection controllerConnection = new ControllerConnection(m_controller.getDeviceInformation().address, m_controller.getDeviceInformation().portM, m_controller.getDeviceInformation().timeout, hasCRC);
|
Shared.addControllerConnection(m_controller.getDeviceInformation().address + ":" + m_controller.getDeviceInformation().portM, controllerConnection);
|
controllerConnection.start();
|
|
lcontrollers = new ArrayList<M_Controller>();
|
hcontrollers.put(m_controller.getDeviceInformation().address + ":" + m_controller.getDeviceInformation().portM, lcontrollers);
|
}
|
|
lcontrollers.add(m_controller);
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
System.out.println("DEVICE.EX: " + device.getIdentifier() + " - " + e.toString());
|
}
|
}
|
|
Collection<List<M_Controller>> lvalues = hcontrollers.values();
|
Iterator<List<M_Controller>> iterator = lvalues.iterator();
|
while (iterator.hasNext())
|
{
|
List<M_Controller> lcontroller = iterator.next();
|
|
if (lcontroller.size() == 1)
|
{
|
M_Controller m_controller = lcontroller.get(0);
|
System.out.println("CONTROLLER 1: " + m_controller.getIdentifier());
|
|
if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_DYNAMIC)
|
{
|
ControllerDevice controller = new ControllerDynamicController(m_controller, false);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RMY)
|
{
|
ControllerDevice controller = new ControllerTelventController(m_controller, false);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RTAC)
|
{
|
ControllerDevice controller = new ControllerRtacController(m_controller, true);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_CMY)
|
{
|
ControllerDevice controller = new ControllerTelventController(m_controller, true);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
}
|
else
|
{
|
System.out.println("CONTROLLER > 1: " + lcontroller.size());
|
M_Controller m_controller = null;
|
for (M_Controller m_controllerSub : lcontroller)
|
{
|
if (m_controller == null)
|
{
|
m_controller = Serialization.clone(m_controllerSub);
|
}
|
else
|
{
|
m_controller.getDeviceConfiguration().lsubcontroller.addAll(m_controllerSub.getDeviceConfiguration().lsubcontroller);
|
m_controller.getDeviceStatus().lsubcontroller.addAll(m_controllerSub.getDeviceStatus().lsubcontroller);
|
m_controller.getDeviceStatus().lsubcontrollerUpdate.addAll(m_controllerSub.getDeviceStatus().lsubcontrollerUpdate);
|
}
|
}
|
|
if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_DYNAMIC)
|
{
|
ControllerDevice controller = new ControllerDynamicController(m_controller, lcontroller, false);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RMY)
|
{
|
ControllerDevice controller = new ControllerTelventController(m_controller, false);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_RTAC)
|
{
|
ControllerDevice controller = new ControllerRtacController(m_controller, true);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
else if (m_controller.getDeviceInformation().type == M_ControllerInformation.TYPE_CMY)
|
{
|
ControllerDevice controller = new ControllerTelventController(m_controller, true);
|
Shared.lcontroller.add(controller);
|
controller.start();
|
}
|
}
|
}
|
|
|
// Factory controller
|
// Shared.model.factoryController = new FactoryController();
|
// Shared.model.factoryController.start();
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
StringWriter sw = new StringWriter();
|
e.printStackTrace(new PrintWriter(sw));
|
FlatDialog.showDialog(null, Shared.getMessage("Error"), e.getMessage() + "\n\n" + sw.toString(), true, FlatDialog.DIALOG_INFORMATION);
|
System.exit(0);
|
}
|
}
|
|
}
|
/*
|
try
|
{
|
if (existParameter(args, "-createcontrollers") == true)
|
{
|
File f = new File("docs/17.json");
|
M_Controller m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
f = new File("docs/18.json");
|
m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
f = new File("docs/39.json");
|
m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
f = new File("docs/40.json");
|
m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
f = new File("docs/41.json");
|
m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
f = new File("docs/42.json");
|
m_controller = Serialization.deserialize(M_Controller.class, f);
|
System.out.println(m_controller.getIdentifier());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println(m_controller.getDeviceConfiguration().lsubcontroller.get(0));
|
Shared.controllerDatabase.timeless_updateOrAddObject(new DevicePersistenceTimeless(m_controller));
|
if (art.servers.Shared.controllerDatabase != null)
|
{
|
List<Device> ldevice = (List<Device>)DevicePersistenceTimeless.getDevices((List<Object>)(List<?>)art.servers.Shared.controllerDatabase.timeless_getObject(DevicePersistenceTimeless.class.getName(), "type = '" + M_Controller.class.getName() + "'"));
|
System.out.println("LDEVICE: " + ldevice.size());
|
|
for (Device device : ldevice)
|
{
|
M_Controller m_controller2 = (M_Controller)device;
|
System.out.println("A1.------------------ " + m_controller2.getIdentifier());
|
System.out.println("A2.------------------ " + m_controller2.getDeviceConfiguration().lsubcontroller.size());
|
System.out.println("A3.------------------ " + m_controller2.getDeviceConfiguration().ltrafficGroup.size());
|
System.out.println("A4.------------------ " + device.information.serverPort);
|
System.out.println("A5.------------------ " + device.information.serverAddress);
|
System.out.println("A6.------------------ " + art.servers.Shared.configuration.listener.port);
|
System.out.println("A7.------------------ " + art.servers.Shared.configuration.listener.address);
|
if ((device instanceof Device) && (device.information.serverPort == art.servers.Shared.configuration.listener.port) && (device.information.serverAddress.equalsIgnoreCase(art.servers.Shared.configuration.listener.address)))
|
{
|
device.information.serverAddress = art.servers.Shared.configuration.listener.address;
|
device.information.serverPort = art.servers.Shared.configuration.listener.port;
|
device.information.serverAddressExternal = art.servers.Shared.configuration.listener.addressExternal;
|
device.information.serverPortExternal = art.servers.Shared.configuration.listener.portExternal;
|
}
|
}
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
*/
|