1 // fg_props.cxx -- support for FlightGear properties.
3 // Written by David Megginson, started 2000.
5 // Copyright (C) 2000, 2001 David Megginson - david@megginson.com
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.
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.
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.
24 # include <simgear/compiler.h>
27 #include <simgear/misc/exception.hxx>
28 #include <simgear/magvar/magvar.hxx>
29 #include <simgear/timing/sg_time.hxx>
33 #include <ATC/ATCdisplay.hxx>
34 #include <Aircraft/aircraft.hxx>
35 #include <Time/tmp.hxx>
36 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
38 # include <WeatherCM/FGLocalWeatherDatabase.h>
40 # include <Environment/environment.hxx>
41 #endif // FG_WEATHERCM
42 #include <Objects/matlib.hxx>
45 #include <Sound/soundmgr.hxx>
47 #include "globals.hxx"
49 #include "fg_props.hxx"
51 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
52 SG_USING_STD(istream);
53 SG_USING_STD(ostream);
57 static double getWindNorth ();
58 static double getWindEast ();
59 static double getWindDown ();
60 #endif // FG_WEATHERCM
62 static bool winding_ccw = true; // FIXME: temporary
64 static bool fdm_data_logging = false; // FIXME: temporary
66 static bool frozen = false; // FIXME: temporary
70 ////////////////////////////////////////////////////////////////////////
71 // Default property bindings (not yet handled by any module).
72 ////////////////////////////////////////////////////////////////////////
74 struct LogClassMapping {
77 LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
80 LogClassMapping log_class_mappings [] = {
81 LogClassMapping(SG_NONE, "none"),
82 LogClassMapping(SG_TERRAIN, "terrain"),
83 LogClassMapping(SG_ASTRO, "astro"),
84 LogClassMapping(SG_FLIGHT, "flight"),
85 LogClassMapping(SG_INPUT, "input"),
86 LogClassMapping(SG_GL, "gl"),
87 LogClassMapping(SG_VIEW, "view"),
88 LogClassMapping(SG_COCKPIT, "cockpit"),
89 LogClassMapping(SG_GENERAL, "general"),
90 LogClassMapping(SG_MATH, "math"),
91 LogClassMapping(SG_EVENT, "event"),
92 LogClassMapping(SG_AIRCRAFT, "aircraft"),
93 LogClassMapping(SG_AUTOPILOT, "autopilot"),
94 LogClassMapping(SG_IO, "io"),
95 LogClassMapping(SG_CLIPPER, "clipper"),
96 LogClassMapping(SG_NETWORK, "network"),
97 LogClassMapping(SG_UNDEFD, "")
102 * Get the logging classes.
107 sgDebugClass classes = logbuf::get_log_classes();
108 static string result = ""; // FIXME
109 for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
110 if ((classes&log_class_mappings[i].c) > 0) {
113 result += log_class_mappings[i].name;
116 return result.c_str();
121 addLoggingClass (const string &name)
123 sgDebugClass classes = logbuf::get_log_classes();
124 for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
125 if (name == log_class_mappings[i].name) {
126 logbuf::set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
130 SG_LOG(SG_GENERAL, SG_ALERT, "Unknown logging class: " << name);
135 * Set the logging classes.
138 setLoggingClasses (const char * c)
141 logbuf::set_log_classes(SG_NONE);
143 if (classes == "none") {
144 SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
148 if (classes.empty() || classes == "all") { // default
149 logbuf::set_log_classes(SG_ALL);
150 SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
151 << getLoggingClasses());
155 string rest = classes;
157 int sep = rest.find('|');
159 name = rest.substr(0, sep);
160 rest = rest.substr(sep+1);
161 addLoggingClass(name);
162 sep = rest.find('|');
164 addLoggingClass(rest);
165 SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
166 << getLoggingClasses());
171 * Get the logging priority.
174 getLoggingPriority ()
176 switch (logbuf::get_log_priority()) {
188 SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
189 << logbuf::get_log_priority());
196 * Set the logging priority.
199 setLoggingPriority (const char * 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);
213 SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
215 SG_LOG(SG_GENERAL, SG_INFO, "Logging priority is " << getLoggingPriority());
220 * Return the current frozen state.
230 * Set the current frozen state.
236 // Stop sound on a pause
238 globals->get_soundmgr()->pause();
240 globals->get_soundmgr()->resume();
245 * Return the current aircraft directory (UIUC) as a string.
250 return aircraft_dir.c_str();
255 * Set the current aircraft directory (UIUC).
258 setAircraftDir (const char * dir)
265 * Return the number of milliseconds elapsed since simulation started.
268 getElapsedTime_sec ()
270 return globals->get_sim_time_sec();
275 * Return the current Zulu time.
280 static char buf[64]; // FIXME
281 struct tm * t = globals->get_time_params()->getGmt();
282 sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
283 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
284 t->tm_hour, t->tm_min, t->tm_sec);
290 * Set the current Zulu time.
293 setDateString (const char * date_string)
295 static const SGPropertyNode *cur_time_override
296 = fgGetNode("/sim/time/cur-time-override", true);
298 SGTime * st = globals->get_time_params();
299 struct tm * current_time = st->getGmt();
302 // Scan for basic ISO format
303 // YYYY-MM-DDTHH:MM:SS
304 int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
305 &(new_time.tm_year), &(new_time.tm_mon),
306 &(new_time.tm_mday), &(new_time.tm_hour),
307 &(new_time.tm_min), &(new_time.tm_sec));
309 // Be pretty picky about this, so
310 // that strange things don't happen
311 // if the save file has been edited
314 SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
315 << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
319 // OK, it looks like we got six
320 // values, one way or another.
321 new_time.tm_year -= 1900;
322 new_time.tm_mon -= 1;
324 // Now, tell flight gear to use
325 // the new time. This was far
326 // too difficult, by the way.
328 mktime(&new_time) - mktime(current_time) + globals->get_warp();
329 double lon = current_aircraft.fdm_state->get_Longitude();
330 double lat = current_aircraft.fdm_state->get_Latitude();
331 globals->set_warp(warp);
332 st->update(lon, lat, cur_time_override->getLongValue(), warp);
333 fgUpdateSkyAndLightingParams();
337 * Return the GMT as a string.
342 static char buf[16]; // FIXME
343 struct tm *t = globals->get_time_params()->getGmt();
344 sprintf(buf, " %.2d:%.2d:%.2d",
345 t->tm_hour, t->tm_min, t->tm_sec);
346 // cout << t << " " << buf << endl;
352 * Get the texture rendering state.
357 return (material_lib.get_step() == 0);
362 * Set the texture rendering state.
365 setTextures (bool textures)
368 material_lib.set_step(0);
370 material_lib.set_step(1);
375 * Return the magnetic variation
380 return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
385 * Return the magnetic dip
390 return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
395 * Return the current heading in degrees.
400 return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
407 * Get the current visibility (meters).
412 return WeatherDatabase->getWeatherVisibility();
417 * Set the current visibility (meters).
420 setVisibility (double visibility)
422 WeatherDatabase->setWeatherVisibility(visibility);
426 * Get the current wind north velocity (feet/second).
431 return current_aircraft.fdm_state->get_V_north_airmass();
436 * Set the current wind north velocity (feet/second).
439 setWindNorth (double speed)
441 current_aircraft.fdm_state
442 ->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
447 * Get the current wind east velocity (feet/second).
452 return current_aircraft.fdm_state->get_V_east_airmass();
457 * Set the current wind east velocity (feet/second).
460 setWindEast (double speed)
462 cout << "Set wind-east to " << speed << endl;
463 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
470 * Get the current wind down velocity (feet/second).
475 return current_aircraft.fdm_state->get_V_down_airmass();
480 * Set the current wind down velocity (feet/second).
483 setWindDown (double speed)
485 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
490 #endif // FG_WEATHERCM
495 return globals->get_warp();
501 globals->set_warp(warp);
507 return globals->get_warp_delta();
511 setWarpDelta (long delta)
513 globals->set_warp_delta(delta);
523 setWindingCCW (bool state)
527 glFrontFace ( GL_CCW );
529 glFrontFace ( GL_CW );
535 #if defined(FX) && !defined(WIN32)
536 return globals->get_fullscreen();
543 setFullScreen (bool state)
545 #if defined(FX) && !defined(WIN32)
546 globals->set_fullscreen(state);
547 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
548 XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
556 return fdm_data_logging;
560 setFDMDataLogging (bool state)
562 // kludge; no getter or setter available
563 if (state != fdm_data_logging) {
564 fgToggleFDMdataLogging();
565 fdm_data_logging = state;
570 ////////////////////////////////////////////////////////////////////////
571 // Tie the properties.
572 ////////////////////////////////////////////////////////////////////////
577 cout << "start of fgInitProps()" << endl;
579 fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
580 fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
581 fgTie("/sim/freeze/master", getFreeze, setFreeze);
582 fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
584 fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
585 fgTie("/sim/time/gmt", getDateString, setDateString);
586 fgSetArchivable("/sim/time/gmt");
587 fgTie("/sim/time/gmt-string", getGMTString);
588 fgTie("/sim/rendering/textures", getTextures, setTextures);
591 fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
595 fgTie("/environment/visibility-m", getVisibility, setVisibility);
596 fgSetArchivable("/environment/visibility-m");
597 fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
598 fgSetArchivable("/environment/wind-from-north-fps");
599 fgTie("/environment/wind-from-east-fps", getWindEast, setWindEast);
600 fgSetArchivable("/environment/wind-from-east-fps");
601 fgTie("/environment/wind-from-down-fps", getWindDown, setWindDown);
602 fgSetArchivable("/environment/wind-from-down-fps");
605 fgTie("/environment/magnetic-variation-deg", getMagVar);
606 fgTie("/environment/magnetic-dip-deg", getMagDip);
608 fgTie("/sim/time/warp", getWarp, setWarp, false);
609 fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
611 // Misc. Temporary junk.
612 fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
613 fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
614 fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
616 cout << "end of fgInitProps()" << endl;
627 ////////////////////////////////////////////////////////////////////////
629 ////////////////////////////////////////////////////////////////////////
633 * Save the current state of the simulator to a stream.
636 fgSaveFlight (ostream &output, bool write_all)
639 fgSetBool("/sim/startup/onground", false);
640 fgSetArchivable("/sim/startup/onground");
641 fgSetBool("/sim/startup/trim", false);
642 fgSetArchivable("/sim/startup/trim");
643 fgSetString("/sim/startup/speed-set", "UVW");
644 fgSetArchivable("/sim/startup/speed-set");
647 writeProperties(output, globals->get_props(), write_all);
648 } catch (const sg_exception &e) {
649 guiErrorMessage("Error saving flight: ", e);
657 * Restore the current state of the simulator from a stream.
660 fgLoadFlight (istream &input)
662 SGPropertyNode props;
664 readProperties(input, &props);
665 } catch (const sg_exception &e) {
666 guiErrorMessage("Error reading saved flight: ", e);
670 fgSetBool("/sim/startup/onground", false);
671 fgSetBool("/sim/startup/trim", false);
672 fgSetString("/sim/startup/speed-set", "UVW");
674 copyProperties(&props, globals->get_props());
675 // When loading a flight, make it the
676 // new initial state.
677 globals->saveInitialState();
683 ////////////////////////////////////////////////////////////////////////
684 // Property convenience functions.
685 ////////////////////////////////////////////////////////////////////////
688 fgGetNode (const char * path, bool create)
690 return globals->get_props()->getNode(path, create);
694 fgGetNode (const char * path, int index, bool create)
696 return globals->get_props()->getNode(path, index, create);
700 fgHasNode (const char * path)
702 return (fgGetNode(path, false) != 0);
706 fgGetBool (const char * name, bool defaultValue)
708 return globals->get_props()->getBoolValue(name, defaultValue);
712 fgGetInt (const char * name, int defaultValue)
714 return globals->get_props()->getIntValue(name, defaultValue);
718 fgGetLong (const char * name, long defaultValue)
720 return globals->get_props()->getLongValue(name, defaultValue);
724 fgGetFloat (const char * name, float defaultValue)
726 return globals->get_props()->getFloatValue(name, defaultValue);
730 fgGetDouble (const char * name, double defaultValue)
732 return globals->get_props()->getDoubleValue(name, defaultValue);
736 fgGetString (const char * name, const char * defaultValue)
738 return globals->get_props()->getStringValue(name, defaultValue);
742 fgSetBool (const char * name, bool val)
744 return globals->get_props()->setBoolValue(name, val);
748 fgSetInt (const char * name, int val)
750 return globals->get_props()->setIntValue(name, val);
754 fgSetLong (const char * name, long val)
756 return globals->get_props()->setLongValue(name, val);
760 fgSetFloat (const char * name, float val)
762 return globals->get_props()->setFloatValue(name, val);
766 fgSetDouble (const char * name, double val)
768 return globals->get_props()->setDoubleValue(name, val);
772 fgSetString (const char * name, const char * val)
774 return globals->get_props()->setStringValue(name, val);
778 fgSetArchivable (const char * name, bool state)
780 SGPropertyNode * node = globals->get_props()->getNode(name);
782 SG_LOG(SG_GENERAL, SG_ALERT,
783 "Attempt to set archive flag for non-existant property "
786 node->setAttribute(SGPropertyNode::ARCHIVE, state);
790 fgSetReadable (const char * name, bool state)
792 SGPropertyNode * node = globals->get_props()->getNode(name);
794 SG_LOG(SG_GENERAL, SG_ALERT,
795 "Attempt to set read flag for non-existant property "
798 node->setAttribute(SGPropertyNode::READ, state);
802 fgSetWritable (const char * name, bool state)
804 SGPropertyNode * node = globals->get_props()->getNode(name);
806 SG_LOG(SG_GENERAL, SG_ALERT,
807 "Attempt to set write flag for non-existant property "
810 node->setAttribute(SGPropertyNode::WRITE, state);
814 fgUntie (const char * name)
816 if (!globals->get_props()->untie(name))
817 SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
823 ////////////////////////////////////////////////////////////////////////
824 // Implementation of FGCondition.
825 ////////////////////////////////////////////////////////////////////////
827 FGCondition::FGCondition ()
831 FGCondition::~FGCondition ()
837 ////////////////////////////////////////////////////////////////////////
838 // Implementation of FGPropertyCondition.
839 ////////////////////////////////////////////////////////////////////////
841 FGPropertyCondition::FGPropertyCondition (const char * propname)
842 : _node(fgGetNode(propname, true))
846 FGPropertyCondition::~FGPropertyCondition ()
852 ////////////////////////////////////////////////////////////////////////
853 // Implementation of FGNotCondition.
854 ////////////////////////////////////////////////////////////////////////
856 FGNotCondition::FGNotCondition (FGCondition * condition)
857 : _condition(condition)
861 FGNotCondition::~FGNotCondition ()
867 FGNotCondition::test () const
869 return !(_condition->test());
874 ////////////////////////////////////////////////////////////////////////
875 // Implementation of FGAndCondition.
876 ////////////////////////////////////////////////////////////////////////
878 FGAndCondition::FGAndCondition ()
882 FGAndCondition::~FGAndCondition ()
884 for (unsigned int i = 0; i < _conditions.size(); i++)
885 delete _conditions[i];
889 FGAndCondition::test () const
891 int nConditions = _conditions.size();
892 for (int i = 0; i < nConditions; i++) {
893 if (!_conditions[i]->test())
900 FGAndCondition::addCondition (FGCondition * condition)
902 _conditions.push_back(condition);
907 ////////////////////////////////////////////////////////////////////////
908 // Implementation of FGOrCondition.
909 ////////////////////////////////////////////////////////////////////////
911 FGOrCondition::FGOrCondition ()
915 FGOrCondition::~FGOrCondition ()
917 for (unsigned int i = 0; i < _conditions.size(); i++)
918 delete _conditions[i];
922 FGOrCondition::test () const
924 int nConditions = _conditions.size();
925 for (int i = 0; i < nConditions; i++) {
926 if (_conditions[i]->test())
933 FGOrCondition::addCondition (FGCondition * condition)
935 _conditions.push_back(condition);
940 ////////////////////////////////////////////////////////////////////////
941 // Implementation of FGComparisonCondition.
942 ////////////////////////////////////////////////////////////////////////
945 doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
947 switch (left->getType()) {
948 case SGPropertyNode::BOOL: {
949 bool v1 = left->getBoolValue();
950 bool v2 = right->getBoolValue();
952 return FGComparisonCondition::LESS_THAN;
954 return FGComparisonCondition::GREATER_THAN;
956 return FGComparisonCondition::EQUALS;
959 case SGPropertyNode::INT: {
960 int v1 = left->getIntValue();
961 int v2 = right->getIntValue();
963 return FGComparisonCondition::LESS_THAN;
965 return FGComparisonCondition::GREATER_THAN;
967 return FGComparisonCondition::EQUALS;
970 case SGPropertyNode::LONG: {
971 long v1 = left->getLongValue();
972 long v2 = right->getLongValue();
974 return FGComparisonCondition::LESS_THAN;
976 return FGComparisonCondition::GREATER_THAN;
978 return FGComparisonCondition::EQUALS;
981 case SGPropertyNode::FLOAT: {
982 float v1 = left->getFloatValue();
983 float v2 = right->getFloatValue();
985 return FGComparisonCondition::LESS_THAN;
987 return FGComparisonCondition::GREATER_THAN;
989 return FGComparisonCondition::EQUALS;
992 case SGPropertyNode::DOUBLE: {
993 double v1 = left->getDoubleValue();
994 double v2 = right->getDoubleValue();
996 return FGComparisonCondition::LESS_THAN;
998 return FGComparisonCondition::GREATER_THAN;
1000 return FGComparisonCondition::EQUALS;
1003 case SGPropertyNode::STRING:
1004 case SGPropertyNode::NONE:
1005 case SGPropertyNode::UNSPECIFIED: {
1006 string v1 = left->getStringValue();
1007 string v2 = right->getStringValue();
1009 return FGComparisonCondition::LESS_THAN;
1011 return FGComparisonCondition::GREATER_THAN;
1013 return FGComparisonCondition::EQUALS;
1017 throw sg_exception("Unrecognized node type");
1022 FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
1031 FGComparisonCondition::~FGComparisonCondition ()
1033 delete _right_value;
1037 FGComparisonCondition::test () const
1039 // Always fail if incompletely specified
1040 if (_left_property == 0 ||
1041 (_right_property == 0 && _right_value == 0))
1044 // Get LESS_THAN, EQUALS, or GREATER_THAN
1046 doComparison(_left_property,
1047 (_right_property != 0 ? _right_property : _right_value));
1049 return (cmp == _type);
1051 return (cmp != _type);
1055 FGComparisonCondition::setLeftProperty (const char * propname)
1057 _left_property = fgGetNode(propname, true);
1061 FGComparisonCondition::setRightProperty (const char * propname)
1063 delete _right_value;
1065 _right_property = fgGetNode(propname, true);
1069 FGComparisonCondition::setRightValue (const SGPropertyNode *node)
1071 _right_property = 0;
1072 delete _right_value;
1073 _right_value = new SGPropertyNode(*node);
1078 ////////////////////////////////////////////////////////////////////////
1079 // Read a condition and use it if necessary.
1080 ////////////////////////////////////////////////////////////////////////
1082 // Forward declaration
1083 static FGCondition * readCondition (const SGPropertyNode * node);
1085 static FGCondition *
1086 readPropertyCondition (const SGPropertyNode * node)
1088 return new FGPropertyCondition(node->getStringValue());
1091 static FGCondition *
1092 readNotCondition (const SGPropertyNode * node)
1094 int nChildren = node->nChildren();
1095 for (int i = 0; i < nChildren; i++) {
1096 const SGPropertyNode * child = node->getChild(i);
1097 FGCondition * condition = readCondition(child);
1099 return new FGNotCondition(condition);
1101 SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
1105 static FGCondition *
1106 readAndConditions (const SGPropertyNode * node)
1108 FGAndCondition * andCondition = new FGAndCondition;
1109 int nChildren = node->nChildren();
1110 for (int i = 0; i < nChildren; i++) {
1111 const SGPropertyNode * child = node->getChild(i);
1112 FGCondition * condition = readCondition(child);
1114 andCondition->addCondition(condition);
1116 return andCondition;
1119 static FGCondition *
1120 readOrConditions (const SGPropertyNode * node)
1122 FGOrCondition * orCondition = new FGOrCondition;
1123 int nChildren = node->nChildren();
1124 for (int i = 0; i < nChildren; i++) {
1125 const SGPropertyNode * child = node->getChild(i);
1126 FGCondition * condition = readCondition(child);
1128 orCondition->addCondition(condition);
1133 static FGCondition *
1134 readComparison (const SGPropertyNode * node,
1135 FGComparisonCondition::Type type,
1138 FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
1139 condition->setLeftProperty(node->getStringValue("property[0]"));
1140 if (node->hasValue("property[1]"))
1141 condition->setRightProperty(node->getStringValue("property[1]"));
1143 condition->setRightValue(node->getChild("value", 0));
1148 static FGCondition *
1149 readCondition (const SGPropertyNode * node)
1151 const string &name = node->getName();
1152 if (name == "property")
1153 return readPropertyCondition(node);
1154 else if (name == "not")
1155 return readNotCondition(node);
1156 else if (name == "and")
1157 return readAndConditions(node);
1158 else if (name == "or")
1159 return readOrConditions(node);
1160 else if (name == "less-than")
1161 return readComparison(node, FGComparisonCondition::LESS_THAN, false);
1162 else if (name == "less-than-equals")
1163 return readComparison(node, FGComparisonCondition::GREATER_THAN, true);
1164 else if (name == "greater-than")
1165 return readComparison(node, FGComparisonCondition::GREATER_THAN, false);
1166 else if (name == "greater-than-equals")
1167 return readComparison(node, FGComparisonCondition::LESS_THAN, true);
1168 else if (name == "equals")
1169 return readComparison(node, FGComparisonCondition::EQUALS, false);
1170 else if (name == "not-equals")
1171 return readComparison(node, FGComparisonCondition::EQUALS, true);
1178 ////////////////////////////////////////////////////////////////////////
1179 // Implementation of FGConditional.
1180 ////////////////////////////////////////////////////////////////////////
1182 FGConditional::FGConditional ()
1187 FGConditional::~FGConditional ()
1193 FGConditional::setCondition (FGCondition * condition)
1196 _condition = condition;
1200 FGConditional::test () const
1202 return ((_condition == 0) || _condition->test());
1207 // The top-level is always an implicit 'and' group
1209 fgReadCondition (const SGPropertyNode * node)
1211 return readAndConditions(node);
1215 // end of fg_props.cxx