Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Find and share HowTos to various installations / configurations!
6 posts • Page 1 of 1
ozangor
Posts:44
Joined: Thu Sep 22, 2011 2:57 pm

Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by ozangor »

Greetings everyone,

I'm not sure if the subject is clear.

What I'm trying to achieve is as follows:

Let's consider a websocket server object in the c++ side. It is possible to define callback functions for connection opened, closed, message received and some other events.

I want to define those callback functions in WinCC OA and register them to the server object's event handlers. In other words, I need to send information in both directions.

Imagine that my server manager class in the library can handle multiple servers and my servers can handle multiple clients, my callback in wincc oa should look like for the message received event:

Code: Select all

CallbackFunction(uint serverId, uint clientId, string message | blob message)
{
  doWhatever(serverId, clientId, processMessage(message));
}
A quite similar thing is already there in the httpConnect's callback for websockets. It gets the connection information(id, etc.) as a mapping and the message is read in the callback function with httpReadWebSocket(). It is possible to send back any response by simply using the connection id given in the mapping.

Any advice/solution would be appreciated.

Thanks in advance. With best regards,

Ozan

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by mkoller »

See this thread for an example implementation:
https://portal.etm.at/index.php?option= ... =1040#1042

ozangor
Posts:44
Joined: Thu Sep 22, 2011 2:57 pm

Re: Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by ozangor »

Oh, thank you very much.

That's exactly what I was looking for.

ozangor
Posts:44
Joined: Thu Sep 22, 2011 2:57 pm

Re: Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by ozangor »

Hi again,

I could not manage to make it work for my implementation. For testing purposes, I tried to write a control extension which only looks for a function and calls it, instead of using it in a more complex system. It did not work either.

I get access violation exception when I call any of startFunc/startThread/startSingleThreadFunc methods: Unhandled exception at 0x000007FEDE792EEF (libCtrlV314.dll) in WCCOAui.exe: 0xC0000005: Access violation writing location 0x0000000000000018.

In addition, your example TCP server does not work for me as well. It is possible to start listening, and the test client is able to connect. However, when a message is sent, the incomingConnection method is never called.

I would be more than happy if you just could explain me the simplest steps to achieve it. API documentation is nowhere near being descriptive. I'm using WinCC OA 3.15 with latest patches, Windows x64.
The dll which throws the exception is "libCtrlV314". Does 3.15 still use 3.14 dll? Or is there something wrong with my environment variables etc?

Kind regards,
Ozan

Edit: okay, the last sentence I wrote was the source of the problem. It works now.

Merikarhu
Posts:13
Joined: Wed Jun 07, 2017 3:19 pm

Re: Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by Merikarhu »

Can you tell exactly what you did because im having almost same problem, im also getting Access violation when trying to call function.

ozangor
Posts:44
Joined: Thu Sep 22, 2011 2:57 pm

Re: Control Extensions - Defining callbacks and passing arguments to them for the events triggered in the objects used in a control extension

Post by ozangor »

Hey,

My OS is Windows, first of all.

Check the environment variables, especially api_root. If you need to change this variable, you will need to restart your pc to have changes applied. Then call checkAPIenv.cmd (i think this was the correct file name) in the api_root folder.
Try to create new clean ctrl extension with the given batch file. (newWCCOACtrlExt??? something like this). Then move your existing implementation to this project and if you are using 64bit system, use Visual Studio Developer Prompt to start your project by:

Code: Select all

start /b devenv "solutionfilename.sln"
For me, I was using 3.15 api but my api root set to 3.14 folder. After these steps, it worked as it supposed to.

Hope this will help you.

Regards,
Ozan

6 posts • Page 1 of 1