]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_props.cxx
Minor rounding error fix for the latitude and longitude strings.
[flightgear.git] / src / Main / fg_props.cxx
1 // fg_props.cxx -- support for FlightGear properties.
2 //
3 // Written by David Megginson, started 2000.
4 //
5 // Copyright (C) 2000, 2001 David Megginson - david@megginson.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <simgear/compiler.h>
28 #include <simgear/structure/exception.hxx>
29 #include <simgear/props/props_io.hxx>
30
31 #include <simgear/timing/sg_time.hxx>
32 #include <simgear/misc/sg_path.hxx>
33 #include <simgear/scene/model/particles.hxx>
34 #include <simgear/sound/soundmgr_openal.hxx>
35
36 #include <GUI/gui.h>
37
38 #include "globals.hxx"
39 #include "fg_props.hxx"
40
41
42 static bool winding_ccw = true; // FIXME: temporary
43
44 static bool frozen = false;     // FIXME: temporary
45
46 using std::string;
47 ////////////////////////////////////////////////////////////////////////
48 // Default property bindings (not yet handled by any module).
49 ////////////////////////////////////////////////////////////////////////
50
51 struct LogClassMapping {
52   sgDebugClass c;
53   string name;
54   LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
55 };
56
57 LogClassMapping log_class_mappings [] = {
58   LogClassMapping(SG_NONE, "none"),
59   LogClassMapping(SG_TERRAIN, "terrain"),
60   LogClassMapping(SG_ASTRO, "astro"),
61   LogClassMapping(SG_FLIGHT, "flight"),
62   LogClassMapping(SG_INPUT, "input"),
63   LogClassMapping(SG_GL, "gl"),
64   LogClassMapping(SG_VIEW, "view"),
65   LogClassMapping(SG_COCKPIT, "cockpit"),
66   LogClassMapping(SG_GENERAL, "general"),
67   LogClassMapping(SG_MATH, "math"),
68   LogClassMapping(SG_EVENT, "event"),
69   LogClassMapping(SG_AIRCRAFT, "aircraft"),
70   LogClassMapping(SG_AUTOPILOT, "autopilot"),
71   LogClassMapping(SG_IO, "io"),
72   LogClassMapping(SG_CLIPPER, "clipper"),
73   LogClassMapping(SG_NETWORK, "network"),
74   LogClassMapping(SG_INSTR, "instrumentation"),
75   LogClassMapping(SG_ATC, "atc"),
76   LogClassMapping(SG_NASAL, "nasal"),
77   LogClassMapping(SG_SYSTEMS, "systems"),
78   LogClassMapping(SG_AI, "ai"),
79   LogClassMapping(SG_ENVIRONMENT, "environment"),
80   LogClassMapping(SG_SOUND, "sound"),
81   LogClassMapping(SG_NAVAID, "navaid"),
82   LogClassMapping(SG_GUI, "gui"),
83   LogClassMapping(SG_UNDEFD, "")
84 };
85
86
87 /**
88  * Get the logging classes.
89  */
90 // XXX Making the result buffer be global is a band-aid that hopefully
91 // delays its destruction 'til after its last use.
92 namespace
93 {
94 string loggingResult;
95 }
96
97 static const char *
98 getLoggingClasses ()
99 {
100   sgDebugClass classes = sglog().get_log_classes();
101   loggingResult.clear();
102   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
103     if ((classes&log_class_mappings[i].c) > 0) {
104       if (!loggingResult.empty())
105         loggingResult += '|';
106       loggingResult += log_class_mappings[i].name;
107     }
108   }
109   return loggingResult.c_str();
110 }
111
112
113 static void
114 addLoggingClass (const string &name)
115 {
116   sgDebugClass classes = sglog().get_log_classes();
117   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
118     if (name == log_class_mappings[i].name) {
119       sglog().set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
120       return;
121     }
122   }
123   SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging class: " << name);
124 }
125
126
127 /**
128  * Set the logging classes.
129  */
130 void
131 setLoggingClasses (const char * c)
132 {
133   string classes = c;
134   sglog().set_log_classes(SG_NONE);
135
136   if (classes == "none") {
137     SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
138     return;
139   }
140
141   if (classes.empty() || classes == "all") { // default
142     sglog().set_log_classes(SG_ALL);
143     SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
144            << getLoggingClasses());
145     return;
146   }
147
148   string rest = classes;
149   string name = "";
150   string::size_type sep = rest.find('|');
151   if (sep == string::npos)
152     sep = rest.find(',');
153   while (sep != string::npos) {
154     name = rest.substr(0, sep);
155     rest = rest.substr(sep+1);
156     addLoggingClass(name);
157     sep = rest.find('|');
158     if (sep == string::npos)
159       sep = rest.find(',');
160   }
161   addLoggingClass(rest);
162   SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
163          << getLoggingClasses());
164 }
165
166
167 /**
168  * Get the logging priority.
169  */
170 static const char *
171 getLoggingPriority ()
172 {
173   switch (sglog().get_log_priority()) {
174   case SG_BULK:
175     return "bulk";
176   case SG_DEBUG:
177     return "debug";
178   case SG_INFO:
179     return "info";
180   case SG_WARN:
181     return "warn";
182   case SG_ALERT:
183     return "alert";
184   default:
185     SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
186            << sglog().get_log_priority());
187     return "unknown";
188   }
189 }
190
191
192 /**
193  * Set the logging priority.
194  */
195 void
196 setLoggingPriority (const char * p)
197 {
198   if (p == 0)
199       return;
200   string priority = p;
201   if (priority == "bulk") {
202     sglog().set_log_priority(SG_BULK);
203   } else if (priority == "debug") {
204     sglog().set_log_priority(SG_DEBUG);
205   } else if (priority.empty() || priority == "info") { // default
206     sglog().set_log_priority(SG_INFO);
207   } else if (priority == "warn") {
208     sglog().set_log_priority(SG_WARN);
209   } else if (priority == "alert") {
210     sglog().set_log_priority(SG_ALERT);
211   } else {
212     SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
213   }
214   SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << getLoggingPriority());
215 }
216
217
218 /**
219  * Return the current frozen state.
220  */
221 static bool
222 getFreeze ()
223 {
224   return frozen;
225 }
226
227
228 /**
229  * Set the current frozen state.
230  */
231 static void
232 setFreeze (bool f)
233 {
234     frozen = f;
235
236     // Stop sound on a pause
237     SGSoundMgr *smgr = globals->get_soundmgr();
238     if ( smgr != NULL ) {
239         if ( f ) {
240             smgr->suspend();
241         } else if (fgGetBool("/sim/sound/working")) {
242             smgr->resume();
243         }
244     }
245
246     // Pause the particle system
247     simgear::Particles::setFrozen(f);
248 }
249
250
251 /**
252  * Return the number of milliseconds elapsed since simulation started.
253  */
254 static double
255 getElapsedTime_sec ()
256 {
257   return globals->get_sim_time_sec();
258 }
259
260
261 /**
262  * Return the current Zulu time.
263  */
264 static const char *
265 getDateString ()
266 {
267   static char buf[64];          // FIXME
268   
269   SGTime * st = globals->get_time_params();
270   if (!st) {
271     buf[0] = 0;
272     return buf;
273   }
274   
275   struct tm * t = st->getGmt();
276   sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
277           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
278           t->tm_hour, t->tm_min, t->tm_sec);
279   return buf;
280 }
281
282
283 /**
284  * Set the current Zulu time.
285  */
286 static void
287 setDateString (const char * date_string)
288 {
289   SGTime * st = globals->get_time_params();
290   struct tm * current_time = st->getGmt();
291   struct tm new_time;
292
293                                 // Scan for basic ISO format
294                                 // YYYY-MM-DDTHH:MM:SS
295   int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
296                    &(new_time.tm_year), &(new_time.tm_mon),
297                    &(new_time.tm_mday), &(new_time.tm_hour),
298                    &(new_time.tm_min), &(new_time.tm_sec));
299
300                                 // Be pretty picky about this, so
301                                 // that strange things don't happen
302                                 // if the save file has been edited
303                                 // by hand.
304   if (ret != 6) {
305     SG_LOG(SG_INPUT, SG_WARN, "Date/time string " << date_string
306            << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
307     return;
308   }
309
310                                 // OK, it looks like we got six
311                                 // values, one way or another.
312   new_time.tm_year -= 1900;
313   new_time.tm_mon -= 1;
314                                 // Now, tell flight gear to use
315                                 // the new time.  This was far
316                                 // too difficult, by the way.
317   long int warp =
318     mktime(&new_time) - mktime(current_time) + globals->get_warp();
319     
320   fgSetInt("/sim/time/warp", warp);
321 }
322
323 /**
324  * Return the GMT as a string.
325  */
326 static const char *
327 getGMTString ()
328 {
329   static char buf[16];
330   SGTime * st = globals->get_time_params();
331   if (!st) {
332     buf[0] = 0;
333     return buf;
334   }
335   
336   struct tm *t = st->getGmt();
337   snprintf(buf, 16, "%.2d:%.2d:%.2d",
338       t->tm_hour, t->tm_min, t->tm_sec);
339   return buf;
340 }
341
342 /**
343  * Return the current heading in degrees.
344  */
345 static double
346 getHeadingMag ()
347 {
348   double magheading = fgGetDouble("/orientation/heading-deg") -
349     fgGetDouble("/environment/magnetic-variation-deg");
350   return SGMiscd::normalizePeriodic(0, 360, magheading );
351 }
352
353 /**
354  * Return the current track in degrees.
355  */
356 static double
357 getTrackMag ()
358 {
359   double magtrack = fgGetDouble("/orientation/track-deg") -
360     fgGetDouble("/environment/magnetic-variation-deg");
361   return SGMiscd::normalizePeriodic(0, 360, magtrack );
362 }
363
364 static bool
365 getWindingCCW ()
366 {
367   return winding_ccw;
368 }
369
370 static void
371 setWindingCCW (bool state)
372 {
373   winding_ccw = state;
374   if ( winding_ccw )
375     glFrontFace ( GL_CCW );
376   else
377     glFrontFace ( GL_CW );
378 }
379
380 ////////////////////////////////////////////////////////////////////////
381 // Tie the properties.
382 ////////////////////////////////////////////////////////////////////////
383 SGConstPropertyNode_ptr FGProperties::_longDeg;
384 SGConstPropertyNode_ptr FGProperties::_latDeg;
385 SGConstPropertyNode_ptr FGProperties::_lonLatformat;
386
387 const char *
388 FGProperties::getLongitudeString ()
389 {
390   static char buf[32];
391   double d = _longDeg->getDoubleValue();
392   int format = _lonLatformat->getIntValue();
393   char c = d < 0.0 ? 'W' : 'E';
394   d = fabs(d);
395
396   if (format == 0) {
397     snprintf(buf, 32, "%3.6f%c", d, c);
398
399   } else if (format == 1) {
400     // dd mm.mmm' (DMM-Format) -- uses a round-off factor tailored to the
401     // required precision of the minutes field (three decimal places),
402     // preventing minute values of 60.
403     double min = (d - int(d)) * 60.0;
404     if (min >= 59.9995) {
405         min -= 60.0;
406         d += 1.0;
407     }
408     snprintf(buf, 32, "%d*%06.3f%c", int(d), fabs(min), c);
409
410   } else {
411     // mm'ss.s'' (DMS-Format) -- uses a round-off factor tailored to the
412     // required precision of the seconds field (one decimal place),
413     // preventing second values of 60.
414     double min = (d - int(d)) * 60.0;
415     double sec = (min - int(min)) * 60.0;
416     if (sec >= 59.95) {
417         sec -= 60.0;
418         min += 1.0;
419         if (min >= 60.0) {
420             min -= 60.0;
421             d += 1.0;
422         }
423     }
424     snprintf(buf, 32, "%d*%02d %04.1f%c", int(d),
425         int(min), fabs(sec), c);
426   }
427   buf[31] = '\0';
428   return buf;
429 }
430
431 const char *
432 FGProperties::getLatitudeString ()
433 {
434   static char buf[32];
435   double d = _latDeg->getDoubleValue();
436   int format = _lonLatformat->getIntValue();
437   char c = d < 0.0 ? 'S' : 'N';
438   d = fabs(d);
439
440   if (format == 0) {
441     snprintf(buf, 32, "%3.6f%c", d, c);
442
443   } else if (format == 1) {
444     double min = (d - int(d)) * 60.0;
445     if (min >= 59.9995) {
446         min -= 60.0;
447         d += 1.0;
448     }
449     snprintf(buf, 32, "%d*%06.3f%c", int(d), fabs(min), c);
450
451   } else {
452     double min = (d - int(d)) * 60.0;
453     double sec = (min - int(min)) * 60.0;
454     if (sec >= 59.95) {
455         sec -= 60.0;
456         min += 1.0;
457         if (min >= 60.0) {
458             min -= 60.0;
459             d += 1.0;
460         }
461     }
462     snprintf(buf, 32, "%d*%02d %04.1f%c", int(d),
463         int(min), fabs(sec), c);
464   }
465   buf[31] = '\0';
466   return buf;
467 }
468
469
470
471 \f
472
473 FGProperties::FGProperties ()
474 {
475 }
476
477 FGProperties::~FGProperties ()
478 {
479 }
480
481 void
482 FGProperties::init ()
483 {
484 }
485
486 void
487 FGProperties::bind ()
488 {
489   _longDeg      = fgGetNode("/position/longitude-deg", true);
490   _latDeg       = fgGetNode("/position/latitude-deg", true);
491   _lonLatformat = fgGetNode("/sim/lon-lat-format", true);
492
493   _offset = fgGetNode("/sim/time/local-offset", true);
494
495   // utc date/time
496   _uyear = fgGetNode("/sim/time/utc/year", true);
497   _umonth = fgGetNode("/sim/time/utc/month", true);
498   _uday = fgGetNode("/sim/time/utc/day", true);
499   _uhour = fgGetNode("/sim/time/utc/hour", true);
500   _umin = fgGetNode("/sim/time/utc/minute", true);
501   _usec = fgGetNode("/sim/time/utc/second", true);
502   _uwday = fgGetNode("/sim/time/utc/weekday", true);
503   _udsec = fgGetNode("/sim/time/utc/day-seconds", true);
504
505   // real local date/time
506   _ryear = fgGetNode("/sim/time/real/year", true);
507   _rmonth = fgGetNode("/sim/time/real/month", true);
508   _rday = fgGetNode("/sim/time/real/day", true);
509   _rhour = fgGetNode("/sim/time/real/hour", true);
510   _rmin = fgGetNode("/sim/time/real/minute", true);
511   _rsec = fgGetNode("/sim/time/real/second", true);
512   _rwday = fgGetNode("/sim/time/real/weekday", true);
513
514   _tiedProperties.setRoot(globals->get_props());
515
516   // Simulation
517   _tiedProperties.Tie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
518   _tiedProperties.Tie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
519   _tiedProperties.Tie("/sim/freeze/master", getFreeze, setFreeze);
520
521   _tiedProperties.Tie("/sim/time/elapsed-sec", getElapsedTime_sec);
522   _tiedProperties.Tie("/sim/time/gmt", getDateString, setDateString);
523   fgSetArchivable("/sim/time/gmt");
524   _tiedProperties.Tie("/sim/time/gmt-string", getGMTString);
525
526   // Position
527   _tiedProperties.Tie("/position/latitude-string", getLatitudeString);
528   _tiedProperties.Tie("/position/longitude-string", getLongitudeString);
529
530   // Orientation
531   _tiedProperties.Tie("/orientation/heading-magnetic-deg", getHeadingMag);
532   _tiedProperties.Tie("/orientation/track-magnetic-deg", getTrackMag);
533
534   // Misc. Temporary junk.
535   _tiedProperties.Tie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
536 }
537
538 void
539 FGProperties::unbind ()
540 {
541     _tiedProperties.Untie();
542
543     // drop static references to properties
544     _longDeg = 0;
545     _latDeg = 0;
546     _lonLatformat = 0;
547 }
548
549 void
550 FGProperties::update (double dt)
551 {
552     _offset->setIntValue(globals->get_time_params()->get_local_offset());
553
554     // utc date/time
555     struct tm *u = globals->get_time_params()->getGmt();
556     _uyear->setIntValue(u->tm_year + 1900);
557     _umonth->setIntValue(u->tm_mon + 1);
558     _uday->setIntValue(u->tm_mday);
559     _uhour->setIntValue(u->tm_hour);
560     _umin->setIntValue(u->tm_min);
561     _usec->setIntValue(u->tm_sec);
562     _uwday->setIntValue(u->tm_wday);
563     _udsec->setIntValue(u->tm_hour * 3600 + u->tm_min * 60 + u->tm_sec);
564
565     // real local date/time
566     time_t real = time(0);
567     struct tm *r = localtime(&real);
568     _ryear->setIntValue(r->tm_year + 1900);
569     _rmonth->setIntValue(r->tm_mon + 1);
570     _rday->setIntValue(r->tm_mday);
571     _rhour->setIntValue(r->tm_hour);
572     _rmin->setIntValue(r->tm_min);
573     _rsec->setIntValue(r->tm_sec);
574     _rwday->setIntValue(r->tm_wday);
575 }
576
577
578 \f
579 ////////////////////////////////////////////////////////////////////////
580 // Save and restore.
581 ////////////////////////////////////////////////////////////////////////
582
583
584 /**
585  * Save the current state of the simulator to a stream.
586  */
587 bool
588 fgSaveFlight (std::ostream &output, bool write_all)
589 {
590
591   fgSetBool("/sim/presets/onground", false);
592   fgSetArchivable("/sim/presets/onground");
593   fgSetBool("/sim/presets/trim", false);
594   fgSetArchivable("/sim/presets/trim");
595   fgSetString("/sim/presets/speed-set", "UVW");
596   fgSetArchivable("/sim/presets/speed-set");
597
598   try {
599     writeProperties(output, globals->get_props(), write_all);
600   } catch (const sg_exception &e) {
601     guiErrorMessage("Error saving flight: ", e);
602     return false;
603   }
604   return true;
605 }
606
607
608 /**
609  * Restore the current state of the simulator from a stream.
610  */
611 bool
612 fgLoadFlight (std::istream &input)
613 {
614   SGPropertyNode props;
615   try {
616     readProperties(input, &props);
617   } catch (const sg_exception &e) {
618     guiErrorMessage("Error reading saved flight: ", e);
619     return false;
620   }
621
622   fgSetBool("/sim/presets/onground", false);
623   fgSetBool("/sim/presets/trim", false);
624   fgSetString("/sim/presets/speed-set", "UVW");
625
626   copyProperties(&props, globals->get_props());
627
628   return true;
629 }
630
631
632 bool
633 fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
634 {
635     string fullpath;
636     if (in_fg_root) {
637         SGPath loadpath(globals->get_fg_root());
638         loadpath.append(path);
639         fullpath = loadpath.str();
640     } else {
641         fullpath = path;
642     }
643
644     try {
645         readProperties(fullpath, props, default_mode);
646     } catch (const sg_exception &e) {
647         guiErrorMessage("Error reading properties: ", e);
648         return false;
649     }
650     return true;
651 }
652
653
654 \f
655 ////////////////////////////////////////////////////////////////////////
656 // Property convenience functions.
657 ////////////////////////////////////////////////////////////////////////
658
659 SGPropertyNode *
660 fgGetNode (const char * path, bool create)
661 {
662   return globals->get_props()->getNode(path, create);
663 }
664
665 SGPropertyNode * 
666 fgGetNode (const char * path, int index, bool create)
667 {
668   return globals->get_props()->getNode(path, index, create);
669 }
670
671 bool
672 fgHasNode (const char * path)
673 {
674   return (fgGetNode(path, false) != 0);
675 }
676
677 void
678 fgAddChangeListener (SGPropertyChangeListener * listener, const char * path)
679 {
680   fgGetNode(path, true)->addChangeListener(listener);
681 }
682
683 void
684 fgAddChangeListener (SGPropertyChangeListener * listener,
685                      const char * path, int index)
686 {
687   fgGetNode(path, index, true)->addChangeListener(listener);
688 }
689
690 bool
691 fgGetBool (const char * name, bool defaultValue)
692 {
693   return globals->get_props()->getBoolValue(name, defaultValue);
694 }
695
696 int
697 fgGetInt (const char * name, int defaultValue)
698 {
699   return globals->get_props()->getIntValue(name, defaultValue);
700 }
701
702 long
703 fgGetLong (const char * name, long defaultValue)
704 {
705   return globals->get_props()->getLongValue(name, defaultValue);
706 }
707
708 float
709 fgGetFloat (const char * name, float defaultValue)
710 {
711   return globals->get_props()->getFloatValue(name, defaultValue);
712 }
713
714 double
715 fgGetDouble (const char * name, double defaultValue)
716 {
717   return globals->get_props()->getDoubleValue(name, defaultValue);
718 }
719
720 const char *
721 fgGetString (const char * name, const char * defaultValue)
722 {
723   return globals->get_props()->getStringValue(name, defaultValue);
724 }
725
726 bool
727 fgSetBool (const char * name, bool val)
728 {
729   return globals->get_props()->setBoolValue(name, val);
730 }
731
732 bool
733 fgSetInt (const char * name, int val)
734 {
735   return globals->get_props()->setIntValue(name, val);
736 }
737
738 bool
739 fgSetLong (const char * name, long val)
740 {
741   return globals->get_props()->setLongValue(name, val);
742 }
743
744 bool
745 fgSetFloat (const char * name, float val)
746 {
747   return globals->get_props()->setFloatValue(name, val);
748 }
749
750 bool
751 fgSetDouble (const char * name, double val)
752 {
753   return globals->get_props()->setDoubleValue(name, val);
754 }
755
756 bool
757 fgSetString (const char * name, const char * val)
758 {
759   return globals->get_props()->setStringValue(name, val);
760 }
761
762 void
763 fgSetArchivable (const char * name, bool state)
764 {
765   SGPropertyNode * node = globals->get_props()->getNode(name);
766   if (node == 0)
767     SG_LOG(SG_GENERAL, SG_DEBUG,
768            "Attempt to set archive flag for non-existant property "
769            << name);
770   else
771     node->setAttribute(SGPropertyNode::ARCHIVE, state);
772 }
773
774 void
775 fgSetReadable (const char * name, bool state)
776 {
777   SGPropertyNode * node = globals->get_props()->getNode(name);
778   if (node == 0)
779     SG_LOG(SG_GENERAL, SG_DEBUG,
780            "Attempt to set read flag for non-existant property "
781            << name);
782   else
783     node->setAttribute(SGPropertyNode::READ, state);
784 }
785
786 void
787 fgSetWritable (const char * name, bool state)
788 {
789   SGPropertyNode * node = globals->get_props()->getNode(name);
790   if (node == 0)
791     SG_LOG(SG_GENERAL, SG_DEBUG,
792            "Attempt to set write flag for non-existant property "
793            << name);
794   else
795     node->setAttribute(SGPropertyNode::WRITE, state);
796 }
797
798 void
799 fgUntie(const char * name)
800 {
801   SGPropertyNode* node = globals->get_props()->getNode(name);
802   if (!node) {
803     SG_LOG(SG_GENERAL, SG_WARN, "fgUntie: unknown property " << name);
804     return;
805   }
806   
807   if (!node->isTied()) {
808     return;
809   }
810   
811   if (!node->untie()) {
812     SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
813   }
814 }
815
816
817 // end of fg_props.cxx