Class ASCIIProtocol
Implementation of Brainboxes.IO.IIOProtocol using the Brainboxes ASCII/DCON command protocol. This is the default protocol for ED-series devices on TCP port 9500.
Assembly: Brainboxes.IO.dll
View Source
public class ASCIIProtocol : Protocol, IIOProtocol, IProtocol
Inheritance: System.Object -> Brainboxes.IO.Protocol
Implements:
Brainboxes.IO.IIOProtocol, Brainboxes.IO.IProtocol
Properties
Address
default ASCII DCON device address can be set in constructor to specific value
View Source
public int Address { get; }
BaudRate
The baud rate of the device
View Source
public int BaudRate { get; }
DataFormat
The data format of the analog device Defaults to Engineering format
View Source
public AnalogDataFormat DataFormat { get; }
TemperatureUnit
The unit of temperature of the analog device
View Source
public TemperatureUnit TemperatureUnit { get; }
IOCounterMode
The counter mode of the digital device, whether it is a 16-bit or 32-bit counter
View Source
public CounterMode IOCounterMode { get; }
DeviceName
The name of the ED Device
View Source
public string DeviceName { get; set; }
Fields
deviceType
The device type string cached from a device name query.
View Source
protected string deviceType
_address
The ASCII address of the device
View Source
protected int _address
_baudRate
The baud rate of the device
View Source
protected int _baudRate
_checksum
The checksum setting of the device
View Source
protected bool _checksum
_analogFilterSetting
The filter setting of the analog device
View Source
protected bool _analogFilterSetting
_analogModuleSetting
The module setting of the analog device
View Source
protected bool _analogModuleSetting
_analogDataFormat
The ASCII data format of the analog device.
View Source
protected AnalogDataFormat _analogDataFormat
_temperatureUnit
The temperature unit of analog temperature measurement device (ED-582, ED-593)
Defaults to Celsius format
View Source
protected TemperatureUnit _temperatureUnit
_ioCounterMode
The counter mode setting of the digital device
View Source
protected CounterMode _ioCounterMode
_ioCounterUpdateDirection
The counter update direction of the digital device
View Source
protected IOChangeTypes _ioCounterUpdateDirection
_commsEncoding
ASCII character encoding is used to send and receive data to/from the EDDevice Windows-28591 = ISO-8859-1 = ASCII
View Source
protected readonly Encoding _commsEncoding
_newLine
New line character used by the ASCII protocol to signal end of message
View Source
protected readonly string _newLine
_newLineCode
New line character code 13
View Source
protected readonly int _newLineCode
_commandsWithoutResponse
commands which have no response #** Synchronized Sampling Command ~** Host is OK Command $AARS Restart the device to power on setting SendCommand returns null for these commands
View Source
protected readonly Regex[] _commandsWithoutResponse
Methods
SetAnalogDataFormat(AnalogDataFormat)
Sets the data format setting of the device. For more info see http://www.brainboxes.com/files/pages/support/faqs/docs/AsciiCommands/%25aannttccffanalog.pdf
View Source
public void SetAnalogDataFormat(AnalogDataFormat dataFormat)
Parameters
| Type | Name |
|---|---|
| Brainboxes.IO.AnalogDataFormat | dataFormat |
SetTemperatureUnit(TemperatureUnit)
Sets the temperature unit setting of the device. For more info see http://www.brainboxes.com/files/pages/support/faqs/docs/AsciiCommands/%25aannttccffanalog.pdf
View Source
public void SetTemperatureUnit(TemperatureUnit temperatureUnit)
Parameters
| Type | Name |
|---|---|
| Brainboxes.IO.TemperatureUnit | temperatureUnit |
SendCommand(string)
Send a command to a Brainboxes Device and optionally receive a response back from the device
View Source
public string SendCommand(string command)
Returns
System.String: response from device, null if there is no response
Parameters
| Type | Name | Description |
|---|---|---|
System.String | command | command to send to device |
SetOutputLineState(int, int)
Set an individual digital output line state open (0) or closed (1)s
View Source
[Obsolete("SetOutputLineState is deprecated. Replaced by SetDigitalOutputLineState")]
public void SetOutputLineState(int line, int state)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
System.Int32 | state |
SetDigitalOutputLineState(int, int)
Set an individual digital output line state open (0) or closed (1)s
View Source
public void SetDigitalOutputLineState(int line, int state)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
System.Int32 | state |
SetAnalogOutputLineState(int, double)
Set an individual analogue output line value
View Source
public void SetAnalogOutputLineState(int line, double value)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
System.Double | value |
SetAnalogOutputLineState(int, string)
Set an individual analogue output line to a Hexadecimal value
View Source
public void SetAnalogOutputLineState(int line, string hexValue)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
System.String | hexValue |
SetAllOutputLineStates(int, int)
set all output lines on the device open (0) or closed (1) The bit position represents the line number
View Source
[Obsolete("SetAllOutputLineStates is deprecated. Replaced by SetAllDigitalOutputLineStates")]
public void SetAllOutputLineStates(int states, int numberOfOutputs = 8)
Parameters
| Type | Name |
|---|---|
System.Int32 | states |
System.Int32 | numberOfOutputs |
SetAllDigitalOutputLineStates(int, int)
set all output lines on the device open (0) or closed (1) The bit position represents the line number
View Source
public void SetAllDigitalOutputLineStates(int states, int numberOfOutputs = 8)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | states | |
System.Int32 | numberOfOutputs | The number of outputs on the device |
GetLineState(int, bool)
Get the state of a digital IO line
View Source
[Obsolete("GetLineState is deprecated. Replaced by GetDigitalLineState")]
public int GetLineState(int line, bool isInput = true)
Returns
System.Int32
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
System.Boolean | isInput |
GetDigitalLineState(int, bool)
Get the state of a digital IO Line
View Source
public int GetDigitalLineState(int line, bool isInput = true)
Returns
System.Int32: 1: Line closed/High/On, 0: Line Open/Low/Off
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | line | |
System.Boolean | isInput | ignored by ASCII protocol |
GetAnalogLineState(int, int, bool)
Get the state of an Analog IO Line. If the analog line is disabled it will return +00.000
View Source
public double GetAnalogLineState(int line, int numberOfLines = 8, bool isInput = true)
Returns
System.Double
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | line | |
System.Int32 | numberOfLines | |
System.Boolean | isInput | Whether the analog IO Line is an input |
GetAllLineStates()
Get the state of all the digital IOLines of the device as an integer
View Source
[Obsolete("GetAllLineStates is deprecated. Replaced by GetAllDigitalLineStates")]
public int GetAllLineStates()
Returns
System.Int32: Each bit in the integer represents a digital IOLine state
GetAllDigitalLineStates()
Get the state of all the digital IOLines of the device as an integer
View Source
public int GetAllDigitalLineStates()
Returns
System.Int32: Each bit in the integer represents a digital IOLine state
GetAllAnalogInputLineStates(int)
Gets the state of all the Analog Input lines of the device as double[lineNumber]
View Source
public double[] GetAllAnalogInputLineStates(int numberOfInputs = 8)
Returns
System.Double[]
Parameters
| Type | Name |
|---|---|
System.Int32 | numberOfInputs |
GetAllAnalogOutputLineStates(int)
Gets the state of all the Analog Output lines of the device as double[lineNumber]
View Source
public double[] GetAllAnalogOutputLineStates(int numberOfOutputs = 4)
Returns
System.Double[]
Parameters
| Type | Name |
|---|---|
System.Int32 | numberOfOutputs |
CommandDoesNotHaveResponse(string)
Test whether the command does not have an ASCII response from the ED Device
View Source
public bool CommandDoesNotHaveResponse(string command)
Returns
System.Boolean: true if not response
Parameters
| Type | Name |
|---|---|
System.String | command |
_sendCommand(string, BBStream)
Any command sent to the ED Device is sent by this function
View Source
protected string _sendCommand(string command, BBStream s)
Returns
System.String: response from the ED device
Parameters
| Type | Name | Description |
|---|---|---|
System.String | command | The ASCII command |
| Brainboxes.IO.BBStream | s | The stream to send the command on (captured locally to avoid race conditions) |
GetDeviceName()
Get the name of the Device
View Source
public string GetDeviceName()
Returns
System.String
ResetToFactoryDefaultSettings()
Reset the ED device to factory default settings
View Source
public void ResetToFactoryDefaultSettings()
Restart()
Power Off and the On the ED Device
View Source
public void Restart()
GetAllLatchedHighInputStates()
Get the HIGH LATCH states of all the digital inputs
View Source
[Obsolete("GetAllLatchedHighInputStates is deprecated. Replaced by GetAllLatchedHighDigitalInputStates")]
public int GetAllLatchedHighInputStates()
Returns
System.Int32
GetAllLatchedHighDigitalInputStates()
Get the HIGH LATCH states of all the digital Inputs
View Source
public int GetAllLatchedHighDigitalInputStates()
Returns
System.Int32
GetAllLatchedLowInputStates()
Get the LOW LATCH state of all the digital INPUTS
View Source
[Obsolete("GetAllLatchedLowInputStates is deprecated. Replaced by GetAllLatchedLowDigitalInputStates")]
public int GetAllLatchedLowInputStates()
Returns
System.Int32
GetAllLatchedLowDigitalInputStates()
Get the LOW LATCH state of all the digital INPUTS
View Source
public int GetAllLatchedLowDigitalInputStates()
Returns
System.Int32
GetAllLatchedInputStates(bool)
Get the LATCH state of the INPUTS
View Source
protected int GetAllLatchedInputStates(bool isHigh = true)
Returns
System.Int32
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | isHigh | Whether to get the HIGH or LOW LATCH |
ClearAllLatchedInputs()
Clear the digital INPUT latches
View Source
[Obsolete("ClearAllLatchedInputs is deprecated. Replaced by ClearAllLatchedDigitalInputs")]
public void ClearAllLatchedInputs()
ClearAllLatchedDigitalInputs()
Clear the INPUT latches
View Source
public void ClearAllLatchedDigitalInputs()
GetLineCount(int)
Reads the digital input counter of the specified channel
View Source
[Obsolete("GetLineCount is deprecated. Replaced by GetDigitalInputLineCount")]
public int GetLineCount(int line)
Returns
System.Int32
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
GetDigitalInputLineCount(int)
Reads the digital input counter of the specified channel
View Source
public int GetDigitalInputLineCount(int line)
Returns
System.Int32
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
ClearLineCount(int)
Clears the digital input counter of the specified line.
View Source
[Obsolete("ClearLineCount is deprecated. Replaced by ClearDigitalInputLineCount")]
public void ClearLineCount(int line)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
ClearDigitalInputLineCount(int)
Clears the digital input counter of the specified line.
View Source
public void ClearDigitalInputLineCount(int line)
Parameters
| Type | Name |
|---|---|
System.Int32 | line |
GetDeviceConfiguration()
Read the device configuration
View Source
public void GetDeviceConfiguration()
SetDeviceConfiguration(int, int, IOChangeTypes, CounterMode, bool)
Sets configuration parameters for a digital IO device.
View Source
public void SetDeviceConfiguration(int newAddress, int newBaudRate, IOChangeTypes newIOCounterUpdateDirection, CounterMode newCounterMode, bool newChecksum = false)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | newAddress | The new ASCII/Modbus address for the device (0-255). |
System.Int32 | newBaudRate | The new baud rate (e.g. 9600, 115200). |
| Brainboxes.IO.IOChangeTypes | newIOCounterUpdateDirection | |
| Brainboxes.IO.CounterMode | newCounterMode | |
System.Boolean | newChecksum |
Exceptions
System.NotImplementedException
Thrown by Brainboxes.IO.ModbusTCPProtocol — device configuration is only supported via the ASCII protocol.
SetDeviceConfiguration(int, int, AnalogDataFormat, bool, bool, bool, TemperatureUnit)
Sets configuration parameters for an analog IO device.
View Source
public void SetDeviceConfiguration(int newAddress, int newBaudRate, AnalogDataFormat newAnalogDataFormat, bool newFilterSettings = false, bool newModuleSettings = false, bool newChecksum = false, TemperatureUnit newTemperatureUnit = TemperatureUnit.Celsius)
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | newAddress | The new ASCII/Modbus address for the device (0-255). |
System.Int32 | newBaudRate | The new baud rate (e.g. 9600, 115200). |
| Brainboxes.IO.AnalogDataFormat | newAnalogDataFormat | The analog data format: Brainboxes.IO.AnalogDataFormat.Engineering, Brainboxes.IO.AnalogDataFormat.FullScaleRange, or Brainboxes.IO.AnalogDataFormat.Hexadecimal. |
System.Boolean | newFilterSettings | Whether to enable input filtering. |
System.Boolean | newModuleSettings | Whether to enable module-specific settings. |
System.Boolean | newChecksum | Whether to enable checksum validation on commands. |
| Brainboxes.IO.TemperatureUnit | newTemperatureUnit |
Exceptions
System.NotImplementedException
Thrown by Brainboxes.IO.ModbusTCPProtocol — device configuration is only supported via the ASCII protocol.