summaryrefslogtreecommitdiffstats
path: root/Project/ControlEditor.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-11 17:07:11 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-11 17:07:11 -0300
commit6cf253651521f0cdaf3a80f8ae58e9917fe2ec57 (patch)
tree2b5e7680483e44caa3bb96a5384ec2c7e4a920bb /Project/ControlEditor.cpp
parent4269e9370873ac31fe671c710536958ca4374aad (diff)
downloadPSP.git-6cf253651521f0cdaf3a80f8ae58e9917fe2ec57.tar.gz
PSP.git-6cf253651521f0cdaf3a80f8ae58e9917fe2ec57.tar.xz
PSP.git-6cf253651521f0cdaf3a80f8ae58e9917fe2ec57.zip
Initialization implemented
Diffstat (limited to 'Project/ControlEditor.cpp')
-rw-r--r--Project/ControlEditor.cpp67
1 files changed, 36 insertions, 31 deletions
diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp
index ad2db78..ac778de 100644
--- a/Project/ControlEditor.cpp
+++ b/Project/ControlEditor.cpp
@@ -623,41 +623,46 @@ void ControlEditor::OnKeyDown(wxKeyEvent& event)
double integrationError = 1e-5;
double simTime = 10.0;
double printStep = 1e-2;
-
+
double pulsePer = 1.0;
- ControlElementSolver solver(this, timeStep, integrationError, true, 0.0);
-
- double currentTime = 0.0;
- double printTime = 0.0;
- double pulseTime = 0.0;
- std::vector<double> time;
- std::vector<double> solution;
- std::vector<double> inputV;
- while(currentTime <= simTime) {
- double input = 0.0;
- if(pulseTime >= pulsePer * 2.0) pulseTime = 0.0;
- if(pulseTime >= pulsePer) input = 1.0;
-
- solver.SolveNextStep(input);
- if(printTime >= printStep) {
- time.push_back(currentTime);
- solution.push_back(solver.GetLastSolution());
- inputV.push_back(input);
- printTime = 0.0;
+ ControlElementSolver solver(this, timeStep, integrationError, false, 0.0);
+ if(solver.IsOK()) {
+ double currentTime = 0.0;
+ double printTime = 0.0;
+ double pulseTime = 0.0;
+ std::vector<double> time;
+ std::vector<double> solution;
+ std::vector<double> inputV;
+ while(currentTime <= simTime) {
+ double input = 0.0;
+ if(pulseTime >= pulsePer * 2.0) pulseTime = 0.0;
+ if(pulseTime >= pulsePer) input = 1.0;
+
+ solver.SolveNextStep(input);
+ if(printTime >= printStep) {
+ time.push_back(currentTime);
+ solution.push_back(solver.GetLastSolution());
+ inputV.push_back(input);
+ printTime = 0.0;
+ }
+ printTime += timeStep;
+ currentTime += timeStep;
+ pulseTime += timeStep;
}
- printTime += timeStep;
- currentTime += timeStep;
- pulseTime += timeStep;
+ std::vector<ElementPlotData> epdList;
+ ElementPlotData curve1Data(_("TESTES"), ElementPlotData::CT_BUS);
+ curve1Data.AddData(inputV, _("Entrada"));
+ curve1Data.AddData(solution, _("Saida"));
+ epdList.push_back(curve1Data);
+
+ ChartView* cView = new ChartView(this, epdList, time);
+ cView->Show();
+ } else {
+ wxMessageDialog msgDialog(this, _("it was not possible to solve the control system"),
+ _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
+ msgDialog.ShowModal();
}
- std::vector<ElementPlotData> epdList;
- ElementPlotData curve1Data(_("TESTES"), ElementPlotData::CT_BUS);
- curve1Data.AddData(inputV, _("Entrada"));
- curve1Data.AddData(solution, _("Saida"));
- epdList.push_back(curve1Data);
-
- ChartView* cView = new ChartView(this, epdList, time);
- cView->Show();
/*
std::vector<double> time, sinC, cosC, tgC;