Skip to content

Commit

Permalink
cvsimport
Browse files Browse the repository at this point in the history
  • Loading branch information
jentron committed Sep 11, 2013
2 parents 2208ef8 + 60e04fc commit 06d0f97
Show file tree
Hide file tree
Showing 12 changed files with 741 additions and 232 deletions.
669 changes: 502 additions & 167 deletions COPYING

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/input_output/FGOutputTextFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using namespace std;

namespace JSBSim {

static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.5 2013/01/12 19:26:59 jberndt Exp $";
static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.6 2013/09/11 12:51:13 jberndt Exp $";
static const char *IdHdr = ID_OUTPUTTEXTFILE;

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -75,6 +75,8 @@ bool FGOutputTextFile::Load(Element* el)
if(!FGOutputFile::Load(el))
return false;

PreLoad(el, PropertyManager);

string type = el->GetAttributeValue("type");
string delim;
if (type == "TABULAR") {
Expand Down Expand Up @@ -238,6 +240,12 @@ bool FGOutputTextFile::OpenFile(void)
}
}

if (PreFunctions.size() > 0) {
for (unsigned int i=0;i<PreFunctions.size();i++) {
outstream << delimeter << PreFunctions[i]->GetName();
}
}

outstream << endl;
outstream.flush();

Expand Down Expand Up @@ -382,6 +390,9 @@ void FGOutputTextFile::Print(void)
for (unsigned int i=0;i<OutputProperties.size();i++) {
outstream << delimeter << OutputProperties[i]->getDoubleValue();
}
for (unsigned int i=0;i<PreFunctions.size();i++) {
outstream << delimeter << PreFunctions[i]->getDoubleValue();
}
outstream.precision(10);

outstream << endl;
Expand Down
82 changes: 61 additions & 21 deletions src/input_output/FGScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ using namespace std;

namespace JSBSim {

static const char *IdSrc = "$Id: FGScript.cpp,v 1.51 2013/06/10 01:50:43 jberndt Exp $";
static const char *IdSrc = "$Id: FGScript.cpp,v 1.52 2013/09/11 12:46:35 jberndt Exp $";
static const char *IdHdr = ID_FGSCRIPT;

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -275,6 +275,9 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)

// Notify about when this event is triggered?
if ((notify_element = event_element->FindElement("notify")) != 0) {
if (notify_element->HasAttribute("format")) {
if (notify_element->GetAttributeValue("format") == "kml") newEvent->NotifyKML = true;
}
newEvent->Notify = true;
// Check here for new <description> tag that gets echoed
string notify_description = notify_element->FindElementValue("description");
Expand All @@ -284,23 +287,16 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
notify_property_element = notify_element->FindElement("property");
while (notify_property_element) {
notifyPropertyName = notify_property_element->GetDataLine();
if (PropertyManager->GetNode(notifyPropertyName)) {
newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) );

newEvent->NotifyPropertyNames.push_back(notifyPropertyName);
newEvent->NotifyProperties.push_back(0);
string caption_attribute = notify_property_element->GetAttributeValue("caption");
if (caption_attribute.empty()) {
newEvent->DisplayString.push_back(notifyPropertyName);
} else {
newEvent->DisplayString.push_back(caption_attribute);
}
} else {
cout << endl << fgred << " Could not find the property named "
<< notifyPropertyName << " in script" << endl << " \""
<< ScriptName << "\". Execution is aborted. Please recheck "
<< "your input files and scripts." << reset << endl;
delete newEvent->Condition;
delete newEvent;
return false;
}

notify_property_element = notify_element->FindNextElement("property");
}
}
Expand All @@ -313,7 +309,6 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
} else {
newEvent->SetParam.push_back( 0L );
cerr << "Property " << prop_name << " will be late-bound." << endl;
}
newEvent->SetParamName.push_back( prop_name );

Expand Down Expand Up @@ -477,15 +472,44 @@ bool FGScript::RunScript(void)

