iec61850

package module
v0.0.0-...-1bfd549 Latest Latest
Warning

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

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

README

iec61850

License PkgGoDev Go Version Go Report Card

English | 中文

cgo version of IEC61850 library, reference libiec61850

Overview

iec61850 is an open source (Apache-2.0 license) implementation of the IEC 61850 client and server library that implements the MMS, GOOSE and SV protocols. It can be used to implement IEC 61850 compliant clients and PCs on embedded systems and PCs running Linux, Windows Server application. This project relies on and refers to libiec61850.

Features

The library support the following IEC 61850 protocol features:

  • MMS client/server, GOOSE (IEC 61850-8-1)
  • Sampled Values (SV - IEC 61850-9-2)
  • Support for buffered and unbuffered reports
  • Online report control block configuration
  • Data access service (get data, set data)
  • online data model discovery and browsing
  • all data set services (get values, set values, browse)
  • dynamic data set services (create and delete)
  • log service
  • MMS file services (browse, get file, set file, delete/rename file)
  • Setting group handling
  • Support for service tracking
  • GOOSE and SV control block handling
  • TLS support

How to use

go get -u github.com/wendy512/iec61850

License

iec61850 is based on the Apache License 2.0 agreement, and iec61850 relies on some third-party components whose open source agreement is also Apache License 2.0.

Contact

Documentation

Index

Constants

View Source
const (
	ActDA  = "%s/%s.SGCB.ActSG"
	EditDA = "%s/%s.SGCB.EditSG"
	CnfDA  = "%s/%s.SGCB.CnfEdit"
)

Variables

View Source
var (
	NotConnected                      = errors.New("the service request can not be executed because the client is not yet connected")
	AlreadyConnected                  = errors.New("connect service not execute because the client is already connected")
	ConnectionLost                    = errors.New("the service request can not be executed caused by a loss of connection")
	ServiceNotSupported               = errors.New("the service or some given parameters are not supported by the client stack or by the server")
	ConnectionRejected                = errors.New("connection rejected by server")
	OutstandingCallLimitReached       = errors.New("cannot send request because outstanding call limit is reached")
	UserProvidedInvalidArgument       = errors.New("API function has been called with an invalid argument")
	EnableReportFailedDatasetMismatch = errors.New("API function has been called with an invalid argument")
	ObjectReferenceInvalid            = errors.New("the object provided object reference is invalid (there is a syntactical error)")
	UnexpectedValueReceived           = errors.New("received object is of unexpected type")
	Timeout                           = errors.New("the communication to the server failed with a timeout")
	AccessDenied                      = errors.New("the server rejected the access to the requested object/service due to access control")
	ObjectDoesNotExist                = errors.New("the server reported that the requested object does not exist (returned by server)")
	ObjectExists                      = errors.New("the server reported that the requested object already exists")
	ObjectAccessUnsupported           = errors.New("the server does not support the requested access method (returned by server)")
	TypeInconsistent                  = errors.New("the server expected an object of another type (returned by server)")
	TemporarilyUnavailable            = errors.New("the object or service is temporarily unavailable (returned by server)")
	ObjectUndefined                   = errors.New("the specified object is not defined in the server (returned by server)")
	InvalidAddress                    = errors.New("the specified address is invalid (returned by server)")
	HardwareFault                     = errors.New("service failed due to a hardware fault (returned by server)")
	TypeUnsupported                   = errors.New("the requested data type is not supported by the server (returned by server)")
	ObjectAttributeInconsistent       = errors.New("the provided attributes are inconsistent (returned by server)")
	ObjectValueInvalid                = errors.New("the provided object value is invalid (returned by server)")
	ObjectInvalidated                 = errors.New("the object is invalidated (returned by server)")
	MalformedMessage                  = errors.New("received an invalid response message from the server")
	ServiceNotImplemented             = errors.New("service not implemented")
	Unknown                           = errors.New("unknown error")
	StructureMustBeMmsValue           = errors.New("structure type must be MmsValue array")
	CreateControlObjectClientFail     = errors.New("control object not found in server")
	ControlObjectFail                 = errors.New("control object fail")
	ControlSelectFail                 = errors.New("select control fail")
	UnSupportOperation                = errors.New("un support operation")
)

Functions

func C2GoBool

func C2GoBool(i C.int) bool

func C2GoStr

func C2GoStr(str *C.char) string

func GetIedClientError

func GetIedClientError(err C.IedClientError) error

func Go2CBool

func Go2CBool(b bool) C.int

func Go2CStr

func Go2CStr(str string) *C.char

func IsBitSet

func IsBitSet(n int, pos uint) bool

Types

type Client

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

func NewClient

func NewClient(settings *Settings) (*Client, error)

