How get a pointer value in QAxObject with python?

381 Views Asked by At

I need use QAxObject to read some PLCdata.I Can connect PLC successful but the problem is that I can't read data from it.The reason in below.

class Test(QAxWidget):
    def __init__(self):
        super().__init__()
        self.setControl("ActUtlType.ActUtlType.1")
        self.dynamicCall("SetActLogicalStationNumber(int)", 1)

        ret = self.dynamicCall("Open()")
        value = 12
        ret = self.dynamicCall("ReadDeviceRandom2(QString, int, int&)", "D300", 1, value)
        print(ret, value)

enter image description here
info: ReadDeviceRandom2 method, szDeviceList is PLC address, ISize is read data size, IpsData is to store read data

The problem is that method ReadDeviceRandom2 need to pass a int address to it, but python has no int address.So the sample code not working. In this situation how can i pass a pointer to it and read it.

The output:
enter image description here


Then I use other method

import win32com.client

plc = win32com.client.Dispatch("ActUtlType.ActUtlType.1")
plc.ActLogicalStationNumber = 1
plc.open()

value = 0
ret = plc.ReadDeviceRandom2("D300", 1, value)

print(ret, value)

The output, it work fine. enter image description here

0

There are 0 best solutions below