Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate propulsion..state based on propulsion..revolutions #118

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions calcs/propState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const _ = require('lodash')

module.exports = function (app, plugin) {
var engines = plugin.engines

app.debug('engines: %j', engines)

return engines.map(instance => {
return {
group: 'propulsion',
optionKey: instance + 'state',
title: `${instance} propulsion state (based on revolutions)`,
derivedFrom: function () {
return [
'propulsion.' + instance + '.revolutions'
]
},
calculator: function (revol) {
tkurki marked this conversation as resolved.
Show resolved Hide resolved
const currentState =
app.getSelfPath('propulsion.' + instance + '.state.value') || 'none'

if ((revol > 0) && (currentState !== "started")) {
return [
{
path: 'propulsion.' + instance + '.state',
value: "started"
}
]
} else if ((revol == 0) && (currentState !== "stopped")) {
return [
{
path: 'propulsion.' + instance + '.state',
value: "stopped"
}
]
}
}
}
})
}
Loading