CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_acd.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2018 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2018 */
7/*********************************************************************/
8/* */
9/* File: panukl_acd.cpp */
10/* */
11/* Author: J.Mieloszyk, modif. T.Grabowski */
12/* */
13/* Contents - acd file data (propeller info) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "panukl_acd.h"
21
22using namespace std;
23
24ACD_FILE::ACD_FILE( void ){ Clean (); }
25
26ACD_FILE::~ACD_FILE( void ){}
27
28void ACD_FILE::Clean( void )
29{
30 Prop.clear();
31}
32
33int ACD_FILE::Read(char *FileName)
34{
35 ifstream in(FileName);
36
37 if(in.fail())
38 {
39 fprintf( stderr, "[.ACD] file open error to reading (%s)\n", FileName );
40 return (-1);
41 }
42 else
43 {
44 char Trush[256];
45 int n_Props;
46 PropDef PropData;
47
48 in >> Trush >> n_Props >> ro >> V;
49
50 for(int x=0; x<n_Props; x++)
51 {
52 in >> PropData.Id;
53 in >> PropData.X0;
54 in >> PropData.Y0;
55 in >> PropData.Z0;
56 in >> PropData.Xthrust;
57 in >> PropData.Ythrust;
58 in >> PropData.Zthrust;
59 in >> PropData.Omega;
60 in >> PropData.D;
61 in >> PropData.T;
62 in >> PropData.P;
63
64 Prop.push_back(PropData);
65 }
66 }
67
68 in.close();
69 return 0;
70}
71
72int ACD_FILE::Write(char *FileName)
73{
74 ofstream out(FileName);
75
76 if(out.fail())
77 {
78 fprintf( stderr, "[.ACD] file open error to writing (%s)\n", FileName );
79 return (-1);
80 }
81 else
82 {
83 out << "n_Props:\t" << Prop.size() << endl;
84 out << ro << "\t" << V << endl << endl;
85
86 for(unsigned int x=0; x<Prop.size(); x++)
87 {
88 out << Prop[x].Id << "\t";
89 out << Prop[x].X0 << "\t";
90 out << Prop[x].Y0 << "\t";
91 out << Prop[x].Z0 << "\t";
92 out << Prop[x].Xthrust << "\t";
93 out << Prop[x].Ythrust << "\t";
94 out << Prop[x].Zthrust << "\t";
95 out << Prop[x].Omega << "\t";
96 out << Prop[x].D << "\t";
97 out << Prop[x].T << "\t";
98 out << Prop[x].P << endl;
99 }
100 }
101
102 out.close();
103 return 0;
104}
void Clean()
cleans local variables
int Read(char *FileName)
reads parameters file
int Write(char *Filename)
writes parameters file
double V
airspeed [m/s]
Definition panukl_acd.h:51
double ro
air density [kg/m^3]
Definition panukl_acd.h:50
std::vector< PropDef > Prop
vector of propellers
Definition panukl_acd.h:52
Structure to define actuator (propeller disc)
Definition panukl_acd.h:30
double Zthrust
Z component of thrust direction.
Definition panukl_acd.h:37
double Y0
Y coordinate of disc center.
Definition panukl_acd.h:33
double P
shaft power of propeller [W]
Definition panukl_acd.h:41
double Ythrust
Y component of thrust direction.
Definition panukl_acd.h:36
int Id
identification number
Definition panukl_acd.h:31
double D
propeller diameter [m]
Definition panukl_acd.h:39
double T
thrust generated by propeller [N]
Definition panukl_acd.h:40
double Xthrust
X component of thrust direction (for definition vector normal to actuator disc plane,...
Definition panukl_acd.h:35
double X0
X coordinate of disc center.
Definition panukl_acd.h:32
double Z0
Z coordinate of disc center.
Definition panukl_acd.h:34
double Omega
propeller angular rate in RPM, positive direction of rotation (right hand rule) defined around the th...
Definition panukl_acd.h:38