04/06/2016 Agenda Agenda RTSIM RTSIM MetaSim MetaSim RTSIM RTSIM RTLib RTLib Real Real-Time Real Real Time Time system Time system system SIMulator system SIMulator SIMulator SIMulator Examples Examples Mauro Marinoni Mauro Marinoni Project Project proposals proposals ReTiS ReTiS Lab, Lab, TeCIP TeCIP Institute Institute Scuola superiore Sant’Anna - Scuola superiore Sant’Anna - Pisa Pisa 1 2 Component Component- -Based Software Design Based Software Design – – LMES LMES Component Component- -Based Software Design Based Software Design – – LMES LMES Real Real- -Time system Time system SIMulator SIMulator RTSIM is a collection of programming libraries written in C++ for simulating real-time control systems. It has been developed for experimenting with new scheduling algorithms and solutions. RTSIM RTSIM RTSIM RTSIM It already contains some classic real-time scheduling algorithms. l ith It consists of 2 components: MetaSim: it is a generic library for simulation of discrete event systems. Overview Overview RTLib: based on MetaSim, it is a library for simulating scheduling algorithms and real-time tasks. 3 4 Component Component- -Based Software Design Based Software Design – – LMES LMES Component Component- -Based Software Design Based Software Design – – LMES LMES RTSIM - RTSIM - Installation Installation MetaSim MetaSim MetaSim is a framework that allows to develop Both MetaSim and RTLib are available on GitHub : develop customized customized simulation entities simulation entities . https://github.com/glipari/metasim Each entity that can post discrete events in time. https://github.com/glipari/rtlib2.0 The framework also provides some useful classes in order to: Configurable using Cmake Configurable using Cmake handle random variables; Can be compiled under Unix, Mac and Windows collect statistical values; write traces and debug output. Testing support written using the Catch library The user can analyze the behavior of a system without Documentation can be generated using the Doxygen tool actually having it. 5 6 Component- Component -Based Software Design Based Software Design – – LMES LMES Component Component- -Based Software Design Based Software Design – – LMES LMES 1
04/06/2016 MetaSim MetaSim – – Simulations Simulations MetaSim MetaSim – – Classes Classes The main classes classes of the framework are: The model can run under different different conditions conditions and with Entities : they are the bricks with which is possible to model a system. different inputs, deterministic or randomly distributed . Every component of the system must be derived from this class. This class provides basic functionalities for initialization and provides a In a deterministic simulation the user is interested in naming system. analyzing the temporal evolution of the system state (trace) Events : simulations are based on the discrete event model. Events under certain conditions. are the basic objects for describing the temporal evolution of the system. If the input is randomly distributed , the user is interested RandomVar : the basic class to generate random variables from in obtaining statistics on certain system variables, like different distributions. average, variance, maximum and minimum value, Simulation : this is the main engine of the library. confidence intervals, etc. BaseStat : the basic class to collect statistics. Trace : the basic class to trace the behavior of a system 7 8 Component Component- -Based Software Design Based Software Design – – LMES LMES Component- Component -Based Software Design Based Software Design – – LMES LMES MetaSim MetaSim – – Classes Classes MetaSim MetaSim – – Entities Entities The main classes It is the base class for every simulation object. classes of the framework are: Entities : they are the bricks with which is possible to model a system. It has an internal status, an interface for modifying the status, Every component of the system must be derived from this class. This and can contain one or more events. class provides basic functionalities for initialization and provides a It can be referred also by its name (a string of characters) using naming system. the static method find . Events : simulations are based on the discrete event model. Events are the basic objects for describing the temporal evolution of the A specific entity class should redefine the find function for p y system. doing type checking. RandomVar : the basic class to generate random variables from Function newRun() resets the entity status at the beginning of every different distributions. run. It is called automatically at the beginning of every run, and Simulation : this is the main engine of the library. initializes the entity status. It can be redefined in order to perform the desired changes, for example to change the parameters after some BaseStat : the basic class to collect statistics. Mutually runs. Warning Warning : in newRun() is not permitted to create/destroy new exclusive entity objects. Trace : the basic class to trace the system behavior. 9 10 10 Component- Component -Based Software Design Based Software Design – – LMES LMES Component- Component -Based Software Design Based Software Design – – LMES LMES MetaSim MetaSim – – Events Events MetaSim MetaSim – – Events (2) Events (2) It is the basic event class, it models an event in the simulator and If the event is marked as disposable , the main simulation loop contains all the basic methods for handling it. will delete it after it has been processed. Setting disp to true To define a new ”type” of events in your system model, you need to gives the ownership of the object to the Simulation engine, derive a class from this, overriding the virtual doit doit() () method. which will destroy after using it. This class also includes a static event queue, where all ” active ” events When an event is ”triggered” in the simulation, its doit() are enqueued. method is invoked. To insert an event in the queue, you can call the post() method specifying a q , y p y g p () triggering time. In most of the cases, the doit() method simply calls a method Events are ordered in the queue by triggering time. of an entity, which will be informally called ” handler ” of the In case of two events with the same triggering time, events are ordered by event. In case the doit() method only calls the appropriate priority. The priority is for the object, and not for the class! event handler, you can use the template class GEvent< X > const int MetaSim::Event::_DEFAULT_PRIORITY = 8 instead of deriving a new class. It is not possible to post an event in the past, but is possible to post an event in the present. 11 11 12 12 Component Component- -Based Software Design Based Software Design – – LMES LMES Component Component- -Based Software Design Based Software Design – – LMES LMES 2
Recommend
More recommend