Skip to content
Snippets Groups Projects
Commit b3505fe0 authored by James Goppert's avatar James Goppert
Browse files

Cleaned up stream output.

parent 791a9ad0
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -19,6 +19,7 @@
#include "initialization/FGTrimmer.h"
#include "math/FGStateSpace.h"
#include <iomanip>
#include <fstream>
#include "models/FGAircraft.h"
#include "models/propulsion/FGEngine.h"
#include "models/propulsion/FGTurbine.h"
......@@ -238,12 +239,28 @@ int main (int argc, char const* argv[])
ss.linearize(x0,u0,y0,A,B,C,D);
std::cout << std::scientific;
std::cout << "\nA\n" << A << std::endl;
std::cout << "\nB\n" << B << std::endl;
std::cout << "\nC\n" << C << std::endl;
std::cout << "\nD\n" << D << std::endl;
std::cout << std::fixed;
std::cout.precision(10);
std::cout
<< std::scientific
<< "\nA=\n" << A
<< "\nB=\n" << B
<< "\nC=\n" << C
<< "\nD=\n" << D
<< std::fixed
<< std::endl;
// write scicoslab file
std::ofstream scicos(std::string(aircraft+"_lin.sce").c_str());
scicos.precision(10);
scicos
<< std::scientific
<< aircraft << ".x0=..\n" << x0 << ";\n"
<< aircraft << ".u0=..\n" << u0 << ";\n"
<< aircraft << ".sys = syslin('c',..\n" << A << ",..\n"
<< B << ",..\n" << C << ",..\n" << D << ");\n"
<< aircraft << ".tfm = ss2tf(" << aircraft << ".sys);\n"
<< std::endl;
}
// vim:ts=4:sw=4
......@@ -98,39 +98,62 @@ std::ostream &operator<<( std::ostream &out, const FGStateSpace::Component &c )
{
out << "\t" << c.getName()
<< "\t" << c.getUnit()
<< "\t:\t" << c.get() << std::ends;
<< "\t:\t" << c.get();
}
std::ostream &operator<<( std::ostream &out, const FGStateSpace::ComponentVector &v )
{
for (int i=0; i< v.getSize(); i++)
{
out << *(v.getComp(i)) << std::endl;
}
out << std::ends;
for (int i=0; i< v.getSize(); i++)
{
out << *(v.getComp(i)) << "\n";
}
out << "";
}
std::ostream &operator<<( std::ostream &out, const FGStateSpace &ss )
{
out << "\nX:\n" << ss.x
<< "\nU:\n" << ss.u
<< "\nY:\n" << ss.y
<< std::ends;
<< "\nY:\n" << ss.y;
}
std::ostream &operator<<( std::ostream &out, const std::vector< std::vector<double> > &vec2d )
{
for (int i=0;i<vec2d.size();i++)
int nI = vec2d.size();
out << "[";
for (int i=0;i<nI;i++)
{
for (int j=0;j<vec2d[0].size();j++)
int nJ = vec2d[i].size();
for (int j=0;j<nJ;j++)
{
out << "\t" << vec2d[i][j];
if (j==vec2d[0].size()-1) out << ";";
else out << ",";
out << vec2d[i][j];
if (j==nJ-1)
{
if ( i==nI-1 )
{
out << "]";
}
else out << ";\n";
}
else out << ",\t";
}
out << std::endl;
out << "";
}
}
std::ostream &operator<<( std::ostream &out, const std::vector<double> &vec )
{
int nI = vec.size();
out << "[";
for (int i=0;i<nI;i++)
{
out << vec[i];
if ( i==nI-1 )
{
out << "]";
}
else out << ";\n";
}
out << std::ends;
}
......
......@@ -638,6 +638,7 @@ std::ostream &operator<<(std::ostream &out, const FGStateSpace::Component &c );
std::ostream &operator<<(std::ostream &out, const FGStateSpace::ComponentVector &v );
std::ostream &operator<<(std::ostream &out, const FGStateSpace &ss );
std::ostream &operator<<( std::ostream &out, const std::vector< std::vector<double> > &vec2d );
std::ostream &operator<<( std::ostream &out, const std::vector<double> &vec );
} // JSBSim
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment