device

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func LoadDt

func LoadDt()

* * 加载系统内支持的设备类型 *

func NewAISDeviceMaster added in v0.6.3

func NewAISDeviceMaster(e typex.RuleX) typex.XDevice

* * AIS 数据解析服务器 *

func NewCustomProtocolDevice

func NewCustomProtocolDevice(e typex.RuleX) typex.XDevice

func NewGenericBacnetIpDevice added in v0.6.1

func NewGenericBacnetIpDevice(e typex.RuleX) typex.XDevice

func NewGenericHttpDevice added in v0.6.5

func NewGenericHttpDevice(e typex.RuleX) typex.XDevice

* * 通用串口透传 *

func NewGenericModbusDevice

func NewGenericModbusDevice(e typex.RuleX) typex.XDevice

* * 温湿度传感器 *

func NewGenericOpcuaDevice

func NewGenericOpcuaDevice(e typex.RuleX) typex.XDevice

func NewGenericSnmpDevice

func NewGenericSnmpDevice(e typex.RuleX) typex.XDevice

Example: 0x02 0x92 0xFF 0x98

* * 温湿度传感器 *

func NewGenericUartDevice

func NewGenericUartDevice(e typex.RuleX) typex.XDevice

* * 通用串口透传 *

func NewIRDevice added in v0.6.3

func NewIRDevice(e typex.RuleX) typex.XDevice

func NewIcmpSender

func NewIcmpSender(e typex.RuleX) typex.XDevice

Example: 0x02 0x92 0xFF 0x98

* * 温湿度传感器 *

func NewSIEMENS_PLC added in v0.6.5

func NewSIEMENS_PLC(e typex.RuleX) typex.XDevice

* * 西门子 S1200 系列 PLC *

func NewVideoCamera

func NewVideoCamera(e typex.RuleX) typex.XDevice

func NewWSStdInOut added in v0.6.4

func NewWSStdInOut() wsInOut

func ParseADDR_I added in v0.6.5

func ParseADDR_I(s string) string

解析I格式

func ParseADDR_Q added in v0.6.5

func ParseADDR_Q(s string) string

解析Q格式

func ParseDB_D added in v0.6.5

func ParseDB_D(s string) string

解析DB

func ParseDB_X added in v0.6.5

func ParseDB_X(s string) string

解析DBX格式

Types

type AISDeviceMaster added in v0.6.3

type AISDeviceMaster struct {
	typex.XStatus

	RuleEngine typex.RuleX

	// session
	DevicesSessionMap map[string]*__AISDeviceSession
	// contains filtered or unexported fields
}

func (*AISDeviceMaster) Details added in v0.6.3

func (aism *AISDeviceMaster) Details() *typex.Device

真实设备

func (*AISDeviceMaster) Driver added in v0.6.3

func (aism *AISDeviceMaster) Driver() typex.XExternalDriver

驱动

func (*AISDeviceMaster) Init added in v0.6.3

func (aism *AISDeviceMaster) Init(devId string, configMap map[string]interface{}) error

 初始化

func (*AISDeviceMaster) OnCtrl added in v0.6.3

func (aism *AISDeviceMaster) OnCtrl(cmd []byte, args []byte) ([]byte, error)

* * OnCtrl 接口可以用来向外广播数据 *

func (*AISDeviceMaster) OnDCACall added in v0.6.3

func (aism *AISDeviceMaster) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*AISDeviceMaster) OnRead added in v0.6.3

func (aism *AISDeviceMaster) OnRead(cmd []byte, data []byte) (int, error)

从设备里面读数据出来

func (*AISDeviceMaster) OnWrite added in v0.6.3

func (aism *AISDeviceMaster) OnWrite(cmd []byte, _ []byte) (int, error)

把数据写入设备

func (*AISDeviceMaster) Property added in v0.6.3

func (aism *AISDeviceMaster) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*AISDeviceMaster) SetState added in v0.6.3

func (aism *AISDeviceMaster) SetState(status typex.DeviceState)

状态

func (*AISDeviceMaster) Start added in v0.6.3

