Using node-red with ERP using ActiveX COM

Has anyone had any success using node-red to consume activeX COM objects? My specific requirement is to communicate with an ERP system (3rd party software) installed on the same machine node-red is installed so I can transact with it

I've not tried but maybe you could share some more about what you are trying to achieve so we could give some thoughts that might help?

Is this a user interaction? Automation?

If not possible directly, you could eventually do it in Python. I did this once in Python myself several years ago. Today I would then also use MQTT to communicate with NR

ERP <---> Python/MQTT Client <---> MQTT Broker <----> NR w MQTT Client

Thank you. So, we have a third party manufacturing requirements planning (MRP) system that sits on a SQL Server database. I have successfully accessed the data using [node-red-contrib-mssql-plus] which is great for reading data.

The challenge I have is writing to the database because there is a business layer that encapsulates a variety of undocumented business rules, so, by writing straight to the database we will corrupt it. So a simple request like [Create Purchase Order] might actually affect 3 or 4 database tables.

The business rules are implemented through a class library in a COM component (DLL) installed on the same server as Node-RED. I can browse the interfaces using something like Visual Studio but I can't see a way to access the DLL/COM interfaces using Node-RED so I can invoke these end-points.

There is currently no API onto the MRP and the risk/cost of replacing it would be prohibitive at this stage. We are currently using a proprietary third party platform to achieve the above requirement, it's expensive but more importantly difficult to maintain the equivalent flows which is why we are investigating Node-RED.

Appreciate any input/guidance you can provide on this.

I have, in the past, had to do something similar. What I did was to watch the database (using profiler) and understand what changes were made then simply re-created that in node-red - bypassing the DLL altogether.

Failing that, you could create a wrapper (proxy) application in VS (c# or VB.NET) that includes an MQTT client lib (there are a few to chose from). Have this wrapper application subscribe to a set of known topics that then call the various Active-x functions (e.g. a proxy application) & then publish the results back to a known topic for node-red to consume.

1 Like

Exactly, but I did it all in Python :wink: Importing a DLL and to use functions via entry points is straight forward

from ctypes import .....

Anyway would work the same, just the individual taste for language selection and suitable prefered tools that matters.

Is python able to automate COM (AKA Active-X) DLLs?

yes, I have done it but the result was then running under Windows

In that case, loading an ActiveX (OCX), I just code as below (simplified), just gives the idea

import win32com.client

and then

    def attachOCX(self, flag):
        #Attach interface to the OCX
        self.AxkmkusbT = None
        try:
            self.AxkmkusbT = win32com.client.Dispatch(
                "KMKUSB5I8OOCX.KMKUSB"
            )
        except: 
            raise eg.Exception(
                self.b_nbr,
                self.text.txt_OCX_CannotBeFound_T
            )
        if self.AxkmkusbT != None and flag:
            print self.b_nbr, self.text.txt_OCX_Found_T

2 Likes

That is really useful thank you all!
I'll give that a try.

I prefer python but for automating Active-x in a .NET env is far easier.

Include a reference to the DLL, declare an instance Dim WithEvents AxThirdParty1 As AxThirdParty.ThirdPartyControl then call its functions AxThirdParty1.DoSomething()

1 Like

Quite a few references to calling COM DLL's from node.js

https://www.google.com/search?q=node.js+how+to+call+a+COM+dll

Though I imagine they all assume that node.js (in your case Node-RED) will be running on Windows.

Indeed, there is this: win32ole - npm

It is 9y old - but might work (or there may be newer alternatives)?

Update: there are quite a few :thinking: This one was published 3m ago: winax - npm

Hi,

If you are able to 'connect' and 'drive' the COM objects with Python then you would not need to use MQTT or any alternative broker. Python and interface with Node-RED. There may be advantages of using MQTT if you wish to take a pub / sub 'messages' type approach, but it is not strictly necessary.

Cheers,

Paul

Paul

With this I assume you could maybe even use it inside NR in a function node!?? Just installing & adding a line in settings.js...

    functionGlobalContext: {
        winax:require('winax'),

Dont need to do that if you dont want to...


image

note

your node-red server must have the developer tools installed for these nodes as they have a built step

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.