Skip to content
New issue

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

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

Already on GitHub? # to your account

refactor: break conversion out into separate files and use canboatjs #8

Merged
merged 24 commits into from
Jan 30, 2018

Conversation

sbender9
Copy link
Member

No description provided.

@mairas
Copy link
Contributor

mairas commented Jan 21, 2018

Would it make sense if each individual conversion module would in their module.exports return a list of functions instead of a single function? I'd like to create conversions for every environment temperature variable. They all map to the same PGN with different tempSource values. I'd like to map the (SK path, tempSource) values to separate functions, and returning a list would make that possible.

I'm a complete newbie in JS, so it may well be I've missed something trivial here...

index.js Outdated
var conversions = load_conversions(app, plugin)
conversions = [].concat.apply([], conversions)

var types = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the conversion types are an essential concept when defining the conversions. I struggled to understand their differences by following the code only. Could you maybe add a some comments clarifying the different conversion types?

@sbender9
Copy link
Member Author

It now supports the conversion returning an error

@sbender9
Copy link
Member Author

I've also changed the type stuff and added a comment to document it.

@sbender9
Copy link
Member Author

Don’t do anything with the arrays yet. I need to change the way that’s done.

@sbender9
Copy link
Member Author

ok @mairas take a look at the battery conversion. Yours will look something like that.

@sbender9 sbender9 requested a review from tkurki January 22, 2018 01:08
index.js Outdated

onDelta - You will get all deltas via app.signalk.on('delta', ...). Please do no use this unless absolutely necessary.

bacanjs - The conversion should specify a variable called 'keys' which is an array of the Signal K paths that the convesion needs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be renamed to e.g. onValueChange? As far as I understood, baconjs refers to specific implementation, not the source concept.

Also: typo (on line 33, too).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to onValueChange or similar

@mairas
Copy link
Contributor

mairas commented Jan 23, 2018

The sub-list approach looks good to me! Thanks!

return options.BATTERY.batteries.map(battery => {
return {
keys: batteryKeys.map(key => `electrical.batteries.${battery.signalkId}.${key}`),
timeouts: batteryKeys.map(key => 60000),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all the timeouts are the same maybe a single number would do here and the calling code could handle arrays and single numbers. Pretty minor...

@sbender9 sbender9 merged commit 1550029 into master Jan 30, 2018
@sbender9 sbender9 changed the title refactor: break conversion out into separate files and use Concentrate refactor: break conversion out into separate files and use canboatjs Jan 30, 2018
@sbender9 sbender9 deleted the refactor branch February 6, 2018 04:03
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants