Пример #1
0
        public void ShowObserverView(MyAbstractObserver observer)
        {
            MyNode owner = null;

            if (observer is MyAbstractMemoryBlockObserver)
            {
                owner = (observer as MyAbstractMemoryBlockObserver).Target.Owner;
            }
            else if (observer is MyTimePlotObserver)
            {
                owner = (observer as MyTimePlotObserver).Target.Owner;
            }
            else
            {
                owner = observer.GenericTarget as MyNode;
            }

            ObserverForm newView = new ObserverForm(this, observer, owner);

            ObserverViews.Add(newView);

            newView.Show(dockPanel, DockState.Float);
            newView.FloatPane.FloatWindow.Size     = new Size((int)observer.WindowSize.Width, (int)observer.WindowSize.Height);
            newView.FloatPane.FloatWindow.Location = new Point((int)observer.WindowLocation.X, (int)observer.WindowLocation.Y);

            if (!SystemInformation.VirtualScreen.Contains(newView.FloatPane.FloatWindow.Bounds))
            {
                newView.FloatPane.FloatWindow.Location = new Point(0, 0);
            }
        }
Пример #2
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = observer.GetTargetName(declaredOwner);
        }
Пример #3
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = MyProject.ShortenNodeTypeName(observer.GetType()) + ": " + observer.GetTargetName(declaredOwner);
        }
Пример #4
0
 public void UpdateObserverView(MyAbstractObserver observer)
 {
     foreach (ObserverForm ov in ObserverViews.ToList())
     {
         if (ov.Observer == observer)
         {
             ov.UpdateView(SimulationHandler.SimulationStep);
         }
     }
 }
Пример #5
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = observer.GetTargetName(declaredOwner);
        }
Пример #6
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = MyProject.ShortenNodeTypeName(observer.GetType()) + ": " + observer.GetTargetName(declaredOwner);
        }
