Table of Contents

Class PSCommSimple

Namespace
PalmSens.Core.Simplified
Assembly
PalmSens.Core.Simplified.dll
public class PSCommSimple
Inheritance
PSCommSimple
Inherited Members

Constructors

PSCommSimple(IPlatform, IPlatformInvoker)

Initializes a new instance of the PSCommSimple class. This class handles is used to perform measurements and control the device manually. It requires a reference to the platform specific instance of the class, i.e. PSCommSimpleWinForms, PSCommSimpleWPF or PSCommSimpleXamarin

public PSCommSimple(IPlatform platform, IPlatformInvoker platformInvoker)

Parameters

platform IPlatform

The reference to the platform specific PSCommSimple class.

platformInvoker IPlatformInvoker

Exceptions

ArgumentNullException

Platform cannot be null

Properties

Capabilities

Gets the capabilities of the connected device.

public DeviceCapabilities Capabilities { get; }

Property Value

DeviceCapabilities

The device capabilities.

Exceptions

NullReferenceException

Not connected to a device.

Comm

Gets or sets the CommManager and (un)subscribes the corresponding events.

public CommManager Comm { get; set; }

Property Value

CommManager

The CommManager.

Connected

Gets a value indicating whether PSCommSimple is connected to a device.

public bool Connected { get; }

Property Value

bool

true if connected; otherwise, false.

ConnectedDevice

Gets the connected device type.

public enumDeviceType ConnectedDevice { get; }

Property Value

enumDeviceType

The connected device type.

Exceptions

NullReferenceException

Not connected to a device.

DeviceState

Gets the state of the device.

public CommManager.DeviceState DeviceState { get; }

Property Value

CommManager.DeviceState

The state of the device.

Exceptions

NullReferenceException

Not connected to a device.

IsCellOn

Gets a value indicating whether the connected device's [cell is on].

public bool IsCellOn { get; }

Property Value

bool

true if [cell is on]; otherwise, false.

Exceptions

NullReferenceException

Not connected to a device.

Methods

AbortMeasurement()

Aborts the current active measurement.

public Task AbortMeasurement()

Returns

Task

Exceptions

NullReferenceException

Not connected to a device.

Exception

The device is not currently performing measurement

Connect()

Connects to the device with the highest priority.

public Task Connect()

Returns

Task

Connect(Device)

Connects to the specified device.

public Task Connect(Device device)

Parameters

device Device

The device.

Returns

Task

Disconnect()

Disconnects from the connected device.

public Task Disconnect()

Returns

Task

Exceptions

NullReferenceException

Not connected to a device.

Dispose()

public void Dispose()

GetAvailableDevices()

Returns an array of connected devices.

public Task<IReadOnlyList<Device>> GetAvailableDevices()

Returns

Task<IReadOnlyList<Device>>

The connected devices.

GetInternalStorageBrowser()

Get an internal storage handler that will read the current connected device stored files. This is only for devices that have internal storage.

public IInternalStorageBrowser GetInternalStorageBrowser()

Returns

IInternalStorageBrowser

A new instance of the internal storage handler for the current connection.

Exceptions

InvalidOperationException

This exception is thrown when the device is not connected or if the device does not support storage.

IsValidMethod(Method)

Determines whether [the specified method] is compatible with the device.

public bool IsValidMethod(Method method)

Parameters

method Method

The method.

Returns

bool

true if the method is valid; otherwise, false.

Measure(Method, TaskBarrier)

Runs a measurement as specified in the method on the connected device until completion.

public Task<SimpleMeasurement> Measure(Method method, TaskBarrier taskBarrier = null)

Parameters

method Method

The method containing the measurement parameters.

taskBarrier TaskBarrier

Returns

Task<SimpleMeasurement>

A SimpleMeasurement instance containing all the data related to the measurement.

Measure(Method, int, TaskBarrier)

Runs a measurement as specified in the method on the connected device until completion.

public Task<SimpleMeasurement> Measure(Method method, int muxChannel, TaskBarrier taskBarrier = null)

Parameters

method Method

The method.

muxChannel int

The mux channel.

taskBarrier TaskBarrier

The task barrier.

Returns

Task<SimpleMeasurement>

ReadCellCurrent()

Reads the cell current.

public Task<float> ReadCellCurrent()

Returns

Task<float>

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

ReadCellPotential()

Reads the cell potential.

public Task<float> ReadCellPotential()

Returns

Task<float>

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

ReadDigitalLine(byte)

Reads the specified digital line(s) state(s). Which lines to read from are specified in a bitmask. Bit 0 is for GPIO0, bit 1 for GPIO1, etc. Bits that are high correspond with a high output signal

public Task<uint> ReadDigitalLine(byte bitMask)

Parameters

bitMask byte

A bitmask specifying which digital lines to read (0 = ignore, 1 = read).

Returns

Task<uint>

Bitmask that represents the specified lines output signal (0 = low, 1 = high).

