df
Alejandro Acuña
2024-09-16 f56295b7f2c7282783589fb4903529b09e161daa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
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();
            }
 
*/