25 lines
541 B
PHP
25 lines
541 B
PHP
<?php
|
|
|
|
namespace app\net\parsers;
|
|
|
|
|
|
/**
|
|
* 新版电流采集器报文解析器(长度38)
|
|
*/
|
|
class NewCurrentCollectorParser implements PacketParserInterface
|
|
{
|
|
public function supports(string $hexString): bool
|
|
{
|
|
return strlen($hexString) === 38;
|
|
}
|
|
|
|
public function parse(string $hexString): array
|
|
{
|
|
return [
|
|
'hexType' => 4,
|
|
'isMatched' => true,
|
|
'detectionDevice' => substr($hexString, 16, 2),
|
|
'channel1' => substr($hexString, 24, 2),
|
|
];
|
|
}
|
|
} |