Documentation
¶
Overview ¶
Package dlt645 provides a client for dlt645
Index ¶
- Constants
- func Reverse(s interface{})
- type Client
- type Client2007Handler
- func (dlt *Client2007Handler) Decode(raw []byte) (payload *FramePayLoad, err error)
- func (dtl *Client2007Handler) Encode(frame *FramePayLoad) (raw []byte, err error)
- func (dlt *Client2007Handler) ProcessPacket(data []byte) (result []byte, err error)
- func (dlt *Client2007Handler) Send(request []byte) (response []byte, err error)
- func (dlt *Client2007Handler) SendNotResponse(request []byte) (err error)
- func (dlt *Client2007Handler) Verify(request []byte, response []byte) (err error)
- type ClientHandler
- type DltError
- type FramePayLoad
- type Packager
- type Transporter
Constants ¶
View Source
const ( ReadDataDomainMaxSize = 200 WriteDataDomainMaxSize = 50 )
View Source
const ( CommunicationRate19200 = 0x40 // binary 0100 0000 CommunicationRate9600 = 0x20 // binary 0010 0000 CommunicationRate4800 = 0x10 // binary 0001 0000 CommunicationRate2400 = 0x08 // binary 0000 1000 CommunicationRate1200 = 0x04 // binary 0000 0100 CommunicationRate600 = 0x02 // binary 0000 0010 )
View Source
const ( // len limit 5-Bit FunctionCodeReadData = 0x11 // binary 0001 0001 FunctionCodeReadFollowUpData = 0x12 // binary 0001 0010 FunctionCodeWriteData = 0x14 // binary 0001 0100 FunctionCodeReadCommunicationAddress = 0x13 // binary 0001 0011 FunctionCodeWriteCommunicationAddress = 0x15 // binary 0001 0101 FunctionCodeBroadcastTiming = 0x8 // binary 0000 1000 FunctionCodeFreezeCommand = 0x16 // binary 0001 0110 FunctionCodeChangeCommunicationRate = 0x17 // binary 0001 0111 FunctionCodeChangePassword = 0x18 // binary 0001 1000 FunctionCodeClearMaximumDemand = 0x19 // binary 0001 1001 FunctionCodeClearAmmeter = 0x1A // binary 0001 1010 FunctionCodeClearEvent = 0x1B // binary 0001 1011 )
View Source
const ( ExceptionCodeRatesExceedsLimit = 0x40 // binary 0100 0000 费率数超过限制 ExceptionCodeDayPeriodsExceedsThreshold = 0x20 // binary 0010 0000 日时段数超 ExceptionCodeTimeZonesYearExceedsThreshold = 0x10 // binary 0001 0000 年时区数超 ExceptionCodeCommunicationRateCannotChanged = 0x08 // binary 0000 1000 通讯速率不能更改 ExceptionCodeIllegalPassword = 0x04 // binary 0000 0100 密码错误或者没有权限 ExceptionCodeRequestWithoutData = 0x02 // binary 0000 0010 请求无数据 ExceptionCodeOtherError = 0x01 // binary 0000 0001 其他错误 )
View Source
const ( FrameHead = 0x68 FrameTail = 0x16 )
View Source
const (
BroadcastAddressDomain = 0x999999999999
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface {
// read data
ReadData(dataMarker uint32, blockQuantity uint8, year, month, day, hour, minute uint8) (results []byte, err error)
// write data
WriteData(dataMarker uint32, passwordPermission uint8, password uint32, operatorCode uint32, data []byte) (results []byte, err error)
// read communication address
ReadCommunicationAddress() (results []byte, err error)
// write communication address
WriteCommunicationAddress(commAddr uint64) (results []byte, err error)
// broadcast timing
BroadcastTiming(year, month, day, hour, minute, second uint8) (err error)
// freeze command
FreezeCommand(month, day, hour, minute uint8) (results []byte, err error)
// change communication speed
ChangeCommunicationRate(Word uint8) (results []byte, err error)
// change password
ChangePassword(dataMarker uint32, oldPasswordPermission uint8, oldPassword uint32, newPasswordPermission uint8, newPassword uint32) (results []byte, err error)
// Clear the maximum demand
ClearMaximumDemand(passwordPermission uint8, password uint32, operatorCode uint32) (results []byte, err error)
// Clear the ammeter
ClearAmmeter(passwordPermission uint8, password uint32, operatorCode uint32) (results []byte, err error)
// Clear the event
ClearEvent(dataMarker uint32, passwordPermission uint8, password uint32, operatorCode uint32) (results []byte, err error)
}
func Client2007 ¶
func NewClient ¶
func NewClient(handler ClientHandler) Client
type Client2007Handler ¶
type Client2007Handler struct {
// contains filtered or unexported fields
}
func NewClient2007Handler ¶
func NewClient2007Handler(address string) *Client2007Handler
func (*Client2007Handler) Decode ¶
func (dlt *Client2007Handler) Decode(raw []byte) (payload *FramePayLoad, err error)
Decode a DTL645-2007 frame:
StartSymbol : 1 byte Address : 6 byte StartSymbol2 : 1 byte ControlCode : 1 byte DataLen : 1 byte Data : n byte CheckSUm : 1 byte EndSymbol : 1 byte
func (*Client2007Handler) Encode ¶
func (dtl *Client2007Handler) Encode(frame *FramePayLoad) (raw []byte, err error)
Encode encodes a DTL645-2007 frame:
StartSymbol : 1 byte Address : 6 byte StartSymbol2 : 1 byte ControlCode : 1 byte DataLen : 1 byte Data : n byte CheckSUm : 1 byte EndSymbol : 1 byte
func (*Client2007Handler) ProcessPacket ¶
func (*Client2007Handler) SendNotResponse ¶
type ClientHandler ¶
type ClientHandler interface {
Packager
Transporter
}
type FramePayLoad ¶
controlCode 8 bit : 0 master send 1 slave send 7 biy : 0 slave ok 1 slave err 6 bit : 0 have not follow-up data 1 have follow-up data 1-5 bit : function code
Click to show internal directories.
Click to hide internal directories.