/// <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> /// Creates Scada from stream /// </summary> /// <param name="stream">Stream</param> /// <param name="dataConsumer">Data consumer</param> /// <param name="timeType">Time type</param> /// <param name="isAbsoluteTime">The "is absolute time" sign</param> /// <param name="realtimeStep">Realtime Step</param> /// <returns>Scada</returns> public static IScadaInterface ScadaFromBytes(this System.IO.Stream stream, string dataConsumer, TimeType timeType, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep) { IDesktop desktop = stream.DesktopFromStream(); return(desktop.ScadaFromDesktop(dataConsumer, timeType, isAbsoluteTime, realtimeStep)); }
/// <summary> /// Creates Scada from file /// </summary> /// <param name="fileName">File name</param> /// <param name="dataConsumer">Data consumer</param> /// <param name="timeType">Time type</param> /// <param name="isAbsoluteTime">The "is absolute time" sign</param> /// <param name="realtimeStep">Realtime Step</param> /// <returns>Scada</returns> public static IScadaInterface ScadaFromFile(this string fileName, string dataConsumer, TimeType timeType, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep) { IDesktop desktop = fileName.DesktopFromFile(); return(desktop.ScadaFromDesktop(dataConsumer, timeType, isAbsoluteTime, realtimeStep)); }
/// <summary> /// Creates Scada from bytes /// </summary> /// <param name="buffer">Buffer</param> /// <param name="dataConsumer">Data consumer</param> /// <param name="timeType">Time type</param> /// <param name="isAbsoluteTime">The "is absolute time" sign</param> /// <param name="realtimeStep">Realtime Step</param> /// <returns>Scada</returns> public static IScadaInterface ScadaFromBytes(this byte[] buffer, string dataConsumer, TimeType timeType, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep) { IDesktop desktop = buffer.DesktopFromBytes(); return(desktop.ScadaFromDesktop(dataConsumer, timeType, isAbsoluteTime, realtimeStep)); }
/// <summary> /// Constructor /// </summary> /// <param name="desktop">Desktop</param> /// <param name="attrType">Type attribbute</param> /// <param name="attrName">Name attribute</param> protected AbstractXmlCreateObjectFactory(IDesktop desktop, string attrType, string attrName) : base(desktop) { this.desktop = desktop; this.attrType = attrType; this.attrName = attrName; }
/// <summary> /// Checks order of desktop and throws exception if order is illegal /// </summary> /// <param name="desktop">The desktop</param> public virtual void CheckOrder(IDesktop desktop) { foreach (IUIFactory f in factories) { f.CheckOrder(desktop); } }
private void test(IDesktop desktop) { IDifferentialEquationProcessor processor = DifferentialEquationProcessor.Processor; /* IDataPerformerRuntimeFactory str = StaticDataPerformer.Factory; * if (str is IStep) * { * st = str as IStep; * } * for (int i = 0; i < steps; i++) * { * if (st != null) * { * st.Step = i; * } * if (i == 0) * { * desktop.StartAll(start); * } * desktop.UpdateAll(); * StaticDataPerformerExtension.Time = start + i * step; * * if (i > 0 & processor != null) * { * processor.Step(start + i * step - step, start + i * step); * } * StaticDataPerformerExtension.Time = start + i * step; * UpdateChildrenData(); * desktop.ResetUpdatedMeasurements(); * }*/ }
private void addObjectNode(TreeNode parent, IObjectLabel label) { if (tree == null) { return; } NamedNode node = new NamedNode(label, false); if (label is IObjectLabelUI) { IObjectLabelUI lab = label as IObjectLabelUI; lab.Node = node; } parent.Nodes.Add(node); if (!(label.Object is IObjectContainer)) { return; } IObjectContainer cont = label.Object as IObjectContainer; IDesktop desk = cont.Desktop; Dictionary <string, object> t = cont.Interface; foreach (string str in t.Keys) { INamedComponent comp = desk[str]; NamedNode n = new NamedNode(comp, false); node.Nodes.Add(n); } }
/// <summary> /// Constructor /// </summary> /// <param name="component">Linked component</param> /// <param name="fullName">The "show full" name sign</param> public NamedNode(INamedComponent component, bool fullName) { this.component = component; if (component is NamedComponent) { NamedComponent comp = component as NamedComponent; comp.AddNode(this); Text = component.Name; } else { INamedComponent nc = component; IDesktop root = component.Root.Desktop; if (fullName) { Text = component.RootName; } else { Text = component.GetName(nc.Desktop); } } ImageIndex = NamedComponent.GetImageNumber(component); SelectedImageIndex = ImageIndex; }
/// <summary> /// Saves all aliases of desktop to stream /// </summary> /// <param name="desktop">The desktop</param> /// <param name="stream">The stream</param> static public void SaveAllAliases(IDesktop desktop, Stream stream) { Dictionary <string, object> d = desktop.GetAllAliases(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, d); }
/// <summary> /// Creates Xml document /// </summary> /// <param name="desktop">Desktop</param> /// <param name="input">Input</param> /// <param name="start">Start</param> /// <param name="step">Step</param> /// <param name="count">Count of steps</param> /// <returns>Document</returns> static public XmlDocument CreateXmlDocument(this IDesktop desktop, XmlDocument input, double start, double step, int count) { string consumer = (input.GetElementsByTagName("ChartName")[0] as XmlElement).InnerText; return(desktop.CreateXmlDocument(consumer, input, start, step, count)); }
/// <summary> /// Creates Xml document /// </summary> /// <param name="desktop">Desktop</param> /// <param name="consumer">Consumer name</param> /// <param name="input">Input</param> /// <param name="start">Start</param> /// <param name="step">Step</param> /// <param name="count">Count of steps</param> /// <returns>Document</returns> static public XmlDocument CreateXmlDocument(this IDesktop desktop, string consumer, XmlDocument input, double start, double step, int count) { IDataConsumer c = desktop.GetObject(consumer) as IDataConsumer; return(c.CreateXmlDocument(input, start, step, count)); }
/// <summary> /// Checks desktop /// </summary> /// <param name="desktop">The desktop</param> /// <param name="binders">The serialization binders</param> /// <returns>List of exceptions or null if right</returns> public static List <Exception> Check(IDesktop desktop, SerializationBinder[] binders) { exceptions = new List <Exception>(); bool b = false; try { IEnumerable <IObjectLabel> objects = desktop.Objects; IEnumerable <IArrowLabel> arrows = desktop.Arrows; PureDesktopPeer d = new PureDesktopPeer(); d.Copy(objects, arrows, true); d.SetParents(); Stream stream = new MemoryStream(); d.Save(stream); PureDesktopPeer dnew = new PureDesktopPeer(); b = dnew.Load(stream); dnew.Dispose(); } catch (Exception e) { e.ShowError(10); if (exceptions != null) { exceptions.Add(e); } } List <Exception> res = b ? null : exceptions; exceptions = null; desktop.SetParents(); return(res); }
private void Load() { PureDesktopPeer d = new PureDesktopPeer(); d.Load(bytes); pattern = d; }
/// <summary> /// Sets parents of objects /// </summary> /// <param name="desktop">The desktop</param> public void SetParents(IDesktop desktop) { IEnumerable <IObjectLabel> objs = desktop.Objects; INamedComponent comp = null; foreach (IObjectLabel ol in objs) { if (ol.Object == this) { comp = ol; break; } } IEnumerable <object> objects = this.desktop.Components; foreach (INamedComponent nc in objects) { if (nc is IObjectLabel) { IObjectLabel l = nc as IObjectLabel; if (l.Object is IObjectContainer) { IObjectContainer oc = l.Object as IObjectContainer; oc.Desktop.SetParents(); } } nc.Parent = comp; } }
/// <summary> /// Gets objects and arrows of associated object /// </summary> /// <param name="ao">The associated object</param> /// <param name="objects">Objects</param> /// <param name="arrows">Arrows</param> protected virtual void GetObjects(IAssociatedObject ao, IList <ICategoryObject> objects, IList <ICategoryArrow> arrows) { if (ao is IObjectContainer) { IObjectContainer oc = ao as IObjectContainer; IDesktop d = oc.Desktop; IEnumerable <object> c = d.AllComponents; foreach (object o in c) { if (o is IObjectLabel) { IObjectLabel ol = o as IObjectLabel; GetObjects(ol.Object, objects, arrows); } if (o is IArrowLabel) { IArrowLabel al = o as IArrowLabel; GetObjects(al.Arrow, objects, arrows); } } } else { GetObjectsPrivate(ao, objects, arrows); } }
/// <summary> /// Prepares itself /// </summary> public void Prepare() { IDesktop d = this.GetRootDesktop(); this.FullReset(); UpdateChildrenData(); }
static void PostLoad(IDesktop desktop) { try { /* * using (TimeProviderBackup backup = new TimeProviderBackup(desktop, 0, null)) * { * IDataRuntime r = backup.Runtime; * r.Refresh(); * r.StartAll(0); * r.TimeProvider.Time = 0; * // r.UpdateAll(); * }*/ desktop.ForEach((IAssociatedObject ao) => { object o = ao.Object; if (o is Control) { Control c = o as Control; IPostLoadDesktop p = c.FindChildObject <IPostLoadDesktop>(); if (p != null) { p.PostLoad(); } } }); } catch (Exception exception) { exception.ShowError(10); } }
public void SetCurrentDesktop(IDesktop desktop) { lock (syncRoot) { AssertNotDisposed(); currentDesktop = desktop as DefaultDesktop; } }
public IDesktop CreateDesktop(IDesktop parent, string name) { lock (syncRoot) { AssertNotDisposed(); return(new DefaultDesktop(name, parent)); } }
/// <summary> /// Creates component collection /// </summary> /// <param name="consumer">Data consumer</param> /// <param name="list">List of objects</param> /// <param name="action">Action</param> /// <param name="priority">Priorty</param> /// <param name="reason">Reason</param> /// <returns>Component collection</returns> protected IComponentCollection CreateCollection(IDataConsumer consumer, List <object> list, Action <object> action, int priority, string reason) { CreateDataConsumerCollection(consumer, list, action, priority, reason); IDesktop desktop = (consumer as IAssociatedObject).GetDesktop(); return(new ComponentCollection(list, desktop)); }
/// <summary> /// Refreshes a desktop /// </summary> /// <param name="desktop">The desktop</param> public static void Refresh(this IDesktop desktop) { if (desktop is PureDesktopPeer) { PureDesktopPeer p = desktop as PureDesktopPeer; p.Refresh(); } }
public Task <IDesktop> GetNext(IDesktop desktop) { var index = Desktops.IndexOf(desktop); index++; index = index % Desktops.Count; return(Task.FromResult(Desktops[index])); }
public static void Process(XElement element, IDesktop desktop, out List <Arrow> absc) { List <Arrow> l = new List <Arrow>(); SystemBase sb = Create(element, desktop); sb.ProcessArrows(l); absc = l; }
/// <summary> /// Creates Scada from desktop /// </summary> /// <param name="desktop">Desktop</param> /// <param name="dataConsumer">Data consumer</param> /// <param name="timeType">Time type</param> /// <param name="isAbsoluteTime">The "is absolute time" sign</param> /// <param name="realtimeStep">Realtime Step</param> /// <returns>Scada</returns> public static IScadaInterface ScadaFromDesktop(this IDesktop desktop, string dataConsumer, TimeType timeType, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep) { if (desktop == null) { return(null); } return(scadaFactory.Create(desktop, dataConsumer, timeType, isAbsoluteTime, realtimeStep)); }
public Controller(ILayoutFactory layoutFactory, IDesktop desktop, IWindowManager windowManager, IDesktopManager desktopManager) { Desktop = desktop; WindowManager = windowManager; DesktopManager = desktopManager; LayoutFactory = layoutFactory; SetDefaultLayouts(); }
private void Reset(IDesktop desktop) { IEnumerable <ICategoryObject> co = desktop.CategoryObjects; foreach (object o in co) { Reset(o); } }
/// <summary> /// Gets all measurements of one dimension real array /// </summary> /// <param name="ao">Associated object</param> /// <returns>Names of measurements</returns> public static string[] GetOneDimensionRealArrays(this IAssociatedObject ao) { INamedComponent nc = null; if (ao is INamedComponent) { nc = ao as INamedComponent; } else { nc = ao.Object as INamedComponent; } IDesktop desktop = nc.Root.Desktop; if (desktop == null) { desktop = nc.Desktop; } if (desktop == null) { return(new string[0]); } List <string> l = new List <string>(); desktop.ForEach <IMeasurements>((IMeasurements m) => { IAssociatedObject aob = m as IAssociatedObject; INamedComponent ncm = aob.Object as INamedComponent; string nm = ncm.GetName(desktop); for (int i = 0; i < m.Count; i++) { IMeasurement mea = m[i]; if (mea == null) { continue; } object t = mea.Type; if (!(t is ArrayReturnType)) { continue; } ArrayReturnType art = t as ArrayReturnType; Double a = 0; if (!art.ElementType.Equals(a)) { continue; } if (art.Dimension.Length != 1) { continue; } l.Add(nm + "." + mea.Name); } }); return(l.ToArray()); }
/// <summary> /// Creates bytes from desktop /// </summary> /// <param name="desktop">The desktop</param> /// <returns>The bytes</returns> public static byte[] ToBytes(this IDesktop desktop) { if (desktop is PureDesktopPeer) { System.IO.MemoryStream stream = new System.IO.MemoryStream(); (desktop as PureDesktopPeer).Save(stream); return(stream.GetBuffer()); } return(null); }
public Task <IDesktop> GetById(string id) { IDesktop desktop = null; if (DesktopsByName.ContainsKey(id)) { desktop = DesktopsByName[id]; } return(Task.FromResult(desktop)); }
/// <summary> /// Gets objects from names /// </summary> /// <param name="names">Names</param> /// <param name="desktop">Desktop</param> /// <returns>Objects</returns> public static object[] GetObjects(ICollection <string> names, IDesktop desktop) { List <object> l = new List <object>(); foreach (string name in names) { l.Add(desktop.GetObject(name)); } return(l.ToArray()); }
public ActionResult CreateComplete(IDesktop newDesktop) { return View(newDesktop); }
public void SetDesktop(IDesktop desktop) { throw new NotImplementedException(); }