diff --git a/ISOv4Plugin/ISOv4Plugin.csproj b/ISOv4Plugin/ISOv4Plugin.csproj index 4e9fcf3..0f9c9c8 100644 --- a/ISOv4Plugin/ISOv4Plugin.csproj +++ b/ISOv4Plugin/ISOv4Plugin.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -13,7 +13,7 @@ - + diff --git a/ISOv4Plugin/Mappers/TaskMapper.cs b/ISOv4Plugin/Mappers/TaskMapper.cs index 36f89d6..8feca53 100644 --- a/ISOv4Plugin/Mappers/TaskMapper.cs +++ b/ISOv4Plugin/Mappers/TaskMapper.cs @@ -32,6 +32,7 @@ public class TaskMapper : BaseMapper, ITaskMapper { private Dictionary _rxIDsByTask; private Dictionary _taskIDsByPrescription; + public TaskMapper(TaskDataMapper taskDataMapper) : base(taskDataMapper, "TSK") { _rxIDsByTask = new Dictionary(); @@ -650,10 +651,26 @@ private LoggedData ImportLoggedData(ISOTask isoLoggedTask) loggedData.EquipmentConfigurationGroup = new EquipmentConfigurationGroup(); loggedData.EquipmentConfigurationGroup.EquipmentConfigurations = equipConfigs.ToList(); + var configsWithDevElementConfigIds = equipConfigs.Select(equipConfig => + { + return new + { + LeftElmentConfigId = DataModel.Catalog.Connectors.FirstOrDefault(c => c.Id.ReferenceId == equipConfig.Connector1Id)?.DeviceElementConfigurationId ?? 0, + RightElmentConfigId = DataModel.Catalog.Connectors.FirstOrDefault(c => c.Id.ReferenceId == equipConfig.Connector2Id)?.DeviceElementConfigurationId ?? 0, + EquipmentConfigId = equipConfig.Id.ReferenceId + }; + }).Distinct().ToList(); + //Make a reference to the IDs on the OperationData foreach (OperationData operationData in loggedData.OperationData) { - operationData.EquipmentConfigurationIds.AddRange(equipConfigs.Select(e => e.Id.ReferenceId)); + var deviceConfigIds = operationData.GetAllSections() + .Select(x => x.DeviceConfigurationId) + .ToList(); + + operationData.EquipmentConfigurationIds.AddRange(configsWithDevElementConfigIds + .Where(x => deviceConfigIds.Contains(x.LeftElmentConfigId) || deviceConfigIds.Contains(x.RightElmentConfigId)) + .Select(x => x.EquipmentConfigId)); } DataModel.Catalog.EquipmentConfigurations.AddRange(equipConfigs); diff --git a/ISOv4Plugin/Mappers/TimeLogMapper.cs b/ISOv4Plugin/Mappers/TimeLogMapper.cs index 3dc7c50..957a53d 100644 --- a/ISOv4Plugin/Mappers/TimeLogMapper.cs +++ b/ISOv4Plugin/Mappers/TimeLogMapper.cs @@ -340,8 +340,27 @@ protected IEnumerable ImportTimeLog(ISOTask loggedTask, ISOTimeLo ISOTime time = GetTimeElementFromTimeLog(isoTimeLog); //Identify unique devices represented in this TimeLog data - IEnumerable deviceElementIDs = time.DataLogValues.Where(d => !d.ProcessDataDDI.EqualsIgnoreCase("DFFF") && !d.ProcessDataDDI.EqualsIgnoreCase("DFFE")) + List deviceElementIDs = time.DataLogValues.Where(d => !d.ProcessDataDDI.EqualsIgnoreCase("DFFF") && !d.ProcessDataDDI.EqualsIgnoreCase("DFFE")) .Select(d => d.DeviceElementIdRef).Distinct().ToList(); + + //Supplement the list with any parent device elements which although don't log data in the TLG + //May require a vrProductIndex working data based on product allocations + HashSet parentsToAdd = new HashSet(); + foreach (string deviceElementID in deviceElementIDs) + { + ISODeviceElement isoDeviceElement = TaskDataMapper.DeviceElementHierarchies.GetISODeviceElementFromID(deviceElementID); + if (isoDeviceElement != null) + { + while (isoDeviceElement.Parent != null && + isoDeviceElement.Parent is ISODeviceElement parentDet) + { + parentsToAdd.Add(parentDet.DeviceElementId); + isoDeviceElement= parentDet; + } + } + } + deviceElementIDs.AddRange(parentsToAdd); + Dictionary> loggedDeviceElementsByDevice = new Dictionary>(); foreach (string deviceElementID in deviceElementIDs) {