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
package Asf;
 
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
 
public class AsfCommandsAspect extends DeviceGraphicsRuntime
{
 
    public AsfCommandsAspect(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    public AsfCommandsAspect(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands deviceCommands, SVGDiagram diagram)
    {
        super(device, deviceCommands, diagram);
    }
 
  private boolean flashOn = false;
    public void timer()
    {
        flashOn = !flashOn;
        commands();
    }
    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 s52_left = getElement("s52_left");
        SVGElement textBUS = getElement("BUS");
        SVGElement dynamicElements = getElement("elements");
        setAttribute("lock", "display", "inline", 999);
        setAttribute("restart", "display", "inline", 999);
        setAttribute("unlock", "display", "inline", 999);
        setAttribute("lock-off", "display", "inline", 999);
        setAttribute(dynamicElements, "display", "none", 999);
        setAttribute(textBUS, "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_S52_LEFT:
                showElement = s52_left;
                break;
            case art.library.model.devices.vms.asf.AsfCommands.STATE_BUS:
                showElement = textBUS;
                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);
        } else
        {
            setAttribute("lock-off", "display", "none", 999);
        }
        if (deviceCommands.priority < 256)
        {
            setAttribute("lock", "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);                        
//     
}