Parse a line of data sent from FlightGear and update the outputs
Changes to a Property's state will be signaled through its broadcast Property.stream.
Source
void parse(List<int> data) {
var update = UTF8.decode(data);
update = update.split(out_separator);
if (update.length != outputs.values.length) {
print("err... update doesn't contain all properties ($update)");
return;
}
for (var prop in outputs.values) {
var foo = update.removeAt(0);
if (prop.type == PropertyType.int) {
foo = int.parse(foo, onError: (s) {
print('error parsing update($s) for ${prop.node}');
return 0;
});
} else if (prop.type == PropertyType.float) {
foo = num.parse(foo, (s) {
print('error parsing update($s) for ${prop.node}');
return 0.0;
});
} else if (prop.type == PropertyType.bool) {
foo = foo == 'true' || foo == '1';
}
if (foo != prop.value) {
prop._value = foo;
print("${prop.node} updated: $foo");
prop._streamctl.add(prop);
}
}
}