예제 #1
0
        public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType)
        {
            bool isPlot = mbObserverType == typeof(MyTimePlotObserver);

            if (isPlot && !(memoryBlock is MyMemoryBlock <float>))
            {
                MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks");
                return;
            }

            try
            {
                MyAbstractObserver observer;

                if (isPlot)
                {
                    MyTimePlotObserver plotObserver = new MyTimePlotObserver();
                    plotObserver.Target = (MyMemoryBlock <float>)memoryBlock;

                    observer = plotObserver;
                }
                else
                {
                    MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType);
                    memObserver.Target = memoryBlock;

                    observer = memObserver;
                }

                ObserverForm newView = new ObserverForm(this, observer, declaredOwner);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
예제 #2
0
        public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType)
        {
            bool isPlot = mbObserverType == typeof(MyTimePlotObserver) || mbObserverType == typeof(TimePlotObserver);

            if (isPlot && !(memoryBlock is MyMemoryBlock<float>))
            {
                MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks");
                return;
            }

            try
            {
                MyAbstractObserver observer = null;

                if (isPlot)
                {
                    if (mbObserverType == typeof(MyTimePlotObserver))
                    {
                        observer = new MyTimePlotObserver { Target = (MyMemoryBlock<float>)memoryBlock };
                    }
                    else if (mbObserverType == typeof(TimePlotObserver))
                    {
                        observer = new TimePlotObserver { Target = (MyMemoryBlock<float>)memoryBlock };
                    }
                }
                else
                {
                    MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType);
                    memObserver.Target = memoryBlock;

                    observer = memObserver;
                }

                if (observer == null)
                    throw new InvalidOperationException("No observer was initialized");

                ObserverForm newView = new ObserverForm(this, observer, declaredOwner);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);

                ProjectStateChanged("Memory block observer added");
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
예제 #3
0
        public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType)
        {
            bool isPlot = mbObserverType == typeof(MyTimePlotObserver);

            if (isPlot && !(memoryBlock is MyMemoryBlock<float>))
            {
                MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks");
                return;
            }

            try
            {
                MyAbstractObserver observer;

                if (isPlot)
                {
                    MyTimePlotObserver plotObserver = new MyTimePlotObserver();
                    plotObserver.Target = (MyMemoryBlock<float>)memoryBlock;

                    observer = plotObserver;
                }
                else
                {
                    MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType);
                    memObserver.Target = memoryBlock;

                    observer = memObserver;
                }

                ObserverForm newView = new ObserverForm(this, observer, declaredOwner);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }