Table of Contents

Class PSMultiCommSimple

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

Constructors

PSMultiCommSimple(IPlatformMulti, IPlatformInvoker)

Initializes a new instance of the PSMultiCommSimple class. This class handles is used to perform measurements and control a collection of channels manually. It requires a reference to the platform specific instance of the class, i.e. PSMultiCommSimpleWinForms, PSMultiCommSimpleWPF or PSMultiCommSimpleXamarin

public PSMultiCommSimple(IPlatformMulti platform, IPlatformInvoker platformInvoker)

Parameters

platform IPlatformMulti

The reference to the platform specific PSMultiCommSimple class.

platformInvoker IPlatformInvoker

Exceptions

ArgumentNullException

Platform cannot be null

Properties

Capabilities

Gets the capabilities of the connected channels.

public DeviceCapabilities[] Capabilities { get; }

Property Value

DeviceCapabilities[]

The channel capabilities.

Exceptions

NullReferenceException

Not connected to any channels.

ChannelStates

Gets the states of the connected channels.

public CommManager.DeviceState[] ChannelStates { get; }

Property Value

DeviceState[]

The states of the connected channels.

Exceptions

NullReferenceException

Not connected to any channels.

Comms

Gets or sets the connected channels' CommManagers and (un)subscribes the corresponding events.

public CommManager[] Comms { get; }

Property Value

CommManager[]

The CommManager.

CommsByChannelIndex

Gets a dictionary connections by channel index. Do not modify this dictionary.

public Dictionary<int, CommManager> CommsByChannelIndex { get; }

Property Value

Dictionary<int, CommManager>

The index of the comms by channel.

Connected

Gets a value indicating whether PSCommSimple is connected to any channels.

public bool Connected { get; }

Property Value

bool

true if connected; otherwise, false.

ConnectedChannels

Gets the connected channel types.

public enumDeviceType[] ConnectedChannels { get; }

Property Value

enumDeviceType[]

The connected channel types.

Exceptions

NullReferenceException

Not connected to any channels.

ConnectedDevices

Gets the connected devices.

public Device[] ConnectedDevices { get; }

Property Value

Device[]

The connected devices.

Exceptions

NullReferenceException

Not connected to any channels.

IsCellOn

Gets values indicating whether the connected channels' [cell is on].

public bool[] IsCellOn { get; }

Property Value

bool[]

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

Exceptions

NullReferenceException

Not connected to any channels.

NConnectedChannels

Gets the number of connected channels.

public int NConnectedChannels { get; }

Property Value

int

The n connected channels.

Methods

AbortAllActiveMeasurementsAsync()

Aborts all active measurements channels.

public Task AbortAllActiveMeasurementsAsync()

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel.

Exception

The channel is not currently performing measurement

AbortMeasurementAsync(int)

Aborts the active measurement on the specified channel.

public Task AbortMeasurementAsync(int channel)

Parameters

channel int

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel.

Exception

The channel is not currently performing measurement

AbortMeasurementsAsync(int[])

Aborts the active measurement on the specified channels.

public Task AbortMeasurementsAsync(int[] channels)

Parameters

channels int[]

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel.

Exception

The channel is not currently performing measurement

CheckConnections(IList<Device>, CancellationToken)

public Task CheckConnections(IList<Device> devices, CancellationToken cancellationToken)

Parameters

devices IList<Device>
cancellationToken CancellationToken

Returns

Task

Connect(IReadOnlyList<Device>, IList<int>)

Connects the specified devices.

public Task Connect(IReadOnlyList<Device> devices, IList<int> channelIndices = null)

Parameters

devices IReadOnlyList<Device>

The devices.

channelIndices IList<int>

The channel indices.

Returns

Task

Disconnect()

Disconnects from the connected channels.

public Task Disconnect()

Returns

Task

Exceptions

NullReferenceException

Not connected to any channels.

Dispose()

public void Dispose()

GetAvailableDevicesAsync()

Returns an array of available instruments/channels.

public Task<IReadOnlyList<Device>> GetAvailableDevicesAsync()

Returns

Task<IReadOnlyList<Device>>

GetInternalStorageHandler(int)

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 GetInternalStorageHandler(int channel)

Parameters

channel int

Returns

IInternalStorageBrowser

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

Exceptions

InvalidOperationException

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

ArgumentException

This is thrown when the channel passed in does not exist in the current communications mapping.

GetTaskResultsAndOrExceptions<T>(Func<int, Task<(T Result, int ChannelIndex, Exception Exception)>>, IList<int>)

Runs an Func delegate asynchronously on the specified channels and handles any exceptions preventing successful results from being returned unless throwExceptions is specifically set to true

public static Task<IReadOnlyList<(T Result, int ChannelIndex, Exception Exception)>> GetTaskResultsAndOrExceptions<T>(Func<int, Task<(T Result, int ChannelIndex, Exception Exception)>> func, IList<int> channels)

Parameters

func Func<int, Task<(T Result, int ChannelIndex, Exception Exception)>>
channels IList<int>

Returns

Task<IReadOnlyList<(T Result, int ChannelIndex, Exception Exception)>>

Type Parameters

T

IsValidMethod(Method)

Determines whether [the specified method] is compatible with all connected channels.

public bool[] IsValidMethod(Method method)

Parameters

method Method

The method.

Returns

bool[]

true if the method is valid; otherwise, false.

IsValidMethod(Method, int)

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

public bool IsValidMethod(Method method, int channel)

Parameters

method Method

The method.

channel int

The specified channel.

Returns

bool

true if the method is valid; otherwise, false.

IsValidMethod(Method, int[])

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

public bool[] IsValidMethod(Method method, int[] channels)

Parameters

method Method

The method.

channels int[]

The specified channels.

Returns

bool[]

true if the method is valid; otherwise, false.

MeasureAllChannelsAsync(Method)

Awaits a measurement as specified in the method until completion on all channels.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> MeasureAllChannelsAsync(Method method)

Parameters

method Method

The method containing the measurement parameters.

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

MeasureAllChannelsAsync(Method, int)

Awaits a measurement as specified in the method until completion on all channels.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> MeasureAllChannelsAsync(Method method, int muxChannel)

Parameters

method Method

The method containing the measurement parameters.

muxChannel int

The mux channel to measure on.

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

MeasureAsync(Method, int)

Runs a measurement as specified in the method on the specified channel.

public Task<SimpleMeasurement> MeasureAsync(Method method, int channel)

Parameters

method Method

The method containing the measurement parameters.

channel int

Returns

Task<SimpleMeasurement>

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

MeasureAsync(Method, int, int, TaskBarrier)

Awaits a measurement as specified in the method on the specified channel until completion.

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

Parameters

method Method

The method containing the measurement parameters.

channel int

The channel.

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 any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

MeasureAsync(Method, int[])

Awaits a measurement as specified in the method until completion on the specified collection of channels.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> MeasureAsync(Method method, int[] channels)

Parameters

method Method

The method containing the measurement parameters.

channels int[]

The channels.

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

MeasureAsync(Method, int[], int)

Awaits a measurement as specified in the method until completion on the specified collection of channels. No results will be returned if other measurements were started correctly.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> MeasureAsync(Method method, int[] channels, int muxChannel)

Parameters

method Method

The method containing the measurement parameters.

channels int[]

The channels.

muxChannel int

The mux channel to measure on.

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

An array of ValueTuples containing:

  • An instance of the SimpleMeasurement instance containing all the data related to the measurement, null in the case of an exception
  • The channel index
  • Null unless an exception was caught

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

ReadCellCurrentAsync()

Reads the cell current on all channels.

public Task<IReadOnlyList<(float Current, int ChannelIndex, Exception Exception)>> ReadCellCurrentAsync()

Returns

Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>>

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

ReadCellCurrentAsync(int)

Reads the cell current on the specified channel.

public Task<float> ReadCellCurrentAsync(int channel)

Parameters

channel int

Returns

Task<float>

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

ReadCellCurrentAsync(int[])

Reads the cell current on the specified channels.

public Task<IReadOnlyList<(float Current, int ChannelIndex, Exception Exception)>> ReadCellCurrentAsync(int[] channels)

Parameters

channels int[]

Returns

Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>>

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

