Hello, I’m attempting to create a custom interface for OpenTAP using python.
Before I can do that I’m trying to get OpenTAP test plans to load and run.
This worked well using the OpenTAP Basic Steps (Delay etc.) but there seem to be some issues with my custom Python plugins.
When loading a TapPlan with a Python Plugin instrument, there are errors in the session log stating the serializer is “Unable to deserialize step”. This TapPlan runs without issue in the Editor and using the CLI.
Is there something missing from my plugin or my Python program?
Code and logs:
__main__.py (TapPlan runner)
import sys
import os
import clr
tapDependencies = {
"System.Reflection.Metadata": "1.4.3.0",
"System.Collections.Immutable": "1.2.3.0"
}
tapPath = os.environ['TAP_PATH']
sys.path.append(tapPath)
sys.path.append(tapPath + "\\Packages\\OpenTAP")
clr.AddReference('System')
clr.AddReference('OpenTap')
clr.AddReference('OpenTap.Plugins.BasicSteps')
for dependency in tapDependencies.keys():
sys.path.append(tapPath + "\\Dependencies\\" + dependency + "." + tapDependencies[dependency])
clr.AddReference(dependency)
from System import *
from OpenTap import *
from OpenTap.Plugins.BasicSteps import *
PluginManager.Search()
print("----- PLUGINS FOUND -----")
for plugin in PluginManager.GetAllPlugins():
print(plugin.Name)
SessionLogs.Initialize("test.log")
tapPlan = tapPath + "\\DummyPSU.TapPlan"
testPlan = TestPlan()
print("----- PLUGINS REQUIRED -----")
for plugin in testPlan.GetPluginsRequiredToLoad(tapPlan):
print(plugin)
testPlan.Load(tapPlan)
testPlan.Execute()
DummyPSU.TapPlan (Created using the GUI Editor)
<?xml version="1.0" encoding="utf-8"?>
<TestPlan type="OpenTap.TestPlan" Locked="false">
<Steps>
<TestStep type="Python.DummyPSU.MaintainVoltage" Id="00000000-0000-0000-0000-000000000000">
<PowerSupply Source="OpenTap.InstrumentSettings">Dummy PSU</PowerSupply>
<Voltage>5</Voltage>
<Time>1000</Time>
<ChildTestSteps />
<Enabled>true</Enabled>
<Name>Maintain Voltage</Name>
<BreakConditions>Inherit</BreakConditions>
</TestStep>
</Steps>
<BreakConditions>Inherit</BreakConditions>
<OpenTap.Description />
<Package.Dependencies>
<Package Name="OpenTAP" Version="9.15.2+39e6c2a2" />
</Package.Dependencies>
</TestPlan>
Command Output
----- PLUGINS FOUND -----
OpenTap.DefaultDataAnnotator
OpenTap.ProxyAnnotation
OpenTap.MultiObjectAnnotator
OpenTap.DutSettings
OpenTap.DynamicMemberTypeDataProvider
OpenTap.EmbeddedTypeDataProvider
OpenTap.EngineSettings
OpenTap.InstrumentSettings
OpenTap.ResultSinkListener
OpenTap.StringConvertProvider+CachePopularity+Wrap
OpenTap.LogResultListener
OpenTap.ParameterMemberAnnotator
OpenTap.TestStepMenuItemsModelFactory
OpenTap.ConnectionSettings
OpenTap.RfConnection
OpenTap.DirectionalRfConnection
OpenTap.CSharpTypeInfoProvider
OpenTap.ResourceTaskManager
OpenTap.LazyResourceManager
OpenTap.ResultSettings
OpenTap.TestPlanRunSummaryListener
OpenTap.VisaDeviceDiscovery
OpenTap.Diagnostic.AccurateStamper
OpenTap.Plugins.ConvertibleStringConvertProvider
OpenTap.Plugins.EnabledStringConvertProvider
OpenTap.Plugins.EnumStringConvertProvider
OpenTap.Plugins.ListStringConvertProvider
OpenTap.Plugins.ResourceStringConvertProvider
OpenTap.Plugins.MacroStringConvertProvider
OpenTap.Plugins.SecureStringConvertProvider
OpenTap.Plugins.TestStepConvertProvider
OpenTap.Plugins.InputStringConvertProvider
OpenTap.Plugins.BoolConverter
OpenTap.Plugins.CollectionSerializer
OpenTap.Plugins.ConstResourceSerializer
OpenTap.Plugins.DefaultValueSerializer
OpenTap.Plugins.ObjectSerializer
OpenTap.Plugins.DynamicStepSerializer
OpenTap.Plugins.ExternalParameterSerializer
OpenTap.Plugins.InputOutputRelationSerializer
OpenTap.Plugins.KeyValuePairSerializer
OpenTap.Plugins.MacroStringSerializer
OpenTap.Plugins.ResourceSerializer
OpenTap.Plugins.SecureStringSerializer
OpenTap.Plugins.TestPlanSerializer
OpenTap.Plugins.TestStepListSerializer
OpenTap.Plugins.TestStepSerializer
OpenTap.Cli.RunCliAction
OpenTap.Plugins.BasicSteps.BasicStepsAnnotator
OpenTap.Plugins.BasicSteps.DelayStep
OpenTap.Plugins.BasicSteps.DialogStep
OpenTap.Plugins.BasicSteps.DialogStepCompatibilitSerializer
OpenTap.Plugins.BasicSteps.ExpandMemberDataProvider
OpenTap.Plugins.BasicSteps.IfStep
OpenTap.Plugins.BasicSteps.LockStep
OpenTap.Plugins.BasicSteps.LogStep
OpenTap.Plugins.BasicSteps.ParallelStep
OpenTap.Plugins.BasicSteps.ProcessStep
OpenTap.Plugins.BasicSteps.RepeatStep
OpenTap.Plugins.BasicSteps.GenericScpiInstrument
OpenTap.Plugins.BasicSteps.SCPIRegexStep
OpenTap.Plugins.BasicSteps.SequenceStep
OpenTap.Plugins.BasicSteps.SweepLoop
OpenTap.Plugins.BasicSteps.SweepLoopRange
OpenTap.Plugins.BasicSteps.LegacySweepLoader
OpenTap.Plugins.BasicSteps.SweepParameterRangeStep
OpenTap.Plugins.BasicSteps.SweepParameterStep
OpenTap.Plugins.BasicSteps.TestPlanReference
OpenTap.Plugins.BasicSteps.TestPlanReference+SubPlanResultListener
OpenTap.Plugins.BasicSteps.TimeGuardStep
OpenTap.KeysightVisaDeviceDiscovery
Keysight.OpenTap.Wpf.AvailableValuesControlProvider
Keysight.OpenTap.Wpf.BoolControlProvider
Keysight.OpenTap.Wpf.FilePathControlProvider
Keysight.OpenTap.Wpf.MethodControlProvider
Keysight.OpenTap.Wpf.MultiSelectProvider
Keysight.OpenTap.Wpf.CollectionControlProvider
Keysight.OpenTap.Wpf.SimpleControlProvider
Keysight.OpenTap.Wpf.GuiControlsSettings
Keysight.OpenTap.Wpf.GuiMenuModelFactory
Keysight.OpenTap.Wpf.EditorSettings
Keysight.OpenTap.Wpf.NotifyingResultListener
Keysight.OpenTap.Wpf.ThreadBreakAnnotator
Keysight.OpenTap.Wpf.ControlProviders.EnabledControlProvider
Keysight.OpenTap.Wpf.ControlProviders.PasswordControlProvider
Keysight.OpenTap.Wpf.ControlProviders.VerdictControlProvider
OpenTap.Package.FileHashPackageAction
OpenTap.Package.FileHashPackageAction+Hash
OpenTap.Package.VerifyPackageHashes
OpenTap.Package.GitVersionAction
OpenTap.Package.UseVersionData
OpenTap.Package.MajorMinorBuildRevisionVersionConverter
OpenTap.Package.FourValueVersionConverter
OpenTap.Package.Tap8CompatibilityVersionConverter
OpenTap.Package.PackageDefExt+SetAssemblyInfoData
OpenTap.Package.MissingPackageData
OpenTap.Package.PackageVersionSerializerPlugin
OpenTap.Package.CacheAction
OpenTap.Package.PackageCreateAction
OpenTap.Package.PackageDownloadAction
OpenTap.Package.PackageInstallAction
OpenTap.Package.PackageListAction
OpenTap.Package.PackageShowAction
OpenTap.Package.PackageTestAction
OpenTap.Package.PackageUninstallAction
OpenTap.Package.PackageDefinitionSerializerPlugin
OpenTap.Package.PackageDependencySerializerPlugin
OpenTap.Package.PackageFileSerializerPlugin
OpenTap.Package.PackageIconData
OpenTap.Package.PackageManagerSettings
OpenTap.Package.TestPlanPackageDependency
OpenTap.Package.UpdateCheck
Keysight.OpenTap.Package.Gui.GuiAction
Keysight.OpenTap.Package.Gui.PackageManagerGuiSettings
Keysight.OpenTap.Package.Gui.RepositoryListProvider
Keysight.OpenTap.Gui.PanelSettings
Keysight.OpenTap.Gui.EditorCliAction
Keysight.OpenTap.Gui.LogPanelPlugin
Keysight.OpenTap.Gui.StepExplorerPlugin
Keysight.OpenTap.Gui.StepSettingsPlugin
Keysight.OpenTap.Gui.TestPlanGridListener
Keysight.OpenTap.Gui.TestPlanPlugin
Keysight.OpenTap.Gui.TestPlanSettings
Keysight.OpenTap.Gui.PackageManagerToolProvider
Keysight.OpenTap.Gui.RunExplorerToolProvider
Keysight.OpenTap.Gui.ResultViewerToolProvider
Keysight.OpenTap.Gui.ToolMenuEntry
Keysight.OpenTap.CommunityEditionPopup.GuiAction
OSIntegration.Windows.StartMenuItemData
OSIntegration.Windows.FileAssociationData
OSIntegration.Windows.OSIntegrationInstallAction
OSIntegration.Windows.OSIntegrationUninstallAction
OSIntegration.Windows.FirewallRule
OSIntegration.Windows.IconTool
OSIntegration.Windows.SingleFileAssociation
OSIntegration.Windows.FileAssociation
OSIntegration.Windows.ElevateActions
OSIntegration.Windows.LaunchAction
OSIntegration.Windows.ListInstallationsAction
OSIntegration.Windows.RegisterInstallationAction
OSIntegration.Windows.UnregisterInstallationAction
Keysight.Plugins.Python.ListPythonConverter
Keysight.Plugins.Python.EnumPythonConverter
Keysight.Plugins.Python.PythonProxyConverter
Keysight.OpenTap.Plugins.Python.PythonComponentSettings
Keysight.OpenTap.Plugins.Python.PythonDut
Keysight.OpenTap.Plugins.Python.PythonInstrument
Keysight.OpenTap.Plugins.Python.PythonResultListener
Keysight.OpenTap.Plugins.Python.PythonSettings
Keysight.OpenTap.Plugins.Python.PythonStep
Keysight.OpenTap.Plugins.Python.SDK.PythonCliAction
Keysight.OpenTap.Plugins.Python.SDK.PythonSetPath
Keysight.OpenTap.Plugins.Python.SDK.PythonSetVersion
Keysight.OpenTap.Plugins.Python.SDK.PythonSearchPath
Python.DummyPSU.MaintainCurrent
Python.DummyPSU.PowerSupply
Python.DummyPSU.MaintainVoltage
----- PLUGINS REQUIRED -----
Python.DummyPSU.MaintainVoltage
test.log
2021-08-13 09:54:08.407750 ; Session ; Debug ; Session log loaded as 'C:\Program Files\OpenTAP\SessionLogs\SessionLog 2021-08-13 09-54-07.txt'. [9.48 ms]
2021-08-13 09:54:08.424664 ; Session ; Debug ; Running '"C:\Program Files\Python37\python.exe" c:/Users/Thomas/Desktop/DLLTest/__main__.py' in 'C:\Users\Thomas\Desktop\DLLTest'.
2021-08-13 09:54:08.449598 ; Session ; Debug ; Microsoft Windows 10.0.19043 X64
2021-08-13 09:54:08.449598 ; Session ; Debug ; .NET Framework 4.8.4400.0
2021-08-13 09:54:08.477528 ; Resolver ; Debug ; Found 13/42 assembly files. [24.9 ms]
2021-08-13 09:54:08.478525 ; Session ; Debug ; OpenTAP Engine 9.15.2+39e6c2a2 X64
2021-08-13 09:54:08.620141 ; Searcher ; Debug ; Ordered 13 assemblies according to references. [137 ms]
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found 10 plugin assemblies containing 225 plugin types. [227 ms]
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+39e6c2a2 of OpenTap.dll from C:\Program Files\OpenTAP\OpenTap.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+39e6c2a2 of OpenTap.Plugins.BasicSteps.dll from C:\Program Files\OpenTAP\Packages\OpenTAP\OpenTap.Plugins.BasicSteps.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+c38682f7 of Keysight.OpenTap.Wpf.dll from C:\Program Files\OpenTAP\Packages\WPF Controls\Keysight.OpenTap.Wpf.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+39e6c2a2 of OpenTap.Package.dll from C:\Program Files\OpenTAP\OpenTap.Package.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+c38682f7 of PackageManager.exe from C:\Program Files\OpenTAP\PackageManager.exe
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+c38682f7 of Editor.exe from C:\Program Files\OpenTAP\Editor.exe
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 9.15.2+c38682f7 of Keysight.OpenTap.CommunityEditionPopup.dll from C:\Program Files\OpenTAP\Packages\Editor CE\Keysight.OpenTap.CommunityEditionPopup.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 1.0.0 of OpenTap.OSIntegration.Windows.dll from C:\Program Files\OpenTAP\Packages\OSIntegration\OpenTap.OSIntegration.Windows.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 1.0.0.0 of Keysight.OpenTap.Plugins.Python.dll from C:\Program Files\OpenTAP\Packages\Python\Keysight.OpenTap.Plugins.Python.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Found version 1.0.0.0 of Python.DummyPSU.dll from C:\Program Files\OpenTAP\Packages\Python\DummyPSU\Python.DummyPSU.dll
2021-08-13 09:54:08.708906 ; PluginManager ; Debug ; Searched 13 Assemblies. [228 ms]
2021-08-13 09:54:08.846537 ; Session ; Debug ; Session log loaded as 'test.log'. [44.5 ms]
2021-08-13 09:54:08.848532 ; Session ; Debug ; Running '"C:\Program Files\Python37\python.exe" c:/Users/Thomas/Desktop/DLLTest/__main__.py' in 'C:\Users\Thomas\Desktop\DLLTest'.
2021-08-13 09:54:08.929314 ; PluginManager ; Debug ; Loaded OpenTap. [488 us]
2021-08-13 09:54:08.930311 ; PluginManager ; Debug ; Loaded OpenTap.Plugins.BasicSteps. [138 us]
2021-08-13 09:54:08.933303 ; PluginManager ; Debug ; Loaded OpenTap.Package. [3.75 ms]
2021-08-13 09:54:08.951256 ; PluginManager ; Debug ; Loaded OpenTap.OSIntegration.Windows. [2.70 ms]
2021-08-13 09:54:09.079917 ; PluginManager ; Debug ; Loaded mscorlib. [400 ns]
2021-08-13 09:54:09.255443 ; Resolver ; Debug ; Found match for Keysight.OpenTap.Plugins.Python, Version=1.0.0.0, Culture=en, PublicKeyToken=null in C:\Program Files\OpenTAP\Packages\Python\Keysight.OpenTap.Plugins.Python.dll
2021-08-13 09:54:09.261426 ; PluginManager ; Debug ; Loaded Python.DummyPSU. [29.6 ms]
2021-08-13 09:54:09.273394 ; PluginManager ; Debug ; Loaded Keysight.OpenTap.Plugins.Python. [554 us]
2021-08-13 09:54:09.294340 ; Settings ; Debug ; PythonSettings loaded from C:\Program Files\OpenTAP\Settings\Python.xml [21.4 ms]
2021-08-13 09:54:09.299365 ; Wrapper ; Debug ; Python version: 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]
2021-08-13 09:54:09.311295 ; Python ; Debug ; Loaded Python.Runtime, Version=2.5.2.0, Culture=neutral, PublicKeyToken=null
2021-08-13 09:54:09.327251 ; Resolver ; Debug ; Unable to find match for OpenTap.__spec__
2021-08-13 09:54:09.334231 ; Resolver ; Debug ; Unable to find match for OpenTap.Plugins.BasicSteps.__spec__
2021-08-13 09:54:09.340216 ; Resolver ; Debug ; Unable to find match for System.__spec__
2021-08-13 09:54:09.344205 ; Resolver ; Debug ; Unable to find match for OpenTap.__path__
2021-08-13 09:54:09.348198 ; Resolver ; Debug ; Unable to find match for OpenTap.__all__
2021-08-13 09:54:09.353181 ; Resolver ; Debug ; Found match for Keysight.Ccl.Wsl, Version=4.0.1.9, Culture=neutral, PublicKeyToken=55333af07c70062e in C:\Program Files\OpenTAP\Dependencies\Keysight.Ccl.Wsl.4.0.1.9\Keysight.Ccl.Wsl.dll
2021-08-13 09:54:09.353181 ; Resolver ; Debug ; Found match for Xceed.Wpf.AvalonDock, Version=3.1.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4 in C:\Program Files\OpenTAP\Dependencies\Xceed.Wpf.AvalonDock.3.1.0.0\Xceed.Wpf.AvalonDock.dll
2021-08-13 09:54:09.363154 ; Resolver ; Debug ; Unable to find match for Keysight.OpenTap.Plugins.Python.__spec__
2021-08-13 09:54:09.368141 ; Resolver ; Debug ; Unable to find match for Keysight.OpenTap.Plugins.Python.__path__
2021-08-13 09:54:09.376121 ; PluginManager ; Debug ; Loaded Keysight.OpenTap.Wpf. [50.7 ms]
2021-08-13 09:54:09.377125 ; Resolver ; Debug ; Unable to find match for Keysight.OpenTap.Plugins.Python.PythonComponentSettingsWrapper
2021-08-13 09:54:09.383103 ; PluginManager ; Debug ; Loaded Editor. [57.8 ms]
2021-08-13 09:54:09.390081 ; Resolver ; Debug ; Unable to find match for Keysight.OpenTap.Plugins.Python.__all__
2021-08-13 09:54:09.397063 ; Resolver ; Debug ; Unable to find match for Keysight.__path__
2021-08-13 09:54:09.401055 ; Resolver ; Debug ; Found match for System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 in C:\Program Files\OpenTAP\Dependencies\System.Windows.Interactivity.4.5.0.0\System.Windows.Interactivity.dll
2021-08-13 09:54:09.405043 ; Resolver ; Debug ; Unable to find match for Keysight.Plugins
2021-08-13 09:54:09.411028 ; Resolver ; Debug ; Unable to find match for Keysight.Plugins.Python
2021-08-13 09:54:09.417020 ; Resolver ; Debug ; Unable to find match for Keysight.Plugins.Python.__all__
2021-08-13 09:54:09.418009 ; PluginManager ; Debug ; Loaded PackageManager. [92.4 ms]
2021-08-13 09:54:09.448936 ; Serializer ; Error ; XML Line 3: Unable to create instance of Python.DummyPSU.PowerSupply.
2021-08-13 09:54:09.451928 ; Serializer ; Debug ; Exception: Object reference not set to an instance of an object.
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonInstrumentWrapper.load(String name, String moduleName)
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at Python.DummyPSU.PowerSupply.load_instance()
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonInstrumentWrapper..ctor()
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at Python.DummyPSU.PowerSupply..ctor()
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; --- End of stack trace from previous location where exception was thrown ---
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.TryDeserializeObject(XElement element, ITypeData t, Action`1 setter, Object newobj, Boolean logWarnings)
2021-08-13 09:54:09.454909 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.Deserialize(XElement element, ITypeData t, Action`1 setter)
2021-08-13 09:54:09.455908 ; Serializer ; Debug ; Exception caught at:
2021-08-13 09:54:09.464892 ; Serializer ; Debug ; at System.Object Deserialize(System.Xml.Linq.XDocument, OpenTap.ITypeData, Boolean, System.String)
2021-08-13 09:54:09.464892 ; Serializer ; Debug ; at OpenTap.ComponentSettings Load(System.Type)
2021-08-13 09:54:09.464892 ; Serializer ; Debug ; at ResultT Invoke(ArgT)
2021-08-13 09:54:09.464892 ; Serializer ; Debug ; at OpenTap.ComponentSettings GetCurrent(System.Type)
2021-08-13 09:54:09.464892 ; Serializer ; Debug ; ...
2021-08-13 09:54:09.464892 ; Settings ; Debug ; InstrumentSettings loaded from C:\Program Files\OpenTAP\Settings\Bench\Default\Instruments.xml [46.4 ms]
2021-08-13 09:54:09.469869 ; Serializer ; Warning ; XML line 4 column 6: Unable to deserialize step.
2021-08-13 09:54:09.477847 ; Serializer ; Error ; XML Line 4: Unable to create instance of OpenTap.DynamicMemberTypeDataProvider+TestStepTypeData.
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; Exception: Object reference not set to an instance of an object.
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonStepWrapper.load(String name, String moduleName)
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at Python.DummyPSU.MaintainVoltage.load_instance()
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonStepWrapper..ctor()
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at Python.DummyPSU.MaintainVoltage..ctor()
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; --- End of stack trace from previous location where exception was thrown ---
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.TryDeserializeObject(XElement element, ITypeData t, Action`1 setter, Object newobj, Boolean logWarnings)
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.Deserialize(XElement element, ITypeData t, Action`1 setter)
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; Exception caught at:
2021-08-13 09:54:09.477847 ; Serializer ; Debug ; at System.Object Deserialize(System.Xml.Linq.XDocument, OpenTap.ITypeData, Boolean, System.String)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.TestPlan Load(System.IO.Stream, System.String, Boolean, OpenTap.TapSerializer, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.TestPlan Load(System.String, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; ...
2021-08-13 09:54:09.478849 ; Serializer ; Error ; XML Line 4: Unable to create instance of OpenTap.DynamicMemberTypeDataProvider+TestStepTypeData.
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; Exception: Object reference not set to an instance of an object.
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonStepWrapper.load(String name, String moduleName)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at Python.DummyPSU.MaintainVoltage.load_instance()
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at Keysight.OpenTap.Plugins.Python.PythonStepWrapper..ctor()
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at Python.DummyPSU.MaintainVoltage..ctor()
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; --- End of stack trace from previous location where exception was thrown ---
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.TryDeserializeObject(XElement element, ITypeData t, Action`1 setter, Object newobj, Boolean logWarnings)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.Plugins.ObjectSerializer.Deserialize(XElement element, ITypeData t, Action`1 setter)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; Exception caught at:
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at System.Object Deserialize(System.Xml.Linq.XDocument, OpenTap.ITypeData, Boolean, System.String)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.TestPlan Load(System.IO.Stream, System.String, Boolean, OpenTap.TapSerializer, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at OpenTap.TestPlan Load(System.String, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; at System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
2021-08-13 09:54:09.478849 ; Serializer ; Debug ; ...
2021-08-13 09:54:09.482837 ; TestPlan ; Information ; Loaded test plan from C:\Program Files\OpenTAP\DummyPSU.TapPlan [602 ms]
2021-08-13 09:54:09.511759 ; Settings ; Debug ; ResultSettings loaded from C:\Program Files\OpenTAP\Settings\Results.xml [28.0 ms]
2021-08-13 09:54:09.522727 ; TestPlan ; Information ; -----------------------------------------------------------------
2021-08-13 09:54:09.527715 ; TestPlan ; Information ; Starting TestPlan 'Untitled' on 13/08/2021 9:54:09 AM, 0 of 0 TestSteps enabled.
2021-08-13 09:54:09.560627 ; Settings ; Debug ; EngineSettings loaded from C:\Program Files\OpenTAP\Settings\Engine.xml [30.5 ms]
2021-08-13 09:54:09.695266 ; Log ; Information ; Resource "Log" opened. [816 us]
2021-08-13 09:54:09.711223 ; TestPlan ; Debug ; Saved Test Plan XML [99.6 ms]
2021-08-13 09:54:09.733199 ; TestPlan ; Debug ; PrePlanRun Methods completed [1.92 ms]
2021-08-13 09:54:09.733199 ; TestPlan ; Debug ; Test step runs finished. [17.1 us]
2021-08-13 09:54:09.770068 ; Log ; Debug ; OnTestPlanRunCompleted for Log. [29.7 ms]
2021-08-13 09:54:09.789836 ; Log ; Information ; Resource "Log" closed. [81.7 us]
DummyPSU Plugin:
__init__.py
import sys
from .DummyPSU import *
from .Functionality import *
DummyPSU.py
from PythonTap import *
from System import Double, Boolean
import OpenTap
class PowerSupply(Instrument):
def __init__(self):
super(PowerSupply, self).__init__()
self.Name = "Dummy PSU"
self.Type = "PowerSupply"
self.voltage = 0
self.current = 0
default_voltage = self.AddProperty("default_voltage", 0, Double)
default_voltage.AddAttribute(OpenTap.UnitAttribute, "V")
default_voltage.AddAttribute(OpenTap.DisplayAttribute, "Default Voltage", "Default Voltage for the PSU")
default_current = self.AddProperty("default_current", 0, Double)
default_current.AddAttribute(OpenTap.UnitAttribute, "A")
default_current.AddAttribute(OpenTap.DisplayAttribute, "Default Current", "Default Current for the PSU")
self.RegisterMethod("Voltage", Boolean)
self.RegisterMethod("Current", Boolean)
def Open(self):
self.Info("Connected to " + self.Name)
self.DefaultVoltage()
self.DefaultCurrent()
self.Info(self.Name + ": Set defaults - " + str(self.voltage) + "V, " + str(self.current) + "A")
def Close(self):
self.Info("Disconnected " + self.Name)
def Voltage(self, v):
self.voltage = v
self.Debug("Voltage: {0}V", self.voltage)
return True
def Current(self, a):
self.current = a
self.Debug("Current: {0}A", self.current)
return True
def DefaultVoltage(self):
self.Voltage(self.default_voltage)
def DefaultCurrent(self):
self.Current(self.default_current)
Functionality.py
from PythonTap import *
from System import Array, Double, Byte, Int32
import OpenTap
from DummyPSU import PowerSupply
@Attribute(DisplayAttribute, Name="Maintain Voltage", Description="Maintain Power Supply voltage for specified ms", Group="PowerSupply")
class MaintainVoltage(TestStep):
def __init__(self):
super(MaintainVoltage, self).__init__()
prop = self.AddProperty("Voltage", 0.0, Double) # AddProperty(Name, Default, Type)
prop.AddAttribute(UnitAttribute, "V")
prop.AddAttribute(DisplayAttribute, Name="Voltage", Group="Power Supply", Order=0, Collapsed=False)
prop = self.AddProperty("Time", 0, Int32)
prop.AddAttribute(UnitAttribute, "ms")
prop.AddAttribute(DisplayAttribute, Name="Time", Group="Power Supply", Order=1, Collapsed=False)
prop = self.AddProperty("PowerSupply", None, PowerSupply)
prop.AddAttribute(DisplayAttribute, Name="Power Supply", Group="Power Supply", Order=-1, Collapsed=False)
def Run(self):
self.PowerSupply.Voltage(self.Voltage)
self.Info("Set voltage to " + str(self.Voltage) + "V, maintaining for " + str(self.Time) + "ms")
OpenTap.TapThread.Sleep(self.Time)
@Attribute(DisplayAttribute, Name="Maintain Current", Description="Maintain Power Supply current for specified ms", Group="PowerSupply")
class MaintainCurrent(TestStep):
def __init__(self):
super(MaintainCurrent, self).__init__()
prop = self.AddProperty("Current", 0.0, Double)
prop.AddAttribute(UnitAttribute, "A")
prop.AddAttribute(DisplayAttribute, Name="Current", Group="Power Supply", Order=0, Collapsed=False)
prop = self.AddProperty("Time", 0, Int32)
prop.AddAttribute(UnitAttribute, "ms")
prop.AddAttribute(DisplayAttribute, Name="Time", Group="Power Supply", Order=1, Collapsed=False)
prop = self.AddProperty("PowerSupply", None, PowerSupply)
prop.AddAttribute(DisplayAttribute, Name="Power Supply", Group="Power Supply", Order=-1, Collapsed=False)
def Run(self):
self.PowerSupply.Current(self.Current)
self.Info("Set current to " + str(self.Current) + "A, maintaining for " + str(self.Time) + "ms")
OpenTap.TapThread.Sleep(self.Time)
Edit:
Just had a look at the “limitations” page on the Python Integration Docs, the first and third seem relevant:
-
It is not possible to add child test steps from the constructor of a Python test step. This is due to the object not being fully instanced at the time of modification. To get around this problem a ‘Load’ button can be added so that the steps can be loaded manually.
-
Loading OpenTAP from a Python script is not currently supported. There are probably ways to get around this limitation.