#include "common.ch" #include "activex.ch" // ---------------------------------------------------------------------------- // function main local ActCtrl, nValue, nTest local n1,n2,n3,i ActCtrl := ActOpen(2) ActWrite(ActCtrl, "D1004", 0) while .t. nTest := ActRead(ActCtrl, "D1004") if nTest != 0 n1 := ActRead(ActCtrl, "D1000") n2 := ActRead(ActCtrl, "D1002") n3 := ActRead(ActCtrl, "D1006") ? n1, n2, n3,ntest ActWrite(ActCtrl, "D1004", 0) endif enddo ActClose(ActCtrl) return nil // ---------------------------------------------------------------------------- // function ActOpen(nLogicalStation) local ActCtrl, t ? "Open communication... " ActCtrl := CreateObject("ActUtlType.ActMLUtlType") ActCtrl:ActLogicalStationNumber = nLogicalStation t := ActCtrl:Open() if t != 0 ? "Error n. " + str(t) return nil endif return ActCtrl // ---------------------------------------------------------------------------- // function ActRead(ActCtrl, cDeviceName) local aResult := {0} local t t := ActCtrl:ReadDeviceBlock2(cDeviceName, 1, aResult) if t != 0 ? "Read error" endif return aResult[1] // ---------------------------------------------------------------------------- // function ActWrite(ActCtrl, cDeviceName, nValue) local aValues := {nValue + 0.00000000} local t t := ActCtrl:WriteDeviceBlock2(cDeviceName, 1, aValues) if t != 0 ? "Write error" endif return nil // ---------------------------------------------------------------------------- // function ActClose(ActCtrl) local t t := ActCtrl:close() ? "Close... " + str(t) return nil