Cancel
Showing results for 
Search instead for 
Did you mean: 

ResetSimulation COM function

Creator
Creator

Hi everybody, I am using the COM interface to link Plant SImulation (COM object) with Matlab (calling program). I am using many commands and they works properly, but I do not understand how to use the ResetSimulation funciton.

In the Context Help the example says to use

eMPlant.ResetSimulation(".Models.Frame.EventController");

However, this code doesn't work and I think something before the ".Models..." should be put, but I do not understand what. Can someone help me? Thanks

10 REPLIES

Re: ResetSimulation COM function

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
this should work (if your eventController has this path), but EventController is also a Method of the frame, maybe this causes a problem
but you could try to call the reset method of the eventController:

eMPlant.executeSimTalk("EventController.reset")
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: ResetSimulation COM function

Creator
Creator
With this new code Matlab returns an error. Is it possible to code the reset of the EventController in the EndSim method? This would solve the problem since I wouldn't need the ResetSimulation function.

Re: ResetSimulation COM function

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
this should work

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: ResetSimulation COM function

Creator
Creator

I have coded in the EndSim 

EventController.reset;

 If I run the simulation from Plant Simulation, at the end the reset works. If I do it from Matlab, it doesn't, even if the other methods called in the EndSim method works. Thus, the COM Function SaveModel saves it in the end simulation state. 

 

What should I do to make the model reset at the end of the simulation?

Re: ResetSimulation COM function

Phenom
Phenom

the resetSimulation has to work.

 

I checked resetSimulation with v14.1 and this piece of .NET Code - this works

 

 

    Sub Main()

        Dim psi As eMPlantLib.IRemoteControl
        psi = CreateObject("Tecnomatix.PlantSimulation.RemoteControl.14.1")
        psi.LoadModel("c:\temp\x01.spp")
        psi.SetVisible(True)
        psi.ResetSimulation(".Modelle.Netzwerk.Ereignisverwalter")
        psi.StartSimulation(".Modelle.Netzwerk.Ereignisverwalter")

    End Sub

 

 

 

Re: ResetSimulation COM function

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Forest,

 

I'd assume that the reset methods didn't run yet. You can periodically check the attribute 'IsResetting' of the event controller and save the model when this attribut is false.

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: ResetSimulation COM function

Creator
Creator

I use V13, not V14. My COM code in Matlab is the following:

PlantSimulation = actxserver('Tecnomatix.PlantSimulation.RemoteControl.13.0');
PlantSimulation.LoadModel('C:\Users\....');
PlantSimulation.StartSimulation('.Models.Frame.EventController');

/*code of matlab (that also use the SimulationFinished event)*/

PlantSimulation.ResetSimulation('.Models.Frame.EventController');
PlantSimulation.SaveModel('C:\Users\...');

All the lines work well and also the SaveModel works fine. The problem is that the reset code do not work and the model is saved at its EndSimulation configuration.

 

If I understand well, you mean that the reset of the model takes some time and Matlab doesn't wait this time and thus it is saved without reset. As said before, I also tried to put the reset in the endsim method, but didn't work either with Matlab, whereas it works if I run the model from Plant Simulation.

 

I checked the "IsResetting" attribute after being saved by Matlab and it is false. It is like Matlab is skipping this line. 

Re: ResetSimulation COM function

Phenom
Phenom

I've checked with v13 - this also works (s. code below)

 

Sub Main()

        Dim psi As eMPlantLib.IRemoteControl

        psi = CreateObject("Tecnomatix.PlantSimulation.RemoteControl.13.0")
        psi.LoadModel("c:\temp\x01.spp")
        psi.SetVisible(True)

        psi.ResetSimulation(".Models.Frame.EventController")
        psi.StartSimulation(".Models.Frame.EventController")


    End Sub

 

 

I've  noticed your executeSimTalk code  doesn't contain the full path

 

Have you tried the simtalk 2 workaround with ...executeSimTalk (".models.frame.eventcontroller.reset") ?

Re: ResetSimulation COM function

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Forrest,

 

One addition to my previous answer. You first have to wait that 'IsResetting' becomes true and then you have to wait that it becomes false again.

When you get the notification that the simulation is finished the reset phase which you initiated in EndSim hasn't started yet.

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.