/// <summary> /// Gets time measure from variable /// </summary> /// <param name="variable">The variable</param> /// <returns>The time measure</returns> static public IMeasurement GetTimeMeasure(this ITimeVariable variable) { VariableMeasurement v = variable.Variable; if (v == null) { return(null); } return(v.measurement); }
/// <summary> /// Sets measure time variable /// </summary> /// <param name="measure">The measure</param> /// <param name="variable">The time variable</param> static public void Set(this IMeasurement measure, ITimeVariable variable) { VariableMeasurement v = variable.Variable; if (v == null) { return; } v.measurement = measure; }
ObjectFormulaTree IDerivationOperation.Derivation(ObjectFormulaTree tree, string s) { if (derivation != null) { return(derivation); } if (!(measurement is IDerivation)) { throw new Exception("VariableMeasure.Derivation"); } IDerivation d = measurement as IDerivation; VariableMeasurement mea = new VariableMeasurement("", d.Derivation, null); derivation = new ObjectFormulaTree(mea, new List <ObjectFormulaTree>()); return(derivation); }
void IReplaceMeasurements.Replace(IMeasurements oldMeasurements, IMeasurement oldMeasure, IMeasurements newMeasurements, IMeasurement newMeasure) { if (oldMeasure == newMeasure) { return; } foreach (string key in acc.Keys) { object op = acc[key]; if (!(op is VariableMeasurement)) { continue; } VariableMeasurement vm = op as VariableMeasurement; if (vm.Measurement == oldMeasure) { if (vm == timeVariable) { timeVariable = null; } vm.Measurement = newMeasure; string s = vm.Symbol + " = "; int i = 0; for (; i < arguments.Count; i++) { string ss = arguments[i] as string; ss = ss.Substring(0, 4); if (ss.Equals(s)) { break; } } if (i < arguments.Count) { string so = arguments[i] as string; string sr = s + this.GetRelativeName(newMeasurements as IAssociatedObject); sr += "." + newMeasure.Name; replacement[sr] = so; arguments.Insert(i, sr); arguments.RemoveAt(i + 1); } } } }
/// <summary> /// The operation that performs after arrows setting /// </summary> public void PostSetArrow() { try { PostDeserialization(); isSerialized = true; DynamicalParameter parameter = new DynamicalParameter(); foreach (IMeasurements measurements in measurementsData) { string name = this.GetMeasurementsName(measurements); for (int i = 0; i < measurements.Count; i++) { IMeasurement measure = measurements[i]; string p = name + "." + measure.Name; List <string> arg = new List <string>(arguments); foreach (string s in arg) { string ss = s.Substring(4); //!!!TEMP==================== bool b = ss.Equals(p); if (!b) { if (ss.Replace("/", "_").Equals(p)) { arguments.Remove(s); arguments.Add(s.Substring(0, 4) + p); b = true; } } if (b) //!!!TEMP === { char c = s[0]; parameter.Add(c, measure); string key = c + ""; if (!acc.ContainsKey(key)) { acc[c + ""] = c.Create(measure, this); } } } } } timeVariable = null; IMeasurement timeMeasure = StaticExtensionDataPerformerPortable.Factory.TimeProvider.TimeMeasurement; foreach (string s in arguments) { if (s.Substring(4).Equals("Time")) { //timeChar = s[0]; // parameter.Add(s[0], timeMeasure); string key = s[0] + ""; if (!acc.ContainsKey(key)) { timeVariable = s[0].Create(timeMeasure, this); acc[key] = timeVariable; } } } Parameter = parameter; string argStr = AllVariables; foreach (string key in parameters.Keys) { if (!acc.ContainsKey(key)) { acc[key] = new AliasNameVariable(key, this, key); } } postSetUnary(); } catch (Exception ex) { ex.ShowError(10); if (deriOrder >= 0) { if (ex.Message.Equals("VariableMeasure.Derivation")) { --deriOrder; PostSetArrow(); return; } } this.Throw(ex); } SetFeedback(); SetForward(); }