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

A class for representing and encoding 6-byte binary commands. More...

Inheritance diagram for BinaryCommand:
Command

Public Member Functions

 BinaryCommand ()
 Create a blank BinaryCommand. More...
 
 BinaryCommand (byte[] command)
 Create a BinaryCommand from 6 bytes in the proper form to be sent to a device using the binary protocol. More...
 
 BinaryCommand (byte deviceAddress, byte commandNumber, int data)
 The recommended constructor, creating a BinaryCommand from user- specified parameters. More...
 
override bool Equals (object obj)
 Tests the equality of any object against this command. More...
 
override bool Equals (Command command)
 Checks to see if this command is equal to another Command. More...
 
bool Equals (BinaryCommand command)
 Reports whether a BinaryCommand is equal to this one. More...
 
override int GetHashCode ()
 Returns a hash code based off the command's attributes. More...
 
byte[] ToByteArray ()
 Encodes the command represented by this object into an array of bytes in the form specified by the Zaber Binary Protocol Manual. More...
 
override string ToString ()
 Returns a human-readable representation of this command. More...
 

Public Attributes

byte CommandNumber = 54
 The number of the command to send. More...
 
int Data = 0
 The data value to send in the command. More...
 
byte DeviceAddress
 The address of the device to which to send a command, or 0 to send a command to all devices on the chain. More...
 

Detailed Description

A class for representing and encoding 6-byte binary commands.

Constructor & Destructor Documentation

BinaryCommand ( )
inline

Create a blank BinaryCommand.

Though this constructor should be thought of as creating a blank command, integers must be set to something by default, which is usually 0. This is dangerous, as command number 0 is the "reset" command. Therefore, the default command number is instead 54, the "get status" command.

BinaryCommand ( byte[]  command)
inline

Create a BinaryCommand from 6 bytes in the proper form to be sent to a device using the binary protocol.

Parameters
commandA byte array, the first six bytes of which will be converted into a BinaryCommand object.
BinaryCommand ( byte  deviceAddress,
byte  commandNumber,
int  data 
)
inline

The recommended constructor, creating a BinaryCommand from user- specified parameters.

Parameters
deviceAddressThe number of the target device.
commandNumberThe number of the command to send.
dataThe data to send with the command.

Member Function Documentation

override bool Equals ( object  obj)
inlineinherited

Tests the equality of any object against this command.

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

Checks to see if this command is equal to another Command.

Parameters
commandThe command to compare this one to.
Returns
True if the commands are equal, false if inequal.

Implements Command.

bool Equals ( BinaryCommand  command)
inline

Reports whether a BinaryCommand is equal to this one.

Equality is defined as having all of the same attribute values. If any of the objects' attributes are inequal, this method returns false.

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

Returns a hash code based off the command'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 Command.

byte [] ToByteArray ( )
inline

Encodes the command represented by this object into an array of bytes in the form specified by the Zaber Binary Protocol Manual.

Returns
A 6-byte array to be transmitted to a device.
override string ToString ( )
inlinevirtual

Returns a human-readable representation of this command.

Returns
A string representing the command.

Implements Command.

Member Data Documentation

byte CommandNumber = 54

The number of the command to send.

int Data = 0

The data value to send in the command.

byte DeviceAddress
inherited

The address of the device to which to send a command, or 0 to send a command to all devices on the chain.


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