1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/9/3
- * Time: 8:05 PM
- */
- namespace App\Servers;
- use App\Maps\SettingCmdMap;
- use App\Models\BatteryTraitModel;
- use App\Models\CacheLogTraitModel;
- class BoxSelectCmdServer extends BaseServer
- {
- use CacheLogTraitModel, BatteryTraitModel;
- public function main($body)
- {
- $data = $this->decode($body);
- $this->cacheLog($data['msg_id'], $data['setting']);
- self::log($data, 'BoxSelectCmdServer', self::$LOG_MAJOR);
- return false;
- }
- /**
- * 解析装载的数据
- * @param $body
- * @return array
- * User: Mead
- */
- private function decode($body)
- {
- $arr = explode(BikeControl::SPLIT_TAG, implode('', $body));
- $setting = $_msg = $msg = '';
- if (count($arr) === 2) {
- list($setting, $_msg) = explode(BikeControl::SPLIT_TAG, implode('', $body));
- } else {
- $setting = $arr[0];
- }
- // $msg = $this->decodeMsgId($_msg);
- $setting = $this->decodeSetting($setting);
- foreach ($setting as $key => $item) {
- switch ($key) {
- case SettingCmdMap::SETTING_VIN:
- $setting[$key] = $this->byVoltageGetElectric($item / 1000);
- break;
- case SettingCmdMap::SETTING_ACCFILT:
- case SettingCmdMap::SETTING_FDZT:
- case SettingCmdMap::SETTING_OILSTATE:
- if ($item === 'FAIL') {
- $setting[$key] = "获取失败";
- } else {
- $setting[$key] = $item ? "打开" : "关闭";
- }
- break;
- }
- }
- return [
- 'setting' => $setting,
- 'msg_id' => $_msg,
- ];
- }
- }
|