1. Ong Chin Keat
  2. PowerBuilder
  3. Wednesday, 2 August 2023 01:12 AM UTC
*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.
Attachments (1)
References
  1. https://us2.advantech.com/DAQNavi/aboutDAQNavi.aspx

Responses (4)
  1. Likes
  2. Latest
  3. Oldest
Loading...

Find Questions by Tag

.EXE .NET 6.0 .NET Assembly .NET Core 3.1 .NET Core Framework .NET DataStore .NET Std Framework 32-bit 64-bit ADO.NET AEM AI Algorithm Amazon AWS Android Apache API APK App Store App Store (Apple) Appeon Workspace Appeon Xcelerator Plug-in Architecture Array ASE Asynchronous Methods Authentication AutoBuild AutoCompiler Automated Testing Automation AutoScript Azure Barcode Base64 Batch BigData BLOB Branch & Merge Browser Bug Build Button C# C# Class Importer C# Editor C# Model generator Calendar Camera Certificate Chrome Citrix Class Client Client/Server Cloud Cluster Collection COM Command Line Compiler Compression Computed Field Configuration Controls Cookies Cordova Crash Cross-Platform Crosstab CSharpAssembly CSharpObject CSS CSV Cursor Data Database Database Driver Database Painter Database Profile Database Provider DataObject DataSource DataStore DataStore (C#) DataStore (PS) DataType DataWindow DATE DATETIME DB2 Debug Debugger Debugging Deployment Design DLL DO-WHILE Dockable Docker Documentation DOUBLE Download DragDrop Edge Edit Style Editor Elevate Conference Email Embedded SQL Emulator Encoding Encryption Enhancement Request Entity Entity Framework ERP Error Event Event Handler Event Handling Excel Exception Export Expression External Functions F# Field File File Access Filter Firefox Firewall Font FOR-NEXT Foreground Format Function Garbage Collection GeoLocation Git Graph HANA Hash Header HTML/5 HTTP/S HTTPClient Icon IDE Identity IIS IMAPI Import InfoMaker Inheritance Installation Integer IntelliSense Interface Internet Internet Explorer iOS IPA iPad iPhone IWA J# Java JavaScript JBoss JDBC JOIN JSON JSONGenerator JSONParser Kestrel Label Lambda Large File LDAP Library License LINQ Linux OS Load Balancing Localization Localized PBVM Log In Log Out Logging LONG LONGLONG macOS MAPI Maps MDI Memory Memory Leak Menu Merge MessageBox Messagging Method Migration MIME TYPE Mobile Model ModelStore ModelStore (C#) MSOLEDBSQL Multi Threading MVC MySQL n-Tier Namespace NativePDF NVO OAuth ODATA ODBC Office Offline OLE OLEDB Online Open Source OpenAPI OpenSSL Oracle OrcaScript Other Outlook Output Package Parameter Patch PayPal PB Classic PB Native PB.NET PBC PBD PBDOM PBG PBJVM PBL PBNI PBORCA PBVM PBX PDF Performance Permission PFC Picture Pipeline Play Store (Google) Plugin Popup Port POST PostgreSQL PowerBuilder PowerBuilder (Appeon) PowerBuilder (SAP) PowerBuilder Compiler PowerBuilder Runtime PowerClient PowerScript (PS) PowerScript IDE PowerScript Migrator PowerServer PowerServer Mobile PowerServer Toolkit PowerServer Web PowerServerLabel Print Properties Proxy Publish PULL PUSH Query Regression Release Renew Resize Response REST Retrieve RibbonBar RibbonBar Builder Rich Text Roadmap RPC Runtime Packager SaaS Scaffolding Script SDI SDK Security Server Service Session Single Sign-on Size SMTP SMTPClient SnapDevelop SOAP Sort Source Code Speech Recognition SQL SQL Anywhere SQL Server SqlBuilder SqlExecutor SQLite SqlModelMapper Storage Stored Procedure Subscription SVN Swagger Syntax TabbedBar TabbedView Tablet TabPage Target TE Control Testing Text TFS Theme TIME Timer TLS/SSL Tomcat TortoiseGit TortoiseSVN Transaction Transparency Trial Trigger TRY-CATCH TX Control Type UI ULONG UltraLite Uninstall Unit Test Unit Testing UNIX OS Update Upgrade Upload URL User Center User Object UWP Validation VARCHAR Variable Versioning Visual Studio Visual Studio Code VM Voice Warning WCF Web API Web Extensions Web Service WebBrowser WebForms WebLogic WebSphere WildFly WinAPI Window Windows OS WinForms Wizard Workgroup Workspace WPF XCODE XHTML XML Zoom

Helpful?

If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.