|
@@ -1180,58 +1180,57 @@ class Lampcontrol extends Base_Controller {
|
|
|
return intval(explode(':', $date)[0]) * 3600 + intval(explode(':', $date)[1]) * 60;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 更新蓄电池设置
|
|
|
public function set_battery(){
|
|
|
$data['username'] = $this->input->post('username',true);
|
|
|
$data['client_key'] = $this->input->post('client_key',true);
|
|
|
- $data['role'] = $this->input->post('role',true);
|
|
|
$data['token'] = $this->input->post('token',true);
|
|
|
$lamp_id = $this->input->post('lamp_id',true);
|
|
|
$data['clientid'] = $this->input->post('clientid',true);
|
|
|
+ $data['role'] = $this->input->post('role',true);
|
|
|
$data['version'] = $this->session->userdata('version');
|
|
|
-
|
|
|
- $data['batterytype'] = $this->input->post('batterytype',true);//蓄电池类型
|
|
|
- $data['vovervoltage'] = $this->input->post('vovervoltage',true);//超压电压
|
|
|
- $data['vlimitedcharge'] = $this->input->post('vlimitedcharge',true);//充电限制电压
|
|
|
- // $vlimitedcharge = $this->input->post('vlimitedcharge',true);//Full charge voltage
|
|
|
- $data['vpromoterecover'] = $this->input->post('vpromoterecover',true);//充电返回电压
|
|
|
- $data['vpromotecharge'] = $this->input->post('vpromotecharge',true);//提升充电电压
|
|
|
- // $vpromotecharge = $this->input->post('vpromotecharge',true);//提升充电电压 Direct charge voltage
|
|
|
- $data['vfloatingcharge'] = $this->input->post('vfloatingcharge',true); // 浮充充电电压
|
|
|
- $data['voverdischargerecover'] = $this->input->post('voverdischargerecover',true); // 过放返回电压
|
|
|
- $data['tempcompmin'] = $this->input->post('tempcompmin',true); // 温度补偿最低温度
|
|
|
- $data['tempcompmax'] = $this->input->post('tempcompmax',true); // 温度补偿最高温度
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Reduced start voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Reduced end voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Light control voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Light control delay time
|
|
|
|
|
|
-
|
|
|
+ $data['system_voltage'] = $this->input->post('system_voltage',true); // 电池电压
|
|
|
+ $data['battery_type'] = $this->input->post('battery_type',true); //蓄电池类型
|
|
|
+ $data['overvoltage'] = $this->input->post('overvoltage',true) * 1000; // 超压电压
|
|
|
+ $data['char_limit_voltage'] = $this->input->post('char_limit_voltage',true) * 1000; // 充电限制电压
|
|
|
+ $data['equ_char_voltage'] = $this->input->post('equ_char_voltage',true) * 1000; // 均衡充电电压
|
|
|
+ $data['increa_char_voltage'] = $this->input->post('increa_char_voltage',true) * 1000; // 提升充电电压
|
|
|
+ $data['float_char_voltage'] = $this->input->post('float_char_voltage',true) * 1000; // 浮充充电电压
|
|
|
+ $data['increa_char_return_voltage'] = $this->input->post('increa_char_return_voltage',true) * 1000; // 提升充电返回电压
|
|
|
+ $data['over_dischar_return_voltage'] = $this->input->post('over_dischar_return_voltage',true) * 1000; // 过放返回电压
|
|
|
+ $data['battery_under_voltage'] = $this->input->post('battery_under_voltage',true) * 1000; // 欠压警告电压 新增
|
|
|
+ $data['over_dischar_voltage'] = $this->input->post('over_dischar_voltage',true) * 1000; // 过放电压
|
|
|
+ $data['discharge_limit_voltage'] = $this->input->post('discharge_limit_voltage',true) * 1000; // 放电限制电压 新增
|
|
|
+ $data['equ_char_time'] = $this->input->post('equ_char_time',true) * 60; // 均衡充电时间
|
|
|
+ $data['increa_char_time'] = $this->input->post('increa_char_time',true) * 60; // 提升充电时间
|
|
|
+ $data['balan_char_interval'] = $this->input->post('balan_char_interval',true); // 均衡充电间隔
|
|
|
+ $data['temper_compen_coeff'] = $this->input->post('temper_compen_coeff',true); // 温度补偿系数
|
|
|
+ $data['char_upper_limit_temper'] = $this->input->post('char_upper_limit_temper',true); // 上限温度
|
|
|
+ $data['char_lower_limit_temper'] = $this->input->post('char_lower_limit_temper',true); // 下限温度
|
|
|
+ $data['reduced_start_voltage'] = $this->input->post('reduced_start_voltage',true) * 1000; // 智能功率起始电压
|
|
|
+ $data['reduced_stop_voltage'] = $this->input->post('reduced_stop_voltage',true) * 1000; // 智能功率结束电压
|
|
|
+ $data['light_voltage'] = $this->input->post('light_voltage',true); // 光控电压
|
|
|
+ $data['light_delay_time'] = $this->input->post('light_delay_time',true); // 光控延时时间
|
|
|
+
|
|
|
$lampArr = explode(',', $lamp_id);
|
|
|
// $lampList = $this->Lamp_model->get_list_in('L.id', $lampArr, 'L.id,N.protocoltype', array());
|
|
|
$url = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/api/lampcontrol/set_battery_asy';
|
|
|
|
|
|
- foreach ($lampList as $l) {
|
|
|
- $data['lamp_id'] = $l;
|
|
|
+ foreach ($lampArr as $l) {
|
|
|
+ $data['lampid'] = $l;
|
|
|
doAsyncRequest($url,$data);
|
|
|
-
|
|
|
}
|
|
|
+ exit();
|
|
|
}
|
|
|
|
|
|
- // 新控制器更新蓄电池设置
|
|
|
- public function modbus_set_battery(){
|
|
|
- $data['username'] = $this->input->post('username',true);
|
|
|
- $data['client_key'] = $this->input->post('client_key',true);
|
|
|
- $data['token'] = $this->input->post('token',true);
|
|
|
- $lamp_id = $this->input->post('lamp_id',true);
|
|
|
- $data['clientid'] = $this->input->post('clientid',true);
|
|
|
- $data['role'] = $this->input->post('role',true);
|
|
|
- $data['version'] = $this->session->userdata('version');
|
|
|
+ //更新蓄电池设置
|
|
|
+ public function set_battery_asy(){
|
|
|
+ $clientid = $this->input->post('clientid',true);
|
|
|
+ $where['id'] = $this->input->post('lamp_id',true);//路灯id
|
|
|
|
|
|
-
|
|
|
- $data['battery_type'] = $this->input->post('battery_type',true); //蓄电池类型
|
|
|
$data['system_voltage'] = $this->input->post('system_voltage',true); // 电池电压
|
|
|
+ $data['battery_type'] = $this->input->post('battery_type',true); //蓄电池类型
|
|
|
$data['overvoltage'] = $this->input->post('overvoltage',true); // 超压电压
|
|
|
$data['char_limit_voltage'] = $this->input->post('char_limit_voltage',true); // 充电限制电压
|
|
|
$data['equ_char_voltage'] = $this->input->post('equ_char_voltage',true); // 均衡充电电压
|
|
@@ -1239,84 +1238,41 @@ class Lampcontrol extends Base_Controller {
|
|
|
$data['float_char_voltage'] = $this->input->post('float_char_voltage',true); // 浮充充电电压
|
|
|
$data['increa_char_return_voltage'] = $this->input->post('increa_char_return_voltage',true); // 提升充电返回电压
|
|
|
$data['over_dischar_return_voltage'] = $this->input->post('over_dischar_return_voltage',true); // 过放返回电压
|
|
|
+ $data['battery_under_voltage'] = $this->input->post('battery_under_voltage',true); // 欠压警告电压 新增
|
|
|
$data['over_dischar_voltage'] = $this->input->post('over_dischar_voltage',true); // 过放电压
|
|
|
+ $data['discharge_limit_voltage'] = $this->input->post('discharge_limit_voltage',true) * 60; // 放电限制电压 新增
|
|
|
$data['equ_char_time'] = $this->input->post('equ_char_time',true) * 60; // 均衡充电时间
|
|
|
$data['increa_char_time'] = $this->input->post('increa_char_time',true) * 60; // 提升充电时间
|
|
|
$data['balan_char_interval'] = $this->input->post('balan_char_interval',true); // 均衡充电间隔
|
|
|
$data['temper_compen_coeff'] = $this->input->post('temper_compen_coeff',true); // 温度补偿系数
|
|
|
$data['char_upper_limit_temper'] = $this->input->post('char_upper_limit_temper',true); // 上限温度
|
|
|
$data['char_lower_limit_temper'] = $this->input->post('char_lower_limit_temper',true); // 下限温度
|
|
|
+ $data['reduced_start_voltage'] = $this->input->post('reduced_start_voltage',true); // 智能功率起始电压
|
|
|
+ $data['reduced_stop_voltage'] = $this->input->post('reduced_stop_voltage',true); // 智能功率结束电压
|
|
|
$data['light_voltage'] = $this->input->post('light_voltage',true); // 光控电压
|
|
|
-
|
|
|
- $lampArr = explode(',', $lamp_id);
|
|
|
- // $lampList = $this->Lamp_model->get_list_in('L.id', $lampArr, 'L.id,N.protocoltype', array());
|
|
|
- $url = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/api/device/modbus_set_battery_asy';
|
|
|
+ $data['light_delay_time'] = $this->input->post('light_delay_time',true); // 光控延时时间
|
|
|
|
|
|
- foreach ($lampArr as $l) {
|
|
|
- $data['lampid'] = $l;
|
|
|
- doAsyncRequest($url,$data);
|
|
|
- }
|
|
|
- exit();
|
|
|
- }
|
|
|
-
|
|
|
- // public function set_battery_asy(){
|
|
|
- // $res = $this->battery_update();
|
|
|
- // $clientid = $this->input->post('clientid',true);
|
|
|
- // $lampid = $this->input->post('lamp_id',true);
|
|
|
- // $data = $this->Lamp_model->getData(array('id'=>$lampid),'projectid,networkid,address,number');
|
|
|
- // if ($res['msg'] == '0000') {
|
|
|
- // $projectData = $this->Project_model->getData(array('id'=>$data['projectid']),'projectname');
|
|
|
- // $networkData = $this->Network_model->getData(array('id'=>$data['networkid']),'networkname');
|
|
|
-
|
|
|
- // $this->add_operation_log('update',"修改\"{$projectData['projectname']}\"项目下的\"{$networkData['networkname']}\"网络里的编号为\"{$data['number']}\"、无线模块地址为\"{$data['address']}\"的路灯蓄电池参数");
|
|
|
- // $this->add_operation_log('update',"Update the lamp battery setting:\"{$data['number']}\".Wireless module address:\"{$data['address']}\".Project name:\"{$projectData['projectname']}\".Network name:\"{$networkData['networkname']}\".",0,1);
|
|
|
- // }
|
|
|
- // if (empty($res['result'])) {
|
|
|
- // // exit(json_result($res['msg'],$res['msg'],array('number'=>$data['number'])));
|
|
|
- // $data = ['code'=>$res['msg'],'status'=>2,'msg'=>$res['msg'],'data'=>['number'=>$data['number'],'type'=>'set_load','id'=>$lamp_id]];
|
|
|
- // exit(send_websocket($clientid,$data));
|
|
|
- // }else{
|
|
|
- // // exit(json_result($res['msg'],$this->response[$res['msg']],array('number'=>$data['number'])));
|
|
|
- // $data = ['code'=>$res['msg'],'status'=>2,'msg'=>$this->response[$res['msg']],'data'=>['number'=>$data['number'],'type'=>'set_load','id'=>$lamp_id]];
|
|
|
- // exit(send_websocket($clientid,$data));
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- //更新蓄电池设置
|
|
|
- public function set_battery_asy(){
|
|
|
- $clientid = $this->input->post('clientid',true);
|
|
|
- $where['id'] = $this->input->post('lamp_id',true);//路灯id
|
|
|
- $data['batterytype'] = $this->input->post('batterytype',true);//蓄电池类型
|
|
|
- $data['vovervoltage'] = $this->input->post('vovervoltage',true);//超压电压
|
|
|
- $data['vlimitedcharge'] = $this->input->post('vlimitedcharge',true);//充电限制电压
|
|
|
- // $vlimitedcharge = $this->input->post('vlimitedcharge',true);//Full charge voltage
|
|
|
- $data['vpromoterecover'] = $this->input->post('vpromoterecover',true);//充电返回电压
|
|
|
- $data['vpromotecharge'] = $this->input->post('vpromotecharge',true);//提升充电电压
|
|
|
- // $vpromotecharge = $this->input->post('vpromotecharge',true);//提升充电电压 Direct charge voltage
|
|
|
- $data['vfloatingcharge'] = $this->input->post('vfloatingcharge',true); // 浮充充电电压
|
|
|
- $data['voverdischargerecover'] = $this->input->post('voverdischargerecover',true); // 过放返回电压
|
|
|
- $data['tempcompmin'] = $this->input->post('tempcompmin',true); // 温度补偿最低温度
|
|
|
- $data['tempcompmax'] = $this->input->post('tempcompmax',true); // 温度补偿最高温度
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Reduced start voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Reduced end voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Light control voltage
|
|
|
- // $tempcompmax = $this->input->post('tempcompmax',true); // Light control delay time
|
|
|
$lampData = $this->Lamp_model->get_one($where,'projectid,address,number');
|
|
|
- $sendData = '100100010000000000';
|
|
|
- foreach ($data as $v) {
|
|
|
- if ($v === null || $v === '') {
|
|
|
- $lampData = $this->Lamp_model->getOne($where['id'],'number');
|
|
|
- $data = ['code'=>'0007','status'=>2,'msg'=>$this->response['0007'],'data'=>['number'=>$lampData['number'],'type'=>'set_load','id'=>$where['id']]];
|
|
|
- exit(send_websocket($clientid,$data));
|
|
|
+ $sendData = '';
|
|
|
+ foreach ($data as $k=>$v) {
|
|
|
+ if ($k == 'system_voltage' || $k == 'battery_type' || $k == 'light_voltage' || $k == 'light_delay_time' || $k == 'balan_char_interval' || $k == 'temper_compen_coeff') {
|
|
|
+ $word = substr('00'.base_convert($v, 10, 16), -2);
|
|
|
+ }elseif ($k == 'char_upper_limit_temper' || $k == 'char_lower_limit_temper') {
|
|
|
+ if ($v < 0){
|
|
|
+ $word = '1'.substr('0000000000000000'.base_convert(substr('0000'.base_convert(abs($v), 10, 16), -4), 16, 2), -15);
|
|
|
+ $word = substr('0000'.base_convert($word, 2, 16), -4);
|
|
|
+ }else{
|
|
|
+ $word = substr('0000'.base_convert($v, 10, 16), -4);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $word = substr('0000'.base_convert($v, 10, 16), -4);
|
|
|
}
|
|
|
+
|
|
|
+ $sendData .= $word;
|
|
|
}
|
|
|
-
|
|
|
- $len = doubBitSubStr(base_convert(intval(mb_strlen($sendData)/4), 10, 16)).bitSubStr(base_convert(intval(mb_strlen($sendData)/2), 10, 16));
|
|
|
- // $sendData = '0110e002'.$len.$sendData;
|
|
|
- $sendData .= crc16(pack('H*',$sendData));
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
|
|
|
-
|
|
|
+ $res = send_cmd('10',$lampData['address'],$sendData);
|
|
|
+
|
|
|
$lampData = $this->Lamp_model->getData(array('id'=>$lampid),'projectid,address,number');
|
|
|
if (!empty($res)) {
|
|
|
$projectData = $this->Project_model->get_one(array('id'=>$lampData['projectid']),'projectname');
|
|
@@ -1629,6 +1585,79 @@ class Lampcontrol extends Base_Controller {
|
|
|
$t = $t > 10 ? $t : '0'.$t;
|
|
|
return $h.':'.$t;
|
|
|
}
|
|
|
+
|
|
|
+ // 新控制器获取默认参数值
|
|
|
+ public function modbus_get_data(){
|
|
|
+ $type = $this->input->post('type',true);
|
|
|
+ $type = empty($type) ? 1 : $type;
|
|
|
+ $update = array();
|
|
|
+ if ($type == 1) { // 负载参数
|
|
|
+ $update['intell_power'] = '2';
|
|
|
+ $update['load_current'] = '0.9';
|
|
|
+ $update['light_delay'] = '20';
|
|
|
+ $update['induction_delay'] = '20';
|
|
|
+ $update['first_light_time'] = '00:30';
|
|
|
+ $update['first_light_human_power'] = '50';
|
|
|
+ $update['first_light_unman_power'] = '20';
|
|
|
+ $update['second_light_time'] = '00:30';
|
|
|
+ $update['second_light_human_power'] = '70';
|
|
|
+ $update['second_light_unman_power'] = '30';
|
|
|
+ $update['third_light_time'] = '02:00';
|
|
|
+ $update['third_light_human_power'] = '100';
|
|
|
+ $update['third_light_unman_power'] = '50';
|
|
|
+ $update['fourth_light_time'] = '00:30';
|
|
|
+ $update['fourth_light_human_power'] = '70';
|
|
|
+ $update['fourth_light_unman_power'] = '30';
|
|
|
+ $update['fifth_light_time'] = '00:30';
|
|
|
+ $update['fifth_light_human_power'] = '70';
|
|
|
+ $update['fifth_light_unman_power'] = '30';
|
|
|
+ $update['sixth_light_time'] = '04:00';
|
|
|
+ $update['sixth_light_human_power'] = '30';
|
|
|
+ $update['sixth_light_unman_power'] = '10';
|
|
|
+ $update['seventh_light_time'] = '00:00';
|
|
|
+ $update['seventh_light_human_power'] = '100';
|
|
|
+ $update['seventh_light_unman_power'] = '50';
|
|
|
+ $update['eighth_light_time'] = '00:00';
|
|
|
+ $update['eighth_light_human_power'] = '100';
|
|
|
+ $update['eighth_light_unman_power'] = '50';
|
|
|
+ $update['ninth_light_time'] = '00:00';
|
|
|
+ $update['ninth_light_human_power'] = '100';
|
|
|
+ $update['ninth_light_unman_power'] = '50';
|
|
|
+ $update['tenth_light_time'] = '00:00';
|
|
|
+ $update['tenth_light_human_power'] = '50';
|
|
|
+ $update['tenth_light_unman_power'] = '20';
|
|
|
+ $update['begin_voltage'] = '11.5';
|
|
|
+ $update['end_voltage'] = '10.0';
|
|
|
+ $update['end_current'] = '0.15';
|
|
|
+ }else{ // 蓄电池参数
|
|
|
+
|
|
|
+ $update['system_voltage'] = '12'; // 电池电压
|
|
|
+ $update['battery_type'] = '1'; //蓄电池类型
|
|
|
+ $update['overvoltage'] = '15.5'; // 超压电压
|
|
|
+ $update['char_limit_voltage'] = '15.0'; // 充电限制电压
|
|
|
+ $update['equ_char_voltage'] = '14.6'; // 均衡充电电压
|
|
|
+ $update['increa_char_voltage'] = '14.4'; // 提升充电电压
|
|
|
+ $update['float_char_voltage'] = '13.8'; // 浮充充电电压
|
|
|
+ $update['increa_char_return_voltage'] = '13.2'; // 提升充电返回电压
|
|
|
+ $update['over_dischar_return_voltage'] = '12.6'; // 过放返回电压
|
|
|
+ $update['battery_under_voltage'] = '12.0'; // 欠压警告电压 新增
|
|
|
+ $update['over_dischar_voltage'] = '11.1'; // 过放电压
|
|
|
+ $update['discharge_limit_voltage'] = '10.6'; // 放电限制电压 新增
|
|
|
+ $update['equ_char_time'] = '120'; // 均衡充电时间
|
|
|
+ $update['increa_char_time'] = '120'; // 提升充电时间
|
|
|
+ $update['balan_char_interval'] = '30'; // 均衡充电间隔
|
|
|
+ $update['temper_compen_coeff'] = '5'; // 温度补偿系数
|
|
|
+ $update['char_upper_limit_temper'] = '60'; // 上限温度
|
|
|
+ $update['char_lower_limit_temper'] = '-30'; // 下限温度
|
|
|
+ $update['reduced_start_voltage'] = '11.5'; // 智能功率起始电压
|
|
|
+ $update['reduced_stop_voltage'] = '10.0'; // 智能功率结束电压
|
|
|
+ $update['light_voltage'] = '5'; // 光控电压
|
|
|
+ $update['light_delay_time'] = '20'; // 光控延时时间
|
|
|
+
|
|
|
+ }
|
|
|
+ exit(json_result('0000',$this->response['0000'],$update));
|
|
|
+ }
|
|
|
+
|
|
|
// 获取默认参数值
|
|
|
public function get_data(){
|
|
|
$type = $this->input->post('type',true);
|
|
@@ -1687,147 +1716,53 @@ class Lampcontrol extends Base_Controller {
|
|
|
exit(json_result('0400', $this->response['0400'], array()));
|
|
|
}
|
|
|
|
|
|
- $lampData = $this->Lamp_model->getOne($lamp_id,'N.status,N.protocoltype,L.address,L.protocoltype as lampprotocoltype,L.number,N.deviceid');
|
|
|
- // if ($lampData['status'] == 0) {
|
|
|
- // exit(json_result('0412',$this->response['0412'],array()));
|
|
|
- // }
|
|
|
+ $lampData = $this->Lamp_model->get_one(['id'=>$lamp_id],'address,number');
|
|
|
|
|
|
- $cmd = '{"cmd_type":"get_battery_setting_cmd","cmd_id":'.$lamp_id.',"broadcast":0}';
|
|
|
+ $res = send_cmd('11',$lampData['address'],'');
|
|
|
|
|
|
- if (($lampData['protocoltype'] == 4 || $lampData['protocoltype'] == 6) && $lampData['lampprotocoltype'] == 0) {
|
|
|
- $address = '';
|
|
|
- if (mb_strlen($lampData['address']) >= 8) {
|
|
|
- $address = mb_substr($lampData['address'], -8);
|
|
|
+
|
|
|
+ $lampData = $this->Lamp_model->getData(array('id'=>$lampid),'projectid,address,number');
|
|
|
+ if (!empty($res)) {
|
|
|
+ $info = unpack('H*', $res['msg'])[1];
|
|
|
+ $data['system_voltage'] = base_convert(substr($info, 18,2), 16, 10); // 电池电压
|
|
|
+ $data['battery_type'] = base_convert(substr($info, 21,1), 16, 10); //蓄电池类型
|
|
|
+ $data['overvoltage'] = round(base_convert(substr($info, 22,4), 16, 10)/1000,1); // 超压电压
|
|
|
+ $data['char_limit_voltage'] = round(base_convert(substr($info, 26,4), 16, 10)/1000,1); // 充电限制电压
|
|
|
+ $data['equ_char_voltage'] = round(base_convert(substr($info, 30,4), 16, 10)/1000,1); // 均衡充电电压
|
|
|
+ $data['increa_char_voltage'] = round(base_convert(substr($info, 34,4), 16, 10)/1000,1); // 提升充电电压
|
|
|
+ $data['float_char_voltage'] = round(base_convert(substr($info, 38,4), 16, 10)/1000,1); // 浮充充电电压
|
|
|
+ $data['increa_char_return_voltage'] = round(base_convert(substr($info, 42,4), 16, 10)/1000,1); // 提升充电返回电压
|
|
|
+ $data['over_dischar_return_voltage'] = round(base_convert(substr($info, 46,4), 16, 10)/1000,1); // 过放返回电压
|
|
|
+ $data['battery_under_voltage'] = round(base_convert(substr($info, 50,4), 16, 10)/1000,1); // 欠压警告电压 新增
|
|
|
+ $data['over_dischar_voltage'] = round(base_convert(substr($info, 54,4), 16, 10)/1000,1); // 过放电压
|
|
|
+ $data['discharge_limit_voltage'] = round(base_convert(substr($info, 58,4), 16, 10)/1000,1); // 放电限制电压 新增
|
|
|
+ $data['equ_char_time'] = base_convert(substr($info, 62,4), 16, 10); // 均衡充电时间
|
|
|
+ $data['increa_char_time'] = base_convert(substr($info, 66,4), 16, 10); // 提升充电时间
|
|
|
+ $data['balan_char_interval'] = base_convert(substr($info, 70,2), 16, 10); // 均衡充电间隔
|
|
|
+ $data['temper_compen_coeff'] = base_convert(substr($info, 72,2), 16, 10); // 温度补偿系数
|
|
|
+
|
|
|
+ $char_upper_limit_temper = base_convert(substr($info, 74,2), 16, 2); // 上限温度
|
|
|
+ if (substr(substr('00000000'.$char_upper_limit_temper, -8), 0,1) == 1) {
|
|
|
+ $data['char_upper_limit_temper'] = 0 - base_convert(substr('0000000'.$char_upper_limit_temper, -7), 2, 10);
|
|
|
}else{
|
|
|
- $address = '00000000';
|
|
|
+ $data['char_upper_limit_temper'] = base_convert($char_upper_limit_temper, 2, 10);
|
|
|
}
|
|
|
- $sendData = $address.'030328204b';
|
|
|
-
|
|
|
- if ($lampData['protocoltype'] == 4) {
|
|
|
- $res = lampMqttCmd('/IDCOL/CmdInput/'.$lampData['address'],'/IDCOL/CmdOutput/'.$lampData['address'],pack('H*','0001'.$sendData));
|
|
|
+ $char_lower_limit_temper = base_convert(substr($info, 76,2), 16, 2); // 下限温度
|
|
|
+ if (substr(substr('00000000'.$char_lower_limit_temper, -8), 0,1) == 1) {
|
|
|
+ $data['char_lower_limit_temper'] = 0 - base_convert(substr('0000000'.$char_lower_limit_temper, -7), 2, 10);
|
|
|
}else{
|
|
|
- device_cmd($lampData['deviceid'],pack('H*',$sendData));
|
|
|
- $cmd = '{"type":"cmd","deviceId":"'.$lampData['address'].'"}';
|
|
|
- $info = send_lorawan_915($cmd);
|
|
|
- $res = array();
|
|
|
- if (!empty($info)) {
|
|
|
- $info = json_decode($info,true);
|
|
|
- if ($info && $info['res'] == 0) $res['msg'] = $info['resInfo'];
|
|
|
- }
|
|
|
+ $data['char_lower_limit_temper'] = base_convert($char_lower_limit_temper, 2, 10);
|
|
|
}
|
|
|
|
|
|
- if (empty($res)) {
|
|
|
- exit(json_result('0016', $this->response['0016']));
|
|
|
- }else{
|
|
|
- $msg1 = $res['msg'];
|
|
|
- // 数据校验
|
|
|
- $msg = mb_substr($msg1, 10);
|
|
|
- $t = 0;
|
|
|
- for ($i=0; $i < mb_strlen($msg) / 2 - 1; $i++) {
|
|
|
- $s = mb_substr($msg, $i*2,2);
|
|
|
- $t += base_convert($s, 16, 10);
|
|
|
- }
|
|
|
- $t = base_convert($t, 10, 16);
|
|
|
- if (mb_strlen($t) > 2) {
|
|
|
- $t = mb_substr($t, -2);
|
|
|
- }elseif($t <= 1){
|
|
|
- $t = '0'.$t;
|
|
|
- }
|
|
|
- if ($t == mb_substr($msg, -2)) {
|
|
|
- $data = array();
|
|
|
- $dataStr = mb_substr($msg1, 16);
|
|
|
- $data['batterytype'] = base_convert(mb_substr($dataStr, 56,2), 16, 10);//蓄电池类型
|
|
|
- $data['capacity'] = base_convert(mb_substr($dataStr, 0,4), 16, 10);//蓄电池容量
|
|
|
- $data['capacity1'] = base_convert(mb_substr($dataStr, 0,4), 16, 10);//蓄电池容量
|
|
|
- $data['vovervoltage'] = round(base_convert(mb_substr($dataStr, 4,4), 16, 10)/10,1);//超压电压
|
|
|
- $data['vlimitedcharge'] = round(base_convert(mb_substr($dataStr, 8,4), 16, 10)/10,1);//充电限制电压
|
|
|
- $data['vbalancecharge'] = round(base_convert(mb_substr($dataStr, 12,4), 16, 10)/10,1);//均衡充电电压
|
|
|
- $data['vpromotecharge0'] = round(base_convert(mb_substr($dataStr, 16,4), 16, 10)/10,1);//提升充电电压/过充电压(锂电池)
|
|
|
- $data['vpromotecharge1'] = round(base_convert(mb_substr($dataStr, 16,4), 16, 10)/10,1);//提升充电电压/过充电压(锂电池)
|
|
|
- $data['vfloatingcharge'] = round(base_convert(mb_substr($dataStr, 20,4), 16, 10)/10,1);//浮充充电电压
|
|
|
- $data['vpromoterecover0'] = round(base_convert(mb_substr($dataStr, 24,4), 16, 10)/10,1);//提升充电恢复电压/过充返回电压(锂电池)
|
|
|
- $data['vpromoterecover1'] = round(base_convert(mb_substr($dataStr, 24,4), 16, 10)/10,1);//提升充电恢复电压/过充返回电压(锂电池)
|
|
|
- $data['voverdischargerecover0'] = round(base_convert(mb_substr($dataStr, 28,4), 16, 10)/10,1);//过放恢复电压
|
|
|
- $data['voverdischargerecover1'] = round(base_convert(mb_substr($dataStr, 28,4), 16, 10)/10,1);//过放恢复电压
|
|
|
- $data['vundervoltagewarn'] = round(base_convert(mb_substr($dataStr, 32,4), 16, 10)/10,1);//欠压警告电压
|
|
|
- $data['voverdischarge0'] = round(base_convert(mb_substr($dataStr, 36,4), 16, 10)/10,1);//过放电压
|
|
|
- $data['voverdischarge1'] = round(base_convert(mb_substr($dataStr, 36,4), 16, 10)/10,1);//过放电压
|
|
|
- $data['balancechargetime'] = base_convert(mb_substr($dataStr, 40,2), 16, 10);//均衡充电时间
|
|
|
- $data['promotechargetime'] = base_convert(mb_substr($dataStr, 42,2), 16, 10);//提升充电时间
|
|
|
- $data['balanceinterval'] = base_convert(mb_substr($dataStr, 44,2), 16, 10);//均衡充电间隔
|
|
|
- $data['tempcompensation'] = base_convert(mb_substr($dataStr, 46,2), 16, 10);//温度补偿系数
|
|
|
- $data['tempcompmax'] = bitDecode(mb_substr($dataStr, 48,2));//温度补偿最高温度
|
|
|
- $data['tempcompmin'] = bitDecode(mb_substr($dataStr, 50,2));//温度补偿最低温度
|
|
|
- $data['turnfloatingcurrent'] = round(base_convert(mb_substr($dataStr, 52,4), 16, 10)/100,2);//转浮充的电流
|
|
|
- $data['vsystem'] = base_convert(mb_substr($dataStr, 58,2), 16, 10);//系统电压
|
|
|
- $data['minusnocharge'] = base_convert(mb_substr($dataStr, 60,2), 16, 10);//零下禁充
|
|
|
- $data['chargemode'] = base_convert(mb_substr($dataStr, 62,2), 16, 10);//充电模式
|
|
|
- exit(json_result('0000', $this->response['0000'], $data));
|
|
|
- }else{
|
|
|
- exit(json_result('0010', $this->response['0010']));
|
|
|
- }
|
|
|
- }
|
|
|
+ $data['reduced_start_voltage'] = round(base_convert(substr($info, 78,4), 16, 10)/1000,1); // 智能功率起始电压
|
|
|
+ $data['reduced_stop_voltage'] = round(base_convert(substr($info, 82,4), 16, 10)/1000,1); // 智能功率结束电压
|
|
|
+ $data['light_voltage'] = base_convert(substr($info, 86,2), 16, 10); // 光控电压
|
|
|
+ $data['light_delay_time'] = base_convert(substr($info, 88,2), 16, 10); // 光控延时时间
|
|
|
|
|
|
- }
|
|
|
- if (isset($lampData['protocoltype']) && $lampData['protocoltype'] != 0) {
|
|
|
- $cmdret = send_cmd($cmd,1,30,$lampData['protocoltype']);
|
|
|
- if ($cmdret === false) {
|
|
|
- sleep(1);
|
|
|
- $cmdret = send_cmd($cmd,1,30,$lampData['protocoltype']);
|
|
|
- }
|
|
|
+ exit(json_result('0000',$this->response['0000'],$data));
|
|
|
}else{
|
|
|
- $cmdret = send_cmd($cmd,0,30,$lampData['protocoltype']);
|
|
|
- if ($cmdret === false) {
|
|
|
- sleep(1);
|
|
|
- $cmdret = send_cmd($cmd,0,30,$lampData['protocoltype']);
|
|
|
- }
|
|
|
+ exit(json_result('0016',$this->response['0016']));
|
|
|
}
|
|
|
- if (empty($cmdret)) exit(json_result('0016',$this->response['0016']));
|
|
|
- $r = json_decode($cmdret, true);
|
|
|
- if ($r['result'] == false) {
|
|
|
- $version = $this->session->userdata('version');
|
|
|
- if (empty($version)) {
|
|
|
- $msg = empty($r['msg']) ? '未知错误' : transfer_error_tips($r['msg']);
|
|
|
- }else{
|
|
|
- $msg = empty($r['msg']) ? 'Unknown error' : $r['msg'];
|
|
|
- }
|
|
|
- exit(json_result('other', $msg));
|
|
|
- }
|
|
|
- $res = $this->Battery_model->getOne($lamp_id);
|
|
|
- if (empty($res)) {
|
|
|
- $update['batterytype'] = '0';//蓄电池类型
|
|
|
- $update['capacity0'] = '200';//蓄电池容量
|
|
|
- $update['capacity1'] = '';//蓄电池容量
|
|
|
- $update['vovervoltage'] = '16';//超压电压
|
|
|
- $update['vlimitedcharge'] = '15.5';//充电限制电压
|
|
|
- $update['vbalancecharge'] = '14.6';//均衡充电电压
|
|
|
- $update['vpromotecharge0'] = '14.4';//提升充电电压/过充电压(锂电池)
|
|
|
- $update['vpromotecharge1'] = '12.6';//提升充电电压/过充电压(锂电池)
|
|
|
- $update['vfloatingcharge'] = '13.8';//浮充充电电压
|
|
|
- $update['vpromoterecover0'] = '13.2';//提升充电恢复电压/过充返回电压(锂电池)
|
|
|
- $update['vpromoterecover1'] = '12';//提升充电恢复电压/过充返回电压(锂电池)
|
|
|
- $update['voverdischargerecover0'] = '12.6';//过放恢复电压
|
|
|
- $update['voverdischargerecover1'] = '11';//过放恢复电压
|
|
|
- $update['vundervoltagewarn'] = '12';//欠压警告电压
|
|
|
- $update['voverdischarge0'] = '11';//过放电压
|
|
|
- $update['voverdischarge1'] = '9';//过放电压
|
|
|
- $update['balancechargetime'] = '1';//均衡充电时间
|
|
|
- $update['promotechargetime'] = '4';//提升充电时间
|
|
|
- $update['balanceinterval'] = '30';//均衡充电间隔
|
|
|
- $update['tempcompensation'] = '-4';//温度补偿系数
|
|
|
- $update['tempcompmax'] = '99';//温度补偿最高温度
|
|
|
- $update['tempcompmin'] = '-40';//温度补偿最低温度
|
|
|
- $update['turnfloatingcurrent'] = '20';//转浮充的电流
|
|
|
- $update['vsystem'] = '12';//系统电压
|
|
|
- $update['minusnocharge'] = '0';//零下禁充
|
|
|
- $update['chargemode'] = '0';//充电模式
|
|
|
- $res = $update;
|
|
|
- }
|
|
|
-
|
|
|
- $data = $res;
|
|
|
- unset($data['id']);
|
|
|
- unset($data['updatetime']);
|
|
|
- exit(json_result('0000', $this->response['0000'], $data));
|
|
|
}
|
|
|
|
|
|
// 灯控相关数据
|