Skip to content

Commit

Permalink
Merge pull request #195 from ADAPT/develop
Browse files Browse the repository at this point in the history
Merge for next release
  • Loading branch information
Stuart Rhea authored Oct 18, 2022
2 parents 3e6bbe0 + 6a42280 commit ea5d903
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ISOv4Plugin/Mappers/TimeLogMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,11 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
{
OperationData operationData = new OperationData();

//Get ids of all device elements in a group including parent element ids
//since product allocations can be at parent elements which are not logging any data.
var elementHierarchyIds = GetISOElementHierarchyIds(deviceElementGroup);
Dictionary<string, List<ISOProductAllocation>> productAllocations = deviceProductAllocations
.Where(x => deviceElementGroup.Contains(x.Key))
.Where(x => elementHierarchyIds.Contains(x.Key))
.ToDictionary(x => x.Key, x => x.Value);
List<int> productIDs = GetDistinctProductIDs(TaskDataMapper, productAllocations);

Expand Down Expand Up @@ -479,6 +482,20 @@ private List<string> FilterDeviceElementIds(DeviceHierarchyElement deviceHierarc
return elementIdsToKeep;
}

private List<string> GetISOElementHierarchyIds(List<string> deviceElementIds)
{
return deviceElementIds.Aggregate(new { ids = new HashSet<string>(), TaskDataMapper.DeviceElementHierarchies }, (acc, x) =>
{
var isoDevElement = acc.DeviceElementHierarchies.GetISODeviceElementFromID(x);
while (isoDevElement != null)
{
acc.ids.Add(isoDevElement.DeviceElementId);
isoDevElement = isoDevElement.Parent as ISODeviceElement;
}
return acc;
}).ids.ToList();
}

protected virtual ISOTime GetTimeElementFromTimeLog(ISOTimeLog isoTimeLog)
{
return isoTimeLog.GetTimeElement(this.TaskDataPath);
Expand Down

0 comments on commit ea5d903

Please sign in to comment.