Class BusDriver
Base class for a bus driver using a port filter.
Inherited Members
Namespace: Mechatronics.SensorSDK
Syntax
public class BusDriver : IPortFilter<byte[]>
Constructors
BusDriver(PortType<Byte[]>)
Initialize the bus driver.
Declaration
public BusDriver(PortType<byte[]> port)
Parameters
Type | Name | Description |
---|---|---|
PortType<Byte[]> | port | Port that the driver is on. |
Fields
_address
Declaration
protected byte _address
Field Value
Type | Description |
---|---|
Byte |
_callback
Declaration
protected BusDriver.MessageHandler _callback
Field Value
Type | Description |
---|---|
BusDriver.MessageHandler |
_port
Declaration
protected PortType<byte[]> _port
Field Value
Type | Description |
---|---|
PortType<Byte[]> |
Methods
Join(Byte, BusDriver.MessageHandler)
Start listening to messages.
Declaration
public virtual bool Join(byte address, BusDriver.MessageHandler handler)
Parameters
Type | Name | Description |
---|---|---|
Byte | address | Address to listen at. |
BusDriver.MessageHandler | handler | Handler to callback with messages |
Returns
Type | Description |
---|---|
Boolean |
Leave(BusDriver.MessageHandler)
Leave the bus and clean up the handler.
Declaration
public virtual void Leave(BusDriver.MessageHandler callback)
Parameters
Type | Name | Description |
---|---|---|
BusDriver.MessageHandler | callback | Registered handler to cleanup. |
Process(IPortType, Byte[], IPortFilter<Byte[]>)
Called by the port on new data to process.
Declaration
public override byte[] Process(IPortType port, byte[] Data, IPortFilter<byte[]> previousFilter)
Parameters
Type | Name | Description |
---|---|---|
IPortType | port | Calling port |
Byte[] | Data | New data received on the port. |
IPortFilter<Byte[]> | previousFilter | Previous portfilter if it exists, that output the Data. |
Returns
Type | Description |
---|---|
Byte[] | Proccessed data. |
Overrides
Mechatronics.SystemGraph.IPortFilter<System.Byte[]>.Process(Mechatronics.SystemGraph.IPortType, System.Byte[], Mechatronics.SystemGraph.IPortFilter<System.Byte[]>)
Send(Byte, Byte[])
Send data on the bus.
Declaration
public virtual bool Send(byte toAddress, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
Byte | toAddress | Address to send to. |
Byte[] | data | Data to send. |
Returns
Type | Description |
---|---|
Boolean | True on success. |