whyclj
2020-12-24 bbd0bca64a9694492efc432c4457078d926853ef
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
package com.data;
 
import java.util.Date;
 
import com.base.ComBase;
import com.modbus.data.MyModbusMaster;
import com.modbus.data.MyModbusUtils;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.code.DataType;
 
/**
 *     ÕûÁ÷״̬ÐÅÏ¢
 */
public class Afe_Rectifier_State {
    
    public int dev_id;
    public Date record_time = new Date();            //¼Ç¼ʱ¼ä
    
    public int rectifier_start;            //'ÕûÁ÷Æô¶¯',
    public int rectifier_stop;            //'ÕûÁ÷Í£Ö¹',
    public int inverter_start;            //'Äæ±äÆô¶¯',
    public int inverter_stop;            //'Äæ±äÍ£Ö¹',
    public int speed_torque_change;        //'ËÙ¶È/ת¾ØÄ£Ê½',
    public int reset;                    //'¸´Î»',
    public int rectifier_run;            //'ÕûÁ÷ÔËÐÐ',
    public int inverter_run;            //'Äæ±äÔËÐÐ',
    public int report_alm;                //'×ۺϱ¨¾¯',
    public int report_fault;            //'×ۺϹÊÕÏ',
    
    public BatchRead<Integer> createBatchRead(MyModbusMaster master) {
        BatchRead<Integer> batch = new BatchRead<Integer>();        
        batch.addLocator(0,MyModbusUtils.createBaseLocator(0x85B6,DataType.TWO_BYTE_INT_UNSIGNED,master));        //
        batch.addLocator(1,MyModbusUtils.createBaseLocator(0x85B7,DataType.TWO_BYTE_INT_UNSIGNED,master));        //
        return batch;
    }
 
    public void putBatchResult(BatchResults<Integer> res) {
        if(null != res) {
            int state1 = MyModbusUtils.readIntergerToInt(res.getValue(0));
            int state2 = MyModbusUtils.readIntergerToInt(res.getValue(1));
            //System.out.println(state1+"==="+state2);
            
            this.rectifier_start = (state1 & ComBase.my_power_2(0))>0?1:0;
            this.rectifier_stop = (state1 & ComBase.my_power_2(1))>0?1:0;
            this.inverter_start = (state1 & ComBase.my_power_2(2))>0?1:0;
            this.inverter_stop = (state1 & ComBase.my_power_2(3))>0?1:0;
            this.speed_torque_change = (state1 & ComBase.my_power_2(4))>0?1:0;
            this.reset = (state1 & ComBase.my_power_2(5))>0?1:0;
            
            this.rectifier_run = (state2 & ComBase.my_power_2(0))>0?1:0;
            this.inverter_run = (state2 & ComBase.my_power_2(1))>0?1:0;
            this.report_alm = (state2 & ComBase.my_power_2(2))>0?1:0;
            this.report_fault = (state2 & ComBase.my_power_2(3))>0?1:0;
            this.record_time = new Date();
        }
    }
    
    public Afe_Rectifier_State() {
        
    }
    
    public Afe_Rectifier_State(int dev_id) {
        this.dev_id = dev_id;
    }
    
    public int getDev_id() {
        return dev_id;
    }
    public void setDev_id(int dev_id) {
        this.dev_id = dev_id;
    }
    public Date getRecord_time() {
        return record_time;
    }
    public void setRecord_time(Date record_time) {
        this.record_time = record_time;
    }
    public int getRectifier_start() {
        return rectifier_start;
    }
    public void setRectifier_start(int rectifier_start) {
        this.rectifier_start = rectifier_start;
    }
    public int getRectifier_stop() {
        return rectifier_stop;
    }
    public void setRectifier_stop(int rectifier_stop) {
        this.rectifier_stop = rectifier_stop;
    }
    public int getInverter_start() {
        return inverter_start;
    }
    public void setInverter_start(int inverter_start) {
        this.inverter_start = inverter_start;
    }
    public int getInverter_stop() {
        return inverter_stop;
    }
    public void setInverter_stop(int inverter_stop) {
        this.inverter_stop = inverter_stop;
    }
    public int getSpeed_torque_change() {
        return speed_torque_change;
    }
    public void setSpeed_torque_change(int speed_torque_change) {
        this.speed_torque_change = speed_torque_change;
    }
    public int getReset() {
        return reset;
    }
    public void setReset(int reset) {
        this.reset = reset;
    }
    public int getRectifier_run() {
        return rectifier_run;
    }
    public void setRectifier_run(int rectifier_run) {
        this.rectifier_run = rectifier_run;
    }
    public int getInverter_run() {
        return inverter_run;
    }
    public void setInverter_run(int inverter_run) {
        this.inverter_run = inverter_run;
    }
    public int getReport_alm() {
        return report_alm;
    }
    public void setReport_alm(int report_alm) {
        this.report_alm = report_alm;
    }
    public int getReport_fault() {
        return report_fault;
    }
    public void setReport_fault(int report_fault) {
        this.report_fault = report_fault;
    }
    
    @Override
    public String toString() {
        return "Afe_Rectifier_State [dev_id=" + dev_id + ", record_time=" + record_time + ", rectifier_start="
                + rectifier_start + ", rectifier_stop=" + rectifier_stop + ", inverter_start=" + inverter_start
                + ", inverter_stop=" + inverter_stop + ", speed_torque_change=" + speed_torque_change + ", reset="
                + reset + ", rectifier_run=" + rectifier_run + ", inverter_run=" + inverter_run + ", report_alm="
                + report_alm + ", report_fault=" + report_fault + "]";
    }
}