Alejandro Acuña
2024-08-12 1876e65234c20209001178705cfa50d8f9ded67a
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
 
import com.kitfox.svg.SVGDiagram;
 
public class DeviceGraphicsRuntime_Inforpark_VmsBanner_Actions extends DeviceGraphicsRuntime {
 
    public DeviceGraphicsRuntime_Inforpark_VmsBanner_Actions(art.library.model.devices.Device device, SVGDiagram diagram) {
        super(device, diagram);
    }
 
    private int position = 0;
 
    public void timer()
    {
        try 
        {
            art.library.model.devices.vms.banner.BannerCommands deviceCommands = (art.library.model.devices.vms.banner.BannerCommands) getDeviceCommands();
            String text = deviceCommands.rotulosElectronicos.text;
            int fontlength = 10;
            if (deviceCommands.rotulosElectronicos.fontSize == 2) 
            {
                fontlength = 8;
            }
            if (text.length() > fontlength)
            {
                position = position + 1;
                if (position >= text.length())
                {
                    position = 0;
                }
                commands();
                return;
            }
        }
        catch (Exception e) 
        {
        }
        position = 0;
    }
 
    public void commands() 
    {
        try {
            art.library.model.devices.vms.banner.BannerCommands deviceCommands = (art.library.model.devices.vms.banner.BannerCommands) getDeviceCommands();
            String foreground = "#000000";
            try {
                setAttribute("Font-12-Center", "display", "none");
                setAttribute("Font-12-Left", "display", "none");
                setAttribute("Font-12-Right", "display", "none");
                setAttribute("Font-16-Center", "display", "none");
                setAttribute("Font-16-Left", "display", "none");
                setAttribute("Font-16-Right", "display", "none");
                setAttribute("Auto", "display", "none");
                setAttribute("Reboot", "display", "none");
                setAttribute("lblObert", "display", "none");
                setAttribute("lblTancat", "display", "none");
                
                switch (deviceCommands.operationMode)
                {
                    case art.library.model.devices.vms.banner.BannerCommands.OPERATION_AUTOMATIC:
                        setAttribute("Auto", "display", "inline");
                        position = 0;
                        break;
                    case art.library.model.devices.vms.banner.BannerCommands.OPERATION_MANUAL:
                        setAttribute("Manual", "display", "inline");
                        break;
                }
                switch (deviceCommands.reset)
                {
                    case art.library.model.devices.vms.banner.BannerCommands.CONDITION_YES:
                        setAttribute("Reboot", "display", "inline");
                        position = 0;
                        break;
                }
              
                switch(deviceCommands.state)
                {
                  
                    case art.library.model.devices.vms.banner.BannerCommands.STATE_OPEN: 
                           setAttribute("lblObert", "display", "inline");
                        break;
                
                    case art.library.model.devices.vms.banner.BannerCommands.STATE_CLOSE: 
                          setAttribute("lblTancat", "display", "inline");
                        break;
                
                }
                if (deviceCommands.rotulosElectronicos != null) 
                {
                    switch (deviceCommands.rotulosElectronicos.foreground) 
                    {
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_BLUE:
                            foreground = "#0000FF";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_CYAN:
                            foreground = "#00FFFF";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_GREEN:
                            foreground = "#00FF00";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_PURPLE:
                            foreground = "#FF00FF0";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_RED:
                            foreground = "#FF0000";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_WHITE:
                            foreground = "#FFFFFF";
                            break;
                        case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.COLOR_YELLOW:
                            foreground = "#FFFF00";
                            break;
                        default:
                            foreground = "#FFFFFF";
                            break;
                    }
                }
            }
            catch (Exception e) 
            {
            }
            try 
            {
                if (deviceCommands.rotulosElectronicos != null && deviceCommands.operationMode == art.library.model.devices.vms.banner.BannerCommands.OPERATION_MANUAL) {
                    String fontsize = "Font-12-Center";
                    int fontlength = 10;
                    if (deviceCommands.rotulosElectronicos.fontSize == 2) {
                        fontsize = "Font-16-Center";
                        fontlength = 8;
                    }
                    String text = deviceCommands.rotulosElectronicos.text;
                    if (text.length() > fontlength) {
                        if (position > 0) {
                            text = text + "   " + deviceCommands.rotulosElectronicos.text;
                        }
                        text = text.substring(position, Math.min(position + fontlength, text.length()));
                        setText(fontsize, text);
                    } else {
                        switch (deviceCommands.rotulosElectronicos.horizontalAlignment) {
                            case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.ALIGNMENT_HORIZONTAL_LEFT:
                                fontsize = fontsize = "Font-" + fontsize.split("-")[1] + "-Left";
                                break;
                            case art.library.model.devices.vms.banner.status.BannerRotulosElectronicosStatus.ALIGNMENT_HORIZONTAL_RIGHT:
                                fontsize = "Font-" + fontsize.split("-")[1] + "-Right";
                                break;
                            default:
                                fontsize = "Font-" + fontsize.split("-")[1] + "-Center";
                                break;
                        }
                        setText(fontsize, text);
                    }
                    setAttribute(fontsize, "fill", foreground);
                    setAttribute(fontsize, "display", "inline");
                }
            } catch (Exception e) {
            }
        } catch (Exception e) {
        }
    }
 
//    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);                        
//    
}