Skip to content

Commit ea5d903

Browse files
author
Stuart Rhea
authored
Merge pull request #195 from ADAPT/develop
Merge for next release
2 parents 3e6bbe0 + 6a42280 commit ea5d903

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ISOv4Plugin/Mappers/TimeLogMapper.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,11 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
366366
{
367367
OperationData operationData = new OperationData();
368368

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

@@ -479,6 +482,20 @@ private List<string> FilterDeviceElementIds(DeviceHierarchyElement deviceHierarc
479482
return elementIdsToKeep;
480483
}
481484

485+
private List<string> GetISOElementHierarchyIds(List<string> deviceElementIds)
486+
{
487+
return deviceElementIds.Aggregate(new { ids = new HashSet<string>(), TaskDataMapper.DeviceElementHierarchies }, (acc, x) =>
488+
{
489+
var isoDevElement = acc.DeviceElementHierarchies.GetISODeviceElementFromID(x);
490+
while (isoDevElement != null)
491+
{
492+
acc.ids.Add(isoDevElement.DeviceElementId);
493+
isoDevElement = isoDevElement.Parent as ISODeviceElement;
494+
}
495+
return acc;
496+
}).ids.ToList();
497+
}
498+
482499
protected virtual ISOTime GetTimeElementFromTimeLog(ISOTimeLog isoTimeLog)
483500
{
484501
return isoTimeLog.GetTimeElement(this.TaskDataPath);

0 commit comments

Comments
 (0)