lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
var CMD_BTS_StartDischarge = 37;        //容量测试
var CMD_BTS_StartRESTest = 50;            //内阻测试
var CMD_BTS_GetDischargeParm = 41;        //获取放电参数
var CMD_BTS_SetDischargeParm = 40;        //设置放电参数
var CMD_BTS_Start = 81;                    //启动测试
var CMD_BTS_Stop = 83;                    //停止测试
 
 
 
// 初始化设置参数的按钮
var BTSBtn = {
    disabled: function() {
        $('#btn_start_test').addClass('whyc-btn-disabled');    // 启动测试无效
        $('#btn_ensure').addClass('whyc-btn-disabled'); // 设定参数无效
    },
    active:function() {
        if(!$('#btn_start_test').hasClass('no-remove-disabled')) {
            $('#btn_start_test').removeClass('whyc-btn-disabled'); // 启动测试可以点击
        }
        
        if(!$('#btn_ensure').hasClass('no-remove-disabled')) {
            $('#btn_ensure').removeClass('whyc-btn-disabled');     // 设置参数可以点击
        }
        
    },
    startTest:function(param) {
        if(param) {
            $('#btn_start_test').removeClass('whyc-btn-disabled');    // 启动测试可以点击
        }else {
            $('#btn_start_test').addClass('whyc-btn-disabled');    // 启动测试无效
        }
    },
    ensure: function(param) {
        if(param) {
            $('#btn_ensure').removeClass('whyc-btn-disabled');     // 设置参数可以点击
        }else {
            $('#btn_ensure').addClass('whyc-btn-disabled'); // 设定参数无效
        }
    }
    
};
 
// BTS数据校验
$(function() {
    // 放电电流
    $('#discurr').testVal({
        pattern: /^[0-9]+(\.[0-9]*)?$/,
        regVal: true,
        min: 0,
        max: 1000,
        msg: '取值范围0~1000A'
    });
    
    // 放电小时率
    $('#hourrate').testVal({
        pattern: /^[0-9]+$/,
        regVal: false,
        msg: '输入的数据格式不正确'
    });
    
    // 放电电容
    $('#discap').testVal({
        pattern: /^[0-9]+$/,
        regVal: true,
        min: 0,
        max: 90000,
        msg: '取值范围0~90000AH'
    });
    
    // 放电时长
    $('#distime').testVal({
        pattern: /^[0-9]+$/,
        regVal: true,
        min: 0,
        max: 5940,
        msg: '取值范围0~5940分钟'
    });
    
    // 单体下限阀值
    $('#MonomerVol_low').testVal({
        pattern: /^[0-9]+(\.[0-9]*)?$/,
        regVal: true,
        min: 0,
        max: 20,
        msg: '取值范围0~20V'
    });
    
    // 组端下限阀值GroupVol_low
    $('#GroupVol_low').testVal({
        pattern: /^[0-9]+(\.[0-9]*)?$/,
        regVal: true,
        min: 0,
        max: 60,
        msg: '取值范围0~60V'
    });
    
    // 单体下限数量
    $('#MonomerlowCount').testVal({
        pattern: /^[0-9]+$/,
        regVal: false,
        msg: '输入的数据格式不正确'
    });
    
    // 升压上限
    $('#MonomerlowCount').testVal({
        pattern: /^[0-9]+(\.[0-9]*)?$/,
        regVal: false,
        msg: '输入的数据格式不正确'
    });
    
    // 充电电流
    $('#ChargeCurrSet').testVal({
        pattern: /^[0-9]+(\.[0-9]*)?$/,
        regVal: false,
        msg: '输入的数据格式不正确'
    });
    
    // 温度上限
    $('#TempUpHighLimit').testVal({
        pattern: /^[0-9]+$/,
        regVal: false,
        msg: '输入的数据格式不正确'
    });
    
    // 获取BTS面板的所有文本框
    $('#bts').on('input propertychange', 'input[type=text]', function() {
        setBTSPopupStatus($(this).attr('id'), $(this).val());
    });
    
    // 获取BTS面板的所有的下拉框
    $('#bts').on('change', 'select', function() {
        setBTSPopupStatus($(this).attr('id'), $(this).val());
    });
});
 
