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
00059 typedef struct GWEN_LIBLOADERSTRUCT GWEN_LIBLOADER;
00060
00061 namespace simth
00062 {
00063
00110 class StreamDrivenSystem : public FreeConnectionSystem
00111 {
00112 private:
00113
00114
00115
00116 std::string parameterOutputFileName;
00117
00118
00119 std::queue<Device*> processQueue;
00120
00121 typedef simth::checkedVector<std::string> StringList;
00122 StringList libPaths;
00123 StringList preLoadLibs;
00124 int startDeviceNumber;
00125 bool verbose;
00126
00127 simth::checkedVector<LoopControl*> controls;
00128 typedef std::map<int, Device*> DeviceMap;
00129 DeviceMap devices;
00130 simth::checkedVector<Connection> connections;
00131
00132 static const std::string const_blockQualifier;
00133
00134
00135 bool _isIterationStopped;
00136
00137
00138
00139 bool _isStoppedPremature;
00140
00141
00142
00143 bool _reachedEnd;
00144
00149 virtual LoopControl* loopControl(const std::string& varName);
00153 virtual Device* device(int deviceNr);
00154
00156
00157
00160
00167 void nextIteration();
00168
00172 bool reachedEnd();
00173
00184 virtual void stopIteration();
00185
00190 virtual void stopSimulationPremature();
00192
00193
00196
00197
00198 GWEN_LIBLOADER *loadLibrary(const std::string& path,
00199 const std::string& fileName) const
00200 throw (simth::file_not_found, std::runtime_error,
00201 simth::library_dependencies);
00202
00208 DeviceFactory *createDeviceFactory(const std::string& libName) const;
00209
00213 DeviceFactory *getDeviceFactory(const std::string &filename) const;
00214
00217 virtual void connectDevices();
00218
00222 DeviceFactory::FactoryMap getAllFactoryMaps() const;
00223
00225
00226
00229
00230 Device *createDeviceByFactoryV1(const std::string& datasetFileName,
00231 int deviceNr);
00232
00234 virtual void initLoopControls(const std::string&);
00235
00246 virtual void readConnectionTable(const std::string&);
00248 void readConnectionTablev1(std::ifstream*is);
00249
00251
00252
00255
00256
00257 Device *createDeviceByFactoryFunc(const std::string& deviceFileName,
00258 int deviceNr,
00259 const DeviceDescription& dd,
00260 const DeviceFactory::FactoryFunc& factoryfunc,
00261 const std::string& cppname);
00262
00263
00264
00265 static std::string getTypeName(const std::string& filename, int deviceNr);
00266
00268 virtual void initDevices(const std::string& deviceFileName,
00269 const DeviceManager::DDMap& ddmap);
00270
00277 void readConnectionTablev2(std::ifstream* is);
00278
00280
00281
00284
00285
00286 Device *createDeviceByFactoryFunc(const ParameterDescription& pdescr,
00287 int deviceNr,
00288 const DeviceDescription& dd,
00289 const DeviceFactory::FactoryFunc& factoryfunc,
00290 const std::string& cppname);
00291
00293 void initDevicesV3(const ParameterDescription& pardescr,
00294 const DeviceManager::DDMap& ddmap);
00295
00297 void readConnectionTablev3(
00298 const std::vector<ParameterDescription::Connection>& clist);
00299
00301 void initLoopControls(const ParameterDescription& pardescr);
00302
00303
00304
00305 static std::string getTypeName(const ParameterDescription& pdescr,
00306 int deviceNr);
00307
00311 static const ParameterDescription::Devicevalues&
00312 getDevice(const ParameterDescription& pdescr, unsigned deviceNr);
00313
00317 static const ParameterDescription::Loopvariable&
00318 getLoopvar(const ParameterDescription& pdescr, unsigned nr);
00319
00321
00322
00323
00324 public:
00325
00329 StreamDrivenSystem(const std::string& fileName);
00330
00331 virtual ~StreamDrivenSystem();
00332
00338 virtual void connectInterface(ControlInterface* interface, const std::string& varName);
00339
00342 virtual const Device* device(int deviceNr) const;
00343
00356 virtual void acceptSignal(Device* dev, process_signal sig);
00357
00364 virtual double startSimulation(int mode = 0);
00365
00372 virtual void print(std::ostream &os) const;
00373 };
00374
00375
00376 }
00377
00378
00379 #endif