2017-12-18 13:04:17 -08:00
|
|
|
namespace pxsim {
|
2019-09-30 22:43:50 -07:00
|
|
|
export const enum GyroSensorMode {
|
2017-12-18 13:04:17 -08:00
|
|
|
None = -1,
|
|
|
|
Angle = 0,
|
|
|
|
Rate = 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
export class GyroSensorNode extends UartSensorNode {
|
|
|
|
id = NodeType.GyroSensor;
|
|
|
|
|
|
|
|
private rate: number = 0;
|
|
|
|
|
|
|
|
constructor(port: number) {
|
|
|
|
super(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
getDeviceType() {
|
|
|
|
return DAL.DEVICE_TYPE_GYRO;
|
|
|
|
}
|
|
|
|
|
|
|
|
setRate(rate: number) {
|
2019-09-30 22:43:50 -07:00
|
|
|
rate = rate | 0;
|
2017-12-18 13:04:17 -08:00
|
|
|
if (this.rate != rate) {
|
|
|
|
this.rate = rate;
|
2017-12-19 14:20:35 -08:00
|
|
|
this.setChangedState();
|
2017-12-18 13:04:17 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-01 10:11:58 -07:00
|
|
|
getRate() {
|
|
|
|
return this.rate;
|
|
|
|
}
|
|
|
|
|
2017-12-18 13:04:17 -08:00
|
|
|
getValue() {
|
2019-10-01 10:11:58 -07:00
|
|
|
return this.getRate();
|
2017-12-18 13:04:17 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|