device

package
v0.0.0-...-dddc173 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commif = make(map[string]string)

Commif ..

View Source
var Mutex = make(map[string]*sync.Mutex)

Mutex ..

View Source
var RegDevice = make(Devlist)

RegDevice ..

View Source
var RemotePort serial.Port

RemotePort ...

Functions

func Bcd2Hex

func Bcd2Hex(n byte) byte

Bcd2Hex ..

func Bcd2_2f

func Bcd2_2f(a, b int) float64

Bcd2_2f ..

func ByteToFloat32

func ByteToFloat32(bytes []byte) float32

ByteToFloat32 ..

func ByteToFloat64

func ByteToFloat64(bytes []byte) float64

ByteToFloat64 ..

func BytesToInt

func BytesToInt(b []byte) int

BytesToInt ..

func Closeser

func Closeser() error

Closeser ...

{
  "cmd": "remoteSerial",
  "parse": "closeser"
}

func Float32ToByte

func Float32ToByte(float float32) []byte

Float32ToByte ..

func Float64ToByte

func Float64ToByte(float float64) []byte

Float64ToByte ..

func Hex2Bcd

func Hex2Bcd(n byte) byte

Hex2Bcd ..

func HexStringReverse

func HexStringReverse(str string) string

HexStringReverse ...

func Ifa2uint16

func Ifa2uint16(ifa interface{}) (uint16, error)

Ifa2uint16 ...

func Ifal2bytel

func Ifal2bytel(ifal interface{}) ([]byte, error)

Ifal2bytel ...

func IntToBytes

func IntToBytes(n int) []byte

IntToBytes ..

func Openser

func Openser(param *simplejson.Json) (err error)

Openser ...

{
  "cmd": "remoteSerial",
  "parse": "openser",
  "data": {
    "port":"/dev/ttyUSB0",
    "baudrate": "9600",
    "databits": "8",
    "stopbits": "1",
    "parity": "E"
  }
}

func Rmser

func Rmser(results []byte) (int, error)

Rmser ...

func Rser

func Rser() (results []byte, err error)

Rser ...

func SerialRead

func SerialRead(serport serial.Port, timeout time.Duration, results []byte) (rblen int, err error)

SerialRead ..

func StringReverse

func StringReverse(str string) string

StringReverse ...

func Wser

func Wser(data []byte) error

Wser ...

{
  "cmd": "remoteSerial",
  "parse": "wser",
  "data":88888888
}

Types

type Device

type Device struct {
	Dname      string
	DepService bool
	Devid      string
	Devtype    string
	Commif     string
	Devaddr    string
	Mutex      *sync.Mutex
}

Device ..

func (*Device) GetCommif

func (d *Device) GetCommif() string

GetCommif return Commif

func (*Device) NewDev

func (d *Device) NewDev(id string, ele map[string]string) Device

NewDev ..

type Devicerwer

type Devicerwer interface {
	NewDev(id string, ele map[string]string) (Devicerwer, error)
	RWDevValue(rw string, m Dict) (Dict, error)
	CheckKey(e Dict) (bool, error)
	GetElement() (Dict, error)
	HelpDoc() interface{}
	GetCommif() string
}

Devicerwer ..

type Devlist

type Devlist map[string]Devicerwer

Devlist ..

func NewDevHandler

func NewDevHandler(devlistfile string) (Devlist, error)

NewDevHandler ..

type Dict

type Dict map[string]interface{}

Dict ...

func GetMultiType

func GetMultiType(results []byte) (ret Dict)

GetMultiType .....

type ModbusRtu

type ModbusRtu struct {
	//组合Device
	Device `json:"device"`
	/**************按不同设备自定义*************************/
	BaudRate        int    `json:"baud_rate"`
	DataBits        int    `json:"data_bits"`
	StopBits        int    `json:"stop_bits"`
	Parity          string `json:"parity"`
	FunctionCode    int    `json:"function_code"`
	StartingAddress uint16 `json:"starting_address"`
	Quantity        uint16 `json:"quantity"`
}

ModbusRtu struct

func (*ModbusRtu) CheckKey

func (d *ModbusRtu) CheckKey(ele Dict) (bool, error)

CheckKey ..

func (*ModbusRtu) GetElement

func (d *ModbusRtu) GetElement() (Dict, error)

GetElement ..

func (*ModbusRtu) HelpDoc

func (d *ModbusRtu) HelpDoc() interface{}

HelpDoc ..

func (*ModbusRtu) NewDev

func (d *ModbusRtu) NewDev(id string, ele map[string]string) (Devicerwer, error)

NewDev ..

func (*ModbusRtu) RWDevValue

func (d *ModbusRtu) RWDevValue(rw string, m Dict) (ret Dict, err error)

RWDevValue ..

type ModbusTcp

type ModbusTcp struct {
	//组合Device
	Device
	/**************按不同设备自定义*************************/
	FunctionCode    int
	StartingAddress uint16
	Quantity        uint16
}

ModbusTcp ..

func (*ModbusTcp) CheckKey

func (d *ModbusTcp) CheckKey(ele Dict) (bool, error)

CheckKey ..

func (*ModbusTcp) GetElement

func (d *ModbusTcp) GetElement() (Dict, error)

GetElement ..

func (*ModbusTcp) HelpDoc

func (d *ModbusTcp) HelpDoc() interface{}

HelpDoc ..

func (*ModbusTcp) NewDev

func (d *ModbusTcp) NewDev(id string, ele map[string]string) (Devicerwer, error)

NewDev ..

func (*ModbusTcp) RWDevValue

func (d *ModbusTcp) RWDevValue(rw string, m Dict) (ret Dict, err error)

RWDevValue ..

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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