1 Reply Latest reply on Jul 3, 2008 4:50 PM by heiko.braun

    SAM's simulation API

    heiko.braun

      I've commited the first cut of a simulation API that layers a top of javasim.
      It should help exploring SAM's event processing capabilities and API.

        • 1. Re: SAM's simulation API
          heiko.braun

          Javadocs will follow. But to give you an idea here's an example taken from a unit test:

           // config
           Properties config = new Properties();
           config.put(EventSimulation.TOTAL_SIM_TIME, 60.00);
          
           // init
           EventSimulation simulation = EventSimulation.bootstrap(
           config,
           Thread.currentThread().getContextClassLoader().getResource("simulation/esper-cfg.xml")
           );
          
           // shared between all entities
           SimulationContext context = simulation.getContext();
          
           // create an event source and associate a message factory
           EventSourceEntity source = new EventSourceEntity("source-A", 0.10);
           source.setEventMessageFactory( new SensorMessageFactory() );
          
           // create an event sink
           EventSinkEntity sink = new EventSinkEntity("sensor-events-viz");
           sink.setEventHandler( new ChartGenerationHandler() );
          
           simulation.addSource(source);
           simulation.addSink(sink);
          
           // bind statements to test
           simulation.bindStatement("select * from SensorEventMessage.win:length_batch(10)", sink);
          
           // start simulation
           simulation.singleRun();