Skip to content

Commit

Permalink
fix up interaction with event
Browse files Browse the repository at this point in the history
  • Loading branch information
tballmsft committed Nov 4, 2023
1 parent a6d3530 commit affc6bb
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions jacs_topwriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ namespace jacs {

wr.emitStmt(Op.STMT1_WAIT_ROLE, [this.emit(wr)])

// save the event code away
const roleEventCode = this.parent.lookupGlobal(
"z_role_code" + this.index
)
roleEventCode.write(
wr,
wr.emitExpr(Op.EXPR0_PKT_EV_CODE, [])
)

if (wakeup && wakeup.convert) {
const roleGlobal = this.parent.lookupGlobal(
"z_role" + this.index
Expand All @@ -154,6 +163,12 @@ namespace jacs {
)
roleGlobalChanged.write(wr, literal(0))
this.parent.callLinked(wakeup.convert, [this.emit(wr)])

// TODO: on a loud event, it might be too fast
// TODO: to get value from the sensor
// const microphone =
// this.classIdentifier == ServiceClass.SoundLevel

wr.emitIf(
wr.emitExpr(Op.EXPR2_NE, [
wr.emitExpr(Op.EXPR0_RET_VAL, []),
Expand Down Expand Up @@ -1244,11 +1259,10 @@ namespace jacs {
!wakeup ||
this.hasFilterEvent(rule))
) {
this.ifEq(
wr.emitExpr(Op.EXPR0_PKT_EV_CODE, []),
code,
emitBody
const roleEventCode = this.lookupGlobal(
"z_role_code" + role.index
)
this.ifEq(roleEventCode.read(wr), code, emitBody)
} else if (wakeup && wakeup.convert) {
const roleGlobal = this.lookupGlobal(
"z_role" + role.index
Expand Down Expand Up @@ -1418,7 +1432,7 @@ namespace jacs {
function needsWakeup() {
return [
{ classId: ServiceClass.Temperature, convert: undefined },
{ classId: ServiceClass.SoundLevel, convert: undefined },
{ classId: ServiceClass.SoundLevel, convert: "sound_1_to_5" },
{ classId: ServiceClass.Accelerometer, convert: undefined },
{ classId: ServiceClass.LightLevel, convert: "light_1_to_5" },
{
Expand Down

0 comments on commit affc6bb

Please sign in to comment.