Skip to main content

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
Declaration
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
Declaration
public int Address { get; }

BaudRate

The baud rate of the device

View Source
Declaration
public int BaudRate { get; }

DataFormat

The data format of the analog device Defaults to Engineering format

View Source
Declaration
public AnalogDataFormat DataFormat { get; }

TemperatureUnit

The unit of temperature of the analog device

View Source
Declaration
public TemperatureUnit TemperatureUnit { get; }

IOCounterMode

The counter mode of the digital device, whether it is a 16-bit or 32-bit counter

View Source
Declaration
public CounterMode IOCounterMode { get; }

DeviceName

The name of the ED Device

View Source
Declaration
public string DeviceName { get; set; }

Fields

deviceType

The device type string cached from a device name query.

View Source
Declaration
protected string deviceType

_address

The ASCII address of the device

View Source
Declaration
protected int _address

_baudRate

The baud rate of the device

View Source
Declaration
protected int _baudRate

_checksum

The checksum setting of the device

View Source
Declaration
protected bool _checksum

_analogFilterSetting

The filter setting of the analog device

View Source
Declaration
protected bool _analogFilterSetting

_analogModuleSetting

The module setting of the analog device

View Source
Declaration
protected bool _analogModuleSetting

_analogDataFormat

The ASCII data format of the analog device.

View Source
Declaration
protected AnalogDataFormat _analogDataFormat

_temperatureUnit

The temperature unit of analog temperature measurement device (ED-582, ED-593)
Defaults to Celsius format

View Source
Declaration
protected TemperatureUnit _temperatureUnit

_ioCounterMode

The counter mode setting of the digital device

View Source
Declaration
protected CounterMode _ioCounterMode

_ioCounterUpdateDirection

The counter update direction of the digital device

View Source
Declaration
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
Declaration
protected readonly Encoding _commsEncoding

_newLine

New line character used by the ASCII protocol to signal end of message

View Source
Declaration
protected readonly string _newLine

_newLineCode

New line character code 13

View Source
Declaration
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
Declaration
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
Declaration
public void SetAnalogDataFormat(AnalogDataFormat dataFormat)
Parameters
TypeName
Brainboxes.IO.AnalogDataFormatdataFormat

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
Declaration
public void SetTemperatureUnit(TemperatureUnit temperatureUnit)
Parameters
TypeName
Brainboxes.IO.TemperatureUnittemperatureUnit

SendCommand(string)

Send a command to a Brainboxes Device and optionally receive a response back from the device

View Source
Declaration
public string SendCommand(string command)
Returns

System.String: response from device, null if there is no response

Parameters
TypeNameDescription
System.Stringcommandcommand to send to device

SetOutputLineState(int, int)

Set an individual digital output line state open (0) or closed (1)s

View Source
Declaration
[Obsolete("SetOutputLineState is deprecated. Replaced by SetDigitalOutputLineState")]
public void SetOutputLineState(int line, int state)
Parameters
TypeName
System.Int32line
System.Int32state

SetDigitalOutputLineState(int, int)

Set an individual digital output line state open (0) or closed (1)s

View Source
Declaration
public void SetDigitalOutputLineState(int line, int state)
Parameters
TypeName
System.Int32line
System.Int32state

SetAnalogOutputLineState(int, double)

Set an individual analogue output line value

View Source
Declaration
public void SetAnalogOutputLineState(int line, double value)
Parameters
TypeName
System.Int32line
System.Doublevalue

SetAnalogOutputLineState(int, string)

Set an individual analogue output line to a Hexadecimal value

View Source
Declaration
public void SetAnalogOutputLineState(int line, string hexValue)
Parameters
TypeName
System.Int32line
System.StringhexValue

SetAllOutputLineStates(int, int)

set all output lines on the device open (0) or closed (1) The bit position represents the line number

View Source
Declaration
[Obsolete("SetAllOutputLineStates is deprecated. Replaced by SetAllDigitalOutputLineStates")]
public void SetAllOutputLineStates(int states, int numberOfOutputs = 8)
Parameters
TypeName
System.Int32states
System.Int32numberOfOutputs

SetAllDigitalOutputLineStates(int, int)

set all output lines on the device open (0) or closed (1) The bit position represents the line number

View Source
Declaration
public void SetAllDigitalOutputLineStates(int states, int numberOfOutputs = 8)
Parameters
TypeNameDescription
System.Int32states
System.Int32numberOfOutputsThe number of outputs on the device

GetLineState(int, bool)

Get the state of a digital IO line

View Source
Declaration
[Obsolete("GetLineState is deprecated. Replaced by GetDigitalLineState")]
public int GetLineState(int line, bool isInput = true)
Returns

System.Int32

Parameters
TypeName
System.Int32line
System.BooleanisInput

GetDigitalLineState(int, bool)

Get the state of a digital IO Line

View Source
Declaration
public int GetDigitalLineState(int line, bool isInput = true)
Returns

System.Int32: 1: Line closed/High/On, 0: Line Open/Low/Off

Parameters
TypeNameDescription
System.Int32line
System.BooleanisInputignored 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
Declaration
public double GetAnalogLineState(int line, int numberOfLines = 8, bool isInput = true)
Returns

System.Double

Parameters
TypeNameDescription
System.Int32line
System.Int32numberOfLines
System.BooleanisInputWhether the analog IO Line is an input

GetAllLineStates()

Get the state of all the digital IOLines of the device as an integer

