protected virtual void CreateTestReportProtected(ITest test, IComponentCollection collection) { if (test == null) { return; } Write("This calculation has tests"); Write("=======Test results======="); object o = test[collection]; if (o == null) { Write("Succcess"); Write("========================="); return; } else { List <string> l = o.ToTestStringList(); int i = 1; foreach (string s in l) { Write(i + ".) " + s); ++i; } Write("========================="); } }
/// <summary> /// Sets consumers /// </summary> /// <param name="collection">Consumers</param> /// <returns>Lists of parameters</returns> public virtual void Set(object collection) { IComponentCollection cc = collection as IComponentCollection; IDataRuntime rt = StaticExtensionDataPerformerPortable.Factory.Create(cc, 0); Clear(); variablesStr.Clear(); /* IEnumerable<IDataConsumer> consumers = cc.GetAll<IDataConsumer>(); * foreach (IDataConsumer c in consumers) * { * c.GetMeasurements(measurements); * }*/ List <object> l = new List <object>(); cc.ForEach <IDifferentialEquationSolver>((IDifferentialEquationSolver solver) => { if (solver is IMeasurements) { if (!l.Contains(solver)) { l.Insert(0, solver); } } if (solver is IDataConsumer) { (solver as IDataConsumer).GetDependentObjects(l); } } ); foreach (object o in l) { if (o is IMeasurements) { measurements.Add(o as IMeasurements); } } foreach (IMeasurements m in measurements) { IDataRuntimeFactory s = StaticExtensionDataPerformerPortable.Factory; if (m is IDifferentialEquationSolver) { IDifferentialEquationSolver ds = m as IDifferentialEquationSolver; Add(ds); } else if (s != null) { IDifferentialEquationSolver ds = rt.GetDifferentialEquationSolver(m); if (ds != null) { Add(ds); } } if (m is INormalizable) { Add(m as INormalizable); } } measurements.SortMeasurements(); }
/// <summary> /// Posts itself /// </summary> private void Post() { IComponentCollection cc = this.GetDependentCollection(); cc.GetAll <IMeasurements>(childMeasurements); cc.GetAll <IUpdatableObject>(updatable); if (updatable.Count == 0) { update = UpdateChildren; } else { update = () => { UpdateChildren(); foreach (IUpdatableObject uo in updatable) { if (uo.Update != null) { uo.Update(); } } UpdateChildren(); }; } SetAliases(); SetMea(); Process(); }
/// <summary> /// Loads test /// </summary> /// <param name="stream">Stream</param> /// <param name="collection">Component collection</param> /// <returns>Test</returns> public static ITest Load(this Stream stream, out IComponentCollection collection) { PureDesktopPeer d = new PureDesktopPeer(); d.Load(stream, SerializationInterface.StaticExtensionSerializationInterface.Binder, true); collection = d; BinaryFormatter bf = new BinaryFormatter(); while (true) { try { object o = bf.Deserialize(stream); if (o is ITest) { return(o as TestCategory.Interfaces.ITest); } } catch (Exception ex) { ex.ShowError(10); break; } } return(null); }
/// <summary> /// Adds/Creates a component associated with the given entity id. /// </summary> public C AddComponent <C>(int eid) where C : Component, new() { IComponentCollection collection = null; componentCollectionCache.TryGetValue(typeof(C), out collection); if (collection == null) { // Assigns the component collection a filter identifier collection = new ComponentCollection <C>(caboodle, _count++); componentCollections.Add(collection); componentCollectionCache.Add(typeof(C), collection); } var c = collection.Add(eid) as C; ComponentInfo info; info.id = collection.GetId(); info.component = c; OnAdded?.Invoke(eid, info); return(c); }
public void Refresh(IComponentCollection componentCollection) { foreach (var component in componentCollection.Components) { component.Accept(this); } }
/// <summary> /// Start /// </summary> /// <param name="collection">Components</param> /// <param name="timeUnit">Time unit</param> /// <param name="isAbsoluteTime">Components</param> /// <param name="realtimeStep">Realtime step</param> /// <param name="dataConsumer">Data consumer</param> public static IRealtime StartRealtime(this IComponentCollection collection, TimeType timeUnit, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep, IDataConsumer dataConsumer, IEventLog log, string reason) { if (reason.Equals(StaticExtensionEventInterfaces.Realtime)) { if (currentRuntime != null) { throw new Exception(); } start(reason); currentRuntime = Runtime.Start(collection, timeUnit, isAbsoluteTime, realtimeStep, dataConsumer, log, reason); if (currentRuntime == null) { stop(); } } else { start(reason); return(Runtime.Start(collection, timeUnit, isAbsoluteTime, realtimeStep, dataConsumer, log, reason)); } return(currentRuntime); }
public void AddSound(string name, double start, double step, int stepCount, IComponentCollection collection) { SoundTest st = new SoundTest(collection, name, start, step, stepCount); testList.Add(st); }
/// <summary> /// Creates enumerator /// </summary> /// <param name="consumer">The consumer</param> /// <returns>The enumerator</returns> protected virtual IEnumerable <object> Create(IDataConsumer consumer) { Func <object, bool> stop = (object o) => { return(false); }; IDesktop desktop = (consumer as IAssociatedObject).GetRootDesktop(); object l = null; desktop.ForEach((BelongsToCollectionPortable b) => { if (b.Source == consumer) { object o = b.Target; if (o is LogHolder) { LogHolder llh = o as LogHolder; (llh as IAssociatedObject).Prepare(true); l = llh.Reader; } } }); if (l != null) { string reason = Event.Interfaces.StaticExtensionEventInterfaces.PureRealtimeLogAnalysis; IComponentCollection collection = consumer.CreateCollection(reason); collection.ForEach((ICalculationReason r) => { r.CalculationReason = reason; }); if (isDirectoryOriented) { return(consumer.RealtimeAnalysisEnumerableDirectory(l, stop, reason, TimeType.Second, false)); } return(consumer.RealtimeAnalysisEnumerable(l, stop, reason, TimeType.Second, false)); } return(null); }
/// <summary> /// Realtime analysis enumerable /// </summary> /// <param name="dataConsumer">Data consumer</param> /// <param name="readers">Input</param> /// <param name="stop">Stop function</param> /// <param name="reason">Reason</param> /// <param name="timeType">Time type</param> /// <param name="isAbsoluteTime">The absolute time "sign"</param> /// <returns>The enumerable</returns> public static IEnumerable <object> RealtimeAnalysisEnumerableDirectory(this IDataConsumer dataConsumer, ILogReaderCollection readers, Func <object, bool> stop, string reason, TimeType timeType, bool isAbsoluteTime) { IComponentCollection cc = dataConsumer.CreateCollection(reason); cc.ForEach((ICalculationReason re) => { re.CalculationReason = reason; }); cc.ForEach((IRealTimeStartStop ss) => { ss.Start(); }); IEnumerable <ILogReader> r = readers.Readers; foreach (ILogReader reader in r) { cc.ForEach((IRealTimeStartStop ss) => { ss.Start(); }); IEnumerable <object> en = dataConsumer.RealtimeAnalysisEnumerable(reader, stop, reason, timeType, isAbsoluteTime); object ob = null; foreach (object o in en) { ob = o; } yield return(ob); cc.ForEach((IRealTimeStartStop ss) => { ss.Stop(); }); } cc.ForEach((IRealTimeStartStop ss) => { ss.Stop(); }); }
public static IEnumerable <T> FindAll <T>(this IComponentCollection componentCollection) where T : class { var collectionAsType = componentCollection as T; if (collectionAsType != null) { yield return(collectionAsType); } foreach (var component in componentCollection.Components) { var componentAsType = component as T; if (componentAsType != null) { yield return(componentAsType); } var childCollection = component as IComponentCollection; if (childCollection != null) { foreach (var result in childCollection.FindAll <T>()) { yield return(result); } } } }
public void Refresh(IComponentCollection componentCollection) { foreach (var component in componentCollection.Components) { component.Accept(this); } }
/// <summary> /// Constructor /// </summary> /// <param name="collection">Collection</param> /// <param name="provider">Time provider</param> /// <param name="priority">Priority</param> /// <param name="reason">Reason</param> public TimeProviderBackup(IComponentCollection collection, ITimeMeasureProvider provider, int priority, string reason) { this.collection = collection; CreateMeasurements(priority, reason); runtime = StaticExtensionDataPerformerPortable.Factory.Create(collection, priority, reason); SetTimeProvider(collection, provider, dictionary); }
Dictionary <string, DataPerformer.Basic.Series> GetSeries(IComponentCollection collection) { IDataConsumer dataConsumer = collection.GetObject <IDataConsumer>(name); string[] ss = (values == null) ? series.Keys.ToArray() : values; return(dataConsumer.GetSeries(start, step, stepCount, argument, ss)); }
/// <summary> /// Copy itself to collection /// </summary> /// <param name="collection">The collection</param> /// <returns>Copy</returns> protected virtual IDataRuntime Copy(IComponentCollection collection) { if (collection == this.collection) { return(this); } return(new DataRuntime(collection, reason, priority + 1, null, realtimeStep)); }
public void AddChart(string name, double start, double step, int stepCount, string argument, string[] values, IComponentCollection collection) { SeriesWrapper.LocalChart lc = new SeriesWrapper.LocalChart(name, start, step, stepCount, argument, values); lc.Create(collection); testList.Add(lc); }
/// <summary> /// Preparation /// </summary> /// <param name="collection">Desktop</param> private void prepareAll(IComponentCollection collection) { components.Clear(); components.AddRange(collection.AllComponents); collection.ForEach <ICategoryObject>((ICategoryObject l) => { objects.Add(l); }); arrows.Clear(); collection.ForEach <ICategoryArrow>((ICategoryArrow l) => { arrows.Add(l); }); IDifferentialEquationProcessor processor = DifferentialEquationProcessor.Processor; }
/// <summary> /// Constructor /// </summary> /// <param name="collection">Collection</param> /// <param name="priority">Priority</param> /// <param name="reason">Reason</param> public TimeProviderBackup(IComponentCollection collection, int priority, string reason) { this.collection = collection; CreateMeasurements(priority, reason); runtime = StaticExtensionDataPerformerPortable.Factory.Create(collection, priority); SetTimeProvider(collection, StaticExtensionDataPerformerPortable.Factory.TimeProvider, dictionary); processor = DifferentialEquationProcessors.DifferentialEquationProcessor.Processor; processor.Set(collection); }
/// <summary> /// Constructor /// </summary> /// <param name="collection">Collection of components</param> /// <param name="name">Sound component name</param> /// <param name="start">Start time</param> /// <param name="step">Step</param> /// <param name="stepCount">Count of steps</param> internal SoundTest(IComponentCollection collection, string name, double start, double step, int stepCount) { this.name = name; this.start = start; this.step = step; this.stepCount = stepCount; soundResults = GetSounds(collection); }
/// <summary> /// Starts animation /// </summary> /// <param name="collection">Collection of components</param> /// <param name="reasons">Reasons</param> /// <param name="animationType">Type of animation</param> /// <param name="pause">Pause</param> /// <param name="timeScale">Time scale</param> /// <param name="realTime">The "real time" sign</param> /// <param name="absoluteTime">The "absolute time" sign</param> /// <returns>Animation asynchronous calculation</returns> public static IAsynchronousCalculation StartAnimation(this IComponentCollection collection, string[] reasons, Animation.Interfaces.Enums.AnimationType animationType, TimeSpan pause, double timeScale, bool realTime, bool absoluteTime) { currentCalculation = global::Animation.Interfaces.StaticExtensionAnimationInterfaces.StartAnimation (collection, reasons, animationType, pause, timeScale, realTime, absoluteTime) as IAsynchronousCalculation; return(currentCalculation); }
/// <summary> /// Crates tests /// </summary> /// <param name="collection">Collection of components</param> internal void Create(IComponentCollection collection) { Dictionary <string, DataPerformer.Basic.Series> d = GetSeries(collection); series.Clear(); foreach (string key in d.Keys) { series[key] = new LocalSeries(d[key]); } }
/// <summary> /// Calculates value of residual parameter /// </summary> /// <param name="collection">Collection of objects</param> /// <returns>Residual parameter</returns> double GetValue(IComponentCollection collection) { AliasRegression reg = collection.GetObject <AliasRegression>(name); // Regression component for (int i = 0; i < number; i++) { reg.FullIterate(); // Iteration cylce } return(reg.SquareResidual); // returns residual parameter }
private static void SetTimeProvider(IComponentCollection collection, ITimeMeasureProvider provider, IDictionary <ITimeMeasureConsumer, IMeasurement> dictionary) { IEnumerable <object> c = collection.AllComponents; foreach (object o in c) { SetTimeProvider(o, provider, dictionary); } }
/// <summary> /// Starts animation /// </summary> /// <param name="collection">Collection of components</param> /// <param name="reasons">Reasons</param> /// <param name="animationType">Type of animation</param> /// <param name="pause">Pause</param> /// <param name="timeScale">Time scale</param> /// <param name="realTime">The "real time" sign</param> /// <param name="absoluteTime">The "absolute time" sign</param> /// <returns>Animation asynchronous calculation</returns> public static object StartAnimation(IComponentCollection collection, string[] reasons, Enums.AnimationType animationType, TimeSpan pause, double timeScale, bool realTime, bool absoluteTime) { if (driver == null) { return(null); } return(driver.StartAnimation(collection, reasons, animationType, pause, timeScale, realTime, absoluteTime)); }
/// <summary> /// Prepares itself /// </summary> protected virtual void Prepare() { ClearAll(); collection = factory.CreateCollection(consumer, priority, null); prepareAll(collection); IEnumerable <object> comp = collection.AllComponents; GetMeasurements(); foreach (object o in comp) { IUpdatableObject up = o.GetLabelObject <IUpdatableObject>(); if (up == null) { continue; } if (up is IDynamical) { continue; } if (up.ShouldUpdate) { if (up.Update != null) { updatable.Add(up.Update); } } } foreach (object obj in comp) { IDynamical dyn = obj.GetLabelObject <IDynamical>(); if (dyn == null) { continue; } dynamical.Add(dyn); } collection.ForEach <IStep>((IStep s) => { steps.Add(s); }); if (updatable.Count == 0) { updateAll = UpdateMeasurements; } else { updateAll = () => { UpdateMeasurements(); foreach (Action up in updatable) { up(); } UpdateMeasurements(); }; } }
public static IComponentWithProperties FindComponentWithProperties(this IComponentCollection componentCollection, IEnumerable <int> path) { var candidate = new ComponentFindingComponentVisitor().Find(componentCollection, path); if (!(candidate is IComponentWithProperties)) { throw new KolaException("Component with properties not found"); } return(candidate as IComponentWithProperties); }
/// <summary> /// Constructor /// </summary> /// <param name="collection">Collection</param> /// <param name="provider">Time provider</param> /// <param name="processor">Differential equation processor</param> /// <param name="priority">Priority</param> /// <param name="reason">Reason</param> public TimeProviderBackup(IComponentCollection collection, ITimeMeasureProvider provider, IDifferentialEquationProcessor processor, int priority, string reason) { this.collection = collection; SetCollectionHolders(); CreateMeasurements(priority, reason); runtime = StaticExtensionDataPerformerPortable.Factory.Create(collection, priority); SetTimeProvider(collection.AllComponents, provider, dictionary); this.processor = processor; processor.Set(collection); }
/// <summary> /// Tests collection of components /// </summary> /// <param name="collection">Collection of components</param> /// <returns>Test result</returns> object ITest.this[IComponentCollection collection] { get { if (GetValue(collection) != value) // If calculated value of residual parameter is not equal // is not equal to saved value of residual parameter { return("Different regression values. Object - " + name); // Then method returns error message } return(null); // Null means absence of error } }
public IComponentCollection Get(global::System.Type c) { IComponentCollection cm = null; componentCollectionCache.TryGetValue(c, out cm); if (cm == null) { throw new NoSuchComponentException("No such component, " + c.Name, c.Name); } return(cm); }
/// <summary> /// Gets names of appropriate objects /// </summary> /// <param name="collection">Component collection</param> /// <returns>Names</returns> public static List <string> GetNames(IComponentCollection collection) { List <string> l = new List <string>(); collection.ForEach <IObjectTransformer>((IObjectTransformer t) => { if (IsAccessible(t) != null) { l.Add(t.GetName(collection)); } }); return(l); }
/// <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 } }
public void SetUp() { var components = new IComponent[] { new Atom("atom 0"), new Container("container 1", components: new[] { new Atom("atom 1.0") }), new Widget("widget 2", areas: new[] { new Area("area 1", new[] { new Atom("atom 2.0.0") }), }) }; var template = new Template(Enumerable.Empty<string>(), components); var visitor = new CollectionFindingComponentVisitor(); this.found = visitor.Find(template, new int[] { }); }
void IComponentRegistration.Register(IComponentCollection registrations) { registrations.AddFor<ILog>().ImplementedBy<Log>(); }
public AmendmentApplyingVisitor(IComponentCollection componentCollection, IComponentSpecificationLibrary specificationLibrary) { this.componentCollection = componentCollection; this.specificationLibrary = specificationLibrary; }
void IComponentRegistration.Register(IComponentCollection registrations) { registrations.AddFor<IFileSystem>().ImplementedBy<LocalFileSystem>(); }
void IComponentRegistration.Register(IComponentCollection registrations) { registrations.AddFor<IPublisher>().ImplementedBy<Publisher>(); registrations.AddFor<INuGetServer>().ImplementedBy<NuGetServer>(); registrations.AddFor<IPackageFactory>().ImplementedBy<PackageFactory>(); }