COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
rearth_test Class Reference

#include <rearth_test.h>

Inheritance diagram for rearth_test:
Collaboration diagram for rearth_test:

Public Member Functions

 rearth_test (TestContainer *parent=0)
 
 ~rearth_test ()
 

Private Slots

void on_TestList_currentItemChanged (QListWidgetItem *current, QListWidgetItem *previous)
 
void on_SelectMax_clicked ()
 
void on_SelectMin_clicked ()
 

Private Attributes

Ui::rearth_test * ui
 
int MaxErrIndex
 
int MinErrIndex
 

Constructor & Destructor Documentation

rearth_test::rearth_test ( TestContainer parent = 0)
explicit
32  :
33  QWidget(parent),
34  ui(new Ui::rearth_test)
35 {
36  ui->setupUi(this);
37  QListWidget *testlist = ui->TestList;
38  FILE *LATvRdata;
39  if (TestContainer::openFileLine(&LATvRdata, "LATvR.txt", 0)!=0) { //For some reason it says this isn't declared.
40  int i, numTests;
41  double lat, radFunction, radCorrect, delta, minDelta, minDeltaRadius, maxDelta, maxDeltaRadius, averageDelta=0.0, averageRadius;
42  fscanf(LATvRdata, "%d", &numTests);
43  TestContainer::skipLines(LATvRdata, 2);
44  for (i=0; i<numTests; i++) {
45  fscanf(LATvRdata, "%lf%lf", &lat, &radCorrect);
46  radFunction = rearth(lat);
47  delta = radFunction-radCorrect;
48  averageDelta += delta;
49  averageRadius +=radCorrect;
50  if (i==0) {
51  maxDelta = minDelta = delta;
52  maxDeltaRadius = minDeltaRadius = radCorrect;
54  } else if (fabs(delta)>fabs(maxDelta)) {
55  maxDelta = delta;
56  maxDeltaRadius = radCorrect;
57  MaxErrIndex = i;
58  } else if (fabs(delta)<fabs(minDelta)) {
59  minDelta = delta;
60  minDeltaRadius = radCorrect;
61  MinErrIndex = i;
62  }
63  QListWidgetItem *newTest = new QListWidgetItem(QString("lat: %1°, rearth: %2, correct: %3, delta: %4").arg(DEGOF(lat)).arg(radFunction).arg(radCorrect).arg(delta), testlist);
64  QVariant latitude(lat);
65  newTest->setData(Qt::UserRole, latitude);
66  QVariant functionOut(radFunction);
67  newTest->setData(Qt::UserRole+1, functionOut);
68  QVariant correct(radCorrect);
69  newTest->setData(Qt::UserRole+2, correct);
70  QVariant error(delta);
71  newTest->setData(Qt::UserRole+3, error);
72  //add custom data for each test, helpful url: http://stackoverflow.com/questions/7136818/can-i-store-some-user-data-in-every-item-of-a-qlistwidget
73  }
74  fclose(LATvRdata);
75  parent->setError((minDelta*100)/minDeltaRadius, (maxDelta*100)/maxDeltaRadius, (averageDelta*100)/averageRadius);
76  averageDelta /= numTests;
77  averageRadius /= numTests;
78  ui->TestCount->setText(QString("%1 Tests:").arg(numTests));
79  ui->testsOverview->setText(QString("Max error in #%1 Min error in #%2").arg(MaxErrIndex+1).arg(MinErrIndex+1));
80  testlist->item(MaxErrIndex)->setBackground(Qt::red);
81  testlist->item(MinErrIndex)->setBackground(Qt::darkGreen);
82  }
83 }
int MaxErrIndex
Definition: rearth_test.h:59
static double delta
Definition: agent_exec-2-0.cpp:141
int i
Definition: rw_test.cpp:37
static int openFileLine(FILE **fp, const char filename[], int startLine)
Definition: testcontainer.cpp:155
void setError(double min, double max, double avg)
Definition: testcontainer.cpp:114
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
int MinErrIndex
Definition: rearth_test.h:60
static void skipLines(FILE *fp, int lines)
Definition: testcontainer.cpp:144
double rearth(double lat)
Definition: convertlib.cpp:1556
Ui::rearth_test * ui
Definition: rearth_test.h:57
rearth_test::~rearth_test ( )
86 {
87  delete ui;
88 }
Ui::rearth_test * ui
Definition: rearth_test.h:57

Member Function Documentation

void rearth_test::on_TestList_currentItemChanged ( QListWidgetItem *  current,
QListWidgetItem *  previous 
)
privateslot
91 {
92  ui->TestInfo->setTitle(QString("Test %1").arg(int(ui->TestList->currentRow())+1));
93  double lat=(current->data(Qt::UserRole)).toDouble(), output=(current->data(Qt::UserRole+1)).toDouble();
94  double correct=(current->data(Qt::UserRole+2)).toDouble(), error=(current->data(Qt::UserRole+3)).toDouble();
95  double percentError = (error/correct)*100.0;
96  ui->TestInfo->setEnabled(true);
97  ui->LatDegrees->display(DEGOF(lat));
98  ui->LatPiRadians->display(lat/DPI);
99  ui->LatNormalRadians->display(lat);
100  ui->RadiusOut->display(output/1000);
101  ui->RadiusCorrect->display(correct/1000);
102  ui->DeltaDisplay->display(error);
103  ui->PercentError->display(percentError);
104 }
string output
Definition: agent-2-0.cpp:56
static antstruc current
Definition: agent_antenna.cpp:161
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
const double DPI
Double precision PI.
Definition: math/constants.h:14
Ui::rearth_test * ui
Definition: rearth_test.h:57
void rearth_test::on_SelectMax_clicked ( )
privateslot
107 {
108  ui->TestList->setCurrentRow(MaxErrIndex);
109 }
int MaxErrIndex
Definition: rearth_test.h:59
Ui::rearth_test * ui
Definition: rearth_test.h:57
void rearth_test::on_SelectMin_clicked ( )
privateslot
112 {
113  ui->TestList->setCurrentRow(MinErrIndex);
114 }
int MinErrIndex
Definition: rearth_test.h:60
Ui::rearth_test * ui
Definition: rearth_test.h:57

Member Data Documentation

Ui::rearth_test* rearth_test::ui
private
int rearth_test::MaxErrIndex
private
int rearth_test::MinErrIndex
private

The documentation for this class was generated from the following files: