serversvc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MeterServerService

type MeterServerService struct {
	Address  [model.AddrLength]byte
	Password [model.PasswordLength]byte
	Time     time.Time
	Server   Server
}

func NewRtuServer

func NewRtuServer(port string, dataBits int, stopBits int, baudRate int, parity serial.Parity,
	timeout time.Duration) (*MeterServerService, error)

NewRtuServer 创建新的RtuServer实例

func NewTcpServer

func NewTcpServer(ip string, port int, timeout time.Duration) (*MeterServerService, error)

NewTcpServer 创建新的TcpServer实例

func (*MeterServerService) HandleRequest

func (s *MeterServerService) HandleRequest(frame *protocol.Frame) ([]byte, error)

处理读数据请求(协议与业务分离)

func (*MeterServerService) RegisterDevice

func (s *MeterServerService) RegisterDevice(addr [model.AddrLength]byte)

设备注册

func (*MeterServerService) Set00

func (s *MeterServerService) Set00(di uint32, value float32) (bool, error)

写电能量

func (*MeterServerService) Set01

func (s *MeterServerService) Set01(di uint32, demand *model.Demand) (bool, error)

写最大需量及发生时间

func (*MeterServerService) Set02

func (s *MeterServerService) Set02(di uint32, value float32) (bool, error)

写变量

func (*MeterServerService) Set04

func (s *MeterServerService) Set04(di uint32, value interface{}) (bool, error)

写参变量

func (*MeterServerService) SetAddress

func (s *MeterServerService) SetAddress(address []byte) error

写通讯地址

func (*MeterServerService) SetPassword

func (s *MeterServerService) SetPassword(password []byte) error

func (*MeterServerService) SetTime

func (s *MeterServerService) SetTime(t []byte)

写时间

type Server

type Server interface {
	Start() error
	Stop() error
	HandleConnection(interface{})
}

Jump to

Keyboard shortcuts

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