# Standard Methods The common device API shared by every Plesty device (connection, I/O and lifecycle). See [Usage](usage.md) for how to use them. ```{eval-rst} .. py:function:: connect() -> bool :no-index: :bdg-secondary-line:`standard` Open the VISA connection to the PM100D. :returns: ``True`` if the connection is successfully open, ``False`` otherwise. ``` ```{eval-rst} .. py:function:: disconnect() -> NoneType :no-index: :bdg-secondary-line:`standard` Close the VISA connection and release all resources. ``` ```{eval-rst} .. py:function:: identity() -> str :no-index: :bdg-secondary-line:`standard` Return the instrument identification string (``\*IDN?``). :returns: Identification string in the form ``'THORLABS,PM100D,,'``. ``` ```{eval-rst} .. py:function:: check_errors() -> list :no-index: :bdg-secondary-line:`standard` Query the error queue and return any active error messages. :returns: Empty list when the device reports no error (``0,"No error"``); a one-element list containing the raw error string otherwise. ``` ```{eval-rst} .. py:function:: check_operatability() -> bool :no-index: :bdg-secondary-line:`standard` Return ``True`` if the VISA session is open. :returns: ``True`` when the traffic manager exists and its session is open. ``` ```{eval-rst} .. py:function:: write(key: str, value: str | float | int | bool) -> bool :no-index: :bdg-secondary-line:`standard` Write a configuration parameter value to the device after validation. :param key: Name of the parameter to write (as listed on the Parameters page). :type key: str :param value: New value; validated against the parameter's type and range before being sent to the device. :type value: str | float | int | bool :returns: ``True`` if the write succeeded, ``False`` otherwise (e.g. a permission check failed). ``` ```{eval-rst} .. py:function:: query(key: str) -> Any :no-index: :bdg-secondary-line:`standard` Query a configuration parameter value from the device. :param key: Name of the parameter to read (as listed on the Parameters page). :type key: str :returns: The parameter's current value, converted to its declared type. ``` ```{eval-rst} .. py:function:: reset() -> NoneType :no-index: :bdg-secondary-line:`standard` Send ``\*RST`` to return the instrument to its factory default state. ``` ```{eval-rst} .. py:function:: clear() -> NoneType :no-index: :bdg-secondary-line:`standard` Send ``\*CLS`` to clear the status registers and error queue. ``` ```{eval-rst} .. py:function:: status() -> DeviceStatus :no-index: :bdg-secondary-line:`standard` Return a point-in-time snapshot of the device's operational state. :returns: The current :class:`DeviceStatus`. ``` ```{eval-rst} .. py:function:: set_data_path(path: str | os.PathLike[str]) -> str :no-index: :bdg-secondary-line:`standard` Set the directory where this device stores acquired data. :param path: Target directory, absolute or relative to the device's default data path. :type path: str | os.PathLike[str] :returns: The directory now in effect, in the configured spelling of its data root — a mapped drive stays a mapped drive; resolution is used for the containment checks only. ``` ```{eval-rst} .. py:function:: get_data_path() -> str :no-index: :bdg-secondary-line:`standard` Return the directory currently used for acquired data. :returns: The directory in effect, in its configured spelling: the last one set by a client, or the device's configured default. The directory is created if missing — the configured default is otherwise never created anywhere (construction is side-effect-free), and vendor software validating the directory rejects one that does not exist (plesty-lib#31). ```