-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement the MPC use case for Monitored Units #108
base: dev
Are you sure you want to change the base?
Conversation
186302a
to
47947ab
Compare
Thanks a lot for the PR! Some first thoughts, more will surely come: Having individual public functions for each scenario is what surely is expected and needed. But using those individually will result in a notify update message for each call, which I think is not nice. I do see 2 options here:
|
Regarding initialization: how about the possibility to define the supported scenarios, and for each scenario define a configuration item where items like amount of phases, measurement type, reference to etc. needs to be set. Scenario 1 is required, all other scenarios are option/recommended. And even within the scenarios there are optional items, e.g. phase specfiic power. Also I am wondering you only added setters, but maybe it is also helpful to have getters to e.g. validate the current storage? |
e8b7796
to
7e07acf
Compare
7e07acf
to
a82f86c
Compare
Co-authored-by: Simon Thelen <[email protected]>
Implements the new approach added by enbility#115 to allow setting measurement values independently or at the same time
a82f86c
to
193fc5c
Compare
I've updated the PR with support for updating multiple measurements at the same time using the Update() function. For an example as to how to use the Update() function look at the Test_PowerPerPhase test. The mu/mpc use case is now also configurable for e.g. non-three-phase use cases by passing configuration parameters to the NewMpc function. The config types are located in usecases/mu/mpc/config.go. For an example as to how to use these configuration parameters, look at the MPC testhelper |
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.
Awesome updates, I really like the way you solve the multiple datapoint update topic!
usecases/mu/mpc/config.go
Outdated
type MonitorPowerConfig struct { | ||
ConnectedPhases ConnectedPhases // The phases that are measured | ||
|
||
ValueSourceTotal *model.MeasurementValueSourceType // The source of the values from the acPowerTotal (not optional) |
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 (not optional)
, how about writing required
or mandatory
?
model.FeatureTypeTypeMeasurement, | ||
}, | ||
}, | ||
} |
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 scenarios should only be added, if the configuration for this scenario is provided and hence the application supports it. Right now this code would always report that all scenarios are supported.
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.
Should be fixed now, though it might be nice to have tests for it as well.
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.
Yes. Test coverage still has potential to grow ;)
panic(err) | ||
} | ||
|
||
idEc1 := model.ElectricalConnectionIdType(0) |
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 will cause problems, as other use cases may use an eletrical connection in the entity, and they may not be identical.
Instead we should check if one exists with the properties defined in the spec and use that. Otherwise create one.
s.sut.AddFeatures() | ||
s.sut.AddUseCase() | ||
|
||
//s.remoteDevice, s.monitoredEntity = setupDevices(s.service, s.T()) |
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.
I would love to see such tests as in CS/LPC to be added, not just using the mocks.
This commit also adds some fixes to allow leaving unsupported config parameters to NewMPC as nil and a test for those scenarios.
6834d88
to
62108f5
Compare
I've updated the PR with fixes for the simple changes, will look over the rest when I have more time |
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.
Great improvements already, thank you!
ValueConstraints *model.MeasurementConstraintsDataType // The constraints for the frequency values (optional can be nil) | ||
} | ||
|
||
func (c *MonitorPowerConfig) SupportsPhases(phase []string) bool { |
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.
It would be great to have some tests for this method standalone as well. So line 93 is also covered.
return uc, nil | ||
} | ||
|
||
func (e *MPC) AddFeatures() { |
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 method is getting quite loooooooong. How about splitting it up into individual functions for each config?
Also I am still not sure if using panics is the right approach. Maybe AddFeatures()
signature should be changed to AddFeatures() error
overall ?
Also the code looks quite repetitive, and maybe there is a good way to shrink this down, and thus making it also easire to improve the test coverage for all error scenarios?
This adds an implementation of the MPC use case for Monitored Units.
The current implementation has 2 major restrictions so far:
I'm opening this as a Draft PR because while this UC works, it can still be improved and I'm looking for feedback and potential improvements. Some of the areas I'm explicitly looking for feedback in are: