Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3bdf708
default value: Update nislscapi_full.json
zoechanzy Aug 6, 2026
077ce2a
default value: Update files to consume default values
zoechanzy Aug 6, 2026
646ecac
default value: Add default value for library parameter
zoechanzy Aug 6, 2026
7dd42d6
default value: Update unit tests for new defaults
zoechanzy Aug 7, 2026
14f3ae7
default value: Update examples for new defaults
zoechanzy Aug 7, 2026
30845a7
fix: convert integer defaults to float for double and TimeoutSeconds …
zoechanzy Aug 7, 2026
21b5669
fix: use named parameters for get_function_parameter_list
zoechanzy Aug 12, 2026
e906a73
default value: Add constants for resource aliases
zoechanzy Aug 13, 2026
4175108
default value: Update nislscapi_full.json
zoechanzy Aug 17, 2026
2f4cb6c
default value: Update unit tests
zoechanzy Aug 17, 2026
5fe1708
default value: Update examples
zoechanzy Aug 18, 2026
985f24b
default value: Add get_default_alias_constants in function_helpers.py
zoechanzy Aug 20, 2026
dffcc1c
default value: Update nislscapi_full.json
zoechanzy Aug 20, 2026
ed44a8d
examples: Remove reservation_group from check_chassis_battery to alig…
junliang-tan Aug 24, 2026
d00b777
examples: Restore original parameter ordering and update to use DEFAU…
junliang-tan Aug 24, 2026
487019b
examples: Remove reservation_access and reservation_group from reset_…
junliang-tan Aug 24, 2026
b7c6f0b
examples: Remove reservation_group from show_command_and_property_tre…
junliang-tan Aug 24, 2026
0df81ec
examples: Remove device_names from reset_device to align with the Lab…
junliang-tan Aug 24, 2026
abc88dd
examples: Update show_command_and_property_tree to use the default de…
junliang-tan Aug 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions examples/check_chassis_battery.py
Comment thread
zoechanzy marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import click

from nislsc import Session
from nislsc.constants import ReservationAccess
from nislsc.constants import DEFAULT_PHYS_CHANS_ALIAS, ReservationAccess


@click.command()
Expand All @@ -22,29 +22,22 @@ def main(chassis_name: str) -> None:
""" # noqa: D301
try:
physical_channel_names = f"{chassis_name}/BatteryVoltageSensor"
connection_timeout = 10.0
reservation_access = ReservationAccess.READ_ONLY
reservation_group = "admin"
reservation_timeout = 10.0

with Session.initialize_session_with_physical_channels(
None,
physical_channel_names=physical_channel_names,
connection_timeout=connection_timeout,
reservation_access=reservation_access,
reservation_group=reservation_group,
reservation_timeout=reservation_timeout,
) as session:
sensor_lower_critical = session.get_physical_channel_property_double(
physical_channel_names=physical_channel_names,
physical_channel_names=DEFAULT_PHYS_CHANS_ALIAS,
property_name="SensorLowerCritical",
)
sensor_reading = session.get_physical_channel_property_double(
physical_channel_names=physical_channel_names,
physical_channel_names=DEFAULT_PHYS_CHANS_ALIAS,
property_name="SensorReading",
)
health_state = session.get_physical_channel_property_string(
physical_channel_names=physical_channel_names,
physical_channel_names=DEFAULT_PHYS_CHANS_ALIAS,
property_name="HealthState",
)
needs_replacement = sensor_reading < sensor_lower_critical
Comment thread
junliang-tan marked this conversation as resolved.
Expand Down
13 changes: 1 addition & 12 deletions examples/reset_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import click

from nislsc import Session
from nislsc.constants import ReservationAccess


@click.command()
Expand All @@ -22,20 +21,10 @@ def main(device_names: str) -> None:
reset_device SLSC-12001-XXXXXXXX-Mod1,SLSC-12001-XXXXXXXX-Mod2
""" # noqa: D301
try:
connection_timeout = 10.0
reservation_access = ReservationAccess.READ_ONLY
reservation_group = "admin"
reservation_timeout = 10.0

