Skip to content

Commit 78cf09b

Browse files
authored
Merge pull request #246 from ADAPT/develop
Changes for next release
2 parents dfd4f45 + d89121d commit 78cf09b

File tree

9 files changed

+231
-88
lines changed

9 files changed

+231
-88
lines changed

ISOv4Plugin/Mappers/AllocationStampMapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public static IEnumerable<TimeScope> ImportAllocationStamps(IEnumerable<ISOAllo
8989
public static TimeScope ImportAllocationStamp(ISOAllocationStamp isoAllocationStamp)
9090
{
9191
TimeScope adaptTimeScope = new TimeScope();
92+
adaptTimeScope.DateContext = DateContextEnum.ActualStart;
9293
adaptTimeScope.TimeStamp1 = isoAllocationStamp.Start;
9394

9495
//[Check] AllocationStamp XML element: a recording with only the Start attribute defined is allowed

ISOv4Plugin/Mappers/DeviceMapper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ public interface IDeviceMapper
3333
public class DeviceMapper : BaseMapper, IDeviceMapper
3434
{
3535
DeviceElementMapper _deviceElementMapper;
36-
private readonly IManufacturer _manufacturer;
3736

3837
public DeviceMapper(TaskDataMapper taskDataMapper) : base(taskDataMapper, "DVC")
3938
{
4039
_deviceElementMapper = new DeviceElementMapper(taskDataMapper);
41-
42-
_manufacturer = ManufacturerFactory.GetManufacturer(taskDataMapper);
4340
}
4441

4542
#region Export

ISOv4Plugin/Mappers/GuidancePatternMapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using AgGateway.ADAPT.ISOv4Plugin.ISOEnumerations;
1414
using AgGateway.ADAPT.ISOv4Plugin.ISOModels;
1515
using AgGateway.ADAPT.Representation.UnitSystem;
16-
using AgGateway.ADAPT.ISOv4Plugin.ExtensionMethods;
1716

1817
namespace AgGateway.ADAPT.ISOv4Plugin.Mappers
1918
{

ISOv4Plugin/Mappers/TaskDataMapper.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class TaskDataMapper : ITaskDataMapper
3535
public const string ExportVersion = "ExportVersion"; //Version "3" or "4"
3636
public const string SuppressTimeLogDataInterpolation = "SuppressTimeLogDataInterpolation";
3737

38-
public TaskDataMapper(string dataPath, Properties properties)
38+
public TaskDataMapper(string dataPath, Properties properties, int? taskDataVersionMajor = null)
3939
{
4040
BaseFolder = dataPath;
4141
RepresentationMapper = new RepresentationMapper();
@@ -45,16 +45,22 @@ public TaskDataMapper(string dataPath, Properties properties)
4545
InstanceIDMap = new InstanceIDMap();
4646
Errors = new List<IError>();
4747

48-
//Export version
49-
string exportVersion = Properties.GetProperty(ExportVersion);
50-
if (Int32.TryParse(exportVersion, out int version))
48+
if (taskDataVersionMajor.HasValue)
5149
{
52-
Version = version; //3 or 4
50+
Version = taskDataVersionMajor.Value;
5351
}
54-
if (version != 3 && version != 4)
52+
else
5553
{
56-
Version = 4; //Default ISO Version for the export
57-
}
54+
string exportVersion = Properties.GetProperty(ExportVersion);
55+
if (Int32.TryParse(exportVersion, out int version))
56+
{
57+
Version = version; //3 or 4
58+
}
59+
if (version != 3 && version != 4)
60+
{
61+
Version = 4; //Default ISO Version for the export
62+
}
63+
}
5864
}
5965

6066
public string BaseFolder { get; private set; }
@@ -501,8 +507,8 @@ public ApplicationDataModel.ADM.ApplicationDataModel Import(ISO11783_TaskData ta
501507
}
502508
}
503509

504-
var manufacturer = ManufacturerFactory.GetManufacturer(this);
505-
manufacturer?.PostProcessModel(AdaptDataModel, DeviceElementHierarchies);
510+
var manufacturer = ManufacturerFactory.GetManufacturer(this);
511+
manufacturer?.PostProcessModel(AdaptDataModel, DeviceElementHierarchies);
506512

507513
return AdaptDataModel;
508514
}

ISOv4Plugin/Mappers/TaskMapper.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using AgGateway.ADAPT.ISOv4Plugin.ISOModels;
1818
using AgGateway.ADAPT.ISOv4Plugin.Mappers.Factories;
1919
using AgGateway.ADAPT.ISOv4Plugin.Representation;
20+
using AgGateway.ADAPT.Representation.RepresentationSystem.ExtensionMethods;
2021

2122
namespace AgGateway.ADAPT.ISOv4Plugin.Mappers
2223
{
@@ -571,7 +572,11 @@ private LoggedData ImportLoggedData(ISOTask isoLoggedTask)
571572
if (personID.HasValue)
572573
{
573574
//Create a Role
574-
PersonRole role = new PersonRole() { PersonId = personID.Value };
575+
PersonRole role = new PersonRole()
576+
{
577+
PersonId = personID.Value,
578+
Role = new EnumeratedValue { Value = AgGateway.ADAPT.Representation.RepresentationSystem.DefinedTypeEnumerationInstanceList.dtiPersonRoleOperator.ToModelEnumMember() }
579+
};
575580

576581
//Add to Catalog
577582
DataModel.Catalog.PersonRoles.Add(role);
@@ -713,19 +718,28 @@ private Summary ImportSummary(ISOTask isoLoggedTask, LoggedData loggedData)
713718
foreach (ISOTime time in isoLoggedTask.Times.Where(t => t.HasStart && t.HasType)) //Nothing added without a Start and Type attribute
714719
{
715720
TimeScope timeScope = new TimeScope();
721+
timeScope.DateContext = DateContextEnum.ActualStart;
716722
timeScope.TimeStamp1 = time.Start;
717723
if (time.Stop != null)
718724
{
719725
timeScope.TimeStamp2 = time.Stop;
720726
}
721727

722-
if (time.Stop == null && time.Duration != null)
728+
if (time.Duration != null)
723729
{
724-
//Calculate the Stop time if missing and duration present
725-
timeScope.TimeStamp2 = timeScope.TimeStamp1.Value.AddSeconds(time.Duration.Value);
730+
timeScope.Duration = System.TimeSpan.FromSeconds(time.Duration.Value);
731+
if (time.Stop == null)
732+
{
733+
//Calculate the Stop time if missing and duration present
734+
timeScope.TimeStamp2 = timeScope.TimeStamp1.Value.AddSeconds(time.Duration.Value);
735+
}
736+
}
737+
else if (timeScope.TimeStamp1.HasValue && timeScope.TimeStamp2.HasValue)
738+
{
739+
//Calculate the Duration if missing and start/stop present
740+
timeScope.Duration = timeScope.TimeStamp2.Value - timeScope.TimeStamp1.Value;
726741
}
727742
timeScope.DateContext = time.Type == ISOEnumerations.ISOTimeType.Planned ? DateContextEnum.ProposedStart : DateContextEnum.ActualStart;
728-
timeScope.Duration = timeScope.TimeStamp2.GetValueOrDefault() - timeScope.TimeStamp1.GetValueOrDefault();
729743
summary.TimeScopes.Add(timeScope);
730744
}
731745

@@ -827,6 +841,7 @@ private StampedMeteredValues GetStampedMeteredValuesForTimes(IEnumerable<ISOTime
827841

828842
//TimeScope
829843
stampedValues.Stamp = new TimeScope();
844+
stampedValues.Stamp.DateContext = DateContextEnum.ActualStart;
830845
stampedValues.Stamp.TimeStamp1 = orderedTimes.First().Start;
831846
if (orderedTimes.Last().Stop != null)
832847
{
@@ -841,7 +856,10 @@ private StampedMeteredValues GetStampedMeteredValuesForTimes(IEnumerable<ISOTime
841856
//All types should be the same
842857
stampedValues.Stamp.DateContext = orderedTimes.First().Type == ISOEnumerations.ISOTimeType.Planned ? DateContextEnum.ProposedStart : DateContextEnum.ActualStart;
843858
//Duration will define the time from the first to the last time. Gaps will be identifiable by examining Summary.Timescopes as defined above.
844-
stampedValues.Stamp.Duration = stampedValues.Stamp.TimeStamp2.GetValueOrDefault() - stampedValues.Stamp.TimeStamp1.GetValueOrDefault();
859+
if (stampedValues.Stamp.TimeStamp1.HasValue && stampedValues.Stamp.TimeStamp2.HasValue)
860+
{
861+
stampedValues.Stamp.Duration = stampedValues.Stamp.TimeStamp2.Value - stampedValues.Stamp.TimeStamp1.Value;
862+
}
845863

846864
//Values
847865
foreach (ISODataLogValue dlv in orderedTimes.Last().DataLogValues) //The last Time contains the comprehensive Task totals

0 commit comments

Comments
 (0)