Search Results for

    Show / Hide Table of Contents

    Class ModelParamsLayer

    Model-driven layer (P/PD) that sits on top of an existing params layer. Computes controller output from magnitudes and stimulates via the wrapped core.

    Inheritance
    object
    ModelParamsLayer
    Implements
    IModelParamsCore
    IStimParamsCore
    IStimulationCore
    Namespace: Wss.ModelModule
    Assembly: WSS_Core_Interface.dll
    Syntax
    public sealed class ModelParamsLayer : IModelParamsCore, IStimParamsCore, IStimulationCore

    Constructors

    ModelParamsLayer(IStimParamsCore, string)

    Initializes a model layer over an existing params/core implementation.

    Declaration
    public ModelParamsLayer(IStimParamsCore inner, string modelPathOrDir)
    Parameters
    Type Name Description
    IStimParamsCore inner

    Wrapped stimulation params core.

    string modelPathOrDir

    Model JSON file path or directory.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when inner is null.

    Methods

    AddOrUpdateStimParam(string, float)

    Adds or updates a parameter by dotted key. Examples: stim.ch.1.defaultPA, stim.ch.2.minPW, stim.ch.3.maxPW, stim.ch.4.IPI.

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

    Dotted parameter key.

    float value

    Value to set.

    Dispose()

    Declaration
    public void Dispose()

    GetAllStimParams()

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

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

    Dictionary mapping dotted keys to parameter values.

    GetChannelAmp(int)

    Gets the per-channel default amplitude (PA) in mA.

    Declaration
    public float GetChannelAmp(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Default amplitude in milliamps.

    GetChannelAmpMode(int)

    Gets the current amplitude-control mode for a channel.

    Declaration
    public string GetChannelAmpMode(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    string

    "PW" or "PA".

    GetChannelDefault(int)

    Gets the non-controlled axis default (PA when PW mode, PW when PA mode).

    Declaration
    public float GetChannelDefault(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Default value expressed in the non-controlled axis units (µs for PA mode).

    GetChannelDefaultPW(int)

    Gets the per-channel default pulse width in µs.

    Declaration
    public int GetChannelDefaultPW(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    int

    Default pulse width in microseconds.

    GetChannelIPI(int)

    Gets per-channel IPI in ms.

    Declaration
    public int GetChannelIPI(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    int

    Inter-pulse interval in milliseconds.

    GetChannelMax(int)

    Gets the active-control maximum (µs when PW mode, mA when PA mode).

    Declaration
    public float GetChannelMax(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Maximum value in the active axis units (µs for PW mode).

    GetChannelMin(int)

    Gets the active-control minimum (µs when PW mode, mA when PA mode).

    Declaration
    public float GetChannelMin(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Minimum value in the active axis units (µs for PW mode).

    GetChannelPAMax(int)

    Gets per-channel maximum PA in mA.

    Declaration
    public float GetChannelPAMax(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Maximum amplitude in milliamps.

    GetChannelPAMin(int)

    Gets per-channel minimum PA in mA.

    Declaration
    public float GetChannelPAMin(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    float

    Minimum amplitude in milliamps.

    GetChannelPWMax(int)

    Gets per-channel maximum pulse width in µs.

    Declaration
    public int GetChannelPWMax(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    int

    Maximum pulse width in microseconds.

    GetChannelPWMin(int)

    Gets per-channel minimum pulse width in µs.

    Declaration
    public int GetChannelPWMin(int ch)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    Returns
    Type Description
    int

    Minimum pulse width in microseconds.

    GetCoreConfigController()

    Gets the JSON-backed stimulation configuration controller currently used by this core.

    Declaration
    public CoreConfigController GetCoreConfigController()
    Returns
    Type Description
    CoreConfigController

    The active CoreConfigController instance that provides read/write access to stimulation parameters and constants loaded from the configuration file.

    Remarks

    Returned reference is live, not a copy and thread safe.

    GetModelConfigController()

    Returns the model-layer configuration controller used to read and write model constants (e.g., proportional/derivative gains, offsets, and mode selection).

    Declaration
    public ModelConfigController GetModelConfigController()
    Returns
    Type Description
    ModelConfigController

    The active ModelConfigController instance.

    Remarks

    Use this to query constants like PModeProportional or to persist model settings.

    Examples
    var mc = model.GetModelConfigController();
    float kp = mc.GetConstant("PModeProportional");
    mc.SetConstant("PDModeDerivative", 0.15f);
    mc.SaveJson();

    GetStimIntensity(int)

    Returns the most recently computed stimulation intensity for the channel. For PW-driven systems, this is the last pulse width (µs) sent by StimulateNormalized(int, float).

    Declaration
    public float GetStimIntensity(int channel)
    Parameters
    Type Name Description
    int channel

    1-based logical channel.

    Returns
    Type Description
    float

    Most recent intensity value (µs or mA depending on mode).

    GetStimParam(string)

    Reads a parameter by dotted key. Throws if the key is missing.

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

    Dotted parameter key.

    Returns
    Type Description
    float

    Parameter value as float.

    GetStimParamsConfigController()

    Returns the parameters/configuration controller for stimulation params.

    Declaration
    public StimParamsConfigController GetStimParamsConfigController()
    Returns
    Type Description
    StimParamsConfigController

    The active StimParamsConfigController.

    Initialize()

    Initializes the core: loads JSON config, prepares buffers, and begins connecting to the transport. Non-blocking; call Tick() to advance state.

    Declaration
    public void Initialize()

    IsChannelInRange(int)

    Returns true if ch is within the valid channel range.

    Declaration
    public bool IsChannelInRange(int ch)
    Parameters
    Type Name Description
    int ch

    1-based channel to check.

    Returns
    Type Description
    bool

    IsModeValid()

    Validates the current controller mode from model config (e.g., P or PD).

    Declaration
    public bool IsModeValid()
    Returns
    Type Description
    bool

    true if the mode is supported; otherwise false.

    Examples
    if (!model.IsModeValid()) { /* fallback or warn */ }

    LoadConfigFile()

    Reloads the stimulation JSON configuration from disk into memory.

    Declaration
    public void LoadConfigFile()

    LoadParamsJson()

    Loads the stimulation-parameters JSON from the default location.

    Declaration
    public void LoadParamsJson()

    LoadParamsJson(string)

    Loads the stimulation-parameters JSON from a specific file path or directory.

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

    File path or directory.

    Ready()

    True when the core is ready to accept start stimulation.

    Declaration
    public bool Ready()
    Returns
    Type Description
    bool

    SaveParamsJson()

    Saves the current stimulation-parameters JSON to disk.

    Declaration
    public void SaveParamsJson()

    SetAllChannelsAmpMode(string)

    Sets the same amplitude-control mode for all channels.

    Declaration
    public void SetAllChannelsAmpMode(string mode)
    Parameters
    Type Name Description
    string mode

    Target amplitude mode string.

    SetChannelAmp(int, float)

    Sets the per-channel default amplitude (PA) in mA.

    Declaration
    public void SetChannelAmp(int ch, float mA)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float mA

    Amplitude in milliamps.

    SetChannelAmpMode(int, string)

    Sets the amplitude-control mode ("PW"/"PA") for a channel.

    Declaration
    public void SetChannelAmpMode(int ch, string mode)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    string mode

    Target amplitude mode string.

    SetChannelDefault(int, float)

    Sets the non-controlled axis default (PA when PW mode, PW when PA mode).

    Declaration
    public void SetChannelDefault(int ch, float value)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float value

    Default value expressed in the non-controlled axis units (µs for PA mode).

    SetChannelDefaultPW(int, int)

    Sets the per-channel default pulse width in µs.

    Declaration
    public void SetChannelDefaultPW(int ch, int us)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    int us

    Default pulse width in microseconds.

    SetChannelIPI(int, int)

    Sets per-channel IPI in ms.

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

    1-based logical channel.

    int ms

    Inter-pulse interval in milliseconds.

    SetChannelMax(int, float)

    Sets the active-control maximum for a channel (µs when PW mode, mA when PA mode).

    Declaration
    public void SetChannelMax(int ch, float value)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float value

    Maximum value in the active axis units (µs for PW mode).

    SetChannelMin(int, float)

    Sets the active-control minimum for a channel (µs when PW mode, mA when PA mode).

    Declaration
    public void SetChannelMin(int ch, float value)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float value

    Minimum value in the active axis units (µs for PW mode).

    SetChannelPAMax(int, float)

    Sets per-channel maximum PA in mA.

    Declaration
    public void SetChannelPAMax(int ch, float mA)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float mA

    Maximum amplitude in milliamps.

    SetChannelPAMin(int, float)

    Sets per-channel minimum PA in mA.

    Declaration
    public void SetChannelPAMin(int ch, float mA)
    Parameters
    Type Name Description
    int ch

    1-based logical channel.

    float mA

    Minimum amplitude in milliamps.

    SetChannelPWMax(int, int)

    Sets per-channel maximum pulse width in µs.

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

    1-based logical channel.

    int us

    Maximum pulse width in microseconds.

    SetChannelPWMin(int, int)

    Sets per-channel minimum pulse width in µs.

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

    1-based logical channel.

    int us

    Minimum pulse width in microseconds.

    Shutdown()

    Stops streaming, attempts to zero outputs, disconnects transport, and releases resources. Safe to call multiple times.

    Declaration
    public void Shutdown()

    StartStim(WssTarget)

    Starts stimulation on the target and launches streaming when ready.

    Declaration
    public void StartStim(WssTarget t)
    Parameters
    Type Name Description
    WssTarget t

    Started()

    True when device transport is started or streaming.

    Declaration
    public bool Started()
    Returns
    Type Description
    bool

    StimWithMode(int, float)

    Computes a pulse width from magnitude using the active controller mode and stimulates the resolved channel. Updates cached per-channel PW and amp internally.

    Declaration
    public void StimWithMode(int ch, float magnitudeIn)
    Parameters
    Type Name Description
    int ch

    1-based channel index.

    float magnitudeIn
    Examples
    model.StimWithMode("index", 0.42f);     // P/PD mapping → PW → StimulateAnalog
    model.StimWithMode("ch3",   0.75f);

    StimulateAnalog(int, int, float, int)

    Caches per-channel amplitude, pulse width, and IPI. No I/O here; the streaming loop pushes cached values to the device.

    Declaration
    public void StimulateAnalog(int ch, int pw, float amp, int ipi)
    Parameters
    Type Name Description
    int ch
    int pw
    float amp

    Amplitude (mA domain; mapped to device scale during streaming).

    int ipi

    StimulateNormalized(int, float)

    Computes a pulse width from a normalized value in [0,1] using per-channel parameters (minPW, maxPW, amp, IPI) and forwards the result to the core. Implementations clamp the input to [0,1] and cache the last PW sent.

    Declaration
    public void StimulateNormalized(int channel, float normalizedValue)
    Parameters
    Type Name Description
    int channel

    1-based logical channel.

    float normalizedValue

    Normalized drive in [0,1].

    StopStim(WssTarget)

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

    Declaration
    public void StopStim(WssTarget t)
    Parameters
    Type Name Description
    WssTarget t

    Tick()

    Advances the internal state machine (e.g., Connecting → SettingUp → Ready → Streaming). Call regularly from the main loop.

    Declaration
    public void Tick()

    TryGetBasic(out IBasicStimulation)

    Exposes the optional BASIC capability if available from the wrapped core. Returns true and sets basic if supported.

    Declaration
    public bool TryGetBasic(out IBasicStimulation basic)
    Parameters
    Type Name Description
    IBasicStimulation basic

    Out parameter for the BASIC interface.

    Returns
    Type Description
    bool

    true when BASIC is available, otherwise false.

    TryGetStimParam(string, out float)

    Tries to read a parameter by dotted key.

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

    Dotted parameter key.

    float value

    Out value if the key exists.

    Returns
    Type Description
    bool

    true if found, otherwise false.

    ZeroOutStim(WssTarget)

    Sends a zero-out command. Does not alter cached values.

    Declaration
    public void ZeroOutStim(WssTarget t)
    Parameters
    Type Name Description
    WssTarget t

    Implements

    IModelParamsCore
    IStimParamsCore
    IStimulationCore

    Extension Methods

    StimParamsBasicExtensions.LoadBoard(IStimParamsCore, WssTarget)
    StimParamsBasicExtensions.LoadWaveform(IStimParamsCore, string, int)
    StimParamsBasicExtensions.RequestConfigs(IStimParamsCore, int, int, WssTarget)
    StimParamsBasicExtensions.SaveBoard(IStimParamsCore, WssTarget)
    StimParamsBasicExtensions.TryUpdateWaveform(IStimParamsCore, WaveformBuilder, int, WssTarget)
    StimParamsBasicExtensions.UpdateEventShape(IStimParamsCore, int, int, int, WssTarget)
    StimParamsBasicExtensions.UpdateWaveform(IStimParamsCore, int[], int, WssTarget)
    StimParamsBasicExtensions.UpdateWaveform(IStimParamsCore, WaveformBuilder, int, WssTarget)
    StimParamsBasicExtensions.WaveformSetup(IStimParamsCore, WaveformBuilder, int, WssTarget)
    In this article
    Back to top Generated by DocFX