func (aism *AISDeviceMaster) Start(cctx typex.CCTX) error

启动

func (*AISDeviceMaster) Status added in v0.6.3

func (aism *AISDeviceMaster) Status() typex.DeviceState

设备当前状态

func (*AISDeviceMaster) Stop added in v0.6.3

func (aism *AISDeviceMaster) Stop()

停止设备

type AddressInfo added in v0.6.5

type AddressInfo struct {
	DataBlockNumber int    // 数据块号
	DataType        string // 数据类型
	ElementNumber   int    // 元素号
}

AddressInfo 包含解析后的地址信息

type AuthType

type AuthType string

Auth 认证模式 枚举

const (
	AUTH_ANONYMOUS AuthType = "Anonymous"
	AUTH_USERNAME  AuthType = "UserName"
)

type BacnetIpConfig added in v0.6.1

type BacnetIpConfig struct {
	CommonConfig bacnetIpCommonConfig `json:"commonConfig"`
	NodeConfig   []bacnetIpNodeConfig `json:"nodeConfig"`
}

type BaseSentence added in v0.6.4

type BaseSentence struct {
	Talker string `json:"talker"` // The talker id (e.g GP)
	Type   string `json:"type"`   // The data type (e.g GSA)
}

func (BaseSentence) DataType added in v0.6.4

func (s BaseSentence) DataType() string

DataType returns the type of the message

func (BaseSentence) Prefix added in v0.6.4

func (s BaseSentence) Prefix() string

Prefix returns the talker and type of message

func (BaseSentence) TalkerID added in v0.6.4

func (s BaseSentence) TalkerID() string

TalkerID returns the talker of the message

type CustomProtocolDevice

type CustomProtocolDevice struct {
	typex.XStatus

	RuleEngine typex.RuleX
	// contains filtered or unexported fields
}

func (*CustomProtocolDevice) Details

func (mdev *CustomProtocolDevice) Details() *typex.Device

真实设备

func (*CustomProtocolDevice) Driver

驱动

func (*CustomProtocolDevice) Init

func (mdev *CustomProtocolDevice) Init(devId string, configMap map[string]interface{}) error

初始化

func (*CustomProtocolDevice) OnCtrl

func (mdev *CustomProtocolDevice) OnCtrl(cmd []byte, _ []byte) ([]byte, error)

* * 外部指令交互, 常用来实现自定义协议等 *

func (*CustomProtocolDevice) OnDCACall

func (mdev *CustomProtocolDevice) OnDCACall(_ string, Command string,
	Args interface{}) typex.DCAResult

* * 设备服务调用 *

func (*CustomProtocolDevice) OnRead

func (mdev *CustomProtocolDevice) OnRead(cmd []byte, data []byte) (int, error)

* * 数据读出来,对数据结构有要求, 其中Key必须是个数字或者数字字符串, 例如 1 or "1" *

func (*CustomProtocolDevice) OnWrite

func (mdev *CustomProtocolDevice) OnWrite(cmd []byte, data []byte) (int, error)

把数据写入设备

func (*CustomProtocolDevice) Property

func (mdev *CustomProtocolDevice) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*CustomProtocolDevice) SetState

func (mdev *CustomProtocolDevice) SetState(status typex.DeviceState)

状态

func (*CustomProtocolDevice) Start

func (mdev *CustomProtocolDevice) Start(cctx typex.CCTX) error

启动

func (*CustomProtocolDevice) Status

func (mdev *CustomProtocolDevice) Status() typex.DeviceState

设备当前状态

func (*CustomProtocolDevice) Stop

func (mdev *CustomProtocolDevice) Stop()

停止设备

type Date added in v0.6.4

type Date struct {
	Valid bool `json:"valid"`
	DD    int  `json:"dd"`
	MM    int  `json:"mm"`
	YY    int  `json:"yy"`
}

Date type

func (Date) String added in v0.6.4

func (d Date) String() string

String representation of date

type GNS added in v0.6.4

