0

I need to call a method from an DLL with pythonnet. This methods expects a list of a specific type to fill in the returned objects. After some research I found the hint that I need only a dummy (to satisfy the signature).

https://www.adrian.idv.hk/2018-08-15-pythonnet/

So I need a dummy object. Unfortunately the class is an abstract class, so I can not call the constructor. Here I need some help how I can call the method. clr.GetClrType() did not help, it returned a System.RuntimeType, instead of the expected class type...

The code here is just for information:

import sys
import clr
import ctypes

#change the sys.path
sys.path.insert(1,"D:\HBM Common API\API")

clr.AddReference("Hbm.Api.Common")
from Hbm.Api.Common import DaqEnvironment
from Hbm.Api.Common.Entities import Device
from Hbm.Api.Common.Entities.Problems import CommunicationFailedError
from Hbm.Api.Common.Entities.Channels import Channel
from Hbm.Api.Common.Entities.Problems import Problem

from Hbm.Api.Common.Enums import SettingType
from Hbm.Api.Common.Enums import LedFlashMode

clr.AddReference("Hbm.Api.QuantumX")
from Hbm.Api.QuantumX import QuantumXDevice
from Hbm.Api.QuantumX import QuantumXDeviceFamily


inst = DaqEnvironment.GetInstance()  # there is no constructor for the environment
deviceList = inst.Scan()

#quantum = QuantumXDevice("10.10.10.100")
quantumFamily = QuantumXDeviceFamily()
retDevices = quantumFamily.Scan()
quantum = retDevices[0]

print('Yipiih: QuantumX Found: HW Number: ' + quantum.SerialNo)

#Problem = Problem()  # this is not possible as it is an abstract class
typeProb = clr.GetClrType(Problem)
dummyProb = typeProb()

#call the Connect Method:
connected, retList = DaqEnvironment.Connect(retDevices[0], typeProb)
Matze
  • 23
  • 3

1 Answers1

0

DaqEnvironment.Connect() needs a C# List as second argument. This can be done like this:

    clr.AddReference("System.Collections")
    from System.Collections.Generic import List
    from Hbm.Api.Common.Entities.Problems import Problem

    connect_problems = List[Problem]()
    is_ok = env.Connect(found_devices[0], connect_problems)

found_devices was created by calling DaqEnvironment.Scan()

4xx0R
  • 16