Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ISOv4Plugin/Mappers/TimeLogMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
operationData.DeviceElementUses = sectionMapper.ConvertToBaseTypes(sections.ToList());
operationData.GetDeviceElementUses = x => operationData.DeviceElementUses.Where(s => s.Depth == x).ToList();
operationData.PrescriptionId = prescriptionID;
operationData.OperationType = GetOperationType(productIDs, time, workingDatas);
var adaptDeviceModelId = TaskDataMapper.InstanceIDMap.GetADAPTID(dvc.DeviceId);
operationData.OperationType = GetOperationType(productIDs, time, workingDatas, adaptDeviceModelId);
operationData.ProductIds = productIDs;
if (!useDeferredExecution)
{
Expand Down Expand Up @@ -662,15 +663,15 @@ private void AddProductAllocationsForDeviceElement(Dictionary<string, Dictionary
}
}

private OperationTypeEnum GetOperationType(List<int> productIds, ISOTime time, List<WorkingData> workingDatas)
private OperationTypeEnum GetOperationType(List<int> productIds, ISOTime time, List<WorkingData> workingDatas, int? adaptDeviceModelId)
{
var productCategories = productIds
.Select(x => TaskDataMapper.AdaptDataModel.Catalog.Products.FirstOrDefault(y => y.Id.ReferenceId == x))
.Where(x => x != null && x.Category != CategoryEnum.Unknown)
.Select(x => x.Category)
.ToList();

var deviceOperationType = GetOperationTypeFromLoggingDevices(time);
var deviceOperationType = GetOperationTypeFromLoggingDevices(time, adaptDeviceModelId);

// Prefer product category to determine operation type where possible
switch (productCategories.FirstOrDefault())
Expand Down Expand Up @@ -718,7 +719,7 @@ private OperationTypeEnum GetOperationType(List<int> productIds, ISOTime time, L
}
}

private OperationTypeEnum GetOperationTypeFromLoggingDevices(ISOTime time)
private OperationTypeEnum GetOperationTypeFromLoggingDevices(ISOTime time, int? adaptDeviceModelId)
{
HashSet<DeviceOperationType> representedTypes = new HashSet<DeviceOperationType>();
IEnumerable<string> distinctDeviceElementIDs = time.DataLogValues.Select(d => d.DeviceElementIdRef).Distinct();
Expand All @@ -728,7 +729,7 @@ private OperationTypeEnum GetOperationTypeFromLoggingDevices(ISOTime time)
if (deviceElementID.HasValue)
{
DeviceElement deviceElement = DataModel.Catalog.DeviceElements.FirstOrDefault(d => d.Id.ReferenceId == deviceElementID.Value);
if (deviceElement != null && deviceElement.DeviceClassification != null)
if (deviceElement != null && deviceElement.DeviceClassification != null && deviceElement.DeviceModelId == adaptDeviceModelId)
{
DeviceOperationType deviceOperationType = DeviceOperationTypes.FirstOrDefault(d => d.MachineEnumerationMember.ToModelEnumMember().Value == deviceElement.DeviceClassification.Value.Value);
if (deviceOperationType != null)
Expand Down
Loading