engineerper před 1 rokem
rodič
revize
5f391b402d

+ 0 - 12
doc/lc-fangdaosha/fangdaosha.sql

@@ -347,25 +347,6 @@ CREATE TABLE `gateway`  (
 
 -- ----------------------------
 -- Records of gateway
-
-DROP TABLE IF EXISTS `ipcast`;
-CREATE TABLE `ipcast`  (
-  `id` int NOT NULL AUTO_INCREMENT,
-  `device_id` int NULL DEFAULT NULL,
-  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
-  `gid` int NULL DEFAULT NULL COMMENT '关联网关id',
-  `state` tinyint(1) NULL DEFAULT NULL COMMENT '0离线,1在线',
-  `is_deleted` tinyint(1) NULL DEFAULT NULL COMMENT '1删除',
-  PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ip音柱' ROW_FORMAT = DYNAMIC;
-
 
 -- ----------------------------
 -- Table structure for jwt_blacklists

+ 22 - 16
isapi/isapi_event_channelCap.go

@@ -2,31 +2,37 @@ package isapi
 
 import (
 	"encoding/xml"
+	"github.com/sirupsen/logrus"
 )
 
 type ChannelEventCapList struct {
-	XMLName         xml.Name          `xml:"ChannelEventCapList"`
-	Text            string            `xml:",chardata"`
-	Version         string            `xml:"version,attr"`
-	Xmlns           string            `xml:"xmlns,attr"`
-	ChannelEventCap []ChannelEventCap `xml:"ChannelEventCap"`
+	ChannelEventCap []ChannelEventCap `xml:"ChannelEventCap" json:"channelEventCap"`
 }
 
 type ChannelEventCap struct {
-	Text      string `xml:",chardata"`
 	EventType struct {
-		Text string `xml:",chardata"`
-		Opt  string `xml:"opt,attr"`
-	} `xml:"eventType"`
-	ChannelID string `xml:"channelID"`
-	ID        string `xml:"id"`
+		Opt string `xml:"opt,attr" json:"opt"`
+	} `xml:"eventType" json:"eventType"`
+	ChannelID string `xml:"channelID" json:"channelID"`
+	ID        string `xml:"id" json:"ID"`
 }
 
-func (c *Client) GetAllChanEventCap() ([]byte, error) {
-
-	return c.CommonGet("/ISAPI/Event/channels/capabilities")
+func (c *Client) GetAllChanEventCap() (resp ChannelEventCapList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Event/channels/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetOneChanEventCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Event/channels/1/capabilities")
+func (c *Client) GetOneChanEventCap() (resp ChannelEventCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Event/channels/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }

+ 13 - 2
isapi/isapi_event_httphost.go

@@ -1,5 +1,10 @@
 package isapi
 
+import (
+	"encoding/xml"
+	"github.com/sirupsen/logrus"
+)
+
 type eventType string
 
 const (
@@ -18,8 +23,14 @@ func (c *Client) GetHostCap() ([]byte, error) {
 }
 
 // PutHost 配置单个监听主机参数
-func (c *Client) PutHost(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Event/notification/httpHosts")
+func (c *Client) PutHost(data []byte) (info ResponseStatus, err error) {
+	resp, err := c.CommonPut(data, "/ISAPI/Event/notification/httpHosts")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(resp, &info)
+	return
 }
 
 // DelHost 删除单个监听主机参数

+ 18 - 13
isapi/isapi_smart_calibration.go

@@ -1,26 +1,31 @@
 package isapi
 
+// SmartCalibrationList 配置最大、最小尺寸
 // SmartCalibrationList 配置最大、最小尺寸
 type SmartCalibrationList struct {
 	SmartCalibration []struct {
-		ID         string `xml:"ID"`
+		ID         string `xml:"ID" json:"ID"`
 		FilterSize struct {
 			MinTargetSize struct {
 				RegionCoordinatesList struct {
 					RegionCoordinates []struct {
-						PositionX string `xml:"positionX"`
-						PositionY string `xml:"positionY"`
-					} `xml:"RegionCoordinates"`
-				} `xml:"RegionCoordinatesList"`
-			} `xml:"MinTargetSize"`
+						PositionX string `xml:"positionX" json:"positionX"`
+						PositionY string `xml:"positionY" json:"positionY"`
+					} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+				} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			} `xml:"MinTargetSize" json:"MinTargetSize"`
 			MaxTargetSize struct {
 				RegionCoordinatesList struct {
 					RegionCoordinates []struct {
-						PositionX string `xml:"positionX"`
-						PositionY string `xml:"positionY"`
-					} `xml:"RegionCoordinates"`
-				} `xml:"RegionCoordinatesList"`
-			} `xml:"MaxTargetSize"`
-		} `xml:"FilterSize"`
-	} `xml:"SmartCalibration"`
+						PositionX string `xml:"positionX" json:"positionX"`
+						PositionY string `xml:"positionY" json:"positionY"`
+					} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+				} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			} `xml:"MaxTargetSize" json:"MaxTargetSize"`
+			Mode struct {
+				Text string `xml:",chardata" json:"chardata"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"mode" json:"mode"`
+		} `xml:"FilterSize" json:"FilterSize"`
+	} `xml:"SmartCalibration" json:"SmartCalibration"`
 }

