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
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
Solved! Go to Solution.
freelance simulation specialist
I have coded in the EndSim
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?
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
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.
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.
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") ?
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.