Make ts run better.
Change-Id: I5bdaa0e1bda5aaca6d29e4a0948fe6151e616af0
diff --git a/aos/network/web_proxy_main.cc b/aos/network/web_proxy_main.cc
index 479320a..7ea3ff4 100644
--- a/aos/network/web_proxy_main.cc
+++ b/aos/network/web_proxy_main.cc
@@ -15,17 +15,23 @@
std::vector<std::unique_ptr<aos::web_proxy::Subscriber>> *subscribers,
const aos::FlatbufferDetachedBuffer<aos::Configuration> &config) {
aos::ShmEventLoop event_loop(&config.message());
- const aos::Node *self = aos::configuration::GetMyNode(&config.message());
+ const bool is_multi_node =
+ aos::configuration::MultiNode(event_loop.configuration());
+ const aos::Node *self =
+ is_multi_node ? aos::configuration::GetMyNode(event_loop.configuration())
+ : nullptr;
+
+ LOG(INFO) << "My node is " << aos::FlatbufferToJson(self);
// TODO(alex): skip fetchers on the wrong node.
for (uint i = 0; i < config.message().channels()->size(); ++i) {
auto channel = config.message().channels()->Get(i);
- if (!aos::configuration::ChannelIsReadableOnNode(channel, self)) {
- subscribers->emplace_back(nullptr);
- } else {
+ if (aos::configuration::ChannelIsReadableOnNode(channel, self)) {
auto fetcher = event_loop.MakeRawFetcher(channel);
subscribers->emplace_back(
std::make_unique<aos::web_proxy::Subscriber>(std::move(fetcher), i));
+ } else {
+ subscribers->emplace_back(nullptr);
}
}
@@ -33,7 +39,9 @@
auto timer = event_loop.AddTimer([&]() {
for (auto &subscriber : *subscribers) {
- subscriber->RunIteration();
+ if (subscriber != nullptr) {
+ subscriber->RunIteration();
+ }
}
});
diff --git a/aos/network/www/proxy.ts b/aos/network/www/proxy.ts
index 80c71b2..13f4636 100644
--- a/aos/network/www/proxy.ts
+++ b/aos/network/www/proxy.ts
@@ -1,5 +1,6 @@
import {ConfigHandler} from './config_handler';
import {Configuration} from 'aos/configuration_generated';
+import * as WebProxy from 'aos/network/web_proxy_generated';
// There is one handler for each DataChannel, it maintains the state of
// multi-part messages and delegates to a callback when the message is fully
@@ -73,7 +74,7 @@
const fbBuffer = new flatbuffers.ByteBuffer(new Uint8Array(e.data));
// TODO(alex): handle config updates if/when required
if (!this.configHandler) {
- const config = aos.Configuration.getRootAsConfiguration(fbBuffer);
+ const config = Configuration.getRootAsConfiguration(fbBuffer);
this.config = config;
this.configHandler = new ConfigHandler(config, this.dataChannel);
this.configHandler.printConfig();
diff --git a/y2020/www/image_handler.ts b/y2020/www/image_handler.ts
index 802e448..6ad83a3 100644
--- a/y2020/www/image_handler.ts
+++ b/y2020/www/image_handler.ts
@@ -1,10 +1,11 @@
import {CameraImage} from 'y2020/vision/vision_generated';
+import {ImageMatchResult} from 'y2020/vision/sift/sift_generated'
export class ImageHandler {
private canvas = document.createElement('canvas');
private imageBuffer: Uint8ClampedArray|null = null;
private imageTimestamp: flatbuffers.Long|null = null;
- private result: fr971.vision.ImageMatchResult|null = null;
+ private result: ImageMatchResult|null = null;
private resultTimestamp: flatbuffers.Long|null = null;
constructor() {
@@ -56,7 +57,7 @@
handleImageMetadata(data: Uint8Array): void {
const fbBuffer = new flatbuffers.ByteBuffer(data);
- this.result = frc971.vision.ImageMatchResult.getRootAsImageMatchResult(fbBuffer);
+ this.result = ImageMatchResult.getRootAsImageMatchResult(fbBuffer);
this.resultTimestamp = result.imageMonotonicTimestampNs();
draw();
}
@@ -92,6 +93,6 @@
}
getResultId(): string {
- return frc971.vision.ImageMatchResult.getFullyQualifiedName();
+ return ImageMatchResult.getFullyQualifiedName();
}
}