OpenWAM
Public Member Functions | List of all members
TGain Class Reference
Inheritance diagram for TGain:
[legend]
Collaboration diagram for TGain:
[legend]

Public Member Functions

 TGain (int i)
 
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

Definition at line 42 of file TGain.h.

Member Function Documentation

◆ AcumulaResultadosMediosController()

void TGain::AcumulaResultadosMediosController ( double  Actual)
virtual

Acumulate average results

Parameters
ActualCurrent time

Implements TController.

Definition at line 187 of file TGain.cpp.

187  {
188 
189  /* Lo que se hace en esta funcion se realiza dentro del calculo del eje, para asi poder
190  llevar a cabo la salida de resultados medios por pantalla. */
191  double Delta = Actual - FResMediosCtrl.Tiempo0;
192 
193  if(FResMediosCtrl.Output) {
194  FResMediosCtrl.OutputSUM += fOutput * Delta;
195  }
196  FResMediosCtrl.TiempoSUM += Delta;
197  FResMediosCtrl.Tiempo0 = Actual;
198 
199 }

References TController::FResMediosCtrl.

◆ AsignaObjetos()

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

Asign the input sensor and controllers

Parameters
SensorArray with the sensor objects
ControllerArray with the controller objects

Implements TController.

Definition at line 70 of file TGain.cpp.

70  {
71 
72  if(FInObject == nmInController) {
73  FGainInput = new stGainInputController(Controller[FObjectID - 1]);
74  } else {
75  FGainInput = new stGainInputSensor(Sensor[FObjectID - 1]);
76  }
77 }

◆ CabeceraResultadosInsControlador()

void TGain::CabeceraResultadosInsControlador ( stringstream &  insoutput)
virtual

Generate instantaneous results header

Parameters
insoutputStringStream where the instantaneous results are stored

Implements TController.

Definition at line 139 of file TGain.cpp.

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

References TController::FResInstantCtrl, and PutLabel().

Here is the call graph for this function:

◆ CabeceraResultadosMedControlador()

void TGain::CabeceraResultadosMedControlador ( stringstream &  medoutput)
virtual

Generate average results header

Parameters
medoutputStringStrems where the average results are stored

Implements TController.

Definition at line 128 of file TGain.cpp.

128  {
129 
130  std::string Label;
131 
132  if(FResMediosCtrl.Output) {
133  Label = "\t" + PutLabel(705) + std::to_string(fID) + PutLabel(901);
134  medoutput << Label.c_str();
135  }
136 
137 }

References TController::FResMediosCtrl, and PutLabel().

Here is the call graph for this function:

◆ ImprimeResultadosInsControlador()

void TGain::ImprimeResultadosInsControlador ( stringstream &  insoutput)
virtual

Print instantaneous results

Parameters
insoutputStringStream where the instantaneous results are stored

Implements TController.

Definition at line 160 of file TGain.cpp.

160  {
161 
162  std::string Label;
163 
164  if(FResInstantCtrl.Output) {
165  insoutput << "\t" << FResInstantCtrl.OutputINS;
166  }
167 
168 }

References TController::FResInstantCtrl.

◆ ImprimeResultadosMedControlador()

void TGain::ImprimeResultadosMedControlador ( stringstream &  medoutput)
virtual

Print average results

Parameters
medoutputStringStream where the average results are stored

Implements TController.

Definition at line 150 of file TGain.cpp.

150  {
151 
152  std::string Label;
153 
154  if(FResMediosCtrl.Output) {
155  medoutput << "\t" << FResMediosCtrl.OutputMED;
156  }
157 
158 }

References TController::FResMediosCtrl.

◆ IniciaMedias()

void TGain::IniciaMedias ( )
virtual

Initialize average results

Implements TController.

Definition at line 170 of file TGain.cpp.

170  {
171 
172  FResMediosCtrl.OutputSUM = 0.;
173 
174 }

