Provide utilities for convenient plotting of channels
Implement a set of utilities (along with basic examples) to
make it so that we can readily make plots of individual channels
from logfiles (or live on the robot).
Change-Id: Ic648c9ccb9dcb73419dc2c8c4c395fdea0536110
diff --git a/aos/network/www/reflection.ts b/aos/network/www/reflection.ts
index 9c21a17..2e1ed8f 100644
--- a/aos/network/www/reflection.ts
+++ b/aos/network/www/reflection.ts
@@ -120,6 +120,16 @@
static getRootTable(bb: ByteBuffer): Table {
return new Table(bb, -1, bb.readInt32(bb.position()) + bb.position());
}
+ static getNamedTable(
+ bb: ByteBuffer, schema: reflection.Schema, type: string,
+ offset: number): Table {
+ for (let ii = 0; ii < schema.objectsLength(); ++ii) {
+ if (schema.objects(ii).name() == type) {
+ return new Table(bb, ii, offset);
+ }
+ }
+ throw new Error('Unable to find type ' + type + ' in schema.');
+ }
// Reads a scalar of a given type at a given offset.
readScalar(fieldType: reflection.BaseType, offset: number) {
switch (fieldType) {