mxpopstar
2022-05-03 e75ef5f04f61aa5fbd89fd5c413dcee1819b7a91
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
package com.dev.fbs9600_curr;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.BoxLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
 
import com.LimitedDocument;
import com.dev.fbs9600_mon.SPCommMon;
 
import javax.swing.JTabbedPane;
 
import org.apache.logging.log4j.Logger;
 
import main.page_debug_inf;
import main.page_dfu;
 
public class module_curr_page extends JPanel {
    public SPCommMon Comm_Curr = null;
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JTextField tf_addr;
    private JTextField tf_version;
    private JTextField tf_curr;
    private JTextField tf_setaddr;
    private JTextField tf_peak_curr;
    private JTextField tf_currrange_set;
    private JButton btn_curr_test_start;
    private JTextField tf_peakavg_curr;
    private JTextField tf_lockbit;
    private JTextField tf_ssb;
    private JTextField tf_CurrSlope_Set;
    private JButton btn_currrange_write;
    private JButton btn_SetCurr1_Slope;
    private JButton btn_addr_write;
    private JButton btn_junheng_volset;
    private JButton btnNewButton;
    private JButton btnNewButton_1;
    private JButton btnNewButton_2;
    private JButton btnNewButton_3;
    private JTextField tf_curr_range;
    private JTextField tf_curr_slope;
    private JTextField tf_curr_float;
    private JTextField tf_curr_float_slope;
    private JTextField tf_Currfloat_Slope_Set;
    private JComboBox<?> cb_float_dir;
    private JComboBox<?> cb_dir;
    
    private page_dfu panel_dfu;
    private page_debug_inf panel_debug;
    private JTabbedPane tabbedPane;
    
