C12Adapter Opensource C++ Interface
|
ANSI C12 18 protocol implementation, a further specialization of C12 set of protocols. More...
Public Types | |
enum | { SMALLEST_PACKET_SIZE = 32, BIGGEST_PACKET_SIZE = 8192, PACKET_HEADER_AND_FOOTER_LENGTH = 8, MAXIMUM_BAD_PACKET_LENGTH_SLEEP = 1000, MAXIMUM_BAD_TOGGLE_BIT_SLEEP = 1500 } |
![]() | |
enum | ReadFunctionResponseEnum { ReadFunctionResponseWhenPresent = 0, ReadFunctionResponseWhenDesired = 1, ReadFunctionResponseAlways = 2 } |
Logic of when ST8 has to be read during execution of function. More... | |
enum | { READ_SERVICE_OVERHEAD = 4, WRITE_SERVICE_OVERHEAD = 7, PARTIAL_WRITE_SERVICE_OVERHEAD = 9 } |
![]() | |
enum | { MAXIMUM_NUMBER_STRING_SIZE = 64, MAXIMUM_SERVICE_NAME_STRING_SIZE = MAXIMUM_NUMBER_STRING_SIZE + 64, DEFAULT_ESTIMATED_RESPONSE_SIZE = 0x1000, MAXIMUM_POSSIBLE_TABLE_OFFSET = 0xFFFFFF, MAXIMUM_POSSIBLE_TABLE_LENGTH = 0xFFFFFF } |
typedef std::vector< TableRawData > | TableRawDataVector |
Vector of table raw data. | |
Public Member Functions | |
MProtocolC1218 (MChannel *channel, bool channelIsOwned=true) | |
Create a new C12.18 protocol with the channel given. More... | |
virtual | ~MProtocolC1218 () |
Destroy the C12.18 protocol object. | |
virtual void | ApplyChannelParameters () |
Setup the configuration of the channel according to the C12.18 protocol handshake settings. | |
virtual void | Identify () |
Perform ANSI C12 Identify request. More... | |
virtual void | Negotiate () |
Perform ANSI C12 Negotiate request. More... | |
int | GetIdentifiedReferenceStandard () const |
Get the reference standard, as identified by the C12.18 Identify command. More... | |
int | GetIdentifiedStandardVersion () const |
Get the standard version, as identified by the C12.18 Identify command. More... | |
int | GetIdentifiedStandardRevision () const |
Get the standard revision, as identified by the C12.18 Identify command. More... | |
bool | GetIdentifiedPropertiesPresent () const |
Tells if Identify command was successful, and IDENTIFIED properties are available. More... | |
unsigned | GetNegotiatedPacketSize () const |
Return the packet size which was negotiated with the meter in the Negotiate command. More... | |
unsigned | GetNegotiatedMaximumNumberOfPackets () const |
Return the maximum number of packets, which was negotiated with the meter in the Negotiate command. More... | |
unsigned | GetNegotiatedSessionBaud () const |
Return the negotiated session baud, which was returned by the meter in the Negotiate command. More... | |
bool | GetNegotiatedPropertiesPresent () const |
Tells if Negotiate command was successful, and negotiated properties are available. More... | |
unsigned | GetIntercharacterTimeout () const |
void | SetIntercharacterTimeout (unsigned timeout) |
unsigned | GetAcknowledgementTimeout () const |
void | SetAcknowledgementTimeout (unsigned timeout) |
unsigned | GetChannelTrafficTimeout () const |
void | SetChannelTrafficTimeout (unsigned timeout) |
unsigned | GetPacketSize () const |
void | SetPacketSize (unsigned packetSize) |
unsigned | GetMaximumNumberOfPackets () const |
void | SetMaximumNumberOfPackets (unsigned num) |
unsigned | GetSessionBaud () const |
void | SetSessionBaud (unsigned sessionBaud) |
bool | GetIssueNegotiateOnStartSession () const |
void | SetIssueNegotiateOnStartSession (bool yes) |
bool | GetIssueLogoffOnEndSession () const |
void | SetIssueLogoffOnEndSession (bool yes) |
unsigned | GetProcedureInitiateTimeout () const |
void | SetProcedureInitiateTimeout (unsigned procedureInitiateTimeout) |
bool | GetNextOutgoingToggleBit () const |
void | SetNextOutgoingToggleBit (bool yes) |
void | SetWakeUpSharedOpticalPort (bool wakeUp) |
bool | GetWakeUpSharedOpticalPort () const |
bool | GetCheckIncomingToggleBit () const |
void | SetCheckIncomingToggleBit (bool doCheck) |
![]() | |
virtual | ~MProtocolC12 () |
Destroy the C12 protocol object. More... | |
virtual void | Logon () |
Perform ANSI C12 Logon service. More... | |
virtual void | Security () |
Perform ANSI C12 Security service. More... | |
virtual void | FullLogin () |
Perform whatever is required by the protocol to clear security with the meter. More... | |
virtual void | Logoff () |
Perform ANSI C12 Logoff service. More... | |
virtual void | Wait (unsigned seconds) |
Perform ANSI C12 Wait service. More... | |
virtual void | Terminate () |
Perform ANSI C12 Terminate service. More... | |
virtual Muint16 | CalculateCRC16FromBuffer (const char *buffer, unsigned length) const |
Two-byte CRC calculation procedure specific to C12 protocol. More... | |
unsigned | GetMaximumReadTableSize () const |
Return the maximum possible size of a table to read partially or fully in a single application layer packet. More... | |
virtual unsigned | CalculateChecksumFromBuffer (const char *buffer, unsigned length) const |
Protocol dependent one-byte checksum calculation procedure that uses buffer and its size. More... | |
MByteString | ApplicationLayerRequestResponse (char command, const MByteString &request) |
Perform the full application layer request and return a response. More... | |
char | ReceiveServiceCode () |
Read a code of the incoming application layer data packet. More... | |
Muint8 | ReceiveServiceByte () |
Read one byte from the incoming application layer data packet. More... | |
unsigned | ReceiveServiceUInt (unsigned size) |
Read several bytes from the incoming application layer data packet. More... | |
MByteString | ReceiveServiceBytes (unsigned length) |
Read several bytes of the incoming application layer data packet. More... | |
MByteString | ReceiveServiceRemainingBytes () |
Read bytes of the incoming application layer data packet. More... | |
unsigned | GetLinkLayerRetries () const |
void | SetLinkLayerRetries (unsigned retries) |
bool | GetIssueSecurityOnStartSession () const |
virtual void | SetIssueSecurityOnStartSession (bool) |
ReadFunctionResponseEnum | GetAlwaysReadFunctionResponse () const |
void | SetAlwaysReadFunctionResponse (ReadFunctionResponseEnum value) |
bool | GetAlwaysUsePartial () const |
void | SetAlwaysUsePartial (bool yes) |
bool | GetUseReadInKeepSessionAlive () const |
void | SetUseReadInKeepSessionAlive (bool yes) |
unsigned | GetUserId () const |
void | SetUserId (unsigned userId) |
const MByteString & | GetUser () const |
void | SetUser (const MByteString &userName) |
unsigned | GetTurnAroundDelay () const |
void | SetTurnAroundDelay (unsigned delay) |
unsigned | GetApplicationLayerRetries () const |
void | SetApplicationLayerRetries (unsigned retries) |
unsigned | GetApplicationLayerRetryDelay () const |
void | SetApplicationLayerRetryDelay (unsigned milliseconds) |
unsigned | GetApplicationLayerProcedureRetries () const |
void | SetApplicationLayerProcedureRetries (unsigned retries) |
unsigned | GetApplicationLayerProcedureRetryDelay () const |
void | SetApplicationLayerProcedureRetryDelay (unsigned milliseconds) |
unsigned | GetProcedureSequenceNumber () const |
void | SetProcedureSequenceNumber (unsigned number) |
void | SetEndSessionOnApplicationLayerError (bool endSessionOnApplicationLayerError) |
bool | GetEndSessionOnApplicationLayerError () const |
![]() | |
virtual MProtocol * | CreateClone () const |
Virtual copy constructor, creates the protocol which is a clone of current. More... | |
virtual | ~MProtocol ()=0 |
Destroy the protocol object. More... | |
void | Finalize () |
Execute this method as first action in the destructor of any child protocol. More... | |
unsigned | GetCountApplicationLayerServicesSuccessful () const |
The number of Application Layer services that have been successfully processed. More... | |
void | IncrementCountApplicationLayerServicesSuccessful () |
Increment the number of application layer services successfully processed. More... | |
unsigned | GetCountApplicationLayerServicesRetried () const |
The number of Application Layer services that have been retried. More... | |
void | IncrementCountApplicationLayerServicesRetried () |
Increment the number of application layer services retried. More... | |
unsigned | GetCountApplicationLayerServicesFailed () const |
The number of Application Layer services that have failed. More... | |
void | IncrementCountApplicationLayerServicesFailed () |
Increment the number of application layer services failed. More... | |
unsigned | GetCountLinkLayerPacketsSuccessful () const |
The number of Link Layer packets that have been successfully processed. More... | |
void | IncrementCountLinkLayerPacketsSuccessful () |
Increment the number of data link layer packets successfully processed. More... | |
unsigned | GetCountLinkLayerPacketsRetried () const |
The number of Link Layer packets that have been retried. More... | |
void | IncrementCountLinkLayerPacketsRetried () |
Increment the number of data link layer packets retried. More... | |
unsigned | GetCountLinkLayerPacketsFailed () const |
Get number of data link layer packets failed. More... | |
void | IncrementCountLinkLayerPacketsFailed () |
Increment the number of data link layer packets failed. More... | |
unsigned | GetMaximumRoundTripTime () const |
Gets the maximum measured approximate packet round trip time over the link layer. More... | |
unsigned | GetMinimumRoundTripTime () const |
Gets the minimum measured approximate packet round trip time over the link layer. More... | |
unsigned | GetAverageRoundTripTime () const |
Gets the average measured approximate packet round trip time over the link layer. More... | |
void | ClearPasswordList () |
Set the password list for the protocol to none, so the SetPassword property is used. More... | |
void | AddToPasswordList (const MByteString &password) |
Add a password to the password list. More... | |
int | GetPasswordListSuccessfulEntry () const |
Return the entry, which was successfully tried with the meter. More... | |
void | ResetCounts () |
Clear the statistical data for the channel. More... | |
void | Connect () |
Initializes the channel and establishes the connection with the peer. More... | |
void | Disconnect () |
Severs the connection between the computer and the end device. More... | |
bool | IsConnected () const |
Tells whether the protocol is currently connected. More... | |
bool | IsInSession () const |
Whether the protocol is in session. More... | |
MProgressAction * | CreateRootProgressAction () |
Create root of the progress actions hierarchy. More... | |
MProgressAction * | GetLocalProgressAction () |
Read-only access to the currently preset local action in progress monitor. More... | |
bool | QNeedToCommit () const |
Whether or not it is time to call QCommit(true) in order to sync with the background thread. More... | |
bool | QIsBackgroundCommunicationProgressing () const |
True if the background communication is still progressing. More... | |
bool | QIsDone () |
Combines QNeedToCommit with the following QCommit in case all commands in the queue have been sent. More... | |
void | QAbort () |
Clears the commands in the queue, or cancel the ongoing background communication. More... | |
void | QWriteToMonitor (const MStdString &message) |
Add the message to write to the Monitor log file to MProtocol's command queue. More... | |
void | QConnect () |
Places a Connect command in the queue. More... | |
void | QDisconnect () |
Places a Disconnect command in the queue. More... | |
void | QIdentifyMeter () |
Places an IdentifyMeter task in the queue. More... | |
void | QStartSession () |
Adds a start session command to MProtocol's command queue. More... | |
void | QEndSession () |
Adds an end session command to MProtocol's command queue. More... | |
void | QEndSessionNoThrow () |
EndSessionNoThrow request is queued. More... | |
void | QTableRead (MCOMNumberConstRef number, unsigned expectedSize, int id) |
Adds a ReadTable command to MProtocol's command queue. More... | |
void | QTableWrite (MCOMNumberConstRef number, const MByteString &data) |
Adds a table write command to MProtocol's command queue. More... | |
void | QTableReadPartial (MCOMNumberConstRef number, int offset, int size, int id) |
Adds a partial table read command to MProtocol's command queue. More... | |
void | QTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Adds a partial table write command to MProtocol's command queue. More... | |
void | QFunctionExecute (MCOMNumberConstRef number) |
Place a function without data request in MProtocol command queue. More... | |
void | QFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Place a function with request data in MProtocol's command queue. More... | |
void | QFunctionExecuteResponse (MCOMNumberConstRef number, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE) |
Place a function with response data in MProtocol's command queue. More... | |
void | QFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE) |
Place a function with request and response data in MProtocol's command queue. More... | |
virtual void | QCommit (bool asynchronously=false) |
Executes all operations in MProtocol's command queue. More... | |
MByteString | QGetTableData (MCOMNumberConstRef number, int id=-1) |
Fetch the table data after the table read has been successfully performed by QCommit. More... | |
MByteString | QGetFunctionData (MCOMNumberConstRef number, int id=-1) |
Fetch the function response data after the function has been successfully executed in QCommit. More... | |
MStdString | QGetIdentifyMeterData () |
Fetch the identify meter string after the QIdentifyMeter has been successfully performed in QCommit. More... | |
virtual void | WriteToMonitor (const MStdString &message) |
Synchronously write a message to the monitor, if it is connected. More... | |
void | WriteCountsToMonitor () |
Write running values of communication quality counters to monitor. More... | |
void | StartSession () |
Synchronously start the session. More... | |
void | EndSession () |
Synchronously end the session. More... | |
void | EndSessionNoThrow () |
End the session, but do not throw errors. More... | |
Muint8 | ReadStartByte (const MByteString &setOfValidStartBytes, unsigned trafficTimeout) |
Read the start byte of the packet in a proper way, taking into consideration timeouts and ignoring garbage. More... | |
MByteString | TableRead (MCOMNumberConstRef number, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter. More... | |
void | TableReadBuffer (MCOMNumberConstRef number, void *buff, unsigned size) |
Same as ReadTable, but instead of returning a byte string, read table into a given buffer. More... | |
template<class T > | |
void | TableReadBuffer (MCOMNumberConstRef number, T &table) |
Same as ReadTable, but instead of returning a byte string, read table into a given template variable. More... | |
MByteString | TableReadNoThrow (MCOMNumberConstRef number, MException **exception, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter, do not throw an exception, but rather return it. More... | |
void | TableWrite (MCOMNumberConstRef number, const MByteString &data) |
Synchronously write the whole table with number given as parameter. More... | |
void | TableWriteBuffer (MCOMNumberConstRef number, const void *data, unsigned size) |
Same as TableWrite, but uses buffer, given as data and size parameters. More... | |
template<class T > | |
void | TableWriteBuffer (MCOMNumberConstRef number, const T &table) |
Same as WriteTable, but uses variable of some specific template class or structure. More... | |
MByteString | TableReadPartial (MCOMNumberConstRef number, int offset, int size) |
Synchronously read part of the table with number given as parameter. More... | |
void | TableReadPartialBuffer (MCOMNumberConstRef number, int offset, void *buff, unsigned size) |
Same as TableReadPartial, but instead of returning a byte string, read table into a given buffer. More... | |
template<class T > | |
void | TableReadPartialBuffer (MCOMNumberConstRef number, T &table, int offset) |
Same as TableReadPartial, but instead of returning a byte string, partially read table into a given template variable. More... | |
void | TableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Synchronously write part of the table with number given as parameter. More... | |
void | TableWritePartialBuffer (MCOMNumberConstRef number, int offset, const void *buff, unsigned size) |
Same as TableWritePartial, but instead of using a byte string, write table using a given buffer. More... | |
template<class T > | |
void | TableWritePartialBuffer (MCOMNumberConstRef number, const T &table, int offset) |
Same as TableWritePartial, but instead of using a byte string, write table using a given template class contents. More... | |
void | FunctionExecute (MCOMNumberConstRef number) |
Synchronously execute the function with no parameters, the number of the function is given as parameter. More... | |
void | FunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request data, the number of the function is given as parameter. More... | |
MByteString | FunctionExecuteResponse (MCOMNumberConstRef number) |
Synchronously execute the function with response data, the number of the function is given as parameter. More... | |
MByteString | FunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request and response data, the number of the function is given as parameter. More... | |
virtual unsigned | GetNumberOfDataLinkPackets (MCommunicationCommand::CommandType typeOfRequest, unsigned applicationLayerDataSize=0) |
Return the number of data link packets that are required for a given request, provided an optional size of the application data. More... | |
MStdString | IdentifyMeterWithContext (bool sessionIsStarted=false, TableRawDataVector *tablesRead=NULL) |
Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More... | |
unsigned | CalculateChecksum (const MByteString &buffer) const |
Protocol dependent one-byte checksum calculation procedure that uses byte string. More... | |
unsigned | CalculateCRC16 (const MByteString &buffer) const |
Protocol dependent two-byte CRC calculation procedure that accepts the byte string. More... | |
void | Sleep (unsigned milliseconds) |
Calls channel's Sleep method if the channel is present. More... | |
bool | GetMeterIsLittleEndian () const |
void | SetMeterIsLittleEndian (bool isLittleEndian) |
MChannel * | GetChannel () const |
void | SetChannel (MChannel *channel) |
bool | IsChannelOwned () const |
void | SetIsChannelOwned (bool yes) |
bool | GetKeepSessionAlive () const |
void | SetKeepSessionAlive (bool alive) |
MByteString | GetPassword () const |
void | SetPassword (const MByteString &password) |
const MByteStringVector & | GetPasswordList () const |
void | SetPasswordList (const MByteStringVector &passwordList) |
MProgressMonitor * | GetProgressMonitor () const |
void | SetProgressMonitor (MProgressMonitor *p) |
MCommunicationQueue & | GetCommandQueue () |
M_NO_PROGRESS_MONITOR. More... | |
const MCommunicationQueue & | GetCommandQueue () const |
M_NO_PROGRESS_MONITOR. More... | |
MStdString | IdentifyMeter (bool sessionIsStarted=false) |
MStdString | DoIdentifyMeter0 () |
![]() | |
virtual | ~MCOMObject () |
Object destructor. | |
virtual MStdStringVector | GetAllPropertyNames () const |
Return the list of publicly available properties in MCOM syntax. More... | |
virtual MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of publicly available persistent properties in MCOM syntax. More... | |
MStdString | GetPersistentPropertyValues (bool onlyNondefaults=false, bool excludeSecurityRelated=false) const |
Get the string with the list of persistent property names and their values. More... | |
void | SetPersistentPropertyValues (const MStdString &values) |
Set the persistent properties for the object using the string with the following format: More... | |
void | SetPropertyValues (const MDictionary &values) |
Set the properties for the object using the property list object. More... | |
void | WritePropertiesToMonitor () |
Write all non-default values of protocol properties into monitor. More... | |
MStdString | DoGetPersistentPropertyValues0 () const |
Get the string with the whole list of persistent property names and their values. More... | |
MStdString | DoGetPersistentPropertyValues1 (bool onlyNondefaults) const |
Get the string with the list of persistent property names and their values. More... | |
![]() | |
virtual | ~MObject () |
Object destructor. | |
virtual const MClass * | GetClass () const =0 |
Get the final class of the object. More... | |
virtual unsigned | GetEmbeddedSizeof () const |
For embedded object types, return the size of the class. More... | |
bool | IsEmbeddedObject () const |
Tell if the object is of embedded kind. More... | |
SHOW_INTERNAL MVariant | Call (const MStdString &name, const MVariant ¶ms) |
Call the object service with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) |
Call the object service with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) |
Call the object service with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) |
Call the object service with two parameter. More... | |
MVariant | Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3) |
Call the object service with three parameter. More... | |
MVariant | Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4) |
Call the object service with four parameter. More... | |
MVariant | Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5) |
Call the object service with five parameter. More... | |
MVariant | Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6) |
Call the object service with six parameter. More... | |
virtual MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) |
Call the object service with parameters, given as variant vector. More... | |
virtual bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. | |
virtual bool | IsServicePresent (const MStdString &name) const |
Tell if the service with the given name exists. | |
virtual MVariant | GetProperty (const MStdString &name) const |
Get the property value using name of the property. More... | |
virtual void | SetProperty (const MStdString &name, const MVariant &value) |
Set the property using name of the property, and value. More... | |
virtual void | SetPersistentPropertiesToDefault () |
Set the persistent properties of the object to their default values. More... | |
virtual MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
virtual void | SetPersistentPropertyToDefault (const MStdString &name) |
Set the persistent property with the name given to default value. More... | |
virtual const char * | GetType () const |
Get the name of the type for the object (could be the same as class name). | |
virtual void | SetType (const MStdString &) |
Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More... | |
virtual void | Validate () |
Validate internal structures of the object. More... | |
Protected Member Functions | |
virtual void | DoStartSession () |
Synchronously start the session, don't do service count. More... | |
virtual void | DoEndSession () |
Synchronously end the session, don't do service count. More... | |
![]() | |
MProtocolC12 (MChannel *channel, bool channelIsOwned=true) | |
Create a new abstract ANSI C12 protocol with the channel given. More... | |
![]() | |
MProtocol (MChannel *channel, bool channelIsOwned=true) | |
Create a new abstract protocol with the channel given. More... | |
virtual void | DoTableRead (MCOMNumberConstRef number, MByteString &data, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter, don't do service count. More... | |
virtual void | DoTableWrite (MCOMNumberConstRef number, const MByteString &data) |
Synchronously write the whole table with number given as parameter, don't do service count. More... | |
virtual void | DoTableReadPartial (MCOMNumberConstRef number, MByteString &data, int offset, int size) |
Synchronously read part of the table with number given as parameter, don't do service count. More... | |
virtual void | DoTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Synchronously write part of the table with number given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecute (MCOMNumberConstRef number) |
Synchronously execute the function with no parameters, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request data, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteResponse (MCOMNumberConstRef number, MByteString &response) |
Synchronously execute the function with response data, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, MByteString &response) |
Synchronously execute the function with request and response data, the number of the function is given as parameter, don't do service count. More... | |
virtual MStdString | DoIdentifyMeter (bool sessionIsStarted, TableRawDataVector *tablesRead) |
Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More... | |
void | DoTryPasswordOrPasswordList () |
Try password or passwords for the protocol according to the PASSWORD and PasswordList settings. More... | |
virtual void | DoTryPasswordEntry (const MByteString &entry) |
Try one password, throw if error. More... | |
virtual void | DoBuildComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, int par1=-1, int par2=-1) |
Build service name with a number and given parameters. More... | |
void | DoBuildPossiblyNumericComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, bool isHex, int par1=-1, int par2=-1) |
Helper service name builder that can interpret numeric values either as hex or as decimal. More... | |
![]() | |
MCOMObject () | |
Object constructor, protected as the class is abstract. | |
![]() | |
MObject () | |
Object constructor, protected as the class is abstract. | |
void | DoSetPersistentPropertiesToDefault (const MClass *staticClass) |
Set the persistent properties to their default values for one object provided the class for that object. More... | |
Additional Inherited Members | |
![]() | |
static unsigned | StaticCalculateChecksum (const MByteString &buff) |
Compute checksum of the byte string given as parameters. More... | |
static unsigned | StaticCalculateChecksumFromBuffer (const char *data, unsigned size) |
Compute checksum of the buffer and length given as parameters. More... | |
static Muint16 | StaticCalculateCRC16FromBuffer (const char *buffer, unsigned length) |
Two-byte CRC calculation static procedure specific to C12 protocol. More... | |
static unsigned | CRC16 (const MByteString &buffer) |
Same as above, but taking byte string, reflected. More... | |
![]() | |
static unsigned | StaticCalculateChecksumFromBuffer (const char *buff, unsigned size) |
Most popular one-byte checksum calculation procedure, a sum of all bytes. More... | |
static unsigned | StaticCalculateChecksum (const MByteString &buffer) |
Compute checksum of the byte string given as parameters. More... | |
![]() | |
static const MClass * | GetStaticClass () |
Get the declared class of this particular object. More... | |
static bool | IsClassPresent (const MStdString &name) |
Tells if the given class name is available. More... | |
![]() | |
static const MClass | s_class |
Class of MObject. | |
ANSI C12 18 protocol implementation, a further specialization of C12 set of protocols.
ANSI Std C12.18-1996 "PROTOCOL SPECIFICATION FOR ANSI Type 2 OPTICAL Port", is intended as a single communications standard for Water, Gas, and Electricity meters that will work on any manufacturer's conforming product. The ANSI C12.18 is a point to point protocol developed to transport table data over an optical connection. A copy of the document can be obtained through NEMA or ANSI. MProtocolC1218 is the protocol implementation of the ANSI C12.18 standard. It inherits properties from the abstract class MProtocol, which is common to all protocols. MProtocolC1218 is intended for communications through the optical probe channel, MChannelOpticalProbe. MProtocolC1221 has extensions for working through modems and multi-drop networks. The Password is 20 characters long, refer to the Password help topic for padding rules.
anonymous enum |
MProtocolC1218::MProtocolC1218 | ( | MChannel * | channel, |
bool | channelIsOwned = true |
||
) |
Create a new C12.18 protocol with the channel given.
|
protectedvirtual |
Synchronously end the session, don't do service count.
This protected service is indeed the one, which needs overwriting by a particular protocol. Depending on the particular protocol this leads to sequence of logoff and terminate commands.
See EndSession, which is public. That one does necessary statistics, monitor handling and error message formatting.
Reimplemented from MProtocol.
|
protectedvirtual |
Synchronously start the session, don't do service count.
This protected service is indeed the one, which needs overwriting by a particular protocol. Depending on the particular protocol this leads to sequence of handshake and logon commands.
See StartSession, which is public. That one does necessary statistics, monitor handling and error message formatting.
Reimplemented from MProtocol.
Reimplemented in MProtocolC1221.
|
inline |
The maximum number of milliseconds to wait for the acknowledgement of the packet.
Should this amount of time be exceeded after the packet is sent, and there is no ACK seen (byte 0x06), a timeout condition will occur. Either a retry is triggered, or if the number of retries is zero already, an error is raised.
When MProtocolC1221::TimingSetup gets called, acknowledgement timeout is negotiated with the device to the precision of seconds. See MProtocolC1221::TimingSetup for more details.
|
inline |
Maximum number of milliseconds the device waits for a valid packet before terminating the communications session.
Channel traffic timeout applies to the ANSI C12.18 and C12.21 protocols. When C12.21 is used, the value of this property can be agreed with the device by using MProtocolC1221::TimingSetup() service. The agreement leads to approximation of the timeout value to the precision of seconds, and the approximation is done towards the upper value. For example, channel traffic timeouts 5001, 5500 or 5900 will become 6000 after successful MProtocolC1221::TimingSetup(). Because the value is passed to the device as byte value of seconds, the maximum channel traffic timeout value is limited to 255000.
|
inline |
Whether to check the incoming toggle bit or not.
This property is true by default. If it is false, the incoming toggle bit is ignored.
The ANSI C12.18 and C12.21 protocols define a toggle bit in the control field definition byte. This bit is used to detect duplicate packets. By setting this property to false, MeteringSDK can be forced to not check the toggle bit. This is useful for meters that do not properly implement the ANSI C12 toggle bit.
|
inline |
Tells if Identify command was successful, and IDENTIFIED properties are available.
Specifies whether or not the dynamic identified properties are available. The identified properties are only available after a successful start session sequence.
int MProtocolC1218::GetIdentifiedReferenceStandard | ( | ) | const |
Get the reference standard, as identified by the C12.18 Identify command.
The ANSI Reference Standard implemented by the meter. This property is available only after the ANSI C12 Identify request is executed (for example, through a start session sequence). The value of this property persists unchanged until the identification of a different meter is performed. If the property is queried before a successful Identify request, an error is raised. The property GetIdentifiedPropertiesPresent can be used to determine if the IdentifiedReferenceStandard is available.
int MProtocolC1218::GetIdentifiedStandardRevision | ( | ) | const |
Get the standard revision, as identified by the C12.18 Identify command.
The revision of the ANSI C12.xx protocol standard, as implemented by the meter. This property is important for scripts that are affected by the differences between revisions of the ANSI C12.xx standards.
This property is available only after the ANSI C12 Identify request is executed (for example, through a start session sequence). The value of this property persists unchanged until the identification of a different meter is performed. If the property is queried before a successful Identify request, an error is raised. The property GetIdentifiedPropertiesPresent can be used to determine if the IdentifiedStandardRevision is available.
int MProtocolC1218::GetIdentifiedStandardVersion | ( | ) | const |
Get the standard version, as identified by the C12.18 Identify command.
The version of the ANSI C12.xx protocol standard, as implemented by the meter. This property is important for scripts that are affected by the differences between versions of the ANSI C12.xx standards.
This property is available only after the ANSI C12 Identify request is executed (for example, through a start session sequence). The value of this property persists unchanged until the identification of a different meter is performed. If the property is queried before a successful Identify request, an error is raised. The property GetIdentifiedPropertiesPresent can be used to determine if the IdentifiedStandardVersion is available.
|
inline |
The maximum number of milliseconds allowed between individual characters sent or received in the same packet.
Should this amount of time be exceeded in between any two characters in the packet, a timeout condition will occur. Either a retry is triggered, or if the number of retries is zero already, an error is raised.
Intercharacter timeout is not precisely guarded due to hardware constraints, however the implementation guarantees that the actual timeout will not be smaller than the value given to this property. Also, when MProtocolC1221::TimingSetup gets called, intercharacter timeout is negotiated with the device to the precision of seconds. See MProtocolC1221::TimingSetup for more details.
|
inline |
Whether the Logoff C12 service shall be applied within EndSession sequence.
A standard C12.18 and C12.21 session can end with Terminate, optionally preceded by Logoff. This property allows omitting of Logoff when EndSession is called. The property has no effect on the Logoff() method that can always be called directly.
|
inline |
Whether the Negotiate C12 service shall be applied within StartSession sequence.
When the negotiate service is issued (GetIssueNegotiateOnStartSession = 1), the values of the protocol properties GetSessionBaud, GetMaximumNumberOfPackets, and GetPacketSize are the communication parameters that are requested in the negotiate service. The device does not have to accept the requested communication parameters and may reject them by specifying different values to be used. To discover what values were actually used during communications, one can query the negotiated properties.
When the negotiate service is not issued (IssueNegotiateOnStartSession = 0), the default values of the protocol properties (as defined by the ANSI C12.18 and C12.21 standard) are used for communications. Setting the values of GetSessionBaud, GetMaximumNumberOfPackets, and GetPacketSize, does not affect communications, and reading these property values does not necessarily reflect the values used during communications.
Set IssueNegotiateOnStartSession to false [0] for devices that do not support the negotiate service. The ANSI C12.18 and C12.21 protocol specifies that the negotiate service is optional and devices can respond with Service Not Supported (SNS). When MeteringSDK receives an SNS from the device, it passes the error back to the caller and does not continue with communications.
|
inline |
Maximum number of link layer packets used by the protocol.
The maximum number of packets that will be requested in the negotiate service sent to the end device. The maximum number of packets is the maximum number of data link layer packets that can be assembled by the implementation into a single service request. After a successful negotiate service, the dynamic property GetNegotiatedMaximumNumberOfPackets contains the actual value that is used during communication.
The MaximumNumberOfPackets property is only used when the negotiate service is sent to the end device. Whether or not the negotiate service is sent to the end device depends on the property GetIssueNegotiateOnStartSession.
If GetIssueNegotiateOnStartSession = 0 [False], then MCOM uses the MaximumNumberOfPackets property value as set, even though the ANSI C12.18 and C12.21 standards define the default value as 1. This is useful for testing firmware.
For more details refer to the ANSI C12.18 and C12.21 standards.
unsigned MProtocolC1218::GetNegotiatedMaximumNumberOfPackets | ( | ) | const |
Return the maximum number of packets, which was negotiated with the meter in the Negotiate command.
The number of packets that was negotiated with the meter during the start session sequence. This dynamic property is available only after the completion of a successful start session sequence. The value of this property will persist unchanged until another start session sequence. If the property is queried before a successful start session sequence, an error will be raised. The property GetNegotiatedPropertiesPresent can be used to determine if the NegotiatedMaximumNumberOfPackets is available.
During the Negotiate service, if the meter accepts the GetMaximumNumberOfPackets from MeteringSDK, then NegotiatedMaximumNumberOfPackets = MaximumNumberOfPackets.
unsigned MProtocolC1218::GetNegotiatedPacketSize | ( | ) | const |
Return the packet size which was negotiated with the meter in the Negotiate command.
The number of bytes in the packet that was negotiated with the meter during the start session sequence. This dynamic property is available only after the completion of a successful start session sequence. The value of this property will persist unchanged until another start session sequence. If the property is queried before a successful start session sequence, an error is raised. The property GetNegotiatedPropertiesPresent can be used to determine if the NegotiatedPacketSize is available.
During the Negotiate service, if the meter accepts the GetPacketSize from MeteringSDK, then NegotiatedPacketSize = PacketSize.
|
inline |
Tells if Negotiate command was successful, and negotiated properties are available.
Specifies whether or not the dynamic negotiated properties are available. The negotiated properties are only available after a successful start session sequence.
unsigned MProtocolC1218::GetNegotiatedSessionBaud | ( | ) | const |
Return the negotiated session baud, which was returned by the meter in the Negotiate command.
The SessionBaud rate that was negotiated with the meter during a start session sequence. This dynamic property is available only after the completion of a successful start session sequence. The value of this property will persist unchanged until another start session sequence. If the property is queried before a successful start session sequence, an error is raised. The property GetNegotiatedPropertiesPresent can be used to determine if the NegotiatedSessionBaud is available.
|
inline |
The value of the toggle bit that will be used in the next outgoing data link packet.
The ANSI C12.18 and C12.21 protocols define a toggle bit in the control field definition byte. The toggle bit is used to detect duplicate packets. The NextOutgoingToggleBit property tells what the state of the next toggle bit will be. When True, the next toggle bit will be set to 1. When False, the next toggle bit will be reset to 0.
The NextOutgoingToggleBit property is useful for clients who want to start a session with the meter using QStartSession, then create their own packet(s) to send to the meter (can be sent using channel WriteBytes service). These clients should set/reset the toggle bit of their control byte based on the value of this property. When they are done sending their own packets, they can set the NextOutgoingToggleBit property and the protocol will use this property to determine how to set the toggle bit in the next package it sends to the meter.
The object sets the NextOutgoingToggleBit to zero after an end session. During normal operations, where clients are using QEndSession to terminate the session, the start session will always start with the toggle bit set to zero making it easier to compare logs from different sessions. However, for clients that want to start the session with the toggle bit set to 1, they can do so by simply setting the NextOutgoingToggleBit to 1 prior to starting the session.
Note that when using the communication queues, the communication is executed on QCommit service. It is important to get the NextOutgoingToggleBit after the QCommit service completes, and to set it before starting the QCommit service.
|
inline |
Packet size used by the ANSI protocol.
The packet size that will be requested in the negotiate service sent to the end device. The packet size is the maximum number of bytes allowed in the link layer packet. After a successful negotiate service, the dynamic property NegotiatedPacketSize contains the actual value that is used during communication.
If GetIssueNegotiateOnStartSession = 0 [False], then MCOM uses the PacketSize property value as set, even though the ANSI C12.18 and C12.21 standards define the default value as 64 bytes. This is useful for testing firmware.
For more details refer to the ANSI C12.18 and C12.21 standards.
|
inline |
Number of milliseconds which the application layer should wait while reading the ST_007 table.
The number of milliseconds to wait for the device to respond to a procedure initiate request, which is a table write to ST_007. Some procedures, on some devices, can take a long time to execute a procedure. Typically devices handle this by acknowledging the ST_007 write, then responding to the ST_008 table read (procedure response request) with the response code 'procedure accepted but not fully completed', which allows for GetApplicationLayerProcedureRetries to be utilized. However, some devices do not respond at all while executing the procedure, resulting in channel read timeout errors on the link layer where GetLinkLayerRetries are utilized. The ProcedureInitiateTimeout value corrects this situation by temporarily increasing the number of Link Layer Retries so that GetLinkLayerRetries * GetAcknowledgementTimeout is not less than ProcedureInitiateTimeout.
|
inline |
Session baud, one which is negotiated with the meter during communication.
When the session baud is nonzero, the suggested baud rate is requested in the negotiate service sent to the device. After a successful negotiate service, the dynamic property GetNegotiatedSessionBaud contains the actual value that is used during communication. Prior to the negotiate service, in case of optical probe the communications start at 9600 bps.
Whether or not the negotiate service is sent to the device depends on the property GetIssueNegotiateOnStartSession. Therefore, to change optical probe baud at negotiate, one shall set SetIssueNegotiateOnStartSession to True, and SetSessionBaud shall be a nonzero value that is a valid baud rate accepted by this property, and by the device.
For more details refer to the ANSI C12.18 and C12.21 standards.
|
inline |
Whether to wake up the shared optical probe on start session.
Determines whether or not a garbage character (0x55) is sent before an identify request to 'wake up' the shared optical port. This property only needs to be set to True when the meter has a shared optical port. Sending the garbage character resolves the problem where the UART is connected to the remote port, the identify command is sent through the optical port, the meter receives the first character (0xEE) while connected to the remote port and switches the UART to the optical port and changes the bit rate, but the meter misses at least the first character of the packet. By sending a garbage character, the meter is given time to switch the UART to the optical port before it receives the first request.
|
virtual |
Perform ANSI C12 Identify request.
This service is called from StartSession, but it can also be called directly by the user for testing purpose.
Reimplemented in MProtocolC1221.
|
virtual |
Perform ANSI C12 Negotiate request.
This service is called from StartSession, but it can also be called directly by the user for testing purpose. The implementation negotiates packet size, number of packets, and one baud rate (command 0x61).
Reimplemented in MProtocolC1221.
void MProtocolC1218::SetAcknowledgementTimeout | ( | unsigned | timeout | ) |
The maximum number of milliseconds to wait for the acknowledgement of the packet.
Should this amount of time be exceeded after the packet is sent, and there is no ACK seen (byte 0x06), a timeout condition will occur. Either a retry is triggered, or if the number of retries is zero already, an error is raised.
When MProtocolC1221::TimingSetup gets called, acknowledgement timeout is negotiated with the device to the precision of seconds. See MProtocolC1221::TimingSetup for more details.
void MProtocolC1218::SetChannelTrafficTimeout | ( | unsigned | timeout | ) |
Maximum number of milliseconds the device waits for a valid packet before terminating the communications session.
Channel traffic timeout applies to the ANSI C12.18 and C12.21 protocols. When C12.21 is used, the value of this property can be agreed with the device by using MProtocolC1221::TimingSetup() service. The agreement leads to approximation of the timeout value to the precision of seconds, and the approximation is done towards the upper value. For example, channel traffic timeouts 5001, 5500 or 5900 will become 6000 after successful MProtocolC1221::TimingSetup(). Because the value is passed to the device as byte value of seconds, the maximum channel traffic timeout value is limited to 255000.
|
inline |
Whether to check the incoming toggle bit or not.
This property is true by default. If it is false, the incoming toggle bit is ignored.
The ANSI C12.18 and C12.21 protocols define a toggle bit in the control field definition byte. This bit is used to detect duplicate packets. By setting this property to false, MeteringSDK can be forced to not check the toggle bit. This is useful for meters that do not properly implement the ANSI C12 toggle bit.
void MProtocolC1218::SetIntercharacterTimeout | ( | unsigned | timeout | ) |
The maximum number of milliseconds allowed between individual characters sent or received in the same packet.
Should this amount of time be exceeded in between any two characters in the packet, a timeout condition will occur. Either a retry is triggered, or if the number of retries is zero already, an error is raised.
Intercharacter timeout is not precisely guarded due to hardware constraints, however the implementation guarantees that the actual timeout will not be smaller than the value given to this property. Also, when MProtocolC1221::TimingSetup gets called, intercharacter timeout is negotiated with the device to the precision of seconds. See MProtocolC1221::TimingSetup for more details.
|
inline |
Whether the Logoff C12 service shall be applied within EndSession sequence.
A standard C12.18 and C12.21 session can end with Terminate, optionally preceded by Logoff. This property allows omitting of Logoff when EndSession is called. The property has no effect on the Logoff() method that can always be called directly.
|
inline |
Whether the Negotiate C12 service shall be applied within StartSession sequence.
When the negotiate service is issued (GetIssueNegotiateOnStartSession = 1), the values of the protocol properties GetSessionBaud, GetMaximumNumberOfPackets, and GetPacketSize are the communication parameters that are requested in the negotiate service. The device does not have to accept the requested communication parameters and may reject them by specifying different values to be used. To discover what values were actually used during communications, one can query the negotiated properties.
When the negotiate service is not issued (IssueNegotiateOnStartSession = 0), the default values of the protocol properties (as defined by the ANSI C12.18 and C12.21 standard) are used for communications. Setting the values of GetSessionBaud, GetMaximumNumberOfPackets, and GetPacketSize, does not affect communications, and reading these property values does not necessarily reflect the values used during communications.
Set IssueNegotiateOnStartSession to false [0] for devices that do not support the negotiate service. The ANSI C12.18 and C12.21 protocol specifies that the negotiate service is optional and devices can respond with Service Not Supported (SNS). When MeteringSDK receives an SNS from the device, it passes the error back to the caller and does not continue with communications.
void MProtocolC1218::SetMaximumNumberOfPackets | ( | unsigned | num | ) |
Maximum number of link layer packets used by the protocol.
The maximum number of packets that will be requested in the negotiate service sent to the end device. The maximum number of packets is the maximum number of data link layer packets that can be assembled by the implementation into a single service request. After a successful negotiate service, the dynamic property GetNegotiatedMaximumNumberOfPackets contains the actual value that is used during communication.
The MaximumNumberOfPackets property is only used when the negotiate service is sent to the end device. Whether or not the negotiate service is sent to the end device depends on the property GetIssueNegotiateOnStartSession.
If GetIssueNegotiateOnStartSession = 0 [False], then MCOM uses the MaximumNumberOfPackets property value as set, even though the ANSI C12.18 and C12.21 standards define the default value as 1. This is useful for testing firmware.
For more details refer to the ANSI C12.18 and C12.21 standards.
|
inline |
The value of the toggle bit that will be used in the next outgoing data link packet.
The ANSI C12.18 and C12.21 protocols define a toggle bit in the control field definition byte. The toggle bit is used to detect duplicate packets. The NextOutgoingToggleBit property tells what the state of the next toggle bit will be. When True, the next toggle bit will be set to 1. When False, the next toggle bit will be reset to 0.
The NextOutgoingToggleBit property is useful for clients who want to start a session with the meter using QStartSession, then create their own packet(s) to send to the meter (can be sent using channel WriteBytes service). These clients should set/reset the toggle bit of their control byte based on the value of this property. When they are done sending their own packets, they can set the NextOutgoingToggleBit property and the protocol will use this property to determine how to set the toggle bit in the next package it sends to the meter.
The object sets the NextOutgoingToggleBit to zero after an end session. During normal operations, where clients are using QEndSession to terminate the session, the start session will always start with the toggle bit set to zero making it easier to compare logs from different sessions. However, for clients that want to start the session with the toggle bit set to 1, they can do so by simply setting the NextOutgoingToggleBit to 1 prior to starting the session.
Note that when using the communication queues, the communication is executed on QCommit service. It is important to get the NextOutgoingToggleBit after the QCommit service completes, and to set it before starting the QCommit service.
void MProtocolC1218::SetPacketSize | ( | unsigned | packetSize | ) |
Packet size used by the ANSI protocol.
The packet size that will be requested in the negotiate service sent to the end device. The packet size is the maximum number of bytes allowed in the link layer packet. After a successful negotiate service, the dynamic property NegotiatedPacketSize contains the actual value that is used during communication.
If GetIssueNegotiateOnStartSession = 0 [False], then MCOM uses the PacketSize property value as set, even though the ANSI C12.18 and C12.21 standards define the default value as 64 bytes. This is useful for testing firmware.
For more details refer to the ANSI C12.18 and C12.21 standards.
|
inline |
Number of milliseconds which the application layer should wait while reading the ST_007 table.
The number of milliseconds to wait for the device to respond to a procedure initiate request, which is a table write to ST_007. Some procedures, on some devices, can take a long time to execute a procedure. Typically devices handle this by acknowledging the ST_007 write, then responding to the ST_008 table read (procedure response request) with the response code 'procedure accepted but not fully completed', which allows for GetApplicationLayerProcedureRetries to be utilized. However, some devices do not respond at all while executing the procedure, resulting in channel read timeout errors on the link layer where GetLinkLayerRetries are utilized. The ProcedureInitiateTimeout value corrects this situation by temporarily increasing the number of Link Layer Retries so that GetLinkLayerRetries * GetAcknowledgementTimeout is not less than ProcedureInitiateTimeout.
void MProtocolC1218::SetSessionBaud | ( | unsigned | sessionBaud | ) |
Session baud, one which is negotiated with the meter during communication.
When the session baud is nonzero, the suggested baud rate is requested in the negotiate service sent to the device. After a successful negotiate service, the dynamic property GetNegotiatedSessionBaud contains the actual value that is used during communication. Prior to the negotiate service, in case of optical probe the communications start at 9600 bps.
Whether or not the negotiate service is sent to the device depends on the property GetIssueNegotiateOnStartSession. Therefore, to change optical probe baud at negotiate, one shall set SetIssueNegotiateOnStartSession to True, and SetSessionBaud shall be a nonzero value that is a valid baud rate accepted by this property, and by the device.
For more details refer to the ANSI C12.18 and C12.21 standards.
|
inline |
Whether to wake up the shared optical probe on start session.
Determines whether or not a garbage character (0x55) is sent before an identify request to 'wake up' the shared optical port. This property only needs to be set to True when the meter has a shared optical port. Sending the garbage character resolves the problem where the UART is connected to the remote port, the identify command is sent through the optical port, the meter receives the first character (0xEE) while connected to the remote port and switches the UART to the optical port and changes the bit rate, but the meter misses at least the first character of the packet. By sending a garbage character, the meter is given time to switch the UART to the optical port before it receives the first request.