Exemple #1
0
        /// <summary>
        /// 整理出可测的支路
        /// </summary>
        private void loadTestBranch()
        {
            List <LogicCircuit> testBranch = new List <LogicCircuit>();
            AppProject          app        = AppProject.GetInstance();

            foreach (var route in cfToVccRoutes)
            {
                bool needTest = route.Exists(p => p.CptType == ViewModel.ComponentType.ContactOpen);
                if (needTest)
                {
                    testBranch.Add(new LogicCircuit(route, route[route.Count - 1].getHeadNode(), route[0].getHeadNode().Equal));
                }
            }
            foreach (var route in vccToGndRoutes)
            {
                var cpt = route.FirstOrDefault(p => p.CptType == ViewModel.ComponentType.ContactOpen);
                if (cpt != null)
                {
                    int index = route.IndexOf(cpt);
                    for (int i = index + 1; i < route.Count; i++)
                    {
                        TNode cf = app.IsCFEqual(route[i].getHeadNode().Equal);
                        if (cf != null && cf.Equal != "GND")
                        {
                            testBranch.Add(new LogicCircuit(route.GetRange(0, i), cf, route[0].getHeadNode().Equal));
                            break;
                        }
                    }
                }
            }
            foreach (var route in cfToGndRoutes)
            {
                var cpt = route.LastOrDefault(p => p.CptType == ViewModel.ComponentType.ContactOpen);
                if (cpt != null)
                {
                    int index = route.IndexOf(cpt);
                    for (int i = index; i >= 0; i--)
                    {
                        TNode cf = app.IsCFEqual(route[i].getHeadNode().Equal);
                        if (cf != null && cf.Equal != "GND")
                        {
                            testBranch.Add(new LogicCircuit(route.GetRange(i, route.Count - i), cf, route[route.Count - 1].getHeadNode().Equal));
                            break;
                        }
                    }
                }
            }
            this.testBranch = testBranch.AsReadOnly();
        }
Exemple #2
0
        /// <summary>
        /// 获取加电后可以直接得电的线圈
        /// </summary>
        private void getNoneConditionCoil(ISet <List <INotifyComponentChanged> > allRts)
        {
            AppProject app = AppProject.GetInstance();

            foreach (var route in vccToGndRoutes)
            {
                for (int i = route.Count - 1; i >= 0; i--)
                {
                    if (route[i].CptType == ViewModel.ComponentType.Coil && !powCoils.ContainsKey(route[i].getName()))
                    {
                        string name = route[i].getName();
                        while (i >= 0)
                        {
                            if (app.IsCFEqual(route[i].getHeadNode().Equal) != null)
                            {
                                powCoils[name] = new List <List <string> >();
                                powCoils[name].Add(new List <string>()
                                {
                                    route[i].getHeadNode().Equal
                                });
                                allRts.Add(route);
                                break;
                            }
                            else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                            {
                                break;
                            }
                            i--;
                        }
                        if (i < 0)
                        {
                            powCoils[name] = new List <List <string> >();
                            powCoils[name].Add(new List <string>()
                            {
                                route[0].getHeadNode().Equal
                            });
                            allRts.Add(route);
                        }
                        break;
                    }
                    else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                    {
                        break;
                    }
                }
            }
            foreach (var route in cfToGndRoutes)
            {
                for (int i = 0; i < route.Count; i++)
                {
                    if (route[i].CptType == ViewModel.ComponentType.Coil && !powCoils.ContainsKey(route[i].getName()))
                    {
                        string name = route[i].getName();
                        i++;
                        while (i < route.Count)
                        {
                            if (app.IsCFEqual(route[i].getHeadNode().Equal) != null)
                            {
                                powCoils[name] = new List <List <string> >();
                                powCoils[name].Add(new List <string>()
                                {
                                    route[i].getHeadNode().Equal
                                });
                                allRts.Add(route);
                                break;
                            }
                            else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                            {
                                break;
                            }
                            i++;
                        }
                        if (i >= route.Count)
                        {
                            powCoils[name] = new List <List <string> >();
                            powCoils[name].Add(new List <string>()
                            {
                                route[route.Count - 1].getHeadNode().Equal
                            });
                            allRts.Add(route);
                        }
                        break;
                    }
                    else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                    {
                        break;
                    }
                }
            }
        }