SetCellCurrent(float)

Sets the cell current.

public Task SetCellCurrent(float current)

Parameters

current float

The current.

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

SetCellPotential(float)

Sets the cell potential.

public Task SetCellPotential(float potential)

Parameters

potential float

The potential.

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

SetCurrentRange(CurrentRange)

Sets the current range.

public Task SetCurrentRange(CurrentRange currentRange)

Parameters

currentRange CurrentRange

The current range.

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

SetDigitalOutput(int)

Sets the digital lines output signal high or low. The output signal for the digital lines are defined in a bitmask. Bit 0 is for GPIO0, bit 1 for GPIO1, etc. Bits that are high correspond with a high output signal

public Task SetDigitalOutput(int bitMask)

Parameters

bitMask int

A bitmask specifying the output of the digital lines (0 = low, 1 = high).

Returns

Task

SetDigitalOutput(int, int)

Sets the specified digital lines to input/output and set the output signal of the lines set to output The output signal for the digital lines are defined in a bitmask. Bit 0 is for GPIO0, bit 1 for GPIO1, etc. Bits that are high correspond with a high output signal

public Task SetDigitalOutput(int bitMask, int configGPIO)

Parameters

bitMask int

A bitmask specifying the output signal of the digital lines (0 = low, 1 = high).

configGPIO int

A bitmask specifying the the mode of digital lines (0 = input, 1 = output).

Returns

Task

StartGetterMethodScript(string, int)

Runs a MethodSCRIPT on the device and returns the output. A timeout exception will be thrown if no new data is received for longer than the timeout. A timeout exception will be thrown for scripts that do not return anything.

public Task<string> StartGetterMethodScript(string script, int timeout = 2500)

Parameters

script string

The MethodSCRIPT.

timeout int

The timeout.

Returns

Task<string>

StartMeasurement(Method, TaskBarrier)

Starts a measurement as specified in the method on the connected device.

public Task<SimpleMeasurement> StartMeasurement(Method method, TaskBarrier taskBarrier = null)

Parameters

method Method

The method containing the measurement parameters.

taskBarrier TaskBarrier

Returns

Task<SimpleMeasurement>

A SimpleMeasurement instance containing all the data related to the measurement.

StartMeasurement(Method, int, TaskBarrier)

Starts a measurement as specified in the method on the connected device.

public Task<SimpleMeasurement> StartMeasurement(Method method, int muxChannel, TaskBarrier taskBarrier = null)

Parameters

method Method

The method containing the measurement parameters.

muxChannel int

The mux channel to measure on.

taskBarrier TaskBarrier

Returns

Task<SimpleMeasurement>

A SimpleMeasurement instance containing all the data related to the measurement.

Exceptions

NullReferenceException

Not connected to a device.

ArgumentException

Method is incompatible with the connected device.

Exception

Could not start measurement.

StartSetterMethodScriptAsync(string, int)

Runs a MethodSCRIPT on the device, ignoring any output returned by the script.

public Task StartSetterMethodScriptAsync(string script, int timeout = 500)

Parameters

script string

The MethodSCRIPT.

timeout int

The timeout.

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode to run a MethodSCRIPT

TurnCellOff()

Turns the cell off.

public Task TurnCellOff()

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

TurnCellOn()

Turns the cell on.

public Task TurnCellOn()

Returns

Task

Exceptions

NullReferenceException

Not connected to a device

Exception

Device must be in idle mode for manual control

ValidateMethod(Method, out bool, out List<string>)

Validates whether the specified method is compatible with the capabilities of the connected device.

public void ValidateMethod(Method method, out bool isValidMethod, out List<string> errors)

Parameters

method Method

The method containing the measurement parameters.

isValidMethod bool

if set to true [is valid method].

errors List<string>

The errors.

Exceptions

NullReferenceException

Not connected to a device.

ArgumentNullException

The specified method cannot be null.

Events

Disconnected

Occurs when a device is [disconnected].

public event DisconnectedEventHandler Disconnected

Event Type

DisconnectedEventHandler

MeasurementEnded

Occurs when a measurement has ended.

public event EventHandler<Exception> MeasurementEnded

Event Type

EventHandler<Exception>

MeasurementStarted

Occurs at the start of a new measurement.

public event EventHandler MeasurementStarted

Event Type

EventHandler

ReceiveStatus

Occurs when a device status package is received, these packages are not sent during a measurement.

public event StatusEventHandler ReceiveStatus

Event Type

StatusEventHandler

SimpleCurveStartReceivingData

Occurs when a new [SimpleCurve starts receiving data].

public event PSCommSimple.SimpleCurveStartReceivingDataHandler SimpleCurveStartReceivingData

Event Type

PSCommSimple.SimpleCurveStartReceivingDataHandler

StateChanged

Occurs when the devive's [state changed].

public event CommManager.StatusChangedEventHandler StateChanged

Event Type

CommManager.StatusChangedEventHandler