-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: AutoEmptyDockAutoEmptyIntervalControlCapability
- Loading branch information
Showing
22 changed files
with
513 additions
and
65 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
backend/lib/core/capabilities/AutoEmptyDockAutoEmptyIntervalControlCapability.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,64 @@ | ||
const Capability = require("./Capability"); | ||
const NotImplementedError = require("../NotImplementedError"); | ||
|
||
/** | ||
* @template {import("../ValetudoRobot")} T | ||
* @extends Capability<T> | ||
*/ | ||
class AutoEmptyDockAutoEmptyIntervalControlCapability extends Capability { | ||
/** | ||
* | ||
* @param {object} options | ||
* @param {T} options.robot | ||
* @class | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
} | ||
|
||
/** | ||
* @returns {Promise<AutoEmptyDockAutoEmptyIntervalControlCapabilityInterval>} | ||
*/ | ||
async getInterval() { | ||
throw new NotImplementedError(); | ||
} | ||
|
||
/** | ||
* | ||
* @param {AutoEmptyDockAutoEmptyIntervalControlCapabilityInterval} newMode | ||
* @returns {Promise<void>} | ||
*/ | ||
async setInterval(newMode) { | ||
throw new NotImplementedError(); | ||
} | ||
|
||
/** | ||
* @returns {{supportedIntervals: Array<AutoEmptyDockAutoEmptyIntervalControlCapabilityInterval>}} | ||
*/ | ||
getProperties() { | ||
return { | ||
supportedIntervals: [] | ||
}; | ||
} | ||
|
||
getType() { | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.TYPE; | ||
} | ||
} | ||
|
||
AutoEmptyDockAutoEmptyIntervalControlCapability.TYPE = "AutoEmptyDockAutoEmptyIntervalControlCapability"; | ||
|
||
/** | ||
* @typedef {string} AutoEmptyDockAutoEmptyIntervalControlCapabilityInterval | ||
* @enum {string} | ||
* | ||
*/ | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL = Object.freeze({ | ||
INFREQUENT: "infrequent", | ||
NORMAL: "normal", | ||
FREQUENT: "frequent", | ||
}); | ||
|
||
|
||
module.exports = AutoEmptyDockAutoEmptyIntervalControlCapability; | ||
|
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
...lib/robots/dreame/capabilities/DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV1.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,60 @@ | ||
const AutoEmptyDockAutoEmptyIntervalControlCapability = require("../../../core/capabilities/AutoEmptyDockAutoEmptyIntervalControlCapability"); | ||
const DreameMiotHelper = require("../DreameMiotHelper"); | ||
const DreameMiotServices = require("../DreameMiotServices"); | ||
|
||
/** | ||
* @extends AutoEmptyDockAutoEmptyIntervalControlCapability<import("../DreameValetudoRobot")> | ||
*/ | ||
class DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV1 extends AutoEmptyDockAutoEmptyIntervalControlCapability { | ||
|
||
/** | ||
* @param {object} options | ||
* @param {import("../DreameValetudoRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.siid = DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.SIID; | ||
this.piid = DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.PROPERTIES.INTERVAL.PIID; | ||
|
||
this.helper = new DreameMiotHelper({robot: this.robot}); | ||
} | ||
|
||
async getInterval() { | ||
const res = await this.helper.readProperty(this.siid, this.piid); | ||
|
||
if (res === 1) { | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL; | ||
} else { | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT; | ||
} | ||
} | ||
|
||
async setInterval(newInterval) { | ||
let val; | ||
|
||
switch (newInterval) { | ||
case AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL: | ||
val = 1; | ||
break; | ||
case AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT: | ||
val = 3; | ||
break; | ||
default: | ||
throw new Error(`Received invalid interval ${newInterval}`); | ||
} | ||
|
||
await this.helper.writeProperty(this.siid, this.piid, val); | ||
} | ||
|
||
getProperties() { | ||
return { | ||
supportedIntervals: [ | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL, | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT, | ||
] | ||
}; | ||
} | ||
} | ||
|
||
module.exports = DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV1; |
69 changes: 69 additions & 0 deletions
69
...lib/robots/dreame/capabilities/DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV2.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,69 @@ | ||
const AutoEmptyDockAutoEmptyIntervalControlCapability = require("../../../core/capabilities/AutoEmptyDockAutoEmptyIntervalControlCapability"); | ||
const DreameMiotHelper = require("../DreameMiotHelper"); | ||
const DreameMiotServices = require("../DreameMiotServices"); | ||
|
||
/** | ||
* @extends AutoEmptyDockAutoEmptyIntervalControlCapability<import("../DreameValetudoRobot")> | ||
*/ | ||
class DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV2 extends AutoEmptyDockAutoEmptyIntervalControlCapability { | ||
|
||
/** | ||
* @param {object} options | ||
* @param {import("../DreameValetudoRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.siid = DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.SIID; | ||
this.piid = DreameMiotServices["GEN2"].AUTO_EMPTY_DOCK.PROPERTIES.AUTO_EMPTY_ENABLED.PIID; | ||
|
||
this.helper = new DreameMiotHelper({robot: this.robot}); | ||
} | ||
|
||
async getInterval() { | ||
const res = await this.helper.readProperty(this.siid, this.piid); | ||
|
||
switch (res) { | ||
case 3: | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT; | ||
case 2: | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.FREQUENT; | ||
|
||
case 1: | ||
default: | ||
return AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL; | ||
} | ||
} | ||
|
||
async setInterval(newInterval) { | ||
let val; | ||
|
||
switch (newInterval) { | ||
case AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL: | ||
val = 1; | ||
break; | ||
case AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.FREQUENT: | ||
val = 2; | ||
break; | ||
case AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT: | ||
val = 3; | ||
break; | ||
default: | ||
throw new Error(`Received invalid interval ${newInterval}`); | ||
} | ||
|
||
await this.helper.writeProperty(this.siid, this.piid, val); | ||
} | ||
|
||
getProperties() { | ||
return { | ||
supportedIntervals: [ | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.NORMAL, | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.FREQUENT, | ||
AutoEmptyDockAutoEmptyIntervalControlCapability.INTERVAL.INFREQUENT, | ||
] | ||
}; | ||
} | ||
} | ||
|
||
module.exports = DreameAutoEmptyDockAutoEmptyIntervalControlCapabilityV2; |
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.