示例#1
0
        public ParsedMessage ParseSystemAlert(AlertTemplate template)
        {
            List <String> stations = new List <String>();

            stations.Add("");
            return(ParseStationAlert(stations, template));
        }
示例#2
0
        public void InitVars()
        {
            AlrtTmplt   = new AlertTemplate();
            MtrTmplt    = new MetraTemplate();
            TmpltPrsr   = new TemplateParser();
            LaiList     = new List <LineAlertInfo>();
            LaiList2    = new List <LineAlertInfo>();
            LaiList3    = new List <LineAlertInfo>();
            StationList = new List <String>();
            TaiList     = new List <TrainAlertInfo>();

            LineAlertInfo lai = new LineAlertInfo();

            lai.LineName    = "Metra Electric";
            lai.LineAbbr    = "ME";
            lai.SubLineList = new List <String>();
            lai.SubLineList.Add("University Park");
            lai.SubLineList.Add("Blue Island");
            LaiList.Add(lai);
            LaiList3.Add(lai);

            lai             = new LineAlertInfo();
            lai.LineName    = "UP North";
            lai.LineAbbr    = "UP-N";
            lai.SubLineList = null;
            LaiList2.Add(lai);
            LaiList3.Add(lai);

            TrainAlertInfo tai = new TrainAlertInfo();

            tai.TrainNum         = "2134";
            tai.SchedOrigin      = "Grayslake";
            tai.SchedOriginTime  = "11:58:00";
            tai.SchedDestination = "Chicago Union Station";
            tai.SchedDestTime    = "13:22:00";
            TaiList.Add(tai);

            tai                  = new TrainAlertInfo();
            tai.TrainNum         = "2136";
            tai.SchedOrigin      = "Fox Lake";
            tai.SchedOriginTime  = "12:45:00";
            tai.SchedDestination = "Chicago Union Station";
            tai.SchedDestTime    = "14:22:00";
            TaiList.Add(tai);

            tai                  = new TrainAlertInfo();
            tai.TrainNum         = "2138";
            tai.SchedOrigin      = "Grayslake";
            tai.SchedOriginTime  = "13:58:00";
            tai.SchedDestination = "Chicago Union Station";
            tai.SchedDestTime    = "15:22:00";
            TaiList.Add(tai);

            StationList.Add("Hubbard Woods");
            StationList.Add("Winnetka");
            StationList.Add("Indian Hill");

            DelayReason = "signal problems";
        }
示例#3
0
        public ParsedMessage ParseTrainAutoAlert(List <TrainAlertInfo> trains, String delayReason, int delayTime,
                                                 AlertTemplate template)
        {
            if (delayReason.Equals(NO_DELAY_REASON))
            {
                delayReason = null;
            }
            Token         tokenInfo = new Token();
            ParsedMessage parsedMsg = new ParsedMessage();
            String        header    = template.Header.Trim();
            String        text      = template.Text.Trim();

            // Process Header
            do
            {
                if (FoundNextToken(template.Header, tokenInfo))
                {
                    parsedMsg.AlertSummary += GetPlainText(header, tokenInfo);
                    parsedMsg.AlertSummary += ParseTrainToken(header, tokenInfo, trains, delayReason, delayTime);
                }
                else
                {
                    break;
                }
            } while (true);
            parsedMsg.AlertSummary += header.Substring(tokenInfo.PrevEndIndex + 1, tokenInfo.StartIndex - tokenInfo.PrevEndIndex);
            if (char.IsLower(parsedMsg.AlertSummary[0]))
            {
                parsedMsg.AlertSummary = char.ToUpper(parsedMsg.AlertSummary[0]) + parsedMsg.AlertSummary.Substring(1);
            }

            tokenInfo.Init();
            // Process Text
            do
            {
                if (FoundNextToken(text, tokenInfo))
                {
                    parsedMsg.AlertText += GetPlainText(text, tokenInfo);
                    parsedMsg.AlertText += ParseTrainToken(text, tokenInfo, trains, delayReason, delayTime);
                }
                else
                {
                    break;
                }
            } while (true);
            parsedMsg.AlertText += text.Substring(tokenInfo.PrevEndIndex + 1, tokenInfo.StartIndex - tokenInfo.PrevEndIndex);
            if (char.IsLower(parsedMsg.AlertText[0]))
            {
                parsedMsg.AlertText = char.ToUpper(parsedMsg.AlertText[0]) + parsedMsg.AlertText.Substring(1);
            }

            return(parsedMsg);
        }
示例#4
0
        public ParsedMessage ParseStationAlert(List <String> stations, AlertTemplate template)
        {
            Token         tokenInfo = new Token();
            ParsedMessage parsedMsg = new ParsedMessage();
            String        header    = template.Header.Trim();
            String        text      = template.Text.Trim();

            // Process Header
            do
            {
                if (FoundNextToken(template.Header, tokenInfo))
                {
                    parsedMsg.AlertSummary += GetPlainText(header, tokenInfo);
                    parsedMsg.AlertSummary += ParseStationToken(header, tokenInfo, stations);
                }
                else
                {
                    break;
                }
            } while (true);
            parsedMsg.AlertSummary += header.Substring(tokenInfo.PrevEndIndex + 1, tokenInfo.StartIndex - tokenInfo.PrevEndIndex);
            if (char.IsLower(parsedMsg.AlertSummary[0]))
            {
                parsedMsg.AlertSummary = char.ToUpper(parsedMsg.AlertSummary[0]) + parsedMsg.AlertSummary.Substring(1);
            }

            tokenInfo.Init();
            // Process Text
            do
            {
                if (FoundNextToken(text, tokenInfo))
                {
                    parsedMsg.AlertText += GetPlainText(text, tokenInfo);
                    parsedMsg.AlertText += ParseStationToken(text, tokenInfo, stations);
                }
                else
                {
                    break;
                }
            } while (true);
            parsedMsg.AlertText += text.Substring(tokenInfo.PrevEndIndex + 1, tokenInfo.StartIndex - tokenInfo.PrevEndIndex);
            if (char.IsLower(parsedMsg.AlertText[0]))
            {
                parsedMsg.AlertText = char.ToUpper(parsedMsg.AlertText[0]) + parsedMsg.AlertText.Substring(1);
            }

            return(parsedMsg);
        }
示例#5
0
 public ParsedMessage ParseElevatorAlert(List <String> stations, AlertTemplate template)
 {
     return(ParseStationAlert(stations, template));
 }
示例#6
0
 public ParsedMessage ParseTrainAlert(List <TrainAlertInfo> trains, String delayReason, AlertTemplate template)
 {
     return(ParseTrainAutoAlert(trains, delayReason, 0, template));
 }