FlyModbusSlaves

package
v0.0.0-...-482d8b5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlyModbusSlave

type FlyModbusSlave struct {
	IsRunning bool
	Settings  *FlyModbusSlaveSettings
	Serv      *mbserver.Server
	Serial    *FlySerials.FlySerial
}

func NewFlyModbusSlave

func NewFlyModbusSlave() *FlyModbusSlave

func (*FlyModbusSlave) BytesToFloat32

func (s *FlyModbusSlave) BytesToFloat32(b []byte) float32

func (*FlyModbusSlave) BytesToFloat64

func (s *FlyModbusSlave) BytesToFloat64(b []byte) float64

func (*FlyModbusSlave) BytesToInt16

func (s *FlyModbusSlave) BytesToInt16(b []byte) int16

func (*FlyModbusSlave) BytesToInt32

func (s *FlyModbusSlave) BytesToInt32(b []byte) int32

字节转换成整形

func (*FlyModbusSlave) BytesToInt64

func (s *FlyModbusSlave) BytesToInt64(b []byte) int64

func (*FlyModbusSlave) Close

func (s *FlyModbusSlave) Close()

func (*FlyModbusSlave) Float32ToBytes

func (s *FlyModbusSlave) Float32ToBytes(n float32) []byte

func (*FlyModbusSlave) Float64ToBytes

func (s *FlyModbusSlave) Float64ToBytes(n float64) []byte

func (*FlyModbusSlave) GetBytes

func (s *FlyModbusSlave) GetBytes(addr int, n int) ([]byte, error)

func (*FlyModbusSlave) GetFloat32

func (s *FlyModbusSlave) GetFloat32(addr int) (float32, error)

func (*FlyModbusSlave) GetFloat64

func (s *FlyModbusSlave) GetFloat64(addr int) (float64, error)

func (*FlyModbusSlave) GetInt16

func (s *FlyModbusSlave) GetInt16(addr int) (int16, error)

func (*FlyModbusSlave) GetInt32

func (s *FlyModbusSlave) GetInt32(addr int) (int32, error)

func (*FlyModbusSlave) GetInt64

func (s *FlyModbusSlave) GetInt64(addr int) (int64, error)

func (*FlyModbusSlave) GetName

func (s *FlyModbusSlave) GetName() string

获取串口配置名称

func (*FlyModbusSlave) Int16ToBytes

func (s *FlyModbusSlave) Int16ToBytes(n int16) []byte

func (*FlyModbusSlave) Int32ToBytes

func (s *FlyModbusSlave) Int32ToBytes(n int32) []byte

整形转换成字节

func (*FlyModbusSlave) Int64ToBytes

func (s *FlyModbusSlave) Int64ToBytes(n int64) []byte

func (*FlyModbusSlave) LoadSettings

func (s *FlyModbusSlave) LoadSettings(settings *FlyModbusSlaveSettings)

func (*FlyModbusSlave) Open

func (s *FlyModbusSlave) Open(settings *FlyModbusSlaveSettings) error

func (*FlyModbusSlave) SetBytes

func (s *FlyModbusSlave) SetBytes(addr int, value []byte) error
	if addr+count >= 65535 {
		return errors.New("overflow")
	}
	for i := 0; i < count; i++ {
		s.Serv.HoldingRegisters[addr+i] = b[i]
	}
	return nil
}

func (*FlyModbusSlave) SetFloat32

func (s *FlyModbusSlave) SetFloat32(addr int, value float32) error

func (*FlyModbusSlave) SetFloat64

func (s *FlyModbusSlave) SetFloat64(addr int, value float64) error

func (*FlyModbusSlave) SetInt16

func (s *FlyModbusSlave) SetInt16(addr int, value int16) error

func (*FlyModbusSlave) SetInt32

func (s *FlyModbusSlave) SetInt32(addr int, value int32) error

func (*FlyModbusSlave) SetInt64

func (s *FlyModbusSlave) SetInt64(addr int, value int64) error

func (*FlyModbusSlave) Start

func (s *FlyModbusSlave) Start() error

启动服务

func (*FlyModbusSlave) Stop

func (s *FlyModbusSlave) Stop()

type FlyModbusSlaveSettings

type FlyModbusSlaveSettings struct {
	Enable     bool
	ConfigType string
	ConfigKey  string
	Debug      bool

	SlaveID       uint
	EnableTcp     bool
	EnableSerial  bool
	MirrorAddress int

	TcpAddr               string
	Port                  string
	BaudRate              uint
	DataBits              uint
	ParityMode            string
	StopBits              uint
	MinimumReadSize       uint
	InterCharacterTimeout uint

	Ready bool
}

func NewFlyModbusSlaveSettings

func NewFlyModbusSlaveSettings() *FlyModbusSlaveSettings

func (*FlyModbusSlaveSettings) LoadIni

func (s *FlyModbusSlaveSettings) LoadIni(config *FlyConfigFile.FlyIni, key string) error

从ini加载配置信息

type FlyModbusSlaveTrigger

type FlyModbusSlaveTrigger struct {
	sync.Mutex
	MB        *FlyModbusSlave
	ListInt16 map[int]*FlyModbusSlaveTriggerInt16
	ListInt32 map[int]*FlyModbusSlaveTriggerInt32
	// isStart   bool
	// isStop    bool
	Task *FlyTasks.FlyLoopTask
}

func NewFlyModbusSlaveTrigger

func NewFlyModbusSlaveTrigger(mb *FlyModbusSlave) *FlyModbusSlaveTrigger

func (*FlyModbusSlaveTrigger) Clean

func (s *FlyModbusSlaveTrigger) Clean()

func (*FlyModbusSlaveTrigger) OnInt16

func (s *FlyModbusSlaveTrigger) OnInt16(addr int, f func(int16) int16)

func (*FlyModbusSlaveTrigger) OnInt32

func (s *FlyModbusSlaveTrigger) OnInt32(addr int, f func(int32) int32)

func (*FlyModbusSlaveTrigger) Start

func (s *FlyModbusSlaveTrigger) Start() error

func (*FlyModbusSlaveTrigger) Stop

func (s *FlyModbusSlaveTrigger) Stop() error

type FlyModbusSlaveTriggerInt16

type FlyModbusSlaveTriggerInt16 struct {
	LastValue int16
	Func      func(int16) int16
}

type FlyModbusSlaveTriggerInt32

type FlyModbusSlaveTriggerInt32 struct {
	LastValue int32
	Func      func(int32) int32
}

Directories

Path Synopsis
Package mbserver implments a Modbus server (slave).
Package mbserver implments a Modbus server (slave).

Jump to

Keyboard shortcuts

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