Administrator
2022-06-17 c5bff04a7761b7aca5dbd511a5989ebab20adb24
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
package com.base;
 
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
 
/**
 * ´´½¨config.xmlÎļþ²¢¸üР config.xml ÎļþÖеÄÊôÐÔÖµ
 * @author ¾ü
 *
 */
public class AppConfig {
    
    public static final int SOURCE_BATTDATA_TYPE_FBSDEV = 0;
    public static final int SOURCE_BATTDATA_TYPE_SQLSERVER = 1;
    public static final int SOURCE_BATTDATA_TYPE_C_INTERFACE = 2;
    public static final int SOURCE_BATTDATA_TYPE_SQLSERVER_AND_C_INTERFACE = 3;
    
    private final String ConfigFileName = "config.xml";
    
    private boolean mysqlDB_RecreateEn = false;
    private String mysqlServerIp = "127.0.0.1";
    
    private int sourceBattDataType = 0;
    //----------------------------------------------------------------//
    private int sourceSQLServerType = 0;
    private String sourceSQLServerIp = "127.0.0.1";
    private String sourceSQLServerUsrName = "sxfg001";
    private String sourceSQLServerPWD = "sxfg001";
    private int sourceSQLServerPort = 5000;
    
    private String cInterfaceServerIp = "127.0.0.1";
    private String cInterfaceUsrName = "cdnt";
    private String cInterfacePWD = "cdnt";
    private int cInterfaceSocketPort = 7009;
    
    private String fbsDeviceBaseIp = "192.168.0.1";
    //----------------------------------------------------------------//
    //----------------------------------------------------------------//
    private boolean sybSrvCurrChargeDirPos = false;
    
    private int mysqlConnCountMax = 300;
    private int workThreadCountMax = 300;
    
    private boolean battAlarmFnEn = false;
    private int battAlarmFnStartDelay = 60;
    private int battAlarmClearedDelay = 600;
    private int battAlarmDataDayCountMax = 400;
    
    private boolean battResStoreFnEn = false;
    private int battResStoreDelayForTestManual = 1200;
    private int battResStoreDayInterval = 7;
    
    private boolean battAutoStoreFnEn = false;
    private int battAutoStoreDelayForStartUp = 60;
    private int battAutoStoreMinuteInterval = 10;
    private int battAutoStoreDayCountMax = 7;
    
    private boolean battTestStateReloadEn = true;
    
    private boolean userTaskFnEn = true;
    private boolean userTaskSmsFnEn = false;
    private String userTaskSmsDevIp = "192.168.1.60";
    
    private boolean idce8200ServerFnEn = false;
    private boolean mobileServerFnEn = true;
    private boolean ftpServerFnEn = true;
    
    private int autoSqlDbBackUpDayInterval = 30;
    private boolean bpm7100CommErrDataClearEN = true;
    private int fbsDevCommRate = 1;
    
    private boolean DevBTS_SeverComm_En = true;
    private boolean DevFBS9100_SeverComm_En = true;
    private boolean DevFBS9100_ClientComm_En = true;
    
    public AppConfig()
    {
        /*
        String path = System.getProperty("user.dir");
        if(path.contains("\\"))
            path += "\\";
        else path += "/";
        */
        String path = ConfigFileName;
        //System.out.println(path);
        File f = new File(path);
        if(false == f.exists())
        {
            writeConfigToXml();
        }
        
        readConfigFromXml();
    }
    
    public boolean getMysqlDB_RecreateEn()
    {
        return mysqlDB_RecreateEn;
    }
    public void setMysqlDB_RecreateEn(boolean en)
    {
        mysqlDB_RecreateEn = en;
    }
    
    public String getMysqlServerIp()
    {
        return mysqlServerIp;
    }
    
    public String getSourceSQLServerIp()
    {
        return sourceSQLServerIp;
    }
    public String getSourceSQLServerUsrName()
    {
        return sourceSQLServerUsrName;
    }
    public String getSourceSQLServerPWD()
    {
        return sourceSQLServerPWD;
    }
    public int getSourceSQLServerPort()
    {
        return sourceSQLServerPort;
    }
    
