mfix
This commit is contained in:
parent
4086df95b7
commit
8e4549d6d3
5 changed files with 15 additions and 9 deletions
|
|
@ -46,6 +46,7 @@ const sendTick = (phase, duration, tick, time) => {
|
|||
num_seconds_at_cps_change,
|
||||
num_seconds_since_cps_change,
|
||||
cycle,
|
||||
phase,
|
||||
});
|
||||
num_ticks_since_cps_change++;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ function safeEval(str, options = {}) {
|
|||
str = `(async ()=>${str})()`;
|
||||
}
|
||||
const body = `"use strict";return (${str})`;
|
||||
console.log(body);
|
||||
return Function(body)();
|
||||
}
|
||||
|
||||
|
|
@ -48,5 +49,6 @@ export const evaluate = async (code, transpiler) => {
|
|||
// if no transpiler is given, we expect a single instruction (!wrapExpression)
|
||||
const options = { wrapExpression: !!transpiler };
|
||||
let evaluated = await safeEval(code, options);
|
||||
console.log(evaluated);
|
||||
return { mode: 'javascript', pattern: evaluated, meta };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,18 +59,19 @@ export class NeoCyclist {
|
|||
end,
|
||||
tickdeadline,
|
||||
cycle,
|
||||
phase,
|
||||
} = payload;
|
||||
this.cps = cps;
|
||||
this.cycle = cycle;
|
||||
|
||||
setTimeReference(num_seconds_at_cps_change, num_seconds_since_cps_change, tickdeadline);
|
||||
|
||||
processHaps(begin, end, num_cycles_at_cps_change, num_seconds_at_cps_change);
|
||||
processHaps(begin, end, num_cycles_at_cps_change, num_seconds_at_cps_change, phase);
|
||||
|
||||
this.time_at_last_tick_message = this.getTime();
|
||||
};
|
||||
|
||||
const processHaps = (begin, end, num_cycles_at_cps_change, seconds_at_cps_change) => {
|
||||
const processHaps = (begin, end, num_cycles_at_cps_change, seconds_at_cps_change, phase) => {
|
||||
if (this.started === false) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -85,7 +86,8 @@ export class NeoCyclist {
|
|||
this.latency +
|
||||
this.worker_time_dif;
|
||||
const duration = hap.duration / this.cps;
|
||||
onTrigger?.(hap, 0, duration, this.cps, targetTime);
|
||||
const deadline = targetTime - phase;
|
||||
onTrigger?.(hap, deadline, duration, this.cps, targetTime);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue