}
string config = tokens[ configToken ];
- string file = config+".xml";
+ file_name = config+".xml";
+ direction = tokens[2];
- SGPath path( globals->get_fg_root() );
- path.append("Protocol");
- path.append(file.c_str());
- SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
- << path.str());
-
- SGPropertyNode root;
- try {
- readProperties(path.str(), &root);
- } catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Unable to load the protocol configuration file");
- return;
- }
-
- if (tokens[2] == "out") {
- SGPropertyNode *output = root.getNode("generic/output");
- if (output) {
- read_config(output, _out_message);
- }
- } else if (tokens[2] == "in") {
- SGPropertyNode *input = root.getNode("generic/input");
- if (input) {
- read_config(input, _in_message);
- }
- } else {
+ if (direction != "in" && direction != "out") {
SG_LOG(SG_GENERAL, SG_ALERT, "Unsuported protocol direction: "
- << tokens[2]);
+ << direction);
}
+
+ reinit();
}
FGGeneric::~FGGeneric() {
if (binary_byte_order == BYTE_ORDER_MATCHES_NETWORK_ORDER) {
*((int32_t*)&buf[length]) = (int32_t)fixed;
} else {
- *((uint32_t*)&buf[length]) = sg_bswap_32((uint32_t)val);
+ *((uint32_t*)&buf[length]) = sg_bswap_32((uint32_t)fixed);
}
length += sizeof(int32_t);
break;
break;
case FG_FIXED:
- case FG_DOUBLE:
+ case FG_FLOAT:
val = _in_message[i].offset + strtod(p1, 0) * _in_message[i].factor;
_in_message[i].prop->setFloatValue((float)val);
break;
+ case FG_DOUBLE:
+ val = _in_message[i].offset + strtod(p1, 0) * _in_message[i].factor;
+ _in_message[i].prop->setDoubleValue(val);
+ break;
+
default: // SG_STRING
_in_message[i].prop->setStringValue(p1);
}
}
+void
+FGGeneric::reinit()
+{
+ SGPath path( globals->get_fg_root() );
+ path.append("Protocol");
+ path.append(file_name.c_str());
+
+ SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
+ << path.str());
+
+ SGPropertyNode root;
+ try {
+ readProperties(path.str(), &root);
+ } catch (const sg_exception &) {
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Unable to load the protocol configuration file");
+ return;
+ }
+
+ if (direction == "out") {
+ SGPropertyNode *output = root.getNode("generic/output");
+ if (output) {
+ _out_message.clear();
+ read_config(output, _out_message);
+ }
+ } else if (direction == "in") {
+ SGPropertyNode *input = root.getNode("generic/input");
+ if (input) {
+ _in_message.clear();
+ read_config(input, _in_message);
+ }
+ }
+}
+
+
void
FGGeneric::read_config(SGPropertyNode *root, vector<_serial_prot> &msg)
{