with Session.initialize_session_with_devices(
None,
device_names=device_names,
connection_timeout=connection_timeout,
reservation_access=reservation_access,
reservation_group=reservation_group,
reservation_timeout=reservation_timeout,
) as session:
session.reset_devices(device_names)
session.reset_devices()
print(f"Reset command sent to device(s) {device_names}")
except Exception as e:
click.echo(f"Error: {e}", err=True)
Expand Down
18 changes: 6 additions & 12 deletions examples/show_command_and_property_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from nislsc.constants import (
CommandProperty,
DataType,
DEFAULT_DEVICES_ALIAS,
DeviceProperty,
PhysicalChannelProperty,
PropertyAccess,
Expand Down Expand Up @@ -49,18 +50,11 @@ def get_command_and_property_tree(device_name: str) -> dict:
Returns:
Dictionary containing the command and property tree of the device.
"""
connection_timeout = 10.0
reservation_access = ReservationAccess.READ_ONLY
reservation_group = "admin"
reservation_timeout = 10.0

with Session.initialize_session_with_devices(
None,
device_name,
connection_timeout,
reservation_access,
reservation_group,
reservation_timeout,
device_names=device_name,
reservation_access=reservation_access,
) as session:

data = {
Expand All @@ -70,17 +64,17 @@ def get_command_and_property_tree(device_name: str) -> dict:
}

device_commands = session.get_device_property_string_array(
device_name,
DEFAULT_DEVICES_ALIAS,
DeviceProperty.COMMANDS,
)

device_properties = session.get_device_property_string_array(
device_name,
DEFAULT_DEVICES_ALIAS,
DeviceProperty.PROPERTIES,
)

device_physical_channels = session.get_device_property_string_array(
device_name,
DEFAULT_DEVICES_ALIAS,
DeviceProperty.PHYSICAL_CHANNELS,
)

Expand Down
20 changes: 20 additions & 0 deletions generated/nislsc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@
class StrEnum(str, Enum):
"""StrEnum fallback for Python versions < 3.11."""

CONNECTED_DEVICES_ALIAS = "$ConnectedDevices"
"""A resource alias representing the session's connected devices."""

DEFAULT_DEVICES_ALIAS = "$DefaultDevices"
"""A resource alias representing the session's default devices."""

DEFAULT_NVMEM_AREAS_ALIAS = "$DefaultNVMEMAreas"
"""A resource alias representing the session's default NVMEM areas."""

DEFAULT_PHYS_CHANS_ALIAS = "$DefaultPhysChans"
"""A resource alias representing the session's default physical channels."""

RESERVED_DEVICES_ALIAS = "$ReservedDevices"
"""A resource alias representing the session's reserved devices."""

SESSION_ALIAS = "$Session"
"""A resource alias for accessing session properties."""

SYSTEM_ALIAS = "$System"
"""A resource alias for accessing system properties."""

class ReservationAccess(Enum):
"""Define SLSC reservation access modes."""
Expand Down
36 changes: 18 additions & 18 deletions generated/nislsc/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from typing_extensions import Self

from nislsc.constants import ReservationAccess, TableScaleCoercion
from nislsc.constants import ReservationAccess, TableScaleCoercion, DEFAULT_DEVICES_ALIAS, DEFAULT_NVMEM_AREAS_ALIAS, DEFAULT_PHYS_CHANS_ALIAS
from nislsc.library import Library


Expand Down Expand Up @@ -67,7 +67,7 @@ def close(self) -> None:
self._owns_library = False

@classmethod
def initialize_session_with_devices(cls, library: Library | None, device_names: str, connection_timeout: float, reservation_access: ReservationAccess, reservation_group: str, reservation_timeout: float) -> Self:
def initialize_session_with_devices(cls, device_names: str, library: Library | None = None, connection_timeout: float = -1.0, reservation_access: ReservationAccess = ReservationAccess.READ_WRITE, reservation_group: str = '', reservation_timeout: float = -1.0) -> Self:
"""Initialize an SLSC session with one or multiple devices.

The session opens network connections for devices. If reservationAccess
Expand Down Expand Up @@ -110,7 +110,7 @@ def initialize_session_with_devices(cls, library: Library | None, device_names:
return cls(library, session_handle, owns_library)

@classmethod
def initialize_session_with_nvmem_areas(cls, library: Library | None, nvmem_area_names: str, connection_timeout: float, reservation_access: ReservationAccess, reservation_group: str, reservation_timeout: float) -> Self:
def initialize_session_with_nvmem_areas(cls, nvmem_area_names: str, library: Library | None = None, connection_timeout: float = -1.0, reservation_access: ReservationAccess = ReservationAccess.READ_WRITE, reservation_group: str = '', reservation_timeout: float = -1.0) -> Self:
"""Initialize an SLSC session with one or multiple NVMEM areas.

The session opens network connections for NVMEM areas. If
Expand Down Expand Up @@ -155,7 +155,7 @@ def initialize_session_with_nvmem_areas(cls, library: Library | None, nvmem_area
return cls(library, session_handle, owns_library)

@classmethod
def initialize_session_with_physical_channels(cls, library: Library | None, physical_channel_names: str, connection_timeout: float, reservation_access: ReservationAccess, reservation_group: str, reservation_timeout: float) -> Self:
def initialize_session_with_physical_channels(cls, physical_channel_names: str, library: Library | None = None, connection_timeout: float = -1.0, reservation_access: ReservationAccess = ReservationAccess.READ_WRITE, reservation_group: str = '', reservation_timeout: float = -1.0) -> Self:
"""Initialize an SLSC session with one or multiple physical channels.

The session opens network connections for devices that correspond to the
Expand Down Expand Up @@ -203,7 +203,7 @@ def initialize_session_with_physical_channels(cls, library: Library | None, phys
return cls(library, session_handle, owns_library)

@classmethod
def initialize_session_without_resources(cls, library: Library | None) -> Self:
def initialize_session_without_resources(cls, library: Library | None = None) -> Self:
"""Initialize an SLSC session without specifying any resources or
opening any network connections.

Expand Down Expand Up @@ -239,7 +239,7 @@ def abort_session(self) -> None:
"""
self._interpreter.abort_session(self._session_handle)

def log_in(self, chassis_name: str, username: str, password: str, connection_timeout: float, save_credentials_to_disk: bool) -> None:
def log_in(self, chassis_name: str, username: str, password: str, save_credentials_to_disk: bool, connection_timeout: float = -1.0) -> None:
"""Attempt to connect and log in to the specified SLSC chassis.

If successful, the username and password are cached on the local system
Expand Down Expand Up @@ -297,7 +297,7 @@ def log_out(self, chassis_name: str) -> None:
"""
self._interpreter.log_out(self._session_handle, chassis_name)

def connect_to_devices(self, device_names: str, connection_timeout: float) -> None:
def connect_to_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS, connection_timeout: float = -1.0) -> None:
"""Open network connections for the specified device(s), sharing
connections to the same SLSC chassis.

Expand All @@ -318,7 +318,7 @@ def connect_to_devices(self, device_names: str, connection_timeout: float) -> No
"""
self._interpreter.connect_to_devices(self._session_handle, device_names, connection_timeout)

def disconnect_from_devices(self, device_names: str) -> None:
def disconnect_from_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS) -> None:
"""Close network connections for the specified devices.

When multiple devices share a network connection because they are in the
Expand All @@ -332,7 +332,7 @@ def disconnect_from_devices(self, device_names: str) -> None:
"""
self._interpreter.disconnect_from_devices(self._session_handle, device_names)

def connect_to_chassis_by_address(self, address: str, username: str, password: str, connection_timeout: float) -> str:
def connect_to_chassis_by_address(self, address: str, username: str, password: str, connection_timeout: float = -1.0) -> str:
"""Open a network connection for a chassis by the specified IP address
or hostname.

Expand All @@ -353,7 +353,7 @@ def connect_to_chassis_by_address(self, address: str, username: str, password: s
chassis_name = self._interpreter.connect_to_chassis_by_address(self._session_handle, address, username, password, connection_timeout)
return chassis_name

def reserve_devices(self, device_names: str, reservation_access: ReservationAccess, reservation_group: str, reservation_timeout: float) -> None:
def reserve_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS, reservation_access: ReservationAccess = ReservationAccess.READ_WRITE, reservation_group: str = '', reservation_timeout: float = -1.0) -> None:
"""Reserve the specified device(s), which prevents other sessions from
accessing them.

Expand All @@ -379,7 +379,7 @@ def reserve_devices(self, device_names: str, reservation_access: ReservationAcce
"""
self._interpreter.reserve_devices(self._session_handle, device_names, reservation_access, reservation_group, reservation_timeout)

def unreserve_devices(self, device_names: str) -> None:
def unreserve_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS) -> None:
"""Unreserve the specified device(s), allowing other sessions to access
them.

Expand All @@ -390,7 +390,7 @@ def unreserve_devices(self, device_names: str) -> None:
"""
self._interpreter.unreserve_devices(self._session_handle, device_names)

def reset_devices(self, device_names: str) -> None:
def reset_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS) -> None:
"""Reset the specified device(s) to the default state.

This function sends the specified devices a hardware reset signal,
Expand Down Expand Up @@ -425,7 +425,7 @@ def rename_device(self, device_name: str, new_device_name: str) -> None:
"""
self._interpreter.rename_device(self._session_handle, device_name, new_device_name)

