class
IConvertExtension.
IConvertExtension
Bases: object
This extension provides methods for testing and converting a device or device module.
can_convert
targetType
targetId
targetVersion
targetModuleId=None
Verifies whether the device can be converted to another specific device or module.
If a module is to be verified, pass a valid targetModuleId , otherwise leave it null.
targetType (int) -- Type of the target.
targetId (string) -- The target id.
targetVersion (string) -- The target version.
targetModuleId (string) -- The target module id (optional).
True if the conversion is possible, False otherwise
bool
This example shows how to perform a verification whether a conversion would be possible.
from __future__ import print_function
# define the device id for the parameters
x01c = DeviceID(4096, "1003 009D", "1.36.2.6")
lxm52 = DeviceID(4096, "1003 0082", "1.50.0.4")
lxm52Id = "LXM52"
def main():
if not projects.primary:
system.ui.error("No active project.")
return
proj = projects.primary
controller = proj.find('LMC', True)[0]
drive = proj.find('Drive', True)[0]
#test using DeviceID
result = controller.can_convert(x01c)
print('Conversion possible: ' + str(result))
#test using DeviceID
result = drive.can_convert(lxm52, lxm52Id)
print('Conversion possible: ' + str(result))
#test using single parameters
result = drive.can_convert(4096, "1003 0082", "1.36.2.6", "LXM52"):
print('Conversion possible: ' + str(result))
main()
convert
targetType
targetId
targetVersion
targetModuleId=None
Converts the device to the specified target device.
If a module is to be converted, pass a valid targetModuleId , otherwise leave it null.
targetType (int) -- Type of the target device.
targetId (string) -- The target device id.
targetVersion (string) -- The target device version.
targetModuleId (string) -- The target module id (optional).
This example shows how to convert a device.
from __future__ import print_function
def main():
if not projects.primary:
system.ui.error("No active project.")
return
proj = projects.primary
# find the controller to convert by name 'LMC'
controller = proj.find('LMC', True)[0]
# find the drive to convert by name 'Drive'
drive = proj.find('Drive', True)[0]
controller.convert(4096, "1003 009D", "1.36.2.6")
drive.convert(DeviceID(4096, "1003 0082", "1.50.0.4"), "LXM52")
system.ui.info("Conversion complete")
main()
get_alternative_devices
Gets a list of alternative DeviceIDs for the device.
A list of DeviceIDs
IList
This example shows an example of getting a list of alternative devices for a given device.
from __future__ import print_function
#help function to print the delivered device ids
def deviceid_to_string(devId):
mystr = "ID: {0.id} Type: {0.type} Version: {0.version}".format(devId)
if hasattr(devId, 'module_id') and devId.module_id is not None:
mystr += " ModuleID: {0.module_id}".format(devId)
return mystr
def main():
if not projects.primary:
system.ui.error("No active project.")
return
proj = projects.primary
controller = proj.find('LMC', True)[0]
alternativeControllers = controller.get_alternative_devices()
print("ALTERNATIVE DEVICES FOR LMC")
for id in alternativeControllers:
print(deviceid_to_string(id))
drive = proj.find('drive', True)[0]
alternativeDrives = drive.get_alternative_devices()
print("ALTERNATIVE DEVICES FOR DRIVE")
for id in alternativeDrives:
print(deviceid_to_string(id))
system.ui.info("Test complete. Verify the script output window")
main()
get_preferred_alternative_devices
Gets the preferred alternative DeviceIDs for the device.
A list of DeviceIDs
IList
This example shows an example of getting a list of alternative devices for a given device.
from __future__ import print_function
#help function to print the delivered device ids
def deviceid_to_string(devId):
mystr = "ID: {0.id} Type: {0.type} Version: {0.version}".format(devId)
if hasattr(devId, 'module_id') and devId.module_id is not None:
mystr += " ModuleID: {0.module_id}".format(devId)
return mystr
def main():
if not projects.primary:
system.ui.error("No active project.")
return
proj = projects.primary
controller = proj.find('LMC', True)[0]
alternativeControllers = controller.get_preferred_alternative_devices()
print("ALTERNATIVE DEVICES FOR LMC")
for id in alternativeControllers:
print(deviceid_to_string(id))
drive = proj.find('drive', True)[0]
alternativeDrives = drive.get_preferred_alternative_devices()
print("ALTERNATIVE DEVICES FOR DRIVE")
for id in alternativeDrives:
print(deviceid_to_string(id))
system.ui.info("Test complete. Verify the script output window")
main()