main_randEvents.py
This application demonstrates a simulation of a set of randomly generated observable events.
This is the entry point script for the random global events, meaning that this is the one you need to execute. This is a managed application, so you need to execute this code before starting up the NOS-T Manager application. The application contains a single EventGenerator class which generates the random events for the simulation in a
DataFrame and listens to the time status published by the manager application and publishes event information
at the specified start datetime, sunrise/sunset datetime, and event finish datetime.
- class EventGenerator(app, event_count, max_event_duration, scenario_start, scenario_length, seed)
Bases:
ObserverThe EventGenerator object class inherits properties from the Observer object class in the NOS-T tools library
This object class initializes an array of events randomized by location, start-time, and duration. The observer watches the simulation clock and publishes
EventStarted,EventDayChange, andEventFinishedmessages at the appropriate scenario times.- app
An application containing a test-run namespace, a name and description for the app, client credentials, and simulation timing instructions
- Type:
ManagedApplication
- max_event_duration
An upper bound for any random draw setting the duration of an event in hours
- Type:
- seed
A value specifying the seed used for pseudorandom number generation for event locations and start times
- Type:
- generate_events()
A method called during object initialization to generate events with ID, start time, finish time, latitude and longitude, list of sunrise/sunset times, and indicator of initial day/night status.
- on_change(source, property_name, old_value, new_value)
Standard on_change callback function format inherited from Observer object class
In this instance, the callback function checks the simulation
datetimeagainst each scheduled event startdatetime, sunrise/sunsetdatetime, and finishdatetimefor the scenario. If immediately past any of these event times, anEventStarted,EventDayChange, orEventFinishedmessage is sent to PREFIX/event/start, PREFIX/event/dayChange, PREFIX/event/finish, respectively.