ReadCellPotentialAsync()

Reads the cell potential on all channels.

public Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>> ReadCellPotentialAsync()

Returns

Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>>

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to a channel

Exception

Channel must be in idle mode for manual control

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

ReadCellPotentialAsync(int)

Reads the cell potential on the specified channel.

public Task<float> ReadCellPotentialAsync(int channel)

Parameters

channel int

The channel.

Returns

Task<float>

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to a channel

Exception

Channel must be in idle mode for manual control

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

ReadCellPotentialAsync(int[])

Reads the cell potential on the specified channels.

public Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>> ReadCellPotentialAsync(int[] channels)

Parameters

channels int[]

Returns

Task<IReadOnlyList<(float Potential, int ChannelIndex, Exception Exception)>>

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to a channel

Exception

Channel must be in idle mode for manual control

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

RunAsyncAggregateExceptions(Func<int, Task<(int ChannelIndex, Exception Exception)>>, int[])

Runs a Func delegate asynchronously on the specified channels and aggregates any exceptions

public static Task RunAsyncAggregateExceptions(Func<int, Task<(int ChannelIndex, Exception Exception)>> func, int[] channels)

Parameters

func Func<int, Task<(int ChannelIndex, Exception Exception)>>
channels int[]

Returns

Task

SetCellCurrentAsync(float)

Sets the cell current on all channels.

public Task SetCellCurrentAsync(float current)

Parameters

current float

The current.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCellCurrentAsync(float, int)

Sets the cell current on the specified channel.

public Task SetCellCurrentAsync(float current, int channel)

Parameters

current float

The current.

channel int

The channel.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCellCurrentAsync(float, int[])

Sets the cell current on the specified channels.

public Task SetCellCurrentAsync(float current, int[] channels)

Parameters

current float

The current.

channels int[]

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCellPotentialAsync(float)

Sets the cell potential on all channels.

public Task SetCellPotentialAsync(float potential)

Parameters

potential float

The potential.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCellPotentialAsync(float, int)

Sets the cell potential on the specified channel.

public Task SetCellPotentialAsync(float potential, int channel)

Parameters

potential float

The potential.

channel int

The channel.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCellPotentialAsync(float, int[])

Sets the cell potential on the specified channels.

public Task SetCellPotentialAsync(float potential, int[] channels)

Parameters

potential float

The potential.

channels int[]

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCurrentRangeAsync(CurrentRange)

Sets the current range on all channels.

public Task SetCurrentRangeAsync(CurrentRange currentRange)

Parameters

currentRange CurrentRange

The current range.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCurrentRangeAsync(CurrentRange, int)

Sets the current range on the specified channel.

public Task SetCurrentRangeAsync(CurrentRange currentRange, int channel)

Parameters

currentRange CurrentRange

The current range.

channel int

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

SetCurrentRangeAsync(CurrentRange, int[])

Sets the current range on the specified channels.

public Task SetCurrentRangeAsync(CurrentRange currentRange, int[] channels)

Parameters

currentRange CurrentRange

The current range.

channels int[]

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

StartMeasureAllChannelsAsync(Method, int, bool)

Starts a measurement as specified in the method on all channels.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> StartMeasureAllChannelsAsync(Method method, int muxChannel, bool useHWsync = false)

Parameters

method Method

The method containing the measurement parameters.

muxChannel int

The mux channel to measure on.

useHWsync bool

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

StartMeasureAsync(Method, int)

Starts a measurement as specified in the method on the specified channel.

public Task<SimpleMeasurement> StartMeasureAsync(Method method, int channel)

Parameters

method Method

The method containing the measurement parameters.

channel int

Returns

Task<SimpleMeasurement>

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

StartMeasureAsync(Method, int, int, TaskBarrier)

Starts a measurement as specified in the method on the specified channel.

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

Parameters

method Method

The method containing the measurement parameters.

channel int

The channel.

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 any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

StartMeasureAsync(Method, int[], bool)

Starts a measurement as specified in the method on the specified channel.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> StartMeasureAsync(Method method, int[] channels, bool useHWSync = false)

Parameters

method Method

The method containing the measurement parameters.

channels int[]

The channels.

useHWSync bool

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

