Пример #1
0
        private BackTraceElement GetElement(int bpaddr)
        {
            BaseViewModel bvmodel = BreakPointManager.GetBVModel(bpaddr);

            if (bvmodel != null)
            {
                LadderNetworkViewModel lnvmodel = ifacade.ProjectModel.GetNetwork(bvmodel);
                if (lnvmodel == null)
                {
                    return(null);
                }
                LadderDiagramViewModel ldvmodel = lnvmodel.LDVModel;
                SimuBrpoElement        brpo     = new SimuBrpoElement();
                brpo.LDVModel = ldvmodel;
                brpo.LNVModel = lnvmodel;
                brpo.BVModel  = bvmodel;
                return(new BackTraceElement(BackTraceType.Diagram, brpo));
            }
            FuncBlock fblock = BreakPointManager.GetFBlock(bpaddr);

            if (fblock != null)
            {
                FuncBlockViewModel fbvmodel = ifacade.ProjectModel.GetFuncBlock(fblock);
                if (fbvmodel == null)
                {
                    return(null);
                }
                FuncBrpoElement brpo = new FuncBrpoElement();
                brpo.FBVModel = fbvmodel;
                brpo.FBlock   = fblock;
                return(new BackTraceElement(BackTraceType.FuncBlock, brpo));
            }
            return(new BackTraceElement(BackTraceType.External));
        }
Пример #2
0
        private void DG_Main_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Dispatcher.Invoke(new Utility.Delegates.Execute(() =>
            {
                SimuBrpoElement ele = (SimuBrpoElement)(DG_Main.SelectedItem);
                if (ele != null)
                {
                    if (e.OriginalSource is ComboBox &&
                        e.AddedItems.Count == 1)
                    {
                        ele.Condition = e.AddedItems[0].ToString();
                        switch (ele.Condition)
                        {
                        case "无": ele.BPRect.Label = String.Empty; break;

                        case "0": ele.BPRect.Label = "0"; break;

                        case "1": ele.BPRect.Label = "1"; break;

                        case "上升沿": ele.BPRect.Label = "↑"; break;

                        case "下降沿": ele.BPRect.Label = "↓"; break;
                        }
                        Active(ele);
                    }
                    ifacade.NavigateToNetwork(
                        new NavigateToNetworkEventArgs(
                            ele.LNVModel.NetworkNumber,
                            ele.LDVModel.ProgramName,
                            ele.BVModel.X,
                            ele.BVModel.Y));
                }
            }));
        }
Пример #3
0
        private void OnBreakpointChanged(object sender, BreakpointChangedEventArgs e)
        {
            LadderNetworkViewModel        lnvmodel = (LadderNetworkViewModel)sender;
            LadderDiagramViewModel        ldvmodel = lnvmodel.LDVModel;
            IEnumerable <SimuBrpoElement> fit      = null;
            SimuBrpoElement ele = null;

            if (e.BPRect_old != null)
            {
                fit = items.Where((_ele) => { return(_ele.BPRect == e.BPRect_old); });
                if (fit.Count() > 0)
                {
                    ele = fit.First();
                    Unactive(ele);
                    items.Remove(ele);
                }
            }
            if (e.BPRect_new != null)
            {
                ele           = new SimuBrpoElement();
                ele.IsActive  = true;
                ele.LDVModel  = ldvmodel;
                ele.LNVModel  = lnvmodel;
                ele.BVModel   = e.BPRect_new.BVModel;
                ele.BPRect    = e.BPRect_new;
                ele.BreakTime = "1";
                items.Add(ele);
                Active(ele);
            }
            PropertyChanged(this, new PropertyChangedEventArgs("Items"));
            ifacade.MainWindow.LACBreakpoint.Show();
        }
Пример #4
0
        public void Unactive(SimuBrpoElement ele)
        {
            int bpaddr = ele.BVModel.BPAddress;

            SimulateDllModel.SetBPAddr(bpaddr, 0);
            SimulateDllModel.SetCPAddr(bpaddr, 0);
        }
Пример #5
0
        public void Active(SimuBrpoElement ele)
        {
            int bpaddr = ele.BVModel.BPAddress;
            int bpmsg  = 0;
            int cpmsg  = 0;

            switch (ele.BPRect.Label)
            {
            case "": ele.Condition = "无"; bpmsg = 1; break;

            case "0": ele.Condition = "0"; cpmsg = 1; break;

            case "1": ele.Condition = "1"; cpmsg = 2; break;

            case "↑": ele.Condition = "上升沿"; cpmsg = 4; break;

            case "↓": ele.Condition = "下降沿"; cpmsg = 8; break;

            default: ele.Condition = "无"; break;
            }
            int count = 1;

            try
            {
                count = int.Parse(ele.BreakTime);
                SimulateDllModel.SetBPAddr(bpaddr, bpmsg);
                SimulateDllModel.SetCPAddr(bpaddr, cpmsg);
                SimulateDllModel.SetBPCount(bpaddr, count);
            }
            catch (Exception e)
            {
            }
        }
Пример #6
0
        public void Remove(int id)
        {
            SimuBrpoElement ele = items[id];

            Unactive(ele);
            items.Remove(ele);
            ele.LDVModel.RemoveBreakpoint(ele.LNVModel, ele.BPRect);
        }
Пример #7
0
        private void DG_Main_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            SimuBrpoElement ele = (SimuBrpoElement)(DG_Main.SelectedItem);

            if (ele != null && ele.IsActive)
            {
                Active(ele);
            }
        }
Пример #8
0
        private void OnJumpCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            SimuBrpoElement ele = (SimuBrpoElement)(DG_Main.SelectedItem);

            if (ele != null)
            {
                smanager.JumpTo(ele.BVModel.BPAddress);
            }
        }
Пример #9
0
        private void OnActiveSwapCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            SimuBrpoElement ele = (SimuBrpoElement)(DG_Main.SelectedItem);

            if (ele != null)
            {
                ele.IsActive ^= true;
                if (ele.IsActive)
                {
                    Active(ele);
                }
                else
                {
                    Unactive(ele);
                }
            }
        }
Пример #10
0
 private void OnBreakpointPause(object sender, BreakpointPauseEventArgs e)
 {
     Dispatcher.Invoke(new Utility.Delegates.Execute(() =>
     {
         BaseViewModel bvmodel = BreakPointManager.GetBVModel(e.Address);
         if (bvmodel != null)
         {
             Breakpoint = bvmodel;
             ifacade.NavigateToNetwork(bvmodel);
             IEnumerable <SimuBrpoElement> fit = items.Where(
                 (_ele) => { return(_ele.BVModel == bvmodel); });
             if (fit.Count() > 0)
             {
                 SimuBrpoElement ele = fit.First();
                 int id = items.IndexOf(ele);
                 DG_Main.SelectedIndex = id;
             }
         }
     }));
 }