Method \"startFunc\" of \"Controller\" class

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
9 posts • Page 1 of 1
eMichx
Posts:64
Joined: Thu Apr 24, 2014 11:24 am

Method \"startFunc\" of \"Controller\" class

Post by eMichx »

Hello,

I'm testing the method startFunc defined for the "Controller" class, but I have some difficulties to use it.

- Is there any possibility to send several arguments (different from DYN_VAR) with different types?
The "Variable" class used for the parameter " Args ", does not know how to manage lists!

- When I execute " startFunc ", it seems that the scenario is not any more executed when a function is called inside the function executed with " startFunc "!
for example, 2 functions Debug, just the first one is executed!

- How do we get back the value of return of the executed function?

regards
Emmanuel

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: Method \"startFunc\" of \"Controller\" class

Post by Gertjan van Schijndel »

It is possible to send several arguments with different types to the 'startFunc' method by placing the arguments in a 'RecVar' as described in the header file in the description of the 'args' argument:

Code: Select all

This can either be a pointer to any Variable subclass if you pass only one value or it can be a pointer to a RecVar holding more parameters for the function.
You can use the 'startThread' method of the 'CtrlScript' class to execute complex functions.

You can pass a 'DoneCB' object to the 'startFunc' or 'startThread' function to get the return value of the executed function back as described in the header file in the description of the 'done' argument:

Code: Select all

DoneCB::execute() will be called with the value the function returns with the "return" statement

eMichx
Posts:64
Joined: Thu Apr 24, 2014 11:24 am

Re: Method \"startFunc\" of \"Controller\" class

Post by eMichx »

Thanks,

The RecVar is working well.

I have changed my code to use startThread, but it seems that there is no change. I have modified the function of the library to keep
just 2 lines Debug(). When the startThread method is executed, just the first one Debug is called.
Furthermore, I have no ExecReturn for startTheard (idem for startFunc). it's seems to be locked
There is no call of thread in the called function, nor any loop!


regards
Emmanuel

eMichx
Posts:64
Joined: Thu Apr 24, 2014 11:24 am

Re: Method \"startFunc\" of \"Controller\" class

Post by eMichx »

Helllo,

I have found the reason of the short execution of the called function, it was due to the fact that methods startFunc didn't wait the complete execution
of the function.
Would there be a function which waits for the end of a thread? Or do I have to use a standard function as WaitForSingleObject?

regards
Emmanuel

eMichx
Posts:64
Joined: Thu Apr 24, 2014 11:24 am

Re: Method \"startFunc\" of \"Controller\" class

Post by eMichx »

Hello,

I'm trying also to use method "startThreadRefParam", but one of the param passed by reference doesn't contain
the new value.
The parameter has been append with RecVar::append method like :
TextVar* RetValue = new TextVar("none");
Param.append(RetValue);
...
libCtrl->startThreadRefParam(ThreadPtr, LibFuncPtr, &Param);
where LibFuncPtr is pointed to the result of the method findFunc("getProperty",...)

In my library, the function is defined as :
void getProperty(string param1, string param2, string& RetVal, const bool var =false) {
...
RetVal = xxx;
}

When I use RetValue->debug, my variable contains the original value! not the new expected value!
any idea?

regards
Emmanuel

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

Re: Method \"startFunc\" of \"Controller\" class

Post by mkoller »

Don't use startThreadRefParam
It's not meant to be a public API (in fact it really should be private).
It's called by startFuncRefParam() - see limitations there.
(The method only does what you want when the code in your CTRL script function has 1 line without calling another function).

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

Re: Method \"startFunc\" of \"Controller\" class

Post by mkoller »

Are you implementing a CTRL extension or a new Manager ?
If the latter, you must periodically call (in your main loop) Controller::work().
This is the entry point for the whole CTRL script interpreter working a bit on checked-in scripts.
Never(!) use WaitForSingleObject or similar (and this isn't even platform neutral!).

eMichx
Posts:64
Joined: Thu Apr 24, 2014 11:24 am

Re: Method \"startFunc\" of \"Controller\" class

Post by eMichx »

Thanks,

do you have some examples on the use of the CtrlScript::work method?

regards
Emmanuel

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

Re: Method \"startFunc\" of \"Controller\" class

Post by mkoller »

I wrote Controller::work(), not CtrlScript::work().
The former is the API you should use, the latter is used internally by the CTRL interpreter engine.

9 posts • Page 1 of 1