+ 133 - 38
isapi/isapi_smart_fieldDetection.go

@@ -1,7 +1,10 @@
 package isapi
 
 import (
+	"encoding/json"
 	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
 )
 
 //能力
@@ -9,60 +12,152 @@ import (
 //http://192.168.110.165/ISAPI/Smart/channels/1/calibrations/capabilities
 
 // FieldDetection 区域入侵
-type FieldDetection struct {
-	XMLName              xml.Name `xml:"FieldDetection"`
-	Xmlns                string   `xml:"xmlns,attr"`
-	Version              string   `xml:"version,attr"`
-	ID                   string   `xml:"id"`
-	Enabled              string   `xml:"enabled"`
-	StartTriggerTime     string   `xml:"startTriggerTime"`
-	EndTriggerTime       string   `xml:"endTriggerTime"`
+type FieldDetectionCap struct {
+	XMLName              xml.Name `xml:"FieldDetection"json:"FieldDetection"`
+	Xmlns                string   `xml:"xmlns,attr"json:"xmlns"`
+	Version              string   `xml:"version,attr"json:"version"`
+	ID                   string   `xml:"id"json:"id"`
+	Enabled              string   `xml:"enabled"json:"enabled"`
+	StartTriggerTime     string   `xml:"startTriggerTime"json:"startTriggerTime"`
+	EndTriggerTime       string   `xml:"endTriggerTime"json:"endTriggerTime"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight"json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize"json:"normalizedScreenSize"`
 	FieldDetectionRegionList struct {
-		Size                 string `xml:"size,attr"`
+		Size                 string `xml:"size,attr"json:"size"`
 		FieldDetectionRegion []struct {
-			ID               string `xml:"id"`
-			Enabled          string `xml:"enabled"`
-			SensitivityLevel string `xml:"sensitivityLevel"`
-			TimeThreshold    string `xml:"timeThreshold"`
-			DetectionTarget  string `xml:"detectionTarget"`
+			ID               string `xml:"id"json:"id"`
+			Enabled          string `xml:"enabled"json:"enabled"`
+			SensitivityLevel string `xml:"sensitivityLevel"json:"sensitivityLevel"`
+			TimeThreshold    string `xml:"timeThreshold"json:"timeThreshold"`
+			DetectionTarget  string `xml:"detectionTarget"json:"detectionTarget"`
 			AlarmConfidence  struct {
-				Opt string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
+				Opt string `xml:"opt,attr"json:"opt"`
+			} `xml:"alarmConfidence"json:"alarmConfidence"`
 			RegionCoordinatesList struct {
 				RegionCoordinates []struct {
-					PositionX string `xml:"positionX"`
-					PositionY string `xml:"positionY"`
-				} `xml:"RegionCoordinates"`
-			} `xml:"RegionCoordinatesList"`
-		} `xml:"FieldDetectionRegion"`
-	} `xml:"FieldDetectionRegionList"`
-	IsSupportMultiScene           string `xml:"isSupportMultiScene"`
-	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter"`
-	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"`
+					PositionX string `xml:"positionX"json:"positionX"`
+					PositionY string `xml:"positionY"json:"positionY"`
+				} `xml:"RegionCoordinates"json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList"json:"RegionCoordinatesList"`
+		} `xml:"FieldDetectionRegion"json:"FieldDetectionRegion"`
+	} `xml:"FieldDetectionRegionList"json:"FieldDetectionRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene"json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter"json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"json:"isSupportVehicleMisinfoFilter"`
 }
 