    public String getCInterfaceServerIp()
    {
        return cInterfaceServerIp;
    }
    public String getCInterfaceUsrName()
    {
        return cInterfaceUsrName;
    }
    public String getCInterfacePWD()
    {
        return cInterfacePWD;
    }
    public int getCInterfacePort()
    {
        return cInterfaceSocketPort;
    }
    
    public String getFbsDeviceBaseIp()
    {
        return fbsDeviceBaseIp;
    }
    public int getSourceSQLServerType()
    {
        return sourceSQLServerType;
    }
    public int getSourceBattDataType()
    {
        return sourceBattDataType;
    }
    
    public boolean getSybSrvCurrChargeDirPos()
    {
        return sybSrvCurrChargeDirPos;
    }
    
    public int getMysqlConnCountMax()
    {
        return mysqlConnCountMax;
    }
    public int getWorkThreadCountMax()
    {
        return workThreadCountMax;
    }
    
    public boolean getBattAlarmFnEn()
    {
        return battAlarmFnEn;
    }
    
    public int getBattAlarmFnStartDelay()
    {
        return battAlarmFnStartDelay;
    }
    
    public int getBattAlarmClearedDelay()
    {
        return battAlarmClearedDelay;
    }
    
    public int getBattAlarmDataDayCountMax()
    {
        return battAlarmDataDayCountMax;
    }
    
    public boolean getBattResStoreFnEn()
    {
        return battResStoreFnEn;
    }
    public int getBattResStoreDelayForTestManual()
    {
        return battResStoreDelayForTestManual;
    }
    public int getBattResStoreDayInterval()
    {
        return battResStoreDayInterval;
    }
    
    public boolean getBattAutoStoreFnEn()
    {
        return battAutoStoreFnEn;
    }
    public int getBattAutoStoreDelayForStartUp()
    {
        return battAutoStoreDelayForStartUp;
    }
    public int getBattAutoStoreMinuteInterval()
    {
        return battAutoStoreMinuteInterval;
    }
    public int getBattAutoStoreDayCountMax()
    {
        return battAutoStoreDayCountMax;
    }
    
    public boolean getBattTestStateReloadEn() {
        return battTestStateReloadEn;
    }
    
    public boolean getUserTaskFnEn()
    {
        return userTaskFnEn;
    }
    public boolean getUserTaskSmsFnEn()
    {
        return userTaskSmsFnEn;
    }
    public String getUserTaskSmsDevIp()
    {
        return userTaskSmsDevIp;
    }
    
    public boolean getIdce8200ServerFnEn()
    {
        return idce8200ServerFnEn;
    }
    public boolean getMobileServerFnEn()
    {
        return mobileServerFnEn;
    }
    public boolean getFtpServerFnEn()
    {
        return ftpServerFnEn;
    }
    
    public int getAutoSqlDbBackUpDayInterval() {
        return autoSqlDbBackUpDayInterval;
    }
    
    public boolean getBpm7100CommErrDataClearEN() {
        return bpm7100CommErrDataClearEN;
    }
    
    public int getFbsDevCommRate() {
        return fbsDevCommRate;
    }
    
    public boolean getBTS_CommEn() {
        return DevBTS_SeverComm_En;
    }
    public boolean getFbs9100_ServerCommEn() {
        return DevFBS9100_SeverComm_En;
    }
    public boolean getFbs9100_ClientCommEn() {
        return DevFBS9100_ClientComm_En;
    }
    
