Esempio n. 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);
            }
        }
Esempio n. 2
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = observer.GetTargetName(declaredOwner);
        }
Esempio n. 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);
        }
Esempio n. 4
0
 public void UpdateObserverView(MyAbstractObserver observer)
 {
     foreach (ObserverForm ov in ObserverViews.ToList())
     {
         if (ov.Observer == observer)
         {
             ov.UpdateView(SimulationHandler.SimulationStep);
         }
     }
 }
Esempio n. 5
0
        public ObserverForm(MainForm mainForm, MyAbstractObserver observer, MyNode declaredOwner)
        {
            InitializeComponent();
            m_mainForm = mainForm;

            Observer = observer;
            observer.TriggerReset();

            Text = observer.GetTargetName(declaredOwner);
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 11
0
 public void UpdateObserverView(MyAbstractObserver observer)
 {
     foreach (ObserverForm ov in ObserverViews.ToList())
     {
         if (ov.Observer == observer)
         {
             ov.UpdateView(SimulationHandler.SimulationStep);
         }
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 13
0
 public override CUdeviceptr GetDevicePtr(MyAbstractObserver callee)
 {
     return(GetDevicePtr(callee, 0));
 }
Esempio n. 14
0
 public abstract CUdeviceptr GetDevicePtr(MyAbstractObserver callee, int offset);
Esempio n. 15
0
 public abstract CUdeviceptr GetDevicePtr(MyAbstractObserver callee);
Esempio n. 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);
            }
        }