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

A class for representing replies from devices using the binary protocol. More...

Inheritance diagram for BinaryReply:
Reply

Public Member Functions

 BinaryReply ()
 Create an empty reply object. More...
 
 BinaryReply (byte[] reply)
 Parses a byte array and creates a matching BinaryReply. More...
 
 BinaryReply (byte deviceAddress, byte commandNumber, int data)
 Create a new BinaryReply from a set of parameters. 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 (BinaryReply reply)
 Reports whether this BinaryReply is equal to another BinaryReply. 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

byte CommandNumber = 54
 The number of the command which caused the device to reply. More...
 
int Data = 0
 Data returned with the reply. More...
 
byte DeviceAddress
 The address of the device from which the reply came. More...
 

Detailed Description

A class for representing replies from devices using the binary protocol.

Constructor & Destructor Documentation

BinaryReply ( )
inline

Create an empty reply object.

ints need to be set to something by default. This is typically 0. In Zaber's binary protocol, 0 is the "reset" command. To avoid accidental resetting a device or giving the impression a device has reset, the CommandNumber is set by default instead to 54, the more-harmless "get status" command.

BinaryReply ( byte[]  reply)
inline

Parses a byte array and creates a matching BinaryReply.

ZaberPort automatically calls this constructor to parse a reply received from the port before returning the Reply from Receive(). For this reason, it is rare that a user would need to use this constructor directly, or any BinaryReply constructor for that matter.

Parameters
replyThe byte array to be parsed into a BinaryReply object.
BinaryReply ( byte  deviceAddress,
byte  commandNumber,
int  data 
)
inline

Create a new BinaryReply from a set of parameters.

This constructor is mostly useful for testing purposes, or to more easily compare a reply with an expected response.

Parameters
deviceAddressThe number of the device this reply "came from".
commandNumberThe number of the command that caused the "device" to respond.
dataThe data to be sent along with the command.

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 ( BinaryReply  reply)
inline

Reports whether this BinaryReply is equal to another BinaryReply.

Parameters
replyThe reply to be compared to this one.
Returns
True if the replies are 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.

Returns
A string representing the reply.

Implements Reply.

Member Data Documentation

byte CommandNumber = 54

The number of the command which caused the device to reply.

int Data = 0

Data returned with the reply.

byte DeviceAddress
inherited

The address of the device from which the reply came.


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