*Phenomenon: Recently we upgraded our PB application OS from Windows7 to Windows11, but found the existing External Remote Function call no longer able to work. Fyi, this Global External Function Call library (AdsAPI32.DLL) actually from an Advantech Digital IO Card from with model PCI-1761. According to vendor, it no longer provides COM based library (AdsAPI32.DLL), instead with another type of Library call DAQNavi. Been contacted the Advantech vendor but they only have programming sample with C#, VB.NET, C++, Java, Matlab. *Reproduce Steps: Over here, would appreciate Appeon support can guide us how should PB scrapping based on below few samples provided by Advantech programming: ///////////C#/////////// using Automation.BDaq; ... InstantDiCtrl instantDoCtrl = new InstantDiCtrl(); instantDiCtrl.SelectedDevice = new DeviceInformation(deviceDescription); // Read profile to configure device ret = instantDiCtrl.LoadProfile(filePath); PortDirection[] portDirs = instantDoCtrl.PortDirection; if (portDirs != null){ //Set the first two port to output DioPortDir dir = DioPortDir.Output; portDirs[0].Direction = dir; portDirs[1].Direction = dir; //get port direction and print the direction information DioPortDir currentDir = portDirs[0].Direction; Console.WriteLine("Current Direction of Port[{0}] = {1}", 0, currentDir.toString()); currentDir = portDirs[1].Direction; Console.WriteLine("Current Direction of Port[{0}] = {1}", 1, currentDir.toString()); } else { Console.WriteLine("There is no DIO port of the selected device can set direction!"); } ... // Write port values to DO port ret = instantDoCtrl1.Write(portNum, (byte)state); ... // Read back the DO port status // Note: for relay output, the read back must deferred until the relay becomes stable ret = instantDoCtrl1.Read(portNum, out portData); ... ///////////VB.NET/////////// Imports Automation.BDaq ... Dim portDirs() As PortDirection If InstantDoCtrl1.PortDirection IsNot Nothing Then portDirs = InstantDoCtrl1.PortDirection 'Set the first two port to output. Dim dir As DioPortDir dir = DioPortDir.Output portDirs(0).Direction = dir portDirs(1).Direction = dir 'get port direction and print the direction information Dim prompt As String Dim currentDir As DioPortDir currentDir = portDirs(0).Direction prompt = "Current Direction of Port[" & Str(0) & "] = " & currentDir.ToString() MessageBox.Show(prompt) currentDir = portDirs(0).Direction prompt = "Current Direction of Port[" & Str(1) & "] = " & currentDir.ToString() MessageBox.Show(prompt) Else MessageBox.Show("There is no DIO port of the selected device can set direction!") End If 'Write port values to DO port ret = InstantDoCtrl1.Write(portNum, CByte(state)) ... 'Read back the DO port status 'Note: for relay output, the read back must deferred until the relay becomes stable ret = instantDoCtrl1.Read(portNum, out portData); ... ///////////JAVA////////// import Automation.BDaq.*; ... DeviceInformation devInfo = new DeviceInformation(deviceDescription); InstantDoCtrl instantDoCtrl = new InstantDoCtrl(); //Set the selected device. instantDoCtrl.setSelectedDevice(devInfo); // Read profile to configure device ret = instantDoCtrl.LoadProfile(fileDefaultPath); PortDirection[] portDirs = instantDoCtrl.getPortDirection(); if (portDirs != null) { //Set the first two port to output DioPortDir dir = DioPortDir.Output; portDirs[0].setDirection(dir); portDirs[1].setDirection(dir); //get port direction and print the direction information DioPortDir currentDir = portDirs[0].getDirection(); System.out.println("Current Direction of Port[" + 0 + "] = " + currentDir.toString()); currentDir = portDirs[1].getDirection(); System.out.println("Current Direction of Port[" + 1 + "] = " + currentDir.toString()); } else { System.out.println("There is no DIO port of the selected device can set direction!\n"); } ... // Write port values to DO port ret = instantDoCtrl.Write(portNum, (byte)state); ... // Read back the DO port status // Note: for relay output, the read back must deferred until the relay becomes stable ret = instantDoCtrl.Write(portNum, portData); ... ///////////C++/////////// #include "BDaqCtrl.h" using namespace Automation::BDaq; ... ErrorCode ret = Success; InstantDoCtrl * instantDoCtrl = AdxInstantDoCtrlCreate(); DeviceInformation devInfo(deviceDescription); ret = instantDoCtrl -> setSelectedDevice(devInfo); // Read profile to configure device ret = instantDoCtrl->LoadProfile(filePath); ICollection<PortDirection>* portDirection = instantDoCtrl -> getPortDirection(); if (portDirection != NULL) { //Set the first two port to output DioPortDir dir = Output ; portDirection -> getItem(0).setDirection(dir); portDirection -> getItem(1).setDirection(dir); //get port direction and print the direction information DioPortDir currentDir = portDirection -> getItem(0).getDirection(); printf(" Current Direction of Port[%ld]=%ld \n",0, currentDir); currentDir = portDirection -> getItem(1).getDirection(); printf(" Current Direction of Port[%ld]=%ld \n",1, currentDir); } else { printf("There is no DIO port of the selected device can set direction!\n"); } // Write port values to DO port ret = instantDoCtrl -> Write(portNum, (byte)state); ... // Read back the DO port status // Note: for relay output, the read back must deferred until the relay becomes stable ret = instantDoCtrl -> Read(portNum, &portData); ... Remarks: I tried with External Function Call but failed: FUNCTION INTEGER BioDoWritePorts(ULONG DeviceNum, LONG port, LONG wvalue) LIBRARY "Bio1761.dll" FUNCTION INTEGER BioDiReadPorts(ULONG DeviceNum, LONG port, ref LONG wvalue) LIBRARY "Bio1761.dll" FUNCTION LONG InstantDOCtrl_getDevice() LIBRARY "C:\Windows\SysWOW64\biodaq.dll" FUNCTION LONG InstantDOCtrl_WriteBit(LONG port, LONG wvalue) LIBRARY "C:\Windows\SysWOW64\biodaq.dll" FUNCTION LONG InstantDOCtrl_WriteAny(LONG port, LONG wvalue) LIBRARY "C:\Windows\SysWOW64\biodaq.dll" I tried with ConnectToNewObject but also failed: INTEGER li_rtn oleobject lole_iocard lole_iocard = create oleobject li_rtn = lole_iocard.ConnectToNewObject("Automation.BDaq") //ConnectToNewObject("Automation.BDaq") IF li_rtn <> 0 then MessageBox( "Error", 'Error running Automation.BDaq4 api. :' + STRING(li_rtn)) destroy lole_iocard Return -1 ELSE MessageBox("OK","OK"); END IF Appreciate your help in this matter. NOTE : attached is latest Advantech Driver.
- Ong Chin Keat
- PowerBuilder
- Wednesday, 2 August 2023 01:12 AM UTC
- Page :
- 1
There are no replies made for this question yet.
However, you are not allowed to reply to this question.
However, you are not allowed to reply to this question.