/// <summary> /// Loads all the consequences that are part of a compound treatment. /// </summary> /// <param name="strAttribute"></param> /// <param name="strChange"></param> public void LoadAttributeChange(String strAttribute, String strChange) { AttributeChange attributeChange = new AttributeChange(); attributeChange.Attribute = strAttribute; _attributes.Add(strAttribute); attributeChange.Change = strChange; if (strChange.Contains("COMPOUND_TREATMENT")) { _compoundTreatment = strChange; _compoundTreatment = _compoundTreatment.Replace("COMPOUND_TREATMENT(", ""); _compoundTreatment = _compoundTreatment.Replace(")", ""); CompoundTreatment compoundTreatment = Simulation.CompoundTreatments.Find(delegate(CompoundTreatment ct) { return(ct.CompoundTreatmentName == _compoundTreatment); }); if (compoundTreatment == null) { compoundTreatment = new CompoundTreatment(_compoundTreatment); Simulation.CompoundTreatments.Add(compoundTreatment); } } else { if (SimulationMessaging.AttributeMaximum.Contains(strAttribute)) { attributeChange.Maximum = SimulationMessaging.AttributeMaximum[strAttribute].ToString(); } if (SimulationMessaging.AttributeMinimum.Contains(strAttribute)) { attributeChange.Minimum = SimulationMessaging.AttributeMinimum[strAttribute].ToString(); } } AddAttributeChange(attributeChange); }
private Hashtable ApplyCommittedConsequences(Hashtable hashInput, Committed commit) { var hashOutput = new Hashtable(); var hashConsequences = new Hashtable(); var committedConsequences = CommittedConsequences[commit.ConsequenceID]; foreach (AttributeChange attributeChange in committedConsequences) { if (SimulationMessaging.AttributeMinimum.Contains(attributeChange.Attribute)) { attributeChange.Minimum = SimulationMessaging.AttributeMinimum[attributeChange.Attribute].ToString(); } if (SimulationMessaging.AttributeMaximum.Contains(attributeChange.Attribute)) { attributeChange.Maximum = SimulationMessaging.AttributeMaximum[attributeChange.Attribute].ToString(); } hashConsequences.Add(attributeChange.Attribute, attributeChange); } // Get all of this years deteriorated values. foreach (String key in hashInput.Keys) { object sValue = hashInput[key]; if (hashConsequences.Contains(key)) { AttributeChange change = (AttributeChange)hashConsequences[key]; if (change != null && CommittedEquations.ContainsKey(change.Change)) { CommittedEquation ce = CommittedEquations[change.Change]; if (!ce.HasErrors) { sValue = ce.GetConsequence(hashInput); } } else { if (change != null) { sValue = change.ApplyChange(sValue); } } } hashOutput.Add(key, sValue); } return(hashOutput); }
/// <summary> /// Add a AttributeChange to consequence. Consequences are stored for TREATMENTS so not continously SELECTed. They are not stored for COMMITTED which are individually queried, /// </summary> /// <param name="change"></param> public void AddAttributeChange(AttributeChange change) { _attributeChange.Add(change); }