Documentation ΒΆ
Index ΒΆ
- Constants
- func DecodeBcd(b byte) int
- func EncodeBcd(value int) byte
- type BaseReadToken
- type BatchParsedReadToken
- type BatchRawReadToken
- type Bit
- type BlockInfoToken
- type BlockListToken
- type BlockListTypeToken
- type Byte
- type CatalogToken
- type Char
- type Client
- type ClientBuilder
- func (b ClientBuilder) AutoReconnect(autoReconnect bool) ClientBuilder
- func (b ClientBuilder) Build() Client
- func (b ClientBuilder) BuildAndConnect() *ConnectToken
- func (b ClientBuilder) ConnectRetry(connectRetry bool) ClientBuilder
- func (b ClientBuilder) Host(host string) ClientBuilder
- func (b ClientBuilder) Logger(logger logging.Logger) ClientBuilder
- func (b ClientBuilder) MaxReconnectBackoff(maxReconnectBackoff time.Duration) ClientBuilder
- func (b ClientBuilder) MaxReconnectTimes(maxReconnectTimes int) ClientBuilder
- func (b ClientBuilder) MaxRetries(maxRetries int) ClientBuilder
- func (b ClientBuilder) MaxRetryBackoff(maxRetryBackoff time.Duration) ClientBuilder
- func (b ClientBuilder) OnConnected(onConnected func(c Client)) ClientBuilder
- func (b ClientBuilder) OnUnActive(onUnActive func(c Client, err error)) ClientBuilder
- func (b ClientBuilder) PduLength(pduLength int) ClientBuilder
- func (b ClientBuilder) PlcType(plcType common.PlcType) ClientBuilder
- func (b ClientBuilder) Port(port int) ClientBuilder
- func (b ClientBuilder) Rack(rack int) ClientBuilder
- func (b ClientBuilder) ReconnectInterval(interval time.Duration) ClientBuilder
- func (b ClientBuilder) RetryInterval(interval time.Duration) ClientBuilder
- func (b ClientBuilder) Slot(slot int) ClientBuilder
- func (b ClientBuilder) Timeout(timeout time.Duration) ClientBuilder
- type ClockReadToken
- type CommunicationInfoToken
- type ConnectRequestContext
- type ConnectToken
- type Counter
- type DInt
- type DWord
- type Date
- type DateTime
- type DateTimeLong
- type ErrorToken
- type Int
- type OnClose
- type OnOpen
- type PduToken
- type PduValidate
- type PlcStatusToken
- type ProtectionInfoToken
- type RawInfo
- type ReadToken
- type Real
- type RequestContext
- type S5Time
- type SimpleToken
- type SingleParsedReadToken
- type SingleRawReadToken
- type StandardRequestContext
- type Status
- type String
- type SzlIdsToken
- type Time
- type TimeOfDay
- type Timer
- type TokenCompleter
- type TokenErrorSetter
- type TokenType
- type UnitInfoToken
- type UploadToken
- type ValueToken
- type WString
- type Word
Constants ΒΆ
const ( DefaultPduLength = 480 Localhost string = "127.0.0.1" DefaultPort int = 102 )
Variables ΒΆ
This section is empty.
Functions ΒΆ
Types ΒΆ
type BaseReadToken ΒΆ
type BaseReadToken struct {
// contains filtered or unexported fields
}
func (*BaseReadToken) Done ΒΆ
func (b *BaseReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BaseReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type BatchParsedReadToken ΒΆ
type BatchParsedReadToken struct {
// contains filtered or unexported fields
}
func (*BatchParsedReadToken) Async ΒΆ
func (b *BatchParsedReadToken) Async(ack func(v V, err error))
func (*BatchParsedReadToken) Done ΒΆ
func (b *BatchParsedReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BatchParsedReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type BatchRawReadToken ΒΆ
type BatchRawReadToken struct {
// contains filtered or unexported fields
}
func (*BatchRawReadToken) Done ΒΆ
func (b *BatchRawReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BatchRawReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type BlockInfoToken ΒΆ
type BlockInfoToken struct {
// contains filtered or unexported fields
}
func (*BlockInfoToken) Done ΒΆ
func (b *BlockInfoToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BlockInfoToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type BlockListToken ΒΆ
type BlockListToken struct {
// contains filtered or unexported fields
}
func (*BlockListToken) Done ΒΆ
func (b *BlockListToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BlockListToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type BlockListTypeToken ΒΆ
type BlockListTypeToken struct {
// contains filtered or unexported fields
}
func (*BlockListTypeToken) Done ΒΆ
func (b *BlockListTypeToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*BlockListTypeToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type CatalogToken ΒΆ
type CatalogToken struct {
// contains filtered or unexported fields
}
func (*CatalogToken) Done ΒΆ
func (b *CatalogToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*CatalogToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type Client ΒΆ
type Client interface { // Connect plc connect Connect() *ConnectToken // GetStatus get s7 client connection status GetStatus() Status // IsConnected return plc is connected IsConnected() bool // IsConnectionOpen return plc is connection open IsConnectionOpen() bool // Disconnect plc connection close and release Disconnect() // GetPduLength return plc max pdu length GetPduLength() int // ReadRaw read raw bytes from address ReadRaw(address string) *SingleRawReadToken // ReadBatchRaw read batch raw bytes from addresses ReadBatchRaw(addresses []string) *BatchRawReadToken // ReadParsed read auto parsed data from address ReadParsed(address string) *SingleParsedReadToken // ReadBatchParsed read batch auto parsed data from address ReadBatchParsed(addresses []string) *BatchParsedReadToken // WriteRaw write raw bytes to plc address WriteRaw(address string, data []byte) *SimpleToken // WriteRawBatch write batch raw bytes to plc addresses WriteRawBatch(addresses []string, data [][]byte) *SimpleToken // BaseRead block read // Support exceeds the maximum pdu length. // If the maximum pdu length is exceeded, it will be divided into multiple requests // And the aggregated results will be returned after the last request BaseRead(area common.AreaType, dbNumber int, byteAddr int, bitAddr int, size int) *BaseReadToken // BaseWrite block write // Support exceeds the maximum pdu length. // If the maximum pdu length is exceeded, it will be divided into multiple requests BaseWrite(area common.AreaType, dbNumber int, byteAddr int, bitAddr int, data []byte) *SimpleToken // DBGet get all data of the data block DBGet(dbNumber int) *BaseReadToken // DBFill fill the data block to the specified byte DBFill(dbNumber int, fillByte byte) *SimpleToken // HotRestart Puts the CPU in run mode performing and hot start. HotRestart() *SimpleToken // ColdRestart change CPU into run mode performing and cold start ColdRestart() *SimpleToken // StopPlc change CPU to stop mode StopPlc() *SimpleToken // CopyRamToRom copy Ram to Rom CopyRamToRom() *SimpleToken // Compress compress Compress() *SimpleToken // InsertFile insert file InsertFile(blockType common.BlockType, blockNumber int) *SimpleToken // UploadFile upload file content from PLC to PC UploadFile(blockType common.BlockType, blockNumber int) *UploadToken // DownloadFile download file content from PC to PLC DownloadFile(bytes []byte, blockType common.BlockType, blockNumber int, mC7CodeLength int) *SimpleToken // ClockRead read plc clock ClockRead() *ClockReadToken // ClockSet set plc clock ClockSet(t time.Time) *SimpleToken // ReadSzl // ref: https://support.industry.siemens.com/cs/mdm/109755202?c=22058881035&lc=cs-CZ ReadSzl(szlId uint16, szlIndex uint16) *PduToken // GetSzlIds get szl ids GetSzlIds() *SzlIdsToken // GetCatalog get plc catalogοΌorder code and versionοΌ GetCatalog() *CatalogToken // GetPlcStatus get plc mode running status GetPlcStatus() *PlcStatusToken // GetUnitInfo get plc unit info GetUnitInfo() *UnitInfoToken // GetCommunicationInfo get plc communication info GetCommunicationInfo() *CommunicationInfoToken // GetProtectionInfo get plc protection level info GetProtectionInfo() *ProtectionInfoToken // BlockList list blocks infoοΌblock countοΌ BlockList() *BlockListToken // BlockListType list blocks of type BlockListType(blockType common.BlockType) *BlockListTypeToken // BlockInfo get block info BlockInfo(bt common.BlockType, bn int) *BlockInfoToken // SetPassword set session pwd SetPassword(pwd string) *SimpleToken // ClearPassword clear session pwd ClearPassword() *SimpleToken }
type ClientBuilder ΒΆ
type ClientBuilder struct {
// contains filtered or unexported fields
}
func NewClientBuilder ΒΆ
func NewClientBuilder() ClientBuilder
func (ClientBuilder) AutoReconnect ΒΆ
func (b ClientBuilder) AutoReconnect(autoReconnect bool) ClientBuilder
func (ClientBuilder) Build ΒΆ
func (b ClientBuilder) Build() Client
func (ClientBuilder) BuildAndConnect ΒΆ
func (b ClientBuilder) BuildAndConnect() *ConnectToken
func (ClientBuilder) ConnectRetry ΒΆ
func (b ClientBuilder) ConnectRetry(connectRetry bool) ClientBuilder
func (ClientBuilder) Host ΒΆ
func (b ClientBuilder) Host(host string) ClientBuilder
func (ClientBuilder) Logger ΒΆ
func (b ClientBuilder) Logger(logger logging.Logger) ClientBuilder
func (ClientBuilder) MaxReconnectBackoff ΒΆ
func (b ClientBuilder) MaxReconnectBackoff(maxReconnectBackoff time.Duration) ClientBuilder
func (ClientBuilder) MaxReconnectTimes ΒΆ
func (b ClientBuilder) MaxReconnectTimes(maxReconnectTimes int) ClientBuilder
func (ClientBuilder) MaxRetries ΒΆ
func (b ClientBuilder) MaxRetries(maxRetries int) ClientBuilder
func (ClientBuilder) MaxRetryBackoff ΒΆ
func (b ClientBuilder) MaxRetryBackoff(maxRetryBackoff time.Duration) ClientBuilder
func (ClientBuilder) OnConnected ΒΆ
func (b ClientBuilder) OnConnected(onConnected func(c Client)) ClientBuilder
func (ClientBuilder) OnUnActive ΒΆ
func (b ClientBuilder) OnUnActive(onUnActive func(c Client, err error)) ClientBuilder
func (ClientBuilder) PduLength ΒΆ
func (b ClientBuilder) PduLength(pduLength int) ClientBuilder
func (ClientBuilder) PlcType ΒΆ
func (b ClientBuilder) PlcType(plcType common.PlcType) ClientBuilder
func (ClientBuilder) Port ΒΆ
func (b ClientBuilder) Port(port int) ClientBuilder
func (ClientBuilder) Rack ΒΆ
func (b ClientBuilder) Rack(rack int) ClientBuilder
func (ClientBuilder) ReconnectInterval ΒΆ
func (b ClientBuilder) ReconnectInterval(interval time.Duration) ClientBuilder
func (ClientBuilder) RetryInterval ΒΆ
func (b ClientBuilder) RetryInterval(interval time.Duration) ClientBuilder
func (ClientBuilder) Slot ΒΆ
func (b ClientBuilder) Slot(slot int) ClientBuilder
func (ClientBuilder) Timeout ΒΆ
func (b ClientBuilder) Timeout(timeout time.Duration) ClientBuilder
type ClockReadToken ΒΆ
type ClockReadToken struct {
// contains filtered or unexported fields
}
func (*ClockReadToken) Done ΒΆ
func (b *ClockReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*ClockReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type CommunicationInfoToken ΒΆ
type CommunicationInfoToken struct {
// contains filtered or unexported fields
}
func (*CommunicationInfoToken) Async ΒΆ
func (b *CommunicationInfoToken) Async(ack func(v V, err error))
func (*CommunicationInfoToken) Done ΒΆ
func (b *CommunicationInfoToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*CommunicationInfoToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type ConnectRequestContext ΒΆ
func (*ConnectRequestContext) GetRequest ΒΆ
func (c *ConnectRequestContext) GetRequest() *core.PDU
func (*ConnectRequestContext) GetRequestId ΒΆ
func (c *ConnectRequestContext) GetRequestId() uint16
func (*ConnectRequestContext) GetResponse ΒΆ
func (c *ConnectRequestContext) GetResponse() (res *core.PDU, err error)
func (*ConnectRequestContext) PutError ΒΆ
func (c *ConnectRequestContext) PutError(err error)
func (*ConnectRequestContext) PutResponse ΒΆ
func (c *ConnectRequestContext) PutResponse(data *core.PDU)
type ConnectToken ΒΆ
type ConnectToken struct {
// contains filtered or unexported fields
}
func (*ConnectToken) Done ΒΆ
func (b *ConnectToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*ConnectToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type Date ΒΆ
func DateFromBytes ΒΆ
type DateTime ΒΆ
func DateTimeFromBytes ΒΆ
type DateTimeLong ΒΆ
func DateTimeLongFromBytes ΒΆ
func DateTimeLongFromBytes(bs []byte) (d DateTimeLong, err error)
func (DateTimeLong) String ΒΆ
func (d DateTimeLong) String() string
func (DateTimeLong) ToBytes ΒΆ
func (d DateTimeLong) ToBytes() []byte
type ErrorToken ΒΆ
type ErrorToken interface { // Wait will wait indefinitely for the ErrorToken to complete, ie the Publishing // to be sent and confirmed receipt from the broker. Wait() error // WaitTimeout takes a time.Duration to wait for the flow associated with the // ErrorToken to complete, returns true if it returned before the timeout or // returns false if the timeout occurred. In the case of a timeout the ErrorToken // does not have an error set in case the caller wishes to wait again. WaitTimeout(time.Duration) error Async(func(error)) // Done returns a channel that is closed when the flow associated // with the ErrorToken completes. Clients should call Error after the // channel is closed to check if the flow completed successfully. // // Done is provided for use in select statements. Simple use cases may // use Wait or WaitTimeout. Done() <-chan struct{} }
type PduToken ΒΆ
type PduToken struct {
// contains filtered or unexported fields
}
func (*PduToken) Done ΒΆ
func (b *PduToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*PduToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type PduValidate ΒΆ
type PlcStatusToken ΒΆ
type PlcStatusToken struct {
// contains filtered or unexported fields
}
func (*PlcStatusToken) Done ΒΆ
func (b *PlcStatusToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*PlcStatusToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type ProtectionInfoToken ΒΆ
type ProtectionInfoToken struct {
// contains filtered or unexported fields
}
func (*ProtectionInfoToken) Done ΒΆ
func (b *ProtectionInfoToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*ProtectionInfoToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type RawInfo ΒΆ added in v0.0.2
type RawInfo struct { Value []byte Type common.ParamVariableType // contains filtered or unexported fields }
type ReadToken ΒΆ
type ReadToken struct {
// contains filtered or unexported fields
}
func (*ReadToken) Done ΒΆ
func (b *ReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*ReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type RequestContext ΒΆ
type S5Time ΒΆ
func S5TimeFromBytes ΒΆ
type SimpleToken ΒΆ
type SimpleToken struct {
// contains filtered or unexported fields
}
func (*SimpleToken) Async ΒΆ
func (s *SimpleToken) Async(ack func(err error))
func (*SimpleToken) Done ΒΆ
func (s *SimpleToken) Done() <-chan struct{}
func (*SimpleToken) Wait ΒΆ
func (s *SimpleToken) Wait() error
func (*SimpleToken) WaitTimeout ΒΆ
func (s *SimpleToken) WaitTimeout(d time.Duration) error
type SingleParsedReadToken ΒΆ
type SingleParsedReadToken struct {
// contains filtered or unexported fields
}
func (*SingleParsedReadToken) Async ΒΆ
func (b *SingleParsedReadToken) Async(ack func(v V, err error))
func (*SingleParsedReadToken) Done ΒΆ
func (b *SingleParsedReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*SingleParsedReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type SingleRawReadToken ΒΆ
type SingleRawReadToken struct {
// contains filtered or unexported fields
}
func (*SingleRawReadToken) Done ΒΆ
func (b *SingleRawReadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*SingleRawReadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type StandardRequestContext ΒΆ
type StandardRequestContext struct { RequestId uint16 Request *core.PDU Response chan *core.PDU Error chan error }
func (*StandardRequestContext) GetRequest ΒΆ
func (s *StandardRequestContext) GetRequest() *core.PDU
func (*StandardRequestContext) GetRequestId ΒΆ
func (s *StandardRequestContext) GetRequestId() uint16
func (*StandardRequestContext) GetResponse ΒΆ
func (s *StandardRequestContext) GetResponse() (res *core.PDU, err error)
func (*StandardRequestContext) PutError ΒΆ
func (s *StandardRequestContext) PutError(err error)
func (*StandardRequestContext) PutResponse ΒΆ
func (s *StandardRequestContext) PutResponse(data *core.PDU)
type SzlIdsToken ΒΆ
type SzlIdsToken struct {
// contains filtered or unexported fields
}
func (*SzlIdsToken) Done ΒΆ
func (b *SzlIdsToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*SzlIdsToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type Time ΒΆ
func TimeFromBytes ΒΆ
type TimeOfDay ΒΆ
func TimeOfDayFromBytes ΒΆ
type Timer ΒΆ
func TimerFromBytes ΒΆ
type TokenCompleter ΒΆ
type TokenCompleter interface { TokenErrorSetter // contains filtered or unexported methods }
func NewToken ΒΆ
func NewToken(tt TokenType) TokenCompleter
type TokenErrorSetter ΒΆ
type TokenErrorSetter interface {
// contains filtered or unexported methods
}
type UnitInfoToken ΒΆ
type UnitInfoToken struct {
// contains filtered or unexported fields
}
func (*UnitInfoToken) Done ΒΆ
func (b *UnitInfoToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*UnitInfoToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type UploadToken ΒΆ
type UploadToken struct {
// contains filtered or unexported fields
}
func (*UploadToken) Done ΒΆ
func (b *UploadToken) Done() <-chan struct{}
Done implements the ValueToken Done method.
func (*UploadToken) WaitTimeout ΒΆ
WaitTimeout implements the ValueToken WaitTimeout method.
type ValueToken ΒΆ
type ValueToken[V interface{}] interface { // Wait will wait indefinitely for the ValueToken to complete, ie the Publishing // to be sent and confirmed receipt from the broker. Wait() (V, error) // WaitTimeout takes a time.Duration to wait for the flow associated with the // ValueToken to complete, returns true if it returned before the timeout or // returns false if the timeout occurred. In the case of a timeout the ValueToken // does not have an error set in case the caller wishes to wait again. WaitTimeout(time.Duration) (V, error) Async(func(V, error)) // Done returns a channel that is closed when the flow associated // with the ValueToken completes. Clients should call Error after the // channel is closed to check if the flow completed successfully. // // Done is provided for use in select statements. Simple use cases may // use Wait or WaitTimeout. Done() <-chan struct{} }