driver

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

This package provides an example implementation of S7 interface.

Index

Constants

View Source
const (
	HOST             = "Host"
	PORT             = "Port"
	RACK             = "Rack"
	SLOT             = "Slot"
	ADDRESS_TYPE     = "AddressType"
	DBADDRESS        = "DBAddress"
	STARTING_ADDRESS = "StartingAddress"
	LENGTH           = "Length"
	POS              = "Pos"
)
View Source
const (
	Protocol = "s7"
)

Constants related to protocol properties

Variables

This section is empty.

Functions

func NewProtocolDriver

func NewProtocolDriver() interfaces.ProtocolDriver

Types

type CommandInfo

type CommandInfo struct {
	Host            string
	Port            int
	Rack            int
	Slot            int
	AddressType     string
	DbAddress       int
	StartingAddress int
	Length          int
	Pos             int
	ValueType       string
}

type DBInfo

type DBInfo struct {
	Area       int
	DBNumber   int
	Start      int
	Amount     int
	WordLength int
	DBArray    []string
}

type Driver

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

func (*Driver) AddDevice

func (s *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() error

func (*Driver) HandleReadCommands

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

HandleReadCommands triggers a protocol Read operation for the specified device.

func (*Driver) HandleWriteCommands

func (s *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. Since the commands are actuation commands, params provide parameters for the individual command.

func (*Driver) Initialize

func (s *Driver) Initialize(sdk interfaces.DeviceServiceSDK) error

Initialize performs protocol-specific initialization for the device service.

func (*Driver) NewS7Client

func (s *Driver) NewS7Client(deviceName string, protocol map[string]models.ProtocolProperties) *S7Client

Create S7Client by 'Device' definition

func (*Driver) RemoveDevice

func (s *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) Start

func (d *Driver) Start() error

func (*Driver) Stop

func (s *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 (s *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

func (*Driver) ValidateDevice

func (s *Driver) ValidateDevice(device models.Device) error

type S7Client

type S7Client struct {
	DeviceName string
	Client     gos7.Client
}

type S7Info

type S7Info struct {
	// PLC connection info
	Host string
	Port int
	Rack int
	Slot int

	// DB address, start, size
	DbAddress    int
	StartAddress int
	ReadSize     int

	ConnEstablishingRetry int
	ConnRetryWaitTime     int
}

Jump to

Keyboard shortcuts

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