driver

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnvifProtocol = "Onvif"
	Address       = "Address"
	Port          = "Port"
	AuthMode      = "AuthMode"
	SecretPath    = "SecretPath"

	// Service is resource attribute and indicates the web service for the Onvif
	Service = "service"
	// GetFunction is resource attribute and indicates the SOAP action for the specified web service, it is used for the read operation
	GetFunction = "getFunction"
	// SetFunction is resource attribute and indicates the SOAP action for the specified web service, it is used for the write operation
	SetFunction = "setFunction"

	// SubscribeType indicates the way to fetch the event message. The value should be PullPoint or BaseNotification.
	SubscribeType    = "subscribeType"
	PullPoint        = "PullPoint"
	BaseNotification = "BaseNotification"
	// DefaultSubscriptionPolicy is optional, we should check the camera capabilities before using
	DefaultSubscriptionPolicy = "defaultSubscriptionPolicy"
	// DefaultInitialTerminationTime indicates the subscription lifetime with specified duration.  For example, PT1H.
	DefaultInitialTerminationTime = "defaultInitialTerminationTime"
	// DefaultAutoRenew indicates the subscription will auto-renew before out of date. For example, true or false.
	DefaultAutoRenew = "defaultAutoRenew"
	// DefaultTopicFilter indicates the optional XPATH expression to filter the event. For example, tns1:RuleEngine/TamperDetector
	DefaultTopicFilter = "defaultTopicFilter"
	// DefaultMessageContentFilter indicates the optional XPATH expression to filter the event. For example, boolean(//tt:SimpleItem[@Name=”IsTamper”])
	DefaultMessageContentFilter = "defaultMessageContentFilter"
	// DefaultMessageTimeout specify the Timeout for PullMessage. Maximum time to block until this method returns. For example, PT5S
	DefaultMessageTimeout = "defaultMessageTimeout"
	// DefaultMessageLimit specify the MessageLimit for PullMessage. Upper limit for the number of messages to return at once, For example, 10
	DefaultMessageLimit = "defaultMessageLimit"
	// DefaultConsumerURL point to the consumer's network location
	DefaultConsumerURL = "defaultConsumerURL"

	Manufacturer    = "Manufacturer"
	Model           = "Model"
	FirmwareVersion = "FirmwareVersion"
	SerialNumber    = "SerialNumber"
	HardwareId      = "HardwareId"
)
View Source
const (
	EdgeXWebService        = "EdgeX"
	RebootNeeded           = "RebootNeeded"
	CameraEvent            = "CameraEvent"
	SubscribeCameraEvent   = "SubscribeCameraEvent"
	UnsubscribeCameraEvent = "UnsubscribeCameraEvent"
	GetSnapshot            = "GetSnapshot"
)
View Source
const MinimumInitialTerminationTime = 11

MinimumInitialTerminationTime indicates the minimum InitialTerminationTime because device service sends Renew request every ten second before termination time

View Source
const (
	OnvifEventRestPath = "onvifevent"
)
View Source
const (
	URLRawQuery = "urlRawQuery"
)

Variables

This section is empty.

Functions

Types

type BaseNotificationManager

type BaseNotificationManager struct {
	// contains filtered or unexported fields
}

BaseNotificationManager manages the consumers to renew the subscription

func NewBaseNotificationManager

func NewBaseNotificationManager(lc logger.LoggingClient) *BaseNotificationManager

NewBaseNotificationManager create the new BaseNotificationManager entity

func (*BaseNotificationManager) NewConsumer

func (manager *BaseNotificationManager) NewConsumer(onvifClient *OnvifClient, resourceName string, attributes map[string]interface{}, data []byte) errors.EdgeX

NewConsumer create the new NewConsumer entity and send the subscription request to the camera

func (*BaseNotificationManager) UnsubscribeAll

func (manager *BaseNotificationManager) UnsubscribeAll()

type CameraInfo

type CameraInfo struct {
	Address    string
	Port       int
	AuthMode   string
	SecretPath string
}

CameraInfo holds the camera connection info

func CreateCameraInfo

func CreateCameraInfo(protocols map[string]models.ProtocolProperties) (*CameraInfo, errors.EdgeX)

CreateCameraInfo creates new CameraInfo entity from the protocol properties

type Consumer

type Consumer struct {
	Name string

	// SubscriptionAddress is the reference for the event producer
	SubscriptionAddress string
	// Stopped indicates the Consumer should stop the subscription
	Stopped chan bool
	// contains filtered or unexported fields
}

Consumer holds the subscription info and receive the camera event

func (*Consumer) StartRenewLoop

func (consumer *Consumer) StartRenewLoop()

StartRenewLoop renews the subscription before termination time

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver implements the sdkModel.ProtocolDriver interface for the device service

func (*Driver) AddDevice

func (d *Driver) AddDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error

AddDevice is a callback function that is invoked when a new Device associated with this Device Service is added

func (*Driver) DisconnectDevice