References TController::FResMediosCtrl.

◆ LeeController()

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

Read the information of the controller

Parameters
FileWAMInput data filename
fileposPosition to read within the input file

Implements TController.

Definition at line 50 of file TGain.cpp.

50  {
51 
52  int Type = 0;
53 
54  FILE *fich = fopen(FileWAM, "r");
55  fsetpos(fich, &filepos);
56 
57  fscanf(fich, "%lf ", &FGain);
58  fscanf(fich, "%d %d", &Type, &FObjectID);
59  if(Type == 0) {
60  FInObject = nmInController;
61  } else {
62  FInObject = nmInSensor;
63  }
64 
65  fgetpos(fich, &filepos);
66  fclose(fich);
67 
68 }

◆ LeeResultadosInsControlador()

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

Read the instantaneous results selected

Parameters
FileWAMInput data filename
fileposPosition within the input file

Implements TController.

Definition at line 104 of file TGain.cpp.

104  {
105 
106  int nvars = 0, var = 0;
107 
108  FILE *fich = fopen(FileWAM, "r");
109  fsetpos(fich, &filepos);
110 
111  fscanf(fich, "%d ", &nvars);
112  for(int i = 0; i < nvars; i++) {
113  fscanf(fich, "%d ", &var);
114  switch(var) {
115  case 0:
116  FResInstantCtrl.Output = true;
117  break;
118  default:
119  std::cout << "Resultados instantaneos en Controlador " << fID << " no implementados " << std::endl;
120  }
121  }
122 
123  fgetpos(fich, &filepos);
124  fclose(fich);
125 
126 }

References TController::FResInstantCtrl.

◆ LeeResultadosMedControlador()

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

Read the average results selected

Parameters
FileWAMInput data filename
fileposPosition within the input file

Implements TController.

Definition at line 79 of file TGain.cpp.

79  {
80 
81  int nvars = 0, var = 0;
82 
83  FILE *fich = fopen(FileWAM, "r");
84  fsetpos(fich, &filepos);
85 
86  fscanf(fich, "%d ", &nvars);
87  for(int i = 0; i < nvars; i++) {
88  fscanf(fich, "%d ", &var);
89  switch(var) {
90  case 0:
91  FResMediosCtrl.Output = true;
92  break;
93 
94  default:
95  std::cout << "Resultados medios en Controlador " << fID << " no implementados " << std::endl;
96  }
97  }
98 
99  fgetpos(fich, &filepos);
100  fclose(fich);
101 
102 }

References TController::FResMediosCtrl.

◆ Output()

double TGain::Output ( double  Time)
virtual

Return the output value of the controller

Parameters
TimeCurrent time

Implements TController.

Definition at line 44 of file TGain.cpp.

44  {
45 
46  fOutput = FGainInput->Output(Time) * FGain;
47  return fOutput;
48 }

◆ ResultadosInstantController()

void TGain::ResultadosInstantController ( )
virtual

Calculate instanteneous results

Implements TController.

Definition at line 201 of file TGain.cpp.

201  {
202 
203  if(FResInstantCtrl.Output)
204  FResInstantCtrl.OutputINS = fOutput;
205 
206 }

References TController::FResInstantCtrl.

◆ ResultadosMediosController()

void TGain::ResultadosMediosController ( )
virtual

Calculate average results

Implements TController.

Definition at line 176 of file TGain.cpp.

176  {
177 
178  if(FResMediosCtrl.Output) {
179  FResMediosCtrl.OutputMED = FResMediosCtrl.OutputSUM / FResMediosCtrl.TiempoSUM;
180  FResMediosCtrl.OutputSUM = 0.;
181  }
182 
183  FResMediosCtrl.TiempoSUM = 0;
184 
185 }

References TController::FResMediosCtrl.


The documentation for this class was generated from the following files:
stGainInputSensor
Definition: TController.h:129
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
stGainInputController
Definition: TController.h:144