    public void writeConfigToXml()
    {
        Logger logger = LogManager.getLogger(this.getClass());
        try {
            Document document = DocumentHelper.createDocument();
            Element root = document.addElement("root");
            //root.addComment("Õâ¸öÒ»¸ö×¢ÊÍ");
            
            Element param;
            Element sub_param;
            
            //-------------------------------------------------------//
            param = root.addElement("mysql_ramdb_recreate_en"); 
            param.addText(String.valueOf(mysqlDB_RecreateEn));
            //-------------------------------------------------------//
            param = root.addElement("mysql_server_ip"); 
            param.addText(mysqlServerIp);
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            root.addComment("SOURCE_BATTDATA_TYPE_FBSDEV = 0");
            root.addComment("SOURCE_BATTDATA_TYPE_SQLSERVER = 1");
            root.addComment("SOURCE_BATTDATA_TYPE_C_INTERFACE = 2");
            root.addComment("SOURCE_BATTDATA_TYPE_SQLSERVER_AND_C_INTERFACE = 3");
            
            param = root.addElement("source_battdata_type");
            param.addText(String.valueOf(sourceBattDataType));
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            param = root.addElement("source_sqlserver_config");
            
            param.addComment("SOURCE_SQLSERVER_TYPE_SYBASE_DEMO = 0");
            param.addComment("SOURCE_SQLSERVER_TYPE_SYBASE = 1");
            param.addComment("SOURCE_SQLSERVER_TYPE_MSSQLSERVER = 2");
            
            sub_param = param.addElement("source_sqlserver_type"); 
            sub_param.addText(String.valueOf(sourceSQLServerType));
            
            sub_param = param.addElement("source_sqlserver_ip"); 
            sub_param.addText(sourceSQLServerIp);
            
            sub_param = param.addElement("source_sqlserver_usrname"); 
            sub_param.addText(sourceSQLServerUsrName);
            
            sub_param = param.addElement("source_sqlserver_pwd"); 
            sub_param.addText(sourceSQLServerPWD);
            
            sub_param = param.addElement("source_sqlserver_port"); 
            sub_param.addText(String.valueOf(sourceSQLServerPort));
            //-------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("c_interface_server_config");
            
            sub_param = param.addElement("c_interface_server_ip");
            sub_param.addText(cInterfaceServerIp);
            
            sub_param = param.addElement("c_interface_usrname");
            sub_param.addText(cInterfaceUsrName);
            
            sub_param = param.addElement("c_interface_pwd");
            sub_param.addText(cInterfacePWD);
            
            sub_param = param.addElement("c_interface_sokcet_port");
            sub_param.addText(String.valueOf(cInterfaceSocketPort));
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("fbs_device_base_ip"); 
            param.addText(fbsDeviceBaseIp);
            //--------------------------------------------------------//
            
            param = root.addElement("syb_srv_curr_charge_dir_pos"); 
            param.addText(String.valueOf(sybSrvCurrChargeDirPos));
            
            param = root.addElement("mysql_conn_count_max"); 
            param.addText(String.valueOf(mysqlConnCountMax));
            
            param = root.addElement("work_thread_count_max"); 
            param.addText(String.valueOf(workThreadCountMax));
            
            //--------------------------------------------------------//
            param = root.addElement("batt_alarm_fn_config");
            
            sub_param = param.addElement("batt_alarm_fn_en"); 
            sub_param.addText(String.valueOf(battAlarmFnEn));
             
            sub_param = param.addElement("batt_alarm_fn_start_delay"); 
            sub_param.addText(String.valueOf(battAlarmFnStartDelay));
             
            sub_param = param.addElement("batt_alarm_cleared_delay"); 
            sub_param.addText(String.valueOf(battAlarmClearedDelay));
            
            sub_param = param.addElement("batt_alarm_data_daycount_max"); 
            sub_param.addText(String.valueOf(battAlarmDataDayCountMax));
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("batt_res_store_fn_config");
            
            sub_param = param.addElement("batt_res_store_fn_en"); 
            sub_param.addText(String.valueOf(battResStoreFnEn));
            
            sub_param = param.addElement("batt_res_store_delay_for_test_manual"); 
            sub_param.addText(String.valueOf(battResStoreDelayForTestManual));
            
            sub_param = param.addElement("batt_res_store_day_interval"); 
            sub_param.addText(String.valueOf(battResStoreDayInterval));
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("batt_auto_store_fn_config");
            
            sub_param = param.addElement("batt_auto_store_fn_en"); 
            sub_param.addText(String.valueOf(battAutoStoreFnEn));
            
            sub_param = param.addElement("batt_auto_store_delay_for_start_up"); 
            sub_param.addText(String.valueOf(battAutoStoreDelayForStartUp));
            
            sub_param = param.addElement("batt_auto_store_minute_interval"); 
            sub_param.addText(String.valueOf(battAutoStoreMinuteInterval));
            
            sub_param = param.addElement("batt_auto_store_day_count_max"); 
            sub_param.addText(String.valueOf(battAutoStoreDayCountMax));
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("user_task_fn_config");
            
            sub_param = param.addElement("user_task_fn_en"); 
            sub_param.addText(String.valueOf(userTaskFnEn));
            
            sub_param = param.addElement("user_task_sms_fn_en"); 
            sub_param.addText(String.valueOf(userTaskSmsFnEn));
            
            sub_param = param.addElement("user_task_sms_dev_ip"); 
            sub_param.addText(userTaskSmsDevIp);
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            param = root.addElement("idce8200_server_fn_config");
            param.addText(String.valueOf(idce8200ServerFnEn));
            
            param = root.addElement("mobile_server_fn_config");
            param.addText(String.valueOf(mobileServerFnEn));
            
            param = root.addElement("ftp_server_fn_config");
            param.addText(String.valueOf(ftpServerFnEn));
            //--------------------------------------------------------//
            
            //-------------------------------------------------------//
            param = root.addElement("auto_sqldb_backup_dayinterval"); 
            param.addText(String.valueOf(autoSqlDbBackUpDayInterval));
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            param = root.addElement("bpm7100_commerr_dataclear_en"); 
            param.addText(String.valueOf(bpm7100CommErrDataClearEN));
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            param = root.addElement("fbsdev_comm_rate"); 
            param.addText(String.valueOf(fbsDevCommRate));
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            param = root.addElement("dev_bts_severcomm_en"); 
            param.addText(String.valueOf(DevBTS_SeverComm_En));
            //-------------------------------------------------------//
            //-------------------------------------------------------//
            param = root.addElement("devfbs9100_severcomm_en"); 
            param.addText(String.valueOf(DevFBS9100_SeverComm_En));
            //-------------------------------------------------------//
            //-------------------------------------------------------//
            param = root.addElement("devfbs9100_clientcomm_en"); 
            param.addText(String.valueOf(DevFBS9100_ClientComm_En));
            //-------------------------------------------------------//
            param = root.addElement("batt_teststate_reload_en"); 
            param.addText(String.valueOf(battTestStateReloadEn));
            //-------------------------------------------------------//
            
            OutputFormat format = OutputFormat.createPrettyPrint();
            format.setEncoding("gbk");
            XMLWriter writer2 = new XMLWriter(new FileWriter(ConfigFileName), format);
            writer2.write(document);
            writer2.close();
        } catch (IOException e) {
            logger.error(e.toString(), e);
        }
    }
    
