Core Serial Library in C#  1.2
Public Types | Public Member Functions | Public Attributes | List of all members
AsciiReply Class Reference

A class to parse and represent replies from Zaber devices using the ASCII protocol. More...

Inheritance diagram for AsciiReply:
Reply

Public Types

enum  ReplyType : ushort { Response = '@', Info = '#', Alert = '!' }
 Represents the three different possible types of reply. More...
 

Public Member Functions

 AsciiReply ()
 Create a blank AsciiReply. More...
 
 AsciiReply (string reply)
 Create a new AsciiReply parsed from a string. More...
 
 AsciiReply (char messageType, byte deviceAddress, int axisNumber, bool rejected, bool busy, string warningFlags, string responseData)
 A constructor for making AsciiReplies by explicitly settings each attribute. More...
 
override bool Equals (object obj)
 Tests the equality of any object against this reply. More...
 
override bool Equals (Reply reply)
 Checks to see if this reply is equal to another Reply. More...
 
bool Equals (AsciiReply reply)
 Reports whether an AsciiReply is equal to another AsciiReply. More...
 
override int GetHashCode ()
 Returns a hash code based off the reply's attributes. More...
 
override string ToString ()
 Returns a human-readable representation of this reply. More...
 

Public Attributes

int AxisNumber
 The axis from which the reply came, or 0 if the reply came from a whole device. More...
 
bool Busy
 Whether the device is moving or not. More...
 
byte DeviceAddress
 The address of the device from which the reply came. More...
 
ReplyType MessageType
 The message type of the reply. Either '@', '#', or '!', for "response", "info", or "alert", respectively. More...
 
bool Rejected
 Whether the device rejected the last command. More...
 
string ResponseData
 The "meat" of a response. Can contain many different things: see the command reference for your chosen test to see what to expect. More...
 
string WarningFlags
 A two-letter code if something is wrong, or "--" if everything is OK. More...
 

Detailed Description

A class to parse and represent replies from Zaber devices using the ASCII protocol.

Member Enumeration Documentation

enum ReplyType : ushort
strong

Represents the three different possible types of reply.

Enumerator
Response 

Sent as soon as a device has received a command and determined if it should respond.

Info 

Extra info from the device for testing/debugging/programming purposes.

Info is designed to be read by the user and ignored by software. One or more info messages can follow a reply or alert message. The common occurrence of info messages is in reply to the "/help" command.

Alert 

Sent when a motion command has completed if a device has the "comm.alert" setting set to 1.

Constructor & Destructor Documentation

AsciiReply ( )
inline

Create a blank AsciiReply.

Most of the time, you will want to use the one-argument AsciiReply constructor, which will parse a reply string and turn it into a populated AsciiReply object.

AsciiReply ( string  reply)
inline

Create a new AsciiReply parsed from a string.

It is rare that you will need to construct an AsciiReply yourself: ZaberPort packages up received strings as AsciiReplies automatically. This constructor parses a reply and builds a matching AsciiReply object.

Parameters
replyThe string to be parsed.
Exceptions
ArgumentNullExceptionreply is null.
FormatExceptionThe reply could not be parsed.
AsciiReply ( char  messageType,
byte  deviceAddress,
int  axisNumber,
bool  rejected,
bool  busy,
string  warningFlags,
string  responseData 
)
inline

A constructor for making AsciiReplies by explicitly settings each attribute.

Parameters
messageTypeThe type of the reply.
deviceAddressThe address of the device which sent the reply.
axisNumberThe number of the axis which sent the reply.
rejectedWhether a command was rejected by the device.
busyWhether the device is busy.
warningFlagsA flag warning that something may be wrong with the device or its operation.
responseDataThe data associated with a reply.

Member Function Documentation

override bool Equals ( object  obj)
inlineinherited

Tests the equality of any object against this reply.

Parameters
objThe object to be compared.
Returns
True if the object and this reply are equal, false if they are inequal.
override bool Equals ( Reply  reply)
inlinevirtual

Checks to see if this reply is equal to another Reply.

Parameters
replyThe reply to compare this one to.
Returns
True if the replies are equal, false if inequal.

Implements Reply.

bool Equals ( AsciiReply  reply)
inline

Reports whether an AsciiReply is equal to another AsciiReply.

Equality is defined as having all of the same attribute values. If any of the MessageType, DeviceAddress, AxisNumber, etc. are inequal, this method returns false.

Parameters
replyThe AsciiReply to which to compare this AsciiReply.
Returns
true if equal, false if inequal.
override int GetHashCode ( )
inlinevirtual

Returns a hash code based off the reply's attributes.

The hash code returned by this function depends on all of the attributes of the object, including the mutable ones. This means that when using this class in a HashMap or similar structure, it should be considered immutable, or else it will be lost upon being changed.

Returns
The calculated hash code.

Implements Reply.

override string ToString ( )
inlinevirtual

Returns a human-readable representation of this reply.

This method will return a string which is either identical or very similar to the original reply string.

Returns
A string representing the reply.

Implements Reply.

Member Data Documentation

int AxisNumber

The axis from which the reply came, or 0 if the reply came from a whole device.

bool Busy

Whether the device is moving or not.

A device will always be busy immediately after being given a "move" command. This attribute is especially useful for polling a device to see whether it is ready to be given another command.

byte DeviceAddress
inherited

The address of the device from which the reply came.

ReplyType MessageType

The message type of the reply. Either '@', '#', or '!', for "response", "info", or "alert", respectively.

bool Rejected

Whether the device rejected the last command.

string ResponseData

The "meat" of a response. Can contain many different things: see the command reference for your chosen test to see what to expect.

string WarningFlags

A two-letter code if something is wrong, or "--" if everything is OK.


The documentation for this class was generated from the following file: