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
133
134
135
136
137
138
139
140
141
142
package LightStuds;
 
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
 
public class LightStudsStatusAspect extends DeviceGraphicsRuntime
{
 
    public LightStudsStatusAspect(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    private boolean flashOn = false;
 
    public void timer()
    {
        flashOn = !flashOn;
        status();
    }
    
    public void status()
    {
        try
        {
            art.library.model.devices.Device device = getDevice();
            art.library.model.devices.lighting.lightstuds.LightStudsStatus status = (art.library.model.devices.lighting.lightstuds.LightStudsStatus) device.getDeviceStatus(); art.library.model.devices.lighting.lightstuds.LightStudsAlarms alarms = (art.library.model.devices.lighting.lightstuds.LightStudsAlarms) device.getDeviceAlarms();
        
            setAttribute("light-on", "display", "none", 999);
            setAttribute("Auto", "display", "none", 999);
            setAttribute("Manual", "display", "none", 999);
            
            String lightColor = "#646464";
 
            for (int i = 0; i <= 5; i++)
            {
                setAttribute("alarm-" + i, "display", (alarms.getServerityAlarm() == i) ? "inline" : "none", 999);
            }
 
            if (status.BUSVAO != null)
            {
                switch (status.BUSVAO.status)
                {
                    case art.library.model.devices.lighting.lightstuds.status.LightStudsStatus_BUSVAO.STATUS_MANUAL:
                        setAttribute("light-on", "display", "inline", 999);
                        setAttribute("Manual", "display", "inline", 999);
                        break;
                    case art.library.model.devices.lighting.lightstuds.status.LightStudsStatus_BUSVAO.STATUS_AUTOMATIC:
                        setAttribute("light-on", "display", "inline", 999);
                        setAttribute("Auto", "display", "inline", 999);
                        break;
                }
            }
 
            if (status.BUSVAO.circuits != null)
            {
                for (art.library.model.devices.lighting.lightstuds.status.LightStudsStatus_BUSVAO_Circuit circuit : status.BUSVAO.circuits)
                {
                    if (circuit.status == art.library.model.devices.lighting.lightstuds.status.LightStudsStatus_BUSVAO_Circuit.STATUS_ON)
                    {
                        int brightNessLevel = circuit.brightnessLevel;
 
                        java.awt.Color colorBrightness = new java.awt.Color(60, 60, 0);
 
                        for (int i = 0; i < brightNessLevel; i++)
                        {
                            colorBrightness = colorBrightness.brighter();
                        }
 
                        lightColor = "#" + Integer.toHexString(colorBrightness.getRGB()).substring(2);
                    }
                }
            }
 
            setAttribute("Baliza_izq", "fill", lightColor, 999);
            setAttribute("Baliza_drch", "fill", lightColor, 999);
 
        } catch (Exception ex)
        {
        }
    }
 
    public void commands()
    {
        art.library.model.devices.vms.asf.AsfCommands deviceCommands = (art.library.model.devices.vms.asf.AsfCommands) getDeviceCommands();
        SVGElement arrow = getElement("arrow");
        SVGElement cross = getElement("cross");
        SVGElement arrowRight = getElement("arrow-right");
        SVGElement arrowLeft = getElement("arrow-left");
        SVGElement dynamicElements = getElement("elements");
        setAttribute("lock-on", "display", "inline", 999);
        setAttribute("restart", "display", "inline", 999);
        setAttribute("unlock", "display", "inline", 999);
        setAttribute(dynamicElements, "display", "none", 999);
        SVGElement showElement = null;
        switch (deviceCommands.state)
        {
            case art.library.model.devices.vms.asf.AsfCommands.STATE_ARROW:
                showElement = arrow;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_CROSS:
                showElement = cross;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_OFF:
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_LEFT:
                showElement = arrowLeft;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_RIGHT:
                showElement = arrowRight;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_FLASHING_LEFT:
                showElement = (flashOn) ? arrowLeft : null;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_FLASHING_RIGHT:
                showElement = (flashOn) ? arrowRight : null;
                break;
        }
        if (showElement != null)
        {
            setAttribute(showElement, "display", "inline", 999);
        }
        if (deviceCommands.reset != art.library.model.devices.vms.asf.AsfCommands.CONDITION_YES)
        {
            setAttribute("restart", "display", "none", 999);
        }
        if (deviceCommands.liberate != art.library.model.devices.vms.asf.AsfCommands.CONDITION_YES)
        {
            setAttribute("unlock", "display", "none", 999);
        }
        if (deviceCommands.priority < 256)
        {
            setAttribute("lock-on", "display", "none", 999);
        }
    }
 
//    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);                        
//     
}