Skip to main content

Class Device<Conn, Proto>

Class Device<Conn, Proto>​

A generic Brainboxes Device

Assembly: Brainboxes.IO.dll​
View Source​
Declaration
public abstract class Device<Conn, Proto> : IDevice<Conn, Proto>, IDisposable where Conn : IConnection where Proto : IProtocol

Derived:
Brainboxes.IO.BBSerialPort, Brainboxes.IO.EDDevice, Brainboxes.IO.ESDevice

Implements:
Brainboxes.IO.IDevice<<Conn>,<Proto>>, System.IDisposable

Properties​

Label​

User definable label for the Device to help identify when many devices / when debugging

View Source​
Declaration
public string Label { get; set; }

IsConnected​

Whether this Brainboxes Device instance has an active connection

View Source​
Declaration
public virtual bool IsConnected { get; }

IsAvailable​

Whether the connection to this Brainboxes Device is available, e.g. online or offline​. In case of network TCP connection: this is if the device is pingable on the network. In case of serial connection: this is if the device COM port is listed on the system and not open by another process.

View Source​
Declaration
public virtual bool IsAvailable { get; }

Connection​

The connection. If the connection is replaced and the previous connection was connected, the new connection will be connected too

View Source​
Declaration
public virtual Conn Connection { get; set; }

Protocol​

Marking as virtual allows it to be overridden in the child class

View Source​
Declaration
public virtual Proto Protocol { get; set; }

Fields​

_connection​

The connection

View Source​
Declaration
protected Conn _connection

_protocol​

The protocol

View Source​
Declaration
protected Proto _protocol

Methods​

Create(string)​

Connects to the IP Address given and determines what kind of Brainboxes Device is there, creates the object and returns it

View Source​
Declaration
public static Device<Conn, Proto> Create(string ipAddress)
Returns​

Brainboxes.IO.Device<Conn, Proto>

Parameters​
TypeName
System.StringipAddress

_connection_ConnectionStatusChangedEvent(IConnection, string, bool)​

when the status of a connection changes this event is called which then fires a device status change event

View Source​
Declaration
protected void _connection_ConnectionStatusChangedEvent(IConnection connection, string property, bool newValue)
Parameters​
TypeName
Brainboxes.IO.IConnectionconnection
System.Stringproperty
System.BooleannewValue

Connect()​

Connect the Brainboxes Device

View Source​
Declaration
public virtual void Connect()

Disconnect()​

Disconnect the Brainboxes Device

View Source​
Declaration
public virtual void Disconnect()

ToString()​

Describe this Brainboxes Device

View Source​
Declaration
public override string ToString()
Returns​

System.String

Describe()​

Give a complete summary of the Device

View Source​
Declaration
public virtual string Describe()
Returns​

System.String

Dispose()​

Dispose of this Brainboxes device

View Source​
Declaration
public void Dispose()

Dispose(bool)​

Dispose of this Brainboxes device

View Source​
Declaration
protected virtual void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
Parameters​
TypeName
System.BooleanitIsSafeToAlsoFreeManagedObjects

Events​

_deviceStatusChangedEvent​

The event which describes when a device status change occurs

View Source​
Declaration
protected event DeviceStatusChangedEventHandler<Conn, Proto> _deviceStatusChangedEvent
Event Type​

Brainboxes.IO.DeviceStatusChangedEventHandler<<Conn>,<Proto>>

DeviceStatusChangedEvent​

Event When the status of the devices connection changes for example goes from Disconnected to Connected or from Available to Unavailable

View Source​
Declaration
public event DeviceStatusChangedEventHandler<Conn, Proto> DeviceStatusChangedEvent
Event Type​

Brainboxes.IO.DeviceStatusChangedEventHandler<<Conn>,<Proto>>

Implements​

  • Brainboxes.IO.IDevice<<Conn>,<Proto>>
  • System.IDisposable