Skip to content

Commit

Permalink
-added some functions required for vxworks
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23084 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
RuedKamp committed Oct 30, 2014
1 parent 19e6ea1 commit 72429c5
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Core/SimController/SimController.cpp
Expand Up @@ -119,9 +119,9 @@ void SimController::StartVxWorks(boost::shared_ptr<IMixedSystem> mixedsystem, Si
}

// Added for real-time simulation using VxWorks and Bodas
void SimController::calcOneStep()
void SimController::calcOneStep(double cycletime)
{
_simMgr->runSingleStep();
_simMgr->runSingleStep(cycletime);
}


Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Core/SimController/SimManager.cpp
Expand Up @@ -110,8 +110,9 @@ void SimManager::initialize()
#endif
}

void SimManager::runSingleStep()
void SimManager::runSingleStep(double cycletime)
{
_solver->setcycletime(cycletime);
_solver->solve(_solverTask);
}

Expand Down
21 changes: 13 additions & 8 deletions SimulationRuntime/cpp/Include/Core/SimController/ISimController.h
Expand Up @@ -35,23 +35,28 @@ struct SimSettings
/*SimController to start and stop the simulation*/
class ISimController
{

public:
/// Enumeration to control the time integration
virtual ~ISimController() {};
#if defined(__vxworks) || defined(__TRICORE__)
#else
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey) = 0;
virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey)=0;
#endif
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(string modelLib, string modelKey) = 0;
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path,string modelKey) = 0;
virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(string modelLib,string modelKey) = 0;
virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path,string modelKey) = 0;

// Starts the simulation; modelKey: Modelica model name; modelica_path: path to Modelica system dll
/*
Starts the simulation
modelKey: Modelica model name
modelica_path: path to Modelica system dll
*/
virtual void Start(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings, string modelKey)=0;
// Stops the simulation
virtual void Stop() = 0;

// Functions for realtime-usage (VxWorks and BODAS)
virtual void StartVxWorks(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings) = 0;
virtual boost::shared_ptr<ISimData> getSimData(string modelname) = 0;
virtual void calcOneStep() = 0;
virtual void calcOneStep(double cycletime) = 0;

/// Stops the simulation
virtual void Stop() = 0;
};
Expand Up @@ -20,7 +20,7 @@ class SimController : public ISimController,
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(string modelLib, string modelKey);
#if defined(__vxworks) || defined(__TRICORE__)
#else
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey);
virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey);
#endif
virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path, string modelKey);
/// Starts the simulation
Expand All @@ -31,7 +31,7 @@ class SimController : public ISimController,
// for real-time usage (VxWorks and BODAS)
virtual boost::shared_ptr<ISimData> getSimData(string modelname);
virtual void StartVxWorks(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings);
virtual void calcOneStep();
virtual void calcOneStep(double cycletime);

private:
void initialize(PATH library_path, PATH modelicasystem_path);
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Include/Core/SimController/SimManager.h
Expand Up @@ -34,8 +34,8 @@ class SimManager
void runSimulation();
void initialize();

// for real-time usage (VxWorks and BODAS)
void runSingleStep();
// for real-time usage (VxWorks and BODAS)
void runSingleStep(double cycletime);

private:
void computeEndTimes(std::vector<std::pair<double,int> > &tStopsSub);
Expand Down
2 changes: 2 additions & 0 deletions SimulationRuntime/cpp/Include/Core/Solver/ISolver.h
Expand Up @@ -67,6 +67,8 @@ class ISolver
/// Write out statistical information (statistical information of last simulation, e.g. time, number of steps, etc.)
virtual void writeSimulationInfo() = 0;

virtual void setcycletime(double cycletime) = 0;

/// Indicates whether a solver error occurred during integration, returns type of error and provides error message
/*virtual const int reportErrorMessage(ostream& messageStream) = 0;*/
};
4 changes: 3 additions & 1 deletion SimulationRuntime/cpp/Include/Solver/CVode/CVode.h
Expand Up @@ -151,7 +151,9 @@ class Cvode
int calcJacobian(double t, long int N, N_Vector fHelp, N_Vector errorWeight, N_Vector jthcol, double* y, N_Vector fy, DlsMat Jac);
void initializeColoredJac();


void setcycletime(double cycletime);


ISolverSettings
*_cvodesettings; ///< Input - Solver settings

Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/cpp/Include/Solver/Euler/Euler.h
Expand Up @@ -54,6 +54,7 @@ class Euler : public ISolver, public SolverDefaultImplementation
/// Indicates whether a solver error occurred during integration, returns type of error and provides error message
virtual const int reportErrorMessage(ostream& messageStream);
virtual bool stateSelection();
virtual void setcycletime(double cycletime);
private:
/// (Explizites) Euler-Verfahren 1. Ordnung
/*
Expand Down
3 changes: 3 additions & 0 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -857,3 +857,6 @@ int Cvode::check_flag(void *flagvalue, const char *funcname, int opt)

return (0);
}

void Cvode::setcycletime(double cycletime){}

2 changes: 2 additions & 0 deletions SimulationRuntime/cpp/Solver/Euler/Euler.cpp
Expand Up @@ -1311,3 +1311,5 @@ void Euler::calcJac(double* yHelp, double* _fHelp, const double* _f, double* jac
}
}
}

void Euler::setcycletime(double cycletime){}

0 comments on commit 72429c5

Please sign in to comment.