func (d *Driver) DisconnectDevice(deviceName string, protocols map[string]models.ProtocolProperties) error

DisconnectDevice handles protocol-specific cleanup when a device is removed.

func (*Driver) Discover

func (d *Driver) Discover()

Discover triggers protocol specific device discovery, which is an asynchronous operation. Devices found as part of this discovery operation are written to the channel devices.

func (*Driver) HandleReadCommands

func (d *Driver) HandleReadCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []sdkModel.CommandRequest) ([]*sdkModel.CommandValue, error)

HandleReadCommands triggers a protocol Read operation for the specified device.

func (*Driver) HandleWriteCommands

func (d *Driver) HandleWriteCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []sdkModel.CommandRequest, params []*sdkModel.CommandValue) error

HandleWriteCommands passes a slice of CommandRequest struct each representing a ResourceOperation for a specific device resource (aka DeviceObject). Since the commands are actuation commands, params provide parameters for the individual command.

func (*Driver) Initialize

func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *sdkModel.AsyncValues,
	deviceCh chan<- []sdkModel.DiscoveredDevice) error

Initialize performs protocol-specific initialization for the device service.

func (*Driver) RemoveDevice

func (d *Driver) RemoveDevice(deviceName string, protocols map[string]models.ProtocolProperties) error

RemoveDevice is a callback function that is invoked when a Device associated with this Device Service is removed

func (*Driver) Stop

func (d *Driver) Stop(force bool) error

Stop the protocol-specific DS code to shutdown gracefully, or if the force parameter is 'true', immediately. The driver is responsible for closing any in-use channels, including the channel used to send async readings (if supported).

func (*Driver) UpdateDevice

func (d *Driver) UpdateDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error

UpdateDevice is a callback function that is invoked when a Device associated with this Device Service is updated

type Duration

type Duration struct {
	Y int
	M int
	W int
	D int
	// Time Component
	TH int
	TM int
	TS int
}

Duration represents an ISO8601 Duration

type OnvifClient

type OnvifClient struct {
	DeviceName string

	// RebootNeeded indicates the camera should reboot to apply the configuration change
	RebootNeeded bool
	// CameraEventResource is used to send the async event to north bound
	CameraEventResource models.DeviceResource
	// contains filtered or unexported fields
}

OnvifClient manages the state required to issue ONVIF requests to the specified camera

func (*OnvifClient) CallOnvifFunction

func (onvifClient *OnvifClient) CallOnvifFunction(req sdkModel.CommandRequest, functionType string, data []byte) (cv *sdkModel.CommandValue, edgexErr errors.EdgeX)

CallOnvifFunction send the request to the camera via onvif client

type PullPointManager

type PullPointManager struct {
	// contains filtered or unexported fields
}

PullPointManager manages the subscribers to pull event from specified PullPoints

func (*PullPointManager) NewSubscriber

func (manager *PullPointManager) NewSubscriber(onvifClient *OnvifClient, resourceName string, attributes map[string]interface{}, data []byte) errors.EdgeX

NewSubscriber creates a new subscriber entity and start pulling the event from the camera

func (*PullPointManager) UnsubscribeAll

func (manager *PullPointManager) UnsubscribeAll()

UnsubscribeAll stops all subscriptions

type RestNotificationHandler

type RestNotificationHandler struct {
	// contains filtered or unexported fields
}

RestNotificationHandler handle the notification from the camera and send to async value channel

func NewRestNotificationHandler

func NewRestNotificationHandler(service *sdk.DeviceService, logger logger.LoggingClient, asyncValues chan<- *models.AsyncValues) *RestNotificationHandler

NewRestNotificationHandler create a new RestNotificationHandler entity

func (RestNotificationHandler) AddRoute

func (handler RestNotificationHandler) AddRoute() errors.EdgeX

AddRoute adds route for receiving the notification from the camera

type Subscriber

type Subscriber struct {
	Name string

	// SubscriptionAddress is used to pull the event from the camera
	SubscriptionAddress string

	// Stopped indicates the Subscriber should stop the PullMessageLoop
	Stopped chan bool
	// contains filtered or unexported fields
}

func (*Subscriber) StartPullMessageLoop

func (sub *Subscriber) StartPullMessageLoop()

StartPullMessageLoop implements the long-polling strategy to pull the camera event

type SubscriptionRequest

type SubscriptionRequest struct {
	// AutoRenew indicate the device service should renew the subscription
	AutoRenew *bool

	// TopicFilter  indicates the optional XPATH expression to filter the event by topic
	TopicFilter *string
	// TopicFilter  indicates the optional XPATH expression to filter the event by message content
	MessageContentFilter *string
	// SubscriptionPolicy is the camera's subscription policy, the user should check the capability before using it
	SubscriptionPolicy *string
	// InitialTerminationTime indicates the subscription lifetime with specified duration
	InitialTerminationTime *string

	// MessageTimeout indicates the timeout to pull event message
	MessageTimeout *string
	// MessageTimeout indicates the limit for the number of messages to return at once
	MessageLimit *int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL