#include <streamdrivensystem.h>
Inheritance diagram for simth::StreamDrivenSystem:
Public Member Functions | |
StreamDrivenSystem (const std::string &fileName) | |
virtual | ~StreamDrivenSystem () |
virtual void | connectInterface (ControlInterface *interface, const std::string &varName) |
virtual const Device * | device (int deviceNr) const |
virtual void | acceptSignal (Device *dev, process_signal sig) |
virtual double | startSimulation (int mode=0) |
virtual void | print (std::ostream &os) const |
The connection between the interfaces of the device blocks (see FreeConnectionSystem) is defined by the help of a connection file. The name of this file and other parameters are defined in a so-called parameter file. The name of that file is passed as argument in the constructor.
The simulation is started with the start device, i.e. the device that ID equals the start device number. This number can set by the parameter 'start_device_number' in the parameter file. By default this number is set to zero. The start device has to be a special device that needs no input data to start processing. An example for such an block is a BitGenerator defined in SimtheticLib. The function Device::process() of that device will be invoked by the StreamDrivenSimulationSystem to start the simulation. The output of the start device will be the input data of other devices (that are connected with that start device). If a device gets new input data to one of its input interfaces, the function acceptNewData() of that device is called (by the connected device that send the data). Since the function acceptNewData() is declared virtual, a device can react to incomming data by its own choice implementing its own version of acceptNewData(). (The standard implementation of acceptNewData() checks the current lengths of stored input data of all input interfaces and sends the READY_TO_PROCESS signal if each of them exceeds a certain length.)
If a device sends a 'READY_TO_PROCESS' signal, the StreamDrivenSystem will queue a request for processing of that device in a 'process queue'. During a simulation run, the StreamDrivenSystem calls the process functions of the device whose 'request for processing' is in the first position of the process queue, and then consecutively every next device.
If the process queue runs empty, the process() function of the start device is called.
If a device sends a 'STOP_ITERATION' signal, the StreamDrivenSystem stops the current iteration. This means, that no new(!) request for processing will be accepted by the StreamDrivenSystem and the process function of the start device will not be called if the process queue runs empty. With other words, only 'request for processing' that had been queued in the process queue, will be processed by the StreamDrivenSimulationSystem, i.e. the process functions of the corresponding devices will be called.
|
Constructor of the stream driven simulation system. The passed argument specifies the name of the parameter file. |
|
|
|
Connects a ControlInterface of the Device calling this function to a loop control of the StreamDrivenSystem.
Implements simth::DeviceSystemIntf. |
|
Returns a pointer to the specified device (constant version). Implements simth::DeviceSystemIntf. |
|
Receive a signal from the specified device. WATCH OUT: These 'signals' are only signalled through functions in the simth::Device class. In any derived Device, you should only call the funtions in the Device base class, not directly the acceptSignal() function.
Implements simth::DeviceSystemIntf. |
|
Main function of the stream driven simulation system. This function is called by the main function to start the simulation.
Implements simth::SimulationSystem. |
|
Prints information about the simulation system to the given ostream. In order to give more detailed information, a derived class shoul reimplement this function.
Reimplemented from simth::SimulationSystem. |