]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_props.cxx
Roy Vegard Ovesen:
[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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <simgear/compiler.h>
25 #endif
26
27 #include <simgear/structure/exception.hxx>
28 #include <simgear/magvar/magvar.hxx>
29 #include <simgear/timing/sg_time.hxx>
30 #include <simgear/misc/sg_path.hxx>
31 #include <simgear/scene/material/matlib.hxx>
32 #include <simgear/sound/soundmgr.hxx>
33
34 #include STL_IOSTREAM
35
36 #include <ATC/ATCdisplay.hxx>
37 #include <Aircraft/aircraft.hxx>
38 #include <Time/tmp.hxx>
39 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
40 #ifdef FG_WEATHERCM
41 #  include <WeatherCM/FGLocalWeatherDatabase.h>
42 #else
43 #  include <Environment/environment.hxx>
44 #endif // FG_WEATHERCM
45
46 #include <GUI/gui.h>
47
48 #include "globals.hxx"
49 #include "fg_props.hxx"
50
51 SG_USING_STD(istream);
52 SG_USING_STD(ostream);
53
54 #ifdef FG_WEATHERCM
55 static double getWindNorth ();
56 static double getWindEast ();
57 static double getWindDown ();
58 #endif // FG_WEATHERCM
59
60 static bool winding_ccw = true; // FIXME: temporary
61
62 static bool fdm_data_logging = false; // FIXME: temporary
63
64 static bool frozen = false;     // FIXME: temporary
65
66
67 \f
68 ////////////////////////////////////////////////////////////////////////
69 // Default property bindings (not yet handled by any module).
70 ////////////////////////////////////////////////////////////////////////
71
72 struct LogClassMapping {
73   sgDebugClass c;
74   string name;
75   LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
76 };
77
78 LogClassMapping log_class_mappings [] = {
79   LogClassMapping(SG_NONE, "none"),
80   LogClassMapping(SG_TERRAIN, "terrain"),
81   LogClassMapping(SG_ASTRO, "astro"),
82   LogClassMapping(SG_FLIGHT, "flight"),
83   LogClassMapping(SG_INPUT, "input"),
84   LogClassMapping(SG_GL, "gl"),
85   LogClassMapping(SG_VIEW, "view"),
86   LogClassMapping(SG_COCKPIT, "cockpit"),
87   LogClassMapping(SG_GENERAL, "general"),
88   LogClassMapping(SG_MATH, "math"),
89   LogClassMapping(SG_EVENT, "event"),
90   LogClassMapping(SG_AIRCRAFT, "aircraft"),
91   LogClassMapping(SG_AUTOPILOT, "autopilot"),
92   LogClassMapping(SG_IO, "io"),
93   LogClassMapping(SG_CLIPPER, "clipper"),
94   LogClassMapping(SG_NETWORK, "network"),
95   LogClassMapping(SG_UNDEFD, "")
96 };
97
98
99 /**
100  * Get the logging classes.
101  */
102 static const char *
103 getLoggingClasses ()
104 {
105   sgDebugClass classes = logbuf::get_log_classes();
106   static string result = "";    // FIXME
107   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
108     if ((classes&log_class_mappings[i].c) > 0) {
109       if (!result.empty())
110         result += '|';
111       result += log_class_mappings[i].name;
112     }
113   }
114   return result.c_str();
115 }
116
117
118 static void
119 addLoggingClass (const string &name)
120 {
121   sgDebugClass classes = logbuf::get_log_classes();
122   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
123     if (name == log_class_mappings[i].name) {
124       logbuf::set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
125       return;
126     }
127   }
128   SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging class: " << name);
129 }
130
131
132 /**
133  * Set the logging classes.
134  */
135 static void
136 setLoggingClasses (const char * c)
137 {
138   string classes = c;
139   logbuf::set_log_classes(SG_NONE);
140
141   if (classes == "none") {
142     SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
143     return;
144   }
145
146   if (classes.empty() || classes == "all") { // default
147     logbuf::set_log_classes(SG_ALL);
148     SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
149            << getLoggingClasses());
150     return;
151   }
152
153   string rest = classes;
154   string name = "";
155   int sep = rest.find('|');
156   while (sep > 0) {
157     name = rest.substr(0, sep);
158     rest = rest.substr(sep+1);
159     addLoggingClass(name);
160     sep = rest.find('|');
161   }
162   addLoggingClass(rest);
163   SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
164          << getLoggingClasses());
165 }
166
167
168 /**
169  * Get the logging priority.
170  */
171 static const char *
172 getLoggingPriority ()
173 {
174   switch (logbuf::get_log_priority()) {
175   case SG_BULK:
176     return "bulk";
177   case SG_DEBUG:
178     return "debug";
179   case SG_INFO:
180     return "info";
181   case SG_WARN:
182     return "warn";
183   case SG_ALERT:
184     return "alert";
185   default:
186     SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
187            << logbuf::get_log_priority());
188     return "unknown";
189   }
190 }
191
192
193 /**
194  * Set the logging priority.
195  */
196 static void
197 setLoggingPriority (const char * p)
198 {
199   if (p == 0)
200       return;
201   string priority = p;
202   if (priority == "bulk") {
203     logbuf::set_log_priority(SG_BULK);
204   } else if (priority == "debug") {
205     logbuf::set_log_priority(SG_DEBUG);
206   } else if (priority.empty() || priority == "info") { // default
207     logbuf::set_log_priority(SG_INFO);
208   } else if (priority == "warn") {
209     logbuf::set_log_priority(SG_WARN);
210   } else if (priority == "alert") {
211     logbuf::set_log_priority(SG_ALERT);
212   } else {
213     SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
214   }
215   SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << getLoggingPriority());
216 }
217
218
219 /**
220  * Return the current frozen state.
221  */
222 static bool
223 getFreeze ()
224 {
225   return frozen;
226 }
227
228
229 /**
230  * Set the current frozen state.
231  */
232 static void
233 setFreeze (bool f)
234 {
235     frozen = f;
236
237     // Stop sound on a pause
238     SGSoundMgr *s = globals->get_soundmgr();
239     if ( s != NULL ) {
240         if ( f ) {
241             s->pause();
242         } else {
243             s->resume();
244         }
245     }
246 }
247
248
249 /**
250  * Return the current aircraft directory (UIUC) as a string.
251  */
252 static const char *
253 getAircraftDir ()
254 {
255   return aircraft_dir.c_str();
256 }
257
258
259 /**
260  * Set the current aircraft directory (UIUC).
261  */
262 static void
263 setAircraftDir (const char * dir)
264 {
265   aircraft_dir = dir;
266 }
267
268
269 /**
270  * Return the number of milliseconds elapsed since simulation started.
271  */
272 static double
273 getElapsedTime_sec ()
274 {
275   return globals->get_sim_time_sec();
276 }
277
278
279 /**
280  * Return the current Zulu time.
281  */
282 static const char *
283 getDateString ()
284 {
285   static char buf[64];          // FIXME
286   struct tm * t = globals->get_time_params()->getGmt();
287   sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
288           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
289           t->tm_hour, t->tm_min, t->tm_sec);
290   return buf;
291 }
292
293
294 /**
295  * Set the current Zulu time.
296  */
297 static void
298 setDateString (const char * date_string)
299 {
300   static const SGPropertyNode *cur_time_override
301         = fgGetNode("/sim/time/cur-time-override", true);
302
303   SGTime * st = globals->get_time_params();
304   struct tm * current_time = st->getGmt();
305   struct tm new_time;
306
307                                 // Scan for basic ISO format
308                                 // YYYY-MM-DDTHH:MM:SS
309   int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
310                    &(new_time.tm_year), &(new_time.tm_mon),
311                    &(new_time.tm_mday), &(new_time.tm_hour),
312                    &(new_time.tm_min), &(new_time.tm_sec));
313
314                                 // Be pretty picky about this, so
315                                 // that strange things don't happen
316                                 // if the save file has been edited
317                                 // by hand.
318   if (ret != 6) {
319     SG_LOG(SG_INPUT, SG_WARN, "Date/time string " << date_string
320            << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
321     return;
322   }
323
324                                 // OK, it looks like we got six
325                                 // values, one way or another.
326   new_time.tm_year -= 1900;
327   new_time.tm_mon -= 1;
328
329                                 // Now, tell flight gear to use
330                                 // the new time.  This was far
331                                 // too difficult, by the way.
332   long int warp =
333     mktime(&new_time) - mktime(current_time) + globals->get_warp();
334   double lon = current_aircraft.fdm_state->get_Longitude();
335   double lat = current_aircraft.fdm_state->get_Latitude();
336   globals->set_warp(warp);
337   st->update(lon, lat, cur_time_override->getLongValue(), warp);
338 }
339
340 /**
341  * Return the GMT as a string.
342  */
343 static const char *
344 getGMTString ()
345 {
346   static char buf[16];          // FIXME
347   struct tm *t = globals->get_time_params()->getGmt();
348   sprintf(buf, " %.2d:%.2d:%.2d",
349           t->tm_hour, t->tm_min, t->tm_sec);
350   // cout << t << " " << buf << endl;
351   return buf;
352 }
353
354 /**
355  * Return the magnetic variation
356  */
357 static double
358 getMagVar ()
359 {
360   return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
361 }
362
363
364 /**
365  * Return the magnetic dip
366  */
367 static double
368 getMagDip ()
369 {
370   return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
371 }
372
373
374 /**
375  * Return the current heading in degrees.
376  */
377 static double
378 getHeadingMag ()
379 {
380   double magheading;
381   magheading = current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
382   if (magheading < 0) magheading += 360;
383   return magheading;
384 }
385
386
387 #ifdef FG_WEATHERCM
388
389 /**
390  * Get the current visibility (meters).
391  */
392 static double
393 getVisibility ()
394 {
395   return WeatherDatabase->getWeatherVisibility();
396 }
397
398
399 /**
400  * Set the current visibility (meters).
401  */
402 static void
403 setVisibility (double visibility)
404 {
405   WeatherDatabase->setWeatherVisibility(visibility);
406 }
407
408 /**
409  * Get the current wind north velocity (feet/second).
410  */
411 static double
412 getWindNorth ()
413 {
414   return current_aircraft.fdm_state->get_V_north_airmass();
415 }
416
417
418 /**
419  * Set the current wind north velocity (feet/second).
420  */
421 static void
422 setWindNorth (double speed)
423 {
424   current_aircraft.fdm_state
425     ->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
426 }
427
428
429 /**
430  * Get the current wind east velocity (feet/second).
431  */
432 static double
433 getWindEast ()
434 {
435   return current_aircraft.fdm_state->get_V_east_airmass();
436 }
437
438
439 /**
440  * Set the current wind east velocity (feet/second).
441  */
442 static void
443 setWindEast (double speed)
444 {
445   SG_LOG(SG_GENERAL, SG_INFO,, "Set wind-east to " << speed );
446   current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
447                                                            speed,
448                                                            getWindDown());
449 }
450
451
452 /**
453  * Get the current wind down velocity (feet/second).
454  */
455 static double
456 getWindDown ()
457 {
458   return current_aircraft.fdm_state->get_V_down_airmass();
459 }
460
461
462 /**
463  * Set the current wind down velocity (feet/second).
464  */
465 static void
466 setWindDown (double speed)
467 {
468   current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
469                                                            getWindEast(),
470                                                            speed);
471 }
472
473 #endif // FG_WEATHERCM
474
475 static long
476 getWarp ()
477 {
478   return globals->get_warp();
479 }
480
481 static void
482 setWarp (long warp)
483 {
484   globals->set_warp(warp);
485 }
486
487 static long
488 getWarpDelta ()
489 {
490   return globals->get_warp_delta();
491 }
492
493 static void
494 setWarpDelta (long delta)
495 {
496   globals->set_warp_delta(delta);
497 }
498
499 static bool
500 getWindingCCW ()
501 {
502   return winding_ccw;
503 }
504
505 static void
506 setWindingCCW (bool state)
507 {
508   winding_ccw = state;
509   if ( winding_ccw )
510     glFrontFace ( GL_CCW );
511   else
512     glFrontFace ( GL_CW );
513 }
514
515 static bool
516 getFullScreen ()
517 {
518 #if defined(FX) && !defined(WIN32)
519   return globals->get_fullscreen();
520 #else
521   return false;
522 #endif
523 }
524
525 static void
526 setFullScreen (bool state)
527 {
528 #if defined(FX) && !defined(WIN32)
529   globals->set_fullscreen(state);
530 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
531   XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
532 #  endif
533 #endif
534 }
535
536 static bool
537 getFDMDataLogging ()
538 {
539   return fdm_data_logging;
540 }
541
542 static void
543 setFDMDataLogging (bool state)
544 {
545                                 // kludge; no getter or setter available
546   if (state != fdm_data_logging) {
547     fgToggleFDMdataLogging();
548     fdm_data_logging = state;
549   }
550 }
551
552 \f
553 ////////////////////////////////////////////////////////////////////////
554 // Tie the properties.
555 ////////////////////////////////////////////////////////////////////////
556
557 FGProperties::FGProperties ()
558 {
559 }
560
561 FGProperties::~FGProperties ()
562 {
563 }
564
565 void
566 FGProperties::init ()
567 {
568 }
569
570 void
571 FGProperties::bind ()
572 {
573                                 // Simulation
574   fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
575   fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
576   fgTie("/sim/freeze/master", getFreeze, setFreeze);
577   fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
578
579   fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
580   fgTie("/sim/time/gmt", getDateString, setDateString);
581   fgSetArchivable("/sim/time/gmt");
582   fgTie("/sim/time/gmt-string", getGMTString);
583
584                                 // Orientation
585   fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
586
587                                 // Environment
588 #ifdef FG_WEATHERCM
589   fgTie("/environment/visibility-m", getVisibility, setVisibility);
590   fgSetArchivable("/environment/visibility-m");
591   fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
592   fgSetArchivable("/environment/wind-from-north-fps");
593   fgTie("/environment/wind-from-east-fps", getWindEast, setWindEast);
594   fgSetArchivable("/environment/wind-from-east-fps");
595   fgTie("/environment/wind-from-down-fps", getWindDown, setWindDown);
596   fgSetArchivable("/environment/wind-from-down-fps");
597 #endif
598
599   fgTie("/environment/magnetic-variation-deg", getMagVar);
600   fgTie("/environment/magnetic-dip-deg", getMagDip);
601
602   fgTie("/sim/time/warp", getWarp, setWarp, false);
603   fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
604
605                                 // Misc. Temporary junk.
606   fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
607   fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
608   fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
609 }
610
611 void
612 FGProperties::unbind ()
613 {
614                                 // Simulation
615   fgUntie("/sim/logging/priority");
616   fgUntie("/sim/logging/classes");
617   fgUntie("/sim/freeze/master");
618   fgUntie("/sim/aircraft-dir");
619
620   fgUntie("/sim/time/elapsed-sec");
621   fgUntie("/sim/time/gmt");
622   fgUntie("/sim/time/gmt-string");
623
624                                 // Orientation
625   fgUntie("/orientation/heading-magnetic-deg");
626
627                                 // Environment
628 #ifdef FG_WEATHERCM
629   fgUntie("/environment/visibility-m");
630   fgUntie("/environment/wind-from-north-fps");
631   fgUntie("/environment/wind-from-east-fps");
632   fgUntie("/environment/wind-from-down-fps");
633 #endif
634
635   fgUntie("/environment/magnetic-variation-deg");
636   fgUntie("/environment/magnetic-dip-deg");
637
638   fgUntie("/sim/time/warp");
639   fgUntie("/sim/time/warp-delta");
640
641                                 // Misc. Temporary junk.
642   fgUntie("/sim/temp/winding-ccw");
643   fgUntie("/sim/temp/full-screen");
644   fgUntie("/sim/temp/fdm-data-logging");
645 }
646
647 void
648 FGProperties::update (double dt)
649 {
650                                 // Date and time
651     struct tm * t = globals->get_time_params()->getGmt();
652
653     fgSetInt("/sim/time/utc/year", t->tm_year + 1900);
654     fgSetInt("/sim/time/utc/month", t->tm_mon + 1);
655     fgSetInt("/sim/time/utc/day", t->tm_mday);
656     fgSetInt("/sim/time/utc/hour", t->tm_hour);
657     fgSetInt("/sim/time/utc/minute", t->tm_min);
658     fgSetInt("/sim/time/utc/second", t->tm_sec);
659
660     fgSetDouble("/sim/time/utc/day-seconds",
661                 t->tm_hour * 3600 +
662                 t->tm_min * 60 +
663                 t->tm_sec);
664 }
665
666
667 \f
668 ////////////////////////////////////////////////////////////////////////
669 // Save and restore.
670 ////////////////////////////////////////////////////////////////////////
671
672
673 /**
674  * Save the current state of the simulator to a stream.
675  */
676 bool
677 fgSaveFlight (ostream &output, bool write_all)
678 {
679
680   fgSetBool("/sim/presets/onground", false);
681   fgSetArchivable("/sim/presets/onground");
682   fgSetBool("/sim/presets/trim", false);
683   fgSetArchivable("/sim/presets/trim");
684   fgSetString("/sim/presets/speed-set", "UVW");
685   fgSetArchivable("/sim/presets/speed-set");
686
687   try {
688     writeProperties(output, globals->get_props(), write_all);
689   } catch (const sg_exception &e) {
690     guiErrorMessage("Error saving flight: ", e);
691     return false;
692   }
693   return true;
694 }
695
696
697 /**
698  * Restore the current state of the simulator from a stream.
699  */
700 bool
701 fgLoadFlight (istream &input)
702 {
703   SGPropertyNode props;
704   try {
705     readProperties(input, &props);
706   } catch (const sg_exception &e) {
707     guiErrorMessage("Error reading saved flight: ", e);
708     return false;
709   }
710
711   fgSetBool("/sim/presets/onground", false);
712   fgSetBool("/sim/presets/trim", false);
713   fgSetString("/sim/presets/speed-set", "UVW");
714
715   copyProperties(&props, globals->get_props());
716   // When loading a flight, make it the
717   // new initial state.
718   globals->saveInitialState();
719   return true;
720 }
721
722
723 bool
724 fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
725 {
726     string fullpath;
727     if (in_fg_root) {
728         SGPath loadpath(globals->get_fg_root());
729         loadpath.append(path);
730         fullpath = loadpath.str();
731     } else {
732         fullpath = path;
733     }
734
735     try {
736         readProperties(fullpath, props);
737     } catch (const sg_exception &e) {
738         guiErrorMessage("Error reading properties: ", e);
739         return false;
740     }
741     return true;
742 }
743
744
745 \f
746 ////////////////////////////////////////////////////////////////////////
747 // Property convenience functions.
748 ////////////////////////////////////////////////////////////////////////
749
750 SGPropertyNode *
751 fgGetNode (const char * path, bool create)
752 {
753   return globals->get_props()->getNode(path, create);
754 }
755
756 SGPropertyNode * 
757 fgGetNode (const char * path, int index, bool create)
758 {
759   return globals->get_props()->getNode(path, index, create);
760 }
761
762 bool
763 fgHasNode (const char * path)
764 {
765   return (fgGetNode(path, false) != 0);
766 }
767
768 void
769 fgAddChangeListener (SGPropertyChangeListener * listener, const char * path)
770 {
771   fgGetNode(path, true)->addChangeListener(listener);
772 }
773
774 void
775 fgAddChangeListener (SGPropertyChangeListener * listener,
776                      const char * path, int index)
777 {
778   fgGetNode(path, index, true)->addChangeListener(listener);
779 }
780
781 bool
782 fgGetBool (const char * name, bool defaultValue)
783 {
784   return globals->get_props()->getBoolValue(name, defaultValue);
785 }
786
787 int
788 fgGetInt (const char * name, int defaultValue)
789 {
790   return globals->get_props()->getIntValue(name, defaultValue);
791 }
792
793 int
794 fgGetLong (const char * name, long defaultValue)
795 {
796   return globals->get_props()->getLongValue(name, defaultValue);
797 }
798
799 float
800 fgGetFloat (const char * name, float defaultValue)
801 {
802   return globals->get_props()->getFloatValue(name, defaultValue);
803 }
804
805 double
806 fgGetDouble (const char * name, double defaultValue)
807 {
808   return globals->get_props()->getDoubleValue(name, defaultValue);
809 }
810
811 const char *
812 fgGetString (const char * name, const char * defaultValue)
813 {
814   return globals->get_props()->getStringValue(name, defaultValue);
815 }
816
817 bool
818 fgSetBool (const char * name, bool val)
819 {
820   return globals->get_props()->setBoolValue(name, val);
821 }
822
823 bool
824 fgSetInt (const char * name, int val)
825 {
826   return globals->get_props()->setIntValue(name, val);
827 }
828
829 bool
830 fgSetLong (const char * name, long val)
831 {
832   return globals->get_props()->setLongValue(name, val);
833 }
834
835 bool
836 fgSetFloat (const char * name, float val)
837 {
838   return globals->get_props()->setFloatValue(name, val);
839 }
840
841 bool
842 fgSetDouble (const char * name, double val)
843 {
844   return globals->get_props()->setDoubleValue(name, val);
845 }
846
847 bool
848 fgSetString (const char * name, const char * val)
849 {
850   return globals->get_props()->setStringValue(name, val);
851 }
852
853 void
854 fgSetArchivable (const char * name, bool state)
855 {
856   SGPropertyNode * node = globals->get_props()->getNode(name);
857   if (node == 0)
858     SG_LOG(SG_GENERAL, SG_DEBUG,
859            "Attempt to set archive flag for non-existant property "
860            << name);
861   else
862     node->setAttribute(SGPropertyNode::ARCHIVE, state);
863 }
864
865 void
866 fgSetReadable (const char * name, bool state)
867 {
868   SGPropertyNode * node = globals->get_props()->getNode(name);
869   if (node == 0)
870     SG_LOG(SG_GENERAL, SG_DEBUG,
871            "Attempt to set read flag for non-existant property "
872            << name);
873   else
874     node->setAttribute(SGPropertyNode::READ, state);
875 }
876
877 void
878 fgSetWritable (const char * name, bool state)
879 {
880   SGPropertyNode * node = globals->get_props()->getNode(name);
881   if (node == 0)
882     SG_LOG(SG_GENERAL, SG_DEBUG,
883            "Attempt to set write flag for non-existant property "
884            << name);
885   else
886     node->setAttribute(SGPropertyNode::WRITE, state);
887 }
888
889 void
890 fgUntie (const char * name)
891 {
892   if (!globals->get_props()->untie(name))
893     SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
894 }
895
896
897 // end of fg_props.cxx