Search Results for

    Show / Hide Table of Contents

    Class Stimulation

    Provides a Unity-facing API for WSS stimulation using the full params + model stack.

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

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

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

    When forcePort is false, the wrapper auto-selects a serial port. When Stimulation.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.

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

    Dotted parameter path such as stim.ch.1.amp.

    float value

    Parameter value to store.

    Awake()

    Creates the transport, then the full stimulation stack: core -> params layer -> model layer. Detects hardware if forcePort is false.

    Declaration
    public void Awake()
    Remarks

    Uses UnityEngine.Application.streamingAssetsPath as the configuration root for the core, params, and model layers.

    GetAllStimParams()

    Returns a dictionary copy of all current stimulation parameters.

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

    A new dotted-key map representing the current parameter state.

    GetChannelAmp(string)

    Gets per-finger amplitude in milliamps.

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

    GetChannelIPI(string)

    Gets per-finger IPI in milliseconds.

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

    GetChannelPWMax(string)

    Gets per-finger maximum PW in microseconds.

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

    GetChannelPWMin(string)

    Gets per-finger minimum PW in microseconds.

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

    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.

    GetModelConfigCTRL()

    Provides access to the model configuration controller.

    Declaration
    public ModelConfigController GetModelConfigCTRL()
    Returns
    Type Description
    ModelConfigController

    The current model configuration controller owned by the wrapper.

    GetStimIntensity(string)

    Gets the last computed stimulation intensity for a finger.

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

    Finger label or alias.

    Returns
    Type Description
    int

    The last intensity value produced by the active model pipeline for that 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 path.

    Returns
    Type Description
    float

    The current value stored for key.

    IsFingerValid(string)

    Checks whether the specified finger maps to a valid channel index.

    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 valid for the current configuration.

    LoadParamsJson()

    Loads model-layer parameters JSON from the default location.

    Declaration
    public void LoadParamsJson()
    Remarks

    Replaces the current in-memory parameter values with the persisted values.

    LoadParamsJson(string)

    Loads model-layer parameters JSON from a specified path.

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

    A file path, or a directory that the underlying API resolves to its default filename.

    Ready()

    Returns true if the device is initialized and ready.

    Declaration
    public bool Ready()
    Returns
    Type Description
    bool

    true when setup completed successfully and the wrapper can send commands.

    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 (logs an error) if basic stimulation is not supported.

    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 broadcasts, 1..3 select a unit, and any other value maps to unit 1.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    SaveParamsJson()

    Saves model-layer parameters JSON to disk.

    Declaration
    public void SaveParamsJson()
    Remarks

    Persists the current in-memory stimulation parameters using the wrapper's configured default path.

    SetChannelAmp(string, float)

    Sets per-finger amplitude in milliamps.

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

    SetChannelIPI(string, int)

    Sets per-finger IPI in milliseconds.

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

    SetChannelPWMax(string, int)

    Sets per-finger maximum PW in microseconds.

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

    SetChannelPWMin(string, int)

    Sets per-finger minimum PW in microseconds.

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

    StartStimulation()

    Starts stimulation on the target and launches streaming when ready.

    Declaration
    public void StartStimulation()
    Remarks

    Broadcasts to all connected WSS units.

    Started()

    Returns true if stimulation is currently active.

    Declaration
    public bool Started()
    Returns
    Type Description
    bool

    true when the underlying core reports an active stimulation session.

    StimWithMode(string, float)

    Applies model-driven stimulation using the currently configured control mode.

    Declaration
    public void StimWithMode(string finger, float magnitude)
    Parameters
    Type Name Description
    string finger

    Finger label or alias.

    float magnitude

    Normalized or physical magnitude input expected by the current mode.

    Remarks

    The meaning of magnitude depends on the currently loaded model mode.

    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 label or 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).

    Remarks

    Finger aliases are translated to numeric channels before forwarding to the core.

    StimulateNormalized(string, float)

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

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

    Finger label or alias.

    float magnitude

    Normalized drive in the range [0, 1].

    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)

    Attempts to read a parameter by key.

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

    Dotted parameter path.

    float v

    Receives the current value when the key exists.

    Returns
    Type Description
    bool

    true when the key exists; otherwise false.

    UpdateChannelParams(string, int, int, int)

    Updates per-finger calibration parameters used by the params/model layers.

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

    Finger label or alias.

    int max

    Maximum pulse width in microseconds.

    int min

    Minimum pulse width in microseconds.

    int amp

    Amplitude in milliamps.

    Remarks

    Updates the backing dotted-key parameter entries used by the params/model layers.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when 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 (logs an error) if basic stimulation is not supported.

    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. Other values map to unit 1.

    int ipd

    Inter-phase delay in microseconds (clamped internally).

    int eventID

    Event slot to target.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    WaveformSetup(int, WaveformBuilder, int)

    Defines a custom waveform for an event slot on a specific unit.

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

    0 broadcasts, 1..3 select a unit, and any other value maps to unit 1.

    WaveformBuilder wave

    Waveform builder definition to store on the device.

    int eventID

    Target event slot.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    WaveformSetup(WaveformBuilder, int)

    Defines a custom waveform for an event slot on all units.

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

    Waveform builder definition to store on the device.

    int eventID

    Target event slot.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    isModeValid()

    Returns true if the model mode currently loaded is valid.

    Declaration
    public bool isModeValid()
    Returns
    Type Description
    bool

    true when the active model configuration can accept stimulation requests.

    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 (logs an error) if basic stimulation is not supported.

    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. Other values map to unit 1.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    loadWaveform(string, int)

    Loads a waveform definition from a file into the specified event slot.

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

    Waveform file name or path understood by the underlying core.

    int eventID

    Target event slot.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    releaseRadio()

    Explicitly closes the radio connection.

    Declaration
    public void releaseRadio()
    Remarks

    Equivalent to invoking the wrapper shutdown path without disabling the GameObject.

    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. Other values map to unit 1.

    int command

    Command group identifier.

    int id

    Sub-id / selector.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    resetRadio()

    Resets the radio by shutting down and reinitializing the device.

    Declaration
    public void resetRadio()
    Remarks

    Any active stimulation session is interrupted while the connection is restarted.

    updateWaveform(int, int, int)

    Sets event shape IDs directly for the given eventID. Implementations should send setup edits with replies.

    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

    No-op (logs an error) if basic stimulation is not supported.

    updateWaveform(int, int, int, int)

    Selects predefined or custom waveform shapes for a specific WSS target.

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

    0=broadcast, 1..3=unit index. Other values map to unit 1.

    int cathodicWaveform

    Cathodic waveform slot index.

    int anodicWaveform

    Anodic waveform slot index.

    int eventID

    Target event slot.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    updateWaveform(int, int[], int)

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

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

    0=broadcast, 1..3=unit index. Other values map to unit 1.

    int[] waveform

    Concatenated waveform definition.

    int eventID

    Event slot to target.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    updateWaveform(int, WaveformBuilder, int)

    Updates a waveform using a 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 broadcasts, 1..3 select a unit, and any other value maps to unit 1.

    WaveformBuilder waveform

    Waveform builder definition to serialize and send.

    int eventID

    Target event slot.

    Remarks

    No-op (logs an error) if basic stimulation is not supported.

    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 (logs an error) if basic stimulation is not supported.

    updateWaveform(WaveformBuilder, int)

    Uploads a prepared waveform and assigns shapes for eventID.

    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 (logs an error) if basic stimulation is not supported.

    In this article
    Back to top Generated by DocFX