OpenWAM
Public Member Functions | List of all members
TDecisor Class Reference

#include <TDecisor.h>

Inheritance diagram for TDecisor:
[legend]
Collaboration diagram for TDecisor:
[legend]

Public Member Functions

 TDecisor (int i)
 
 ~TDecisor ()
 
double Output (double Time)
 
void LeeController (const char *FileWAM, fpos_t &filepos)
 
void AsignaObjetos (TSensor **Sensor, TController **Controller)
 
void LeeResultadosMedControlador (const char *FileWAM, fpos_t &filepos)
 
void LeeResultadosInsControlador (const char *FileWAM, fpos_t &filepos)
 
void CabeceraResultadosMedControlador (stringstream &medoutput)
 
void CabeceraResultadosInsControlador (stringstream &insoutput)
 
void ImprimeResultadosMedControlador (stringstream &medoutput)
 
void ImprimeResultadosInsControlador (stringstream &insoutput)
 
void IniciaMedias ()
 
void ResultadosMediosController ()
 
void AcumulaResultadosMediosController (double Actual)
 
void ResultadosInstantController ()
 
- Public Member Functions inherited from TController
 TController (nmControlMethod meth, int i)
 
 ~TController ()
 

Additional Inherited Members

- Protected Attributes inherited from TController
std::vector< TSensor * > FSensor
 Array with the pointers of the sensor inputs.
 
int FNumSensors
 Number of sensor input.
 
iVector FSensorID
 Array with the ID of the sensor inputs.
 
int FControllerID
 ID of this controller.
 
nmControlMethod FControl
 Type of controller.
 
stResMediosCtrl FResMediosCtrl
 Struct with the average results of the controllers.
 
stResInstantCtrl FResInstantCtrl
 Struct with the average results of the controllers.
 

Detailed Description

This object represents a decisor. The decirsor chooses the output of one controller (high) or other depending on the fact that the valued sensed is higher or lower than the target value

Definition at line 37 of file TDecisor.h.

Constructor & Destructor Documentation

◆ TDecisor()

TDecisor::TDecisor ( int  i)

Decisor contructor

Parameters
iIndex

Definition at line 35 of file TDecisor.cpp.

35  :
36  TController(nmCtlSwitch, i) {
37  fID = i + 1;
38 }

◆ ~TDecisor()

TDecisor::~TDecisor ( )

Decisor destructor

Definition at line 40 of file TDecisor.cpp.

40  {
41 
42 }

Member Function Documentation

◆ AcumulaResultadosMediosController()

void TDecisor::AcumulaResultadosMediosController ( double  Actual)
virtual

Acumulate average results

Parameters
ActualCurrent time

Implements TController.

Definition at line 188 of file TDecisor.cpp.

188  {
189  double Delta = Actual - FResMediosCtrl.Tiempo0;
190 
191  if(FResMediosCtrl.Output) {
192  FResMediosCtrl.OutputSUM += fOutput * Delta;
193  }
194  FResMediosCtrl.TiempoSUM += Delta;
195  FResMediosCtrl.Tiempo0 = Actual;
196 }

References TController::FResMediosCtrl.

Here is the caller graph for this function:

◆ AsignaObjetos()

void TDecisor::AsignaObjetos ( TSensor **  Sensor,
TController **  Controller 
)
virtual

Asing the different controller and sensors

Parameters
SensorArray with sensors
ControllerArray with controllers

Implements TController.

Definition at line 87 of file TDecisor.cpp.

87  {
88  FSensor.push_back(Sensor[FSensorID[0] - 1]);
89 
90  fControllerLow = Controller[fControllerLowID - 1];
91  fControllerHigh = Controller[fControllerHighID - 1];
92  if(fTargedControlled)
93  fControllerTarget = Controller[fControllerTargetID - 1];
94 }

References TController::FSensor, and TController::FSensorID.

◆ CabeceraResultadosInsControlador()

void TDecisor::CabeceraResultadosInsControlador ( stringstream &  insoutput)
virtual

Generate the instantaneous results header

Parameters
insoutputStringStream where the instantaneous results are stored

