Skip to content

Context

HVContext

CAEN HV Module Context

Usage:
with HVContext("") as hv:
    hv.read(...)

__enter__(self) special

Enter context

Initializes module by calling the start() method

Source code in pycaenhv/context.py
def __enter__(self):
    """ Enter context

    Initializes module by calling the `start()` method
    """
    self.start()
    return self

__exit__(self, type, value, traceback) special

Exit context.

Executes close() method to de-initialize the module before exit.

Source code in pycaenhv/context.py
def __exit__(self, type, value, traceback):
    """ Exit context.

    Executes `close()` method to de-initialize the module before exit.
    """
    self.close()

close(self)

Deinitialize the system

Source code in pycaenhv/context.py
def close(self) -> None:
    """ Deinitialize the system
    """
    deinit_system(self.handle)

start(self)

Initialize module given the configuration in the constructor.

Source code in pycaenhv/context.py
def start(self):
    """ Initialize module given the configuration in the constructor.
    """
    system = CAENHV_SYSTEM_TYPE[self.system.upper()]
    link = LinkType[self.link.upper()]
    self.handle = init_system(system, link, self.argument, self.user,
                              self.password)