2020-06-10 03:51:50 +03:00
|
|
|
namespace jacdac {
|
|
|
|
export class ActuatorClient extends Client {
|
|
|
|
protected state: Buffer;
|
|
|
|
|
2021-02-10 05:59:06 +03:00
|
|
|
constructor(deviceClass: number, stateLength: number, role: string) {
|
|
|
|
super(deviceClass, role);
|
2020-06-10 03:51:50 +03:00
|
|
|
this.state = Buffer.create(stateLength);
|
|
|
|
// TODO
|
|
|
|
// this.onDriverEvent(JDDriverEvent.Connected, () => this.notifyChange());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected ensureState(length: number) {
|
|
|
|
if (length > this.state.length) {
|
|
|
|
const b = control.createBuffer(length);
|
|
|
|
b.write(0, this.state);
|
|
|
|
this.state = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected notifyChange() {
|
2020-12-03 11:44:48 +03:00
|
|
|
this.sendCommand(JDPacket.from(CMD_SET_REG | SystemReg.Value, this.state))
|
2020-06-10 03:51:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|