浏览代码

电池参数新增电池串数

DESKTOP-9JTA2JJ\HP 5 年之前
父节点
当前提交
751b15079a
共有 1 个文件被更改,包括 69 次插入52 次删除
  1. 69 52
      api/application/controllers/Lampcontrol.php

+ 69 - 52
api/application/controllers/Lampcontrol.php

@@ -964,7 +964,70 @@ class Lampcontrol extends Base_Controller {
         //$cmd = '{"cmd_type":"patrol_cmd","cmd_id":'.$where['id'].',"broadcast":0}';
         //$cmdret = send_cmd($cmd, 1);
     }
+    // 新控制器更新负载设置
+    public function modbus_set_load(){
+        $data['username'] = $this->input->post('username',true);
+        $data['client_key'] = $this->input->post('client_key',true);
+        $data['token'] = $this->input->post('token',true);
+        $data['lamp_id'] = $this->input->post('lamp_id',true);
+        $data['clientid'] = $this->input->post('clientid',true);
+        $data['version'] = $this->session->userdata('version');
 
+        // $data['light_voltage']         = $this->input->post('light_voltage',true);
+        $data['intell_power']    = $this->input->post('intell_power',true);
+        $data['load_current']   = $this->input->post('load_current',true);
+        $data['light_delay']  = $this->input->post('light_delay',true);
+        $data['induction_delay'] = $this->input->post('induction_delay',true);
+        $data['first_light_time']    = $this->input->post('first_light_time',true);
+        $data['first_light_human_power']   = $this->input->post('first_light_human_power',true);
+        $data['first_light_unman_power']    = $this->input->post('first_light_unman_power',true);
+        $data['second_light_time']   = $this->input->post('second_light_time',true);
+        $data['second_light_human_power']       = $this->input->post('second_light_human_power',true);
+        $data['second_light_unman_power']        = $this->input->post('second_light_unman_power',true);
+        $data['third_light_time']   = $this->input->post('third_light_time',true);
+        $data['third_light_human_power']         = $this->input->post('third_light_human_power',true);
+        $data['third_light_unman_power']    = $this->input->post('third_light_unman_power',true);
+        $data['fourth_light_time']    = $this->input->post('fourth_light_time',true);
+        $data['fourth_light_human_power']    = $this->input->post('fourth_light_human_power',true);
+        $data['fourth_light_unman_power']    = $this->input->post('fourth_light_unman_power',true);
+        $data['fifth_light_time']    = $this->input->post('fifth_light_time',true);
+        $data['fifth_light_human_power']    = $this->input->post('fifth_light_human_power',true);
+        $data['fifth_light_unman_power']    = $this->input->post('fifth_light_unman_power',true);
+        $data['sixth_light_time']    = $this->input->post('sixth_light_time',true);
+        $data['sixth_light_human_power']    = $this->input->post('sixth_light_human_power',true);
+        $data['sixth_light_unman_power']    = $this->input->post('sixth_light_unman_power',true);
+        $data['seventh_light_time']    = $this->input->post('seventh_light_time',true);
+        $data['seventh_light_human_power']    = $this->input->post('seventh_light_human_power',true);
+        $data['seventh_light_unman_power']    = $this->input->post('seventh_light_unman_power',true);
+        $data['eighth_light_time']    = $this->input->post('eighth_light_time',true);
+        $data['eighth_light_human_power']    = $this->input->post('eighth_light_human_power',true);
+        $data['eighth_light_unman_power']    = $this->input->post('eighth_light_unman_power',true);
+        $data['ninth_light_time']    = $this->input->post('ninth_light_time',true);
+        $data['ninth_light_human_power']    = $this->input->post('ninth_light_human_power',true);
+        $data['ninth_light_unman_power']    = $this->input->post('ninth_light_unman_power',true);
+        $data['tenth_light_time']    = $this->input->post('tenth_light_time',true);
+        $data['tenth_light_human_power']    = $this->input->post('tenth_light_human_power',true);
+        $data['tenth_light_unman_power']    = $this->input->post('tenth_light_unman_power',true);
+        $data['begin_voltage']    = $this->input->post('begin_voltage',true);
+        $data['end_voltage']    = $this->input->post('end_voltage',true);
+        $data['end_current']    = $this->input->post('end_current',true);
+        foreach ($data as $key => $value) {
+            $data[$key] = urldecode($value);
+        }
+        $lampArr = explode(',', $data['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/lampcontrol/modbus_set_load_asy';
+        foreach ($lampList as $l) {
+            $data['lamp_id'] = $l['id'];
+            if ($l['protocoltype'] == 0) {
+                doAsyncRequest($url,$data,30);
+            }else{
+                doAsyncRequest($url,$data);
+            }
+            
+        }
+        exit();
+    }
     // 更新负载设置
     public function set_load(){
         $username = $this->input->post('username',true);
@@ -1190,6 +1253,7 @@ class Lampcontrol extends Base_Controller {
         $data['role'] = $this->input->post('role',true);
         $data['version'] = $this->session->userdata('version');
         
+        $data['battery_count']                 = $this->input->post('battery_count',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) * 1000;  // 超压电压
@@ -1230,6 +1294,7 @@ class Lampcontrol extends Base_Controller {
         $where['id']                        = $this->input->post('lamp_id',true);//路灯id
 
         $data['system_voltage']                 = $this->input->post('system_voltage',true);  // 电池电压
+        $data['battery_count']                 = $this->input->post('battery_count',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);  // 充电限制电压
@@ -1255,7 +1320,7 @@ class Lampcontrol extends Base_Controller {
         $lampData = $this->Lamp_model->get_one($where,'projectid,address,number');
         $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') {
+            if ($k == 'system_voltage' || $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){
@@ -1264,6 +1329,8 @@ class Lampcontrol extends Base_Controller {
                 }else{
                     $word = substr('0000'.base_convert($v, 10, 16), -4);
                 }
+            }elseif ($k == 'battery_type' || $k == 'battery_count') {
+                $word = substr('0'.base_convert($v, 10, 16), -1);
             }else{
                 $word = substr('0000'.base_convert($v, 10, 16), -4);
             }
@@ -1658,57 +1725,6 @@ class Lampcontrol extends Base_Controller {
         exit(json_result('0000',$this->response['0000'],$update));
     }
 
-    // 获取默认参数值
-    public function get_data(){
-        $type = $this->input->post('type',true);
-        $type = empty($type) ? 1 : $type;
-        $update = array();
-        if ($type == 1) { // 负载参数
-            $update['workmode']         = '0';
-            $update['worktimefirst']    = '4';
-            $update['workpowerfirst']   = '80';
-            $update['worktimesencond']  = '1';
-            $update['workpowersencond'] = '40';
-            $update['worktimethird']    = '8';
-            $update['workpowerthird']   = '30';
-            $update['worktimeforth']    = '0';
-            $update['workpowerforth']   = '30';
-            $update['voptically']       = '5';
-            $update['delaytime']        = '1';
-            $update['ledloadcurrent']   = '330';
-            $update['powercmd']         = '1';
-            $update['switchfeature']    = '1';
-        }else{  // 蓄电池参数
-            $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';//充电模式
-        }
-        exit(json_result('0000',$this->response['0000'],$update));
-    }
-
     // 获取蓄电池设置
     public function battery_setting() {
         $lamp_id = $this->input->post('lamp_id', true);
@@ -1725,6 +1741,7 @@ class Lampcontrol extends Base_Controller {
         if (!empty($res)) {
             $info = unpack('H*', $res['msg'])[1];
             $data['system_voltage']                 = base_convert(substr($info, 18,2), 16, 10);  // 电池电压
+            $data['battery_count']                 = base_convert(substr($info, 20,1), 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);  // 充电限制电压