DELL
2024-05-21 b3c0ad2b00c503efaf2e8ef8ac930c8823c08324
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.dev.simpower.dev;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
 
import com.dev.bts.data.FBS9100_ComBase;
 
/**
 *     ¼«¼ò»¯µçÔ´·Öʱ¿ØÖƲÎÊý
 * @author DELL
 *
 */
public class Power_TimeControl {
    public static final int REG_Count                 = 14 * 6;
    
    public static final int Total_Load_Count         = 12;            //×Ü·Êý
 
    public static final int Total_Load_Count_Sigle     = 6;            //µ¥´ÎÉèÖ÷Êý
        
    public TimeControl[] timeControls = new TimeControl[Total_Load_Count];
    
    public Power_TimeControl() {
        for(int i = 0;i<timeControls.length;i++) {
            timeControls[i] = new TimeControl();
        }
    }
    
    
    public boolean putByteBuffer1(ByteBuffer bbf_rx) {
        if(bbf_rx.limit() < REG_Count * 2) {
            return false;
        }
        bbf_rx.position(0);
        
        for(int k = 0;k<Total_Load_Count_Sigle;k++) {
            timeControls[k].putTimeByteBuffer(bbf_rx);
        }
        
        bbf_rx.compact();
        bbf_rx.flip();
        
        return true;
    }
    
    public ByteBuffer getByteBuffer1() {
        ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
        buffer.order(ByteOrder.BIG_ENDIAN);
        buffer.position(0);
        
        for(int k = 0;k<Total_Load_Count_Sigle;k++) {
            buffer.put(timeControls[k].getTimeByteBuffer());
        }
        
        buffer.flip();
        return buffer;
    }
    
    public boolean putByteBuffer2(ByteBuffer bbf_rx) {
        if(bbf_rx.limit() < REG_Count * 2) {
            return false;
        }
        bbf_rx.position(0);
        
        for(int k = Total_Load_Count_Sigle;k<timeControls.length;k++) {
            timeControls[k].putTimeByteBuffer(bbf_rx);
        }
        
        bbf_rx.compact();
        bbf_rx.flip();
        
        return true;
    }
    
    public ByteBuffer getByteBuffer2() {
        ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
        buffer.order(ByteOrder.BIG_ENDIAN);
        buffer.position(0);
        
        for(int k = Total_Load_Count_Sigle;k<timeControls.length;k++) {
            buffer.put(timeControls[k].getTimeByteBuffer());
        }
        
        buffer.flip();
        return buffer;
    }
    
    public class TimeControl{
        public static final int REG_Count = 14;
        
        public int time_close_en;                //3000    ·Ö·1¶¨Ê±¹Ø¶ÏʹÄÜ    1£ºÊ¹Äܶ¨Ê±¹Ø¶Ï
        public int time_close_year;                //3001    ·Ö·1¹Ø¶Ïʱ¼ä¡ªÄê    0~100£¬Àý£º2024Ä꣬2024-2000=24
        public int time_close_month;            //3002    ·Ö·1¹Ø¶Ïʱ¼ä¡ªÔ    
        public int time_close_day;                //3003    ·Ö·1¹Ø¶Ïʱ¼ä¡ªÈÕ    
        public int time_close_hour;                //3004    ·Ö·1¹Ø¶Ïʱ¼ä¡ªÊ±    
        public int time_close_minute;            //3005    ·Ö·1¹Ø¶Ïʱ¼ä¡ª·Ö    
        public int time_close_second;            //3006    ·Ö·1¹Ø¶Ïʱ¼ä¡ªÃë    
        
        public int time_repetcomm_en;            //3007    ·Ö·1¶¨Ê±¸´Í¨Ê¹ÄÜ    
        public int time_repetcomm_year;            //3008    ·Ö·1¸´Í¨Ê±¼ä¡ªÄê    0~100£¬Àý£º2024Ä꣬2024-2000=24
        public int time_repetcomm_month;        //3009    ·Ö·1¸´Í¨Ê±¼ä¡ªÔ    
        public int time_repetcomm_day;            //3010    ·Ö·1¸´Í¨Ê±¼ä¡ªÈÕ    
        public int time_repetcomm_hour;            //3011    ·Ö·1¸´Í¨Ê±¼ä¡ªÊ±    
        public int time_repetcomm_minute;        //3012    ·Ö·1¸´Í¨Ê±¼ä¡ª·Ö    
        public int time_repetcomm_second;        //3013    ·Ö·1¸´Í¨Ê±¼ä¡ªÃë    
        
        public TimeControl() {
            
        }
        
        public boolean putTimeByteBuffer(ByteBuffer bbf_rx) {
            if(bbf_rx.limit() < REG_Count * 2) {
                return false;
            }
            bbf_rx.position(0);
            this.time_close_en = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());
            this.time_close_year = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()) + 2000;            //2800    Äê    0~100£¬Àý£º2024Ä꣬2024-2000=24
            this.time_close_month = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                //2801    Ô    
            this.time_close_day = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                    //2802    ÈÕ    
            this.time_close_hour = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                    //2803    Ê±    
            this.time_close_minute = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                //2804    ·Ö    
            this.time_close_second = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                //2805    Ãë    
            
            this.time_repetcomm_en = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());
            this.time_repetcomm_year = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()) + 2000;        //2800    Äê    0~100£¬Àý£º2024Ä꣬2024-2000=24
            this.time_repetcomm_month = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());            //2801    Ô    
            this.time_repetcomm_day = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());                //2802    ÈÕ    
            this.time_repetcomm_hour = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());            //2803    Ê±    
            this.time_repetcomm_minute = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());            //2804    ·Ö    
            this.time_repetcomm_second = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());            //2805    Ãë    
            
            bbf_rx.compact();
            bbf_rx.flip();
            
            
            System.err.println(this);
            return true;
        }
        
        public ByteBuffer getTimeByteBuffer() {
            ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
            buffer.order(ByteOrder.BIG_ENDIAN);
            buffer.position(0);
            
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_en));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_year - 2000));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_month));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_day));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_hour));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_minute));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_second));
            
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_en));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_year - 2000));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_month));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_day));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_hour));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_minute));
            buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_second));
            
            buffer.flip();
            return buffer;
        }
 
        @Override
        public String toString() {
            return "TimeControl [time_close_en=" + time_close_en + ", time_close_year=" + time_close_year
                    + ", time_close_month=" + time_close_month + ", time_close_day=" + time_close_day
                    + ", time_close_hour=" + time_close_hour + ", time_close_minute=" + time_close_minute
                    + ", time_close_second=" + time_close_second + ", time_repetcomm_en=" + time_repetcomm_en
                    + ", time_repetcomm_year=" + time_repetcomm_year + ", time_repetcomm_month=" + time_repetcomm_month
                    + ", time_repetcomm_day=" + time_repetcomm_day + ", time_repetcomm_hour=" + time_repetcomm_hour
                    + ", time_repetcomm_minute=" + time_repetcomm_minute + ", time_repetcomm_second="
                    + time_repetcomm_second + "]";
        }
        
        
    }
 
    @Override
    public String toString() {
        return "Power_TimeControl [timeControls=" + Arrays.toString(timeControls) + "]";
    }
    
    
}