Search Results for

    Show / Hide Table of Contents

    Class StimulationParams

    Provides a Unity-facing API for WSS stimulation using the core + params layer.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    StimulationParams
    Namespace: WSS.Unity
    Assembly: UnitySubmodule.Docs.dll
    Syntax
    public class StimulationParams : MonoBehaviour
    Remarks

    This component composes WssStimulationCore -> StimParamsLayer and exposes convenience methods that accept finger aliases (e.g., "index" or "ch2").

    Lifecycle: the device is initialized in StimulationParams.OnEnable(), ticked in StimulationParams.Update(), and shut down in StimulationParams.OnDisable().

    When forcePort is false, the wrapper auto-selects a serial port. When StimulationParams.testMode is true, it uses an in-memory test transport instead of hardware.

    Fields

    comPort

    Target COM port to use when forcePort is enabled.

    Declaration
    [SerializeField]
    public string comPort
    Field Value
    Type Description
    string

    forcePort

    Forces connection to a specific COM port instead of auto-detecting.

    Declaration
    [SerializeField]
    public bool forcePort
    Field Value
    Type Description
    bool

    started

    Gets or sets a user-managed flag indicating whether stimulation is considered started.

    Declaration
    public bool started
    Field Value
    Type Description
    bool
    Remarks

    This wrapper does not update this field; use Started() to query device state.

    Methods

    AddOrUpdateStimParam(string, float)

    Sets a parameter by dotted key. Examples: "stim.ch.0.amp", "stim.ch.1.minPW".

    Declaration
    public void AddOrUpdateStimParam(string key, float value)
    Parameters
    Type Name Description
    string key

    Dotted parameter key.

    float value

    Value to set.

    Awake()

    Builds the transport and core WSS, then wraps it with StimParamsLayer. Tries to expose IBasicStimulation if available.

    Declaration
    public void Awake()
    Remarks

    Uses UnityEngine.Application.streamingAssetsPath as the configuration root.

    GetAllStimParams()

    Returns a copy of all current params as dotted-key map.

    Declaration
    public Dictionary<string, float> GetAllStimParams()
    Returns
    Type Description
    Dictionary<string, float>

    Dictionary mapping dotted keys to parameter values.

    GetChannelAmp(string)

    Gets per-finger amplitude in mA.

    Declaration
    public float GetChannelAmp(string finger)
    Parameters
    Type Name Description
    string finger
    Returns
    Type Description
    float

    Default amplitude in milliamps.

    GetChannelIPI(string)

    Gets per-finger IPI in ms.

    Declaration
    public int GetChannelIPI(string finger)
    Parameters
    Type Name Description
    string finger
    Returns
    Type Description
    int

    Inter-pulse interval in milliseconds.

    GetChannelPWMax(string)

    Gets per-finger maximum pulse width in microseconds.

    Declaration
    public int GetChannelPWMax(string finger)
    Parameters
    Type Name Description
    string finger
    Returns
    Type Description
    int

    Maximum pulse width in microseconds.

    GetChannelPWMin(string)

    Gets per-finger minimum pulse width in microseconds.

    Declaration
    public int GetChannelPWMin(string finger)
    Parameters
    Type Name Description
    string finger
    Returns
    Type Description
    int

    Minimum pulse width in microseconds.

    GetCoreConfigCTRL()

    Provides access to the core configuration controller.

    Declaration
    public CoreConfigController GetCoreConfigCTRL()
    Returns
    Type Description
    CoreConfigController

    The current core configuration controller owned by the wrapper.

    GetLastPulseWidth(string)

    Gets the last computed stimulation intensity for a finger.

    Declaration
    public int GetLastPulseWidth(string finger)
    Parameters
    Type Name Description
    string finger

    Finger label or alias.

    Returns
    Type Description
    int

    The last intensity value produced for the resolved channel.

    Remarks

    For PW-driven systems this value is pulse width in microseconds.

    GetStimParam(string)

    Gets a parameter by dotted key.

    Declaration
    public float GetStimParam(string key)
    Parameters
    Type Name Description
    string key

    Dotted parameter key.

    Returns
    Type Description
    float

    Parameter value as float.

    IsFingerValid(string)

    Returns true if the finger maps to a valid channel for the current configuration.

    Declaration
    public bool IsFingerValid(string finger)
    Parameters
    Type Name Description
    string finger

    Finger label or alias.

    Returns
    Type Description
    bool

    true when the resolved channel is within the current configuration range.

    LoadParamsJson()

    Loads params JSON from default location.

    Declaration
    public void LoadParamsJson()

    LoadParamsJson(string)

    Loads params JSON from a given file or directory.

    Declaration
    public void LoadParamsJson(string pathOrDir)
    Parameters
    Type Name Description
    string pathOrDir

    File path or directory with default name.

    Ready()

    True when the core is ready to accept start stimulation.

    Declaration
    public bool Ready()
    Returns
    Type Description
    bool

    Save()

    Saves board settings to non-volatile memory. Implementations should pause streaming if needed, perform the save, then resume.

    Declaration
    public void Save()
    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    Save(int)

    Saves board settings to non-volatile memory. Implementations should pause streaming if needed, perform the save, then resume.

    Declaration
    public void Save(int targetWSS)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    SaveParamsJson()

    Saves current params JSON to disk.

    Declaration
    public void SaveParamsJson()

    SetChannelAmp(string, float)

    Sets per-finger amplitude in mA.

    Declaration
    public void SetChannelAmp(string finger, float mA)
    Parameters
    Type Name Description
    string finger
    float mA

    Amplitude in milliamps.

    SetChannelIPI(string, int)

    Sets per-finger IPI in ms.

    Declaration
    public void SetChannelIPI(string finger, int ms)
    Parameters
    Type Name Description
    string finger
    int ms

    Inter-pulse interval in milliseconds.

    SetChannelPWMax(string, int)

    Sets per-finger maximum pulse width in microseconds.

    Declaration
    public void SetChannelPWMax(string finger, int us)
    Parameters
    Type Name Description
    string finger
    int us

    Maximum pulse width in microseconds.

    SetChannelPWMin(string, int)

    Sets per-finger minimum pulse width in microseconds.

    Declaration
    public void SetChannelPWMin(string finger, int us)
    Parameters
    Type Name Description
    string finger
    int us

    Minimum pulse width in microseconds.

    StartStimulation()

    Starts stimulation on the target and launches streaming when ready.

    Declaration
    public void StartStimulation()
    Remarks

    Broadcasts to all connected WSS units.

    Started()

    True when device transport is started or streaming.

    Declaration
    public bool Started()
    Returns
    Type Description
    bool

    StimulateAnalog(string, int, int, int)

    Sends a direct analog stimulation command using raw parameters.

    Declaration
    public void StimulateAnalog(string finger, int PW, int amp = 3, int IPI = 10)
    Parameters
    Type Name Description
    string finger

    Finger name or channel alias (e.g., "index" or "ch2").

    int PW

    Pulse width in microseconds.

    int amp

    Amplitude in milliamps (default = 3).

    int IPI

    Inter-pulse interval in milliseconds (default = 10).

    StimulateNormalized(string, float)

    Stimulates using a normalized drive value in the range [0, 1].

    Declaration
    public void StimulateNormalized(string finger, float value01)
    Parameters
    Type Name Description
    string finger

    Finger label or alias (e.g., "index", "ring", "ch2").

    float value01

    Normalized drive in [0,1]. Values are clamped.

    Remarks

    Finger aliases are translated to numeric channels before forwarding to the params layer.

    StopStimulation()

    Stops stimulation on the target and, if streaming, stops the background loop.

    Declaration
    public void StopStimulation()
    Remarks

    Broadcasts to all connected WSS units.

    TryGetStimParam(string, out float)

    Tries to read a parameter by dotted key.

    Declaration
    public bool TryGetStimParam(string key, out float v)
    Parameters
    Type Name Description
    string key

    Dotted parameter key.

    float v
    Returns
    Type Description
    bool

    true if found, otherwise false.

    UpdateChannelParams(string, int, int, int)

    Updates per-finger calibration params.

    Declaration
    public void UpdateChannelParams(string finger, int max, int min, int amp)
    Parameters
    Type Name Description
    string finger

    e.g., "index", "ring", or "ch2".

    int max

    Maximum pulse width in microseconds.

    int min

    Minimum pulse width in microseconds.

    int amp

    Amplitude (mA).

    Remarks

    Updates the backing dotted-key parameter entries used by the params layer.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If finger maps to an invalid channel.

    UpdateIPD(int, int)

    Updates inter-phase delay (IPD) for a specific eventID via setup commands (with replies). If currently Streaming, the core pauses streaming, sends the edit, and resumes when done.

    Declaration
    public void UpdateIPD(int ipd, int eventID)
    Parameters
    Type Name Description
    int ipd

    Inter-phase delay in microseconds (clamped internally).

    int eventID

    Event slot to target.

    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    UpdateIPD(int, int, int)

    Updates inter-phase delay (IPD) for a specific eventID via setup commands (with replies). If currently Streaming, the core pauses streaming, sends the edit, and resumes when done.

    Declaration
    public void UpdateIPD(int targetWSS, int ipd, int eventID)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    int ipd

    Inter-phase delay in microseconds (clamped internally).

    int eventID

    Event slot to target.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    WaveformSetup(int, WaveformBuilder, int)

    Defines a custom waveform for the specified event slot on a target unit.

    Declaration
    public void WaveformSetup(int targetWSS, WaveformBuilder wave, int eventID)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    WaveformBuilder wave

    Waveform builder.

    int eventID

    Event slot to target.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    WaveformSetup(WaveformBuilder, int)

    Defines a custom waveform for the specified event slot on all units.

    Declaration
    public void WaveformSetup(WaveformBuilder wave, int eventID)
    Parameters
    Type Name Description
    WaveformBuilder wave

    Waveform builder.

    int eventID

    Event slot to target.

    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    load()

    Loads board settings from non-volatile memory. Implementations should pause streaming if needed, perform the load, then resume.

    Declaration
    public void load()
    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    load(int)

    Loads board settings from non-volatile memory. Implementations should pause streaming if needed, perform the load, then resume.

    Declaration
    public void load(int targetWSS)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    loadWaveform(string, int)

    Loads a waveform definition from external file.

    Declaration
    public void loadWaveform(string fileName, int eventID)
    Parameters
    Type Name Description
    string fileName

    File name or path; “WF.json” suffix is enforced.

    int eventID

    Event slot to target.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    releaseRadio()

    Explicitly releases the radio connection.

    Declaration
    public void releaseRadio()

    request_Configs(int, int, int)

    Requests configuration blocks from the device.

    Declaration
    public void request_Configs(int targetWSS, int command, int id)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    int command

    Command group identifier.

    int id

    Sub-id / selector.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    resetRadio()

    Performs a radio reset by shutting down and re-initializing the connection.

    Declaration
    public void resetRadio()

    updateWaveform(int, int, int)

    Selects a predefined or custom waveform shape from device memory.

    Declaration
    public void updateWaveform(int cathodicWaveform, int anodicWaveform, int eventID)
    Parameters
    Type Name Description
    int cathodicWaveform

    Shape ID for the standard phase.

    int anodicWaveform

    Shape ID for the recharge phase.

    int eventID

    Event slot to modify.

    Remarks

    Slots 0-10 are predefined. Slots 11-13 are custom. No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    updateWaveform(int, int, int, int)

    Selects a predefined or custom waveform shape for a target unit.

    Declaration
    public void updateWaveform(int targetWSS, int cathodicWaveform, int anodicWaveform, int eventID)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    int cathodicWaveform

    Shape ID for the standard phase.

    int anodicWaveform

    Shape ID for the recharge phase.

    int eventID

    Event slot to modify.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    updateWaveform(int, int[], int)

    Updates the waveform parameters for a specific event on a target unit.

    Declaration
    public void updateWaveform(int targetWSS, int[] waveform, int eventID)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    int[] waveform

    Concatenated waveform definition.

    int eventID

    Event slot to target.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    updateWaveform(int, WaveformBuilder, int)

    Updates waveform using JSON-loaded builder definition for a target unit.

    Declaration
    public void updateWaveform(int targetWSS, WaveformBuilder waveform, int eventID)
    Parameters
    Type Name Description
    int targetWSS

    0=broadcast, 1..3=unit index.

    WaveformBuilder waveform

    Prepared WaveformBuilder.

    int eventID

    Event slot to target.

    Remarks

    No-op and logs an error when basic stimulation is unavailable from the wrapped core.

    updateWaveform(int[], int)

    Builds a custom waveform from raw points and schedules the upload for the specified eventID.

    Declaration
    public void updateWaveform(int[] waveform, int eventID)
    Parameters
    Type Name Description
    int[] waveform

    Concatenated waveform definition.

    int eventID

    Event slot to target.

    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    updateWaveform(WaveformBuilder, int)

    Updates waveform using JSON-loaded builder definition for all units.

    Declaration
    public void updateWaveform(WaveformBuilder waveform, int eventID)
    Parameters
    Type Name Description
    WaveformBuilder waveform

    Prepared WaveformBuilder.

    int eventID

    Event slot to target.

    Remarks

    Broadcasts to all connected WSS units. No-op and logs an error when basic stimulation is unavailable.

    In this article
    Back to top Generated by DocFX