-func (c *Client) GetFieldDetectionCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
+func (c *Client) GetFieldDetectionCap() (resp FieldDetectionCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeFd() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+func (c *Client) GetSizeFd() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	fmt.Printf("%+v\n", string(bytes))
+	fmt.Printf("%+v\n", resp)
+	return
 }
 
-func (c *Client) PutSizeFd(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+func (c *Client) PutSizeFd(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // PutFieldDetection 设置区域入侵报警区域
-func (c *Client) PutFieldDetection(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/FieldDetection/1")
+func (c *Client) PutFieldDetection(data []byte) (resp ResponseStatus, err error) {
+	var info FieldDetectionParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/FieldDetection/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetFieldDetection 获取报警区域
-func (c *Client) GetFieldDetection() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/FieldDetection/1")
+func (c *Client) GetFieldDetection() (resp FieldDetectionParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
+}
+
+// FieldDetectionParam 查询,配置 进入区域参数
+type FieldDetectionParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	FieldDetectionRegionList struct {
+		Size                 string `xml:"size,attr" json:"size"`
+		FieldDetectionRegion []struct {
+			ID                    string `xml:"id" json:"id"`
+			Enabled               string `xml:"enabled" json:"enabled"`
+			SensitivityLevel      string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			TimeThreshold         string `xml:"timeThreshold" json:"timeThreshold"`
+			DetectionTarget       string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence       string `xml:"alarmConfidence"json:"alarmConfidence"`
+			RegionCoordinatesList struct {
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+		} `xml:"FieldDetectionRegion" json:"FieldDetectionRegion"`
+	} `xml:"FieldDetectionRegionList" json:"FieldDetectionRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
 }

+ 160 - 35
isapi/isapi_smart_lineDetection.go

@@ -1,59 +1,184 @@
 package isapi
 
+import (
+	"encoding/json"
+	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
+)
+
 //能力
 //http://192.168.110.165/ISAPI/Smart/LineDetection/1/capabilities
 //http://192.168.110.165/ISAPI/Smart/channels/1/calibrations/capabilities
 
 // LineDetection 越界侦测
-type LineDetection struct {
-	ID                   string `xml:"id"`
-	Enabled              string `xml:"enabled"`
+type LineDetectionParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
 	LineItemList struct {
-		Size     string `xml:"size,attr"`
+		Size     string `xml:"size,attr" json:"size"`
 		LineItem []struct {
-			ID                   string `xml:"id"`
-			Enabled              string `xml:"enabled"`
-			SensitivityLevel     string `xml:"sensitivityLevel"`
-			DirectionSensitivity string `xml:"directionSensitivity"`
-			DetectionTarget      string `xml:"detectionTarget"`
-			AlarmConfidence      struct {
-				Text string `xml:",chardata"`
-				Opt  string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
-			CoordinatesList struct {
+			ID                   string `xml:"id" json:"id"`
+			Enabled              string `xml:"enabled" json:"enabled"`
+			SensitivityLevel     string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DirectionSensitivity string `xml:"directionSensitivity"json:"directionSensitivity"`
+			DetectionTarget      string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence      string `xml:"alarmConfidence" json:"alarmConfidence"`
+			CoordinatesList      struct {
 				Coordinates []struct {
-					PositionX string `xml:"positionX"`
-					PositionY string `xml:"positionY"`
-				} `xml:"Coordinates"`
-			} `xml:"CoordinatesList"`
-		} `xml:"LineItem"`
-	} `xml:"LineItemList"`
-	IsSupportMultiScene string `xml:"isSupportMultiScene"`
-	RecogRuleType       string `xml:"recogRuleType"`
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"Coordinates" json:"Coordinates"`
+			} `xml:"CoordinatesList" json:"CoordinatesList"`
+		} `xml:"LineItem" json:"LineItem"`
+	} `xml:"LineItemList" json:"LineItemList"`
+	IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	RecogRuleType       string `xml:"recogRuleType" json:"recogRuleType"`
 }
 
-func (c *Client) GetLineDetectionCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
+// GetLineDetectionCap 获取单个通道越界侦测上限
+func (c *Client) GetLineDetectionCap() (resp LineDetectionCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeLd() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
+// GetSizeLd 获取尺寸大小
+func (c *Client) GetSizeLd() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) PutSizeLd(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/linedetection")
+// PutSizeLd 配置尺寸大小
+func (c *Client) PutSizeLd(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/linedetection")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetLineDetection 获取单个通道越界侦测规则
-func (c *Client) GetLineDetection() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/LineDetection/1")
+func (c *Client) GetLineDetection() (resp LineDetectionParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	marshal, err := json.Marshal(resp)
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	fmt.Println("json数据:", string(marshal))
+	return
 }
 
 // PutLineDetection 配置单个通道越界侦测规则
-func (c *Client) PutLineDetection(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/LineDetection/1")
+func (c *Client) PutLineDetection(data []byte) (resp ResponseStatus, err error) {
+	var info LineDetectionParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/LineDetection/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
+}
+
+type LineDetectionCap struct {
+	ID      string `xml:"id" json:"id"`
+	Enabled struct {
+		Text string `xml:",chardata" json:"value"`
+		Opt  string `xml:"opt,attr" json:"opt"`
+	} `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	LineItemList struct {
+		Size     string `xml:"size,attr" json:"size"`
+		LineItem []struct {
+			ID      string `xml:"id" json:"id"`
+			Enabled struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"enabled" json:"enabled"`
+			SensitivityLevel struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DirectionSensitivity struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"directionSensitivity" json:"directionSensitivity"`
+			CoordinatesList struct {
+				Coordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"Coordinates" json:"Coordinates"`
+			} `xml:"CoordinatesList" json:"CoordinatesList"`
+			DetectionTarget struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+				Def  string `xml:"def,attr" json:"def"`
+			} `xml:"alarmConfidence" json:"alarmConfidence"`
+		} `xml:"LineItem" json:"LineItem"`
+	} `xml:"LineItemList" json:"LineItemList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	RecogRuleType                 string `xml:"recogRuleType" json:"recogRuleType"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
+	IsSupportAllDayUpload         string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
 }

