/// <summary> /// Constructor /// </summary> /// <param name="consumer">Data consumer</param> /// <param name="provider">Time provider</param> /// <param name="processor">Differential equation processor</param> /// <param name="reason">Reason</param> /// <param name="priority">Priority</param> public TimeProviderBackup(IDataConsumer consumer, ITimeMeasureProvider provider, IDifferentialEquationProcessor processor, string reason, int priority) { this.consumer = consumer; collection = consumer.GetDependentCollection(priority); SetTimeProvider(collection, provider, dictionary); CreateMeasurements(priority, null); runtime = consumer.CreateRuntime(reason, priority); this.processor = processor; if (processor != null) { processor.Set(collection); // !!! added to allow buffer processing, as no IDifferentialEquationProcessoris required there } }
/// <summary> /// Adds dependent objects /// </summary> /// <param name="consumer">Data consumer</param> protected void AddDependent(IDataConsumer consumer) { if (consumer == this.consumer) { return; } DataConsumerRuntime rt = consumer.CreateRuntime(reason) as DataConsumerRuntime; List <IMeasurements> l = rt.measurements; for (int i = l.Count - 1; i >= 0; i--) { IMeasurements m = l[i]; if (!measurements.Contains(m)) { measurements.Insert(0, m); } } }
/// <summary> /// Constructor /// </summary> /// <param name="consumer">Data consumer</param> /// <param name="provider">Time provider</param> /// <param name="processor">Differential equation processor</param> /// <param name="reason">Reason</param> /// <param name="priority">Priority</param> public TimeProviderBackup(IDataConsumer consumer, ITimeMeasureProvider provider, IDifferentialEquationProcessor processor, string reason, int priority) { this.consumer = consumer; collection = consumer.GetDependentCollection(priority); SetCollectionHolders(); List <object> l = new List <object>(collection.AllComponents); if (!l.Contains(consumer)) { l.Add(consumer); } SetTimeProvider(l, provider, dictionary); CreateMeasurements(priority, null); runtime = consumer.CreateRuntime(reason, priority); if (processor != null) { this.processor = processor; processor.Set(collection); } }
/// <summary> /// Sets positions /// </summary> protected void SetPositions() { positions.Clear(); if (measures.Count < 3) { return; } measuresData.Clear(); IDataConsumer c = this; foreach (string ms in measures) { for (int i = 0; i < c.Count; i++) { IMeasurements m = c[i]; IAssociatedObject ao = m as IAssociatedObject; string on = this.GetRelativeName(ao) + "."; for (int j = 0; j < m.Count; j++) { IMeasurement mea = m[j]; string s = on + mea.Name; if (s.Equals(ms)) { measuresData.Add(mea); } } } } List <IIterator> iterators = new List <IIterator>(); c.GetIterators(iterators); foreach (IIterator it in iterators) { it.Reset(); } IDataConsumer consumer = this; IDataRuntime rt = consumer.CreateRuntime(StaticExtensionDataPerformerInterfaces.Calculation); while (true) { rt.UpdateAll(); object[] ob = new object[measuresData.Count]; for (int i = 0; i < measuresData.Count; i++) { object o = measuresData[i].Parameter(); if (o is DBNull | o == null) { goto iterate; } ob[i] = o; } IPosition position = factory.Create(ob); if (position != null) { positions.Add(position); } iterate: foreach (IIterator it in iterators) { if (!it.Next()) { goto fin; } } } fin: Parent = parent; return; }