StartMeasurementAllChannelsAsync(Method, bool)

Starts a measurement as specified in the method on the specified channel.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> StartMeasurementAllChannelsAsync(Method method, bool useHWSync = false)

Parameters

method Method

The method containing the measurement parameters.

useHWSync bool

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

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

StartMeasurementAsync(Method, int[], int, bool)

Starts a measurement as specified in the method on the specified collection of channels. No results will be returned if other measurements were started correctly.

public Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>> StartMeasurementAsync(Method method, int[] channels, int muxChannel, bool useHWSync = false)

Parameters

method Method

The method containing the measurement parameters.

channels int[]

The channels.

muxChannel int

The mux channel to measure on.

useHWSync bool

Returns

Task<IReadOnlyList<(SimpleMeasurement Measurement, int ChannelIndex, Exception Exception)>>

An array of ValueTuples containing:

  • An instance of the SimpleMeasurement instance containing all the data related to the measurement, null in the case of an exception
  • The channel index
  • Null unless an exception was caught

Exceptions

NullReferenceException

Not connected to any channels. or Not connected to specified channel.

ArgumentException

Method is incompatible with the connected channel.

Exception

Could not start measurement.

TurnCellOffAsync()

Turns the cell off on all channels.

public Task TurnCellOffAsync()

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

TurnCellOffAsync(int)

Turns the cell off on specified channel.

public Task TurnCellOffAsync(int channel)

Parameters

channel int

The channel.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

TurnCellOffAsync(int[])

Turns the cell off on specified channels.

public Task TurnCellOffAsync(int[] channels)

Parameters

channels int[]

The channels.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

TurnCellOffTask(int, bool)

Turns the cell off on the specified channel.

public Task<(int ChannelIndex, Exception Exception)> TurnCellOffTask(int channel, bool throwExceptions)

Parameters

channel int

The channel.

throwExceptions bool

if set to true [throw on exceptions], otherwise return them.

Returns

Task<(int ChannelIndex, Exception Exception)>

A ValueTuple containing the channel index and any exceptions that were thrown

TurnCellOnAsync()

Turns the cell on on all channels.

public Task TurnCellOnAsync()

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

TurnCellOnAsync(int)

Turns the cell on on specified channel.

public Task TurnCellOnAsync(int channel)

Parameters

channel int

The channel.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel must be in idle mode for manual control

TurnCellOnAsync(int[])

Turns the cell on on specified channels.

public Task TurnCellOnAsync(int[] channels)

Parameters

channels int[]

The channels.

Returns

Task

Exceptions

NullReferenceException

Not connected to a channel

Exception

Channel 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 all connected channels.

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 channel.

ArgumentNullException

The specified method cannot be null.

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

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

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

Parameters

method Method

The method containing the measurement parameters.

channel int

The specified channel.

isValidMethod bool

if set to true [is valid method].

errors List<string>

The errors.

Exceptions

NullReferenceException

Not connected to a channel.

ArgumentNullException

The specified method cannot be null.

ValidateMethod(Method, int[], out bool[], out List<string>[])

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

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

Parameters

method Method

The method containing the measurement parameters.

channels int[]

The specified channels.

isValidMethod bool[]

if set to true [is valid method].

errors List<string>[]

The errors.

Exceptions

NullReferenceException

Not connected to a channel.

ArgumentNullException

The specified method cannot be null.

Events

Disconnected

Occurs when a channel is [disconnected].

public event MultiChannelDisconnectedEventHandler Disconnected

Event Type

MultiChannelDisconnectedEventHandler

MeasurementEnded

Occurs when a measurement has ended.

public event MultiChannelMeasurementEventHandler MeasurementEnded

Event Type

MultiChannelMeasurementEventHandler

MeasurementStarted

Occurs at the start of a new measurement.

public event MultiChannelMeasurementEventHandler MeasurementStarted

Event Type

MultiChannelMeasurementEventHandler

ReceiveStatus

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

public event MultiChannelStatusEventHandler ReceiveStatus

Event Type

MultiChannelStatusEventHandler

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 MultiChannelStateChangedEventHandler StateChanged

Event Type

MultiChannelStateChangedEventHandler