58 dt =
fcs->GetChannelDeltaT();
61 if (element->
GetName() ==
string(
"lag_filter")) {
63 }
else if (element->
GetName() ==
string(
"lead_lag_filter")) {
64 Type =
"LEAD_LAG_FILTER";
65 }
else if (element->
GetName() ==
string(
"washout_filter")) {
66 Type =
"WASHOUT_FILTER";
67 }
else if (element->
GetName() ==
string(
"second_order_filter")) {
68 Type =
"SECOND_ORDER_FILTER";
69 }
else if (element->
GetName() ==
string(
"integrator")) {
71 }
else if (element->
GetName() ==
string(
"summer")) {
73 }
else if (element->
GetName() ==
string(
"pure_gain")) {
75 }
else if (element->
GetName() ==
string(
"scheduled_gain")) {
76 Type =
"SCHEDULED_GAIN";
77 }
else if (element->
GetName() ==
string(
"aerosurface_scale")) {
78 Type =
"AEROSURFACE_SCALE";
79 }
else if (element->
GetName() ==
string(
"switch")) {
81 }
else if (element->
GetName() ==
string(
"kinematic")) {
83 }
else if (element->
GetName() ==
string(
"deadband")) {
85 }
else if (element->
GetName() ==
string(
"fcs_function")) {
86 Type =
"FCS_FUNCTION";
87 }
else if (element->
GetName() ==
string(
"pid")) {
89 }
else if (element->
GetName() ==
string(
"sensor")) {
91 }
else if (element->
GetName() ==
string(
"accelerometer")) {
92 Type =
"ACCELEROMETER";
93 }
else if (element->
GetName() ==
string(
"magnetometer")) {
94 Type =
"MAGNETOMETER";
95 }
else if (element->
GetName() ==
string(
"gyro")) {
97 }
else if (element->
GetName() ==
string(
"actuator")) {
99 }
else if (element->
GetName() ==
string(
"waypoint_heading")) {
100 Type =
"WAYPOINT_HEADING";
101 }
else if (element->
GetName() ==
string(
"waypoint_distance")) {
102 Type =
"WAYPOINT_DISTANCE";
103 }
else if (element->
GetName() ==
string(
"angle")) {
105 }
else if (element->
GetName() ==
string(
"distributor")) {
106 Type =
"DISTRIBUTOR";
114 while (init_element) {
121 while (input_element) {
134 cerr << out_elem->
ReadFrom() <<
" Unable to process property: "
135 << output_node_name << endl;
136 throw(
string(
"Invalid output property name in flight control definition"));
144 OutputNode->setDoubleValue(
Output);
152 if (delayType.length() > 0) {
153 if (delayType ==
"time") {
155 }
else if (delayType ==
"frames") {
158 cerr <<
"Unallowed delay type" << endl;
172 <<
"Element <min> is missing, <clipto> is ignored." << endl;
181 <<
"Element <max> is missing, <clipto> is ignored." << endl;
219 if (num < MinNodes) {
221 <<
" Not enough <input> nodes are provided" << endl
222 <<
" Expecting " << MinNodes <<
" while " << num
223 <<
" are provided." << endl;
224 throw(
"Some inputs are missing.");
227 if (num > MaxNodes) {
229 <<
" Too many <input> nodes are provided" << endl
230 <<
" Expecting " << MaxNodes <<
" while " << num
231 <<
" are provided." << endl
232 <<
" The last " << num-MaxNodes <<
" input nodes will be ignored."
242 node->setDoubleValue(
Output);
249 if (
fcs->GetTrimStatus()) {
267 double vmin =
ClipMin->GetValue();
268 double vmax =
ClipMax->GetValue();
269 double range = vmax - vmin;
272 cerr <<
"Trying to clip with a max value (" << vmax <<
") from "
273 <<
ClipMax->GetName() <<
" lower than the min value (" << vmin
274 <<
") from " <<
ClipMin->GetName() <<
"." << endl
275 <<
"Clipping is ignored." << endl;
280 double value =
Output - vmin;
281 Output = fmod(value, range) + vmin;
302 if (
Name.find(
"/") == string::npos)
317 node->setDoubleValue(
Output);
321 <<
"Could not get or create property " << tmp << endl;
350 cout << endl <<
" Loading Component \"" <<
Name
351 <<
"\" of type: " <<
Type << endl;
354 cout <<
" Minimum limit: " <<
ClipMin->GetName() << endl;
355 cout <<
" Maximum limit: " <<
ClipMax->GetName() << endl;
357 if (
delay > 0) cout <<
" Frame delay: " <<
delay
358 <<
" frames (" <<
delay*
dt <<
" sec)" << endl;
362 if (from == 0) cout <<
"Instantiated: FGFCSComponent" << endl;
363 if (from == 1) cout <<
"Destroyed: FGFCSComponent" << endl;
const std::string & GetName(void) const
Retrieves the element name.
std::string ReadFrom(void) const
Return a string that contains a description of the location where the current XML element was read fr...
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
double GetDataAsNumber(void)
Converts the element data to a number.
Element * FindElement(const std::string &el="")
Searches for a specified element.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
FGFCSComponent(FGFCS *fcs, Element *el)
Constructor.
std::vector< FGPropertyValue_ptr > InitNodes
std::vector< FGPropertyValue_ptr > InputNodes
void CheckInputNodes(size_t MinNodes, size_t MaxNodes, Element *el)
virtual void Debug(int from)
virtual ~FGFCSComponent()
Destructor.
std::vector< double > output_array
virtual void ResetPastStates(void)
FGPropertyManager * PropertyManager
virtual void bind(Element *el)
virtual void SetOutput(void)
std::vector< FGPropertyNode_ptr > OutputNodes
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
Represents a either a real value or a property value.
Class wrapper for property handling.
Represents a property value which can use late binding.