停车场系统数据中间件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

144 lines
4.7 KiB

<?php
namespace App\Services\Device;
class CameraDeviceService extends BaseService
{
protected string $MULTI_PARKING_SPACES_LAMP = '/ISAPI/Parking/parkingSpace/multiParkingSpacesLamp';
protected string $SYSTEM_STATUS = '/ISAPI/System/status';
/**
* @param $ip
* @return CameraDeviceService
*/
public static function query($ip): CameraDeviceService
{
return new self($ip);
}
/**
* 更新车位相机灯光颜色
* @param string $color_occupy
* @param string $color_vacant
* @param bool $is_flicker
* @return array
*/
public function setColor(
string $color_occupy,
string $color_vacant,
bool $is_flicker
): array {
$url = $this->getUrl($this->MULTI_PARKING_SPACES_LAMP);
$body = $this->getColorBody($color_occupy, $color_vacant, $is_flicker);
if (!$body) {
return [];
}
$response = $this->putHttp($url, $body);
return json_decode($response->body(), true);
}
/**
* 获取车位相机信息
* @param $color_occupy
* @param $color_vacant
* @param $is_flicker
* @return array
*/
public function getColorBody(
$color_occupy,
$color_vacant,
$is_flicker
): array {
$is_flicker = (bool)$is_flicker;
$url = $this->getUrl($this->MULTI_PARKING_SPACES_LAMP);
$response = $this->getHttp($url);
$body = json_decode($response->body(), true);
if ($body) {
if (isset($body['VehicleNumber']['VehicleChannelList'][0])) {
$VehicleChannelList
= $body['VehicleNumber']['VehicleChannelList'][0];
if (isset($VehicleChannelList['VehicleNoExist'])) {
// 是否闪烁
$body['VehicleNumber']['VehicleChannelList'][0]['VehicleNoExist']['flashEnabled']
= $is_flicker;
// 无车显示颜色
$body['VehicleNumber']['VehicleChannelList'][0]['VehicleNoExist']['lampColor']
= $color_vacant;
}
if (isset($VehicleChannelList['VehicleExist'])) {
// 是否闪烁
$body['VehicleNumber']['VehicleChannelList'][0]['VehicleExist']['flashEnabled']
= $is_flicker;
// 有车显示颜色
$body['VehicleNumber']['VehicleChannelList'][0]['VehicleExist']['lampColor']
= $color_occupy;
}
}
} else {
return [];
}
return $body;
}
public function getStatus(): bool
{
$url = $this->getUrl($this->SYSTEM_STATUS);
$response = $this->getHttp($url);
return $response->successful();
}
/*
* body 信息
[
"lampType" => "internal",
"VehicleNumber" => [
"VehicleChannelNum" => 1,
"VehicleChannelList" => [
[
"LampSoure" => "internal", // unrelated
"VehicleNoExist" => [
"enabled" => true,
"flashEnabled" => $is_flicker,
"lampColor" => $color_vacant
],
"VehicleExist" => [
"enabled" => true,
"flashEnabled" => $is_flicker,
"lampColor" => $color_occupy
]
]
]
],
"replaceLampCtrl" => [
"enabled" => false,
"ipV4Address" => "0.0.0.0",
"portNo" => 80,
"username" => "admin",
"password" => "dddf4589f3430f7b7395bb9d35e05b27"
],
"lampStatusArr" => [
[
"name" => "内置灯",
"value" => "相机自控",
"\$\$hashKey" => "062"
],
[
"name" => "外置灯1",
"value" => "相机自控",
"\$\$hashKey" => "063"
],
[
"name" => "外置灯2",
"value" => "相机自控",
"\$\$hashKey" => "064"
],
[
"name" => "外置灯3",
"value" => "相机自控",
"\$\$hashKey" => "065"
]
]
]
*/
}