//获取BTS设备的测试参数等
function searchBTSTestParam(temp, acStart){
    var is_showAlert = (acStart == undefined);
    loading.showLoading();
    $.ajax({     
        type: "post",                 
        url:"Fbs9100_setparamAction_action_serchbyDev_id",
        async:true,                
        dataType:'text',
        data:"json="+JSON.stringify(temp),        
        success: function(data){ 
            data = eval('('+data+')');
            var model = eval('('+data.result+')');
            // 根据mode.code判断是否读取成功
            if(model.code == 1 && model.data != undefined && model.data.length>0){
                setBTSParam(model.data, false);
                if(is_showAlert){                
                    noContent.showNoContent("获取测试参数成功", true);
                }
                initPopup(BTS_popup);
                if(!acStart) {
                    BTSBtn.startTest(false);
                }
                
            }else{
                if(model.data != undefined && model.data.length>0){
                    setBTSParam(model.data, true);
                }
                initPopup(BTS_popup, true);
                noContent.showNoContent("获取测试参数失败");
            }
            loading.hideLoading();                    
        },
        error:function(){
            initPopup(BTS_popup, true);
            noContent.showNoContent("获取测试参数失败");
            loading.hideLoading();
            //LD9_popup.showPopup();    
        }                    
    });    
}
 
// 根据机房名称查询机房下的电池组信息
function searchBtsBattInfoByStation(temp) {
    $.ajax({     
        type: "post",                 
        url: "BattInfAction!serchByBattGroupName",                
        async:true,                
        dataType:'json',
        data:"bif.StationName1=&bif.StationName="+temp.binf.StationName,
        success:function(data){
            var model = eval("("+data.result+")");
            if(model.code == 1){
                DevBattInfo = model.data;
                // 初始化电池组名称列表
                $('#battgroupname').text('');
                for(var i=0;i<model.data.length;i++){
                    var batt = model.data[i];
                    var $option = $("<option></option>");
                    $option.text(batt.StationName+":"+batt.BattGroupName+"-"+batt.MonCount+"节");
                    $option.attr("batt_number",batt.GroupIndexInFBSDevice+1);
                    $option.attr("battgroupid",batt.BattGroupId);
                    $option.attr("value",batt.BattGroupId);
                    $option.attr("batt_name",batt.BattGroupName);
                    if(temp.binf.BattGroupId == batt.BattGroupId){            
                        $option.attr("selected",true);                            //默认选中当前选中的电池组
                        $('#dev_id').val(batt.FBSDeviceId);                            //设置设备id
                        $('#battgropunum').val(batt.GroupIndexInFBSDevice + 1);        //设置被测电池组号
                        $('#battgroup_property').val("单体数量:"+batt.MonCount+";电压(V):"+batt.MonVolStd+";容量(AH):"+batt.MonCapStd);
                    }
                    $('#battgroupname').append($option);
                }
                setDischageBattinfo(temp.fstate.dev_testgroupnum);
                
            }
        },
        error:function(){
            
        }
    });
}
 
 
// 设置参数
function setBTSParam(list, errorStatus) {
    // setDischageBattinfo(list[0].fsparam.BattGroupNum);                //设置被测电池组信息
    // console.log(list);
    if(list[0].fsparam.TestCmd == CMD_BTS_StartDischarge){
        $('#discharge_type').val(CMD_BTS_StartDischarge);
    }else if(list[0].fsparam.TestCmd == CMD_BTS_StartRESTest){
        $('#discharge_type').val(CMD_BTS_StartRESTest);
    }
    //console.info(list[0].fsparam.TestCmd);
    $('#discurr').val(list[0].fsparam.DisCurr);                                //放电电流
    $('#hourrate').val(list[0].fsparam.HourRate);                            //放电小时率
    $('#discap').val(list[0].fsparam.DisCap);                                //放电容量
    $('#distime').val(list[0].fsparam.DisTime);                                //放电时长
    $('#MonomerVol_low').val(list[0].fsparam.MonomerVol_Low.toFixed(3));                //单体下限阀值
    $('#GroupVol_low').val(list[0].fsparam.GroupVol_Low.toFixed(1));                    //组端下限阀值
    $('#MonomerlowCount').val(list[0].fsparam.MonomerLowCount);                //单体下限数量
    $('#OnlineVolLowAction').val(list[0].fsparam.OnlineLowAction%2);        //在线电压低处理    
    //console.info(list[i].fsparam.OnlineLowAction%2);
    $('#DCVolHighLimit').val(list[0].fsparam.DCVolHighLimit);
    $('#ChargeCurrSet').val(list[0].fsparam.ChargeCurrSet);
    $('#TempUpHighLimit').val(list[0].fsparam.MonomerTmp_High);
    
    // 充电电流
    $('#ChargeCurrSet').testVal('option', 'allOpts', {
        regVal: true
        ,update: true
        ,min: 0
        ,max: list[0].binf.charge_curr_max
        ,msg: '取值范围0~'+list[0].binf.charge_curr_max+'A'
    });
    
    // 设置文本值
    $('#ChargeCurrSetLabel .val-range').text('0~'+list[0].binf.charge_curr_max);
}
 
