-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MockRobot): Mock more capabilities
- Loading branch information
Showing
10 changed files
with
402 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
backend/lib/robots/mock/capabilities/MockCarpetSensorModeControlCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const CarpetSensorModeControlCapability = require("../../../core/capabilities/CarpetSensorModeControlCapability"); | ||
|
||
/** | ||
* @extends CarpetSensorModeControlCapability<import("../MockRobot")> | ||
*/ | ||
class MockCarpetSensorModeControlCapability extends CarpetSensorModeControlCapability { | ||
|
||
/** | ||
* @param {object} options | ||
* @param {import("../MockRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.mode = CarpetSensorModeControlCapability.MODE.LIFT; | ||
} | ||
|
||
async getMode() { | ||
return this.mode; | ||
} | ||
|
||
async setMode(newMode) { | ||
this.mode = newMode; | ||
} | ||
|
||
getProperties() { | ||
return { | ||
supportedModes: [ | ||
CarpetSensorModeControlCapability.MODE.LIFT, | ||
CarpetSensorModeControlCapability.MODE.AVOID, | ||
CarpetSensorModeControlCapability.MODE.OFF, | ||
] | ||
}; | ||
} | ||
} | ||
|
||
module.exports = MockCarpetSensorModeControlCapability; |
36 changes: 36 additions & 0 deletions
36
backend/lib/robots/mock/capabilities/MockCollisionAvoidantNavigationControlCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const CollisionAvoidantNavigationControlCapability = require("../../../core/capabilities/CollisionAvoidantNavigationControlCapability"); | ||
|
||
/** | ||
* @extends PetObstacleAvoidanceControlCapability<import("../MockRobot")> | ||
*/ | ||
class MockCollisionAvoidantNavigationControlCapability extends CollisionAvoidantNavigationControlCapability { | ||
/** | ||
* @param {object} options | ||
* @param {import("../MockRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.enabled = true; | ||
} | ||
|
||
async isEnabled() { | ||
return this.enabled; | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async enable() { | ||
this.enabled = true; | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async disable() { | ||
this.enabled = false; | ||
} | ||
} | ||
|
||
module.exports = MockCollisionAvoidantNavigationControlCapability; |
27 changes: 27 additions & 0 deletions
27
backend/lib/robots/mock/capabilities/MockMopDockCleanManualTriggerCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const entities = require("../../../entities"); | ||
const MopDockCleanManualTriggerCapability = require("../../../core/capabilities/MopDockCleanManualTriggerCapability"); | ||
|
||
/** | ||
* @extends MopDockCleanManualTriggerCapability<import("../MockRobot")> | ||
*/ | ||
class MockMopDockCleanManualTriggerCapability extends MopDockCleanManualTriggerCapability { | ||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async startCleaning() { | ||
this.robot.state.upsertFirstMatchingAttribute(new entities.state.attributes.DockStatusStateAttribute({ | ||
value: entities.state.attributes.DockStatusStateAttribute.VALUE.CLEANING | ||
})); | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async stopCleaning() { | ||
this.robot.state.upsertFirstMatchingAttribute(new entities.state.attributes.DockStatusStateAttribute({ | ||
value: entities.state.attributes.DockStatusStateAttribute.VALUE.IDLE | ||
})); | ||
} | ||
} | ||
|
||
module.exports = MockMopDockCleanManualTriggerCapability; |
27 changes: 27 additions & 0 deletions
27
backend/lib/robots/mock/capabilities/MockMopDockDryManualTriggerCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const entities = require("../../../entities"); | ||
const MopDockDryManualTriggerCapability = require("../../../core/capabilities/MopDockDryManualTriggerCapability"); | ||
|
||
/** | ||
* @extends MopDockDryManualTriggerCapability<import("../MockRobot")> | ||
*/ | ||
class MockMopDockDryManualTriggerCapability extends MopDockDryManualTriggerCapability { | ||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async startDrying() { | ||
this.robot.state.upsertFirstMatchingAttribute(new entities.state.attributes.DockStatusStateAttribute({ | ||
value: entities.state.attributes.DockStatusStateAttribute.VALUE.DRYING | ||
})); | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async stopDrying() { | ||
this.robot.state.upsertFirstMatchingAttribute(new entities.state.attributes.DockStatusStateAttribute({ | ||
value: entities.state.attributes.DockStatusStateAttribute.VALUE.IDLE | ||
})); | ||
} | ||
} | ||
|
||
module.exports = MockMopDockDryManualTriggerCapability; |
50 changes: 50 additions & 0 deletions
50
backend/lib/robots/mock/capabilities/MockOperationModeControlCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const entities = require("../../../entities"); | ||
const OperationModeControlCapability = require("../../../core/capabilities/OperationModeControlCapability"); | ||
const ValetudoSelectionPreset = require("../../../entities/core/ValetudoSelectionPreset"); | ||
const stateAttrs = entities.state.attributes; | ||
|
||
/** | ||
* @extends OperationModeControlCapability<import("../MockRobot")> | ||
*/ | ||
class MockOperationModeControlCapability extends OperationModeControlCapability { | ||
/** | ||
* @param {object} options | ||
* @param {import("../MockRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
let presets = [ | ||
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.MOP, value: 0}), | ||
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM, value: 1}), | ||
new ValetudoSelectionPreset({name: entities.state.attributes.PresetSelectionStateAttribute.MODE.VACUUM_AND_MOP, value: 2}) | ||
]; | ||
super({ | ||
robot: options.robot, | ||
presets: presets | ||
}); | ||
|
||
this.StateAttr = new stateAttrs.PresetSelectionStateAttribute({ | ||
type: stateAttrs.PresetSelectionStateAttribute.TYPE.OPERATION_MODE, | ||
value: stateAttrs.PresetSelectionStateAttribute.MODE.VACUUM | ||
}); | ||
|
||
this.robot.state.upsertFirstMatchingAttribute(this.StateAttr); | ||
} | ||
|
||
/** | ||
* @param {string} preset | ||
* @returns {Promise<void>} | ||
*/ | ||
async selectPreset(preset) { | ||
const matchedPreset = this.presets.find(p => { | ||
return p.name === preset; | ||
}); | ||
|
||
if (matchedPreset) { | ||
this.StateAttr.value = matchedPreset.name; | ||
} else { | ||
throw new Error("Invalid Preset"); | ||
} | ||
} | ||
} | ||
|
||
module.exports = MockOperationModeControlCapability; |
36 changes: 36 additions & 0 deletions
36
backend/lib/robots/mock/capabilities/MockPetObstacleAvoidanceControlCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const PetObstacleAvoidanceControlCapability = require("../../../core/capabilities/PetObstacleAvoidanceControlCapability"); | ||
|
||
/** | ||
* @extends PetObstacleAvoidanceControlCapability<import("../MockRobot")> | ||
*/ | ||
class MockPetObstacleAvoidanceControlCapability extends PetObstacleAvoidanceControlCapability { | ||
/** | ||
* @param {object} options | ||
* @param {import("../MockRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.enabled = true; | ||
} | ||
|
||
async isEnabled() { | ||
return this.enabled; | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async enable() { | ||
this.enabled = true; | ||
} | ||
|
||
/** | ||
* @returns {Promise<void>} | ||
*/ | ||
async disable() { | ||
this.enabled = false; | ||
} | ||
} | ||
|
||
module.exports = MockPetObstacleAvoidanceControlCapability; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.