asd
Alejandro Acuña
2024-09-16 816cb391a192e357426312ab8e591fd49d1d242e
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
package Pvv;
 
import art.library.model.devices.Device;
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
 
public class PvvCommandsAspect extends DeviceGraphicsRuntime
{
 
    public PvvCommandsAspect(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
 
    public PvvCommandsAspect(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.pvv.PvvCommands deviceCommands = (art.library.model.devices.vms.pvv.PvvCommands) getDeviceCommands();
        SVGElement circle = getElement("circle");
        SVGElement text1 = getElement("text_1");
        SVGElement text2 = getElement("text_2");
        SVGElement flashes = getElement("flashes");
        SVGElement lock = getElement("lock");
        SVGElement unlock = getElement("unlock");
        SVGElement restart = getElement("restart");
        SVGElement elements = getElement("elements");
        setAttribute(elements, "display", "none", 999);
        setAttribute(restart, "display", "inline", 999);
        setAttribute(unlock, "display", "inline", 999);
        setAttribute(lock, "display", "inline", 999);
        setAttribute("lock-off", "display", "none", 999);
        boolean overrideFlash = false;
        boolean overrideSpeed = false;
        boolean overrideCircle = false;
        SVGElement selectedText = null;
        if (deviceCommands.message != null)
        {
            art.library.model.devices.vms.pvv.commands.PvvCommandsMessage message = (art.library.model.devices.vms.pvv.commands.PvvCommandsMessage) deviceCommands.message;
            selectedText = ((message.speed > 9 && message.speed < 20) || message.speed > 99) ? text1 : text2;
            setText(text1, String.valueOf(message.speed));
            setText(text2, String.valueOf(message.speed));
            setAttribute(circle, "display", "inline", 999);
            setAttribute(selectedText, "display", "inline", 999);
            if (message.blinkings != null)
            {
                if (message.blinkings.blinkingCircle == art.library.model.devices.vms.pvv.PvvCommands.CONDITION_YES)
                {
                    overrideCircle = !flashOn;
                    setAttribute(circle, "display", ((flashOn) ? "inline" : "none"), 999);
                }
                if (message.blinkings.blinkingFlashes == art.library.model.devices.vms.pvv.PvvCommands.CONDITION_YES)
                {
                    overrideFlash = !flashOn;
                    setAttribute(flashes, "display", ((flashOn) ? "inline" : "none"), 999);
                }
                if (message.blinkings.blinkingSpeed == art.library.model.devices.vms.pvv.PvvCommands.CONDITION_YES)
                {
                    overrideSpeed = !flashOn;
                    setAttribute(selectedText, "display", ((flashOn) ? "inline" : "none"), 999);
                }
            }
            if (message.visibilities != null)
            {
                if (!overrideCircle)
                {
                    setAttribute(circle, "display", "inline", 999);
                }
                if (!overrideFlash)
                {
                    setAttribute(flashes, "display", "inline", 999);
                }
                if (!overrideSpeed)
                {
                    setAttribute(selectedText, "display", "inline", 999);
                }
                if (!message.visibilities.visibilityCircle)
                {
                    setAttribute(circle, "display", "none", 999);
                }
                if (!message.visibilities.visibilityFlashes)
                {
                    setAttribute(flashes, "display", "none", 999);
                }
                if (!message.visibilities.visibilitySpeed)
                {
                    setAttribute(selectedText, "display", "none", 999);
                }
            }
        }
        if (deviceCommands.reset != art.library.model.devices.vms.pvv.PvvCommands.CONDITION_YES)
        {
            setAttribute(restart, "display", "none", 999);
        }
        if (deviceCommands.liberate != art.library.model.devices.vms.pvv.PvvCommands.CONDITION_YES)
        {
            setAttribute(unlock, "display", "none", 999);
            setAttribute("lock-off", "display", "inline", 999);
        }
        if (deviceCommands.message == null)
        {
            setAttribute(selectedText, "display", "none", 999);
            setAttribute(flashes, "display", "none", 999);
            setAttribute(circle, "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);                        
//     
}