.Net Windows DECL Reference
 
Loading...
Searching...
No Matches
MWSDK.NetCore.MedWandControllerBase Class Referenceabstract

Serves as the base class for managing and interacting with MedWand devices. More...

Inherits IDisposable.

Inherited by MWSDK.Wpf.MedWandController.

Public Member Functions

void Construct (string licenseString, string publicKey)
 Initializes the MedWand controller with the provided license information and public key.
 
void Connect ()
 Establishes a connection to the MedWand device.
 
void Initialize ()
 Initializes the MedWand device, setting it to the DeviceState.Initialized state if successful.
 
bool IsBootloaderMode (bool forceCheck=false)
 Determines whether the device is currently in bootloader mode.
 

Public Attributes

string DeviceName = "MedWand"
 Represents the name of the MedWand device.
 

Properties

bool IsLicenseValid [get]
 Gets a value indicating whether the license associated with the MedWand device is valid.
 
DeviceState DeviceState [get]
 Gets the current state of the MedWand device.
 
ReadingState ReadingState [get]
 Gets the current state of the reading process for the MedWand device.
 
bool IsConnected [get]
 Gets a value indicating whether the MedWand device is currently connected.
 
bool IsInitialized [get]
 Gets a value indicating whether the MedWand device has been successfully initialized.
 
string LicenseInfo [get]
 Gets the license information associated with the current instance of the MedWand controller.
 
bool CanUseStethoscope [get]
 Gets a value indicating whether the stethoscope feature can be used with the current license.
 
bool CanUseCamera [get]
 Gets a value indicating whether the camera feature can be used based on the current license.
 
bool CanUseEcg [get]
 Gets a value indicating whether the ECG (Electrocardiogram) feature can be used.
 
string? ComPort [get]
 Gets the name of the COM port associated with the MedWand device.
 
string? VendorId [get]
 Gets the Vendor ID of the connected MedWand device.
 
string? ProductId [get]
 Gets the product identifier of the connected MedWand device.
 
Version? FirmwareVersion [get]
 Gets the firmware version of the connected MedWand device.
 
string DeviceId [get]
 Gets the unique identifier of the connected MedWand device.
 
MedWandGeneration Generation [get]
 Gets the generation of the MedWand device.
 
string Udi [get]
 Gets the Unique Device Identifier (UDI) of the connected MedWand device.
 
MedWandReading LastReading [get]
 Gets the most recent reading data from the MedWand sensor.
 
MedWandSensor ActiveSensor [get]
 Gets the currently active sensor on the MedWand device.
 
int LedIntensity [get]
 Gets the current intensity level of the LED.
 

Events

Action< LicenseState >? LicenseError
 Occurs when there is an issue with the license state of the MedWand device.
 
Action< DeviceState >? DeviceStateChanged
 Occurs when the state of the MedWand device changes.
 
Action< MedWandDeviceError >? DeviceError
 Occurs when an error related to the MedWand device is encountered.
 
Action< ReadingState >? ReadingStateChanged
 Occurs when the reading state of the MedWand device changes.
 
Action< MedWandReading >? ReadingReceived
 Occurs when a new reading is received from the MedWand device.
 
Action< int >? LedIntensityChanged
 Occurs when the LED intensity of the MedWand device changes.
 

Detailed Description

Serves as the base class for managing and interacting with MedWand devices.

This abstract class provides core functionality for configuring, initializing, and controlling MedWand devices.
It includes support for licensing, device state management, sensor operations, and event handling.
Derived classes can extend this functionality to implement specific use cases or platform-specific features.

Member Function Documentation

◆ Connect()

void MWSDK.NetCore.MedWandControllerBase.Connect ( )

Establishes a connection to the MedWand device.

This method attempts to locate and connect to the MedWand device via the serial port. It validates the license, configures the serial port, and initializes communication threads.

Exceptions
AccessViolationExceptionThrown if the license is invalid or if the serial port fails to connect.
KeyNotFoundExceptionThrown if the MedWand device cannot be found.
IOExceptionThrown if the serial port fails to open.
ExceptionThrown for any other unexpected errors during the connection process.
var medWandController = new MedWandController();
medWandController.Connect();
if (medWandController.IsConnected)
{
Console.WriteLine("MedWand connected successfully.");
}
else
{
Console.WriteLine("Failed to connect to MedWand.");
}

