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
115
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceStatus;
import com.kitfox.svg.SVGDiagram;
 
 
public class DeviceGraphicsRuntime_JetFan extends DeviceGraphicsRuntime
{
 
    public DeviceGraphicsRuntime_JetFan(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 = "manual";
            String componentAlarmSymbol = "alarm";
            setAttribute(componentArrowDirect, "display", "none");
            setAttribute(componentArrowReverse, "display", "none");
            setAttribute(componentManSymbol, "display", "none");
            setAttribute(componentHandSymbol, "display", "none");
            setAttribute(componentAlarmSymbol, "display", "none");
            for (int i = 0; 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);
                } 
                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) {}
    }
 
    public void commands()
    {
 
        art.library.model.devices.tunnel.jetfan.JetFanCommands commands = (art.library.model.devices.tunnel.jetfan.JetFanCommands) getDeviceCommands();
 
        String commandBackground = "#9E9E9E";
        String commandWindFlow = "#88A1EB";
 
        setAttribute("direct", "display",(commands.state == art.library.model.devices.tunnel.jetfan.JetFanCommands.STATE_DIRECT) ? "inline" : "none");
        setAttribute("reverse", "display", (commands.state == art.library.model.devices.tunnel.jetfan.JetFanCommands.STATE_REVERSE) ? "inline" : "none");
        setAttribute("restart_hours", "display",  (commands.resetWorkingHours == art.library.model.devices.tunnel.jetfan.JetFanCommands.CONDITION_YES) ? "inline" : "none");
        setAttribute("restart_starts", "display", (commands.resetStartsNumber == art.library.model.devices.tunnel.jetfan.JetFanCommands.CONDITION_YES) ? "inline" : "none");
        setAttribute("restart_stops", "display",  (commands.resetStopsNumber == art.library.model.devices.tunnel.jetfan.JetFanCommands.CONDITION_YES) ? "inline" : "none");
 
        setAttribute("background", "fill", commandBackground);
        setAttribute("direct", "fill", commandWindFlow);
        setAttribute("reverse", "fill", commandWindFlow);
 
    }
//    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);                        
//    
}