JaamSim for event management

323 views
Skip to first unread message

Brian

unread,
Aug 20, 2015, 2:10:39 PM8/20/15
to Jaamsim Users Discussion Group
First let me say that I am very new to JaamSim so hopefully my question isn't too off base...

What I'd like to do is use the JaamSim source for an event manager within an existing publish/subscribe framework that I've developed. Messaging can be from any number of producers, but will ultimately end up at the single consumer. The consumed message will contain the simulation time of the event as well as the event itself (the information needed to create the event).

My idea is this...as the consumer consumes a message, hand it off to JaamSim to be scheduled for execution at some point in the future. When the event is actually processed, it would then be handed off to some other software that would actually handle the guts of the event. So basically, I'm just (for now), attempting to use JaamSim to manage the timing of the events.

This can be thought of as a real-time simulation of events with the simulation end time unknown.

I realize this is pretty vague, but at first glance does JaamSim seem to be a viable choice for my use case?

Thanks,

Brian

Harry King

unread,
Aug 20, 2015, 2:48:17 PM8/20/15
to Jaamsim Users Discussion Group
Brian,

This sounds do-able. The main feature that JaamSim's event engine would provide you is the ability to handle huge numbers of events very efficiently. Most of the classes you need can be found in com.jaamsim.events. I assume that you don't want any of the user interface or 3d graphics.

Is the GPL license an issue for you?

Harry

Brian

unread,
Aug 20, 2015, 4:17:52 PM8/20/15
to Jaamsim Users Discussion Group

Thanks for the reply and I'm glad to hear you think this is do-able.

I'm actually still trying to work out in my head which parts I'd like to leverage from JaamSim and which parts need to be separately developed. For instance, some of the events being consumed would be passed on to a 3D visualization software (NASA World Wind, for example) to be rendered. If possible, one might think of integrating a new View into JaamSim that is actually the World Wind canvas, which also uses Jogl. You can possibly imagine a WorldWindDisplayEntity as well, for example (hopefully I'm on the right track here).

How will JaamSim handle not knowing when the simulation is to end? I imagine that an "EndOfData" message would be produced to indicate data flow is ended, at which point I could add an EndSim (or whatever it is in JaamSim) event to be processed, at which point the simulation would be complete.

The license should not be an issue here.

Thanks again,

Brian

Harry King

unread,
Aug 20, 2015, 5:08:53 PM8/20/15
to Jaamsim Users Discussion Group
Brian,

Another JaamSim user is using World Wind in their simulation system, however, there is no way to integrate World Wind's 3d graphics with JaamSim's 3d graphics and windowing system. They have to operate completely separately application, interfaced through text files. It would be possible to add GIS capabilities to JaamSim -- we have considered adding the ability to import Shape files, but this is low down on our want-list right now.

JaamSim is fine with an open-ended simulation run. If the event queue ever becomes empty, JaamSim will jump to the next event time which is t = infinity.

Harry

Brian

unread,
Aug 20, 2015, 5:20:47 PM8/20/15
to Jaamsim Users Discussion Group

This is due to JaamSim's use of NEWT?

Harry King

unread,
Aug 20, 2015, 7:06:57 PM8/20/15
to Jaamsim Users Discussion Group
Brian,

NEWT is just one of the problems. All the complex functionality of World Wind is tied directly to the graphics in a million places. There is no easy way to swap out one graphics system for another.

Harry

Brian

unread,
Aug 21, 2015, 11:35:28 AM8/21/15
to Jaamsim Users Discussion Group

Makes sense. So, are there any examples anywhere of programmatically creating a simulation? Something to give me a jump start? I can surely figure it out from the manual and the source, just curious.

Thanks for your help.

Brian

slash...@gmail.com

unread,
Aug 21, 2015, 1:33:31 PM8/21/15
to Jaamsim Users Discussion Group
I would be very interested in said examples as well.

Harry King

unread,
Aug 21, 2015, 2:32:44 PM8/21/15
to Jaamsim Users Discussion Group, slash...@gmail.com
Brian,

Unfortunately, we don't have an example, but it should be fairly easy to follow the steps in the JaamSim code. The GUIFrame method main() builds the whole simulation environment. You can find it in the package com.jaamsim.ui.

Harry

Harvey Harrison

unread,
Aug 21, 2015, 2:36:28 PM8/21/15
to Harry King, slash...@gmail.com, jaamsi...@googlegroups.com

The unit tests in the SRC/test folder are all pretty minimal examples to get just the event handling set up and working, that framework may be a good jumping off point for you.

Harvey

--
You received this message because you are subscribed to the Google Groups "Jaamsim Users Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jaamsim-user...@googlegroups.com.
Visit this group at http://groups.google.com/group/jaamsim-users.
To view this discussion on the web, visit https://groups.google.com/d/msgid/jaamsim-users/81f1f6de-9cc3-4986-9154-bb914827bb6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian

unread,
Aug 30, 2015, 5:21:39 PM8/30/15
to Jaamsim Users Discussion Group, d.harr...@gmail.com, slash...@gmail.com
Excellent.  I've taken a look at the unit tests and the manual, and have come up with a quick working solution.  I feel it is not entirely correct, however.

If you could, would you mind seeing if I'm on the right track thus far...

Again, what I'm going for is this:  Any number of producers can produce EventMsg objects that will be consumed.  These producers can produce any number of messages and any given rate.  Once consumed, I'd like to hand off to JaamSim to manage the simulation at some step-rate of my choosing (more often than not real-time, but some multiple of real time sometimes).

I've managed to create an EventManager and schedule events.  I then call resume(), which grabs the next Process and executes it.  So, I'm actually executing my scheduled events (awesome!).  However, I believe the timing isn't working as I'd like it to.  When I call resume(), I pass it Long.MAX_VALUE.  I suspect this is incorrect.  However, if I don't give it that value (or some other value that is beyond all scheduled events), all of my events aren't executed.  Here is where I'm looking for some guidance.  Is what I'm doing correct?  I suppose my real question is this....how do I kick off the "simulation" such that, once started, it will continue to execute events until I stop it?

I've attached a quick diagram to, hopefully, help with understanding what it is that I'm doing.  If what I'm doing doesn't make sense at all, forgive me, I've really just begun to look into how to use JaamSim in this manner.

Thanks again for your help!

Brian
JaamSimExpl.pdf

Harvey Harrison

unread,
Aug 31, 2015, 12:24:24 PM8/31/15
to Brian, Jaamsim Users Discussion Group, Harry King, Mark Manser
Hi Brian,

I think eventManager is going to be able to do what you want, but you
will probably have to add the real-time parts yourself as the
eventManager realtime parts are not going to be usable for this
purpose. The reason being is that once started, the eventManager will
not allow any external events to be scheduled in, to ensure it is
deterministic. So, what I would suggest is:

Buffer up say 20-50ms (or some time step) worth of your event producer
messages, and then add all the jaamsim events that are produced from
those, then call resume() on the eventmanager with an argument equal
to the target simulation 'ticks' value you want to run the simulation
forward until, but also register a listener with the eventanager to
know when it has paused after running forward to that target
value....now wait 20-50ms and run another step forward in the
eventManager with resume(ticks + 20ms worth of ticks)

If you put a delay in your outer code that waits the 20-50ms before
running each step, you'll have somewhat chunky 'realtime'.

The same unit tests I pointed you to last time are a good example of
how to get a listener attached that notifies you when the eventmanager
starts/stops.

Does that work for you, or have I misunderstood what you're trying to do?

Harvey
> https://groups.google.com/d/msgid/jaamsim-users/8bbbeeaa-22b9-47f0-9feb-5746717e0d27%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages