Skip to content

Commit 34b712b

Browse files
author
Stuart Rhea
authored
Merge pull request #210 from ADAPT/develop
PR to master for latest changes
2 parents 7284620 + 16054ed commit 34b712b

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

ISOv4Plugin/ISOv4Plugin.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0</TargetFrameworks>
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="AgGatewayADAPTFramework" Version="3.0.0" />
16+
<PackageReference Include="AgGatewayADAPTFramework" Version="3.0.2" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

ISOv4Plugin/Mappers/TaskMapper.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class TaskMapper : BaseMapper, ITaskMapper
3232
{
3333
private Dictionary<string, int> _rxIDsByTask;
3434
private Dictionary<int, string> _taskIDsByPrescription;
35+
3536
public TaskMapper(TaskDataMapper taskDataMapper) : base(taskDataMapper, "TSK")
3637
{
3738
_rxIDsByTask = new Dictionary<string, int>();
@@ -650,10 +651,26 @@ private LoggedData ImportLoggedData(ISOTask isoLoggedTask)
650651
loggedData.EquipmentConfigurationGroup = new EquipmentConfigurationGroup();
651652
loggedData.EquipmentConfigurationGroup.EquipmentConfigurations = equipConfigs.ToList();
652653

654+
var configsWithDevElementConfigIds = equipConfigs.Select(equipConfig =>
655+
{
656+
return new
657+
{
658+
LeftElmentConfigId = DataModel.Catalog.Connectors.FirstOrDefault(c => c.Id.ReferenceId == equipConfig.Connector1Id)?.DeviceElementConfigurationId ?? 0,
659+
RightElmentConfigId = DataModel.Catalog.Connectors.FirstOrDefault(c => c.Id.ReferenceId == equipConfig.Connector2Id)?.DeviceElementConfigurationId ?? 0,
660+
EquipmentConfigId = equipConfig.Id.ReferenceId
661+
};
662+
}).Distinct().ToList();
663+
653664
//Make a reference to the IDs on the OperationData
654665
foreach (OperationData operationData in loggedData.OperationData)
655666
{
656-
operationData.EquipmentConfigurationIds.AddRange(equipConfigs.Select(e => e.Id.ReferenceId));
667+
var deviceConfigIds = operationData.GetAllSections()
668+
.Select(x => x.DeviceConfigurationId)
669+
.ToList();
670+
671+
operationData.EquipmentConfigurationIds.AddRange(configsWithDevElementConfigIds
672+
.Where(x => deviceConfigIds.Contains(x.LeftElmentConfigId) || deviceConfigIds.Contains(x.RightElmentConfigId))
673+
.Select(x => x.EquipmentConfigId));
657674
}
658675

659676
DataModel.Catalog.EquipmentConfigurations.AddRange(equipConfigs);

ISOv4Plugin/Mappers/TimeLogMapper.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,27 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
340340
ISOTime time = GetTimeElementFromTimeLog(isoTimeLog);
341341

342342
//Identify unique devices represented in this TimeLog data
343-
IEnumerable<string> deviceElementIDs = time.DataLogValues.Where(d => !d.ProcessDataDDI.EqualsIgnoreCase("DFFF") && !d.ProcessDataDDI.EqualsIgnoreCase("DFFE"))
343+
List<string> deviceElementIDs = time.DataLogValues.Where(d => !d.ProcessDataDDI.EqualsIgnoreCase("DFFF") && !d.ProcessDataDDI.EqualsIgnoreCase("DFFE"))
344344
.Select(d => d.DeviceElementIdRef).Distinct().ToList();
345+
346+
//Supplement the list with any parent device elements which although don't log data in the TLG
347+
//May require a vrProductIndex working data based on product allocations
348+
HashSet<string> parentsToAdd = new HashSet<string>();
349+
foreach (string deviceElementID in deviceElementIDs)
350+
{
351+
ISODeviceElement isoDeviceElement = TaskDataMapper.DeviceElementHierarchies.GetISODeviceElementFromID(deviceElementID);
352+
if (isoDeviceElement != null)
353+
{
354+
while (isoDeviceElement.Parent != null &&
355+
isoDeviceElement.Parent is ISODeviceElement parentDet)
356+
{
357+
parentsToAdd.Add(parentDet.DeviceElementId);
358+
isoDeviceElement= parentDet;
359+
}
360+
}
361+
}
362+
deviceElementIDs.AddRange(parentsToAdd);
363+
345364
Dictionary<ISODevice, HashSet<string>> loggedDeviceElementsByDevice = new Dictionary<ISODevice, HashSet<string>>();
346365
foreach (string deviceElementID in deviceElementIDs)
347366
{

0 commit comments

Comments
 (0)