ScriptDeviceRepository¶
- class ScriptDeviceRepository.ScriptDeviceRepository¶
Bases:
objectDevice respository.
- property sources¶
Get the repository sources of the device repository.
- Return type:
- create_device_identification(type, id, version)¶
Factory method for a
DeviceIdobject.- Parameters:
type (int) – The device type.
id (str) – The device id.
- Return type:
str
- Returns:
A new
DeviceIdobject with the provided values.
- create_module_identification(type, id, version, module_id)¶
Factory method for a
ModuleIdobject.- Parameters:
type (int) – The device type.
id (str) – The device id.
module_id (str) – The module id.
- Return type:
str
- Returns:
A new
ModuleIdobject with the provided values.
- import_device(path: str, source: ScriptRepositorySource, converter_factory_guid: Guid, save_device_cache: bool = True)¶
Import a device description file into a repository.
Warning
The original C# function that is called with this method contains 3 overloads. It is strongly advised to pass all arguments with their respective keywords.
stream,path, andsource_pathare not actually optional, they just aren’t required in every overload. Pass them if your overload needs them!Convert a foreign device description file and import the result into a repository.
List of known converter factories:¶ {C633F245-876F-45E8-AAB4-3FBD994C08B8}
Use as default because all available converters are tried
{3992C588-7BDB-4A7C-908D-F444808D8CD2}
XML files of EtherCAT
{6066AEF4-F19A-41ac-A249-721BDAE32D40}
GSDML files of Profinet IO
{CDDE0374-9EFD-401e-93C8-F19443FB60ED}
XML files of Sercos3
{1ce4a9c1-37d3-496c-9e80-cd99ad3807ee}
EDS files of CANbus
- Parameters:
path (str) – The file that contains the device description. This must be a valid device description file. Other types of device descriptions must be imported by special plug-ins.
source (
ScriptRepositorySource) – The repository source where the device should be stored. This parameter may beNone, in which case the default repository source is used. The repository source must be one of the sources defined insources.converter_factory_guid (str) – The guid of the converter to import a foreign device description. For example CANopen EDS files.
save_device_cache (bool) – If
True, after removing the device the device cache is also written. IfFalse, the device cache is not written. If many devices are removed, this is much faster.
- Return type:
DeviceId- Returns:
The ID of the imported device description.
- import_vendor_description(path: str, source: ScriptRepositorySource)¶
Import a device description file into a repository.
Warning
The original C# function that is called with this method contains 2 overloads. It is strongly advised to pass all arguments with their respective keywords.
stream,path, andsource_pathare not actually optional, they just aren’t required in every overload. Pass them if your overload needs them!import_vendor_description(path, source) (2/2)
- Parameters:
path (str) – The file that contains the vendor description. This must be a valid vendor description file.
source (
ScriptRepositorySource) – The repository source where the device should be stored. This parameter may beNone, in which case the default repository source is used. The repository source must be one of the sources defined insources.
- Return type:
ScriptVendorDescription- Returns:
The imported vendor description.
- remove_device(device_id, source, save_device_cache=True)¶
Remove a device from the specified repository source.
- Parameters:
device_id (
DeviceId) – Defines the device to remove.source (
ScriptRepositorySource) – Remove the device from this repository source. IfNonethe device is removed from the default repository source.save_device_cache (bool) – If
True, after removing the device the device cache is also written. IfFalse, the device cache is not written. If many devices are removed, this is much faster.
- remove_vendor_description(vendor_id, source)¶
Remove a vendor description from the specified repository source.
- Parameters:
vendor_id (int) – The vendor id.
source (
ScriptRepositorySource) – Remove the device from this repository source. IfNonethe device is removed from the default repository source.
- save_device_cache()¶
Saves the current devices in the device cache. Could be used to force it after adding or removing many devices.
- rebuild_device_cache()¶
Rebuild the device cache.
The device cache is deleted, initialized and saved.
- get_device_category(category: Guid)¶
This overload is called when
category_idis of type int.Get the device category with the specified type GUID.
- Parameters:
category_id (Guid) – The type GUID of the device category implementation.
- Return type:
- Returns:
The requested device category, or
Noneif the device category does not exist.
- get_device_family(family)¶
Device family.
- Parameters:
family (str) –
VendorID:FamilyID.- Return type:
ScriptDeviceFamily
- get_all_devices(name: str, source: ScriptRepositorySource)¶
Get a collection containing all devices in the repository.
Warning
The original C# function that is called with this method contains 5 overloads. It is strongly advised to pass all arguments with their respective keywords.
Get all device which contain the specified name.
- Parameters:
name (str) – Text which the name of the device has to contain.
source (
ScriptRepositorySource) – If notNone, only this repository source will be searched.
- Return type:
tuple
- Returns:
A device tuple containing the current result of the query.
- get_device(device_id)¶
Get the device description with the specified device identification.
- Parameters:
device_id (
DeviceId) – Device identification.- Return type:
- Returns:
The requested device description, or
Noneif the device description does not exist.
- get_all_vendor_descriptions(source: ScriptRepositorySource)¶
Get a collection of all vendor descriptions in the repository.
Warning
The original C# function that is called with this method contains 2 overloads. It is strongly advised to pass all arguments with their respective keywords.
Get the vendor description with the specified vendor Id.
- Parameters:
source (
ScriptRepositorySource) – Repository source.- Return type:
tuple[ScriptVendorDescription]
- Returns:
A collection of vendor descriptions containing the current result of the query.
- get_vendor_description(vendor_id)¶
Get the vendor description with the specified vendor Id.
- Parameters:
vendor_id (int) – Vendor Id.
- Return type:
ScriptVendorDescription- Returns:
The requested vendor description, or
Noneif the vendor description does not exist.
- class ScriptDeviceRepository.ScriptRepositorySourceList(iterable=(), /)¶
Bases:
listA collection of
ScriptRepositorySourceobjects.- add(name, location_url)¶
Add a new repository source with the specified name.
- Parameters:
name (str) – Name for the new source.
- Return type:
- Returns:
The added repository source.
- remove(source)¶
Remove an existing repository source.
Internal sources cannot be removed.
- Parameters:
source (
ScriptRepositorySource) – The repository source to remove.
- move(source, index)¶
Move an existing repository source to the specified location in the collection.
- Parameters:
source (
ScriptRepositorySource) – Existing repository source.index (int) – New index of the repository source.
- class ScriptDeviceRepository.ScriptRepositorySource¶
Bases:
objectRepository source.
- property name¶
Get or set the name of the repository source.
- Return type:
str
- property location_url¶
Get or set the location URL.
- Return type:
str
- property is_internal¶
Return whether the repository source is internal.
If true, then this repository source is an implicit source (like the project internal repository or the installation specific repository). Therefore its properties like name and location are readonly and may not be changed.
- Return type:
bool
- class ScriptDeviceRepository.ScriptDeviceCategory¶
Bases:
objectCategory of devices.
Devices can be grouped into categories by means of the
DeviceDescription/Device/DeviceInfo/Categorytags of the device description file. One can implement a corresponding class of this interface to display these types in a user-friendly way.- property category_id¶
Id of the category.
- Return type:
int
- property parent_category¶
The type GUID of the parent device category implementation, or
Guid.Empty, if this device implementation is top-level.- Return type:
Guid
- property name¶
Gets a user-friendly display name for this device category.
This string should be localized.
- Return type:
str
- property description¶
Gets a user-friendly description for this device category.
This string should be localized.
- Return type:
str