    /**
     * Create the panel.
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public module_curr_page() {
        setLayout(new BorderLayout(0, 0));
        
        tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        add(tabbedPane, BorderLayout.CENTER);
        
        JPanel panel_28 = new JPanel();
        tabbedPane.addTab("\u57FA\u672C\u6D4B\u8BD5", null, panel_28, null);
        panel_28.setLayout(new GridLayout(4, 0, 0, 0));
        
        JPanel panel_4 = new JPanel();
        panel_28.add(panel_4);
        panel_4.setBorder(new TitledBorder(null, "\u6A21\u5757\u4FE1\u606F", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_4.setLayout(new GridLayout(0, 5, 0, 0));
        
        JPanel panel_5 = new JPanel();
        panel_5.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u6A21\u5757\u5730\u5740", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_4.add(panel_5);
        panel_5.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_addr = new JTextField();
        tf_addr.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_addr.setEditable(false);
        panel_5.add(tf_addr);
        tf_addr.setColumns(10);
        
        JPanel panel_6 = new JPanel();
        panel_6.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u6A21\u5757\u7248\u672C", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_4.add(panel_6);
        panel_6.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_version = new JTextField();
        tf_version.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_version.setEditable(false);
        panel_6.add(tf_version);
        tf_version.setColumns(10);
        
        JPanel panel_62 = new JPanel();
        panel_62.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u9501\u5B9A\u4F4D", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_4.add(panel_62);
        panel_62.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_lockbit = new JTextField();
        tf_lockbit.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_lockbit.setEditable(false);
        panel_62.add(tf_lockbit);
        tf_lockbit.setColumns(10);
        
        JPanel panel_63 = new JPanel();
        panel_63.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u52A0\u5BC6\u4F4D", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_4.add(panel_63);
        panel_63.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_ssb = new JTextField();
        tf_ssb.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_ssb.setEditable(false);
        panel_63.add(tf_ssb);
        tf_ssb.setColumns(10);
        
        JPanel panel_16 = new JPanel();
        panel_4.add(panel_16);
        panel_16.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u7535\u6D41\u91CF\u7A0B(A)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_16.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_curr_range = new JTextField();
        tf_curr_range.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_curr_range.setEditable(false);
        panel_16.add(tf_curr_range);
        tf_curr_range.setColumns(10);
        
        JPanel panel_10 = new JPanel();
        panel_28.add(panel_10);
        panel_10.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u7535\u6D41\u6D4B\u91CF", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.setLayout(new GridLayout(0, 6, 0, 0));
        
        JPanel panel_11 = new JPanel();
        panel_11.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u7535\u6D41(A)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_11);
        panel_11.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_curr = new JTextField();
        tf_curr.setEditable(false);
        tf_curr.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        panel_11.add(tf_curr);
        tf_curr.setColumns(10);
        
        JPanel panel_7 = new JPanel();
        panel_7.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u7535\u6D41\u65B9\u5411", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_7);
        panel_7.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        cb_dir = new JComboBox();
        cb_dir.setModel(new DefaultComboBoxModel(new String[] {"\u5145\u7535", "\u653E\u7535"}));
        panel_7.add(cb_dir);
        
        JPanel panel_17 = new JPanel();
        panel_17.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u7535\u6D41\u7CFB\u6570", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_17);
        panel_17.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_curr_slope = new JTextField();
        tf_curr_slope.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_curr_slope.setEditable(false);
        panel_17.add(tf_curr_slope);
        tf_curr_slope.setColumns(10);
        
        JPanel panel_3 = new JPanel();
        panel_3.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u6D6E\u5145\u7535\u6D41(A)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_3);
        panel_3.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_curr_float = new JTextField();
        tf_curr_float.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_curr_float.setEditable(false);
        panel_3.add(tf_curr_float);
        tf_curr_float.setColumns(10);
        
        JPanel panel_18 = new JPanel();
        panel_18.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u6D6E\u5145\u7535\u6D41\u65B9\u5411", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_18);
        panel_18.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        cb_float_dir = new JComboBox();
        cb_float_dir.setModel(new DefaultComboBoxModel(new String[] {"\u5145\u7535", "\u653E\u7535"}));
        panel_18.add(cb_float_dir);
        
        JPanel panel_19 = new JPanel();
        panel_19.setBorder(new TitledBorder(new EmptyBorder(0, 0, 0, 0), "\u6D6E\u5145\u7535\u6D41\u7CFB\u6570", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_10.add(panel_19);
        panel_19.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        
        tf_curr_float_slope = new JTextField();
        tf_curr_float_slope.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_curr_float_slope.setEditable(false);
        panel_19.add(tf_curr_float_slope);
        tf_curr_float_slope.setColumns(10);
        
        JPanel panel_15 = new JPanel();
        panel_28.add(panel_15);
        panel_15.setBorder(new TitledBorder(new LineBorder(new Color(171, 173, 179), 1, true), "\u53C2\u6570\u8BBE\u7F6E\u4E0E\u64CD\u4F5C", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_15.setLayout(new GridLayout(0, 5, 0, 0));
        
        JPanel panel_14 = new JPanel();
        panel_15.add(panel_14);
        panel_14.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u7F6E\u901A\u4FE1\u5730\u5740", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_14.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
        
        tf_setaddr = new JTextField();
        tf_setaddr.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        panel_14.add(tf_setaddr);
        tf_setaddr.setColumns(8);
        
        btn_addr_write = new JButton("\u8BBE\u7F6E");
        btn_addr_write.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btn_addr_write.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    if (tf_setaddr.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ÇëÊäÈëÐèÒªÉèÖõĵØÖ·!");
                        return;
                    } else {
                        data_flow = (short) (Integer.parseInt(tf_setaddr.getText()));
                    }
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_CurrAddrSet_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_14.add(btn_addr_write);
        
        JPanel panel_24 = new JPanel();
        panel_15.add(panel_24);
        panel_24.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u7F6E\u7535\u6D41\u91CF\u7A0B\uFF08A\uFF09", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_24.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
        
        tf_currrange_set = new JTextField();
        tf_currrange_set.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_currrange_set.setDocument(new LimitedDocument(4, "0123456789."));
        panel_24.add(tf_currrange_set);
        tf_currrange_set.setColumns(8);
        
        btn_currrange_write = new JButton("\u8BBE\u7F6E");
        btn_currrange_write.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btn_currrange_write.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    if (tf_currrange_set.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ÇëÊäÈëÐèÒªÉèÖõĵçÁ÷Á¿³Ì(A)!");
                        return;
                    } else {
                        data_flow = (short) (Integer.parseInt(tf_currrange_set.getText()));
                    }
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_CurrRangeSet_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_24.add(btn_currrange_write);
        
        JPanel panel_25 = new JPanel();
        panel_15.add(panel_25);
        panel_25.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u542F\u52A8\u7EB9\u6CE2\u7535\u6D41\u6D4B\u91CF", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        
        btn_curr_test_start = new JButton("\u542F\u52A8");
        btn_curr_test_start.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btn_curr_test_start.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_CurrTestStart_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_25.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        btn_curr_test_start.setEnabled(false);
        panel_25.add(btn_curr_test_start);
        
        JPanel panel_22 = new JPanel();
        panel_15.add(panel_22);
        panel_22.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u7EB9\u6CE2\u7535\u6D41(mA)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_22.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        
        tf_peakavg_curr = new JTextField();
        tf_peakavg_curr.setEditable(false);
        tf_peakavg_curr.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_peakavg_curr.setDocument(new LimitedDocument(6, "0123456789"));
        panel_22.add(tf_peakavg_curr);
        tf_peakavg_curr.setColumns(10);
        
        JPanel panel_13 = new JPanel();
        panel_15.add(panel_13);
        panel_13.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u7EB9\u6CE2\u5CF0\u503C\uFF08mA\uFF09", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_13.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        
        tf_peak_curr = new JTextField();
        tf_peak_curr.setEditable(false);
        panel_13.add(tf_peak_curr);
        tf_peak_curr.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        tf_peak_curr.setDocument(new LimitedDocument(6, "0123456789"));
        tf_peak_curr.setColumns(10);
        
        JPanel panel_12 = new JPanel();
        panel_28.add(panel_12);
        panel_12.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u7535\u6D41\u6821\u51C6", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_12.setLayout(new BoxLayout(panel_12, BoxLayout.X_AXIS));
        
        JPanel panel_77 = new JPanel();
        panel_77.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u6821\u51C6\u7535\u6D41\u659C\u7387(A)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_12.add(panel_77);
        panel_77.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
        
        tf_CurrSlope_Set = new JTextField();
        tf_CurrSlope_Set.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        panel_77.add(tf_CurrSlope_Set);
        tf_CurrSlope_Set.setColumns(8);
        tf_CurrSlope_Set.setDocument(new LimitedDocument(6, "0123456789."));
        
        btn_SetCurr1_Slope = new JButton("\u8BBE\u7F6E");
        btn_SetCurr1_Slope.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btn_SetCurr1_Slope.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    if (tf_CurrSlope_Set.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ÇëÊäÈëÐèÒªÉèÖõĵçÁ÷ϵÊý!");
                        return;
                    } 
                    if(tf_curr.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ʵ¼Ê²âÊÔµçÁ÷ÖµÎÞЧ!");
                        return;
                    }
                    float test_curr = Float.parseFloat(tf_curr.getText());
                    if(test_curr < 5) {
                        JOptionPane.showMessageDialog(null, "ÊäÈëµçÁ÷±ØÐë´óÓÚ5A£¬·ñÔò²»ÄÜУ׼!");
                        return;
                    }
                    
                    {
                        float set_curr = Float.parseFloat(tf_CurrSlope_Set.getText());
                        data_flow = (short) ((set_curr/test_curr) * 10000);
                        if(data_flow > 30000) data_flow = (short) 30000;
                        if(data_flow < 2000) data_flow = 2000;
                    }
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_SetCurrSlope_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_77.add(btn_SetCurr1_Slope);
        
        btnNewButton = new JButton("\u590D\u4F4D");
        btnNewButton.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(null != Comm_Curr) {
                    short data_flow = 10000;
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_SetCurrSlope_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_77.add(btnNewButton);
        
        JPanel panel_36 = new JPanel();
        panel_12.add(panel_36);
        panel_36.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u7F6E\u7535\u6D41\u96F6\u70B9", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        
        btn_junheng_volset = new JButton("\u8BBE        \u7F6E");
        btn_junheng_volset.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        btn_junheng_volset.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_CurrOffset_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        panel_36.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        panel_36.add(btn_junheng_volset);
        
        JPanel panel_23 = new JPanel();
        panel_23.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u6821\u51C6\u6D6E\u5145\u7535\u6D41\u659C\u7387(A)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_12.add(panel_23);
        panel_23.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
        
        tf_Currfloat_Slope_Set = new JTextField();
        tf_Currfloat_Slope_Set.setFont(new Font("ËÎÌå", Font.PLAIN, 18));
        panel_23.add(tf_Currfloat_Slope_Set);
        tf_Currfloat_Slope_Set.setColumns(8);
        tf_Currfloat_Slope_Set.setDocument(new LimitedDocument(6, "0123456789."));
        
        btnNewButton_1 = new JButton("\u8BBE\u7F6E");
        btnNewButton_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    if (tf_Currfloat_Slope_Set.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ÇëÊäÈëÐèÒªÉèÖõĵçÁ÷ϵÊý!");
                        return;
                    } 
                    if(tf_curr_float.getText().length() <= 0) {
                        JOptionPane.showMessageDialog(null, "ʵ¼Ê²âÊÔµçÁ÷ÖµÎÞЧ!");
                        return;
                    }
                    float test_curr_float = Float.parseFloat(tf_curr_float.getText());
                    if(test_curr_float < 3) {
                        JOptionPane.showMessageDialog(null, "ÊäÈ븡³äµçÁ÷±ØÐë´óÓÚ3A£¬·ñÔò²»ÄÜУ׼!");
                        return;
                    }
                    
                    {
                        float set_curr_float = Float.parseFloat(tf_Currfloat_Slope_Set.getText());
                        data_flow = (short) ((set_curr_float/test_curr_float) * 10000);
                        if(data_flow > 30000) data_flow = (short) 30000;
                        if(data_flow < 2000) data_flow = 2000;
                    }
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                            SPCommMon.UART_SetCurrFloat_Slope_RegAddr, 
                                            data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        btnNewButton_1.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        panel_23.add(btnNewButton_1);
        
        btnNewButton_2 = new JButton("\u590D\u4F4D");
        btnNewButton_2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(null != Comm_Curr) {
                    short data_flow = 10000;
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                        SPCommMon.UART_SetCurrFloat_Slope_RegAddr, 
                                        data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        btnNewButton_2.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        panel_23.add(btnNewButton_2);
        
        JPanel panel_26 = new JPanel();
        panel_26.setBorder(new TitledBorder(null, "\u8BBE\u7F6E\u6D6E\u5145\u7535\u6D41\u96F6\u70B9", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_12.add(panel_26);
        panel_26.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        
        btnNewButton_3 = new JButton("\u8BBE         \u7F6E");
        btnNewButton_3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(null != Comm_Curr) {
                    short data_flow = 0x0001;
                    Comm_Curr.setCommCmd(SPCommMon.CMD_TYPE_WRITE, 
                                        SPCommMon.UART_CurrFloat_Offset_RegAddr, 
                                        data_flow, (short)0xABCD, (short)0x1234);
                }
            }
        });
        btnNewButton_3.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
        panel_26.add(btnNewButton_3);
        
        panel_dfu = new page_dfu();
        tabbedPane.addTab("\u7A0B\u5E8F\u5347\u7EA7", null, panel_dfu, null);
        
        panel_debug = new page_debug_inf();
        tabbedPane.addTab("\u8C03\u8BD5\u4FE1\u606F", null, panel_debug, null);
        
        setButttonState(false);
    }
 
    public void setButttonState(boolean state) {
        btn_currrange_write.setEnabled(state);
        btn_SetCurr1_Slope.setEnabled(state);
        btn_addr_write.setEnabled(state);
        btn_junheng_volset.setEnabled(state);
        btn_curr_test_start.setEnabled(state);
        btnNewButton.setEnabled(state);
        btnNewButton_1.setEnabled(state);
        btnNewButton_2.setEnabled(state);
        btnNewButton_3.setEnabled(state);
        
        panel_dfu.setButttonState(state);
    }
    
    public boolean openCommPort(int comm_type, String spname_or_ipaddr, int bitrate_or_ipport, 
                                int dev_type, int multy_comm_type, JTextField tf_addr, Logger log) {
        boolean res = false;
        Comm_Curr = new SPCommMon(tf_addr, bitrate_or_ipport, dev_type, multy_comm_type, 
                                    panel_dfu.ta_dfu_inf, panel_debug, log);
        Comm_Curr.setCmdNullEn(false);
        
        if(true == Comm_Curr.OpenCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport)) {
            Thread spcommThread = new Thread(Comm_Curr);
            spcommThread.start();
            
            panel_dfu.set_SerialComm_Mon(Comm_Curr);
            panel_dfu.setDfu_Mon_Addr(tf_addr.getText(), tf_addr.getText());
            
            setButttonState(true);
            
            res = true;
        }
        
        return res;
    }
    
    public void closeCommPort() {
        if(null != Comm_Curr) {
            Comm_Curr.exitCommPortThread();
            Comm_Curr = null;
            panel_dfu.set_SerialComm_Mon(Comm_Curr);
            
            setButttonState(false);
        }
    }
    
    public void updateData() {
        try{
            if(null != Comm_Curr) {
                tf_addr.setText(String.format("%d", Comm_Curr.dt_addr));
                tf_version.setText(String.format("V%1.1f", ((double)Comm_Curr.dt_version)/10));
                tf_lockbit.setText(String.format("%d", Comm_Curr.dt_lockpage_count));
                tf_ssb.setText(String.format("%d", Comm_Curr.dt_ssb));
                
                tf_curr.setText(String.format("%1.1f", ((double)Comm_Curr.dt_curr)/10));
                cb_dir.setSelectedIndex(Comm_Curr.dt_curr_dir%cb_dir.getItemCount());
                
                tf_curr_float.setText(String.format("%1.2f", ((double)Comm_Curr.dt_curr_float)/100));
                cb_float_dir.setSelectedIndex(Comm_Curr.dt_curr_float_dir%cb_float_dir.getItemCount());
                
                tf_peakavg_curr.setText(String.format("%1.2f", ((double)Comm_Curr.dt_peakavg_curr)/100));
                tf_peak_curr.setText(String.format("%1.2f", ((double)Comm_Curr.dt_peak_curr)/100));
                
                tf_curr_range.setText(String.format("%d", Comm_Curr.dt_currrange));
                tf_curr_slope.setText(String.format("%d", Comm_Curr.dt_curr_slope));
                tf_curr_float_slope.setText(String.format("%d", Comm_Curr.dt_curr_float_slope));
            }
        } catch (Exception e) {
            e.printStackTrace();
            //JOptionPane.showMessageDialog(null, "updateData():" + e.getMessage());
        }
    }
}