Beispiel #1
0
        /// <summary>
        /// 由索引值获得一个链路对象that在此处new(),目前未建设完成
        /// </summary>
        /// <param name="inx">目标链路在excel中的索引号</param>
        /// <returns>chain_pathex</returns>
        private chain_pathex ReadFromIndex(int inx)
        {
            chain_pathex Breturn = new chain_pathex(view);
            Range        temp    = xsheet.get_Range(string.Format("A{0}", inx));

            //进行判断该表是否为空,从而判断是否读到了表尾
            if (temp.Value2 == null)
            {
                return(null);
            }
            //读入nodes节点信息
            string Nodes = temp.Value2.ToString();

            //读入通断时间信息
            Breturn.tStart = DateTime.ParseExact(temp.Next.Value2.ToString(), "yyyy:MM:dd:HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
            Breturn.tEnd   = DateTime.ParseExact(temp.Next.Next.Value2.ToString(), "yyyy:MM:dd:HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
            string[] nodelist = Nodes.Split(new string[] { "->" }, StringSplitOptions.None);
            foreach (var str in nodelist)
            {
                Breturn.path.Add(str);
                //将系统物件表中的物体添加到链路的小表中
                Breturn.path_Objs.Add(view.Scenemana.stkObjs.Find(c => c.ObjName == str));
            }
            //传感器名称等于链路的id号
            Breturn.sensor_name = Breturn.path[0] + "-" + Breturn.path[Breturn.path.Count - 1];
            return(Breturn);
        }
Beispiel #2
0
 /// <summary>
 /// 将数据从excel表中读出并存入scenemana之中
 /// </summary>
 public void write()
 {
     Echain = ReadFromIndex(indexE);
     Schain = ReadFromIndex(indexS);
     while (Echain != null || Schain != null)
     {
         if (Echain != null && Schain != null)
         {
             var    temp    = Echain.tEnd - Schain.tStart;
             double seconds = temp.TotalSeconds;
             if (seconds <= 0)
             {
                 view.Scenemana.msglist.Add(new Msg {
                     time = (Echain.tEnd - view.dStartTime).TotalSeconds, PathNodes = Echain.path, StartOrEnd = "e", id = Echain.sensor_name
                 });
                 indexE++;
                 Echain = ReadFromIndex(indexE);
             }
             else
             {
                 view.Scenemana.msglist.Add(new Msg {
                     time = (Schain.tStart - view.dStartTime).TotalSeconds, PathNodes = Schain.path, StartOrEnd = "s", id = Schain.sensor_name
                 });
                 indexS++;
                 Schain = ReadFromIndex(indexS);
             }
         }
         else if (Echain == null)
         {
             view.Scenemana.msglist.Add(new Msg {
                 time = (Schain.tStart - view.dStartTime).TotalSeconds, PathNodes = Schain.path, StartOrEnd = "s", id = Schain.sensor_name
             });
             indexS++;
             Schain = ReadFromIndex(indexE);
         }
         else if (Schain == null)
         {
             view.Scenemana.msglist.Add(new Msg {
                 time = (Echain.tEnd - view.dStartTime).TotalSeconds, PathNodes = Echain.path, StartOrEnd = "e", id = Echain.sensor_name
             });
             indexE++;
             Echain = ReadFromIndex(indexS);
         }
     }
 }