Alejandro Acuña
2024-07-30 65a64a81d30f00f1fffd5da6866850e1308e1135
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
package Rtz;
 
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
public class RtzMap extends DeviceGraphicsRuntime
{
 
    public RtzMap(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
  
    public RtzMap(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands commands, SVGDiagram diagram)
    {
        super(device, commands, diagram);
    }
 
    private boolean flashOn = false;
 
    public void timer()
    {
        status();
    }
 
    public void status()
    {
        flashOn = java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) % 2 == 0;
      
        Device device = getDevice();
        art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation information = (art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation) device.getDeviceInformation();
        art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerStatus status = (art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerStatus) device.getDeviceStatus();
        
        art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General statusGeneral = status.rtz32.general;
  
        SVGElement background = getElement("Background");
        SVGElement border = getElement("Border");
        
        setAttribute(border, "display", "inline",999);
        setAttribute(background, "display", "inline", 999);
        
        if (information.mode == art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerInformation.MODE_NON_CENTRALIZED)
        {
            setAttribute(border, "fill", "#FFFFFF",999);
            setAttribute(background, "fill", "#FFFFFF",999);
        }
        else
        {
            if (status.rtz32.centralized.centralized == false)
            {
                setAttribute(border, "fill", "#808080", 999);
                setAttribute(background, "fill", "#808080", 999);
            } 
            else
            {
                boolean semiactuated = status.rtz32.general.semiactuated ;
                boolean offline = false;
                
                if (device.getAlarm("alarm_controller_offline") > 0 || device.getAlarm("alarm_offline") > 0)
                {
                    offline = true;
                    setAttribute(border, "display", flashOn ? "inline" : "none", 999);
                    setAttribute(background, "display", flashOn ? "inline" : "none", 999);
                }
                
                if (status.rtz32.general.control == art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.CONTROL_COMPUTER)
                {
                    setAttribute(border, "fill", "#00FF00", 999);
                    setAttribute(background, "fill", "#00FF00", 999);
                    
                    if(offline == true)
                    {
                        setAttribute(background, "display", flashOn || semiactuated ? "none" : "inline", 999);
                        setAttribute(border, "display", flashOn ? "none" : "inline", 999);
                    }
                }
                else if (status.rtz32.general.control == art.library.model.devices.colors.controller.RTZ32.status.RTZ32_Status_General.CONTROL_LOCAL)
                {
                    setAttribute(border, "fill", "#FF0000", 999);
                    setAttribute(background, "fill", "#FF0000", 999);
                   
                    if (offline == true)
                    {
                        setAttribute(background, "display", flashOn || semiactuated ? "none" : "inline", 999);
                        setAttribute(border, "display", flashOn ? "none" : "inline", 999);
                    }
                }
 
                if (device.getAlarm("alarm_controller_offline") <= 0 && device.getAlarm("alarm_offline") <= 0)
                {
                    if (art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller.class.cast(device).getDeviceAlarms().rtz32.flashing.getServerityAlarm() > 0)
                    {
                        setAttribute(border, "fill", "#FFFF00", 999);
                        setAttribute(background, "fill", "#FFFF00", 999);
                        setAttribute(border, "display", flashOn ? "inline" : "none", 999);
                        setAttribute(background, "display", flashOn ? "inline" : "none", 999);
                        
                        if(semiactuated)
                            setAttribute(background, "display","none", 999);
                    }
                }
            }
        }
    }
 
    public void commands()
    {
        try
        {
            SVGElement background = getElement("Background");
            SVGElement border = getElement("Border");
 
            if (getDeviceCommands().isEmpty())
            {
                setAttribute(border, "fill", "#00007C", 999);
                setAttribute(background, "fill", "#7C7CFA", 999);
            } else
            {
               setAttribute(border, "fill", "#007C00", 999);
                setAttribute(background, "fill", "#7CFA7C", 999);
            }
        } 
        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);                        
//    
}