fixed the creation of interactions for gates to use the node at the outlet, this would be node 2 for old setups and node 1 for new ones and the interactions no longer use node diffs it just uses the raw measurement of that nodes pressure
This commit is contained in:
parent
e4fe48025e
commit
c821d6f265
1 changed files with 36 additions and 42 deletions
|
|
@ -93,13 +93,11 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
compDevice.components.forEach(comp => {
|
compDevice.components.forEach(comp => {
|
||||||
let component = Component.any(comp);
|
let component = Component.any(comp);
|
||||||
//checks the address for the LED components to get the red and green LED's
|
//checks the address for the LED components to get the red and green LED's
|
||||||
|
|
||||||
if (component.locationString() === redAddr && component.subType() === 1) {
|
if (component.locationString() === redAddr && component.subType() === 1) {
|
||||||
setRedComponent(component);
|
setRedComponent(component);
|
||||||
} else if (component.locationString() === greenAddr && component.subType() === 1) {
|
} else if (component.locationString() === greenAddr && component.subType() === 1) {
|
||||||
setGreenComponent(component);
|
setGreenComponent(component);
|
||||||
} else if (component.type() === quack.ComponentType.COMPONENT_TYPE_PRESSURE_CABLE) {
|
} else if (
|
||||||
if (
|
|
||||||
gate.preferences[component.key()] === pond.GateComponentType.GATE_COMPONENT_TYPE_PRESSURE
|
gate.preferences[component.key()] === pond.GateComponentType.GATE_COMPONENT_TYPE_PRESSURE
|
||||||
) {
|
) {
|
||||||
setPressureComponent(component);
|
setPressureComponent(component);
|
||||||
|
|
@ -111,7 +109,7 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(compDevice.device){
|
if(compDevice.device){
|
||||||
|
|
@ -129,13 +127,13 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
|
|
||||||
const createInteractions = async () => {
|
const createInteractions = async () => {
|
||||||
//the interactions to be made
|
//the interactions to be made
|
||||||
|
|
||||||
if (
|
if (
|
||||||
greenComponent !== undefined &&
|
greenComponent !== undefined &&
|
||||||
redComponent !== undefined &&
|
redComponent !== undefined &&
|
||||||
pressureComponent !== undefined
|
pressureComponent !== undefined
|
||||||
) {
|
) {
|
||||||
|
//get the number of nodes in the pressure components
|
||||||
|
let nodes = pressureComponent.numNodes()
|
||||||
let lightInteractions: pond.InteractionSettings[] = []
|
let lightInteractions: pond.InteractionSettings[] = []
|
||||||
//making variables for the parameters of the interactions
|
//making variables for the parameters of the interactions
|
||||||
const redSink = quack.ComponentID.create({
|
const redSink = quack.ComponentID.create({
|
||||||
|
|
@ -163,19 +161,18 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
source: pressureSource,
|
source: pressureSource,
|
||||||
conditions: [
|
conditions: [
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
||||||
value: -highDelta,
|
value: highDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
||||||
value: -lowDelta,
|
value: lowDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
nodeOne: 2,
|
nodeOne: nodes,
|
||||||
nodeTwo: 1,
|
subtype: nodes+1,
|
||||||
subtype: 18,
|
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_TOGGLE,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_TOGGLE,
|
||||||
|
|
@ -201,14 +198,13 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
source: pressureSource,
|
source: pressureSource,
|
||||||
conditions: [
|
conditions: [
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
||||||
value: -highDelta,
|
value: highDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
nodeOne: 2,
|
nodeOne: nodes,
|
||||||
nodeTwo: 1,
|
subtype: nodes+1,
|
||||||
subtype: 18,
|
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
||||||
|
|
@ -221,19 +217,18 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
source: pressureSource,
|
source: pressureSource,
|
||||||
conditions: [
|
conditions: [
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
||||||
value: -highDelta,
|
value: highDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
||||||
value: -lowDelta,
|
value: lowDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
nodeOne: 2,
|
nodeOne: nodes,
|
||||||
nodeTwo: 1,
|
subtype: nodes+1,
|
||||||
subtype: 18,
|
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
||||||
|
|
@ -246,19 +241,18 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
source: pressureSource,
|
source: pressureSource,
|
||||||
conditions: [
|
conditions: [
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
||||||
value: -lowDelta,
|
value: lowDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
||||||
value: -thresholdPascals,
|
value: thresholdPascals,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
nodeOne: 2,
|
nodeOne: nodes,
|
||||||
nodeTwo: 1,
|
subtype: nodes+1,
|
||||||
subtype: 18,
|
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
||||||
|
|
@ -276,7 +270,8 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
subtype: 1,
|
nodeOne: nodes,
|
||||||
|
subtype: nodes+1,
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_SET,
|
||||||
|
|
@ -291,19 +286,18 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
source: pressureSource,
|
source: pressureSource,
|
||||||
conditions: [
|
conditions: [
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
||||||
value: -highDelta,
|
value: highDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
}),
|
}),
|
||||||
pond.InteractionCondition.create({
|
pond.InteractionCondition.create({
|
||||||
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_LESS_THAN,
|
comparison: quack.RelationalOperator.RELATIONAL_OPERATOR_GREATER_THAN,
|
||||||
value: -lowDelta,
|
value: lowDelta,
|
||||||
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
measurementType: quack.MeasurementType.MEASUREMENT_TYPE_PRESSURE
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
nodeOne: 2,
|
nodeOne: nodes,
|
||||||
nodeTwo: 1,
|
subtype: nodes+1,
|
||||||
subtype: 18,
|
|
||||||
schedule: lightSchedule,
|
schedule: lightSchedule,
|
||||||
result: pond.InteractionResult.create({
|
result: pond.InteractionResult.create({
|
||||||
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_TOGGLE,
|
type: quack.InteractionResultType.INTERACTION_RESULT_TYPE_TOGGLE,
|
||||||
|
|
@ -393,7 +387,6 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
//TODO: Once we figure out how to fix the backend to handle rapid addition/removal of interactions
|
//TODO: Once we figure out how to fix the backend to handle rapid addition/removal of interactions
|
||||||
//removeCurrentInteractions();
|
|
||||||
setAdding(true);
|
setAdding(true);
|
||||||
interactionsAPI.clearInteractions(device.id(), [pressureSource]).then(resp => {
|
interactionsAPI.clearInteractions(device.id(), [pressureSource]).then(resp => {
|
||||||
createInteractions();
|
createInteractions();
|
||||||
|
|
@ -401,7 +394,8 @@ export default function GateDeviceInteraction(props: Props) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
disabled={buttonDisabled()}>
|
disabled={buttonDisabled()}
|
||||||
|
>
|
||||||
{adding ? "Adding Interaction" : "Create Interaction"}
|
{adding ? "Adding Interaction" : "Create Interaction"}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue