Counter

counter

A simple model that counts events received in any input port. First, we create a new package with the following command: mkdir -p cd $HOME/vle/tutorial cd $HOME/vle/tutorial vle-2.0 -P examples create We add the file counter.cpp and update the CMakeLists.txt file in the src directory. #include <vle/devs/Dynamics.hpp> #include <vle/value/Double.hpp> namespace example { class Counter : public vle::devs::Dynamics { public: Counter(const vle::devs::DynamicsInit& model, const vle::devs::InitEventList& events) : vle::devs::Dynamics(model, events) , m_counter(0), {} virtual ~Counter() = default; virtual vle::devs::Time init(vle::devs::Time& time) override { return 0; } virtual vle::devs::Time timeAdvance() const override { return vle::devs::infinity; } virtual void externalTransition(const vle::devs::ExternalEventList& events, vle::devs::Time time) override { m_counter += events.

Tutorial 01: counter-generator

In this first example, we will create simulation of two models: an event generator and a event counter. First, we need to create a new empty package in the user home directory. cd $HOME/examples vle-1.1 -P generator-counter create vle-1.1 -P generator-counter configure build The binary package is now installed into the VLE’s home ($VLE_HOME/pkgs-1.1 or $HOME/.vle/pkgs-1.1). Now, we need to add two DEVS models, the counter and the generator. Copy the file Simple.

counter

A simple model that counts events received in any input port. First, we create a new package with the following command: mkdir -p cd $HOME/vle/tutorial cd $HOME/vle/tutorial vle -P examples create We add the file “counter.cpp” and update the CMakeLists.txt file in the src directory. #include <vle/devs/Dynamics.hpp> #include <vle/value/Double.hpp> namespace example { class Counter : public vle::devs::Dynamics { public: Counter(const vle::devs::DynamicsInit& model, const vle::devs::InitEventList& events) : vle::devs::Dynamics(model, events) , m_counter(0), {} virtual ~Counter() {} virtual vle::devs::Time init( const vle::devs::Time& /* time */) { return 0; } virtual vle::devs::Time timeAdvance() const { return vle::devs::infinity; } virtual void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { m_counter += events.