View Source
Declaration
[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
Declaration
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
Declaration
public double[] GetAllAnalogInputLineStates(int numberOfInputs = 8)
Returns

System.Double[]

Parameters
TypeName
System.Int32numberOfInputs

GetAllAnalogOutputLineStates(int)

Gets the state of all the Analog Output lines of the device as double[lineNumber]

View Source
Declaration
public double[] GetAllAnalogOutputLineStates(int numberOfOutputs = 4)
Returns

System.Double[]

Parameters
TypeName
System.Int32numberOfOutputs

CommandDoesNotHaveResponse(string)

Test whether the command does not have an ASCII response from the ED Device

View Source
Declaration
public bool CommandDoesNotHaveResponse(string command)
Returns

System.Boolean: true if not response

Parameters
TypeName
System.Stringcommand

_sendCommand(string, BBStream)

Any command sent to the ED Device is sent by this function

View Source
Declaration
protected string _sendCommand(string command, BBStream s)
Returns

System.String: response from the ED device

Parameters
TypeNameDescription
System.StringcommandThe ASCII command
Brainboxes.IO.BBStreamsThe stream to send the command on (captured locally to avoid race conditions)

GetDeviceName()

Get the name of the Device

View Source
Declaration
public string GetDeviceName()
Returns

System.String

ResetToFactoryDefaultSettings()

Reset the ED device to factory default settings

View Source
Declaration
public void ResetToFactoryDefaultSettings()

Restart()

Power Off and the On the ED Device

View Source
Declaration
public void Restart()

GetAllLatchedHighInputStates()

Get the HIGH LATCH states of all the digital inputs

View Source
Declaration
[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
Declaration
public int GetAllLatchedHighDigitalInputStates()
Returns

System.Int32

GetAllLatchedLowInputStates()

Get the LOW LATCH state of all the digital INPUTS

View Source
Declaration
[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
Declaration
public int GetAllLatchedLowDigitalInputStates()
Returns

System.Int32

GetAllLatchedInputStates(bool)

Get the LATCH state of the INPUTS

View Source
Declaration
protected int GetAllLatchedInputStates(bool isHigh = true)
Returns

System.Int32

Parameters
TypeNameDescription
System.BooleanisHighWhether to get the HIGH or LOW LATCH

ClearAllLatchedInputs()

Clear the digital INPUT latches

View Source
Declaration
[Obsolete("ClearAllLatchedInputs is deprecated. Replaced by ClearAllLatchedDigitalInputs")]
public void ClearAllLatchedInputs()

ClearAllLatchedDigitalInputs()

Clear the INPUT latches

View Source
Declaration
public void ClearAllLatchedDigitalInputs()

GetLineCount(int)

Reads the digital input counter of the specified channel

View Source
Declaration
[Obsolete("GetLineCount is deprecated. Replaced by GetDigitalInputLineCount")]
public int GetLineCount(int line)
Returns

System.Int32

Parameters
TypeName
System.Int32line

GetDigitalInputLineCount(int)

Reads the digital input counter of the specified channel

View Source
Declaration
public int GetDigitalInputLineCount(int line)
Returns

System.Int32

Parameters
TypeName
System.Int32line

ClearLineCount(int)

Clears the digital input counter of the specified line.

View Source
Declaration
[Obsolete("ClearLineCount is deprecated. Replaced by ClearDigitalInputLineCount")]
public void ClearLineCount(int line)
Parameters
TypeName
System.Int32line

ClearDigitalInputLineCount(int)

Clears the digital input counter of the specified line.

View Source
Declaration
public void ClearDigitalInputLineCount(int line)
Parameters
TypeName
System.Int32line

GetDeviceConfiguration()

Read the device configuration

View Source
Declaration
public void GetDeviceConfiguration()

SetDeviceConfiguration(int, int, IOChangeTypes, CounterMode, bool)

Sets configuration parameters for a digital IO device.

View Source
Declaration
public void SetDeviceConfiguration(int newAddress, int newBaudRate, IOChangeTypes newIOCounterUpdateDirection, CounterMode newCounterMode, bool newChecksum = false)
Parameters
TypeNameDescription
System.Int32newAddressThe new ASCII/Modbus address for the device (0-255).
System.Int32newBaudRateThe new baud rate (e.g. 9600, 115200).
Brainboxes.IO.IOChangeTypesnewIOCounterUpdateDirection
Brainboxes.IO.CounterModenewCounterMode
System.BooleannewChecksum
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
Declaration
public void SetDeviceConfiguration(int newAddress, int newBaudRate, AnalogDataFormat newAnalogDataFormat, bool newFilterSettings = false, bool newModuleSettings = false, bool newChecksum = false, TemperatureUnit newTemperatureUnit = TemperatureUnit.Celsius)
Parameters
TypeNameDescription
System.Int32newAddressThe new ASCII/Modbus address for the device (0-255).
System.Int32newBaudRateThe new baud rate (e.g. 9600, 115200).
Brainboxes.IO.AnalogDataFormatnewAnalogDataFormatThe analog data format: Brainboxes.IO.AnalogDataFormat.Engineering, Brainboxes.IO.AnalogDataFormat.FullScaleRange, or Brainboxes.IO.AnalogDataFormat.Hexadecimal.
System.BooleannewFilterSettingsWhether to enable input filtering.
System.BooleannewModuleSettingsWhether to enable module-specific settings.
System.BooleannewChecksumWhether to enable checksum validation on commands.
Brainboxes.IO.TemperatureUnitnewTemperatureUnit
Exceptions

System.NotImplementedException
Thrown by Brainboxes.IO.ModbusTCPProtocol — device configuration is only supported via the ASCII protocol.

Implements