BikeControl.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/9/5
  6. * Time: 9:36 PM
  7. */
  8. namespace App\Servers\Weikemu;
  9. use App\Handlers\ExceptionTrait;
  10. use App\Servers\Weikemu\Maps\VideoMap;
  11. use GatewayWorker\Lib\Gateway;
  12. class BikeControl
  13. {
  14. use ExceptionTrait;
  15. private static $start = '42 44';
  16. private static $registerAddress = 'node1:11001';
  17. /**
  18. * 播放语音
  19. * @param $box_no
  20. * @return bool
  21. * User: Mead
  22. */
  23. public static function playVoice($box_no, $voice_no = '09')
  24. {
  25. $cmd = "2A";
  26. $body = [
  27. self::getMsgId(),
  28. '01',
  29. $voice_no,
  30. 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',
  31. 'FF FF FF FF',
  32. 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',
  33. 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',
  34. ];
  35. $send_msg = self::makeSendMsg($cmd, $body);
  36. return self::send($box_no, $send_msg, false);
  37. }
  38. /**
  39. * queryCmd 3.2.1 查询指令
  40. *
  41. * @param $box_no
  42. * @return bool
  43. * @author Fx
  44. *
  45. */
  46. public static function queryCmd($box_no, $str2 = '00111101')
  47. {
  48. // echo 'queryCmd' . PHP_EOL;
  49. $cmd = "2B";
  50. // $str2 = '00111101'; // 3d
  51. $body = [
  52. self::getMsgId(),
  53. str_pad(base_convert($str2, 2, 16), 2, 0, STR_PAD_LEFT)
  54. ];
  55. $send_msg = self::makeSendMsg($cmd, $body);
  56. // echo $send_msg . PHP_EOL;
  57. return self::send($box_no, $send_msg);
  58. }
  59. /**
  60. * electricSwitchControl 电门控制
  61. *
  62. * @param $box_no
  63. * @param $control 01 电门开启; 00 电门关闭(关闭防盗开关);02 电门关闭(开启防盗开关);
  64. * @return bool
  65. * @author Fx
  66. *
  67. */
  68. public static function electricSwitchControl($box_no, $control = "01")
  69. {
  70. // echo 'kaiguansuo' . PHP_EOL;
  71. $cmd = "2D";
  72. $body = [
  73. self::getMsgId(),
  74. $control,// 01 电门开启; 00 电门关闭(关闭防盗开关);02 电门关闭(开启防盗开关);
  75. ];
  76. $send_msg = self::makeSendMsg($cmd, $body);
  77. return self::send($box_no, $send_msg);
  78. }
  79. /**
  80. * realLocation 3.2.2 实时位置上报参数设置
  81. *
  82. * @param $box_no
  83. * @param string $control 01:实时追踪开启,00:实时追踪关闭
  84. * @param int $interval 上报间隔 秒 量化值30
  85. * @param int $continued 持续时长(1-43200) 分钟
  86. * @return bool
  87. * @author Fx
  88. *
  89. */
  90. public static function realLocation($box_no, $control = "01", $interval = 1, $continued = 60)
  91. {
  92. $cmd = "23";
  93. $body = [
  94. self::getMsgId(),
  95. $control,// 1:实时追踪开启,0:实时追踪关闭
  96. str_pad(base_convert($interval, 10, 16), 4, 0, STR_PAD_LEFT),//上报间隔
  97. str_pad(base_convert($continued, 10, 16), 4, 0, STR_PAD_LEFT),//持续时长(1-43200)
  98. ];
  99. $send_msg = self::makeSendMsg($cmd, $body);
  100. return self::send($box_no, $send_msg);
  101. }
  102. /**
  103. * multipleConfigsSetting 3.2.3 综合配置参数设置
  104. *
  105. * @param $box_no
  106. * @param $arr
  107. * @return bool
  108. * @author Fx
  109. *
  110. */
  111. public static function multipleConfigsSetting($box_no, $arr)
  112. {
  113. $cmd = "2C";
  114. // ['ip' => $ip,'port' => $port,'bluetooth_name' => $bluetooth_name,'bluetooth_token' => $bluetooth_token,
  115. // 'is_auto_lock' => $is_auto_lock, 'auto_lock_time' => $auto_lock_time,
  116. // 'is_displacement' => $is_displacement, 'displacement_radius' => $displacement_radius,
  117. // 'is_shock' => $is_shock,
  118. // 'is_temperature' => $is_temperature,'temperature' => $temperature,
  119. // 'is_speeding' => $is_speeding,'speeding'=>$speeding,
  120. // 'motion_position_sampling_interval'=>$motion_position_sampling_interval,
  121. // 'motion_position_reporting_interval'=>$motion_position_reporting_interval,
  122. // 'static_position_reporting_interval'=>$static_position_reporting_interval];
  123. $ip = $arr['ip'];
  124. $port = $arr['port'];
  125. $bluetooth_name = $arr['bluetooth_name']; // 蓝牙名称
  126. $bluetooth_token = $arr['bluetooth_token']; //蓝牙token
  127. $is_auto_lock = $arr['is_auto_lock']; // 是否开启自动落锁1:自动落锁开启;0:关闭自动落锁
  128. $auto_lock_time = str_pad(base_convert($arr['auto_lock_time'], 10, 2), 7, 0, STR_PAD_LEFT); // 自动落锁时长,量化单位1分钟
  129. $is_displacement = $arr['is_displacement']; // 位移告警开启设置1:位移告警开启;0: 位移告警关闭
  130. $displacement_radius = str_pad(base_convert($arr['displacement_radius'], 10, 2), 7, 0, STR_PAD_LEFT); // 位移告警半径门限,取值范围0~126,量化单位10米
  131. $is_shock = $arr['is_shock'];//震动告警开启设置1:震动告警开启,0:震动告警关闭
  132. $is_temperature = $arr['is_temperature'];//温度告警开启设置。1:温度告警开启;0:温度告警关闭
  133. $temperature = str_pad(base_convert($arr['temperature'], 10, 2), 7, 0, STR_PAD_LEFT); // 温度告警门限,取值范围0~126,
  134. $is_speeding = $arr['is_speeding']; // 超速告警开启设置。1:超速告警开启;0:超速告警关闭
  135. $speeding = str_pad(base_convert($arr['speeding'] * 2, 10, 2), 7, 0, STR_PAD_LEFT); // 超速告警门限 量化单位2km/h,范围 0~126
  136. $motion_position_sampling_interval = $arr['motion_position_sampling_interval']; // 运动状态,位置采样间隔设置(默认1秒)
  137. $motion_position_reporting_interval = $arr['motion_position_reporting_interval']; // 运动状态,位置上报间隔设置
  138. $static_position_reporting_interval = $arr['static_position_reporting_interval']; // 静止状态,位置上报间隔设置
  139. $body = [
  140. self::getMsgId(),
  141. str_pad(base_convert($motion_position_sampling_interval, 10, 16), 2, 0, STR_PAD_LEFT),// 运动状态,位置采样间隔设置(默认1秒)
  142. str_pad(base_convert($motion_position_reporting_interval, 10, 16), 2, 0, STR_PAD_LEFT),// 运动状态,位置上报间隔设置
  143. str_pad(base_convert($static_position_reporting_interval, 10, 16), 4, 0, STR_PAD_LEFT),// 静止状态,位置上报间隔设置
  144. str_pad(base_convert($displacement_radius . $is_displacement, 2, 16), 2, 0, STR_PAD_LEFT),// 位移告警
  145. str_pad(base_convert('0000000' . $is_shock, 2, 16), 2, 0, STR_PAD_LEFT),// 震动告警
  146. str_pad(base_convert($temperature . $is_temperature, 2, 16), 2, 0, STR_PAD_LEFT),// 温度告警
  147. str_pad(base_convert($speeding . $is_speeding, 2, 16), 2, 0, STR_PAD_LEFT),// 超速告警
  148. str_pad(base_convert($auto_lock_time . $is_auto_lock, 2, 16), 2, 0, STR_PAD_LEFT),// 自动落锁
  149. str_pad(base_convert($port, 10, 16), 4, 0, STR_PAD_LEFT),// 自动落锁
  150. str_pad(base_convert($ip, 10, 16), 8, 0, STR_PAD_LEFT),// 自动落锁
  151. str_pad($bluetooth_name, 10, 0, STR_PAD_LEFT),
  152. str_pad(base_convert($bluetooth_token, 10, 16), 8, 0, STR_PAD_LEFT),// 自动落锁
  153. '00 00 00 00 00 00'
  154. ];
  155. $send_msg = self::makeSendMsg($cmd, $body);
  156. return self::send($box_no, $send_msg);
  157. }
  158. /**
  159. * reboot 重启中控
  160. *
  161. * @param $box_no
  162. * @param $reboot string 11:重启升级;01:重启不升级
  163. * @param $ip string 重启升级地址(域名或IP地址)
  164. * @param $port int 重启升级端口号
  165. * @param $path string 重启升级路径
  166. * @param $upFile string 重启升级文件名称
  167. * @return bool
  168. * @author Fx
  169. *
  170. */
  171. public static function reboot($box_no, $reboot = "01", $ip, $port, $path, $upFile)
  172. {
  173. $cmd = "25";
  174. $reboot = '000000' . $reboot; // 11:重启升级;01:重启不升级
  175. $body = [
  176. self::getMsgId(),
  177. self::str2Hex($reboot, 2, 8),
  178. self::char2Hex($ip, 20),
  179. self::str2Hex($port, 10, 8),
  180. self::char2Hex($path, 20),
  181. self::char2Hex($upFile, 20),
  182. ];
  183. $send_msg = self::makeSendMsg($cmd, $body);
  184. return self::send($box_no, $send_msg);
  185. }
  186. /**
  187. * settingVoice 语音设置
  188. *
  189. * @param $box_no
  190. * @param $voice_no
  191. * @param $ip
  192. * @param $port
  193. * @param $path
  194. * @param $upFile
  195. * @return bool
  196. * @author Fx
  197. *
  198. */
  199. public static function settingVoice($box_no, $voice_no, $ip, $port, $path, $upFile)
  200. {
  201. $cmd = "2A";
  202. $body = [
  203. self::getMsgId(),
  204. '00',
  205. self::str2Hex($voice_no, 10, 2),
  206. self::char2Hex($ip, 20),
  207. self::str2Hex($port, 10, 8),
  208. self::char2Hex($path, 20),
  209. self::char2Hex($upFile, 20),
  210. ];
  211. $send_msg = self::makeSendMsg($cmd, $body);
  212. return self::send($box_no, $send_msg);
  213. }
  214. /**
  215. * setBoxSetting 配置中控
  216. *
  217. * @param $box_no
  218. * @param $arr
  219. * @return bool
  220. * @author Fx
  221. *
  222. */
  223. public static function setBoxSetting($box_no, $arr)
  224. {
  225. $cmd = "2C";
  226. // Log::info($arr['auto_lock_time']);
  227. $auto_lock_time = str_pad(base_convert($arr['auto_lock_time'], 10, 2), 7, 0, STR_PAD_LEFT); // 自动落锁时长,量化单位1分钟
  228. $ipArr = explode('.', $arr['ip']);
  229. $ip = self::decToHex($ipArr[0]) . self::decToHex($ipArr[1]) . self::decToHex($ipArr[2]) . self::decToHex($ipArr[3]);
  230. $port = str_pad(base_convert($arr['port'], 10, 16), 4, 0, STR_PAD_LEFT);
  231. // 中控升级后调整
  232. // $ip = 'FF FF FF FF';
  233. // $port = 'FF FF';
  234. $body = [
  235. self::getMsgId(),
  236. 'FF',// 运动状态,位置采样间隔设置(默认1秒)
  237. str_pad(base_convert($arr['motion_position_reporting_interval'], 10, 16), 2, 0, STR_PAD_LEFT),// 运动状态,位置上报间隔设置
  238. str_pad(base_convert($arr['static_position_reporting_interval'], 10, 16), 4, 0, STR_PAD_LEFT),// 静止状态,位置上报间隔设置
  239. 'FF',// 位移告警
  240. 'FF',// 震动告警
  241. 'FF',// 温度告警
  242. 'FF',// 超速告警
  243. str_pad(base_convert($auto_lock_time . '1', 2, 16), 2, 0, STR_PAD_LEFT),// 自动落锁
  244. // 'FF FF',
  245. $port,// port
  246. $ip,
  247. // str_pad(base_convert($arr['ip'], 10, 16), 8, 0, STR_PAD_LEFT),// ip
  248. 'FF FF FF FF FF FF FF FF FF FF',// 20位
  249. 'FF FF FF FF ',//
  250. 'FF FF FF FF FF FF'
  251. ];
  252. $send_msg = self::makeSendMsg($cmd, $body);
  253. return self::send($box_no, $send_msg);
  254. }
  255. /**
  256. * guardSwitch 3.2.7 防盗开关设置
  257. *
  258. * @param $box_no
  259. * @param $control 00:关闭 01:开启
  260. * @return bool
  261. * @author Fx
  262. *
  263. */
  264. public static function guardSwitch($box_no, $control)
  265. {
  266. $cmd = "2E";
  267. $body = [
  268. self::getMsgId(),
  269. $control
  270. ];
  271. $send_msg = self::makeSendMsg($cmd, $body);
  272. return self::send($box_no, $send_msg);
  273. }
  274. /**
  275. * batterySwitch 3.2.8 电池仓开关设置
  276. *
  277. * @param $box_no
  278. * @return bool
  279. * @author Fx
  280. *
  281. */
  282. public static function batterySwitch($box_no)
  283. {
  284. $cmd = "2F";
  285. $body = [
  286. self::getMsgId(),
  287. '01',
  288. ];
  289. $send_msg = self::makeSendMsg($cmd, $body);
  290. return self::send($box_no, $send_msg);
  291. }
  292. /**
  293. * limitSpeed 限速
  294. *
  295. * @param $box_no
  296. * @param $limit int 限速[%]
  297. * @return bool
  298. * @author Fx
  299. *
  300. */
  301. public static function limitSpeed($box_no, $limit)
  302. {
  303. $cmd = "30";
  304. $body = [
  305. self::getMsgId(),
  306. self::str2Hex($limit, 10, 2),// 限速[%]
  307. ];
  308. $send_msg = self::makeSendMsg($cmd, $body);
  309. return self::send($box_no, $send_msg);
  310. }
  311. /**
  312. * undervoltageProtection 3.2.10 控制器欠压保护设置
  313. *
  314. * @param $box_no
  315. * @param $limit int 控制器欠压保护值,量单位1mv
  316. * @return bool
  317. * @author Fx
  318. *
  319. */
  320. public static function undervoltageProtection($box_no, $limit)
  321. {
  322. $cmd = "31";
  323. $body = [
  324. self::getMsgId(),
  325. self::str2Hex($limit, 10, 4),// 限速[%]
  326. ];
  327. $send_msg = self::makeSendMsg($cmd, $body);
  328. return self::send($box_no, $send_msg);
  329. }
  330. /**
  331. * currentLimitingProtection 3.2.11 控制器限流保护设置
  332. *
  333. * @param $box_no
  334. * @param $limit int 控制器限流保护值,量化单位1mA
  335. * @return bool
  336. * @author Fx
  337. *
  338. */
  339. public static function currentLimitingProtection($box_no, $limit)
  340. {
  341. $cmd = "32";
  342. $body = [
  343. self::getMsgId(),
  344. self::str2Hex($limit, 10, 4),//
  345. ];
  346. $send_msg = self::makeSendMsg($cmd, $body);
  347. return self::send($box_no, $send_msg);
  348. }
  349. /**
  350. * slowReboot 3.2.12 控制器缓启动设置
  351. *
  352. * @param $box_no
  353. * @param $control string 01,缓启动;00,快启动
  354. * @return bool
  355. * @author Fx
  356. *
  357. */
  358. public static function slowReboot($box_no, $control)
  359. {
  360. $cmd = "33";
  361. $body = [
  362. self::getMsgId(),
  363. $control,
  364. ];
  365. $send_msg = self::makeSendMsg($cmd, $body);
  366. return self::send($box_no, $send_msg);
  367. }
  368. /**
  369. * lampSwitch 3.2.13 控制器大灯设置
  370. *
  371. * @param $box_no
  372. * @param $control string 01,大灯开;00,大灯关
  373. * @return bool
  374. * @author Fx
  375. *
  376. */
  377. public static function lampSwitch($box_no, $control)
  378. {
  379. $cmd = "34";
  380. $body = [
  381. self::getMsgId(),
  382. $control,
  383. ];
  384. $send_msg = self::makeSendMsg($cmd, $body);
  385. return self::send($box_no, $send_msg);
  386. }
  387. /**
  388. * orderStatus
  389. *
  390. * @param $box_no
  391. * @param $control string 01:接单开启;00:接单关闭
  392. * @return bool
  393. * @author Fx
  394. *
  395. */
  396. public static function orderStatus($box_no, $control)
  397. {
  398. $cmd = "35";
  399. $body = [
  400. self::getMsgId(),
  401. $control,
  402. ];
  403. $send_msg = self::makeSendMsg($cmd, $body);
  404. return self::send($box_no, $send_msg);
  405. }
  406. /**
  407. * openLock 开锁
  408. *
  409. * @param $box_no
  410. * @return bool
  411. * @author Fx
  412. *
  413. */
  414. public static function openLock($box_no)
  415. {
  416. self::electricSwitchControl($box_no, '01');
  417. self::orderStatus($box_no, '01');
  418. return self::playVoice($box_no, VideoMap::VIDEO_OPEN_LOCK);
  419. }
  420. /**
  421. * nowBikeLocation 立即定位
  422. *
  423. * @param $box_no
  424. * @return bool
  425. * @author Fx
  426. *
  427. */
  428. public static function nowBikeLocation($box_no)
  429. {
  430. return self::queryCmd($box_no, '00000001');
  431. }
  432. /**
  433. * openLock 开锁
  434. *
  435. * @param $box_no
  436. * @return bool
  437. * @author Fx
  438. *
  439. */
  440. public static function closeLock($box_no, $video = false)
  441. {
  442. self::electricSwitchControl($box_no, '02');
  443. if ($video) {
  444. self::playVoice($box_no, VideoMap::VIDEO_RETURN_BIKE);
  445. }
  446. return self::orderStatus($box_no, '00');
  447. }
  448. /**
  449. * closeLock 临时关锁 (设防)
  450. *
  451. * @param $box_no
  452. * @return bool
  453. * @author Fx
  454. *
  455. */
  456. public static function temporaryCloseLock($box_no)
  457. {
  458. self::electricSwitchControl($box_no, '02');
  459. return self::playVoice($box_no, VideoMap::VIDEO_FIND_BIKE);
  460. }
  461. /**
  462. * closeLockNoGuard 关锁 (不设防) 失能
  463. *
  464. * @param $box_no
  465. * @return bool
  466. * @author Fx
  467. *
  468. */
  469. public static function outAreaLoseElectric($box_no, $video = false)
  470. {
  471. self::electricSwitchControl($box_no, '00');
  472. sleep(1);
  473. if ($video) {
  474. self::playVoice($box_no, $video);
  475. }
  476. // return self::playVoice($box_no, VideoMap::VIDEO_RESERVED);
  477. }
  478. /**
  479. * outAreaGetElectric 开锁 获能
  480. *
  481. * @param $box_no
  482. * @return bool
  483. * @author Fx
  484. *
  485. */
  486. public static function outAreaGetElectric($box_no)
  487. {
  488. self::electricSwitchControl($box_no, '01');
  489. return self::playVoice($box_no, VideoMap::VIDEO_KEEP_GOING);
  490. }
  491. /**
  492. * 获取序号(msg_id)
  493. * @return string
  494. * Author: Mead
  495. */
  496. private static function getMsgId()
  497. {
  498. $msg_id = str_pad(dechex(rand(0, 65535)), 4, "0", STR_PAD_LEFT);
  499. return $msg_id;
  500. }
  501. /**
  502. * str2Hex 其他进制转16进制
  503. *
  504. * @param $str string 需要转的数据
  505. * @param $frombase int 需要转的进制
  506. * @param $pad_length int 长度
  507. * @return string
  508. * @author Fx
  509. *
  510. */
  511. private static function str2Hex($str, $frombase, $pad_length)
  512. {
  513. return str_pad(base_convert($str, $frombase, 16), $pad_length, 0, STR_PAD_LEFT);
  514. }
  515. /**
  516. * char2Hex char 转16进制
  517. *
  518. * @param $char
  519. * @param $pad_length
  520. * @return string
  521. * @author Fx
  522. *
  523. */
  524. private static function char2Hex($char, $pad_length)
  525. {
  526. return str_pad(bin2hex($char), $pad_length, 0, STR_PAD_LEFT);
  527. }
  528. /**
  529. * 发送数据
  530. * @param $box_no
  531. * @param $msg
  532. * @return bool
  533. * User: Mead
  534. */
  535. private static function send($box_no, $msg)
  536. {
  537. self::log($msg, 'sendMsg');
  538. Gateway::sendToUid($box_no, '+NNMI,' . hex2bin(str_replace(' ', '', $msg . '0D0A')));
  539. return true;
  540. }
  541. /**
  542. * 组装命令
  543. * @param $cmd
  544. * @param $msgID
  545. * @return string
  546. * User: Mead
  547. */
  548. private static function makeSendMsg($cmd, $body, $msg_id = false, $length = false)
  549. {
  550. if (is_array($body)) {
  551. $body = self::arr2arr($body);
  552. }
  553. if (is_string($body)) {
  554. $body = str_split($body, 2);
  555. }
  556. if ($length !== false) {
  557. $length = str_pad($length, 4, '0', STR_PAD_LEFT);
  558. } else {
  559. $length = str_pad(dechex(count($body)), 4, '0', STR_PAD_LEFT);
  560. }
  561. if ($msg_id === false) {
  562. $msg_id = self::getMsgId();
  563. }
  564. $header = [
  565. $cmd,
  566. $msg_id,
  567. '00',
  568. $length
  569. ];
  570. $response = self::formatArr($header, $body);
  571. $response[] = self::verification($response);
  572. return self::format(self::$start . implode('', $response));
  573. }
  574. /**
  575. * 校检
  576. * @param $data
  577. * @param $verification
  578. * @return bool
  579. * Author: Mead
  580. */
  581. protected static function verification($data)
  582. {
  583. $a = $b = 0;
  584. for ($i = 0; $i < count($data); $i++) {
  585. $a = $a + hexdec($data[$i]);
  586. $b = $a + $b;
  587. }
  588. return str_pad(substr(dechex($a), -2), 2, 0, STR_PAD_LEFT) . str_pad(substr(dechex($b), -2), 2, 0, STR_PAD_LEFT);
  589. }
  590. /**
  591. * 格式数组
  592. * @param $arr
  593. * @return array
  594. * User: Mead
  595. */
  596. private static function arr2arr($arr)
  597. {
  598. $arr = implode('', $arr);
  599. return str_split(str_replace(' ', '', $arr), 2);
  600. }
  601. /**
  602. * 合并数组
  603. * @return array
  604. * User: Mead
  605. */
  606. private static function formatArr()
  607. {
  608. $args = func_get_args();
  609. $arr = '';
  610. foreach ($args as $arg) {
  611. $arr .= implode('', $arg);
  612. }
  613. return str_split($arr, 2);
  614. }
  615. /**
  616. * 格式字符
  617. * @param $str
  618. * @return string
  619. * User: Mead
  620. */
  621. private static function format($str)
  622. {
  623. return strtoupper(implode('', str_split(str_replace(' ', '', $str), 2)));
  624. }
  625. }