Пример #7
0
        public void CreateAndShowObserverView(MyWorkingNode node, Type observerType)
        {
            try
            {
                MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType);
                observer.GenericTarget = node;

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

                newView.Show(dockPanel, DockState.Float);
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
Пример #8
0
        private void UpdateTitleAndButtons()
        {
            if (Target is MyNode)
            {
                MyNode node = Target as MyNode;
                nodeNameTextBox.Rtf = @"{\rtf1\ansi \b " + node.Name + @"\b0  - " + node.GetType().Name + "}";
            }
            else if (Target is MyAbstractObserver)
            {
                MyAbstractObserver observer = Target as MyAbstractObserver;
                nodeNameTextBox.Rtf = @"{\rtf1\ansi \b " + observer.TargetIdentifier + @"\b0  - " + observer.GetType().Name + "}";

                snapshotButton.Checked = observer.AutosaveSnapshop;
            }
            else
            {
                nodeNameTextBox.Rtf = "";
            }

            CanEdit            = m_mainForm.SimulationHandler.State == MySimulationHandler.SimulationState.STOPPED;
            helpButton.Enabled = Target is MyWorkingNode || Target is MyAbstractObserver;

            snapshotButton.Enabled = Target is MyAbstractObserver;

            if (Target is MyWorkingNode)
            {
                saveNodeDataButton.Enabled = true;
                saveNodeDataButton.Checked = (Target as MyWorkingNode).SaveOnStop;

                loadNodeDataButton.Enabled = true;
                loadNodeDataButton.Checked = (Target as MyWorkingNode).LoadOnStart;

                clearDataButton.Enabled = true;
            }
            else
            {
                saveNodeDataButton.Enabled = false;
                saveNodeDataButton.Checked = false;

                loadNodeDataButton.Enabled = false;
                loadNodeDataButton.Checked = false;

                clearDataButton.Enabled = false;
            }
        }
Пример #9
0
        private void UpdateTitleAndButtons()
        {
            if (HasMultipleTargets)
            {
                nodeNameTextBox.Rtf = @"{\rtf1\ansi \b " + Targets?.Length + @" \b0 nodes selected.}";
            }
            else if (Target is MyNode)
            {
                MyNode node = Target as MyNode;
                nodeNameTextBox.Rtf = @"{\rtf1\ansi \b " + node.Name + @"\b0  - " + node.GetType().Name + "}";
            }
            else if (Target is MyAbstractObserver)
            {
                MyAbstractObserver observer = Target as MyAbstractObserver;
                nodeNameTextBox.Rtf = @"{\rtf1\ansi \b " + observer.TargetIdentifier + @"\b0  - " + observer.GetType().Name + "}";

                snapshotButton.Checked = observer.AutosaveSnapshop;
            }
            else
            {
                nodeNameTextBox.Rtf = "";
            }

            CanEdit = m_mainForm.SimulationHandler.State == MySimulationHandler.SimulationState.STOPPED;

            // TODO(Premek): Allow help for multiple nodes of the same type.
            helpButton.Enabled = !HasMultipleTargets && (Target is MyWorkingNode || Target is MyAbstractObserver);

            snapshotButton.Enabled = !HasMultipleTargets && (Target is MyAbstractObserver);

            // TODO(Premek): Allow to set SaveOnStop / LoadOnStart for multiple nodes.
            var workingNode   = !HasMultipleTargets ? (Target as MyWorkingNode) : null;
            var isWorkingNode = (workingNode != null);

            saveNodeDataButton.Enabled = isWorkingNode;
            saveNodeDataButton.Checked = workingNode?.SaveOnStop ?? false;

            loadNodeDataButton.Enabled = isWorkingNode;
            loadNodeDataButton.Checked = workingNode?.LoadOnStart ?? false;

            clearDataButton.Enabled = isWorkingNode;

            dashboardButton.Enabled = !HasMultipleTargets && (Target is MyNode);
        }
Пример #10
0
        public override CUdeviceptr GetDevicePtr(MyAbstractObserver callee, int offset)
        {
            CudaDeviceVariable <T> rDeviceVar = GetDevice(MyKernelFactory.Instance.DevCount - 1);

            return(rDeviceVar != null ? rDeviceVar.DevicePointer + (TimeOffset + offset) * rDeviceVar.TypeSize : default(CUdeviceptr));
        }
Пример #11
0
 public void UpdateObserverView(MyAbstractObserver observer)
 {
     foreach (ObserverForm ov in ObserverViews.ToList())
     {
         if (ov.Observer == observer)
         {
             ov.UpdateView(SimulationHandler.SimulationStep);
         }
     }
 }
Пример #12
0
        public void ShowObserverView(MyAbstractObserver observer)
        {
            MyNode owner;

            var blockObserver = observer as MyAbstractMemoryBlockObserver;
            if (blockObserver != null)
            {
                owner = blockObserver.Target.Owner;
            }
            else
            {
                var plotObserver = observer as MyTimePlotObserver;
                if (plotObserver != null)
                {
                    owner = plotObserver.Target.Owner;
                }
                else
                {
                    owner = observer.GenericTarget as MyNode;
                }
            }

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

            // This is only called from deserialization, the state saving would be redundant.
            //ProjectStateChanged("Abstract observer added");

            newView.Show(dockPanel, DockState.Float);
            newView.FloatPane.FloatWindow.Size = new Size((int)observer.WindowSize.Width, (int)observer.WindowSize.Height);
            newView.FloatPane.FloatWindow.Location = new Point((int)observer.WindowLocation.X, (int)observer.WindowLocation.Y);

            if (!SystemInformation.VirtualScreen.Contains(newView.FloatPane.FloatWindow.Bounds))
            {
                newView.FloatPane.FloatWindow.Location = new Point(0, 0);
            }
        }
Пример #13
0
 public override CUdeviceptr GetDevicePtr(MyAbstractObserver callee)
 {
     return(GetDevicePtr(callee, 0));
 }
Пример #14
0
 public abstract CUdeviceptr GetDevicePtr(MyAbstractObserver callee, int offset);
Пример #15
0
 public abstract CUdeviceptr GetDevicePtr(MyAbstractObserver callee);
Пример #16
0
        public void ShowObserverView(MyAbstractObserver observer)
        {
            MyNode owner = null;

            if (observer is MyAbstractMemoryBlockObserver)
            {
                owner = (observer as MyAbstractMemoryBlockObserver).Target.Owner;
            }
            else if (observer is MyTimePlotObserver)
            {
                owner = (observer as MyTimePlotObserver).Target.Owner;
            }
            else
            {
                owner = observer.GenericTarget as MyNode;
            }

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

            newView.Show(dockPanel, DockState.Float);
            newView.FloatPane.FloatWindow.Size = new Size((int)observer.WindowSize.Width, (int)observer.WindowSize.Height);
            newView.FloatPane.FloatWindow.Location = new Point((int)observer.WindowLocation.X, (int)observer.WindowLocation.Y);

            if (!SystemInformation.VirtualScreen.Contains(newView.FloatPane.FloatWindow.Bounds))
            {
                newView.FloatPane.FloatWindow.Location = new Point(0, 0);
            }
        }