[wpilib] Sendable: Don't call setter for getter changes

This commit is contained in:
Peter Johnson
2022-12-05 23:08:40 -08:00
parent 342c375a71
commit b9772214d9
2 changed files with 28 additions and 15 deletions

View File

@@ -130,7 +130,8 @@ void SendableBuilderImpl::AddPropertyImpl(Topic topic, Getter getter,
};
}
if (setter) {
prop->sub = topic.Subscribe({});
prop->sub = topic.Subscribe(
{}, {{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
prop->updateLocal = [=](auto& sub) {
for (auto&& val : sub.ReadQueue()) {
setter(val.value);
@@ -223,7 +224,9 @@ void SendableBuilderImpl::AddRawProperty(
};
}
if (setter) {
prop->sub = topic.Subscribe(typeString, {});
prop->sub = topic.Subscribe(
typeString, {},
{{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
prop->updateLocal = [=](auto& sub) {
for (auto&& val : sub.ReadQueue()) {
setter(val.value);
@@ -246,7 +249,8 @@ void SendableBuilderImpl::AddSmallPropertyImpl(Topic topic, Getter getter,
};
}
if (setter) {
prop->sub = topic.Subscribe({});
prop->sub = topic.Subscribe(
{}, {{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
prop->updateLocal = [=](auto& sub) {
for (auto&& val : sub.ReadQueue()) {
setter(val.value);
@@ -324,7 +328,9 @@ void SendableBuilderImpl::AddSmallRawProperty(
};
}
if (setter) {
prop->sub = topic.Subscribe(typeString, {});
prop->sub = topic.Subscribe(
typeString, {},
{{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
prop->updateLocal = [=](auto& sub) {
for (auto&& val : sub.ReadQueue()) {
setter(val.value);