andes.core.service.DeviceFinder#

class andes.core.service.DeviceFinder(u, link, idx_name: str, default_model: str, auto_find: bool | None = True, auto_add: bool | None = True, name: str | None = None, tex_name: str | None = None, info: str | None = None)[source]#

Service for finding idx of devices which are linked to the given devices.

The auto_find parameter controls if the device idx should be automatically looked up. The auto_add parameter controls if the device will be automatically added. The two parameters are not exclusive. One can skip finding the device but automatically adding it.

If auto_find is True and the idx is None, DeviceFinder will look up for the device. If not found and auto_add is True, DevFinder will then automatically add the devices. The idx of the devices that are found or added will be stored to the DeviceFinder instance, so that DeviceFinder can be used like any IdxParam.

Adding new devices are called at the beginning of andes.system.System.setup().

Examples

The IEEEST stabilizer takes an optional parameter busf of the type IdxParam for specifying the connected bus frequency measurement device, which is needed for mode 6. To avoid reimplementing BusFreq within IEEEST, one can do

self.busfreq = DeviceFinder(self.busf,
                            link=self.buss, idx_name='bus',
                            default_model='BusFreq')

where self.busf is for the optional parameter for the idx of bus frequency estimation devices (e.g., BusFreq), self.buss is for the idx of buses that self.busf devices should measure, and idx_name is the name of the BusFreq parameter through which the indices of measured buses are given.

For each None or invalid values in self.busf, a BusFreq device will be created with its bus set to the corresponding value in self.buss. That is, BusFreq.[idx_name].v = [link].

At the end, the DeviceFinder instance will contain the list of BusFreq that are are connected to self.buss, respectively.

In the case of any valid value in self.busf, that is, the value is an existing BusFreq device, DeviceFinder will return it as is without checking if the BusFreq device actually measures the bus specified by self.buss. It allows to use the measurement at a different location, but the user have to perform the data consistency check.

__init__(u, link, idx_name: str, default_model: str, auto_find: bool | None = True, auto_add: bool | None = True, name: str | None = None, tex_name: str | None = None, info: str | None = None)[source]#

Methods

assign_memory(n)

Assign memory for self.v and set the array to zero.

find_or_add(system)

Find or add devices.

get_names()

Return name in a list

Attributes

class_name

Return the class name

n

Return the count of values in self.v.