Ejemplo n.º 1
0
        public CCheminDeGrapheReseau[] GetChemins(CPointAPointDeGraphe pap)
        {
            List <CCheminDeGrapheReseau> lst = null;

            if (!TryGetValue(pap, out lst))
            {
                return(new CCheminDeGrapheReseau[0]);
            }
            return(lst.ToArray());
        }
Ejemplo n.º 2
0
        public void AddChemins(CPointAPointDeGraphe pap, List <CCheminDeGrapheReseau> lstToAdd)
        {
            List <CCheminDeGrapheReseau> lst = null;

            if (!TryGetValue(pap, out lst))
            {
                lst       = new List <CCheminDeGrapheReseau>();
                this[pap] = lstToAdd;
            }
            lstToAdd.AddRange(lstToAdd);
        }
Ejemplo n.º 3
0
        public void AddChemin(CPointAPointDeGraphe pap, CCheminDeGrapheReseau chemin)
        {
            List <CCheminDeGrapheReseau> lst = null;

            if (!TryGetValue(pap, out lst))
            {
                lst       = new List <CCheminDeGrapheReseau>();
                this[pap] = lst;
            }
            lst.Add(chemin);
        }
Ejemplo n.º 4
0
        protected void PrepareSupervisionEtatOperationnel(CSchemaReseau schema)
        {
            m_listeGraphes.Clear();
            m_baseChemins.Clear();
            List <ESensAllerRetourLienReseau?> lstToCalcul = new List <ESensAllerRetourLienReseau?>();

            if (schema.LienReseau != null)
            {
                lstToCalcul.Add(null);
            }
            else
            {
                lstToCalcul.Add(ESensAllerRetourLienReseau.Forward);
                lstToCalcul.Add(ESensAllerRetourLienReseau.Backward);
            }
            foreach (ESensAllerRetourLienReseau?sens in lstToCalcul)
            {
                CGrapheReseau graphe = m_base.BaseGraphes.GetGrapheExistant(schema, sens);
                if (graphe == null)
                {
                    graphe = new CGrapheReseau(m_base.BaseGraphes);
                    graphe.IntegreLiaison = IntegreLienInGraphe;
                    if (graphe.CalculeGraphe(schema, sens))
                    {
                        m_listeGraphes.Add(graphe);
                    }
                }
                else
                {
                    m_listeGraphes.Add(graphe);
                }
            }
            if (m_listeGraphes.Count == 2)
            {
                //Si l'un des graphes a des liens et pas l'autre, supprime ce graphe
                int nNbLiens1 = m_listeGraphes[0].GetLiensNiveau0().Length;
                int nNbLiens2 = m_listeGraphes[1].GetLiensNiveau0().Length;
                if (nNbLiens1 == 0 && nNbLiens2 != 0)
                {
                    m_listeGraphes.RemoveAt(0);
                }
                else if (nNbLiens2 == 0)
                {
                    m_listeGraphes.RemoveAt(1);
                }
            }


            //Calcule tous les chemins de point d'entrée à point de sortie.
            m_baseChemins.Clear();
            m_dicNoeudsIsoles = new Dictionary <CNoeudDeGrapheReseau, bool>();
            if (m_listeGraphes.Count > 0)
            {
                foreach (CNoeudDeGrapheReseau noeud in m_listeGraphes[0].GetNoeudsIsoles())
                {
                    m_dicNoeudsIsoles[noeud] = true;
                }
            }
            int nIndex = 0;

            foreach (CGrapheReseau graphe in m_listeGraphes)
            {
                List <CNoeudDeGrapheReseau> noeudsDepart;
                List <CNoeudDeGrapheReseau> noeudsArrive;
                if (schema.LienReseau != null)
                {
                    noeudsDepart = new List <CNoeudDeGrapheReseau>();
                    noeudsArrive = new List <CNoeudDeGrapheReseau>();
                    CLienReseau                 lien = schema.LienReseau;
                    CNoeudDeGrapheReseau        noeud;
                    List <EDirectionLienReseau> lstCodes = new List <EDirectionLienReseau>();
                    if (lien.Direction.Code == EDirectionLienReseau.Bidirectionnel)
                    {
                        lstCodes.Add(EDirectionLienReseau.UnVersDeux);
                        lstCodes.Add(EDirectionLienReseau.DeuxVersUn);
                    }
                    else
                    {
                        lstCodes.Add(lien.Direction.Code);
                    }
                    foreach (EDirectionLienReseau direction in lstCodes)
                    {
                        switch (direction)
                        {
                        case EDirectionLienReseau.UnVersDeux:
                            noeud = graphe.GetNoeudForElement(lien.Element1, schema);
                            if (noeud != null)
                            {
                                noeudsDepart.Add(noeud);
                            }
                            noeud = graphe.GetNoeudForElement(lien.Element2, schema);
                            if (noeud != null)
                            {
                                noeudsArrive.Add(noeud);
                            }
                            break;

                        case EDirectionLienReseau.DeuxVersUn:
                            noeud = graphe.GetNoeudForElement(lien.Element2, schema);
                            if (noeud != null)
                            {
                                noeudsDepart.Add(noeud);
                            }
                            noeud = graphe.GetNoeudForElement(lien.Element1, schema);
                            if (noeud != null)
                            {
                                noeudsArrive.Add(noeud);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    noeudsDepart = new List <CNoeudDeGrapheReseau>(graphe.GetNoeudsEntreeNiveau0());
                    noeudsArrive = new List <CNoeudDeGrapheReseau>(graphe.GetNoeudsSortieNiveau0());
                }

                foreach (CNoeudDeGrapheReseau noeudDepart in noeudsDepart)
                {
                    foreach (CNoeudDeGrapheReseau noeudArrivee in noeudsArrive)
                    {
                        CPointAPointDeGraphe         pap     = new CPointAPointDeGraphe(noeudDepart, noeudArrivee);
                        List <CCheminDeGrapheReseau> chemins = graphe.GetChemins(noeudDepart, noeudArrivee);
                        m_baseChemins.AddChemins(pap, chemins);
                        if (chemins.Count != 0)
                        {
                            if (m_dicNoeudsIsoles.ContainsKey(noeudDepart))
                            {
                                m_dicNoeudsIsoles.Remove(noeudDepart);
                            }
                            if (m_dicNoeudsIsoles.ContainsKey(noeudArrivee))
                            {
                                m_dicNoeudsIsoles.Remove(noeudArrivee);
                            }
                        }
                    }
                }
            }
        }