测试 用electron + springboot 构建桌面应用
he wei
2022-03-29 373e2cf6c342b608e7b511e4b416be177e83fceb
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package testElectronJ;
 
import lombok.extern.slf4j.Slf4j;
 
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
 
 
/**
 * FBO测试数据[每个对象为一笔数据]
 * @author LiJun
 *
 */
@Slf4j
public class FboData {
    public static final int MAX_GROUPMODULE_NUM = 5;
    
    public DataType m_DataType;                        //数据类型                
    public int CRC16;
    public TestTime m_TestTime;                        //数据时间        
    public int  BattGroup;                            //组数 未使用            2
    public int BattSum;                                //单体数 未使用            2
    public float OnlineVol;                            //未使用            4
    public float SumVoltage;                        //总电压                4
    public float SumCurrent;                        //总电流                2    
    public float testCap;                            //测试容量
    public float actualCap;                            //实际容量 预估数据
    public float residualCap;                        //剩余容量
    public int residualTime;                        //剩余时间
    public float Temp_Envi;                           //环境温度
    public float Humi_Envi;                           //环境湿度
    
    public FboDataHeadStart.DateTime InsDate;                        //绝缘测试日期
    public float PosInsRes;                           //正极绝缘电阻
    public float NegInsRes;                           //负极绝缘电阻
    public float SingleVol[];                        //0.001        //单体电压
    public float SubCurrent[];                        //未使用        //单体电流
    public float testSubCap[];                        //未使用        //单体测试容量
    public float actualSubCap[];                    //未使用        //实际容量
    public float residualSubCap[];                    //未使用        //剩余容量
    public int residualSubTime[];                    //未使用        //剩余时间
    
    public FboData() {
        // TODO Auto-generated constructor stub
    }
    
    public FboData(int  BattGroup) {
        this.m_DataType = new DataType();
        this.m_TestTime = new TestTime();
        this.InsDate = new FboDataHeadStart().new DateTime();
        this.SingleVol = new float[BattGroup];                        //0.001        //单体电压
        this.SubCurrent = new float[BattGroup];                        //未使用        //单体电流
        this.testSubCap = new float[BattGroup];                        //未使用        //单体测试容量
        this.actualSubCap = new float[BattGroup];                    //未使用        //实际容量
        this.residualSubCap = new float[BattGroup];                    //未使用        //剩余容量
        this.residualSubTime = new int[BattGroup];                    //未使用        //剩余时间
    }
    
    
    
    /**
     *     数据类型
     * @author LiJun
     *
     */
    public class DataType{
        public int typeTag0;
        public int typeTag1;
        public int typeTag2;
        public int typeTag3;
        
