Class StimParamsConfigController
Provides high-level access to stimulation parameter configuration. Automatically seeds channel entries based on max device count and ensures safe access. Supports dotted keys of form "stim.ch.{N}.{leaf}".
Inheritance
Namespace: Wss.CalibrationModule
Assembly: WSS_Core_Interface.dll
Syntax
public sealed class StimParamsConfigController
Constructors
StimParamsConfigController(string, int)
Constructs a new stimulation parameter controller using the provided JSON path and max WSS value. Automatically creates default channel entries if missing.
Declaration
public StimParamsConfigController(string path, int maxWss)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the JSON configuration file. |
| int | maxWss | Maximum number of WSS devices supported by this instance. |
Properties
MaxWss
Number of WSS units allowed by configuration.
Declaration
public int MaxWss { get; }
Property Value
| Type | Description |
|---|---|
| int |
PerWss
Hardware constant: channels per WSS.
Declaration
public int PerWss { get; }
Property Value
| Type | Description |
|---|---|
| int |
TotalChannels
Total number of channels (ChannelsPerWss × MaxWss).
Declaration
public int TotalChannels { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
AddOrUpdateStimParam(string, float)
Adds or updates a stimulation parameter at the specified dotted key.
Declaration
public void AddOrUpdateStimParam(string key, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Parameter key (e.g., "stim.ch.1.defaultPA"). |
| float | value | Value to assign. |
GetAllStimParams()
Returns all numeric stimulation parameters as a flat dictionary of dotted keys and float values.
Declaration
public Dictionary<string, float> GetAllStimParams()
Returns
| Type | Description |
|---|---|
| Dictionary<string, float> |
GetChannelAmp(int)
Gets the default amplitude (PA) stored for the channel.
Declaration
public float GetChannelAmp(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| float |
GetChannelAmpMode(int)
Gets the configured amplitude-control mode, warning and falling back to PW when invalid.
Declaration
public string GetChannelAmpMode(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| string |
GetChannelDefaultPW(int)
Gets the default pulse width used when PA mode is active.
Declaration
public int GetChannelDefaultPW(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| int |
GetChannelIPI(int)
Gets inter-pulse interval (IPI) for a channel in mili seconds.
Declaration
public int GetChannelIPI(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| int |
GetChannelPAMax(int)
Gets maximum PA (mA) for the channel.
Declaration
public float GetChannelPAMax(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| float |
GetChannelPAMin(int)
Gets minimum PA (mA) for the channel.
Declaration
public float GetChannelPAMin(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| float |
GetChannelPWMax(int)
Gets maximum pulse width for a channel in micro seconds.
Declaration
public int GetChannelPWMax(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| int |
GetChannelPWMin(int)
Gets minimum pulse width for a channel in micro seconds.
Declaration
public int GetChannelPWMin(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| int |
GetStimParam(string)
Retrieves a stimulation parameter value.
Declaration
public float GetStimParam(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Parameter key (e.g., "stim.ch.1.maxPW"). |
Returns
| Type | Description |
|---|---|
| float | Parameter value as float. |
IsChannelInRange(int)
Checks whether a channel index is within the valid range.
Declaration
public bool IsChannelInRange(int ch)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch |
Returns
| Type | Description |
|---|---|
| bool |
LoadParamsJson()
Reloads the current context file (same path used at construction or the last Load(path)). Reinstantiates the config to re-read JSON from disk, then ensures channel template exists.
Declaration
public void LoadParamsJson()
LoadParamsJson(string)
Loads a new context file. If path is a directory,
uses "stimParams.json" within it. Replaces the active config and backfills the template.
Declaration
public void LoadParamsJson(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Absolute/relative file path or directory. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the path is null or whitespace. |
SaveParamsJson()
Persists the current stimulation params to disk using the underlying config's Save(). Thread-safe via the config layer.
Declaration
public void SaveParamsJson()
SetAllChannelsAmpMode(string)
Sets the amplitude-control mode for every channel in one call.
Declaration
public void SetAllChannelsAmpMode(string mode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mode |
SetChannelAmp(int, float)
Sets the default amplitude (PA) for a channel. Used when PW is the controlled axis.
Declaration
public void SetChannelAmp(int ch, float mA)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| float | mA |
SetChannelAmpMode(int, string)
Sets the amplitude-control mode ("PW" or "PA") for the specified channel.
Declaration
public void SetChannelAmpMode(int ch, string mode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| string | mode |
SetChannelDefaultPW(int, int)
Sets the default pulse width used when PA is the controlled axis.
Declaration
public void SetChannelDefaultPW(int ch, int us)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| int | us |
SetChannelIPI(int, int)
Sets inter-pulse interval (IPI) for the specified channel in mili seconds.
Declaration
public void SetChannelIPI(int ch, int ms)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| int | ms |
SetChannelPAMax(int, float)
Sets maximum PA (mA) for the specified channel.
Declaration
public void SetChannelPAMax(int ch, float mA)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| float | mA |
SetChannelPAMin(int, float)
Sets minimum PA (mA) for the specified channel.
Declaration
public void SetChannelPAMin(int ch, float mA)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| float | mA |
SetChannelPWMax(int, int)
Sets maximum pulse width for the specified channel in micro seconds.
Declaration
public void SetChannelPWMax(int ch, int us)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| int | us |
SetChannelPWMin(int, int)
Sets minimum pulse width for the specified channel in micro seconds.
Declaration
public void SetChannelPWMin(int ch, int us)
Parameters
| Type | Name | Description |
|---|---|---|
| int | ch | |
| int | us |
TryGetStimParam(string, out float)
Attempts to retrieve a stimulation parameter value without throwing.
Declaration
public bool TryGetStimParam(string key, out float value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Parameter key. |
| float | value | Output value if found. |
Returns
| Type | Description |
|---|---|
| bool | True if the parameter exists. |