-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fairly major bacon.js input/output overhaul #11
Conversation
sdk/smx.ts
Outdated
this.dontSend = this.otherReports$ | ||
.filter((e) => e.type === 'host_cmd_finished') | ||
.map((e) => e.type !== "host_cmd_finished") | ||
.toProperty(false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we can use a property to tell the output buffers to holdWhen
the property is true, but I can't quite figure out how to set the property to false
when we receive host_cmd_finished
but then set it to true
when we send a packet to stop it from sending packets until we get the host_cmd_finished
back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think we have to model it with a combination of two streams (our output and the input we see from the pad). it can watch both streams at once and emit true or false depending on which it saw most recently. I'm not totally sure how to code that with bacon yet, though
sdk/smx.ts
Outdated
const combinedOutput$ = new Bacon.Bus<Array<number>>() | ||
.merge(configOutput$) | ||
.merge(otherOutput$) | ||
.bufferingThrottle(100) | ||
.takeWhile(okSend$) | ||
.doAction(_ => this.startedSend$.push(true)) | ||
.onValue(async (value) => await this.writeToHID(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get this to work without a bufferingThrottle.
I think what happens is okSend$
is true, so it lets one thing through, it then pushes startedSend$
so okSend$
becomes false, but by the time okSend$
becomes true again from a packet finishing, combinedOutput$
has 2 events lined up in the queue, so it then tries to send them both out at the same time. I tried bufferingCount(1)
but that didn't help. Not really too sure how to get this to work how we want it quite yet. A little closer though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I think we do need some kind of buffer on it. may need to play with bacon a bit more to better understand the best pattern to use here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the docs for takeWhile
:
Takes while given predicate function holds true, and then ends.
The ends part is significant, because when a stream ends, I don't think it ever emits events again. So, either the docs are wrong on this, or something else mysterious is happening. Also, when looking at what seems to be the inverse of takeWhile
, the holdWhen
operator:
Pauses and buffers the event stream if last event in valve is truthy. All buffered events are released when valve becomes falsy.
This "all events are released" behavior seems like the undesirable behavior you were observing that we need to work around with bufferingThrottle
?
- Stage Test Value checkbox now correctly stops testing when unselected - Input visualization works, but seems laggy?
83841ae
to
c5110a5
Compare
92ce0a3
to
9f26834
Compare
- Pass in `isFsr` to test data parsing - Throttle stage panel inputs in UI for better reactivity - General cleanup
Various changes and fixes mostly regarding using Bacon.js as the event handler for USB input/output.
Changes:
sdk/index.ts
changed to just export the public APIsdk/smx.ts Bacon.js
event streams to handle input/output properlysdk/state-machines/collate-packets.ts
isFsr
to the Panel Test Data constructor so we know how to return the test data as FSRs are treated differently than LoadCells.