type GNS struct {
	BaseSentence
	Time      Time // UTC of position
	Latitude  float64
	Longitude float64
	// FAA mode indicator for each satellite navigation system (constellation) supported by device.
	//
	// May be up to six characters (according to GPSD).
	// '1' - GPS
	// '2' - GLONASS
	// '3' - Galileo
	// '4' - BDS
	// '5' - QZSS
	// '6' - NavIC (IRNSS)
	Mode       []string
	SVs        int64   // Total number of satellites in use, 00-99
	HDOP       float64 // Horizontal Dilution of Precision
	Altitude   float64 // Antenna altitude, meters, re:mean-sea-level(geoid).
	Separation float64 // Geoidal separation meters
	Age        float64 // Age of differential data
	Station    int64   // Differential reference station ID
	NavStatus  string  // Navigation status (NMEA 4.1+). See NavStats* (`NavStatusAutonomous` etc) constants for possible values.
}

func (GNS) String added in v0.6.4

func (s GNS) String() string

type GenericBacnetIpDevice added in v0.6.1

type GenericBacnetIpDevice struct {
	typex.XStatus

	RuleEngine typex.RuleX
	// contains filtered or unexported fields
}

func (*GenericBacnetIpDevice) Details added in v0.6.1

func (dev *GenericBacnetIpDevice) Details() *typex.Device

func (*GenericBacnetIpDevice) Driver added in v0.6.1

func (*GenericBacnetIpDevice) Init added in v0.6.1

func (dev *GenericBacnetIpDevice) Init(devId string, configMap map[string]interface{}) error

func (*GenericBacnetIpDevice) OnCtrl added in v0.6.1

func (dev *GenericBacnetIpDevice) OnCtrl(cmd []byte, args []byte) ([]byte, error)

func (*GenericBacnetIpDevice) OnDCACall added in v0.6.1

func (dev *GenericBacnetIpDevice) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*GenericBacnetIpDevice) OnRead added in v0.6.1

func (dev *GenericBacnetIpDevice) OnRead(cmd []byte, data []byte) (int, error)

func (*GenericBacnetIpDevice) OnWrite added in v0.6.1

func (dev *GenericBacnetIpDevice) OnWrite(cmd []byte, data []byte) (int, error)

func (*GenericBacnetIpDevice) Property added in v0.6.1

func (dev *GenericBacnetIpDevice) Property() []typex.DeviceProperty

func (*GenericBacnetIpDevice) SetState added in v0.6.1

func (dev *GenericBacnetIpDevice) SetState(state typex.DeviceState)

func (*GenericBacnetIpDevice) Start added in v0.6.1

func (dev *GenericBacnetIpDevice) Start(cctx typex.CCTX) error

func (*GenericBacnetIpDevice) Status added in v0.6.1

func (dev *GenericBacnetIpDevice) Status() typex.DeviceState

func (*GenericBacnetIpDevice) Stop added in v0.6.1

func (dev *GenericBacnetIpDevice) Stop()

type GenericHttpDevice added in v0.6.5

type GenericHttpDevice struct {
	typex.XStatus

	RuleEngine typex.RuleX
	// contains filtered or unexported fields
}

func (*GenericHttpDevice) Details added in v0.6.5

func (hd *GenericHttpDevice) Details() *typex.Device

真实设备

func (*GenericHttpDevice) Driver added in v0.6.5

驱动

func (*GenericHttpDevice) Init added in v0.6.5

func (hd *GenericHttpDevice) Init(devId string, configMap map[string]interface{}) error

 初始化

func (*GenericHttpDevice) OnCtrl added in v0.6.5

func (hd *GenericHttpDevice) OnCtrl(cmd []byte, args []byte) ([]byte, error)

func (*GenericHttpDevice) OnDCACall added in v0.6.5

func (hd *GenericHttpDevice) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*GenericHttpDevice) OnRead added in v0.6.5

func (hd *GenericHttpDevice) OnRead(cmd []byte, data []byte) (int, error)

func (*GenericHttpDevice) OnWrite added in v0.6.5

func (hd *GenericHttpDevice) OnWrite(cmd []byte, b []byte) (int, error)

