Skip to content

Commit

Permalink
Merge pull request #210 from ADAPT/develop
Browse files Browse the repository at this point in the history
PR to master for latest changes
  • Loading branch information
Stuart Rhea authored Jul 20, 2023
2 parents 7284620 + 16054ed commit 34b712b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ISOv4Plugin/ISOv4Plugin.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand All @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AgGatewayADAPTFramework" Version="3.0.0" />
<PackageReference Include="AgGatewayADAPTFramework" Version="3.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 18 additions & 1 deletion ISOv4Plugin/Mappers/TaskMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class TaskMapper : BaseMapper, ITaskMapper
{
private Dictionary<string, int> _rxIDsByTask;
private Dictionary<int, string> _taskIDsByPrescription;

public TaskMapper(TaskDataMapper taskDataMapper) : base(taskDataMapper, "TSK")
{
_rxIDsByTask = new Dictionary<string, int>();
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 20 additions & 1 deletion ISOv4Plugin/Mappers/TimeLogMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,27 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
ISOTime time = GetTimeElementFromTimeLog(isoTimeLog);

//Identify unique devices represented in this TimeLog data
IEnumerable<string> deviceElementIDs = time.DataLogValues.Where(d => !d.ProcessDataDDI.EqualsIgnoreCase("DFFF") && !d.ProcessDataDDI.EqualsIgnoreCase("DFFE"))
List<string> 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<string> parentsToAdd = new HashSet<string>();
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<ISODevice, HashSet<string>> loggedDeviceElementsByDevice = new Dictionary<ISODevice, HashSet<string>>();
foreach (string deviceElementID in deviceElementIDs)
{
Expand Down

0 comments on commit 34b712b

Please sign in to comment.