00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00037 #ifndef STEAM_DRIVEN_SYSTEM_HEADER
00038 #define STEAM_DRIVEN_SYSTEM_HEADER
00039
00040
00041
00042 #include <queue>
00043 #include <map>
00044 #include <iosfwd>
00045 #include <iostream>
00046 #include <string>
00047
00048 #include <simthetic/freeconnectionsystem.h>
00049 #include <simthetic/phbib.h>
00050 #include <simthetic/exceptions.h>
00051 #include <simthetic/basicsimulationsystem.h>
00052 #include <simthetic/devicesystemintf.h>
00053 #include <simthetic/connection.h>
00054 #include <simthetic/basicdevicefactory.h>
00055 #include <simthetic/devicemanager.h>
00056 #include <simthetic/parameterdescription.h>
00057
00058 namespace simth
00059 {
00060
00108 class StreamDrivenSystem : public FreeConnectionSystem
00109 {
00110 private:
00111
00112
00113
00114 std::string parameterOutputFileName;
00115
00116
00117 std::queue<Device*> processQueue;
00118
00119 typedef simth::checkedVector<std::string> StringList;
00120 StringList libPaths;
00121 StringList preLoadLibs;
00122 int startDeviceNumber;
00123 bool verbose;
00124
00125 simth::checkedVector<LoopControl*> controls;
00126 typedef std::map<int, Device*> DeviceMap;
00127 DeviceMap devices;
00128 simth::checkedVector<Connection> connections;
00129
00130 static const std::string const_blockQualifier;
00131
00132
00133 bool _isIterationStopped;
00134
00135
00136
00137 bool _isStoppedPremature;
00138
00139
00140
00141 bool _reachedEnd;
00142
00147 virtual LoopControl* loopControl(const std::string& varName);
00151 virtual Device* device(int deviceNr);
00152
00154
00155
00158
00165 void nextIteration();
00166
00170 bool reachedEnd();
00172
00173
00181 DeviceFactory *createDeviceFactory(const std::string& libName) const;
00182
00186 DeviceFactory *getDeviceFactory(const std::string &filename) const;
00187
00190 virtual void connectDevices();
00191
00195 DeviceFactory::FactoryMap getAllFactoryMaps() const;
00196
00198
00199
00202
00203 Device *createDeviceByFactoryV1(const std::string& datasetFileName,
00204 int deviceNr);
00205
00207 virtual void initLoopControls(const std::string&);
00208
00219 virtual void readConnectionTable(const std::string&);
00221 void readConnectionTablev1(std::ifstream*is);
00222
00224
00225
00228
00229
00230 Device *createDeviceByFactoryFunc(const std::string& deviceFileName,
00231 int deviceNr,
00232 const DeviceDescription& dd,
00233 const DeviceFactory::FactoryFunc& factoryfunc,
00234 const std::string& cppname);
00235
00236
00237
00238 static std::string getTypeName(const std::string& filename, int deviceNr);
00239
00241 virtual void initDevices(const std::string& deviceFileName,
00242 const DeviceManager::DDMap& ddmap);
00243
00250 void readConnectionTablev2(std::ifstream* is);
00251
00253
00254
00257
00258
00259 Device *createDeviceByFactoryFunc(const ParameterDescription& pdescr,
00260 int deviceNr,
00261 const DeviceDescription& dd,
00262 const DeviceFactory::FactoryFunc& factoryfunc,
00263 const std::string& cppname);
00264
00266 void initDevicesV3(const ParameterDescription& pardescr,
00267 const DeviceManager::DDMap& ddmap);
00268
00270 void readConnectionTablev3(
00271 const std::vector<ParameterDescription::Connection>& clist);
00272
00274 void initLoopControls(const ParameterDescription& pardescr);
00275
00276
00277
00278 static std::string getTypeName(const ParameterDescription& pdescr,
00279 int deviceNr);
00280
00284 static const ParameterDescription::Devicevalues&
00285 getDevice(const ParameterDescription& pdescr, unsigned deviceNr);
00286
00290 static const ParameterDescription::Loopvariable&
00291 getLoopvar(const ParameterDescription& pdescr, unsigned nr);
00292
00294
00295
00296
00297 public:
00298
00302 StreamDrivenSystem(const std::string& fileName);
00303
00304 virtual ~StreamDrivenSystem();
00305
00311 virtual void connectInterface(ControlInterface* interface, const std::string& varName);
00312
00315 virtual const Device* device(int deviceNr) const;
00316
00326 virtual double mainSimulationLoop(int mode = 0);
00327
00345 virtual void queueForProcess(Device *dev);
00346
00357 virtual void stopIteration();
00358
00363 virtual void stopSimulationPremature();
00365
00372 virtual void print(std::ostream &os) const;
00373 };
00374
00375
00376 }
00377
00378
00379 #endif