把数据写入设备

func (*GenericHttpDevice) Property added in v0.6.5

func (hd *GenericHttpDevice) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*GenericHttpDevice) SetState added in v0.6.5

func (hd *GenericHttpDevice) SetState(status typex.DeviceState)

状态

func (*GenericHttpDevice) Start added in v0.6.5

func (hd *GenericHttpDevice) Start(cctx typex.CCTX) error

启动

func (*GenericHttpDevice) Status added in v0.6.5

func (hd *GenericHttpDevice) Status() typex.DeviceState

设备当前状态

func (*GenericHttpDevice) Stop added in v0.6.5

func (hd *GenericHttpDevice) Stop()

停止设备

type IR added in v0.6.3

type IR struct {
	typex.XStatus

	// irFd       syscall.Handle windows
	RuleEngine typex.RuleX
	// contains filtered or unexported fields
}

func (*IR) Details added in v0.6.3

func (ird *IR) Details() *typex.Device

真实设备

func (*IR) Driver added in v0.6.3

func (ird *IR) Driver() typex.XExternalDriver

驱动

func (*IR) Init added in v0.6.3

func (ird *IR) Init(devId string, configMap map[string]interface{}) error

 初始化

func (*IR) OnCtrl added in v0.6.3

func (ird *IR) OnCtrl(cmd []byte, args []byte) ([]byte, error)

func (*IR) OnDCACall added in v0.6.3

func (ird *IR) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*IR) OnRead added in v0.6.3

func (ird *IR) OnRead(cmd []byte, data []byte) (int, error)

* * 不支持读, 仅仅是个数据透传 *

func (*IR) OnWrite added in v0.6.3

func (ird *IR) OnWrite(cmd []byte, b []byte) (int, error)

func (*IR) Property added in v0.6.3

func (ird *IR) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*IR) SetState added in v0.6.3

func (ird *IR) SetState(status typex.DeviceState)

状态

func (*IR) Start added in v0.6.3

func (ird *IR) Start(cctx typex.CCTX) error

启动

func (*IR) Status added in v0.6.3

func (ird *IR) Status() typex.DeviceState

设备当前状态

func (*IR) Stop added in v0.6.3

func (ird *IR) Stop()

停止设备

type IcmpSender

type IcmpSender struct {
	typex.XStatus

	RuleEngine typex.RuleX
	// contains filtered or unexported fields
}

func (*IcmpSender) Details

func (sender *IcmpSender) Details() *typex.Device

真实设备

func (*IcmpSender) Driver

func (sender *IcmpSender) Driver() typex.XExternalDriver

驱动

func (*IcmpSender) Init

func (sender *IcmpSender) Init(devId string, configMap map[string]interface{}) error

 初始化

func (*IcmpSender) OnCtrl

func (sender *IcmpSender) OnCtrl(cmd []byte, args []byte) ([]byte, error)

func (*IcmpSender) OnDCACall

func (sender *IcmpSender) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*IcmpSender) OnRead

func (sender *IcmpSender) OnRead(cmd []byte, data []byte) (int, error)

从设备里面读数据出来

func (*IcmpSender) OnWrite

func (sender *IcmpSender) OnWrite(cmd []byte, _ []byte) (int, error)

把数据写入设备

func (*IcmpSender) Property

func (sender *IcmpSender) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*IcmpSender) SetState

func (sender *IcmpSender) SetState(status typex.DeviceState)

状态

func (*IcmpSender) Start

func (sender *IcmpSender) Start(cctx typex.CCTX) error

启动

func (*IcmpSender) Status

func (sender *IcmpSender) Status() typex.DeviceState

设备当前状态

func (*IcmpSender) Stop

func (sender *IcmpSender) Stop()

停止设备

type ModbusPoint added in v0.6.5

type ModbusPoint struct {
	UUID      string `json:"uuid,omitempty"` // 当UUID为空时新建
	Tag       string `json:"tag"`
	Alias     string `json:"alias"`
	Function  int    `json:"function"`
	SlaverId  byte   `json:"slaverId"`
	Address   uint16 `json:"address"`
	Frequency int64  `json:"frequency"`
	Quantity  uint16 `json:"quantity"`
	Value     string `json:"value,omitempty"`
}