    public void readConfigFromXml()
    {
        Logger logger = LogManager.getLogger(this.getClass());
        boolean res = true;
        try 
        {
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File(ConfigFileName));
            Element rootnode = document.getRootElement();
            
            Element node;
            Element sub_node;
            
            //------------------------------------------------------------//
            node = rootnode.element("mysql_ramdb_recreate_en"); 
            mysqlDB_RecreateEn = Boolean.parseBoolean(node.getTextTrim());
            //------------------------------------------------------------//
            node = rootnode.element("mysql_server_ip"); 
            mysqlServerIp = node.getTextTrim();
            //------------------------------------------------------------//
            node = rootnode.element("source_battdata_type"); 
            sourceBattDataType = Integer.parseInt(node.getTextTrim());
            if(sourceBattDataType < 0)
                sourceBattDataType = 0;
            if(sourceBattDataType > 3)
                sourceBattDataType = 3;
            
            //------------------------------------------------------------//
            node = rootnode.element("source_sqlserver_config");
            
            sub_node = node.element("source_sqlserver_type"); 
            sourceSQLServerType = Integer.parseInt(sub_node.getTextTrim());
            
            sub_node = node.element("source_sqlserver_ip"); 
            sourceSQLServerIp = sub_node.getTextTrim();
            
            sub_node = node.element("source_sqlserver_usrname"); 
            sourceSQLServerUsrName = sub_node.getTextTrim();
            
            sub_node = node.element("source_sqlserver_pwd"); 
            sourceSQLServerPWD = sub_node.getTextTrim();
            
            sub_node = node.element("source_sqlserver_port");
            sourceSQLServerPort = Integer.parseInt(sub_node.getTextTrim());
            //------------------------------------------------------------//
            
            //------------------------------------------------------------//
            node = rootnode.element("c_interface_server_config");
            
            sub_node = node.element("c_interface_server_ip");
            cInterfaceServerIp = sub_node.getTextTrim();
            
            sub_node = node.element("c_interface_usrname");
            cInterfaceUsrName = sub_node.getTextTrim();
            
            sub_node = node.element("c_interface_pwd");
            cInterfacePWD = sub_node.getTextTrim();
            
            sub_node = node.element("c_interface_sokcet_port");
            cInterfaceSocketPort = Integer.parseInt(sub_node.getTextTrim());
            //------------------------------------------------------------//
            
            //------------------------------------------------------------//
            node = rootnode.element("fbs_device_base_ip"); 
            fbsDeviceBaseIp = node.getTextTrim();
            //------------------------------------------------------------//
            
            node = rootnode.element("syb_srv_curr_charge_dir_pos");
            sybSrvCurrChargeDirPos = Boolean.parseBoolean(node.getTextTrim());
            
            node = rootnode.element("mysql_conn_count_max");
            mysqlConnCountMax = Integer.parseInt(node.getTextTrim());
            if(mysqlConnCountMax < 5)
                mysqlConnCountMax = 5;
            if(mysqlConnCountMax > 20000)
                mysqlConnCountMax = 20000;
            
            node = rootnode.element("work_thread_count_max"); 
            workThreadCountMax = Integer.parseInt(node.getTextTrim());
            
            if(workThreadCountMax < 10)
                workThreadCountMax = 10;
            if(workThreadCountMax > 20000)
                workThreadCountMax = 20000;
            
            //-------------------------------------------------------//
            node = rootnode.element("batt_alarm_fn_config");
            
            sub_node = node.element("batt_alarm_fn_en"); 
            battAlarmFnEn = Boolean.parseBoolean(sub_node.getTextTrim());
            
            sub_node = node.element("batt_alarm_fn_start_delay"); 
            battAlarmFnStartDelay = Integer.parseInt(sub_node.getTextTrim());
            if(battAlarmFnStartDelay < 0)
                battAlarmFnStartDelay = 0;
            if(battAlarmFnStartDelay > 3600)
                battAlarmFnStartDelay = 3600;
            
            sub_node = node.element("batt_alarm_cleared_delay"); 
            battAlarmClearedDelay = Integer.parseInt(sub_node.getTextTrim());
            if(battAlarmClearedDelay < 0)
                battAlarmClearedDelay = 0;
            if(battAlarmClearedDelay > 3600)
                battAlarmClearedDelay = 3600;
            
            
            sub_node = node.element("batt_alarm_data_daycount_max"); 
            battAlarmDataDayCountMax = Integer.parseInt(sub_node.getTextTrim());
            if(battAlarmDataDayCountMax < 7)
                battAlarmDataDayCountMax = 7;
            if(battAlarmDataDayCountMax > 2048)
                battAlarmDataDayCountMax = 2048;
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("batt_res_store_fn_config");
            
            sub_node = node.element("batt_res_store_fn_en");
            battResStoreFnEn = Boolean.parseBoolean(sub_node.getTextTrim());
            
            sub_node = node.element("batt_res_store_delay_for_test_manual");
            battResStoreDelayForTestManual = Integer.parseInt(sub_node.getTextTrim());
            if(battResStoreDelayForTestManual < 180)
                battResStoreDelayForTestManual = 180;
            if(battResStoreDelayForTestManual > 1800)
                battResStoreDelayForTestManual = 1800;
            
            sub_node = node.element("batt_res_store_day_interval");
            battResStoreDayInterval = Integer.parseInt(sub_node.getTextTrim());
            if(battResStoreDayInterval < 1)
                battResStoreDayInterval = 1;
            if(battResStoreDayInterval > 360)
                battResStoreDayInterval = 360;
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("batt_auto_store_fn_config");
            
            sub_node = node.element("batt_auto_store_fn_en");
            battAutoStoreFnEn = Boolean.parseBoolean(sub_node.getTextTrim());
            
            sub_node = node.element("batt_auto_store_delay_for_start_up");
            battAutoStoreDelayForStartUp = Integer.parseInt(sub_node.getTextTrim());
            if(battAutoStoreDelayForStartUp < 180)
                battAutoStoreDelayForStartUp = 180;
            if(battAutoStoreDelayForStartUp > 3600)
                battAutoStoreDelayForStartUp = 3600;
            
            sub_node = node.element("batt_auto_store_minute_interval");
            battAutoStoreMinuteInterval = Integer.parseInt(sub_node.getTextTrim());
            if(battAutoStoreMinuteInterval < 10)
                battAutoStoreMinuteInterval = 10;
            if(battAutoStoreMinuteInterval > ((60*24)*30))
                battAutoStoreMinuteInterval = ((60*24)*30);
            
            sub_node = node.element("batt_auto_store_day_count_max");
            battAutoStoreDayCountMax = Integer.parseInt(sub_node.getTextTrim());
            if(battAutoStoreDayCountMax < 1)
                battAutoStoreDayCountMax = 1;
            if(battAutoStoreDayCountMax > 300)
                battAutoStoreDayCountMax = 300;
            //-------------------------------------------------------//
            
            //--------------------------------------------------------//
            node = rootnode.element("user_task_fn_config");
            
            sub_node = node.element("user_task_fn_en");
            userTaskFnEn = Boolean.parseBoolean(sub_node.getTextTrim());
            
            sub_node = node.element("user_task_sms_fn_en");
            userTaskSmsFnEn = Boolean.parseBoolean(sub_node.getTextTrim());
            
            sub_node = node.element("user_task_sms_dev_ip");
            userTaskSmsDevIp = sub_node.getTextTrim();
            //--------------------------------------------------------//
            
            //--------------------------------------------------------//
            node = rootnode.element("idce8200_server_fn_config");
            idce8200ServerFnEn = Boolean.parseBoolean(node.getTextTrim());
            
            node = rootnode.element("mobile_server_fn_config");
            mobileServerFnEn = Boolean.parseBoolean(node.getTextTrim());
            
            node = rootnode.element("ftp_server_fn_config");
            ftpServerFnEn = Boolean.parseBoolean(node.getTextTrim());
            //--------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("auto_sqldb_backup_dayinterval"); 
            autoSqlDbBackUpDayInterval = Integer.parseInt(node.getTextTrim());
            if(autoSqlDbBackUpDayInterval < 7) {
                autoSqlDbBackUpDayInterval = 7;
            }
            if(autoSqlDbBackUpDayInterval > 365) {
                autoSqlDbBackUpDayInterval = 365;
            }
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("bpm7100_commerr_dataclear_en");
            bpm7100CommErrDataClearEN = Boolean.parseBoolean(node.getTextTrim());
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("fbsdev_comm_rate");
            fbsDevCommRate = Integer.parseInt(node.getTextTrim());
            if(fbsDevCommRate < 1) {
                fbsDevCommRate = 0;
            }
            if(fbsDevCommRate > 200) {
                fbsDevCommRate = 200;
            }
            //-------------------------------------------------------//
            
            //-------------------------------------------------------//
            node = rootnode.element("dev_bts_severcomm_en");
            DevBTS_SeverComm_En = Boolean.parseBoolean(node.getTextTrim());
            //-------------------------------------------------------//
            //-------------------------------------------------------//
            node = rootnode.element("devfbs9100_severcomm_en");
            DevFBS9100_SeverComm_En = Boolean.parseBoolean(node.getTextTrim());
            //-------------------------------------------------------//
            //-------------------------------------------------------//
            node = rootnode.element("devfbs9100_clientcomm_en");
            DevFBS9100_ClientComm_En = Boolean.parseBoolean(node.getTextTrim());
            //-------------------------------------------------------//
            node = rootnode.element("batt_teststate_reload_en");
            battTestStateReloadEn = Boolean.parseBoolean(node.getTextTrim());
            //-------------------------------------------------------//
           
        } catch (NullPointerException | NumberFormatException | DocumentException e) {
            res = false;
            logger.error(e.toString(), e);
        } finally {
            if(false == res)
                writeConfigToXml();
        }
    }
}