public CCheminDeGrapheReseau[] GetChemins(CPointAPointDeGraphe pap)
        {
            List <CCheminDeGrapheReseau> lst = null;

            if (!TryGetValue(pap, out lst))
            {
                return(new CCheminDeGrapheReseau[0]);
            }
            return(lst.ToArray());
        }
        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);
        }
        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);
        }
        protected void PrepareSupervisionEtatOperationnel(CSchemaReseau schema)
        {
            m_listeGraphes.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 = new List <CNoeudDeGrapheReseau>(graphe.GetNoeudsEntreeNiveau0());
                List <CNoeudDeGrapheReseau> noeudsArrive = new List <CNoeudDeGrapheReseau>(graphe.GetNoeudsSortieNiveau0());
                foreach (CNoeudDeGrapheReseau noeudDepart in noeudsDepart)
                {
                    if (m_dicNoeudsIsoles.ContainsKey(noeudDepart))
                    {
                        m_dicNoeudsIsoles.Remove(noeudDepart);
                    }
                    foreach (CNoeudDeGrapheReseau noeudArrivee in noeudsArrive)
                    {
                        if (m_dicNoeudsIsoles.ContainsKey(noeudArrivee))
                        {
                            m_dicNoeudsIsoles.Remove(noeudArrivee);
                        }
                        CPointAPointDeGraphe pap = new CPointAPointDeGraphe(noeudDepart, noeudArrivee);
                        m_baseChemins.Add(pap, graphe.GetChemins(noeudDepart, noeudArrivee));
                    }
                }
            }
        }
Exemple #5
0
        private void CalculeIsOperationnel()
        {
            bool bOldOperationnel = m_bIsOperationnel;

            try
            {
                m_bIsOperationnel = true;
                if (GraviteAlarme < EGraviteAlarme.Major)
                {
                    return;
                }
                Dictionary <int, bool> dicSitesCoupes  = new Dictionary <int, bool>();
                Dictionary <int, bool> dicLiensCoupes  = new Dictionary <int, bool>();
                Dictionary <int, bool> dicEquipsCoupes = new Dictionary <int, bool>();
                //FillDicsCoupes(m_listeFils.ToArray(), dicSitesCoupes, dicLiensCoupes, dicEquipsCoupes);
                //Vérifie s'il y a des sites isolés en erreur, si oui, état opérationnel HS
                foreach (CNoeudDeGrapheReseau noeud in m_dicNoeudsIsoles.Keys)
                {
                    CNoeudDeGrapheReseauSite noeudSite = noeud as CNoeudDeGrapheReseauSite;
                    if (noeudSite != null && dicSitesCoupes.ContainsKey(noeudSite.IdSite))
                    {
                        m_bIsOperationnel = false;
                        return;
                    }
                    CNoeudDeGrapheReseauEquipement noeudEquip = noeud as CNoeudDeGrapheReseauEquipement;
                    if (noeudEquip != null && dicEquipsCoupes.ContainsKey(noeudEquip.IdEquipement))
                    {
                        m_bIsOperationnel = false;
                        return;
                    }
                }
                foreach (KeyValuePair <CPointAPointDeGraphe, List <CCheminDeGrapheReseau> > papToList in m_baseChemins)
                {
                    CPointAPointDeGraphe         pap            = papToList.Key;
                    List <CCheminDeGrapheReseau> cheminsPourPap = papToList.Value;
                    bool bHasOkForThisPap = false;
                    foreach (CCheminDeGrapheReseau chemin in cheminsPourPap)
                    {
                        bool bIsOk = true;
                        foreach (CNoeudDeGrapheReseau noeud in chemin.NoeudsUtilises)
                        {
                            CNoeudDeGrapheReseauSite noeudSite = noeud as CNoeudDeGrapheReseauSite;
                            if (noeudSite != null && dicSitesCoupes.ContainsKey(noeudSite.IdSite))
                            {
                                bIsOk = false;
                                break;
                            }
                            CNoeudDeGrapheReseauEquipement noeudEquip = noeud as CNoeudDeGrapheReseauEquipement;
                            if (noeudEquip != null && dicEquipsCoupes.ContainsKey(noeudEquip.IdEquipement))
                            {
                                bIsOk = false;
                                break;
                            }
                        }
                        if (bIsOk)
                        {
                            foreach (CLienDeGrapheReseau lien in chemin.Liens)
                            {
                                if (dicLiensCoupes.ContainsKey(lien.IdLienReseau))
                                {
                                    bIsOk = false;
                                    break;
                                }
                            }
                        }
                        bHasOkForThisPap |= bIsOk;
                    }
                    if (!bHasOkForThisPap)
                    {
                        m_bIsOperationnel = false;
                        return;
                    }
                }
            }
            finally
            {
                if (m_bIsOperationnel != bOldOperationnel)
                {
                    m_base.OnChangementEtatSupervise(this);
                }
            }
        }