~jtaylor/ubuntu/oneiric/flightgear/fix-749249

« back to all changes in this revision

Viewing changes to src/Instrumentation/attitude_indicator.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-11-26 12:31:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20051126123123-dhs3dijy6nd257up
Tags: 0.9.8-3ubuntu1
adapt gl/glu dependencies for Xorg

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
// TODO:
7
7
// - better spin-up
8
8
 
 
9
#include <simgear/compiler.h>
 
10
 
 
11
#include STL_IOSTREAM
 
12
#include STL_STRING
 
13
#include <sstream>
 
14
 
9
15
#include <math.h>       // fabs()
10
16
 
11
17
#include "attitude_indicator.hxx"
13
19
#include <Main/util.hxx>
14
20
 
15
21
 
 
22
AttitudeIndicator::AttitudeIndicator ( SGPropertyNode *node )
 
23
    :
 
24
    name("attitude-indicator"),
 
25
    num(0),
 
26
    vacuum_system("/systems/vacuum")
 
27
{
 
28
    int i;
 
29
    for ( i = 0; i < node->nChildren(); ++i ) {
 
30
        SGPropertyNode *child = node->getChild(i);
 
31
        string cname = child->getName();
 
32
        string cval = child->getStringValue();
 
33
        if ( cname == "name" ) {
 
34
            name = cval;
 
35
        } else if ( cname == "number" ) {
 
36
            num = (int) child->getDoubleValue();
 
37
        } else if ( cname == "vacuum-system" ) {
 
38
            vacuum_system = cval;
 
39
        } else {
 
40
            SG_LOG( SG_INSTR, SG_WARN, "Error in attitude-indicator config logic" );
 
41
            if ( name.length() ) {
 
42
                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
 
43
            }
 
44
        }
 
45
    }
 
46
}
 
47
 
16
48
AttitudeIndicator::AttitudeIndicator ()
17
49
{
18
50
}
24
56
void
25
57
AttitudeIndicator::init ()
26
58
{
27
 
                                // TODO: allow index of pump and AI
28
 
                                // to be configured.
 
59
    string branch;
 
60
    branch = "/instrumentation/" + name;
 
61
    vacuum_system += "/suction-inhg";
 
62
 
 
63
    SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
 
64
    
29
65
    _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
30
66
    _roll_in_node = fgGetNode("/orientation/roll-deg", true);
31
 
    _suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
32
 
    _tumble_flag_node =
33
 
        fgGetNode("/instrumentation/attitude-indicator/config/tumble-flag",
34
 
                  true);
35
 
    _caged_node =
36
 
        fgGetNode("/instrumentation/attitude-indicator/caged-flag", true);
37
 
    _tumble_node =
38
 
        fgGetNode("/instrumentation/attitude-indicator/tumble-norm", true);
39
 
    _pitch_int_node =
40
 
        fgGetNode("/instrumentation/attitude-indicator/internal-pitch-deg",
41
 
                  true);
42
 
    _roll_int_node =
43
 
        fgGetNode("/instrumentation/attitude-indicator/internal-roll-deg",
44
 
                  true);
45
 
    _pitch_out_node =
46
 
        fgGetNode("/instrumentation/attitude-indicator/indicated-pitch-deg",
47
 
                  true);
48
 
    _roll_out_node =
49
 
        fgGetNode("/instrumentation/attitude-indicator/indicated-roll-deg",
50
 
                  true);
 
67
    _suction_node = fgGetNode(vacuum_system.c_str(), true);
 
68
    SGPropertyNode *cnode = node->getChild("config", 0, true);
 
69
    _tumble_flag_node = cnode->getChild("tumble-flag", 0, true);
 
70
    _caged_node = node->getChild("caged-flag", 0, true);
 
71
    _tumble_node = node->getChild("tumble-norm", 0, true);
 
72
    _pitch_int_node = node->getChild("internal-pitch-deg", 0, true);
 
73
    _roll_int_node = node->getChild("internal-roll-deg", 0, true);
 
74
    _pitch_out_node = node->getChild("indicated-pitch-deg", 0, true);
 
75
    _roll_out_node = node->getChild("indicated-roll-deg", 0, true);
51
76
}
52
77
 
53
78
void
54
79
AttitudeIndicator::bind ()
55
80
{
56
 
    fgTie("/instrumentation/attitude-indicator/serviceable",
 
81
    std::ostringstream temp;
 
82
    string branch;
 
83
    temp << num;
 
84
    branch = "/instrumentation/" + name + "[" + temp.str() + "]";
 
85
 
 
86
    fgTie((branch + "/serviceable").c_str(),
57
87
          &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);
58
 
    fgTie("/instrumentation/attitude-indicator/spin",
 
88
    fgTie((branch + "/spin").c_str(),
59
89
          &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);
60
90
}
61
91
 
62
92
void
63
93
AttitudeIndicator::unbind ()
64
94
{
65
 
    fgUntie("/instrumentation/attitude-indicator/serviceable");
66
 
    fgUntie("/instrumentation/attitude-indicator/spin");
 
95
    std::ostringstream temp;
 
96
    string branch;
 
97
    temp << num;
 
98
    branch = "/instrumentation/" + name + "[" + temp.str() + "]";
 
99
 
 
100
    fgUntie((branch + "/serviceable").c_str());
 
101
    fgUntie((branch + "/spin").c_str());
67
102
}
68
103
 
69
104
void