Alejandro Acuña
2024-10-22 9214c4e5cec380dc263034f9a0e5a10f0dc1ebac
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
package Meteo;
 
 
import Bollard.*;
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 MeteoMap extends DeviceGraphicsRuntime
{
 
    public MeteoMap(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    public void status()
    {
        try
        {
            art.library.model.devices.Device device = getDevice();
            String color1 = "#000000";
            String color2 = "#000000";
            art.library.model.devices.meteo.MeteoStatus status = (art.library.model.devices.meteo.MeteoStatus) device.getDeviceStatus();
            art.library.model.devices.meteo.MeteoAlarms alarms = (art.library.model.devices.meteo.MeteoAlarms) device.getDeviceAlarms();
            switch (device.getDeviceStatus().status)
            {
                case art.library.model.devices.DeviceStatus.STATUS_ONLINE:
                    color1 = "#00FF00";
                    color2 = "#007C00";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_WARNING:
                    color1 = "#FFFF00";
                    color2 = "#7C7C00";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_ALARM:
                    if (alarms.hasAlarmNoWeather() == true)
                    {
                        color1 = "#FF0000";
                        color2 = "#7C0000";
                    } else
                    {
                        color1 = "#00FF00";
                        color2 = "#007C00";
                    }
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_INVALID:
                    color1 = "#B97A57";
                    color2 = "#5A3B2A";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_DISABLE:
                    color1 = "#7C7C7C";
                    color2 = "#3E3E3E";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_SIMULATION:
                    color1 = "#0000FF";
                    color2 = "#00007C";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_OFFLINE:
                    color1 = "#FF00FF";
                    color2 = "#7C007C";
                    break;
                case art.library.model.devices.DeviceStatus.STATUS_UNKNOWN:
                    color1 = "#FF00FF";
                    color2 = "#7C007C";
                    break;
            }
            setAttribute("Present weather clear", "display", "none");
            setAttribute("Present weather wind", "display", "none");
            setAttribute("Present weather fog", "display", "none");
            setAttribute("Present weather rain", "display", "none");
            setAttribute("Present weather snow", "display", "none");
            setAttribute("Present weather snow and rain", "display", "none");
            setAttribute("Present weather unknown", "display", "none");
            if (alarms.hasAlarmWeather() == true)
            {
                setAttribute("Aura", "display", "inline");
                setAttribute("Aura", "fill", "#FF0000");
            } else
            {
                setAttribute("Aura", "display", "none");
            }
            setAttribute("Background", "fill", color1);
            setAttribute("Border", "stroke", color2);
            setText("Information text", String.format("%1$04d", device.getDeviceInformation().number));
            switch (status.getPresentWeather())
            {
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_CLEAR:
                    setAttribute("Present weather clear", "display", "inline");
                    setAttribute("Present weather clear", "fill", color2);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_WIND:
                    setAttribute("Present weather wind", "display", "inline");
                    setAttribute("Present weather wind", "fill", color2);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_FOG:
                    setAttribute("Present weather fog", "display", "inline");
                    setAttribute("Present weather fog", "fill", color2);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_RAIN:
                    setAttribute("Present weather rain", "display", "inline");
                    setAttribute("Present weather rain", "fill", color2, 1);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_SNOW_RAIN:
                    setAttribute("Present weather snow and rain", "display", "inline");
                    setAttribute("Present weather snow and rain", "fill", color2);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_SNOW:
                    setAttribute("Present weather snow", "display", "inline");
                    setAttribute("Present weather snow", "fill", color2);
                    break;
                case art.library.model.devices.meteo.status.MeteoStatusSensor.VALUE_PRESENT_WEATHER_UNKNOWN:
                    setAttribute("Present weather clear", "display", "inline");
                    setAttribute("Present weather clear", "fill", "#800080");
                    break;
            }
        } catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
 
    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);                        
//    
}