Exemple #3
0
        private void getConditionCoil(ISet <List <INotifyComponentChanged> > allRts)
        {
            AppProject app  = AppProject.GetInstance();
            bool       mark = false;

            while (!mark)
            {
                mark = true;
                #region vccToGndRoutes
                foreach (var route in vccToGndRoutes)
                {
                    if (!allRts.Contains(route))
                    {
                        List <List <List <string> > > condition = new List <List <List <string> > >();
                        for (int i = route.Count - 1; i >= 0; i--)
                        {
                            if (route[i].CptType == ViewModel.ComponentType.Coil && !powCoils.ContainsKey(route[i].getName()))
                            {
                                string name = route[i].getName();
                                while (i >= 0)
                                {
                                    if (app.IsCFEqual(route[i].getHeadNode().Equal) != null)
                                    {
                                        mark = false;
                                        string src = route[i].getHeadNode().Equal;
                                        List <List <string> > val = new List <List <string> >();
                                        combine(condition, 0, new List <string>(), val);
                                        val.ForEach(p => {
                                            if (!p.Contains(src))
                                            {
                                                p.Add(src);
                                            }
                                        });
                                        powCoils[name] = val;
                                        allRts.Add(route);
                                        break;
                                    }
                                    else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                                    {
                                        if (!powCoils.ContainsKey(route[i].getName()))
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            condition.Add(powCoils[route[i].getName()]);
                                        }
                                    }
                                    i--;
                                }
                                if (i < 0)
                                {
                                    mark = false;
                                    string src = route[0].getHeadNode().Equal;
                                    List <List <string> > val = new List <List <string> >();
                                    combine(condition, 0, new List <string>(), val);
                                    val.ForEach(p =>
                                    {
                                        if (!p.Contains(src))
                                        {
                                            p.Add(src);
                                        }
                                    });
                                    powCoils[name] = val;
                                    allRts.Add(route);
                                }
                                break;
                            }
                            else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                            {
                                if (!powCoils.ContainsKey(route[i].getName()))
                                {
                                    break;
                                }
                                else
                                {
                                    condition.Add(powCoils[route[i].getName()]);
                                }
                            }
                        }
                    }
                }
                #endregion

                #region cfToGndRoutes
                foreach (var route in cfToGndRoutes)
                {
                    if (!allRts.Contains(route))
                    {
                        List <List <List <string> > > condition = new List <List <List <string> > >();
                        for (int i = 0; i < route.Count; i++)
                        {
                            if (route[i].CptType == ViewModel.ComponentType.Coil && !powCoils.ContainsKey(route[i].getName()))
                            {
                                string name = route[i].getName();
                                i++;
                                while (i < route.Count)
                                {
                                    if (app.IsCFEqual(route[i].getHeadNode().Equal) != null)
                                    {
                                        mark = false;
                                        string src = route[i].getHeadNode().Equal;
                                        List <List <string> > val = new List <List <string> >();
                                        combine(condition, 0, new List <string>(), val);
                                        val.ForEach(p =>
                                        {
                                            if (!p.Contains(src))
                                            {
                                                p.Add(src);
                                            }
                                        });
                                        powCoils[name] = val;
                                        allRts.Add(route);
                                        break;
                                    }
                                    else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                                    {
                                        if (!powCoils.ContainsKey(route[i].getName()))
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            condition.Add(powCoils[route[i].getName()]);
                                        }
                                    }
                                    i++;
                                }
                                if (i >= route.Count)
                                {
                                    mark = false;
                                    string src = route[route.Count - 1].getHeadNode().Equal;
                                    List <List <string> > val = new List <List <string> >();
                                    combine(condition, 0, new List <string>(), val);
                                    val.ForEach(p =>
                                    {
                                        if (!p.Contains(src))
                                        {
                                            p.Add(src);
                                        }
                                    });
                                    powCoils[name] = val;
                                    allRts.Add(route);
                                }
                                break;
                            }
                            else if (route[i].CptType == ViewModel.ComponentType.ContactOpen)
                            {
                                if (!powCoils.ContainsKey(route[i].getName()))
                                {
                                    break;
                                }
                                else
                                {
                                    condition.Add(powCoils[route[i].getName()]);
                                }
                            }
                        }
                    }
                }
                #endregion
            }
        }