◆ Construct()

void MWSDK.NetCore.MedWandControllerBase.Construct ( string licenseString,
string publicKey )

Initializes the MedWand controller with the provided license information and public key.

Parameters
licenseStringThe license string required to initialize the MedWand controller. This value must not be null or empty.
publicKeyThe public key associated with the license string. This value must not be null or empty.

If the license is invalid, expired, or nearing expiration, the LicenseError event will be triggered.

Exceptions
ArgumentExceptionThrown when licenseString or publicKey is null or empty.

Example usage:

var controller = new MedWandController();
controller.Construct("your-license-string", "your-public-key");
if (!controller.IsLicenseValid)
{
throw new Exception("Invalid license.");
}

◆ Initialize()

void MWSDK.NetCore.MedWandControllerBase.Initialize ( )

Initializes the MedWand device, setting it to the DeviceState.Initialized state if successful.

Exceptions
AccessViolationExceptionThrown when the license is invalid.
ExceptionThrown when the device is not connected, fails to send the initialization command, does not respond to the initialization command, or the initialization result is unsuccessful.

This method ensures that the MedWand device is properly initialized and ready for use. It transitions the device state to DeviceState.Initializing during the process and to DeviceState.Initialized upon successful completion. If an error occurs, the device state is set to DeviceState.Error.

◆ IsBootloaderMode()

bool MWSDK.NetCore.MedWandControllerBase.IsBootloaderMode ( bool forceCheck = false)

Determines whether the device is currently in bootloader mode.

Parameters
forceCheckIf set to true, forces a fresh check of the device's bootloader mode status, bypassing any cached results. Defaults to false.
Returns
true if the device is in bootloader mode; otherwise, false.

This method communicates with the device to verify its bootloader mode status. If forceCheck is false, the method may return a cached result if the last check occurred within the past 10 minutes.

Exceptions
InvalidOperationExceptionThrown if the device fails to respond or an error occurs during the check.

Member Data Documentation

◆ DeviceName

string MWSDK.NetCore.MedWandControllerBase.DeviceName = "MedWand"

Represents the name of the MedWand device.

This field is initialized with the default value "MedWand".

Property Documentation

◆ ActiveSensor

MedWandSensor MWSDK.NetCore.MedWandControllerBase.ActiveSensor
get

Gets the currently active sensor on the MedWand device.

A MedWandSensor value representing the sensor currently in use. Defaults to MedWandSensor.None if no sensor is active.

The active sensor is managed by the internal reading state machine and is updated when a sensor is started or stopped. Ensure that no other sensor is active before starting a new one to avoid conflicts.

◆ CanUseCamera

bool MWSDK.NetCore.MedWandControllerBase.CanUseCamera
get

Gets a value indicating whether the camera feature can be used based on the current license.

true if the camera feature is available; otherwise, false.

This property checks the license to determine if the "Camera" feature is enabled.

◆ CanUseEcg

bool MWSDK.NetCore.MedWandControllerBase.CanUseEcg
get

Gets a value indicating whether the ECG (Electrocardiogram) feature can be used.

true if the ECG feature is available and licensed; otherwise, false.

This property checks the license to determine if the ECG feature is enabled.

◆ CanUseStethoscope

bool MWSDK.NetCore.MedWandControllerBase.CanUseStethoscope
get

Gets a value indicating whether the stethoscope feature can be used with the current license.

true if the stethoscope feature is available; otherwise, false.

This property checks the license to determine if the "Stethoscope" feature is enabled.

◆ ComPort

string? MWSDK.NetCore.MedWandControllerBase.ComPort
get

Gets the name of the COM port associated with the MedWand device.

A string representing the COM port name, or null if no COM port is assigned.

The COM port is used for communication with the MedWand device. Ensure that the device is properly connected and recognized by the system to retrieve a valid COM port.

◆ DeviceId

string MWSDK.NetCore.MedWandControllerBase.DeviceId
get