def update_system_configuration_file(self, chassis_name: str, connection_timeout: float) -> None:
def update_system_configuration_file(self, chassis_name: str, connection_timeout: float = -1.0) -> None:
"""Update the information of the specified chassis and its modules in
the local configuration file.

Expand All @@ -442,7 +442,7 @@ def update_system_configuration_file(self, chassis_name: str, connection_timeout
"""
self._interpreter.update_system_configuration_file(self._session_handle, chassis_name, connection_timeout)

def add_network_chassis(self, address: str, username: str, password: str, connection_timeout: float) -> str:
def add_network_chassis(self, address: str, username: str, password: str, connection_timeout: float = -1.0) -> str:
"""Connect to the specified network chassis, adds the chassis and its
modules to the system, and saves them to the local configuration file.

Expand Down Expand Up @@ -1668,7 +1668,7 @@ def set_physical_channel_property_uint64_array(self, physical_channel_names: str
"""
self._interpreter.set_physical_channel_property_uint64_array(self._session_handle, physical_channel_names, property_name, property_value)

def commit_properties_for_devices(self, device_names: str) -> None:
def commit_properties_for_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS) -> None:
"""Commit all device or physical channels properties with pending
changes to hardware for the specified device(s) and the physical
channels that they contain.
Expand All @@ -1683,7 +1683,7 @@ def commit_properties_for_devices(self, device_names: str) -> None:
"""
self._interpreter.commit_properties_for_devices(self._session_handle, device_names)

