Constructor.
53 : fcs(_fcs)
54{
55 Input = Output = delay_time = 0.0;
56 delay = index = 0;
57 ClipMin = ClipMax = new FGRealValue(0.0);
58 clip = cyclic_clip = false;
59 dt = fcs->GetChannelDeltaT();
60
61 auto PropertyManager = fcs->GetPropertyManager();
62 if (element->GetName() == string("lag_filter")) {
63 Type = "LAG_FILTER";
64 } else if (element->GetName() == string("lead_lag_filter")) {
65 Type = "LEAD_LAG_FILTER";
66 } else if (element->GetName() == string("washout_filter")) {
67 Type = "WASHOUT_FILTER";
68 } else if (element->GetName() == string("second_order_filter")) {
69 Type = "SECOND_ORDER_FILTER";
70 } else if (element->GetName() == string("integrator")) {
71 Type = "INTEGRATOR";
72 } else if (element->GetName() == string("summer")) {
73 Type = "SUMMER";
74 } else if (element->GetName() == string("pure_gain")) {
75 Type = "PURE_GAIN";
76 } else if (element->GetName() == string("scheduled_gain")) {
77 Type = "SCHEDULED_GAIN";
78 } else if (element->GetName() == string("aerosurface_scale")) {
79 Type = "AEROSURFACE_SCALE";
80 } else if (element->GetName() == string("switch")) {
81 Type = "SWITCH";
82 } else if (element->GetName() == string("kinematic")) {
83 Type = "KINEMATIC";
84 } else if (element->GetName() == string("deadband")) {
85 Type = "DEADBAND";
86 } else if (element->GetName() == string("fcs_function")) {
87 Type = "FCS_FUNCTION";
88 } else if (element->GetName() == string("pid")) {
89 Type = "PID";
90 } else if (element->GetName() == string("sensor")) {
91 Type = "SENSOR";
92 } else if (element->GetName() == string("accelerometer")) {
93 Type = "ACCELEROMETER";
94 } else if (element->GetName() == string("magnetometer")) {
95 Type = "MAGNETOMETER";
96 } else if (element->GetName() == string("gyro")) {
97 Type = "GYRO";
98 } else if (element->GetName() == string("actuator")) {
99 Type = "ACTUATOR";
100 } else if (element->GetName() == string("waypoint_heading")) {
101 Type = "WAYPOINT_HEADING";
102 } else if (element->GetName() == string("waypoint_distance")) {
103 Type = "WAYPOINT_DISTANCE";
104 } else if (element->GetName() == string("angle")) {
105 Type = "ANGLE";
106 } else if (element->GetName() == string("distributor")) {
107 Type = "DISTRIBUTOR";
108 } else {
109 Type = "UNKNOWN";
110 }
111
112 Name = element->GetAttributeValue("name");
113
114 Element *init_element = element->FindElement("init");
115 while (init_element) {
116 InitNodes.push_back(new FGPropertyValue(init_element->GetDataLine(),
117 PropertyManager, init_element));
118 init_element = element->FindNextElement("init");
119 }
120
121 Element *input_element = element->FindElement("input");
122 while (input_element) {
123 InputNodes.push_back(new FGPropertyValue(input_element->GetDataLine(),
124 PropertyManager, input_element));
125
126 input_element = element->FindNextElement("input");
127 }
128
129 Element *out_elem = element->FindElement("output");
130 while (out_elem) {
131 string output_node_name = out_elem->GetDataLine();
132 bool node_exists = PropertyManager->HasNode(output_node_name);
133 SGPropertyNode* OutputNode = PropertyManager->GetNode( output_node_name,
true );
134 if (!OutputNode) {
135 XMLLogException err(out_elem);
136 err << " Unable to process property: " << output_node_name << "\n";
137 throw err;
138 }
139 OutputNodes.push_back(OutputNode);
140
141
142
143
144 if (!node_exists)
146 out_elem = element->FindNextElement("output");
147 }
148
149 Element* delay_elem = element->FindElement("delay");
150 if ( delay_elem ) {
151 string delay_str = delay_elem->GetDataLine();
152 FGParameterValue delayParam(delay_str, PropertyManager, delay_elem);
153 delay_time = delayParam.GetValue();
154 string delayType = delay_elem->GetAttributeValue("type");
155 if (delayType.length() > 0) {
156 if (delayType == "time") {
157 delay = (unsigned int)(delay_time / dt);
158 } else if (delayType == "frames") {
159 delay = (unsigned int)delay_time;
160 } else {
161 FGXMLLogging log(delay_elem, LogLevel::ERROR);
162 log << "Unallowed delay type\n";
163 }
164 } else {
165 delay = (unsigned int)(delay_time / dt);
166 }
167 output_array.resize(delay);
168 for (unsigned int i=0; i<delay; i++) output_array[i] = 0.0;
169 }
170
171 Element *clip_el = element->FindElement("clipto");
172 if (clip_el) {
173 Element* el = clip_el->FindElement("min");
174 if (!el) {
175 FGXMLLogging log(clip_el, LogLevel::ERROR);
176 log << "Element <min> is missing, <clipto> is ignored.\n";
177 return;
178 }
179
180 ClipMin = new FGParameterValue(el, PropertyManager);
181
182 el = clip_el->FindElement("max");
183 if (!el) {
184 FGXMLLogging log(clip_el, LogLevel::ERROR);
185 log << "Element <max> is missing, <clipto> is ignored.\n";
186 ClipMin = nullptr;
187 return;
188 }
189
190 ClipMax = new FGParameterValue(el, PropertyManager);
191
192 if (clip_el->GetAttributeValue("type") == "cyclic")
193 cyclic_clip = true;
194
195 clip = true;
196 }
197
198 Debug(0);
199}
A node in a property tree.
bool setDoubleValue(double value)
Set a double value for this node.