bck
Alejandro Acuña
2024-11-11 f1cb4443aede6d4657bdc3396c8914d3a9f4fa93
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
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);
    }
 
}