        public int checkDataHead(FileInputStream fis)
        {
            boolean file_end = false;
            byte type_tag = 0;
            byte[] tag = new byte[1];        
            try {
                while(true)
                {
                    type_tag = 0;
                    int n = 0;
                    for(n=0; n<4; n++)
                    {
                        if(1 != fis.read(tag, 0, 1))
                        {
                            file_end = true;
                            break;
                        }
                        if((0xFD != (tag[0]&0xFF)) && (0xFC != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
                        {
                            break;
                        }
                    }
                    
                    if(n >= 4)
                    {
                        type_tag = tag[0];
                        break;
                    }
                    if(true == file_end)
                    {
                        type_tag = 1;
                        break;
                    }
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }        
            setType(type_tag&0xFF);
            
            return (typeTag0);
        }
        
        public void setType(int type)
        {
            typeTag0 = type;
            typeTag1 = type;
            typeTag2 = type;
            typeTag3 = type;
        }
    }
    
    
    public class TestTime{
        public int hour;
        public int minute;
        public int second;
        
        
        @Override
        public String toString() {
            return "TestTime [hour=" + hour + ", minute=" + minute + ", second=" + second + "]";
        }
 
        public String hms(){
            StringBuffer sb = new StringBuffer();
            if (hour > 0) {
                if(hour<10){
                    sb.append("0"+hour + ":");
                }else{
                    sb.append(hour + ":");
                }
            }else{
                sb.append("00"+ ":");
            }
            if (minute > 0) {
                if(minute<10){
                    sb.append("0"+minute + ":");
                }else{
                    sb.append(minute + ":");
                }
            }else{
                sb.append("00" + ":");
            }
            if (second > 0) {
                if(second<10){
                    sb.append("0"+second);
                }else{
                    sb.append(second);
                }
            }else{
                sb.append("00");
            }
            return sb.toString();
        }
        
        
    }
 
 
    public void setData(byte[] databuf) {
        ByteBuffer bf = ByteBuffer.allocate(databuf.length);
        bf.order(ByteOrder.LITTLE_ENDIAN);
        bf.put(databuf);
        bf.position(0);
        
        this.CRC16 = ComBase.changeShortToInt(bf.getShort());
        this.m_TestTime.hour = ComBase.changeByteToInt(bf.get());            //数据时间        
        this.m_TestTime.minute = ComBase.changeByteToInt(bf.get());            //数据时间        
        this.m_TestTime.second = ComBase.changeByteToInt(bf.get());            //数据时间        
        this.BattGroup = ComBase.changeByteToInt(bf.get());                    //组数 未使用            2
        this.BattSum = ComBase.changeShortToInt(bf.getShort());                //单体数 未使用            2
           this.OnlineVol = (float)bf.getInt()/1000;                            //未使用            4
        this.SumVoltage = (float)bf.getInt()/1000;                            //总电压                4
        this.SumCurrent = ComBase.changeShortToFloat(bf.getShort())/10;        //总电流                2    
        this.testCap = ComBase.changeShortToFloat(bf.getShort());            //测试容量
        this.actualCap = ComBase.changeShortToFloat(bf.getShort());            //实际容量 预估数据
        this.residualCap = ComBase.changeShortToFloat(bf.getShort());        //剩余容量
        this.residualTime = ComBase.changeShortToInt(bf.getShort());        //剩余时间
        this.Temp_Envi = ComBase.changeShortToFloat(bf.getShort())/10-20;   //环境温度
        this.Humi_Envi = ComBase.changeShortToFloat(bf.getShort())/10;      //环境湿度
        
        this.InsDate.year = ComBase.changeByteToInt(bf.get());                //年
        this.InsDate.month = ComBase.changeByteToInt(bf.get());                //月
        this.InsDate.day = ComBase.changeByteToInt(bf.get());                //日
        this.InsDate.hour = ComBase.changeByteToInt(bf.get());                //时
        this.InsDate.minute = ComBase.changeByteToInt(bf.get());            //分
        this.InsDate.second = ComBase.changeByteToInt(bf.get());            //秒
        
        this.PosInsRes = ComBase.changeShortToFloat(bf.getShort());         //正极绝缘电阻
        this.NegInsRes = ComBase.changeShortToFloat(bf.getShort());         //负极绝缘电阻
        for(int i=0;i<SingleVol.length;i++) {
            SingleVol[i] = (float)bf.getInt()/1000;                            //0.001        //单体电压
        }
        for(int i=0;i<SubCurrent.length;i++) {
            SubCurrent[i] = ComBase.changeShortToFloat(bf.getShort());        //未使用        //单体电流
        }
        for(int i=0;i<testSubCap.length;i++) {
            testSubCap[i] = ComBase.changeShortToFloat(bf.getShort());        //未使用        //单体测试容量
        }
        for(int i=0;i<actualSubCap.length;i++) {
            actualSubCap[i] = ComBase.changeShortToFloat(bf.getShort()); 
        }
        for(int i=0;i<residualSubCap.length;i++) {
            residualSubCap[i] = ComBase.changeShortToFloat(bf.getShort());     //未使用        //剩余容量
        }
        for(int i=0;i<residualSubTime.length;i++) {
            residualSubTime[i] = ComBase.changeShortToInt(bf.getShort()); //未使用        //剩余时间
        }
        
        //System.out.println(this);
    }
 
 
    @Override
    public String toString() {
        return "FboData [m_DataType=" + m_DataType + ", CRC16=" + CRC16 + ", m_TestTime=" + m_TestTime + ", BattGroup="
                + BattGroup + ", BattSum=" + BattSum + ", OnlineVol=" + OnlineVol + ", SumVoltage=" + SumVoltage
                + ", SumCurrent=" + SumCurrent + ", testCap=" + testCap + ", actualCap=" + actualCap + ", residualCap="
                + residualCap + ", residualTime=" + residualTime + ", Temp_Envi=" + Temp_Envi + ", Humi_Envi="
                + Humi_Envi + ", PosInsRes=" + PosInsRes + ", NegInsRes=" + NegInsRes + ", SingleVol="
                + Arrays.toString(SingleVol) + ", SubCurrent=" + Arrays.toString(SubCurrent) + ", testSubCap="
                + Arrays.toString(testSubCap) + ", actualSubCap=" + Arrays.toString(actualSubCap) + ", residualSubCap="
                + Arrays.toString(residualSubCap) + ", residualSubTime=" + Arrays.toString(residualSubTime) + "]";
    }
    
    
}