CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
sdsa_params.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2018 */
4/* */
5/*********************************************************************/
6/* Warsaw 2018 */
7/*********************************************************************/
8/* */
9/* File: sdsa_params.cpp */
10/* */
11/* Written by: T.Grabowski */
12/* */
13/* Contents - class to read/write parameters file for batch mode */
14/* */
15/*********************************************************************/
16/* */
17/* */
18
19#include "sdsa_params.h"
20
21SDSA_PARAMS::SDSA_PARAMS( void ){ Clean(); }
22
23SDSA_PARAMS::~SDSA_PARAMS( void ){}
24
26{
27 dH0 = dH1 = dDH = 0.0;
28 dV0 = dV1 = dDV = 0.0;
29 dDA = 0.0;
30 iSpeedType = 0;
31 iAero = 0;
32
33 iLQR = 0;
34 iPilot_h = 0;
35 iPilot_a = 0;
36 iPilot_r = 0;
37 iSAS_h = 0;
38 iSAS_a = 0;
39 iSAS_r = 0;
40 iAct_h = 0;
41 iAct_a = 0;
42 iAct_r = 0;
43
44 memset( OutFile, 0 , 256 );
45}
46
47int SDSA_PARAMS::Read( char* ParFile )
48{
49 FILE *File;
50 File = fopen( ParFile, "r" );
51 if( File == NULL )
52 {
53 fprintf( stderr, "SDSA params file open error (%s)\n", ParFile );
54 return (-1);
55 }
56
57 ReadPar( File, "%lf %lf %lf", &dH0, &dH1, &dDH );
58 ReadPar( File, "%lf %lf %lf", &dV0, &dV1, &dDV );
59 ReadPar( File, "%lf", &dDA );
60 ReadPar( File, "%d", &iSpeedType );
61 ReadPar( File, "%d", &iAero );
62 ReadPar( File, "%d", &iLQR );
63 ReadPar( File, "%d %d %d", &iPilot_h, &iPilot_a, &iPilot_r );
64 ReadPar( File, "%d %d %d", &iSAS_h, &iSAS_a, &iSAS_r );
65 ReadPar( File, "%d %d %d", &iAct_h, &iAct_a, &iAct_r );
66 ReadStr( File, OutFile );
67
68 fclose( File );
69
71
72 return (0);
73}
74
75int SDSA_PARAMS::Write( char *ParFile )
76{
77 FILE *File;
78 File = fopen( ParFile, "w" );
79 if( File == NULL )
80 {
81 fprintf( stderr, "SDSA params file open error to writing (%s)\n", ParFile );
82 return (-1);
83 }
84
85 fprintf( File, "# SDSA batch mode configuration file\n");
86 fprintf( File, "%6.2f %6.2f %6.2f # altitude range: mni, max, step\n", dH0, dH1, dDH );
87 fprintf( File, "%6.2f %6.2f %6.2f # airspeed range: mni, max, step\n", dV0, dV1, dDV );
88 fprintf( File, "%6.2f \t\t# aileron deflection angle\n", dDA );
89 fprintf( File, "%d \t\t# airspeed type: 0-TAS, 1-CAS\n", iSpeedType );
90 fprintf( File, "%d \t\t# aero data set (0,1)\n", iAero );
91 fprintf( File, "%d \t\t# LQR flag (0,1)\n", iLQR );
92 fprintf( File, "%d %d %d \t\t# Pilot in the loop (H,A,V)\n", iPilot_h, iPilot_a, iPilot_r );
93 fprintf( File, "%d %d %d \t\t# SAS in the loop (H,A,V)\n", iSAS_h, iSAS_a, iSAS_r );
94 fprintf( File, "%d %d %d \t\t# actuators in the loop (H,A,V)\n", iAct_h, iAct_a, iAct_r );
95 fprintf( File, "%s # output file\n", OutFile );
96
97 fclose( File );
98
99 return (0);
100}
static FILE * fopen(const char *filename, const char *mode)
Cross-platform function to fopen function that supports UTF-8 encoded name.
Definition iofun.cpp:358
static void ClipFileName(char *string)
Clipping of the ending blanc characters of "string".
Definition iofun.cpp:250
static int ReadStr(FILE *stream, char *Par)
Function to read the new line from FILE "stream" and to store it in table of char "Par"....
Definition iofun.cpp:163
static int ReadPar(FILE *stream, const char *Format, void *Par)
Function to read one variable. The type of variable depends on Format, compatible with stdio library.
Definition iofun.cpp:67
double dDH
step of hight of flight taken into the analysis
Definition sdsa_params.h:47
int Read(char *ParFile)
reads parameters file
int iSAS_r
SAS in rudder channel - flag (0-1)
Definition sdsa_params.h:61
double dV1
upper bound of airspeed taken into the analysis
Definition sdsa_params.h:49
int iAct_r
Actuator model in rudder channel - flag (0-1)
Definition sdsa_params.h:64
int iPilot_a
pilot in the loop in aileron channel - flag (0-1)
Definition sdsa_params.h:57
int iAct_h
Actuator model in elevator channel - flag (0-1)
Definition sdsa_params.h:62
int iLQR
LQR flag (0-1)
Definition sdsa_params.h:55
void Clean()
cleans local variables
int iAct_a
Actuator model in aileron channel - flag (0-1)
Definition sdsa_params.h:63
int iAero
number of aerodynamic data (1/2)
Definition sdsa_params.h:53
double dDA
aileron deflection [deg] (for roll response characteristics, must be grater than 0)
Definition sdsa_params.h:51
int Write(char *ParFile)
writes parameters file
int iSAS_h
SAS in elevator channel - flag (0-1)
Definition sdsa_params.h:59
char OutFile[256]
pathname of output file
Definition sdsa_params.h:66
int iSAS_a
SAS in aileron channel - flag (0-1)
Definition sdsa_params.h:60
double dH1
upper bound of hight of flight taken into the analysis
Definition sdsa_params.h:46
double dDV
step of airspeed taken into the analysis
Definition sdsa_params.h:50
int iPilot_h
pilot in the loop in elevator channel - flag (0-1)
Definition sdsa_params.h:56
int iPilot_r
pilot in the loop in rudder channel - flag (0-1)
Definition sdsa_params.h:58
int iSpeedType
airspeed type (0-TAS, 1-CAS)
Definition sdsa_params.h:52
double dV0
lower bound of airspeed taken into the analysis
Definition sdsa_params.h:48
double dH0
lower bound of hight of flight taken into the analysis
Definition sdsa_params.h:45