Alejandro Acuña
2024-08-12 831c7bd85763b5eb5ef46664c65f0181824f9e13
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
package Asf;
 
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
 
public class DeviceGraphicsRuntime_Asf_action_aspect extends DeviceGraphicsRuntime
{
 
    public DeviceGraphicsRuntime_Asf_action_aspect(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
        {
            Device device = getDevice();
            art.library.model.devices.vms.asf.AsfStatus status = (art.library.model.devices.vms.asf.AsfStatus) device.getDeviceStatus();
            art.library.model.devices.vms.asf.AsfAlarms alarms = (art.library.model.devices.vms.asf.AsfAlarms) device.getDeviceAlarms();
            art.library.model.devices.vms.asf.AsfConfiguration configuration = (art.library.model.devices.vms.asf.AsfConfiguration) device.getDeviceConfiguration();
            SVGElement arrow = getElement("arrow");
            SVGElement cross = getElement("cross");
            SVGElement arrowRight = getElement("arrow-right");
            SVGElement arrowLeft = getElement("arrow-left");
            SVGElement dynamicElements = getElement("elements");
            setAttribute(dynamicElements, "display", "none", 999);
            for (int i = 0; i <= 5; i++)
            {
                setAttribute("alarm-" + i, "display", (alarms.getServerityAlarm() == i) ? "inline" : "none", 999);
            }
            setAttribute("lock-on", "display", "inline", 999);
            setAttribute("brightness-icon-on", "display", "inline", 999);
            setAttribute("lock-on", "display", "inline", 999);
            setAttribute("lock-off", "display", "inline", 999);
            setAttribute("light-on", "display", "inline", 999);
            setAttribute("Auto", "display", "inline", 999);
            setAttribute("Manual", "display", "inline", 999);
            SVGElement showElement = null;
            switch (status.state)
            {
                case art.library.model.devices.vms.asf.AsfStatus.STATE_ARROW:
                    showElement = arrow;
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_CROSS:
                    showElement = cross;
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_OFF:
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_LEFT:
                    showElement = arrowLeft;
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_RIGHT:
                    showElement = arrowRight;
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_FLASHING_LEFT:
                    showElement = (flashOn) ? arrowLeft : null;
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_FLASHING_RIGHT:
                    showElement = (flashOn) ? arrowRight : null;
                    break;
            }
            if (showElement != null)
            {
                setAttribute(showElement, "display", "inline", 999);
            }
            if (status.priority < 256)
            {
                setAttribute("lock-on", "display", "none", 999);
            }
            switch (configuration.brightnessMode)
            {
                case art.library.model.devices.vms.asf.AsfConfiguration.BRIGHTNESS_MODE_AUTO:
                    setAttribute("Manual", "display", "none", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfConfiguration.BRIGHTNESS_MODE_MANUAL:
                    setAttribute("Auto", "display", "none", 999);
                    break;
                default:
                    setAttribute("Auto", "display", "none", 999);
                    setAttribute("Manual", "display", "none", 999);
                    setAttribute("light-on", "display", "none", 999);
                    break;
            }
        } 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);                        
//     
}