/// <summary> /// Permet de convertir le fichier texte en un tableau de <see cref="char"/> /// <paramref name="rowFileCount"/> /// </summary> /// <returns></returns> public List <RowConfiguration> FileReader() { var nombreLigne = this.rowCount; this.configurationTable = new List <RowConfiguration>(nombreLigne - 1); using (Stream stream = new FileStream(this.filePath.FullName, FileMode.Open)) { using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { for (int row = 0; row < nombreLigne; row++) { var charArray = reader.ReadLine().ToCharArray(); var tempCharTab = new RowConfiguration(); for (int column = 0; column < charArray.Count(); column++) { if (IsValid(charArray[column]) == true) { tempCharTab.Row.Add(charArray[column]); } else { continue; } } this.configurationTable.Add(tempCharTab); } } } return(this.configurationTable); }
private static void GetPlantingData(OperationData opData, Catalog catalog) { // Get the distance meter from the Machine/Vehicle level WorkingData distanceMeter = null; IEnumerable <DeviceElementUse> machineDEUs = opData.GetDeviceElementUses(0); foreach (DeviceElementUse deu in machineDEUs) { IEnumerable <WorkingData> workingDatas = deu.GetWorkingDatas(); foreach (WorkingData meter in workingDatas) { switch (meter.Representation.Code) { case "vrDistanceTraveled": distanceMeter = meter; break; } } } // Get the row-level meters for determining status, seeding rates, and product assignment for each row IEnumerable <DeviceElementUse> rowDEUs = opData.GetDeviceElementUses(2); List <RowConfiguration> rows = new List <RowConfiguration>(); NumericWorkingData exampleRowMeter = null; foreach (DeviceElementUse deu in rowDEUs) { // Link to the catalog.DeviceElementConfigurations in order to determine the width of the row. // Row widths are always in inches SectionConfiguration rowConfig = catalog.DeviceElementConfigurations.Find(x => x.Id.ReferenceId == deu.DeviceConfigurationId) as SectionConfiguration; RowConfiguration row = new RowConfiguration() { widthIn = rowConfig.SectionWidth.Value.Value }; IEnumerable <WorkingData> workingDatas = deu.GetWorkingDatas(); foreach (WorkingData meter in workingDatas) { switch (meter.Representation.Code) { case "dtRecordingStatus": row.statusMeter = meter; break; case "vrSeedRateMassActual": case "vrSeedRateSeedsActual": row.appRateMeter = meter; exampleRowMeter = meter as NumericWorkingData; break; case "vrProductIndex": row.productIndexMeter = meter; break; } } rows.Add(row); } string rateUnits = ""; if (exampleRowMeter != null) { rateUnits = exampleRowMeter.UnitOfMeasure.Code; } // Initialize the productSummary dictionary // Each product used in the planting operation is identified in the opData.ProductIds list. Dictionary <int, ProductSummary> productSummaryByProductId = new Dictionary <int, ProductSummary>(); foreach (int productId in opData.ProductIds) { ProductSummary productSummary = new ProductSummary(); productSummary.product = catalog.Products.Find(x => x.Id.ReferenceId == productId); productSummaryByProductId[productId] = productSummary; } // Keep track of the default productId. // Single-product applications will only specify one product and will not use vrProductIndex meters int defaultProductId = opData.ProductIds[0]; // Loop through all the spatial records IEnumerable <SpatialRecord> spatialRecords = opData.GetSpatialRecords(); foreach (SpatialRecord spatialRecord in spatialRecords) { NumericRepresentationValue distance = spatialRecord.GetMeterValue(distanceMeter) as NumericRepresentationValue; double distanceFt = distance.Value.Value; // Loop through each row - we need to examine the status, product assignment, and rate of each row individually foreach (RowConfiguration row in rows) { EnumeratedValue rowStatus = spatialRecord.GetMeterValue(row.statusMeter) as EnumeratedValue; if (rowStatus.Value.Value == "Off") { // Skip inactive rows continue; } int productId = defaultProductId; if (row.productIndexMeter != null) { // Check to see which product is currently being planted by the current row unit // Only used for split planter and multi-hybrid planter NumericRepresentationValue productIndex = spatialRecord.GetMeterValue(row.productIndexMeter) as NumericRepresentationValue; if (productIndex != null) { productId = (int)productIndex.Value.Value; } } // Calculate the number of acres covered by this row unit at this point in time double acres = row.CalculateAcres(distanceFt); productSummaryByProductId[productId].totalAcres += acres; if (row.appRateMeter != null) { NumericRepresentationValue appRate = spatialRecord.GetMeterValue(row.appRateMeter) as NumericRepresentationValue; if (appRate != null) { double rate = appRate.Value.Value; // seeds/ac or lbs/ac double amount = rate * acres; // seeds or lbs productSummaryByProductId[productId].totalAmount += amount; } } } } Console.WriteLine("Planting Sumamry by Variety. Rate Units: " + rateUnits); foreach (ProductSummary productSummary in productSummaryByProductId.Values) { Console.WriteLine(productSummary.ToString()); } }
public void ConstructeurTest() { var rowConfiguration = new RowConfiguration(); rowConfiguration.Row.Should().NotBeNull(); }