driver

package
v0.0.1-dev.11 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpWithAuth    = "UpWithAuth"
	UpWithoutAuth = "UpWithoutAuth"
	Reachable     = "Reachable"
	Unreachable   = "Unreachable"
)

Enumerations for DeviceStatus

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

	// 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 CustomConfig

type CustomConfig struct {
	CredentialsRetryTime int
	CredentialsRetryWait int
	RequestTimeout       int
	// DefaultAuthMode indicates the Onvif camera default auth mode. "digest" | "usernametoken" | "both" | "none"
	DefaultAuthMode string
	// DefaultSecretPath indicates the secret path to retrieve username and password from secret store.
	DefaultSecretPath string
	// DiscoveryEthernetInterface indicates the target EthernetInterface for discovering. The default value is `en0`, the user can modify it to meet their requirement.
	DiscoveryEthernetInterface string
	// BaseNotificationURL indicates the device service network location
	BaseNotificationURL string

	// DiscoveryMode indicates mode used to discovery devices on the network.
	DiscoveryMode DiscoveryMode
	// DiscoverySubnets indicates the network segments used when discovery is scanning for devices.
	DiscoverySubnets string
	// ProbeAsyncLimit indicates the maximum number of simultaneous network probes.
	ProbeAsyncLimit int
	// ProbeTimeoutMillis indicates the maximum amount of milliseconds to wait for each IP probe before timing out.
	ProbeTimeoutMillis int
	// MaxDiscoverDurationSeconds indicates the amount of seconds discovery will run before timing out.
	MaxDiscoverDurationSeconds int

	// EnableStatusCheck indicates if status checking should be enabled
	EnableStatusCheck bool
	// CheckStatusInterval indicates the interval in seconds at which the device service will check device statuses
	CheckStatusInterval int

	// Location of Provision Watchers
	ProvisionWatcherDir string
}

CustomConfig holds the values for the driver configuration

type DiscoveryMode

type DiscoveryMode string
const (
	ModeNetScan   DiscoveryMode = "netscan"
	ModeMulticast DiscoveryMode = "multicast"
	ModeBoth      DiscoveryMode = "both"
)

func (DiscoveryMode) IsMulticastEnabled

func (mode DiscoveryMode) IsMulticastEnabled() bool

func (DiscoveryMode) IsNetScanEnabled

func (mode DiscoveryMode) IsNetScanEnabled() bool

func (DiscoveryMode) IsValid

func (mode DiscoveryMode) IsValid() bool

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) Discover

func (d *Driver) Discover()

Discover performs a discovery on the network and passes them to EdgeX to get provisioned

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 MultiErr

type MultiErr []error

func (MultiErr) Error

func (me MultiErr) Error() string

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 OnvifProtocolDiscovery

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

OnvifProtocolDiscovery implements netscan.ProtocolSpecificDiscovery

func NewOnvifProtocolDiscovery

func NewOnvifProtocolDiscovery(driver *Driver) *OnvifProtocolDiscovery

func (*OnvifProtocolDiscovery) ConvertProbeResult

func (proto *OnvifProtocolDiscovery) ConvertProbeResult(probeResult netscan.ProbeResult, params netscan.Params) (sdkModel.DiscoveredDevice, error)

ConvertProbeResult takes a raw ProbeResult and transforms it into a processed DiscoveredDevice struct.

func (*OnvifProtocolDiscovery) OnConnectionDialed

func (proto *OnvifProtocolDiscovery) OnConnectionDialed(host string, port string, conn net.Conn, params netscan.Params) ([]netscan.ProbeResult, error)

OnConnectionDialed handles the protocol specific verification if there is actually a valid device or devices at the other end of the connection.

func (*OnvifProtocolDiscovery) ProbeFilter

func (proto *OnvifProtocolDiscovery) ProbeFilter(_ string, ports []string) []string

ProbeFilter takes in a host and a slice of ports to be scanned. It should return a slice of ports to actually scan, or a nil/empty slice if the host is to not be scanned at all. Can be used to filter out known devices from being probed again if required.

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 ServiceConfig

type ServiceConfig struct {
	AppCustom CustomConfig
}

ServiceConfig a struct that wraps CustomConfig which holds the values for driver configuration

func (*ServiceConfig) UpdateFromRaw

func (c *ServiceConfig) UpdateFromRaw(rawConfig interface{}) bool

UpdateFromRaw updates the service's full configuration from raw data received from the Service Provider.

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