gateway

package
v4.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadClient

func LoadClient(m *Client) error

func LoadClients

func LoadClients() error

func LoadSerial

func LoadSerial(m *Serial) error

func LoadSerials

func LoadSerials() error

func LoadServer

func LoadServer(m *Server) error

func LoadServers

func LoadServers() error

func Offline

func Offline(pid, id string)

func Online

func Online(pid, id string)

func Shutdown

func Shutdown() error

func Startup

func Startup() error

Types

type Base

type Base struct {
	Id          string `json:"id,omitempty" xorm:"pk"` //ID
	Name        string `json:"name,omitempty"`         //名称
	Description string `json:"description,omitempty"`  //说明
	Heartbeat   string `json:"heartbeat,omitempty"`    //心跳包

	//协议
	ProtocolName    string         `json:"protocol_name,omitempty"`
	ProtocolOptions map[string]any `json:"protocol_options,omitempty"`

	Disabled bool      `json:"disabled"`
	Created  time.Time `json:"created" xorm:"created"` //创建时间

	Status string `json:"status,omitempty" xorm:"-"` //状态
	// contains filtered or unexported fields
}

func (*Base) Close

func (l *Base) Close() error

Close 关闭

func (*Base) Closed

func (l *Base) Closed() bool

func (*Base) ID

func (l *Base) ID() string

func (*Base) Pipe

func (l *Base) Pipe(pipe io.ReadWriteCloser)

func (*Base) Read

func (l *Base) Read(data []byte) (int, error)

Read 读

func (*Base) Running

func (l *Base) Running() bool

func (*Base) SetReadTimeout

func (l *Base) SetReadTimeout(t time.Duration) error

func (*Base) Write

func (l *Base) Write(data []byte) (int, error)

Write 写

type Client

type Client struct {
	Base `xorm:"extends"`

	Net  string `json:"net,omitempty"`  //类型 tcp udp
	Addr string `json:"addr,omitempty"` //地址,主机名或IP
	Port uint16 `json:"port,omitempty"` //端口号
}

Client 网络链接

func GetClient

func GetClient(id string) *Client

func (*Client) Open

func (c *Client) Open() error

Open 打开

type Keeper

type Keeper struct {
	Tunnel connect.Tunnel
}

func Keep

func Keep(tunnel connect.Tunnel) *Keeper

func (*Keeper) Keep

func (k *Keeper) Keep()
type Link struct {
	Base `xorm:"extends"`

	ServerId string `json:"server_id" xorm:"index"` //服务器ID
	Remote   string `json:"remote,omitempty"`       //远程地址
}

Link 网络连接

func GetLink(id string) *Link

func (*Link) Open

func (l *Link) Open() error

type PollerOptions

type PollerOptions struct {
	PollerPeriod   uint `json:"poller_period,omitempty"`   //采集周期
	PollerInterval uint `json:"poller_interval,omitempty"` //采集间隔
}

type ProtocolOptions

type ProtocolOptions struct {
	ProtocolName    string         `json:"protocol_name,omitempty"`    //协议 rtu tcp parallel-tcp
	ProtocolOptions map[string]any `json:"protocol_options,omitempty"` //协议参数
}

type RetryOptions

type RetryOptions struct {
	RetryTimeout uint `json:"retry_timeout,omitempty"` //重试时间
	RetryMaximum uint `json:"retry_maximum,omitempty"` //最大次数
}

type Serial

type Serial struct {
	Base `xorm:"extends"`

	PortName   string `json:"port_name,omitempty"`   //port, e.g. COM1 "/dev/ttySerial1".
	BaudRate   uint   `json:"baud_rate,omitempty"`   //9600 115200
	DataBits   uint   `json:"data_bits,omitempty"`   //5 6 7 8
	StopBits   uint   `json:"stop_bits,omitempty"`   //1 2
	ParityMode int    `json:"parity_mode,omitempty"` //0 1 2 NONE ODD EVEN
}

Serial 串口

func GetSerial

func GetSerial(id string) *Serial

func (*Serial) Open

func (s *Serial) Open() error

Open 打开

type Server

type Server struct {
	Base `xorm:"extends"`

	Port uint16 `json:"port,omitempty"` //监听端口

	Mode string `json:"mode,omitempty"` //normal普通,standalone单例,register注册包
	// contains filtered or unexported fields
}

Server TCP服务器

func GetServer

func GetServer(id string) *Server

func (*Server) Close

func (s *Server) Close() error

Close 关闭

func (*Server) GetTunnel

func (s *Server) GetTunnel(id string) *Link

GetTunnel 获取连接

func (*Server) Open

func (s *Server) Open() error

Open 打开

Jump to

Keyboard shortcuts

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