Class Device<Conn, Proto>
A generic Brainboxes Device
Assembly: Brainboxes.IO.dll
View Source
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
public string Label { get; set; }
IsConnected
Whether this Brainboxes Device instance has an active connection
View Source
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
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
public virtual Conn Connection { get; set; }
Protocol
Marking as virtual allows it to be overridden in the child class
View Source
public virtual Proto Protocol { get; set; }
Fields
_connection
The connection
View Source
protected Conn _connection
_protocol
The protocol
View Source
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
public static Device<Conn, Proto> Create(string ipAddress)
Returns
Brainboxes.IO.Device<Conn, Proto>
Parameters
| Type | Name |
|---|---|
System.String | ipAddress |
_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
protected void _connection_ConnectionStatusChangedEvent(IConnection connection, string property, bool newValue)
Parameters
| Type | Name |
|---|---|
| Brainboxes.IO.IConnection | connection |
System.String | property |
System.Boolean | newValue |
Connect()
Connect the Brainboxes Device
View Source
public virtual void Connect()
Disconnect()
Disconnect the Brainboxes Device
View Source
public virtual void Disconnect()
ToString()
Describe this Brainboxes Device
View Source
public override string ToString()
Returns
System.String
Describe()
Give a complete summary of the Device
View Source
public virtual string Describe()
Returns
System.String
Dispose()
Dispose of this Brainboxes device
View Source
public void Dispose()
Dispose(bool)
Dispose of this Brainboxes device
View Source
protected virtual void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
Parameters
| Type | Name |
|---|---|
System.Boolean | itIsSafeToAlsoFreeManagedObjects |
Events
_deviceStatusChangedEvent
The event which describes when a device status change occurs
View Source
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
public event DeviceStatusChangedEventHandler<Conn, Proto> DeviceStatusChangedEvent
Event Type
Brainboxes.IO.DeviceStatusChangedEventHandler<<Conn>,<Proto>>
Implements
Brainboxes.IO.IDevice<<Conn>,<Proto>>System.IDisposable