1
0
Fork 0

Fix ATIS /environment/attention handling

Using a tied property works only for one single usage of the
property. In reality FGATIS is normally instantiated four
times (nav/comm/1/2) where only the first instantiation
works correctly. All subsequent instantions fail to tie
and show some error messages.
Also tied properties shouldn't be used anymore.
This commit is contained in:
Thomas Geymayer 2012-09-27 00:41:23 +02:00
parent 8e3314a7ec
commit f00bcad479
2 changed files with 13 additions and 16 deletions

View file

@ -71,18 +71,17 @@ using flightgear::CommStation;
FGATIS::FGATIS(const std::string& name, int num) :
_name(name),
_num(num),
_cb_attention(this, &FGATIS::attend, fgGetNode("/environment/attention", true)),
transmission(""),
trans_ident(""),
old_volume(0),
atis_failed(false),
msg_OK(0),
attention(0),
_attention(false),
_prev_display(0),
_time_before_search_sec(0),
_last_frequency(0)
{
fgTie("/environment/attention", this, (int_getter)0, &FGATIS::attend);
_root = fgGetNode("/instrumentation", true)->getNode(_name, num, true);
_volume = _root->getNode("volume",true);
_serviceable = _root->getNode("serviceable",true);
@ -130,10 +129,6 @@ FGATIS::FGATIS(const std::string& name, int num) :
// Hint:
// http://localhost:5400/environment/attention?value=1&submit=update
FGATIS::~FGATIS() {
fgUntie("/environment/attention");
}
FGATCVoice* FGATIS::GetVoicePointer()
{
FGATISMgr* pAtisMgr = globals->get_ATIS_mgr();
@ -151,9 +146,9 @@ void FGATIS::init() {
}
void
FGATIS::attend (int attn)
FGATIS::attend(SGPropertyNode* node)
{
attention = attn;
_attention = node->getBoolValue();
#ifdef ATMO_TEST
int flag = fgGetInt("/sim/logging/atmo");
if (flag) {
@ -209,7 +204,7 @@ void FGATIS::update(double dt) {
// - basically every hour and if the weather changes significantly at the station
// If !_prev_display, the radio had been detuned for a while and our
// "transmission" variable was lost when we were de-instantiated.
int changed = GenTransmission(!_prev_display, attention);
int changed = GenTransmission(!_prev_display, _attention);
// update output property
TreeOut(msg_OK);
@ -225,7 +220,7 @@ void FGATIS::update(double dt) {
NoRender(_name);
_prev_display = false;
}
attention = 0;
_attention = false;
}
string uppercase(const string &s) {
@ -296,7 +291,7 @@ int Apt_US_CA(const string id) {
// Regen means regenerate the /current/ transmission.
// Special means generate a new transmission, with a new sequence.
// Returns 1 if we actually generated something.
int FGATIS::GenTransmission(const int regen, const int special) {
int FGATIS::GenTransmission(const int regen, const bool special) {
using namespace atmodel;
using namespace lex;

View file

@ -52,6 +52,8 @@ class FGATIS : public FGATC {
SGPropertyNode_ptr _lat_node;
SGPropertyNode_ptr _elev_node;
SGPropertyChangeCallback<FGATIS> _cb_attention;
// The actual ATIS transmission
// This is generated from the prevailing conditions when required.
// This is the version with markup, suitable for voice synthesis:
@ -67,7 +69,7 @@ class FGATIS : public FGATC {
time_t msg_time; // for moderating error messages
time_t cur_time;
int msg_OK;
int attention;
bool _attention;
bool _prev_display; // Previous value of _display flag
MSS _remap; // abbreviations to be expanded
@ -79,9 +81,9 @@ class FGATIS : public FGATC {
public:
FGATIS(const std::string& name, int num);
~FGATIS(void);
virtual void init();
void attend (int);
void attend(SGPropertyNode* node);
//run the ATIS instance
void update(double dt);
@ -95,7 +97,7 @@ protected:
private:
// Generate the ATIS transmission text:
int GenTransmission(const int regen, const int special);
int GenTransmission(const int regen, const bool special);
// Put the text into the property tree
// (and in debug mode, print it on the console):