WinCC OA 3.14 P13 - Linux
I am netPosting to a server which occasionally restarts, so netPost gets stuck. I searched the doc and found no timeout parameter for this function.
The netPost queries run in a separate WCCOActrl manager.
Tried to do program async (and cancellable) netPosts in separate thread, via startThread. So the calling thread will start another, which will do the netPost, whilst the first one regularly polls the result variables (polling thread acting like sort of a pulsed-active barrier). waitThread is a no-no, because does not have a timeout either. (Or does it?)
A problem emerges here: there is not a (straight) way, or I have not found it, to share chosen variables (memory) between two threads.
The following code prints "1" to the log.
Code: Select all
int myValue;
main() {
myValue = 1;
waitThread(startThread("myFunc", myValue)); // pass by reference does not work through start thread. Probably to avoid the non-sense if main() finished before the started thread, and the variable would've gone out of scope.
DebugN(myValue);
}
void myFunc(int& val) {
val = 42;
}
- Use function-declared (local) variables -> don´t get shared
- Use library variables -> probably my next step: declare some mapping in a .ctl file, and use synchronized access to support simultaneous netPosts (each call gets a unique key used to access the mapping).
- Use datapoint(s) for synchronization: the whole point of trying to use shared variables is to avoid unrelated communications with the event manager.