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