iec104

package module
v0.0.0-...-8ada8ee Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

README

iec104

iec104主站golang实现

quickstart

修改.env中的从站地址

执行docker-compose up

develop

  1. 修改.env中的从站地址
  2. 安装依赖 make deps
  3. 修改example/client/worker/worker.go来处理通过104协议收到的数据
  4. 运行example中的104主站程序 make client

104规约解析

遥信起始地址1H<=>1

遥测起始地址4001H<=>16385

遥脉起始地址6001H<=>24577

实现功能

  1. 每15分钟进行一次总召唤,第一次触发为激活后。

  2. 每15分钟进行一次电度总召唤,第一次触发为总召唤结束后。

  3. 主备切换,断线重连

  4. 信号量解析

    3.1. M_SP_NA_1=1 单点遥信

    3.2. M_DP_NA_1=3 双点遥信

    3.3. M_ME_NA_1=9 带品质描述的遥测

    3.4 M_ME_NC_1=13 浮点数遥测

    3.4 M_IT_NA_1=15 电度总量遥脉

    3.5. M_SP_TB_1=30 带7个字节短时标的单点遥信

Documentation

Index

Constants

View Source
const (
	//MSpNa1 不带游标的单点遥信,3个字节的地址,1个字节的值
	MSpNa1 = 1
	//MDpNa1 不带时标的双点遥信,每个遥信占1个字节
	MDpNa1 = 3
	//MMeNc1 带品质描述的测量值,每个遥测值占3个字节
	MMeNa1 = 9
	//MMeNc1 带品质描述的浮点值,每个遥测值占5个字节
	MMeNc1 = 13
	//MItNa1 电度总量,每个遥脉值占5个字节
	MItNa1 = 15
	//MSpTb1 带游标的单点遥信,3个字节的地址,1个字节的值,7个字节短时标
	MSpTb1 = 30
	//MEiNA1 初始化结束
	MEiNA1 = 70
	//CIcNa1 总召唤
	CIcNa1 = 100
	//CCiNa1 电度总召唤
	CCiNa1 = 101
)

数据类型

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 {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

Client 104客户端

func NewClient

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

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

func (*Client) Run

func (c *Client) Run(task func(*APDU))

Run 运行

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
example

Jump to

Keyboard shortcuts

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