NewClient 创建客户端实例

func (*Client) Close

func (c *Client) Close()

Close 关闭连接

func (*Client) ControlForDirectWithEnhancedSecurity

func (c *Client) ControlForDirectWithEnhancedSecurity(objectRef string, value bool) error

ControlForDirectWithEnhancedSecurity 控制模式 3[direct-with-enhanced-security]

func (*Client) ControlForDirectWithNormalSecurity

func (c *Client) ControlForDirectWithNormalSecurity(objectRef string, value bool) error

ControlForDirectWithNormalSecurity 控制模式 1[direct-with-normal-security]

func (*Client) ControlForSboWithEnhancedSecurity

func (c *Client) ControlForSboWithEnhancedSecurity(objectRef string, value bool) error

ControlForSboWithEnhancedSecurity 控制模式 4[sbo-with-enhanced-security]

func (*Client) ControlForSboWithNormalSecurity

func (c *Client) ControlForSboWithNormalSecurity(objectRef string, value bool) error

ControlForSboWithNormalSecurity 控制模式 2[sbo-with-normal-security]

func (*Client) GetSG

func (c *Client) GetSG(objectRef string) (*SettingGroup, error)

GetSG 获取SettingGroup

func (*Client) GetVariableSpecType

func (c *Client) GetVariableSpecType(objectReference string, fc FC) (MmsType, error)

GetVariableSpecType 获取类型规格

func (*Client) Read

func (c *Client) Read(objectRef string, fc FC) (interface{}, error)

Read 读取属性数据

func (*Client) ReadBool

func (c *Client) ReadBool(objectRef string, fc FC) (bool, error)

ReadBool 读取bool类型值

func (*Client) ReadDataSet

func (c *Client) ReadDataSet(objectRef string) ([]*MmsValue, error)

ReadDataSet 读取DataSet

func (*Client) ReadFloat

func (c *Client) ReadFloat(objectRef string, fc FC) (float64, error)

ReadFloat 读取float类型值

func (*Client) ReadInt32

func (c *Client) ReadInt32(objectRef string, fc FC) (int32, error)

ReadInt32 读取int32类型值

func (*Client) ReadInt64

func (c *Client) ReadInt64(objectRef string, fc FC) (int64, error)

ReadInt64 读取int64类型值

func (*Client) ReadRbcValues

func (c *Client) ReadRbcValues(objectReference string) (*ClientReportControlBlock, error)

func (*Client) ReadString

func (c *Client) ReadString(objectRef string, fc FC) (string, error)

ReadString 读取string类型值

func (*Client) ReadUint32

func (c *Client) ReadUint32(objectRef string, fc FC) (uint32, error)

ReadUint32 读取uint32类型值

func (*Client) SetRbcValues

func (c *Client) SetRbcValues(objectReference string, settings ClientReportControlBlock) error

func (*Client) Write

func (c *Client) Write(objectRef string, fc FC, value interface{}) error

Write 写单个属性值,不支持Structure

func (*Client) WriteSG

func (c *Client) WriteSG(ld, ln, objectRef string, fc FC, actSG int, value interface{}) error

WriteSG 写入SettingGroup

type ClientReportControlBlock

type ClientReportControlBlock struct {
	Ena     bool    // 使能
	IntgPd  int     // 周期上送时间
	TrgOps  TrgOps  // 触发条件
	OptFlds OptFlds // 报告选项
}

type DataAttribute

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

type DataObject

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

func (*DataObject) GetChild

func (do *DataObject) GetChild(name string) *DataAttribute

type DataSet

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

func (*DataSet) AddDataSetEntry

func (ds *DataSet) AddDataSetEntry(ref string)

AddDataSetEntry adds a new DataSetEntry to this DataSet.

type FC

type FC int
const (
	// ST Status information
	ST FC = iota
	// MX Measurands - analogue values
	MX
	// SP Setpoint
	SP
	// SV Substitution
	SV
	// CF Configuration
	CF
	// DC Description
	DC
	// SG Setting group
	SG
	// SE Setting group editable
	SE
	// SR service response / service tracking
	SR
	// OR Operate received
	OR
	// BL Blocking
	BL
	// EX Extended definition
	EX
	// CO Control, deprecated but kept here for backward compatibility
	CO
	// RP Unbuffered Reporting
	RP
	// BR Buffered Reporting
	BR
	// ALL All FCs - wildcard value
	ALL  FC = 99
	NONE FC = -1
)

fc types

type IedModel

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

func CreateModelFromConfigFileEx

func CreateModelFromConfigFileEx(filepath string) (*IedModel, error)

func NewIedModel

func NewIedModel(name string) *IedModel

func (*IedModel) CreateLogicalDevice

func (m *IedModel) CreateLogicalDevice(name string) *LogicalDevice

func (*IedModel) Destroy

func (m *IedModel) Destroy()

type IedServer

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

func NewServer

func NewServer(model *IedModel) *IedServer

NewServer creates a new instance of the IedServer using the provided model.

func (*IedServer) Destroy

func (is *IedServer) Destroy()

Destroy frees all resources associated with the IedServer.

func (*IedServer) IsRunning

func (is *IedServer) IsRunning() bool

IsRunning checks if the IedServer is currently running.

func (*IedServer) LockDataModel

func (is *IedServer) LockDataModel()

LockDataModel locks the data model of the IedServer.

func (*IedServer) Start

func (is *IedServer) Start(port int)

Start initiates the IedServer on the provided port.

func (*IedServer) Stop

func (is *IedServer) Stop()

Stop terminates the IedServer.

func (*IedServer) UnlockDataModel

func (is *IedServer) UnlockDataModel()

UnlockDataModel unlocks the data model of the IedServer.

func (*IedServer) UpdateFloatAttributeValue

func (is *IedServer) UpdateFloatAttributeValue(attr *DataAttribute, value float32)

UpdateFloatAttributeValue updates a DataAttribute with a float value.

func (*IedServer) UpdateInt32AttributeValue

func (is *IedServer) UpdateInt32AttributeValue(attr *DataAttribute, value int32)

UpdateInt32AttributeValue updates a DataAttribute with an Int32 value.

func (*IedServer) UpdateUTCTimeAttributeValue

func (is *IedServer) UpdateUTCTimeAttributeValue(attr *DataAttribute, value int64)

UpdateUTCTimeAttributeValue updates a DataAttribute with a UTC time value.

func (*IedServer) UpdateVisibleStringAttributeValue

func (is *IedServer) UpdateVisibleStringAttributeValue(attr *DataAttribute, value string)

UpdateVisibleStringAttributeValue updates a DataAttribute with a visible string value.

type LogicalDevice

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

func (*LogicalDevice) CreateLogicalNode

func (d *LogicalDevice) CreateLogicalNode(name string) *LogicalNode

type LogicalNode

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

func (*LogicalNode) CreateDataObjectCDC_APC

func (n *LogicalNode) CreateDataObjectCDC_APC(name string, ctlModel int) *DataObject

func (*LogicalNode) CreateDataObjectCDC_ENS

func (n *LogicalNode) CreateDataObjectCDC_ENS(name string) *DataObject

func (*LogicalNode) CreateDataObjectCDC_SAV

func (n *LogicalNode) CreateDataObjectCDC_SAV(name string, isInteger bool) *DataObject

func (*LogicalNode) CreateDataObjectCDC_VSS

func (n *LogicalNode) CreateDataObjectCDC_VSS(name string) *DataObject

func (*LogicalNode) CreateDataSet

func (ln *LogicalNode) CreateDataSet(name string) *DataSet

CreateDataSet creates a new DataSet under this LogicalNode.

type MmsType

type MmsType int
const (
	Array MmsType = iota
	Structure
	Boolean
	BitString
	Integer
	Unsigned
	Float
	OctetString
	VisibleString
	GeneralizedTime
	BinaryTime
	Bcd
	ObjId
	String
	UTCTime
	DataAccessError
	Int8
	Int16
	Int32
	Int64
	Uint8
	Uint16
	Uint32
)

data types

type MmsValue

type MmsValue struct {
	Type  MmsType
	Value interface{}
}

type OptFlds

type OptFlds struct {
	SequenceNumber     bool // 顺序号
	TimeOfEntry        bool // 报告时标
	ReasonForInclusion bool // 原因码
	DataSetName        bool // 数据集
	DataReference      bool // 数据引用
	BufferOverflow     bool // 缓存溢出标识
	EntryID            bool // 报告标识符
	ConfigRevision     bool // 配置版本号
}

type SettingGroup

type SettingGroup struct {
	NumOfSG int
	ActSG   int
	EditSG  int
	CnfEdit bool
}

type Settings

type Settings struct {
	Host           string
	Port           int
	ConnectTimeout uint // 连接超时配置,单位:毫秒
	RequestTimeout uint // 请求超时配置,单位:毫秒
}

Settings 连接配置

func NewSettings

func NewSettings() *Settings

type TrgOps

type TrgOps struct {
	DataChange            bool // 值变化
	QualityChange         bool // 品质变化
	DataUpdate            bool // 数据修改
	TriggeredPeriodically bool // 周期触发
	Gi                    bool // GI(一般审问)请求触发
	Transient             bool // 瞬变
}

Jump to

Keyboard shortcuts

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