// 更新BTS设备测试信息
function updateBTSTestParam(param) {
    //console.info(param);
    loading.showLoading();
    // 根据内容设置参数
    $.ajax({     
        type: "post",                 
        url: "Fbs9100_setparamAction_action_update",                
        async:true,                
        dataType:'text',
        data:"json="+JSON.stringify(param),        
        success: function(data){ 
            data = eval('('+data+')');
            var model = eval('('+data.result+')');
            //console.info(model);
            if(model.code == 1){
                noContent.showNoContent("修改测试参数成功", true);
                var temp = {
                    num:CMD_61850_GETPARAM,
                    dev_id:param.dev_id,
                    TestCmd: 0
                };
                searchBTSTestParam(temp,true);                //重新读取一次测试参数
                
            }else{
                noContent.showNoContent('设置FBS9100参数失败,请检查网络');
            }
            loading.hideLoading();
        },
        error:function(){
            noContent.showNoContent('设置FBS9100参数失败,请检查网络');
            paramsBtn.startTest(false);
            loading.hideLoading();
        }                    
    });
}
 
// 获取BTS设备测试信息
function getBTSTestParam() {
    var param = {
        num:CMD_BTS_SetDischargeParm,
        dev_id:$('#dev_id').val(),                
        BattGroupNum:$('#battgropunum').val(),
        DisCurr:$('#discurr').val(),
        DisCap:$('#discap').val(),
        DisTime:$('#distime').val(),
        GroupVol_Low:$('#GroupVol_low').val(),
        HourRate:$('#hourrate').val(),
        MonomerLowCount:$('#MonomerlowCount').val(),
        MonomerVol_Low:$('#MonomerVol_low').val(),
        OnlineLowAction:$('#OnlineVolLowAction').val(),
        TestCmd:$('#discharge_type').val(),
        ChargeCurrSet:$('#ChargeCurrSet').val(),
        DCVolHighLimit:$('#DCVolHighLimit').val(),
        MonomerTmp_High: $('#TempUpHighLimit').val()
    };
    
    return param;
}
 
//发送指定的命令给BTS设备    (启动,停止)
function sendCmdToBTSDev(temp) {
    loading.showLoading();
    $.ajax({     
        type: "post",                 
        //url:"BTS_61850_setparamAction_61850action_updateCMd",
        url:"Fbs9100_setparamAction_action_serchbyDev_id",
        async:true,                
        dataType:'text',
        data:"json="+JSON.stringify(temp),        
        success: function(data){ 
            data = eval('('+data+')');
            var model = eval('('+data.result+')');
            //console.info(model);
            if(model.code == 1 ){                
                showBTSContent(temp.num,true);
            }else{                
                showBTSContent(temp.num,false);
            }
            loading.hideLoading();                    
        },
        error:function(){
            show61850Content(temp.num,false);
            loading.hideLoading();
            //LD9_popup.showPopup();    
        }                    
    });
}
 
// 显示启动信息
function showBTSContent(cmd, issuccess) {
    if(cmd == CMD_BTS_Start){
        if(issuccess){
            noContent.showNoContent("启动测试成功", true);
        }else{
            noContent.showNoContent("启动测试失败");
        }
    }else if(cmd == CMD_BTS_Stop){
        if(issuccess){
            noContent.showNoContent("停止测试成功", true);
        }else{
            noContent.showNoContent("停止测试失败");
        }
    }
}
 
//根据文本框内容设置61850的按钮状态
function setBTSPopupStatus(id, val) {
    var textList = BTS_popup.popup.find('input[type=text]');
    var selectList = BTS_popup.popup.find('.popup-tbl select');
    var initData = BTS_popup.popup.data().attr;
    var errorStatus = BTS_popup.popup.data().errorStatus; // 获取是否读取参数失败
    //console.log(BTS_popup.popup.data().attr);
    // 读取设备参数失败
    if(errorStatus) {
        BTSBtn.disabled();
        return false;    // 结束函数运行
    }
    
    // 遍历面板下的所有文本框查看是否有错误数据
    var isDisabled = false;
    textList.each(function() {
        if($(this).hasClass('error-data')) {
            isDisabled = true;
        }
    });
    
    // 存在错误的数据
    if(isDisabled) {
        BTSBtn.disabled();
        return false;    // 结束函数运行
    }else {
        BTSBtn.active();
    }
    
    // 遍历对比当前文本框的数据和原始数据是否一致
    for(var i=0; i<initData.length;i++) {
        // 遍历查询到当前的文本框
        if(initData[i].id == id) {
            if(initData[i].val == val) {
                BTSBtn.active();
            }else {
                BTSBtn.startTest(false);
            }
        }
    }
}