Gets the unique identifier of the connected MedWand device.

The DeviceId property retrieves the device's unique identifier. If the identifier is not already cached, it attempts to fetch it by transmitting the appropriate command to the device and waiting for a response.

A string representing the unique identifier of the MedWand device. Returns an empty string if the identifier cannot be retrieved.

◆ DeviceState

DeviceState MWSDK.NetCore.MedWandControllerBase.DeviceState
get

Gets the current state of the MedWand device.

The DeviceState property reflects the current operational state of the device, such as whether it is connected, disconnected, initializing, or in an error state. Changes to this property trigger the DeviceStateChanged event.

A DeviceState enumeration value representing the current state of the device.

See also
DeviceState, DeviceStateChanged

◆ FirmwareVersion

Version? MWSDK.NetCore.MedWandControllerBase.FirmwareVersion
get

Gets the firmware version of the connected MedWand device.

The firmware version is retrieved from the device during the connection process. If the firmware version cannot be determined, a default version of 0.0.0.0 is returned.

A Version object representing the firmware version of the device, or null if the device is not connected.

◆ Generation

MedWandGeneration MWSDK.NetCore.MedWandControllerBase.Generation
get

Gets the generation of the MedWand device.

The generation is determined based on the device's unique identifier or by querying the device. Possible values include MedWandGeneration.Generation1, MedWandGeneration.Generation2, MedWandGeneration.Generation25, MedWandGeneration.Unknown, and MedWandGeneration.NotReady.

A MedWandGeneration value representing the generation of the MedWand device.

◆ IsConnected

bool MWSDK.NetCore.MedWandControllerBase.IsConnected
get

Gets a value indicating whether the MedWand device is currently connected.

A device is considered connected if its state is one of the following: DeviceState.Connected, DeviceState.Initializing, or DeviceState.Initialized.

true if the device is connected; otherwise, false.

◆ IsInitialized

bool MWSDK.NetCore.MedWandControllerBase.IsInitialized
get

Gets a value indicating whether the MedWand device has been successfully initialized.

true if the device is initialized; otherwise, false.

The IsInitialized property reflects the initialization state of the MedWand device. It becomes true after the device has completed the initialization process successfully.

◆ IsLicenseValid

bool MWSDK.NetCore.MedWandControllerBase.IsLicenseValid
get

Gets a value indicating whether the license associated with the MedWand device is valid.

true if the license is valid; otherwise, false.

This property is determined by the internal license controller and reflects the current state of the license.

◆ LastReading

MedWandReading MWSDK.NetCore.MedWandControllerBase.LastReading
get

Gets the most recent reading data from the MedWand sensor.

An instance of MedWandReading containing the latest sensor data, such as timestamp, status, and various measurement values.

◆ LedIntensity

int MWSDK.NetCore.MedWandControllerBase.LedIntensity
get

Gets the current intensity level of the LED.

An integer representing the LED intensity level.

The LED intensity level is managed internally and can be adjusted using the appropriate methods. Changes to the intensity level trigger the LedIntensityChanged event.

◆ LicenseInfo

string MWSDK.NetCore.MedWandControllerBase.LicenseInfo
get

Gets the license information associated with the current instance of the MedWand controller.

This property retrieves a string representation of the license details managed by the underlying license controller.

A string containing the license information.

The following example demonstrates how to access the license information:

var licenseInfo = medWandController.LicenseInfo;
Console.WriteLine($"License Info: {licenseInfo}");

◆ ProductId

string? MWSDK.NetCore.MedWandControllerBase.ProductId
get

Gets the product identifier of the connected MedWand device.

A string representing the product identifier, or null if the product identifier is unavailable.

The product identifier is typically used to uniquely identify the connected device model.

◆ ReadingState

ReadingState MWSDK.NetCore.MedWandControllerBase.ReadingState
get

Gets the current state of the reading process for the MedWand device.

The ReadingState property reflects the operational state of the device's reading mechanism. Possible states include ReadingState.Stopped, ReadingState.Starting, ReadingState.Started, ReadingState.Reading, ReadingState.Recording, ReadingState.Stopping, and ReadingState.Error.