+ 153 - 33
isapi/isapi_smart_regionEntrance.go

@@ -1,53 +1,173 @@
 package isapi
 
+import (
+	"encoding/json"
+	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
+)
+
 // RegionEntrance 进入区域
-type RegionEntrance struct {
-	ID                   string `xml:"id"`
-	Enabled              string `xml:"enabled"`
+type RegionEntranceParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
 	RegionEntranceRegionList struct {
-		Size                 string `xml:"size,attr"`
+		Size                 string `xml:"size,attr" json:"size"`
 		RegionEntranceRegion []struct {
-			ID               string `xml:"id"`
-			SensitivityLevel string `xml:"sensitivityLevel"`
-			DetectionTarget  string `xml:"detectionTarget"`
-			AlarmConfidence  struct {
-				Text string `xml:",chardata"`
-				Opt  string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
+			ID                    string `xml:"id" json:"id"`
+			SensitivityLevel      string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DetectionTarget       string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence       string `xml:"alarmConfidence" json:"alarmConfidence"`
 			RegionCoordinatesList struct {
-				Text  string `xml:",chardata"`
-				Xmlns string `xml:"xmlns,attr"`
-			} `xml:"RegionCoordinatesList"`
-		} `xml:"RegionEntranceRegion"`
-	} `xml:"RegionEntranceRegionList"`
-	IsSupportMultiScene           string `xml:"isSupportMultiScene"`
-	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter"`
-	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"`
-	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect"`
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+		} `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
+	} `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
 }
 
