-
Notifications
You must be signed in to change notification settings - Fork 32
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
Battery Time Estimation #113
Open
hoeken
wants to merge
8
commits into
SignalK:master
Choose a base branch
from
hoeken:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c9162ab
added time to empty and time to full battery calculations.
hoeken 5c5f6b6
moved everything to one file and created per-battery configs.
hoeken 05a900a
changed from var to let. removed debug.
hoeken 3adcfec
oops, Wh not kWh
hoeken 0e19bc3
not sure about the order of operations here, but it cant hurt.
hoeken dadf0c1
updated readme and added myself to contributors.
hoeken 87a3a44
no time to full when fully charged.
hoeken 007e0ae
reverted changed to package.json.
hoeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,75 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = function (app, plugin) { | ||
return plugin.batteries.map(instance => { | ||
return { | ||
group: 'electrical', | ||
optionKey: 'batteryTime' + instance, | ||
title: 'Battery ' + instance + ' Time to Full / Empty', | ||
properties: { | ||
['capacity.' + instance]: { | ||
type: 'number', | ||
title: 'Capacity of battery bank in Wh', | ||
default: 5120 | ||
}, | ||
['socHigh.' + instance]: { | ||
type: 'number', | ||
title: 'State of Charge at Full (Percentage)', | ||
default: 100 | ||
}, | ||
['socLow.' + instance]: { | ||
type: 'number', | ||
title: 'State of Charge at Empty (Percentage)', | ||
default: 20 | ||
} | ||
}, | ||
derivedFrom: function () { | ||
return [ | ||
'electrical.batteries.' + instance + '.power', | ||
'electrical.batteries.' + instance + '.capacity.stateOfCharge' | ||
] | ||
}, | ||
calculator: function (p, soc) { | ||
let capacity = parseFloat( | ||
plugin.properties.electrical['capacity.' + instance] | ||
) | ||
let socLow = | ||
parseFloat(plugin.properties.electrical['socLow.' + instance]) / 100 | ||
let socHigh = | ||
parseFloat(plugin.properties.electrical['socHigh.' + instance]) / 100 | ||
|
||
// app.debug('Capacity: ' + capacity) | ||
// app.debug('SocLow: ' + socLow) | ||
// app.debug('SocHigh: ' + socHigh) | ||
|
||
output = [] | ||
|
||
// how long til full? | ||
let time_to_full = 0 | ||
if (p > 0 && soc < 0.99) { | ||
time_to_full = Math.round(capacity * 60 * 60 * (socHigh - soc) / p) | ||
} | ||
output.push({ | ||
path: 'electrical.batteries.' + instance + '.capacity.timeToFull', | ||
value: time_to_full | ||
}) | ||
|
||
// how long til empty? | ||
let soc_remaining = soc - socLow | ||
let time_to_empty = 0 | ||
if (soc_remaining > 0 && p < 0) { | ||
p = Math.abs(p) | ||
time_to_empty = Math.round(capacity * 60 * 60 * soc_remaining / p) | ||
} | ||
output.push({ | ||
path: 'electrical.batteries.' + instance + '.capacity.timeToEmpty', | ||
value: time_to_empty | ||
}) | ||
|
||
// app.debug(output) | ||
|
||
return output | ||
} | ||
} | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specification has timeRemaining - is this it or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This thing still alive?