Show / Hide Table of Contents

# Class DeviceCompatModule

Wrapper around a single IDeviceCompat instance

##### Inheritance

object
DeviceCompatModule

##### Inherited Members

object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()

###### Namespace: NixUniversalSDK.Wrapper

###### Assembly: NixUniversalSDK.Wrapper.dll

##### Syntax

    public class DeviceCompatModule

### Properties

#### BatteryStateChangedDelegate

Delegate linked to the internal BatteryStateChanged event. The provided integer value corresponds to the new battery state.

##### Declaration

    public Delegates.IntValue? BatteryStateChangedDelegate { get; }

##### Property Value

Type | Description
--- | ---
Delegates.IntValue |

##### Examples

An example handler is shown below:

    void OnBatteryStateChanged(string senderName, int newState)
    {
        // - `senderName` is "BatteryStateChanged"
        // - `newState` is the updated battery level (0 - 100)
        // ...
    }

#### CommandCompletedDelegate

Delegate that is invoked on completion of any async task by the connected device. The `senderId` string value corresponds to the name of the async task that was completed, and the provided integer value corresponds to the CommandStatus value of the result.

##### Declaration

    public Delegates.IntValue? CommandCompletedDelegate { get; }

##### Property Value

Type | Description
--- | ---
Delegates.IntValue |

##### Examples

An example handler is shown below:

    void OnCommandCompletedDelegate(string senderName, int commandStatus)
    {
        // - `senderName` is the async task / function name from
        //   `IDeviceCompat` that invoked this handler.
        // - `commandStatus` is one of the `CommandStatus` values

        if (senderName.Equals(
            "MeasureAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `MeasureAsync`
            // ...
        }
        else if (senderName.Equals(
            "RunFieldCalibrationAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `RunFieldCalibrationAsync`
            // ...
        }
        else if (senderName.Equals(
            "SetFieldCalibrationEnabledAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `SetFieldCalibrationEnabledAsync`
            // ...
        }
        else if (senderName.Equals(
            "SetTemperatureCompensationEnabledAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `SetTemperatureCompensationEnabledAsync`
            // ...
        }
        else if (senderName.Equals(
            "SetHapticFeedbackEnabledAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `SetHapticFeedbackEnabledAsync`
            // ...
        }
        else if (senderName.Equals(
            "SetRgbFeedbackEnabledAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `SetRgbFeedbackEnabledAsync`
            // ...
        }
        else if (senderName.Equals(
            "LedTestAsync",
            StringComparison.OrdinalIgnoreCase))
        {
            // Callback from `LedTestAsync`
            // ...
        }
    }

#### ConnectedDelegate

Delegate linked to the internal Connected event

##### Declaration

    public Delegates.Empty? ConnectedDelegate { get; }

##### Property Value

Type | Description
--- | ---
Delegates.Empty |

##### Examples

An example handler is shown below:

    void OnConnected(string senderName)
    {
        // - `senderName` is "Connected"
        // ...
    }

#### DisconnectedDelegate

Delegate linked to the internal Disconnected event. The provided integer value corresponds to the DeviceStatus argument from the event.

##### Declaration

    public Delegates.IntValue? DisconnectedDelegate { get; }

##### Property Value

Type | Description
--- | ---
Delegates.IntValue |

##### Examples

An example handler is shown below:

    void OnDisconnected(string senderName, int deviceStatus)
    {
        // - `senderName` is "Disconnected"
        // - `deviceStatus` is one of the `DeviceStatus` values

        // Handle status codes here, if desired in your application
        // At minimum, should check for `ErrorUnauthorized` (5) status
        switch (deviceScannerStatus)
        {
            case 5:
                // `DeviceStatus.ErrorUnauthorized`
                // Device not authorized for this SDK build
                // ..
                break;
            case 0:
                // `DeviceStatus.Success`
                // Normal disconnect from `Device_Disconnect()`
                // ...
                break;
            case 4:
                // `DeviceStatus.ErrorDroppedConnection`
                // Nix device dropped the connection
                // ...
                break;
            case 1:
                // `DeviceStatus.ErrorMaxAttempts`
            case 2:
                // `DeviceStatus.ErrorTimeout`
                // Connection to Nix device timed out
                // ...
                break;
            default:
                // Other internal errors
                // ..
                break;
        }
    }

#### ExtPowerStageChangedDelegate

Delegate linked to the internal ExtPowerStateChanged event. The provided boolean value corresponds to the new external power state.

##### Declaration

    public Delegates.BoolValue? ExtPowerStageChangedDelegate { get; }

##### Property Value

Type | Description
--- | ---
Delegates.BoolValue |

##### Examples

An example handler is shown below:

    void OnBatteryStateChanged(string senderName, bool newState)
    {
        // - `senderName` is "ExtPowerStateChanged"
        // - `newState` is the updated external power state:
        //   `true` when power is connected, `false` when disconnected
        // ...
    }