// Print notification values after setting them
if (thisEvent.Notify && !thisEvent.Notified) {
cout << endl << " Event " << event_ctr << " (" << thisEvent.Name << ")"
<< " executed at time: " << currentTime << endl;
if (thisEvent.NotifyKML) {
cout << endl << "<Placemark>" << endl;
cout << " <name> " << currentTime << " seconds" << " </name>" << endl;
cout << " <description>" << endl;
cout << " <![CDATA[" << endl;
cout << " <b>" << thisEvent.Name << " (Event " << event_ctr << ")" << " executed at time: " << currentTime << "</b><br/>" << endl;
} else {
cout << endl << underon
<< highint << thisEvent.Name << normint << underoff
<< " (Event " << event_ctr << ")"
<< " executed at time: " << highint << currentTime << normint << endl;
}
if (!thisEvent.Description.empty()) {
cout << " " << thisEvent.Description << endl;
}
for (j=0; j<thisEvent.NotifyProperties.size();j++) {
// cout << " " << thisEvent.NotifyProperties[j]->GetRelativeName()
cout << " " << thisEvent.DisplayString[j]
<< " = " << thisEvent.NotifyProperties[j]->getDoubleValue() << endl;
if (thisEvent.NotifyProperties[j] == 0) {
if (PropertyManager->HasNode(thisEvent.NotifyPropertyNames[j])) {
thisEvent.NotifyProperties[j] = PropertyManager->GetNode(thisEvent.NotifyPropertyNames[j]);
} else {
throw("Could not find property named "+thisEvent.NotifyPropertyNames[j]+" in script.");
}
}
cout << " " << thisEvent.DisplayString[j] << " = " << thisEvent.NotifyProperties[j]->getDoubleValue();
if (thisEvent.NotifyKML) cout << " <br/>";
cout << endl;
}
if (thisEvent.NotifyKML) {
cout << " ]]>" << endl;
cout << " </description>" << endl;
cout << " <Point>" << endl;
cout << " <altitudeMode> absolute </altitudeMode>" << endl;
cout << " <extrude> 1 </extrude>" << endl;
cout << " <coordinates>" << FDMExec->GetPropagate()->GetLongitudeDeg()
<< "," << FDMExec->GetPropagate()->GetGeodLatitudeDeg()
<< "," << FDMExec->GetPropagate()->GetAltitudeASLmeters() << "</coordinates>" << endl;
cout << " </Point>" << endl;
cout << "</Placemark>" << endl;
}
cout << endl;
thisEvent.Notified = true;
Expand Down Expand Up @@ -561,25 +585,37 @@ void FGScript::Debug(int from)
for (unsigned j=0; j<Events[i].SetValue.size(); j++) {
if (Events[i].SetValue[j] == 0.0 && Events[i].Functions[j] != 0L) {
if (Events[i].SetParam[j] == 0) {
if (Events[i].SetParamName[j].size() == 0) {
cerr << fgred << highint << endl
<< " An attempt has been made to access a non-existent property" << endl
<< " in this event. Please check the property names used, spelling, etc."
<< reset << endl;
exit(-1);
} else {
cout << endl << " set " << Events[i].SetParamName[j]
<< " to function value (Late Bound)";
}
} else {
cout << endl << " set " << Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
<< " to function value";
}
} else {
if (Events[i].SetParam[j] == 0) {
if (Events[i].SetParamName[j].size() == 0) {
cerr << fgred << highint << endl
<< " An attempt has been made to access a non-existent property" << endl
<< " in this event. Please check the property names used, spelling, etc."
<< reset << endl;
exit(-1);
} else {
cout << endl << " set " << Events[i].SetParamName[j]
<< " to function value (Late Bound)";
}
} else {
cout << endl << " set " << Events[i].SetParam[j]->GetRelativeName("/fdm/jsbsim/")
<< " to " << Events[i].SetValue[j];
}
}

switch (Events[i].Type[j]) {
case FG_VALUE:
Expand Down Expand Up @@ -615,10 +651,14 @@ void FGScript::Debug(int from)
// Print notifications
if (Events[i].Notify) {
if (Events[i].NotifyProperties.size() > 0) {
cout << " Notifications" << ":" << endl << " {" << endl;
for (unsigned j=0; j<Events[i].NotifyProperties.size();j++) {
if (Events[i].NotifyKML) {
cout << " Notifications (KML Format):" << endl << " {" << endl;
} else {
cout << " Notifications:" << endl << " {" << endl;
}
for (unsigned j=0; j<Events[i].NotifyPropertyNames.size();j++) {
cout << " "
<< Events[i].NotifyProperties[j]->GetRelativeName("/fdm/jsbsim/")
<< Events[i].NotifyPropertyNames[j]
<< endl;
}
cout << " }" << endl;
Expand Down
8 changes: 5 additions & 3 deletions src/input_output/FGScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

#define ID_FGSCRIPT "$Id: FGScript.h,v 1.24 2013/06/10 01:50:43 jberndt Exp $"
#define ID_FGSCRIPT "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $"

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
Expand Down Expand Up @@ -158,7 +158,7 @@ CLASS DOCUMENTATION
comes the &quot;run&quot; section, where the conditions are
described in &quot;event&quot; clauses.</p>
@author Jon S. Berndt
@version "$Id: FGScript.h,v 1.24 2013/06/10 01:50:43 jberndt Exp $"
@version "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $"
*/

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -214,6 +214,7 @@ class FGScript : public FGJSBBase, public FGXMLFileRead
bool Continuous;
bool Triggered;
bool Notify;
bool NotifyKML;
bool Notified;
double Delay;
double StartTime;
Expand All @@ -223,6 +224,7 @@ class FGScript : public FGJSBBase, public FGXMLFileRead
vector <FGPropertyNode_ptr> SetParam;
vector <std::string> SetParamName;
vector <FGPropertyNode_ptr> NotifyProperties;
vector <string> NotifyPropertyNames;
vector <string> DisplayString;
vector <eAction> Action;
vector <eType> Type;
Expand All @@ -239,7 +241,7 @@ class FGScript : public FGJSBBase, public FGXMLFileRead
Persistent = false;
Continuous = false;
Delay = 0.0;
Notify = Notified = false;
Notify = Notified = NotifyKML = false;
Name = "";
StartTime = 0.0;
TimeSpan = 0.0;
Expand Down
9 changes: 3 additions & 6 deletions src/math/FGFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace std;

namespace JSBSim {

static const char *IdSrc = "$Id: FGFunction.cpp,v 1.50 2013/06/10 02:05:12 jberndt Exp $";
static const char *IdSrc = "$Id: FGFunction.cpp,v 1.51 2013/09/11 12:49:36 jberndt Exp $";
static const char *IdHdr = ID_FUNCTION;

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -807,14 +807,11 @@ void FGFunction::bind(void)
}

if (PropertyManager->HasNode(tmp)) {
FGPropertyNode* property = PropertyManager->GetNode(tmp);
if (property->isTied()) {
cout << "Property " << tmp << " has already been successfully bound (late)." << endl;
return;
} else {
PropertyManager->Tie( tmp, this, &FGFunction::GetValue);
}
}

PropertyManager->Tie( tmp, this, &FGFunction::GetValue);
}
}

Expand Down
Loading

0 comments on commit 06d0f97

Please sign in to comment.