-func (c *Client) GetRegionEntranceCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities")
+// GetRegionEntranceCap 获取区域入口上限
+func (c *Client) GetRegionEntranceCap() (resp RegionEntranceCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeRe() (resp []byte, err error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+// GetSizeRe 获取尺寸大小
+func (c *Client) GetSizeRe() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) PutSizeRe(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+// PutSizeRe 配置尺寸大小
+func (c *Client) PutSizeRe(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetRegionEntrance 获取区域侦测参数
-func (c *Client) GetRegionEntrance() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/regionEntrance/1")
+func (c *Client) GetRegionEntrance() (resp RegionEntranceParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	marshal, err := json.Marshal(resp)
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	fmt.Println("json数据:", string(marshal))
+	return
 }
 
 // PutRegionEntrance 配置区域侦测参数
-func (c *Client) PutRegionEntrance(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/regionEntrance/1")
+func (c *Client) PutRegionEntrance(data []byte) (resp ResponseStatus, err error) {
+	var info RegionEntranceParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/regionEntrance/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
+}
+
+type RegionEntranceCap struct {
+	ID      string `xml:"id"`
+	Enabled struct {
+		Text string `xml:",chardata" json:"value"`
+		Opt  string `xml:"opt,attr" json:"opt"`
+	} `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	RegionEntranceRegionList struct {
+		Size                 string `xml:"size,attr" json:"size"`
+		RegionEntranceRegion []struct {
+			ID               string `xml:"id" json:"id"`
+			SensitivityLevel struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			RegionCoordinatesList struct {
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"`
+			MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"`
+			DetectionTarget         struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+				Def  string `xml:"def,attr" json:"def"`
+			} `xml:"alarmConfidence" json:"alarmConfidence"`
+		} `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
+	} `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
+	IsSupportAllDayUpload         string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
 }

+ 32 - 28
isapi/isapi_system_deviceInfo.go

@@ -2,38 +2,42 @@ package isapi
 
 import (
 	"encoding/xml"
+	"github.com/sirupsen/logrus"
 )
 
 // DeviceInfo 设备信息
 type DeviceInfo struct {
-	XMLName              xml.Name `xml:"DeviceInfo,omitempty"`
-	XMLVersion           string   `xml:"version,attr"`
-	XMLNamespace         string   `xml:"xmlns,attr"`
-	DeviceName           string   `xml:"deviceName,omitempty" json:"deviceName,omitempty"`
-	DeviceID             string   `xml:"deviceID,omitempty" json:"deviceID,omitempty"`
-	DeviceDescription    string   `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"`
-	DeviceLocation       string   `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"`
-	SystemContact        string   `xml:"systemContact,omitempty" json:"systemContact,omitempty"` //生产商
-	Model                string   `xml:"model,omitempty" json:"model,omitempty"`
-	SerialNumber         string   `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"`
-	MacAddress           string   `xml:"macAddress,omitempty" json:"macAddress,omitempty"`
-	FirmwareVersion      string   `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"`
-	FirmwareReleasedDate string   `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"`
-	EncoderVersion       string   `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"`
-	EncoderReleasedDate  string   `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"`
-	BootVersion          string   `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"`
-	BootReleasedDate     string   `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"`
-	HardwareVersion      string   `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"`
-	DeviceType           string   `xml:"deviceType,omitempty" json:"deviceType,omitempty"`
-	TelecontrolID        string   `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"`
-	SupportBeep          string   `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"`
-	SupportVideoLoss     string   `xml:"supportVideoLoss" json:"supportVideoLoss"`
-	FirmwareVersionInfo  string   `xml:"firmwareVersionInfo" json:"firmwareVersionInfo"`
-	Manufacturer         string   `xml:"manufacturer" json:"manufacturer"`
-	SubSerialNumber      string   `xml:"subSerialNumber" json:"subSerialNumber"`
-	OEMCode              string   `xml:"OEMCode" json:"OEMCode"`
+	DeviceName           string `xml:"deviceName,omitempty" json:"deviceName,omitempty"`
+	DeviceID             string `xml:"deviceID,omitempty" json:"deviceID,omitempty"`
+	DeviceDescription    string `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"`
+	DeviceLocation       string `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"`
+	SystemContact        string `xml:"systemContact,omitempty" json:"systemContact,omitempty"` //生产商
+	Model                string `xml:"model,omitempty" json:"model,omitempty"`
+	SerialNumber         string `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"`
+	MacAddress           string `xml:"macAddress,omitempty" json:"macAddress,omitempty"`
+	FirmwareVersion      string `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"`
+	FirmwareReleasedDate string `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"`
+	EncoderVersion       string `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"`
+	EncoderReleasedDate  string `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"`
+	BootVersion          string `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"`
+	BootReleasedDate     string `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"`
+	HardwareVersion      string `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"`
+	DeviceType           string `xml:"deviceType,omitempty" json:"deviceType,omitempty"`
+	TelecontrolID        string `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"`
+	SupportBeep          string `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"`
+	SupportVideoLoss     string `xml:"supportVideoLoss" json:"supportVideoLoss"`
+	FirmwareVersionInfo  string `xml:"firmwareVersionInfo" json:"firmwareVersionInfo"`
+	Manufacturer         string `xml:"manufacturer" json:"manufacturer"`
+	SubSerialNumber      string `xml:"subSerialNumber" json:"subSerialNumber"`
+	OEMCode              string `xml:"OEMCode" json:"OEMCode"`
 }
 
-func (c *Client) GetDeviceInfo() ([]byte, error) {
-	return c.CommonGet("/ISAPI/System/deviceInfo")
+func (c *Client) GetDeviceInfo() (resp DeviceInfo, err error) {
+	bytes, err := c.CommonGet("/ISAPI/System/deviceInfo")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }