Пример #1
0
        /// <summary>
        /// route_segment length, based on blk_list, check sddb
        /// </summary>//0035
        /// <param name="blockList"></param>
        /// <returns></returns>
        /// //BMGR-0035
        public int GetLength()
        {
            int len       = 0;
            int startBIdx = 0;

            for (int i = 0; i < m_BlkLst.Count; ++i)
            {
                if (OrgSig.SDDId == m_BlkLst[i].Secondary_Detection_Device_ID &&
                    0 != m_BlkLst[i].Secondary_Detection_Device_ID)
                {
                    startBIdx = i;
                    break;
                }
            }

            int endBIdx = m_BlkLst.Count - 1;

            if (m_BlkLst.Count() > 1)
            {
                //find signal located block
                GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK blk = SyDB.GetLocatedBlock(DstSig.Kp,DstSig.Track_ID);
                if (blk == null)
                {
                    TraceMethod.Record(TraceMethod.TraceKind.ERROR,$"dstSignal{DstSig.Info} can't find located block");
                    return(-1);
                }
                if (SyDB.IsLocatedOnBlockBeginOrEnd(DstSig.Kp,DstSig.Track_ID,blk))
                {
                    if (m_BlkLst.Exists(s => s.ID == blk.ID) == false)
                    {
                        //the last one is the endBIdx, so donothing
                    }
                    else
                    {
                        endBIdx = m_BlkLst.FindIndex(s => s.ID == blk.ID);
                        var preBlk = (GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK)Sys.GetNode((int)(m_BlkLst[endBIdx - 1].ID),SyDB.GetInstance().blockInfoList.Cast <Node>().ToList());
                        if (SyDB.IsLocatedOnBlockBeginOrEnd(DstSig.Kp,DstSig.Track_ID,preBlk))
                        {
                            endBIdx = endBIdx - 1;//route length end with preblk
                        }
                        else
                        {
                            //the located one is the endBIdx, so donothing
                        }
                    }
                }
                else
                {//the local block is the end one
                    if (m_BlkLst.Exists(s => s.ID == blk.ID) == false)
                    {
                        m_BlkLst.Add(blk);
                        ++endBIdx;
                    }
                    else
                    {
                        endBIdx = m_BlkLst.FindIndex(s => s.ID == blk.ID);
                    }
                }
            }

            string log = "";

            for (int i = startBIdx; i <= endBIdx; ++i)
            {
                len += m_BlkLst[i].GetBlockLen();
                log += "[" + m_BlkLst[i].Info + "]";
            }
            //TraceMethod.RecordInfo($"RouteSegment {Info} has blocks {log}");

            return(len);
        }