/// <summary> /// Nice helper function that tallies up compounds for a set of streams /// </summary> /// <param name="streams"></param> /// <returns></returns> protected virtual Dictionary <string, StreamComponent> TallyCompounds(IEnumerable <AbstractStream> streams) { Dictionary <string, StreamComponent> compounds = new Dictionary <string, StreamComponent>(5); //tally up flow rates for each compound foreach (AbstractStream stream in streams) { // TODO: Get the commented-out part working again throw new NotImplementedException(); ITableAdapter tableAdapter = null;// TableAdapterFactory.CreateTableAdapter(stream.Table); //start at index value = 1 as we're assuming that 1 is the header row, which we don't //check in this particular rule (see CheckOverallFlowRate()) for (int i = 1; i < tableAdapter.GetRowCount(); i++) { string compound = tableAdapter.GetCompoundAtRow(i); string quantity = tableAdapter.GetQuantityAtRow(i); string units = tableAdapter.GetUnitAtRow(i); if (compound != null) { if (!compounds.ContainsKey(compound)) { compounds[compound] = new StreamComponent(); compounds[compound].Name = compound; } compounds[compound].AddValue(quantity, units); } } } return(compounds); }
/// <summary> /// This is called when we want to check the tables validity. Then it calls buildFeedbackMessage so that, /// a a new EveryoneDict can be made with the new data. /// </summary> /// <param name="tables">This is a list of PropertiesWindow to be checked typically all of them</param> private void CheckChemicalStreamPropertiesWindowFeedback(IEnumerable <IPfdElement> tables) { IRule rule = new TableRule(); List <string> nonUniqueNames = new List <string>(); List <IPropertiesWindow> listOfTables = new List <IPropertiesWindow>(); foreach (IPropertiesWindow table in tables) { rule.Target = table; rule.CheckRule(); // TODO: fix (eventually) throw new NotImplementedException("Rule manager is broken"); ITableAdapter tableAdapter = null; //ITableAdapter tableAdapter = TableAdapterFactory.CreateTableAdapter(table); int i = 0; int items = tableAdapter.GetRowCount(); TableType tableType; string label, units, quantity, compound, temp; while (i < items) { tableType = tableAdapter.GetTableType(); label = tableAdapter.GetLabelAtRow(i); units = tableAdapter.GetUnitAtRow(i); quantity = tableAdapter.GetQuantityAtRow(i); compound = tableAdapter.GetCompoundAtRow(i); if (currentDifficultySetting == OptionDifficultySetting.MaterialAndEnergyBalance) { temp = tableAdapter.GetTemperature(); } else { //we dont need temp to just zero it out temp = "0"; } if (!tableDict.Keys.Contains(label)) { tableDict.Add(label, new GenericTableData(table, tableType, label, units, quantity, compound, temp)); } else { if (!nonUniqueNames.Contains(label)) { nonUniqueNames.Add(label); } listOfTables.Add(table); } i++; } foreach (ValidationResult vr in rule.ValidationResults) { if (!EveryoneDict.ContainsKey(vr.Target)) { EveryoneDict.Add(vr.Target, new List <string>()); } EveryoneDict[vr.Target].Add("[" + ruleNumber + "]\n-" + vr.Message + "\n"); ruleNumber++; } } if (nonUniqueNames.Count > 0) { ValidationResult vr = (new ValidationResult(listOfTables, ErrorMessageGenerator.GenerateMesssage(Validation.ErrorMessages.NonUniqueNames, nonUniqueNames.ToArray()))); if (!EveryoneDict.ContainsKey(vr.Target)) { EveryoneDict.Add(vr.Target, new List <string>()); } EveryoneDict[vr.Target].Add("[" + ruleNumber + "]\n-" + vr.Message + "\n"); ruleNumber++; } }