* * 点位表 *

type OpcuaNode

type OpcuaNode struct {
	Tag         string `json:"tag" validate:"required" title:"数据Tag" info:""`
	Description string `json:"description" validate:"required"`
	NodeID      string `json:"nodeId" validate:"required" title:"NodeID" example:"ns=1;s=Test"`
	DataType    string `json:"dataType" title:"数据类型" tag:"String" info:""`
	Value       string `json:"value" title:"值" info:"从OPCUA获取的值"` //不需要配置
}

type PolicyFlag

type PolicyFlag string
const (
	POLICY_NONE           PolicyFlag = "None"
	POLICY_BASIC128RSA15  PolicyFlag = "Basic128Rsa15"
	POLICY_BASIC256       PolicyFlag = "Basic256"
	POLICY_BASIC256SHA256 PolicyFlag = "Basic256Sha256"
)

type RMC added in v0.6.4

type RMC struct {
	BaseSentence `json:"base"` // base
	Time         Time          `json:"time"`       // Time Stamp
	Validity     string        `json:"validity"`   // validity - A-ok, V-invalid
	Latitude     float64       `json:"latitude"`   // Latitude
	Longitude    float64       `json:"longitude"`  // Longitude
	Speed        float64       `json:"speed"`      // Speed in knots
	Course       float64       `json:"course"`     // True course
	Date         Date          `json:"date"`       // Date
	Variation    float64       `json:"variation"`  // Magnetic variation
	FFAMode      string        `json:"ffa_mode"`   // FAA mode indicator (filled in NMEA 2.3 and later)
	NavStatus    string        `json:"nav_status"` // Nav Status (NMEA 4.1 and later)
}

func (RMC) String added in v0.6.4

func (s RMC) String() string

type S1200CommonConfig added in v0.6.5

type S1200CommonConfig struct {
	Host  string `json:"host" validate:"required"`  // 127.0.0.1:502
	Model string `json:"model" validate:"required"` // s7-200 s7-1500
	// https://cloudvpn.beijerelectronics.com/hc/en-us/articles/4406049761169-Siemens-S7
	Rack        *int  `json:"rack" validate:"required"`        // 0
	Slot        *int  `json:"slot" validate:"required"`        // 1
	Timeout     *int  `json:"timeout" validate:"required"`     // 5s
	IdleTimeout *int  `json:"idleTimeout" validate:"required"` // 5s
	AutoRequest *bool `json:"autoRequest" validate:"required"` // false
}

type S1200Config added in v0.6.5

type S1200Config struct {
	CommonConfig S1200CommonConfig `json:"commonConfig" validate:"required"` // 通用配置
}

type SIEMENS_PLC added in v0.6.5

type SIEMENS_PLC struct {
	typex.XStatus

	RuleEngine typex.RuleX

	SiemensDataPoints map[string]*SiemensDataPoint
	// contains filtered or unexported fields
}

https://www.ad.siemens.com.cn/productportal/prods/s7-1200_plc_easy_plus/07-Program/02-basic/01-Data_Type/01-basic.html

func (*SIEMENS_PLC) Details added in v0.6.5

func (s1200 *SIEMENS_PLC) Details() *typex.Device

真实设备

func (*SIEMENS_PLC) Driver added in v0.6.5

func (s1200 *SIEMENS_PLC) Driver() typex.XExternalDriver

驱动

func (*SIEMENS_PLC) Init added in v0.6.5

func (s1200 *SIEMENS_PLC) Init(devId string, configMap map[string]interface{}) error

初始化

func (*SIEMENS_PLC) OnCtrl added in v0.6.5

func (s1200 *SIEMENS_PLC) OnCtrl(cmd []byte, args []byte) ([]byte, error)

func (*SIEMENS_PLC) OnDCACall added in v0.6.5

func (s1200 *SIEMENS_PLC) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult

func (*SIEMENS_PLC) OnRead added in v0.6.5

