Alejandro Acuña
2024-10-25 e51f4a713ed6e744c203c9493165584728a29c52
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
package JetFan;
 
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceGraphicsRuntime;
import art.library.model.devices.DeviceStatus;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
 
public class DeviceGraphicsRuntime_JetFan_status_aspect extends DeviceGraphicsRuntime
{
 
    public DeviceGraphicsRuntime_JetFan_status_aspect(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    public void status()
    {
        try
        {
            Device device = getDevice();
            art.library.model.devices.tunnel.jetfan.JetFanStatus status = (art.library.model.devices.tunnel.jetfan.JetFanStatus) device.getDeviceStatus();
            art.library.model.devices.tunnel.jetfan.JetFanAlarms alarms = (art.library.model.devices.tunnel.jetfan.JetFanAlarms) device.getDeviceAlarms();
            String background = "#FF00FF";
            String startingColor = "#ffff00";
            String componentBackground = "background";
            String componentArrowDirect = "direct";
            String componentArrowReverse = "reverse";
            String componentManSymbol = "man";
            String componentHandSymbol = "hand";
            String componentAlarmSymbol = "alarm";
            setAttribute(componentArrowDirect, "display", "none");
            setAttribute(componentArrowReverse, "display", "none");
            setAttribute(componentManSymbol, "display", "none");
            setAttribute(componentHandSymbol, "display", "none");
            setAttribute(componentAlarmSymbol, "display", "none");
            setAttribute(componentBackground, "display", "inline");
            for (int i = 0; i <= 5; i++)
            {
                setAttribute("Alarm_" + i, "display", "none");
            }
            if (status.status != DeviceStatus.STATUS_OFFLINE)
            {
                for (int i = 1; i <= 5; i++)
                {
                    setAttribute("Alarm_" + i, "display", (alarms.getServerityAlarm() == i) ? "inline" : "none");
                }
            }
            try
            {
                switch (status.status)
                {
                    case DeviceStatus.STATUS_ONLINE:
                        background = "#00FF00";
                        break;
                    case DeviceStatus.STATUS_WARNING:
                        background = "#FFFF00";
                        break;
                    case DeviceStatus.STATUS_ALARM:
                        background = "#FF0000";
                        break;
                    case DeviceStatus.STATUS_INVALID:
                        background = "#B97A57";
                        break;
                    case DeviceStatus.STATUS_DISABLE:
                        background = "#808080";
                        break;
                    case DeviceStatus.STATUS_SIMULATION:
                        background = "#0000FF";
                        break;
                    case DeviceStatus.STATUS_OFFLINE:
                        background = "#FF00FF";
                        break;
                    case DeviceStatus.STATUS_UNKNOWN:
                        background = "#FF00FF";
                        break;
                }
                if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_DIRECT)
                {
                    setAttribute(componentArrowDirect, "display", "inline");
                    setAttribute(componentArrowDirect, "fill", background);
                } else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_REVERSE)
                {
                    setAttribute(componentArrowReverse, "display", "inline");
                    setAttribute(componentArrowReverse, "fill", background);
                } else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_DIRECT_STARTING_TIMING)
                {
                    setAttribute(componentArrowDirect, "display", "inline");
                    setAttribute(componentArrowDirect, "fill", startingColor);
                } else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_REVERSE_STARTING_TIMING)
                {
                    setAttribute(componentArrowReverse, "display", "inline");
                    setAttribute(componentArrowReverse, "fill", startingColor);
                } else if (status.state == art.library.model.devices.tunnel.jetfan.JetFanStatus.JETFAN_STATE_OFF_STARTING_TIMING)
                {
                      background = startingColor;
                }
                setAttribute(componentHandSymbol, "display", (alarms.alarm_manual_control > 0) ? "inline" : "none");
                setAttribute(componentManSymbol, "display", (alarms.alarm_local_control > 0) ? "inline" : "none");
                setAttribute(componentManSymbol, "fill", "#" + Integer.toHexString(java.awt.Color.decode(background).darker().darker().getRGB()).substring(2));
                setAttribute(componentBackground, "fill", background);
            } catch (Exception e)
            {
            }
        } 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);                        
//    
}