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
platformIPlatformThe reference to the platform specific PSCommSimple class.
platformInvokerIPlatformInvoker
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
trueif 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
trueif [cell is on]; otherwise,false.
Exceptions
- NullReferenceException
Not connected to a device.
Methods
AbortMeasurement()
Aborts the current active measurement.
public Task AbortMeasurement()
Returns
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
Connect(Device)
Connects to the specified device.
public Task Connect(Device device)
Parameters
deviceDeviceThe device.
Returns
Disconnect()
Disconnects from the connected device.
public Task Disconnect()
Returns
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
methodMethodThe method.
Returns
- bool
trueif 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
methodMethodThe method containing the measurement parameters.
taskBarrierTaskBarrier
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
methodMethodThe method.
muxChannelintThe mux channel.
taskBarrierTaskBarrierThe task barrier.
Returns
ReadCellCurrent()
Reads the cell current.
public Task<float> ReadCellCurrent()
Returns
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
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
bitMaskbyteA bitmask specifying which digital lines to read (0 = ignore, 1 = read).
Returns
SetCellCurrent(float)
Sets the cell current.
public Task SetCellCurrent(float current)
Parameters
currentfloatThe current.
Returns
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
potentialfloatThe potential.
Returns
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
currentRangeCurrentRangeThe current range.
Returns
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
bitMaskintA bitmask specifying the output of the digital lines (0 = low, 1 = high).
Returns
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
bitMaskintA bitmask specifying the output signal of the digital lines (0 = low, 1 = high).
configGPIOintA bitmask specifying the the mode of digital lines (0 = input, 1 = output).
Returns
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
Returns
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
methodMethodThe method containing the measurement parameters.
taskBarrierTaskBarrier
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
methodMethodThe method containing the measurement parameters.
muxChannelintThe mux channel to measure on.
taskBarrierTaskBarrier
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
Returns
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
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
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
methodMethodThe method containing the measurement parameters.
isValidMethodboolif set to
true[is valid method].errorsList<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
MeasurementEnded
Occurs when a measurement has ended.
public event EventHandler<Exception> MeasurementEnded
Event Type
MeasurementStarted
Occurs at the start of a new measurement.
public event EventHandler MeasurementStarted
Event Type
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
StateChanged
Occurs when the devive's [state changed].
public event CommManager.StatusChangedEventHandler StateChanged
Event Type
- CommManager.StatusChangedEventHandler