-
Notifications
You must be signed in to change notification settings - Fork 23
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?
Changes from all commits
d98505c
2828ede
024d8be
1192090
1cd1b6b
5f52d28
014519d
373a3f7
86e2b8c
22f7190
cd4d9df
14c29df
b3e1c56
f789ffe
12654c1
f6c0bd8
541ba0a
05a6b42
6363fd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,48 @@ func NewElectricalConnection(localEntity spineapi.EntityLocalInterface) (*Electr | |
return ec, nil | ||
} | ||
|
||
func (e *ElectricalConnection) GetOrAddIdForDescription( | ||
electricalConnectionDescription model.ElectricalConnectionDescriptionDataType, | ||
) (*model.ElectricalConnectionIdType, error) { | ||
electricalConnectionId := (*model.ElectricalConnectionIdType)(nil) | ||
highestExistingElectricalConnectionId := model.ElectricalConnectionIdType(0) | ||
|
||
descriptionData := e.featureLocal.DataCopy(model.FunctionTypeElectricalConnectionDescriptionListData).(*model.ElectricalConnectionDescriptionListDataType) | ||
|
||
if descriptionData != nil && descriptionData.ElectricalConnectionDescriptionData != nil { | ||
for _, description := range descriptionData.ElectricalConnectionDescriptionData { | ||
if description.ElectricalConnectionId != nil && | ||
description.PowerSupplyType == electricalConnectionDescription.PowerSupplyType && | ||
description.AcConnectedPhases == electricalConnectionDescription.AcConnectedPhases && | ||
description.AcRmsPeriodDuration == electricalConnectionDescription.AcRmsPeriodDuration && | ||
description.PositiveEnergyDirection == electricalConnectionDescription.PositiveEnergyDirection && | ||
description.ScopeType == electricalConnectionDescription.ScopeType && | ||
description.Label == electricalConnectionDescription.Label && | ||
description.Description == electricalConnectionDescription.Description { | ||
electricalConnectionId = description.ElectricalConnectionId | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about returning here directly? That would remove the need for the if statement in line 62 |
||
} else if description.ElectricalConnectionId != nil { | ||
if *description.ElectricalConnectionId > highestExistingElectricalConnectionId { | ||
highestExistingElectricalConnectionId = *description.ElectricalConnectionId | ||
} | ||
} | ||
} | ||
} | ||
|
||
if electricalConnectionId == nil { | ||
electricalConnectionId = util.Ptr(highestExistingElectricalConnectionId + 1) | ||
description := electricalConnectionDescription | ||
description.ElectricalConnectionId = electricalConnectionId | ||
if errType := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionDescriptionListData, &model.ElectricalConnectionDescriptionListDataType{ | ||
ElectricalConnectionDescriptionData: []model.ElectricalConnectionDescriptionDataType{description}, | ||
}, model.NewFilterTypePartial(), nil); errType != nil { | ||
return nil, errors.New("could not add description data") | ||
} | ||
} | ||
|
||
return electricalConnectionId, nil | ||
} | ||
|
||
// Add a new description data set | ||
// | ||
// NOTE: the electricalConnectionId has to be provided | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Please add comments for this function to understand its usage