-
Notifications
You must be signed in to change notification settings - Fork 20
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
RSDK-4058 Add PowerSensor Component #79
Conversation
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.
Looks good! Just one change, and also let's get it up to date with main
class Voltage { | ||
double volts; | ||
bool isAc; | ||
|
||
Voltage(this.volts, this.isAc); | ||
|
||
factory Voltage.fromProto(GetVoltageResponse pbResponse) { | ||
return Voltage(pbResponse.volts, pbResponse.isAc); | ||
} | ||
} | ||
|
||
class Current { | ||
double amperes; | ||
bool isAc; | ||
|
||
Current(this.amperes, this.isAc); | ||
|
||
factory Current.fromProto(GetCurrentResponse pbResponse) { | ||
return Current(pbResponse.amperes, pbResponse.isAc); | ||
} | ||
} |
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.
Instead of creating these types which are identical to the response type (but with better names), you can just create typedef
s that should do the same thing:
typedef Voltage = GetVoltageResponse;
typedef Current = GetCurrentResponse;
You will have to change a bit of the code, but this way you don't have to create brand new classes
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.
Nice!
scope: https://docs.google.com/document/d/1HjShXMyD6HQkZkAo0bvDe61STdxxfyBrVnbRC6nSlM0/edit