28#include <simgear/structure/exception.hxx>
29#include <simgear/debug/logstream.hxx>
30#include <simgear/io/iochannel.hxx>
31#include <simgear/props/props.hxx>
33#include <simgear/io/SGDataDistributionService.hxx>
43 SG_LOG(SG_IO, SG_ALERT,
"This shouldn't happen, but the channel "
44 <<
"is already in use, ignoring");
50 SG_DDS_Topic *dds =
static_cast<SG_DDS_Topic*
>(io);
54 if (!io->open(SG_IO_BI)) {
55 SG_LOG(SG_IO, SG_ALERT,
"Error opening channel communication layer.");
68 int length =
sizeof(prop);
69 char *buf =
reinterpret_cast<char*
>(&prop);
79 while (io->read(buf, length) &&
91 const char *path = prop.val._u.String;
92 auto it = path_list.find(path);
93 if (it == path_list.end())
95 SGPropertyNode_ptr props =
globals->get_props();
96 SGPropertyNode_ptr
p = props->getNode(path);
99 prop.id = prop_list.size();
101 prop_list.push_back(
p);
102 path_list[prop.val._u.String] = prop.id;
104 }
catch (sg_exception&) {
105 SG_LOG(SG_IO, SG_ALERT,
"out of memory");
112 prop.id = std::distance(path_list.begin(), it);
113 setProp(prop, prop_list[prop.id], s);
118 SG_LOG(SG_IO, SG_DEBUG,
"Recieved a mangled DDS sample.");
119 setProp(prop,
nullptr, s);
123 setProp(prop, prop_list[prop.id], s);
127 if (!io->write(buf, length)) {
128 SG_LOG(SG_IO, SG_ALERT,
"Error writing data.");
149void FGDDSProps::setProp(
FG_DDS_prop& prop, SGPropertyNode_ptr
p, std::string& s)
156 simgear::props::Type type =
p->getType();
157 if (type == simgear::props::BOOL) {
160 }
else if (type == simgear::props::INT) {
162 prop.val._u.Int32 =
p->getIntValue();
163 }
else if (type == simgear::props::LONG) {
165 prop.val._u.Int64 =
p->getLongValue();
166 }
else if (type == simgear::props::FLOAT) {
168 prop.val._u.Float32 =
p->getFloatValue();
169 }
else if (type == simgear::props::DOUBLE) {
171 prop.val._u.Float64 =
p->getDoubleValue();
172 }
else if (type == simgear::props::ALIAS) {
174 s =
p->getStringValue();
175 prop.val._u.String =
const_cast<char*
>(s.c_str());
176 }
else if (type == simgear::props::STRING) {
178 s =
p->getStringValue();
179 prop.val._u.String =
const_cast<char*
>(s.c_str());
180 }
else if (type == simgear::props::UNSPECIFIED) {
182 s =
p->getStringValue();
183 prop.val._u.String =
const_cast<char*
>(s.c_str());
186 prop.val._u.Int32 = 0;
SGProtocolDir get_direction() const
SGIOChannel * get_io_channel() const
void set_enabled(const bool b)
const dds_topic_descriptor_t FG_DDS_prop_desc
#define FG_DDS_MODE_WRITE
#define FG_DDS_PROP_VERSION
#define FG_DDS_PROP_REQUEST
union FG_propValue::@155153037146116023270074041102065253170142315045 _u