Skip to content

Add support for dimmer curves per E1.37-1 - #1476

Merged
peternewman merged 18 commits into
OpenLightingProject:masterfrom
kecramer:add-curve
Sep 8, 2018
Merged

Add support for dimmer curves per E1.37-1#1476
peternewman merged 18 commits into
OpenLightingProject:masterfrom
kecramer:add-curve

Conversation

@kecramer

Copy link
Copy Markdown
Contributor

Tried to imitate the style and conventions of similar endpoints as best I could.

_HandleU16Response was used in the first iteration of this endpoint, but was no longer necessary when I moved the response to a struct. I left the method there as it seems like it could be useful in the future? It can easily be removed though.

@peternewman peternewman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this @kecramer ! Some comments, mostly fairly minor.

The blue sky ideal is to rewrite this whole bit to do something dynamic which will hence support all PIDs (including manufacturer ones) by generating JSON schema and a dynamic UI (although it will still need some smarts for linked PIDs like these). It also needs lots of coding, so feel free to keep hacking in quick fix copy/pastes like these where appropriate. The current web UI also unfortunately doesn't support sub-devices, which a lot of dimmers may represent themselves as.

Comment thread common/rdm/RDMAPI.cpp Outdated

/*
* Fetch the dimmer curve
* @param uid the UID to fetch the DNS domain name for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy/Paste typo

Comment thread common/rdm/RDMAPI.cpp Outdated

/*
* Fetch the dimmer curve description (name)
* @param uid the UID to fetch the DNS domain name for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again

Comment thread common/rdm/RDMAPI.cpp Outdated
}

/*
* Fetch the dimmer curve

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In theory these, and all the others already in the file should be @brief, but given we haven't enabled any of this as Doxygen for some reason, it doesn't really matter right now. But if you felt like fixing them, that would be awesome 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this only for comment blocks with @params after them, or all comment blocks preceding a function call? I can take care of them in one go here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally if it's only one line we want to tag it as brief because then Doxygen can do some magic and show it in a few more places:
https://www.stack.nl/~dimitri/doxygen/manual/commands.html#cmdbrief

It would be all Doxygen style ones, so if they've already got @param or @return or whatever in there too.

Comment thread common/rdm/RDMAPI.cpp Outdated

/*
* Set the dimmer curve
* @param uid the UID to set the DNS domain name for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again

Comment thread common/rdm/RDMAPI.cpp Outdated
* @param error a pointer to a string which it set if an error occurs
* @return true if the request is sent correctly, false otherwise
*/
bool RDMAPI::SetCurve(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Order wise, we probably want Get then Set for the same PID, so GetCurve, SetCurve, GetCurveDescription.

Comment thread olad/RDMHTTPModule.cpp Outdated
if (i <= info->curves.size()) {
ostringstream str;
str << info->curves[i - 1].second << " (" <<
info->curves[i - 1].first << ")";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you move the << on the line above to this line and align them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may want to not print the () if the description is empty; I'm not sure what we do elsewhere regarding this.

Comment thread olad/RDMHTTPModule.cpp Outdated

section.AddItem(item);
section.AddItem(new StringItem("Available Curves",
std::to_string(info->total)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you align this with the second ( above please.

Comment thread olad/RDMHTTPModule.h Outdated
unsigned int active;
unsigned int next;
unsigned int total;
std::vector<std::pair<uint32_t, std::string> > curves;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again.

Comment thread olad/RDMHTTPModule.h Outdated
static const char RESET_DEVICE_SECTION[];
static const char SENSOR_SECTION[];
static const char TILT_INVERT_SECTION[];
static const char CURVE_SECTION[];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again ordering.

Comment thread olad/RDMHTTPModule.h Outdated
static const char PROXIED_DEVICES_SECTION_NAME[];
static const char RESET_DEVICE_SECTION_NAME[];
static const char TILT_INVERT_SECTION_NAME[];
static const char CURVE_SECTION_NAME[];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again.

Comment thread olad/RDMHTTPModule.cpp Outdated

section.AddItem(item);
section.AddItem(new StringItem("Available Curves",
std::to_string(info->total)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This still needs converting to our IntToString function.

Comment thread olad/RDMHTTPModule.cpp
}

info->curves.push_back(pair<uint32_t, string>(curve, description));
info->curve_descriptions.push_back(description);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So now you've made this change, the curve parameter should now be OLA_UNUSED again!

Comment thread olad/RDMHTTPModule.cpp Outdated
for (unsigned int i = 1; i <= info->total; i++) {
if (i <= info->curves.size()) {
if (i <= info->curve_descriptions.size() &&
info->curve_descriptions[i - 1].length() > 0) {

@peternewman peternewman Aug 21, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use !.empty() for the string.

Comment thread olad/RDMHTTPModule.cpp Outdated
for (unsigned int i = 1; i <= info->total; i++) {
if (i <= info->curve_descriptions.size() &&
info->curve_descriptions[i - 1].length() > 0) {
info->curve_descriptions[i - 1].empty() == false) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can just use:
!info->curve_descriptions[i - 1].empty()

So the total bit is:

    if (i <= info->curve_descriptions.size() &&
        !info->curve_descriptions[i - 1].empty()) {

Which should be more readable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, happy to change that. I've found using == false makes it more explicit in my personal coding.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah I think we generally go for ! rather than == false in the rest of the codebase. Personally the latter makes me do a bit of a double-take.

@peternewman peternewman added this to the 0.11.0 milestone Aug 22, 2018

@peternewman peternewman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just one more minor grammar nit.

Comment thread common/rdm/RDMAPI.cpp Outdated
* @param uid the UID to fetch the dimmer curve information for
* @param sub_device the sub device to use
* @param callback the callback to invoke when this request completes
* @param error a pointer to a string which it set if an error occurs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't know if this typo exists throughout, but it should be "which IS set", can you fix it wherever necessary please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like it was present across all the functions. Changed all occurrences in RDMAPI.cpp

@peternewman peternewman assigned peternewman and unassigned nomis52 Sep 6, 2018
@peternewman
peternewman merged commit fa72097 into OpenLightingProject:master Sep 8, 2018
@peternewman peternewman mentioned this pull request Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants