client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotConnected = errors.New("the service request can not be executed because the client is not yet connected")
)

Functions

This section is empty.

Types

type ASDUCall

type ASDUCall interface {
	// OnInterrogation 总召唤回复
	OnInterrogation(*asdu.ASDU) error
	// OnCounterInterrogation 总计数器回复
	OnCounterInterrogation(*asdu.ASDU) error
	// OnRead 读定值回复
	OnRead(*asdu.ASDU) error
	// OnTestCommand 测试下发回复
	OnTestCommand(*asdu.ASDU) error
	// OnClockSync 时钟同步回复
	OnClockSync(*asdu.ASDU) error
	// OnResetProcess 进程重置回复
	OnResetProcess(*asdu.ASDU) error
	// OnDelayAcquisition 延迟获取回复
	OnDelayAcquisition(*asdu.ASDU) error
	// OnASDU 数据回复或控制回复
	OnASDU(*asdu.ASDU) error
}

ASDUCall is the interface of client handler

type Client

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

func New

func New(settings *Settings, call ASDUCall) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) SendClockSynchronizationCmd

func (c *Client) SendClockSynchronizationCmd(addr uint16, t time.Time) error

SendClockSynchronizationCmd 发起时钟同步

func (*Client) SendCmd

func (c *Client) SendCmd(addr uint16, typeId asdu.TypeID, ioa asdu.InfoObjAddr, value any) error

SendCmd 双点遥控

func (*Client) SendCounterInterrogationCmd

func (c *Client) SendCounterInterrogationCmd(addr uint16) error

SendCounterInterrogationCmd 发起累积量召唤

func (*Client) SendInterrogationCmd

func (c *Client) SendInterrogationCmd(addr uint16) error

SendInterrogationCmd 发起总召唤

func (*Client) SendReadCmd

func (c *Client) SendReadCmd(addr uint16, ioa uint) error

SendReadCmd 发起读命令

func (*Client) SendResetProcessCmd

func (c *Client) SendResetProcessCmd(addr uint16) error

SendResetProcessCmd 发起复位进程命令

func (*Client) SendTestCmd

func (c *Client) SendTestCmd(addr uint16) error

SendTestCmd 发送带时标的测试命令

func (*Client) SetConnectionLostHandler

func (c *Client) SetConnectionLostHandler(f func(c *Client))

SetConnectionLostHandler 连接断开后回调,如果连接重复断开也会回调,所以存在多次调用的情况

func (*Client) SetLogCfg

func (c *Client) SetLogCfg(cfg LogCfg)

func (*Client) SetOnConnectHandler

func (c *Client) SetOnConnectHandler(f func(c *Client))

SetOnConnectHandler 连接成功后回调,如果连接断开重新连接上也会回调,所以存在多次调用的情况

func (*Client) SetServerActiveHandler

func (c *Client) SetServerActiveHandler(f func(c *Client))

SetServerActiveHandler 激活确认后回调,如果连接断开重新连接上也会回调,所以存在多次调用的情况

type DataType

type DataType int
const (
	SinglePoint                            DataType = iota // 单点信息
	DoublePoint                                            // 双点信息
	MeasuredValueScaled                                    // 测量值,标度化值信息
	MeasuredValueNormal                                    // 测量值,规一化值信息
	StepPosition                                           // 步位置信息
	BitString32                                            // 比特位串信息
	MeasuredValueFloat                                     // 测量值,短浮点数信息
	IntegratedTotals                                       // 累计量信息
	EventOfProtectionEquipment                             // 继电器保护设备事件信息
	PackedStartEventsOfProtectionEquipment                 // 继电器保护设备事件信息
	PackedOutputCircuitInfo                                // 继电器保护设备成组输出电路信息
	PackedSinglePointWithSCD                               // 带变位检出的成组单点信息
	SingleCommandInfo
	DoubleCommandInfo
	StepCommandInfo
	SetPointCommandNormalInfo
	SetPointCommandScaledInfo
	SetPointCommandFloatInfo
	BitsString32CommandInfo
	UNKNOWN // 未知的
)

func GetDataType

func GetDataType(typeId asdu.TypeID) DataType

type LogCfg

type LogCfg struct {
	Enable      bool //是否开启log
	LogProvider clog.LogProvider
}

type Settings

type Settings struct {
	Host              string
	Port              int
	AutoConnect       bool          //自动重连
	ReconnectInterval time.Duration //重连间隔
	Cfg104            *cs104.Config //104协议规范配置
	TLS               *tls.Config   // tls配置
	Params            *asdu.Params  //ASDU相关特定参数
	LogCfg            *LogCfg
}

Settings 连接配置

func NewSettings

func NewSettings() *Settings

Jump to

Keyboard shortcuts

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