Class CanChannelModule
Represents a module for a Vector CAN channel with VXL API. Warning: You cannot use the interfaces ICanCommunication and ICanCommunication2 at the same time on one instance.
public class CanChannelModule : LisrtModule, ILisrtModule, IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged, ICanCommunication2, IHasServiceView
- Inheritance
-
PropertyChangedBaseCanChannelModule
- Implements
-
INotifyPropertyChangedEx
- Inherited Members
-
PropertyChangedBase.Refresh()PropertyChangedBase.IsNotifyingPropertyChangedBase.PropertyChanged
Constructors
CanChannelModule(string)
Initializes a new instance of the CanChannelModule class.
public CanChannelModule(string name)
Parameters
name
stringCAN channel name.
Properties
BaudRate
Gets or sets the baud rate.
[Configuration(0, Unit = "Baud", Description = "15k to 1M Baud")]
public uint BaudRate { get; set; }
Property Value
ChannelIndex
Gets or sets the device depending channel index.
[Configuration(0)]
public byte ChannelIndex { get; set; }
Property Value
ChannelName
Gets the channel name. Available after Initialize() or SetChannel(ChannelInfo). To get the unique channel identification use DeviceSerial and ChannelIndex.
public string ChannelName { get; }
Property Value
DataReceivedAutoResetEvent
Gets the auto reset event for received data.
protected AutoResetEvent DataReceivedAutoResetEvent { get; }
Property Value
DataTransmittedAutoResetEvent
Gets the auto reset event for successfully transmitted data.
protected AutoResetEvent DataTransmittedAutoResetEvent { get; }
Property Value
DeviceSerial
Gets or sets the device serial.
[Configuration(0)]
public uint DeviceSerial { get; set; }
Property Value
Icon
Gets a icon which is representative for the module.
public override Uri Icon { get; }
Property Value
InitializationState
Gets a value indicating whether the module is initialized.
public InitializationState InitializationState { get; }
Property Value
ReceiveTimeoutInMS
Gets or sets the receive timeout in milliseconds. Default is 200ms.
public int ReceiveTimeoutInMS { get; set; }
Property Value
ReceivedBuffer
Gets the latest received data. Cleared on ClearBuffer(), Receive(), Send(CanData) and Query(CanData).
protected IList<CanData> ReceivedBuffer { get; }
Property Value
Methods
ClearBuffer()
Clears the received data buffer.
protected void ClearBuffer()
Exit()
De initializes the module.
public void Exit()
GetPossibleCanChannels()
Gets all possible CAN channels.
public IEnumerable<ChannelInfo> GetPossibleCanChannels()
Returns
- IEnumerable<ChannelInfo>
All CAN channels.
Initialize()
Initializes the module.
public void Initialize()
Exceptions
- InvalidOperationException
Thrown when channel is not found.
- ArgumentException
Thrown when BaudRate is not between 15k to 1M baud.
Query(CanData)
Sends and receives data.
public IEnumerable<CanData> Query(CanData data)
Parameters
data
CanDataData to send.
Returns
- IEnumerable<CanData>
Received data.
Exceptions
- InvalidOperationException
Thrown when DataReceived has any event handler.
- TimeoutException
Thrown when no data received in the expected time range.
- ArgumentNullException
Thrown when
data
is null.- InvalidOperationException
Thrown when InitializationState is not Initialized.
- TimeoutException
Thrown when no bus device acknowledged the transmission in the expected time range or not data is received in the expected time range.
Receive()
Receives the data from the buffer. The buffer is cleared on ClearBuffer(), Receive(), Send(CanData) and Query(CanData).
public IEnumerable<CanData> Receive()
Returns
- IEnumerable<CanData>
Received data.
Exceptions
- InvalidOperationException
Thrown when InitializationState is not Initialized.
- InvalidOperationException
Thrown when DataReceived has any event handler.
Send(CanData)
Sends CanData to a device.
public void Send(CanData data)
Parameters
data
CanDataData to send.
Exceptions
- ArgumentNullException
Thrown when
data
is null.- InvalidOperationException
Thrown when InitializationState is not Initialized.
- TimeoutException
Thrown when no bus device acknowledged the transmission in the expected time range.
SetChannel(ChannelInfo)
Sets the channel with the channelInfo
.
public void SetChannel(ChannelInfo channelInfo)
Parameters
channelInfo
ChannelInfoChannel info to set.
Exceptions
- InvalidOperationException
Thrown when InitializationState is Initialized.
ShowServiceView()
Shows the service window.
public void ShowServiceView()
Events
DataReceived
Occurs when data are received.
public event EventHandler DataReceived