decode($body); // self::dd($data); print_r($data); return $this->response(); } /** * 状态响应 * @param $login_type * @return array * User: Mead */ public function response($login_type = '00') { $body = [ '5b', '0000' ]; return $body; } /** * 解析装载的状态消息 * @param $body * @return array * User: Mead */ private function decode($body) { $top34Data = $this->decodeWeiKeMuTop34($body); $i = 34; // 控制器类型 $control_type = self::stitching($body, $i, 1); // i=34 $i += 1; // 电压 量化单位1mv $voltage = self::stitching($body, $i, 4); // i=35 $i += 4; //电流 量化单位1mA $electric = self::stitching($body, $i, 2); // i=39 $i += 2; // 500毫秒电机HALL数 $hall = self::stitching($body, $i, 2); // i=41 $i += 2; // 最高转速的百分比 $percentage_of_maximum_speed = self::stitching($body, $i, 1); // i=43 $i += 1; // 欠压值,量化单位1mv $undervoltage_value = self::stitching($body, $i, 2); // i=44 $i += 2; // 限流,量化单位1mv $current_limiting = self::stitching($body, $i, 2); // i=46 $i += 2; // 故障信息 $failure = self::stitching($body, $i, 1); // i=48 return array_merge($top34Data, [ 'control_type' => hexdec($control_type), 'voltage' => hexdec($voltage), 'electric' => hexdec($electric), 'hall' => hexdec($hall), 'percentage_of_maximum_speed' => hexdec($percentage_of_maximum_speed), 'undervoltage_value' => hexdec($undervoltage_value), 'current_limiting' => hexdec($current_limiting), 'failure' => $this->failure($failure), ]); } private function failure($val) { $data = self::handleU1($val); $res = [ '0' => $data[0], '1' => $data[1], '2' => $data[2], '3' => $data[3], '4' => $data[4], 'dianji' => $data[5], 'zhuanba' => $data[6], '7' => $data[7], ]; return $res; } }