namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.186 2016/01/10 16:32:26 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.187 2016/01/31 11:12:59 bcoconni Exp $");
IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Models[i]->InitModel();
}
- RunIC();
-
if (Script)
Script->ResetEvents();
else
Setsim_time(0.0);
+
+ RunIC();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGScript.cpp,v 1.63 2015/09/28 21:14:15 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGScript.cpp,v 1.64 2016/04/03 17:10:46 bcoconni Exp $");
IDENT(IdHdr,ID_FGSCRIPT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGScript::ResetEvents(void)
{
- //LocalProperties.ResetToIC();
+ LocalProperties.ResetToIC();
FDMExec->Setsim_time(StartTime);
for (unsigned int i=0; i<Events.size(); i++)
private:
int sckt;
int sckt_in;
- //int udpsckt;
+ int udpsckt;
DirectionType Direction;
ProtocolType Protocol;
struct sockaddr_in scktName;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.25 2015/12/09 04:28:18 jberndt Exp $");
+IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.26 2016/01/31 11:13:00 bcoconni Exp $");
IDENT(IdHdr,ID_ACCELERATIONS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vPQRidot.InitMatrix();
vUVWidot.InitMatrix();
+ vUVWdot.InitMatrix();
vGravAccel.InitMatrix();
vBodyAccel.InitMatrix();
vQtrndot = FGQuaternion(0,0,0);
vPQRidot.InitMatrix();
vUVWidot.InitMatrix();
+ vUVWdot.InitMatrix();
vGravAccel.InitMatrix();
vBodyAccel.InitMatrix();
vQtrndot = FGQuaternion(0,0,0);
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.92 2015/07/12 19:34:08 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.94 2016/04/03 11:13:19 bcoconni Exp $");
IDENT(IdHdr,ID_FCS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
+FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex), ChannelRate(1)
{
int i;
Name = "FGFCS";
// Execute system channels in order
for (i=0; i<SystemChannels.size(); i++) {
if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl;
+ ChannelRate = SystemChannels[i]->GetRate();
SystemChannels[i]->Execute();
}
+ ChannelRate = 1;
RunPostFunctions();
string sOnOffProperty = channel_element->GetAttributeValue("execute");
string sChannelName = channel_element->GetAttributeValue("name");
+
+ int Rate = 0;
+ if (!channel_element->GetAttributeValue("execrate").empty())
+ Rate = channel_element->GetAttributeValueAsNumber("execrate");
+
if (sOnOffProperty.length() > 0) {
FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
if (OnOffPropertyNode == 0) {
- cerr << highint << fgred
+ cerr << channel_element->ReadFrom() << highint << fgred
<< "The On/Off property, " << sOnOffProperty << " specified for channel "
<< channel_element->GetAttributeValue("name") << " is undefined or not "
<< "understood. The simulation will abort" << reset << endl;
throw("Bad system definition");
- } else {
- newChannel = new FGFCSChannel(sChannelName, OnOffPropertyNode);
- }
- } else {
- newChannel = new FGFCSChannel(sChannelName);
- }
+ } else
+ newChannel = new FGFCSChannel(this, sChannelName, Rate,
+ OnOffPropertyNode);
+ } else
+ newChannel = new FGFCSChannel(this, sChannelName, Rate);
SystemChannels.push_back(newChannel);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGFCS::GetDt(void)
+double FGFCS::GetDt(void) const
{
return FDMExec->GetDeltaT()*rate;
}
PropertyManager->Tie("gear/tailhook-pos-norm", this, &FGFCS::GetTailhookPos, &FGFCS::SetTailhookPos);
PropertyManager->Tie("fcs/wing-fold-pos-norm", this, &FGFCS::GetWingFoldPos, &FGFCS::SetWingFoldPos);
+ PropertyManager->Tie("simulation/channel-dt", this, &FGFCS::GetChannelDeltaT);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Id: FGFCS.h,v 1.49 2015/07/12 19:34:08 bcoconni Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.50 2016/02/27 16:54:15 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@property gear/tailhook-pos-norm
@author Jon S. Berndt
- @version $Revision: 1.49 $
+ @version $Revision: 1.50 $
@see FGActuator
@see FGDeadBand
@see FGFCSFunction
void AddThrottle(void);
void AddGear(unsigned int NumGear);
- double GetDt(void);
+ double GetDt(void) const;
FGPropertyManager* GetPropertyManager(void) { return PropertyManager; }
bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
+ double GetChannelDeltaT(void) const { return GetDt() * ChannelRate; }
private:
double DaCmd, DeCmd, DrCmd, DsCmd, DfCmd, DsbCmd, DspCmd;
double GearCmd,GearPos;
double TailhookPos, WingFoldPos;
SystemType systype;
+ int ChannelRate;
typedef std::vector <FGFCSChannel*> Channels;
Channels SystemChannels;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.5 2015/03/28 14:49:02 bcoconni Exp $"
+#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.9 2016/04/03 17:06:24 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Represents a <channel> in a control system definition.
The <channel> may be defined within a <system>, <autopilot> or <flight_control>
element. Channels are a way to group sets of components that perform
- a specific purpose or algorithm. */
+ a specific purpose or algorithm.
+ Created within a <system> tag, the channel is defined as follows
+ <channel name="name" [execute="property"] [execrate="rate"]>
+ name is the name of the channel - in the old way this would also be used to bind elements
+ execute [optional] is the property that defines when to execute this channel; an on/off switch
+ execrate [optional] is the rate at which the channel should execute.
+ A value of 0 or 1 will execute the channel every frame, a value of 2
+ every other frame (half rate), a value of 4 is every 4th frame (quarter rate)
+ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
class FGFCSChannel {
public:
/// Constructor
- FGFCSChannel(std::string name, FGPropertyNode* node=0) :
- OnOffNode(node), Name(name)
+ FGFCSChannel(FGFCS* FCS, const std::string &name, int execRate,
+ FGPropertyNode* node=0)
+ : fcs(FCS), OnOffNode(node), Name(name)
{
+ ExecRate = execRate < 1 ? 1 : execRate;
+ // Set ExecFrameCountSinceLastRun so that each components are initialized
+ ExecFrameCountSinceLastRun = ExecRate;
}
+
/// Destructor
~FGFCSChannel() {
for (unsigned int i=0; i<FCSComponents.size(); i++) delete FCSComponents[i];
std::string GetName() {return Name;}
/// Adds a component to a channel
- void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);}
+ void Add(FGFCSComponent* comp) {
+ FCSComponents.push_back(comp);
+ comp->SetDtForFrameCount(ExecRate);
+ }
/// Returns the number of components in the channel.
size_t GetNumComponents() {return FCSComponents.size();}
/// Retrieves a specific component.
void Reset() {
for (unsigned int i=0; i<FCSComponents.size(); i++)
FCSComponents[i]->ResetPastStates();
+
+ // Set ExecFrameCountSinceLastRun so that each components are initialized
+ // after a reset.
+ ExecFrameCountSinceLastRun = ExecRate;
}
/// Executes all the components in a channel.
void Execute() {
// If there is an on/off property supplied for this channel, check
// the value. If it is true, permit execution to continue. If not, return
// and do not execute the channel.
- if (OnOffNode != 0)
- if (!OnOffNode->getBoolValue()) return;
+ if (OnOffNode && !OnOffNode->getBoolValue()) return;
+
+ if (fcs->GetDt() != 0.0)
+ ++ExecFrameCountSinceLastRun;
- for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run();
+ // channel will be run at rate 1 if trimming, or when the next execrate
+ // frame is reached
+ if (fcs->GetTrimStatus() || ExecFrameCountSinceLastRun >= ExecRate) {
+ for (unsigned int i=0; i<FCSComponents.size(); i++)
+ FCSComponents[i]->Run();
+ }
+
+ if (ExecFrameCountSinceLastRun >= ExecRate)
+ ExecFrameCountSinceLastRun = 0;
}
+ /// Get the channel rate
+ int GetRate(void) const { return ExecRate; }
private:
+ FGFCS* fcs;
FCSCompVec FCSComponents;
FGConstPropertyNode_ptr OnOffNode;
std::string Name;
+
+ int ExecRate; // rate at which this system executes, 0 or 1 every frame, 2 every second frame etc..
+ int ExecFrameCountSinceLastRun;
};
}
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.54 2015/12/09 04:28:18 jberndt Exp $");
+IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.55 2016/03/26 18:54:27 bcoconni Exp $");
IDENT(IdHdr,ID_MASSBALANCE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGMassBalance::AddPointMass(Element* el)
{
- double radius=0, length=0;
Element* loc_element = el->FindElement("location");
string pointmass_name = el->GetAttributeValue("name");
if (!loc_element) {
- cerr << "Pointmass " << pointmass_name << " has no location." << endl;
+ cerr << el->ReadFrom() << "Pointmass " << pointmass_name
+ << " has no location." << endl;
exit(-1);
}
Element* form_element = el->FindElement("form");
if (form_element) {
+ double radius=0, length=0;
string shape = form_element->GetAttributeValue("shape");
Element* radius_element = form_element->FindElement("radius");
Element* length_element = form_element->FindElement("length");
(PMF)&FGMassBalance::GetXYZcg);
PropertyManager->Tie("inertia/cg-z-in", this,3,
(PMF)&FGMassBalance::GetXYZcg);
+ PropertyManager->Tie("inertia/ixx-slugs_ft2", this,
+ &FGMassBalance::GetIxx);
+ PropertyManager->Tie("inertia/iyy-slugs_ft2", this,
+ &FGMassBalance::GetIyy);
+ PropertyManager->Tie("inertia/izz-slugs_ft2", this,
+ &FGMassBalance::GetIzz);
+ PropertyManager->Tie("inertia/ixy-slugs_ft2", this,
+ &FGMassBalance::GetIxy);
+ PropertyManager->Tie("inertia/ixz-slugs_ft2", this,
+ &FGMassBalance::GetIxz);
+ PropertyManager->Tie("inertia/iyz-slugs_ft2", this,
+ &FGMassBalance::GetIyz);
typedef int (FGMassBalance::*iOPV)() const;
PropertyManager->Tie("inertia/print-mass-properties", this, (iOPV)0,
&FGMassBalance::GetMassPropertiesReport, false);
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.36 2015/08/22 18:09:00 bcoconni Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.37 2016/03/26 18:54:27 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS
FGColumnVector3 vPMxyz;
FGColumnVector3 PointMassCG;
const FGMatrix33& CalculatePMInertias(void);
-
+ double GetIxx(void) const { return mJ(1,1); }
+ double GetIyy(void) const { return mJ(2,2); }
+ double GetIzz(void) const { return mJ(3,3); }
+ double GetIxy(void) const { return -mJ(1,2); }
+ double GetIxz(void) const { return -mJ(1,3); }
+ double GetIyz(void) const { return -mJ(2,3); }
/** The PointMass structure encapsulates a point mass object, moments of inertia
mass, location, etc. */
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFCSComponent.cpp,v 1.41 2015/07/12 19:34:08 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFCSComponent.cpp,v 1.42 2016/02/27 16:54:15 bcoconni Exp $");
IDENT(IdHdr,ID_FCSCOMPONENT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFCSComponent::Run(void)
+void FGFCSComponent::SetDtForFrameCount(int FrameCount)
{
- return true;
+ dt = fcs->GetDt() * FrameCount;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
-// The old way of naming FCS components allowed upper or lower case, spaces, etc.
-// but then the names were modified to fit into a property name heirarchy. This
-// was confusing (it wasn't done intentionally - it was a carryover from the early
-// design). We now support the direct naming of properties in the FCS component
-// name attribute. The old way is supported in code at this time, but deprecated.
+// The old way of naming FCS components allowed upper or lower case, spaces,
+// etc. but then the names were modified to fit into a property name
+// hierarchy. This was confusing (it wasn't done intentionally - it was a
+// carryover from the early design). We now support the direct naming of
+// properties in the FCS component name attribute. The old way is supported in
+// code at this time, but deprecated.
void FGFCSComponent::bind(void)
{
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.27 2015/07/12 19:34:08 bcoconni Exp $"
+#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.28 2016/02/27 16:54:16 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
- FGAngle
@author Jon S. Berndt
- @version $Id: FGFCSComponent.h,v 1.27 2015/07/12 19:34:08 bcoconni Exp $
+ @version $Id: FGFCSComponent.h,v 1.28 2016/02/27 16:54:16 bcoconni Exp $
@see Documentation for the FGFCS class, and for the configuration file class
*/
/// Destructor
virtual ~FGFCSComponent();
- virtual bool Run(void);
+ virtual bool Run(void) { return true; }
virtual void SetOutput(void);
+ void SetDtForFrameCount(int FrameCount);
double GetOutput (void) const {return Output;}
std::string GetName(void) const {return Name;}
std::string GetType(void) const { return Type; }