func (s1200 *SIEMENS_PLC) OnRead(cmd []byte, data []byte) (int, error)

从设备里面读数据出来

func (*SIEMENS_PLC) OnWrite added in v0.6.5

func (s1200 *SIEMENS_PLC) OnWrite(cmd []byte, data []byte) (int, error)

func (*SIEMENS_PLC) Property added in v0.6.5

func (s1200 *SIEMENS_PLC) Property() []typex.DeviceProperty

设备属性,是一系列属性描述

func (*SIEMENS_PLC) Read added in v0.6.5

func (s1200 *SIEMENS_PLC) Read(cmd []byte, data []byte) (int, error)

func (*SIEMENS_PLC) SetState added in v0.6.5

func (s1200 *SIEMENS_PLC) SetState(status typex.DeviceState)

状态

func (*SIEMENS_PLC) Start added in v0.6.5

func (s1200 *SIEMENS_PLC) Start(cctx typex.CCTX) error

启动

func (*SIEMENS_PLC) Status added in v0.6.5

func (s1200 *SIEMENS_PLC) Status() typex.DeviceState

设备当前状态

func (*SIEMENS_PLC) Stop added in v0.6.5

func (s1200 *SIEMENS_PLC) Stop()

停止设备

func (*SIEMENS_PLC) Write added in v0.6.5

func (s1200 *SIEMENS_PLC) Write(cmd []byte, data []byte) (int, error)

type SecurityMode

type SecurityMode string
const (
	MODE_NONE             SecurityMode = "None"
	MODE_SIGN             SecurityMode = "Sign"
	MODE_SIGN_AND_ENCRYPT SecurityMode = "SignAndEncrypt"
)

type SiemensDataPoint added in v0.6.5

type SiemensDataPoint struct {
	UUID       string `json:"uuid"` // 当UUID为空时新建
	DeviceUuid string `json:"device_uuid"`
	Tag        string `json:"tag,omitempty"`
	Type       string `json:"type,omitempty"`
	Frequency  *int64 `json:"frequency,omitempty"`
	Address    *int   `json:"address,omitempty"`
	Start      *int   `json:"start"`
	Size       *int   `json:"size"`
	Value      string `json:"value"`
}

点位表

type TagBlock added in v0.6.4

type TagBlock struct {
	Time         int64  `json:"time"`          // TypeUnixTime unix timestamp (unit is likely to be s, but might be ms, YMMV), parameter: -c
	RelativeTime int64  `json:"relative_time"` // TypeRelativeTime relative time, parameter: -r
	Destination  string `json:"destination"`   // TypeDestinationID destination identification 15 char max, parameter: -d
	Grouping     string `json:"grouping"`      // TypeGrouping sentence grouping, parameter: -g
	LineCount    int64  `json:"line_count"`    // TypeLineCount line count, parameter: -n
	Source       string `json:"source"`        // TypeSourceID source identification 15 char max, parameter: -s
	Text         string `json:"text"`          // TypeTextString valid character string, parameter -t
}

type Time added in v0.6.4

type Time struct {
	Valid       bool `json:"valid"`
	Hour        int  `json:"hour"`
	Minute      int  `json:"minute"`
	Second      int  `json:"second"`
	Millisecond int  `json:"millisecond"`
}

func (Time) String added in v0.6.4

func (t Time) String() string

String representation of Time

type VDMVDO added in v0.6.4

type VDMVDO struct {
	BaseSentence   `json:"base"`
	NumFragments   int64         `json:"numFragments"`
	FragmentNumber int64         `json:"fragmentNumber"`
	MessageID      int64         `json:"messageId"`
	Channel        string        `json:"channel"`
	Payload        []byte        `json:"-"`
	MessageContent aislib.Packet `json:"messageContent"`
}

* * AIS消息结构体 *

func (VDMVDO) PayloadInfo added in v0.6.4

func (v VDMVDO) PayloadInfo() string

func (VDMVDO) String added in v0.6.4

func (s VDMVDO) String() string

Jump to

Keyboard shortcuts

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