def commit_properties_for_physical_channels(self, physical_channel_names: str) -> None:
def commit_properties_for_physical_channels(self, physical_channel_names: str = DEFAULT_PHYS_CHANS_ALIAS) -> None:
"""Commit all physical channel properties with pending changes to
hardware for the specified physical channel(s).

Expand Down Expand Up @@ -2764,7 +2764,7 @@ def set_nvmem_bytes(self, nvmem_area: str, nvmem_address: int, bytes_data: bytes
"""
self._interpreter.set_nvmem_bytes(self._session_handle, nvmem_area, nvmem_address, bytes_data, serial_number, password)

def commit_nvmem_areas(self, nvmem_area_names: str) -> None:
def commit_nvmem_areas(self, nvmem_area_names: str = DEFAULT_NVMEM_AREAS_ALIAS) -> None:
"""Commit pending changes to hardware for the specified NVMEM area(s).

Args:
Expand All @@ -2774,7 +2774,7 @@ def commit_nvmem_areas(self, nvmem_area_names: str) -> None:
"""
self._interpreter.commit_nvmem_areas(self._session_handle, nvmem_area_names)

def commit_nvmem_for_devices(self, device_names: str) -> None:
def commit_nvmem_for_devices(self, device_names: str = DEFAULT_DEVICES_ALIAS) -> None:
"""Commit pending changes to hardware for all NVMEM areas on the
specified device(s).

Expand Down
Loading