changed the speed to be m/s in metric rather than km/h and ft/m in imperial and added the measurement type for speed/velocity to the airflow component
This commit is contained in:
parent
38ae04f40c
commit
8a53f9689a
5 changed files with 46 additions and 12 deletions
|
|
@ -54,7 +54,7 @@
|
|||
"mui-tel-input": "^7.0.0",
|
||||
"notistack": "^3.0.1",
|
||||
"openweathermap-ts": "^1.2.10",
|
||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master",
|
||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#airflow",
|
||||
"query-string": "^9.2.1",
|
||||
"react": "^18.3.1",
|
||||
"react-beautiful-dnd": "^13.1.1",
|
||||
|
|
|
|||
|
|
@ -256,5 +256,15 @@ function unitConversion(
|
|||
});
|
||||
}
|
||||
}
|
||||
if (type === quack.MeasurementType.MEASUREMENT_TYPE_SPEED) {
|
||||
if (user.settings.distanceUnit === pond.DistanceUnit.DISTANCE_UNIT_FEET) {
|
||||
newVals.forEach((val, i) => {
|
||||
val.values.forEach((v, j) => {
|
||||
//convert m/s to ft/m by multiplying by 196.9
|
||||
newVals[i].values[j] = v * 196.9
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return newVals;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ export interface ComponentTypeExtension {
|
|||
interactionResultTypes: Array<quack.InteractionResultType>;
|
||||
states: Array<string>;
|
||||
measurements: Array<ComponentMeasurement>;
|
||||
measurementSummary: Function; //Deprecated: this summary used the old measurement structure
|
||||
measurementSummary?: Function; //Deprecated: this summary used the old measurement structure
|
||||
unitMeasurementSummary: (
|
||||
measurements: convertedUnitMeasurement,
|
||||
excludedNodes?: number[]
|
||||
|
|
@ -382,7 +382,8 @@ export async function getMeasurementSummary(
|
|||
measurement: quack.IMeasurement,
|
||||
filters: GraphFilters
|
||||
): Promise<Array<Summary>> {
|
||||
return extension(type, subtype).measurementSummary(measurement, filters);
|
||||
let sumFunc = extension(type, subtype).measurementSummary
|
||||
return sumFunc ? sumFunc(measurement, filters) : [];
|
||||
}
|
||||
|
||||
const validNodes = (nodeVals: number[], filters?: GraphFilters) => {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
import {
|
||||
ComponentTypeExtension,
|
||||
Summary,
|
||||
simpleMeasurements,
|
||||
simpleSummaries,
|
||||
// simpleMeasurements,
|
||||
// simpleSummaries,
|
||||
unitMeasurementSummaries,
|
||||
AreaChartData,
|
||||
GraphFilters,
|
||||
simpleAreaChartData,
|
||||
LineChartData,
|
||||
simpleLineChartData
|
||||
simpleLineChartData,
|
||||
ComponentMeasurement
|
||||
} from "pbHelpers/ComponentType";
|
||||
import PressureDarkIcon from "assets/components/pressureDark.png";
|
||||
import PressureLightIcon from "assets/components/pressureLight.png";
|
||||
|
|
@ -18,11 +19,32 @@ import { convertedUnitMeasurement } from "models/UnitMeasurement";
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
|
||||
export function Airflow(subtype: number = 0): ComponentTypeExtension {
|
||||
let airflow = describeMeasurement(
|
||||
let cfm = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_CFM,
|
||||
quack.ComponentType.COMPONENT_TYPE_AIRFLOW,
|
||||
subtype
|
||||
);
|
||||
|
||||
let velocity = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_CFM,
|
||||
quack.ComponentType.COMPONENT_TYPE_AIRFLOW,
|
||||
subtype
|
||||
);
|
||||
|
||||
let measurementTypes = [
|
||||
{
|
||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PPM,
|
||||
label: cfm.label(),
|
||||
colour: cfm.colour(),
|
||||
graphType: cfm.graph()
|
||||
} as ComponentMeasurement,
|
||||
{
|
||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_VOLTAGE,
|
||||
label: velocity.label(),
|
||||
colour: velocity.colour(),
|
||||
graphType: velocity.graph()
|
||||
} as ComponentMeasurement
|
||||
];
|
||||
return {
|
||||
type: quack.ComponentType.COMPONENT_TYPE_AIRFLOW,
|
||||
subtypes: [
|
||||
|
|
@ -47,10 +69,10 @@ export function Airflow(subtype: number = 0): ComponentTypeExtension {
|
|||
addressTypes: [quack.AddressType.ADDRESS_TYPE_I2C],
|
||||
interactionResultTypes: [],
|
||||
states: [],
|
||||
measurements: simpleMeasurements(airflow),
|
||||
measurementSummary: async function(measurement: quack.Measurement): Promise<Array<Summary>> {
|
||||
return simpleSummaries(measurement, airflow);
|
||||
},
|
||||
measurements: measurementTypes,
|
||||
// measurementSummary: async function(measurement: quack.Measurement): Promise<Array<Summary>> {
|
||||
// return simpleSummaries(measurement, airflow);
|
||||
// },
|
||||
unitMeasurementSummary: (
|
||||
measurements: convertedUnitMeasurement,
|
||||
excludedNodes?: number[]
|
||||
|
|
|
|||
|
|
@ -450,8 +450,9 @@ export class MeasurementDescriber {
|
|||
this.details.max = 100000;
|
||||
break;
|
||||
case quack.MeasurementType.MEASUREMENT_TYPE_SPEED:
|
||||
let speedUnit = getDistanceUnit()
|
||||
this.details.label = "Speed";
|
||||
this.details.unit = "km/h";
|
||||
this.details.unit = speedUnit === pond.DistanceUnit.DISTANCE_UNIT_METERS ? "m/s" : "ft/m";
|
||||
this.details.colour = green["500"];
|
||||
this.details.path = "edgeTriggered.rises";
|
||||
this.details.max = 500;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue