feat: 实现TCP Server
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?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),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user