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)
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.
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)