Documentation ¶
Overview ¶
Package plcconnector implements communication with PLC.
Index ¶
- Constants
- type Class
- type Client
- type Identity
- type Instance
- type JS
- type PLC
- func (p *PLC) AddTag(t Tag)
- func (p *PLC) Callback(function func(service int, status int, tag *Tag))
- func (p *PLC) Close()
- func (p *PLC) CloseHTTP() error
- func (p *PLC) CreateTag(typ string, name string)
- func (p *PLC) GetClassInstance(class int, instance int) *Instance
- func (p *PLC) GetClassInstanceAttr(class int, instance int, attr int) (*Tag, bool, bool)
- func (p *PLC) GetClassInstancesList(class int, instanceFrom int, maxInstances int) ([]int, []*Instance)
- func (p *PLC) ImportJSON(file string) error
- func (p *PLC) ImportMemoryJSON(file string) error
- func (p *PLC) NewTag(i interface{}, n string)
- func (p *PLC) NewUDT(udt string) error
- func (p *PLC) Serve(host string) error
- func (p *PLC) ServeHTTP(host string) *http.Server
- func (p *PLC) UpdateTag(name string, offset int, data []uint8) bool
- type Tag
- func TagArrayBool(v []bool, c int, n string) *Tag
- func TagArrayDINT(v []int32, c int, n string) *Tag
- func TagArrayINT(v []int16, c int, n string) *Tag
- func TagArrayLINT(v []int64, c int, n string) *Tag
- func TagArrayLREAL(v []float64, c int, n string) *Tag
- func TagArrayREAL(v []float32, c int, n string) *Tag
- func TagArraySINT(v []int8, c int, n string) *Tag
- func TagArrayUDINT(v []uint32, c int, n string) *Tag
- func TagArrayUINT(v []uint16, c int, n string) *Tag
- func TagArrayULINT(v []uint64, c int, n string) *Tag
- func TagArrayUSINT(v []uint8, c int, n string) *Tag
- func TagBOOL(v bool, n string) *Tag
- func TagDINT(v int32, n string) *Tag
- func TagINT(v int16, n string) *Tag
- func TagLINT(v int64, n string) *Tag
- func TagLREAL(v float64, n string) *Tag
- func TagREAL(v float32, n string) *Tag
- func TagSINT(v int8, n string) *Tag
- func TagShortString(v string, n string) *Tag
- func TagString(v string, n string) *Tag
- func TagStringI(v string, n string) *Tag
- func TagUDINT(v uint32, n string) *Tag
- func TagUINT(v uint16, n string) *Tag
- func TagULINT(v uint64, n string) *Tag
- func TagUSINT(v uint8, n string) *Tag
- func (t Tag) BasicType() int
- func (t *Tag) DataBOOL() []bool
- func (t *Tag) DataBytes() []byte
- func (t *Tag) DataDINT() []int32
- func (t *Tag) DataDWORD() []int32
- func (t *Tag) DataINT() []int16
- func (t *Tag) DataLINT() []int64
- func (t *Tag) DataREAL() []float32
- func (t *Tag) DataSINT() []int8
- func (t *Tag) DataString() string
- func (t Tag) DimString() string
- func (t Tag) Dims() int
- func (t Tag) ElemLen() int
- func (t Tag) Len() int
- func (t Tag) NString(n int) string
- func (t Tag) NumType() int
- func (t Tag) PathString(n int) string
- func (t *Tag) SetDataBytes(dt []byte) uint8
- func (t Tag) TypeString() string
Constants ¶
View Source
const ( // Common GetAttrAll = 0x01 SetAttrAll = 0x02 GetAttrList = 0x03 SetAttrList = 0x04 Reset = 0x05 MultiServ = 0x0A GetAttr = 0x0E SetAttr = 0x10 NextInst = 0x11 GetMember = 0x18 // Class Specific InititateUpload = 0x4B ReadTag = 0x4C ReadTemplate = 0x4C WriteTag = 0x4D ReadModifyWrite = 0x4E ForwardClose = 0x4E UploadTransfer = 0x4F UnconnectedSend = 0x52 ReadTagFrag = 0x52 WriteTagFrag = 0x53 ForwardOpen = 0x54 GetInstAttrList = 0x55 LargeForwOpen = 0x5B )
Service
View Source
const ( IdentityClass = 0x01 MessageRouter = 0x02 ConnManager = 0x06 FileClass = 0x37 ProgramClass = 0x64 SymbolClass = 0x6B TemplateClass = 0x6C ClockClass = 0x8B PortClass = 0xF4 TCPClass = 0xF5 EthernetClass = 0xF6 )
Classes
View Source
const ( TypeBOOL = 0xC1 // 1 TypeSINT = 0xC2 // 1 TypeINT = 0xC3 // 2 TypeDINT = 0xC4 // 4 TypeLINT = 0xC5 // 8 TypeUSINT = 0xC6 // 1 TypeUINT = 0xC7 // 2 TypeUDINT = 0xC8 // 4 TypeULINT = 0xC9 // 8 TypeREAL = 0xCA // 4 TypeLREAL = 0xCB // 8 TypeSTIME = 0xCC // synchronous time =DINT TypeDATE = 0xCD // day from 01-01-1972 =UINT TypeTIMEOFDAY = 0xCE // =UDINT TypeDATETIME = 0xCF // =UDINT+UINT TypeSTRING = 0xD0 // =UINT+x*USINT TypeBYTE = 0xD1 // =x*USINT TypeWORD = 0xD2 // =x*UINT TypeDWORD = 0xD3 // =x*UDINT TypeLWORD = 0xD4 // =x*ULINT TypeSTRING2 = 0xD5 // =UINT+x*UINT TypeFTIME = 0xD6 // duration high resolution microseconds =DINT TypeLTIME = 0xD7 // duration long microseconds =LINT TypeITIME = 0xD8 // duration short =INT TypeSTRINGN = 0xD9 // =UINT+UINT(n)+x*n TypeSHORTSTRING = 0xDA // =USINT+x*USINT TypeTIME = 0xDB // duration miliseconds =DINT TypeEPATH = 0xDC TypeENGUNIT = 0xDD // engineering units TypeSTRINGI = 0xDE TypeArray1D = 0x2000 TypeArray2D = 0x4000 TypeArray3D = 0x6000 TypeStruct = 0x8000 TypeType = 0x0FFF TypeStructHead = 0x02A00000 )
Data types
View Source
const ( Success = 0x00 PathSegmentError = 0x04 PathUnknown = 0x05 PartialTransfer = 0x06 ServNotSup = 0x08 AttrListError = 0x0A AttrNotSettable = 0x0E PrivilegeViol = 0x0F NotEnoughData = 0x13 AttrNotSup = 0x14 TooMuchData = 0x15 ObjectNotExist = 0x16 InvalidPar = 0x20 )
Status codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Timeout uint16 // contains filtered or unexported fields }
Client .
type Identity ¶
type Identity struct { Addr string VendorID int // UINT DeviceType int // UINT ProductCode int // UINT Revision string // UINT Status int // UINT SerialNumber uint // UDINT Name string // SHORTSTRING State int // USINT }
Identity .
type JS ¶
type JS struct { AC [5]int `json:"ac"` Symbols map[string]jsSymbols `json:"symbols"` Templates map[string]jsTemplates `json:"templates"` }
JS .
type PLC ¶
type PLC struct { Class map[int]*Class DumpNetwork bool // enables dumping network packets Name string Verbose bool // enables debugging output Timeout time.Duration // contains filtered or unexported fields }
PLC .
func (*PLC) Callback ¶
Callback registers function called at receiving communication with PLC. tag may be nil in event of error or reset.
func (*PLC) GetClassInstance ¶
GetClassInstance .
func (*PLC) GetClassInstanceAttr ¶ added in v0.1.4
GetClassInstanceAttr .
func (*PLC) GetClassInstancesList ¶
func (p *PLC) GetClassInstancesList(class int, instanceFrom int, maxInstances int) ([]int, []*Instance)
GetClassInstancesList .
Source Files ¶
Click to show internal directories.
Click to hide internal directories.