load and unload StateMachine

Hi all

I have one component with a state Machine. The name of the file that contains the stateMachine is a property. So i load the stateMachine in the configureHook (after read the property) I want te stop/cleanup/configure and restart the component. I have a Log ERROR when i want to reconfigure the component ( Parse error at line 32: Semantic error: TaskContext 'Component' has already an Object named 'smTest').

 
Here is an example of the code
    • Fonction appelee au demarrage du composant

 *  Role : configurer les liens avec les autres composants
 *  @return true si configuration OK false sinon
 */
bool Component::configureHook() {
    bool res = true;
    this->scripting()->loadStateMachines( propStateMachineName.get() );
    m_ptrSM =  this->engine()->states()->getStateMachine("sm");
    if ( m_ptrSm != NULL)
    {
      res = true;
    }
     return res;
}void Component::stopHook() {
    m_ptrSM->stop();
    m_ptrSM->deactivate();
}void Component:cleanupHook() {

    scripting()->unloadStateMachine(propStateMachineName.get() );
}

Of course , i can load ths stateMachine only if my pointer mPtrSM is NULL, but it seems to be a bad solution. It would be better if it was possible to call a method for doing that. How can i solve this problem ?

Didier GHi

Didier G

Hi Peter

Unfortunately, the call of the methods this->removeObject( "propStateMachineName.get()" ) didn't work. I can see on the taskbrowser that the statMachine isn't removed from the component (the stateMachine is desactivated) wahen id a cleanup on my component

Now , in the cleanup, i call the method engine()->states()->clear(). It its ok. when i do a cleanup on my component, the statemachine is removed from the component.

In case of submachine, how can i remove the submachine on my component

Didier

Didier GHi

Didier G

Hi Peter

Unfortunately, the call of the methods this->removeObject( "propStateMachineName.get()" ) didn't work. I can see on the taskbrowser that the statMachine isn't removed from the component (the stateMachine is desactivated) wahen id a cleanup on my component

Now , in the cleanup, i call the method engine()->states()->clear(). It its ok. when i do a cleanup on my component, the statemachine is removed from the component.

In case of submachine, how can i remove the submachine on my component

Didier

Didier GHi

On Thu, Nov 19, 2009 at 17:53, <didier [dot] gardan [..] ...> wrote:
> Didier G
>
> Hi Peter
>
> Unfortunately, the call of the methods this->removeObject( "propStateMachineName.get()" ) didn't work. I can see on the taskbrowser that the statMachine isn't removed from the component (the stateMachine is desactivated) wahen id a cleanup on my component

But when the unloadStateMachine call fails, don't you get an error log
? I found the bug in your code. You wrote:

&#10;scripting()-&gt;unloadStateMachine(propStateMachineName.get() );&#10;
It should have been:
&#10;scripting()-&gt;unloadStateMachine( &quot;sm&quot; );&#10;

>
> Now , in the cleanup, i call the method engine()->states()->clear(). It its ok. when i do a cleanup on my component, the statemachine is removed from the component.
>
> In case of submachine, how can i remove the submachine on my component

The submachine should be automatically removed when the parent machine
is removed. The unloadStateMachine call takes care of this.

Peter

load and unload StateMachine

Hi Didier,

On Thu, Nov 19, 2009 at 11:18, <didier [dot] gardan [..] ...> wrote:
> Hi all
>
> I have one component with a state Machine. The name of the file that contains the stateMachine is a property. So i load the stateMachine in the configureHook (after read the property)
> I want te stop/cleanup/configure and restart the component. I have a Log ERROR when i want to reconfigure the component ( Parse error at line 32: Semantic error: TaskContext 'Component' has already an Object named 'smTest').
>
>
> Here is an example of the code
> ** Fonction appelee au demarrage du composant
>  *  Role : configurer les liens avec les autres composants
>  *  @return true si configuration OK false sinon
>  */
> bool
> Component::configureHook()
> {
>    bool res = true;
>    this->scripting()->loadStateMachines( propStateMachineName.get() );
>    m_ptrSM =  this->engine()->states()->getStateMachine("sm");
>    if ( m_ptrSm != NULL)
>    {
>      res = true;
>    }
>     return res;
> }
> void
> Component::stopHook()
> {
>    m_ptrSM->stop();
>    m_ptrSM->deactivate();
> }
> void
> Component:cleanupHook()
> {
>    scripting()->unloadStateMachine(propStateMachineName.get() );
> }
>
> Of course , i can load ths stateMachine only if my pointer mPtrSM is NULL, but it seems to be a bad solution. It would be better if it was possible to call a method for doing that.
> How can i solve this problem ?

Normally, unloadStateMachine should remove the taskobject too. I don't
know yet why this didn't happen in your case, but you can by-pass
this by adding to cleanupHook:

void
Component:cleanupHook()
{
scripting()->unloadStateMachine(propStateMachineName.get() );
// work around bug not removing the object representing the SM:
this->removeObject( propStateMachineName.get() );
}

Hope this helps !

Peter

load and unload StateMachine

Hi all

I have one component with a state Machine. The name of the file that contains the stateMachine is a property. So i load the stateMachine in the configureHook (after read the property)
I want te stop/cleanup/configure and restart the component. I have a Log ERROR when i want to reconfigure the component ( Parse error at line 32: Semantic error: TaskContext 'Component' has already an Object named 'smTest').

Here is an example of the code
** Fonction appelee au demarrage du composant
* Role : configurer les liens avec les autres composants
* @return true si configuration OK false sinon
*/
bool
Component::configureHook()
{
bool res = true;
this->scripting()->loadStateMachines( propStateMachineName.get() );
m_ptrSM = this->engine()->states()->getStateMachine("sm");
if ( m_ptrSm != NULL)
{
res = true;
}
return res;
}
void
Component::stopHook()
{
m_ptrSM->stop();
m_ptrSM->deactivate();
}
void
Component:cleanupHook()
{
scripting()->unloadStateMachine(propStateMachineName.get() );
}

Of course , i can load ths stateMachine only if my pointer mPtrSM is NULL, but it seems to be a bad solution. It would be better if it was possible to call a method for doing that.
How can i solve this problem ?