public void GivenNullGetSectionsWhenGetAllSectionsThenEmptyList() { var operationData = new OperationData { GetDeviceElementUses = null }; var result = operationData.GetAllSections(); Assert.AreEqual(0, result.Count); }
private static void AreEqual(XmlNode tlgNode, string currentPath, OperationData operationData) { var isoSpatialRecords = GetIsoSpatialRecords(tlgNode.Attributes["A"].Value, currentPath).ToList(); var adaptSpatialRecords = operationData.GetSpatialRecords().ToList(); var sections = operationData.GetAllSections(); var meters = sections.SelectMany(x => x.GetWorkingDatas()).ToList(); SpatialRecordAssert.AreEqual(isoSpatialRecords, adaptSpatialRecords, meters); }
public void GivenOperationDataWithMaxDepthThreeWhenGetAllSectionsThenAllSections() { var operationData = new OperationData { MaxDepth = 3 }; var depth0Sections = new List <DeviceElementUse> { new DeviceElementUse() }; var depth1Sections = new List <DeviceElementUse> { new DeviceElementUse() }; var depth2Sections = new List <DeviceElementUse> { new DeviceElementUse() }; var depth3Sections = new List <DeviceElementUse> { new DeviceElementUse() }; operationData.GetDeviceElementUses = depth => { if (depth == 0) { return(depth0Sections); } if (depth == 1) { return(depth1Sections); } if (depth == 2) { return(depth2Sections); } if (depth == 3) { return(depth3Sections); } return(null); }; var result = operationData.GetAllSections(); Assert.AreEqual(4, result.Count); Assert.Contains(depth0Sections.First(), result); Assert.Contains(depth1Sections.First(), result); Assert.Contains(depth2Sections.First(), result); Assert.Contains(depth3Sections.First(), result); }
private ISOTimeLog ExportTimeLog(OperationData operation, IEnumerable <SpatialRecord> spatialRecords, string dataPath) { ISOTimeLog isoTimeLog = new ISOTimeLog(); //ID string id = operation.Id.FindIsoId() ?? GenerateId(5); isoTimeLog.Filename = id; isoTimeLog.TimeLogType = 1; // TimeLogType TLG.C is a required attribute. Currently only the value "1" is defined. ExportIDs(operation.Id, id); List <DeviceElementUse> deviceElementUses = operation.GetAllSections(); List <WorkingData> workingDatas = deviceElementUses.SelectMany(x => x.GetWorkingDatas()).ToList(); ISOTime isoTime = new ISOTime(); isoTime.HasStart = true; isoTime.Type = ISOTimeType.Effective; isoTime.DataLogValues = ExportDataLogValues(workingDatas, deviceElementUses).ToList(); //Set the timelog data definition for PTN ISOPosition position = new ISOPosition(); position.HasPositionNorth = true; position.HasPositionEast = true; position.HasPositionUp = true; position.HasPositionStatus = true; position.HasPDOP = false; position.HasHDOP = false; position.HasNumberOfSatellites = false; position.HasGpsUtcTime = false; position.HasGpsUtcTime = false; isoTime.Positions.Add(position); //Write XML TaskDocumentWriter xmlWriter = new TaskDocumentWriter(); xmlWriter.WriteTimeLog(dataPath, isoTimeLog, isoTime); //Write BIN var binFilePath = Path.Combine(dataPath, isoTimeLog.Filename + ".bin"); BinaryWriter writer = new BinaryWriter(_dataLogValueOrdersByWorkingDataID); writer.Write(binFilePath, workingDatas.ToList(), spatialRecords); return(isoTimeLog); }
private static void AreEqual(OperationData operationData, List <TimeScope> timeScopes, TLG tlg, string cardPath) { var fileName = tlg.A + ".xml"; var tlgXmlHeaderFilePath = Path.Combine(cardPath, "TASKDATA", fileName); Assert.IsTrue(File.Exists(tlgXmlHeaderFilePath)); var tims = new XmlReader().ReadTlgXmlData(cardPath, fileName); TimAssert.AreEqual(timeScopes, tims); var sections = operationData.GetAllSections(); var meters = sections.SelectMany(x => x.GetWorkingDatas()).ToList(); var adaptSpatialRecords = operationData.GetSpatialRecords(); var binaryReader = new BinaryReader(); var isoSpatialRecords = binaryReader.Read(cardPath, tlg.A + ".bin", tims.First()); IsoSpatialRecordAssert.AreEqual(adaptSpatialRecords, meters, isoSpatialRecords); }
/* * Implement sections (called DeviceElementUses) are hierarchical. A section at depth 0 represents the entire width of the implement. * A greater depth indicates a more granular division of the implement. Deere's plugins interpret this as: * 0: Master level. This represents the entire implement. * 1: Meter level. This usually represents one half of the implement. * 2: Section level. This represents one controllable section of the implement. * 3: Row level. This represents a single row. * Not every level will be present in every datacard. For example, you may have Master level and Section level data but no Meter level data. */ private static List <DeviceElementUse> ProcessImplementSections(OperationData operationData, Catalog catalog) { var maxImplementSectionDepth = operationData.MaxDepth; for (int i = 0; i <= maxImplementSectionDepth; ++i) { IEnumerable <DeviceElementUse> sectionsAtThisDepth = operationData.GetDeviceElementUses.Invoke(i); foreach (var section in sectionsAtThisDepth) { //The order indicates the section's relative position on the implement. 0 is the left-most section, 1 is next to it, etc. var sectionOrder = section.Order; var equipmentConfiguration = catalog.DeviceElementConfigurations.Single(config => config.Id.ReferenceId == section.DeviceConfigurationId); var sectionConfiguration = equipmentConfiguration as SectionConfiguration; var sectionWidth = sectionConfiguration.SectionWidth; var lateralOffset = sectionConfiguration.LateralOffset; var inlineOffset = sectionConfiguration.InlineOffset; } } //If you don't care about any of this, you can get all the sections at once and ignore the hierarchy: return(operationData.GetAllSections()); }
private TLG Map(OperationData operationData, string taskDataPath, TaskDocumentWriter taskDocumentWriter) { var tlgId = operationData.Id.FindIsoId() ?? "TLG" + operationData.Id.ReferenceId; taskDocumentWriter.Ids.Add(tlgId, operationData.Id); var tlg = new TLG { A = tlgId }; var sections = operationData.GetAllSections(); var meters = sections.SelectMany(x => x.GetWorkingDatas()).ToList(); var spatialRecords = operationData.GetSpatialRecords != null?operationData.GetSpatialRecords() : null; var timHeader = _timHeaderMapper.Map(meters); _xmlReader.WriteTlgXmlData(taskDataPath, tlg.A + ".xml", timHeader); var binFilePath = Path.Combine(taskDataPath, tlg.A + ".bin"); _binaryWriter.Write(binFilePath, meters, spatialRecords); return(tlg); }