Alejandro Acuña
2024-09-16 adba74e107bcda9e1cb510bc14364b02e781baef
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 Asf;
 
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceCommands;
import art.library.model.devices.DeviceGraphicsRuntime;
import art.library.model.devices.DeviceStatus;
import com.kitfox.svg.SVGDiagram;
 
public class AsfMap extends DeviceGraphicsRuntime
{
 
    public AsfMap(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    private boolean flashOn = false;
 
    public void timer()
    {
        flashOn = !flashOn;
        status();
    }
 
    public void status()
    {
        Device device = getDevice();
        art.library.model.devices.vms.asf.AsfStatus status = (art.library.model.devices.vms.asf.AsfStatus) device.getDeviceStatus();
        art.library.model.devices.DeviceAlarms alarms = (art.library.model.devices.DeviceAlarms) device.getDeviceAlarms();
        String color1 = "#000000";
        String color2 = "#000000";
        setAttribute("arrow-down", "display", "none", 999);
        setAttribute("arrow-left", "display", "none", 999);
        setAttribute("arrow-right", "display", "none", 999);
        setAttribute("cross", "display", "none", 999);
        setAttribute("s52-left", "display", "none", 999);
        setAttribute("bus", "display", "none", 999);
        long alarm_warning_value = device.getAlarm("alarm_warning_value");
        long alarm_alarm_value = device.getAlarm("alarm_alarm_value");
        if (alarm_alarm_value > 0)
        {
            color1 = "#FF0000";
            color2 = "#7C0000";
        } else if (alarm_warning_value > 0)
        {
            color1 = "FFFF7C";
            color2 = "FFFF00";
        } else
        {
            color1 = "#00FF00";
            color2 = "#007C00";
        }
        switch (status.status)
        {
            case DeviceStatus.STATUS_ALARM:
                color1 = "#FF0000";
                color2 = "#7C0000";
                break;
            case DeviceStatus.STATUS_SIMULATION:
                color1 = "#7C7C7C";
                color2 = "#3E3E3E";
                break;
            case DeviceStatus.STATUS_DISABLE:
                color1 = "#0000FF";
                color2 = "#00007C";
                break;
            case DeviceStatus.STATUS_UNKNOWN:
                setAttribute("alarm", "display", "none", 999);
                setAttribute("arrow-down", "fill", color2, 999);
                break;
            case DeviceStatus.STATUS_OFFLINE:
                color1 = "#FF00FF";
                color2 = "#7C007C";
                setAttribute("alarm", "display", "none", 999);
                setAttribute("arrow-down", "fill", color2, 999);
                break;
        }
        if (status.status != DeviceStatus.STATUS_OFFLINE && status.status != DeviceStatus.STATUS_UNKNOWN)
        {
            switch (status.state)
            {
                case art.library.model.devices.vms.asf.AsfStatus.STATE_ARROW:
                    setAttribute("arrow-down", "display", "inline", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_CROSS:
                    setAttribute("cross", "display", "inline", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_FLASHING_LEFT:
                     setAttribute("arrow-left", "display",flashOn ? "inline" : "none", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_LEFT:
                    setAttribute("arrow-left", "display", "inline", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_FLASHING_RIGHT:
                       setAttribute("arrow-right", "display", flashOn ? "inline" : "none", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_RIGHT:
                    setAttribute("arrow-right", "display", "inline", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_BUS:
                    setAttribute("bus", "display", "inline", 999);
                    break;
                case art.library.model.devices.vms.asf.AsfStatus.STATE_S52_LEFT:
                    setAttribute("s52-left", "display", "inline", 999);
                    break;
            }
        } 
        
        setAttribute("background", "fill", color1, 999);
        setAttribute("border", "stroke", color2, 999);
        setAttribute("arrow-down", "fill", color2, 999);
        setAttribute("arrow-left", "fill", color2, 999);
        setAttribute("arrow-right", "fill", color2, 999);
        setAttribute("cross", "fill", color2, 999);
        setAttribute("s52-left", "fill", color2, 999);
        setAttribute("bus", "fill", color2, 999);
        setAttribute("Icon", "fill", color2, 999);
        setAttribute("alarm", "stroke", color1, 999);
              setText("Information text", String.format("%1$04d", device.getDeviceInformation().number));
        setAttribute(getElement("alarm"), "stroke-width", device.getServerityAlarm(), 999);
    }
 
    public void commands()
    {
        DeviceCommands deviceCommands = getDeviceCommands();
        String color1 = "#0000FF";
        String color2 = "#00007C";
        if (!deviceCommands.isEmpty())
        {
            color1 = "#00FF00";
            color2 = "#007C00";
        }
        setText("Information text", String.valueOf(device.getDeviceInformation().number));
        setAttribute("text", "display", "none", 999);
        setAttribute(getElement("alarm"), "stroke-width", 0, 999);
        setAttribute("Border", "stroke", color2);
    }
//    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);                        
//    
}