A ReadingState enumeration value representing the current state of the reading process.

◆ Udi

string MWSDK.NetCore.MedWandControllerBase.Udi
get

Gets the Unique Device Identifier (UDI) of the connected MedWand device.

The UDI is a globally unique identifier that provides detailed information about the device. If the UDI is not already cached, this property attempts to retrieve it from the device.

A string representing the UDI of the device, or an empty string if the UDI could not be retrieved.

◆ VendorId

string? MWSDK.NetCore.MedWandControllerBase.VendorId
get

Gets the Vendor ID of the connected MedWand device.

The Vendor ID is a unique identifier assigned to the manufacturer of the device. This property retrieves the value from the underlying serial port service.

A string representing the Vendor ID of the device, or null if unavailable.

Event Documentation

◆ DeviceError

Action<MedWandDeviceError>? MWSDK.NetCore.MedWandControllerBase.DeviceError

Occurs when an error related to the MedWand device is encountered.

This event is triggered to notify about various device-related errors, such as connection issues, serial port errors, or other device-specific problems. The event provides detailed error information through the MedWandDeviceError parameter.

Example usage:

_medWandController.DeviceError += (error) =>
{
Console.WriteLine($"Device error occurred: {error.Code} - {error.Exception.Message}");
};

◆ DeviceStateChanged

Action<DeviceState>? MWSDK.NetCore.MedWandControllerBase.DeviceStateChanged

Occurs when the state of the MedWand device changes.

This event is triggered whenever the DeviceState property transitions to a new state. It can be used to monitor the connection status, initialization progress, or other state changes of the MedWand device.

Example usage:

_medWandController.DeviceStateChanged += (state) =>
{
Console.WriteLine($"Device state changed to: {state}");
};

◆ LedIntensityChanged

Action<int>? MWSDK.NetCore.MedWandControllerBase.LedIntensityChanged

Occurs when the LED intensity of the MedWand device changes.

This event is triggered whenever the LED intensity is updated via the SetLedIntensity method. Subscribers can use this event to respond to changes in the LED intensity, such as updating UI elements or logging.

Example usage:

medWandController.LedIntensityChanged += intensity =>
{
Console.WriteLine($"LED intensity changed to: {intensity}");
};

◆ LicenseError

Action<LicenseState>? MWSDK.NetCore.MedWandControllerBase.LicenseError

Occurs when there is an issue with the license state of the MedWand device.

This event is triggered in scenarios such as:

  • The license is invalid.
  • The license has expired.
  • The license is nearing expiration.

To handle license errors, subscribe to this event:

_medWandController.LicenseError += (state) =>
{
switch (state)
{
case LicenseState.Invalid:
Console.WriteLine("License is invalid.");
break;
case LicenseState.Expired:
Console.WriteLine("License has expired.");
break;
case LicenseState.Expiring:
Console.WriteLine("License is expiring soon.");
break;
}
};
LicenseState
Defines the various states of a license within the system.
Definition EnumLicense.cs:25

◆ ReadingReceived

Action<MedWandReading>? MWSDK.NetCore.MedWandControllerBase.ReadingReceived

Occurs when a new reading is received from the MedWand device.

This event is triggered whenever the MedWand device processes and provides a new reading. The event handler receives a MedWandReading object containing the details of the reading.

Example usage:

_medWandController.ReadingReceived += (reading) =>
{
Console.WriteLine($"New reading received: {reading}");
};

◆ ReadingStateChanged

Action<ReadingState>? MWSDK.NetCore.MedWandControllerBase.ReadingStateChanged

Occurs when the reading state of the MedWand device changes.

This event is triggered whenever the ReadingState property of the MedWand device changes. It provides the updated ReadingState as an argument to the event handler.

To handle this event, you can subscribe to it as follows:

_medWandController.ReadingStateChanged += MedWandController_ReadingStateChanged;
private void MedWandController_ReadingStateChanged(ReadingState readingState)
{
// Handle the updated reading state here
}
ReadingState
Represents the various states of the reading process in the MedWand SDK.
Definition EnumReadingState.cs:10