iec104

package module
v0.0.0-...-e5738e3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

README

iec104

104规约解析

实现一下数据类型的解析

M_SP_NA_1=1 连续,非连续单点遥信

M_ME_NA_1=9 连续,非连续单点遥测

M_SP_TB_1=30 非连续带时间单点遥信

develop

修改.env中的环境变量

./run d 进入docker容器

./run dev 运行example中的程序

Documentation

Index

Constants

View Source
const (
	//MSpNa1 不带游标的单点遥信,3个字节的地址,1个字节的值
	MSpNa1 = 1
	//MMeNc1 带品质描述的测量值,每个遥测值占3个字节
	MMeNc1 = 9
	//MSpTb1 带游标的单点遥信,3个字节的地址,1个字节的值,7个字节短时标
	MSpTb1 = 30
)

数据类型

Variables

This section is empty.

Functions

This section is empty.

Types

type APCI

type APCI struct {
	ApduLen int
	Ctr1    byte
	Ctr2    byte
	Ctr3    byte
	Ctr4    byte
}

APCI ..

func (*APCI) ParseCtr

func (apci *APCI) ParseCtr() (byte, interface{}, error)

ParseCtr 解析控制域

type APDU

type APDU struct {
	APCI     *APCI
	ASDU     *ASDU
	Len      int
	ASDULen  int
	CtrType  byte
	CtrFrame interface{}
	Signals  []*Signal
}

APDU 104数据包

type ASDU

type ASDU struct {
	TypeID        byte    //类型标识
	Sequence      bool    //是否连续
	Length        byte    //可变结构限定词
	Cause         uint16  //传输原因
	PublicAddress uint16  //公共地址
	Ts            float64 //毫秒级时间戳
}

ASDU 应用服务数据单元

func (*ASDU) ParseASDU

func (asdu *ASDU) ParseASDU(asduBytes []byte) (signals []*Signal, err error)

ParseASDU 解析asdu

func (*ASDU) ParseTime

func (asdu *ASDU) ParseTime(asduBytes []byte) float64

ParseTime 解析asdu中7个字节时表,转为带毫秒的时间戳

func (*ASDU) ParseVariable

func (asdu *ASDU) ParseVariable(b byte) (sq bool, length byte)

ParseVariable 解析asdu可变结构限定词

type Client

type Client struct {
	Ctx context.Context

	Logger *logrus.Logger

	DataChan chan *APDU
	// contains filtered or unexported fields
}

Client 104客户端

func NewClient

func NewClient(address string, logger *logrus.Logger) *Client

NewClient 初始化客户端,连接失败,每隔10秒重试

func (*Client) Close

func (c *Client) Close()

Close 结束程序

func (*Client) Start

func (c *Client) Start(f func(c *Client))

Start 启动

type IFrame

type IFrame struct {
	Send int16
	Recv int16
}

IFrame I帧

type SFrame

type SFrame struct {
	Recv int16
}

SFrame S帧

type Signal

type Signal struct {
	TypeID  uint    `json:"type_id"` //类型id,1:单点遥信,9:单点遥测
	Address uint32  `json:"address"` //地址
	Value   float64 `json:"value"`   //值
	Quality byte    `json:"quality"` //品质描述
	Ts      float64 `json:"ts"`      //毫秒时间戳
}

Signal 104信号

type UFrame

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

UFrame U帧

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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