Implements TController.

Definition at line 150 of file TDecisor.cpp.

150  {
151  std::string Label;
152 
153  if(FResInstantCtrl.Output) {
154  Label = "\t" + PutLabel(705) + std::to_string(fID) + PutLabel(901);
155  insoutput << Label.c_str();
156  }
157 }

References TController::FResInstantCtrl, and PutLabel().

Here is the call graph for this function:

◆ CabeceraResultadosMedControlador()

void TDecisor::CabeceraResultadosMedControlador ( stringstream &  medoutput)
virtual

Generate the average results header

Parameters
medoutputStringStream where the average results are stored

Implements TController.

Definition at line 140 of file TDecisor.cpp.

140  {
141  std::string Label;
142 
143  if(FResMediosCtrl.Output) {
144  Label = "\t" + PutLabel(705) + std::to_string(fID) + PutLabel(901);
145  medoutput << Label.c_str();
146  }
147 
148 }

References TController::FResMediosCtrl, and PutLabel().

Here is the call graph for this function:

◆ ImprimeResultadosInsControlador()

void TDecisor::ImprimeResultadosInsControlador ( stringstream &  insoutput)
virtual

Print the instantaneous values

Parameters
insoutputStringStream where the instantaneous results are stored

Implements TController.

Definition at line 167 of file TDecisor.cpp.

167  {
168  std::string Label;
169 
170  if(FResInstantCtrl.Output) {
171  insoutput << "\t" << FResInstantCtrl.OutputINS;
172  }
173 }

References TController::FResInstantCtrl.

◆ ImprimeResultadosMedControlador()

void TDecisor::ImprimeResultadosMedControlador ( stringstream &  medoutput)
virtual

Print the average results

Parameters
medoutputStringStream where the averate results are stored

Implements TController.

Definition at line 159 of file TDecisor.cpp.

159  {
160  std::string Label;
161 
162  if(FResMediosCtrl.Output) {
163  medoutput << "\t" << FResMediosCtrl.OutputMED;
164  }
165 }

References TController::FResMediosCtrl.

◆ IniciaMedias()

void TDecisor::IniciaMedias ( )
virtual

Initialize average results

Implements TController.

Definition at line 175 of file TDecisor.cpp.

175  {
176  FResMediosCtrl.OutputSUM = 0.;
177  FResMediosCtrl.TiempoSUM = 0.;
178  FResMediosCtrl.Tiempo0 = 0.;
179 }

References TController::FResMediosCtrl.

◆ LeeController()

void TDecisor::LeeController ( const char *  FileWAM,
fpos_t &  filepos 
)
virtual

Read the data of the controller

Parameters
FileWAMFile name of the input data
fileposPosition within the file to read

Implements TController.

Definition at line 62 of file TDecisor.cpp.

62  {
63  FILE *fich = fopen(FileWAM, "r");
64  fsetpos(fich, &filepos);
65 
66  fscanf(fich, "%lf ", &fTarget);
67  fscanf(fich, "%d ", &fControllerLowID);
68  fscanf(fich, "%d ", &fControllerHighID);
69 
70  int ctrl = 0;
71  fscanf(fich, "%d ", &ctrl);
72  if(ctrl == 0) {
73  fTargedControlled = false;
74  } else {
75  fTargedControlled = true;
76  fControllerTargetID = ctrl;
77  }
78 
79  int tmp = 0;
80  FSensorID.resize(1);
81  fscanf(fich, "%d ", &FSensorID[0]);
82 
83  fgetpos(fich, &filepos);
84  fclose(fich);
85 }

References TController::FSensorID.

◆ LeeResultadosInsControlador()

void TDecisor::LeeResultadosInsControlador ( const char *  FileWAM,
fpos_t &  filepos 
)
virtual

Read the instantenous results selected

Parameters
FileWAMFile name of the input data
fileposPosition within the file to read

Implements TController.

Definition at line 118 of file TDecisor.cpp.

