df
Alejandro Acuña
2024-09-16 f56295b7f2c7282783589fb4903529b09e161daa
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
package VMSGeneral;
 
 
import art.library.gui.FlatGUI;
import art.library.model.devices.Device;
import art.library.model.devices.DeviceGraphicsRuntime;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
 
public class VmsGeneralKielse extends DeviceGraphicsRuntime
{
 
    public VmsGeneralKielse(art.library.model.devices.Device device, SVGDiagram diagram)
    {
        super(device, diagram);
    }
  
    public VmsGeneralKielse(art.library.model.devices.Device device, art.library.model.devices.DeviceCommands commands, SVGDiagram diagram)
    {
        super(device, commands, diagram);
    }
 
    private boolean flashOn = false;
 
    public void timer()
    {
        flashOn = java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) % 2 == 0;
    }
 
    public void status()
    {
        Device device = getDevice();
        art.library.model.devices.vms.general.VmsGeneralStatus status = (art.library.model.devices.vms.general.VmsGeneralStatus) device.getDeviceStatus();
        
        if(status.lmessage != null && status.lmessage.isEmpty() == false)
        {
            art.library.model.devices.vms.general.status.VmsGeneralStatusMessage message = status.lmessage.get(0);
            
            java.util.List<art.library.vmsboard.BoardStaticText> lTextObjects = message.document.lobject.stream()
                    .filter(obj -> obj instanceof art.library.vmsboard.BoardStaticText)
                    .map(art.library.vmsboard.BoardStaticText.class::cast)
                    .collect(java.util.stream.Collectors.toList());
            
            if (lTextObjects.size() > 0)
            {
                try {
                    com.kitfox.svg.Text svgText = (com.kitfox.svg.Text)getElement("Line-1");
                    com.kitfox.svg.Tspan span = (com.kitfox.svg.Tspan)svgText.getContent().get(0);
                    
                    FlatGUI.setValue("text", "TEST", span);
                    
                } catch (Exception ex) {
                }
            }
            if (lTextObjects.size() > 1)
            {
                setText("Line-2", lTextObjects.get(1).text);
            }
        }
    }
 
    public void commands()
    {
        try
        {
            SVGElement background = getElement("Background");
            SVGElement border = getElement("Border");
 
            if (getDeviceCommands().isEmpty())
            {
                setAttribute(border, "fill", "#00007C", 999);
                setAttribute(background, "fill", "#7C7CFA", 999);
            } else
            {
                setAttribute(border, "fill", "#007C00", 999);
                setAttribute(background, "fill", "#7CFA7C", 999);
            }
        } 
        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);                        
//    
}