smartinspectpython.siprotocolvariables

Module: siprotocolvariables.py

Revision History

Date Version Description
2023/05/30 3.0.0.0 Initial Version.

@export
class SIProtocolVariables:

Manages connection variables.

This class manages a list of connection variables. Connection variables are placeholders for strings in the Connections of the SmartInspect class. Please see SmartInspect.SetVariable for more information.

Threadsafety:

This class is fully thread-safe.

SIProtocolVariables()

Initializes a new instance of the class.

Count: int

Returns the number of key/value pairs of this collection.

def Add(self, key: str, value: str) -> None:

Adds a new element with a specified key and value to the set of connection variables.

Arguments:
  • key (str): The key of the element.
  • value (str): The value of the element.
Raises:
  • SIArgumentNullException: The key or value argument is null.

This method adds a new element with a given key and value to the set of connection variables. If an element for the given key already exists, the original element's value is not updated.

def Clear(self) -> None:

Removes all key/value pairs of the collection.

def Contains(self, key: str) -> bool:

Tests if the collection contains a value for a given key.

Arguments:
  • key (str): The key of the element to test.
Raises:
  • SIArgumentNullException: The key argument is null.

True if a value exists for the given key and false otherwise.

def Expand(self, connections: str) -> str:

Expands and returns a connections string.

Arguments:
  • connections (str): The connections string to expand and return.
Returns:

The expanded connections string.

Raises:
  • SIArgumentNullException: The connections argument is null.

This method replaces all variables which have previously been added to this collection (with Add or Put) in the given connections string with their respective values and then returns it. Variables in the connections string must have the following form: $variable$.

def Get(self, key: str) -> str:

Returns a value of an element for a given key.

Arguments:
  • key (str): The key whose value to return.
Raises:
  • SIArgumentNullException: The key argument is null.

Either the value for a given key if an element with the given key exists or null otherwise.

def Put(self, key: str, value: str) -> None:

Adds or updates an element with a specified key and value to the set of connection variables.

Arguments:
  • key (str): The key of the element.
  • value (str): The value of the element.
Raises:
  • SIArgumentNullException: The key or value argument is null.

This method adds a new element with a given key and value to the set of connection variables. If an element for the given key already exists, the original element's value is updated.

def Remove(self, key: str) -> None:

Removes an existing element with a given key from this set of connection variables.

Arguments:
  • key (str): The key of the element to remove.
Raises:
  • SIArgumentNullException: The key argument is null.

This method removes the element with the given key from the internal set of connection variables. Nothing happens if no element with the given key can be found.