118  {
119  int nvars = 0, var = 0;
120 
121  FILE *fich = fopen(FileWAM, "r");
122  fsetpos(fich, &filepos);
123 
124  fscanf(fich, "%d ", &nvars);
125  for(int i = 0; i < nvars; i++) {
126  fscanf(fich, "%d ", &var);
127  switch(var) {
128  case 0:
129  FResInstantCtrl.Output = true;
130  break;
131  default:
132  std::cout << "Resultados instantaneos en Controlador " << fID << " no implementados " << std::endl;
133  }
134  }
135 
136  fgetpos(fich, &filepos);
137  fclose(fich);
138 }

References TController::FResInstantCtrl.

◆ LeeResultadosMedControlador()

void TDecisor::LeeResultadosMedControlador ( const char *  FileWAM,
fpos_t &  filepos 
)
virtual

Read the average results selected

Parameters
FileWAMFile name of the input data
fileposPosition within the file to read

Implements TController.

Definition at line 96 of file TDecisor.cpp.

96  {
97  int nvars = 0, var = 0;
98 
99  FILE *fich = fopen(FileWAM, "r");
100  fsetpos(fich, &filepos);
101 
102  fscanf(fich, "%d ", &nvars);
103  for(int i = 0; i < nvars; i++) {
104  fscanf(fich, "%d ", &var);
105  switch(var) {
106  case 0:
107  FResMediosCtrl.Output = true;
108  break;
109  default:
110  std::cout << "Resultados medios en Controlador " << fID << " no implementados " << std::endl;
111  }
112  }
113 
114  fgetpos(fich, &filepos);
115  fclose(fich);
116 }

References TController::FResMediosCtrl.

◆ Output()

double TDecisor::Output ( double  Time)
virtual

Return the final output

Parameters
TimeCurrent time

Implements TController.

Definition at line 44 of file TDecisor.cpp.

44  {
45  fInput = FSensor[0]->Output();
46  double OutputLow = fControllerLow->Output(Time);
47  double OutputHigh = fControllerHigh->Output(Time);
48 
49  if(fTargedControlled)
50  fTarget = fControllerTarget->Output(Time);
51 
52  if(fInput < fTarget) {
53  fOutput = OutputLow;
54  } else {
55  fOutput = OutputHigh;
56  }
58 
59  return fOutput;
60 }

References AcumulaResultadosMediosController(), TController::FSensor, and TController::Output().

Here is the call graph for this function:

◆ ResultadosInstantController()

void TDecisor::ResultadosInstantController ( )
virtual

Calculate instantaneous results

Implements TController.

Definition at line 198 of file TDecisor.cpp.

198  {
199  if(FResInstantCtrl.Output)
200  FResInstantCtrl.OutputINS = fOutput;
201 }

References TController::FResInstantCtrl.

◆ ResultadosMediosController()

void TDecisor::ResultadosMediosController ( )
virtual

Calculate average results

Implements TController.

Definition at line 181 of file TDecisor.cpp.

181  {
182  if(FResMediosCtrl.Output) {
183  FResMediosCtrl.OutputMED = FResMediosCtrl.OutputSUM / FResMediosCtrl.TiempoSUM;
184  FResMediosCtrl.OutputSUM = 0.;
185  }
186 }

References TController::FResMediosCtrl.


The documentation for this class was generated from the following files:
TController::TController
TController(nmControlMethod meth, int i)
Definition: TController.cpp:38
TController::FSensorID
iVector FSensorID
Array with the ID of the sensor inputs.
Definition: TController.h:43
TController::FResMediosCtrl
stResMediosCtrl FResMediosCtrl
Struct with the average results of the controllers.
Definition: TController.h:49
PutLabel
std::string PutLabel(int idx)
Returns an integer.
Definition: labels.cpp:475
TController::FResInstantCtrl
stResInstantCtrl FResInstantCtrl
Struct with the average results of the controllers.
Definition: TController.h:50
TController::Output
virtual double Output(double Time)=0
TController::FSensor
std::vector< TSensor * > FSensor
Array with the pointers of the sensor inputs.
Definition: TController.h:40
TDecisor::AcumulaResultadosMediosController
void AcumulaResultadosMediosController(double Actual)
Definition: TDecisor.cpp:188