Alejandro Acuña
2024-12-18 44b33e24b644459038edd956cfce7345ce3236c1
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
package Rtz;
 
 
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
public class RtzMapMiddle extends DeviceGraphicsRuntime
{
 
    public RtzMapMiddle(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
  
    public RtzMapMiddle(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands commands, SVGDiagram diagram)
    {
        super(device, commands, diagram);
    }
 
     public void status()
    {
        try
        {
            statusSubcontroller();
        } catch (Exception e)
        {
        }
    }
 
    public void statusSubcontroller()
    {
        art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller controller = (art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller) getDevice();
        art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerStatus controllerStatus = (art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerStatus) controller.getDeviceStatus();
        art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation controllerInformation = (art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation) controller.getDeviceInformation();
        art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status subcontrollerStatus = controllerStatus.rtz32;
 
        SVGElement background = getElement("Background");
        SVGElement border = getElement("Border");
        SVGElement icon = getElement("Icon container");
      
        setText("Text number", String.format("%05d", controllerInformation.number));
 
        setAttribute(border, "stroke", "#800080",999);
        setAttribute(border, "display", "inline",999);
        setAttribute(background, "fill", "#FF80FF",999);
        
        switch (controllerStatus.status)
        {
            case art.library.model.devices.DeviceStatus.STATUS_ONLINE:
                break;
            case art.library.model.devices.DeviceStatus.STATUS_WARNING:
                break;
            case art.library.model.devices.DeviceStatus.STATUS_ALARM:
                break;
            case art.library.model.devices.DeviceStatus.STATUS_DISABLE:
                setAttribute(background, "fill", "#404040",999);
                setAttribute(border, "stroke", "#808080",999);
                setAttribute(border, "display", "inline",999);
                return;
            case art.library.model.devices.DeviceStatus.STATUS_SIMULATION:
                setAttribute(background, "fill", "#0000FF",999);
                setAttribute(icon, "fill", "#000080",999);
                setAttribute(border, "stroke", "#000080",999);
                setAttribute(border, "display", "inline",999);
                break;
            case art.library.model.devices.DeviceStatus.STATUS_INVALID:
            case art.library.model.devices.DeviceStatus.STATUS_OFFLINE:
            case art.library.model.devices.DeviceStatus.STATUS_UNKNOWN:
                setAttribute(background, "fill", "#FF00FF",999);
                setAttribute(icon, "fill", "#7C007C",999);
                setAttribute(border, "stroke", "#7C007C",999);
                setAttribute(border, "display", "inline",999);
                return;
        }
       
       
        switch (subcontrollerStatus.general.state)
        {
            case art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.STATE_UNKNOWN:
                setAttribute(background, "fill", "#808080",999);
                setAttribute(icon, "fill", "#808080",999);
                setAttribute(border, "stroke", "#808080",999);
                return;
            case art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.STATE_FLASHING:
                java.util.Calendar calendardate = java.util.Calendar.getInstance();
                calendardate.set(java.util.Calendar.MILLISECOND, 0);
                long seconds = calendardate.getTimeInMillis() / 1000;
                if ((seconds % 2) == 0)
                {
                    setAttribute(background, "fill", "#FFFF00",999);
                    setAttribute(icon, "fill", "#7C7C00",999);
                    setAttribute(border, "stroke", "#7C7C00",999);
                } else
                {
                    setAttribute(background, "fill", "#808000",999);
                    setAttribute(icon, "fill", "#808000",999);
                    setAttribute(border, "stroke", "#808000",999);
                }
                break;
            case art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.STATE_COLORS:
                if (subcontrollerStatus.general.emergency == true)
                {
                    setAttribute(background, "fill", "#FF8000",999);
                    setAttribute(icon, "fill", "#FF8000",999);
                     setAttribute(border, "stroke", "#7C8000",999);
                } 
                else if (subcontrollerStatus.general.control == art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.CONTROL_LOCAL)
                {
                    setAttribute(background, "fill", "#008000",999);
                    setAttribute(icon, "fill", "#008000",999);
                     setAttribute(border, "stroke", "#007C00",999);
                } else
                {
                    setAttribute(background, "fill", "#00FF00", 999);
                    setAttribute(icon, "fill", "#007C00", 999);
                    setAttribute(border, "stroke", "#007C00", 999);
                }
                break;
        }
        
        if (controller.getDeviceAlarms().getServerityAlarm() > 0)
        {
            setAttribute(border, "display", "inline", 999);
            setAttribute(border, "stroke", "#FF0000", 999);
        }
    }
    public void paintNoStatusAvailable()
    {
        art.library.model.devices.colors.controller.M.M_Controller controller = (art.library.model.devices.colors.controller.M.M_Controller) getDevice();
        SVGElement thunderbolt = getElement("Thunderbolt");
        SVGElement emergency = getElement("Emergency");
        SVGElement lock = getElement("Lock");
        SVGElement calendar = getElement("Calendar");
        SVGElement run = getElement("Run");
        SVGElement remote = getElement("Remote");
        SVGElement background = getElement("Background");
        SVGElement border = getElement("Border");
        SVGElement ribbon = getElement("Ribbon");
        SVGElement elapsed1 = getElement("Elapsed1");
        SVGElement elapsed2 = getElement("Elapsed2");
        setAttribute(thunderbolt, "fill-opacity", "1.0", 999);
        setAttribute(emergency, "fill-opacity", "1.0", 999);
        setAttribute(lock, "fill-opacity", "1.0", 999);
        setAttribute(calendar, "fill-opacity", "1.0", 999);
        setAttribute(run, "fill-opacity", "1.0", 999);
        setAttribute(remote, "fill-opacity", "1.0", 999);
        setAttribute(thunderbolt, "fill", "#804080", 999);
        setAttribute(emergency, "fill", "#804080", 999);
        setAttribute(lock, "fill", "#804080", 999);
        setAttribute(calendar, "fill", "#804080", 999);
        setAttribute(run, "fill", "#804080", 999);
        setAttribute(remote, "fill", "#804080", 999);
        setText("Text number", String.format("%05d", controller.getDeviceInformation().number));
        setText("Text information", "");
        setText("Text offset", "");
        setText("Text cycle", "");
        setText("Text elapsed", "");
        setAttribute(elapsed1, "display", "none");
        setAttribute(elapsed2, "display", "none");
        setAttribute(ribbon, "stroke-opacity", 0.50);
        setAttribute(background, "fill", "#FF00FF");
        setAttribute(ribbon, "stroke", "#FF00FF");
        setAttribute(border, "stroke", "#FF00FF");
        setAttribute(border, "display", "inline");
        setAttribute(border, "stroke-width", 6.5);
        setAttribute(border, "stroke-opacity", 1.0);
    }
 
    public void commands()
    {
        final String colorNoCommandsBorder = "#00007C";
        final String colorNoCommandsBackground = "#7C7CFA";
        
        final String colorCommandsBorder = "#007C00";
        final String colorCommandsBackground = "#7CFA7C";
        
        art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller controller = (art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller) getDevice();
        art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation controllerInformation = (art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation) controller.getDeviceInformation();
 
        SVGElement background = getElement("Background");
        SVGElement border = getElement("Border");
        SVGElement icon = getElement("Icon container");
 
        try
        {
            setAttribute(border, "stroke", getDeviceCommands().isEmpty() ? colorNoCommandsBorder : colorCommandsBorder, 999);
            setAttribute(border, "display", "inline", 999);
            setAttribute(background, "fill", getDeviceCommands().isEmpty() ? colorNoCommandsBackground : colorCommandsBackground, 999);
            setAttribute(icon, "fill", getDeviceCommands().isEmpty() ? colorNoCommandsBorder : colorCommandsBorder, 999);
 
            setText("Text number", String.format("%05d", controllerInformation.number));
        } 
        catch (Exception ex){}
 
    }
//    java.io.StringWriter sw = new java.io.StringWriter();
//    art.library.gui.flat.FlatDialog.showDialog(null, "Error", e.getMessage() + "\n\n" + sw.toString(), true, art.library.gui.flat.FlatDialog.DIALOG_ERROR);                        
//    
}