as
Alejandro Acuña
2025-01-21 61cdfc6ee7f013c4533add51d797c1886b312883
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
package art.servers.pvvserver.protocols.dgt;
 
import art.library.model.devices.vms.general.VmsGeneral;
 
public class PvvDgtProtocolConstructor
{
 
    public PvvDgtProtocolConstructor()
    {
    }
 
    public static byte[] ORDCC(VmsGeneral device) throws Exception
    {
        return new byte[0];
    }
 
    /**
     * PVV status query.
     */
    public static byte[] readAlarms(int address) throws Exception
    {
 
        PvvDgtPDU requestAlarms = new PvvDgtPDU();
        requestAlarms.stx = PvvDgtConstants.PVV_STX;
        requestAlarms.etx = PvvDgtConstants.PVV_ETX;
        requestAlarms.address = address;
        requestAlarms.function = PvvDgtConstants.STR_PPVV_ALR;
        requestAlarms.information = new int[0];
        byte[] send = requestAlarms.createMessage();
        return (send);
    }
 
    /**
     * PVV configuration query.
     */
    public static byte[] readConfiguration(int address) throws Exception
    {
 
        PvvDgtPDU requestConfiguration = new PvvDgtPDU();
        requestConfiguration.stx = PvvDgtConstants.PVV_STX;
        requestConfiguration.etx = PvvDgtConstants.PVV_ETX;
        requestConfiguration.address = address;
        requestConfiguration.function = PvvDgtConstants.STR_PPVV_PP;
        requestConfiguration.information = new int[0];
        byte[] send = requestConfiguration.createMessage();
        return (send);
    }
 
    /**
     * PVV message query.
     */
    public static byte[] readMessage(int address) throws Exception
    {
 
        PvvDgtPDU requestConfiguration = new PvvDgtPDU();
        requestConfiguration.stx = PvvDgtConstants.PVV_STX;
        requestConfiguration.etx = PvvDgtConstants.PVV_ETX;
        requestConfiguration.address = address;
        requestConfiguration.function = PvvDgtConstants.STR_PPVV_EP;
        requestConfiguration.information = new int[0];
        byte[] send = requestConfiguration.createMessage();
        return (send);
    }
 
    public static int getBrightnessDGTLevel(int input, int maximum)
    {
        // Input is a 0-100 value
        if (input > 100)
        {
            input = 100;
        }
 
        if (input < 0)
        {
            input = 0;
        }
        return ((int) Math.round(((float) input * (float) maximum) / 100f));
    }
 
    public static int getBrightnessClientLevel(int input, int maximum, int maximumVms)
    {
        // Input is a 0-7 value
        int result = (int) Math.round(((float) input * (float) maximum) / (float) maximumVms);
        if (result > 100)
        {
            result = 100;
        }
        return (result);
    }
}