Skip to content

Commit

Permalink
Merge pull request #163 from concord-consortium/187900630-fix-sample-…
Browse files Browse the repository at this point in the history
…rate-change-display

fix: Stop sensor before restarting recording [PT-187900630]
  • Loading branch information
dougmartin authored Jul 11, 2024
2 parents d931218 + 333d8f2 commit 9c023fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/sensors/devices/gdx-sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ export class GDXSensorDevice extends Device {
time += delta;
}
};
this.gdxDevice.sensors.forEach((sensor: any) => {
if (sensor.number === selectableSensorId) {
sensor.on("value-changed", handleChange);
}
});

this.gdxDevice.start(measurementPeriod);
// need to use internal _stopMeasurements function as stop() doesn't return the promise
this.gdxDevice._stopMeasurements().then(() => {
this.gdxDevice.sensors.forEach((sensor: any) => {
if (sensor.number === selectableSensorId) {
sensor.on("value-changed", handleChange);
}
});

this.gdxDevice.start(measurementPeriod);
});

return () => {
this.gdxDevice?.sensors.forEach((sensor: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/data-table-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ export const DataTableField: React.FC<FieldProps> = props => {
const values: number[] = value || [];
const metadata = (row[TimeSeriesMetadataKey] ?? {measurementPeriod: 0});
const {measurementPeriod} = metadata;
const time = values.length * (measurementPeriod / 1000);
const graphTitle = values.length > 0 ? `${Math.round(time)} sec` : "";
const time = Math.max(0, values.length - 1) * (measurementPeriod / 1000);
const graphTitle = `${Math.round(time)} sec`;

contents =
<div className={css.sparkgraphContainer}>
Expand Down

0 comments on commit 9c023fc

Please sign in to comment.