示例#1
0
文件: Cycle.cs 项目: zfx1982/ATSPM
 public void NextEvent(EventType eventType, DateTime timeStamp)
 {
     //if the event is green add its' data
     if (eventType == EventType.ChangeToGreen)
     {
         //Check to see that the last event was not a change to green
         if (greenLineY == 0)
         {
             //Check for bad data
             if (startTime != DateTime.MinValue)
             {
                 greenLineY = (timeStamp - startTime).TotalSeconds;
                 greenEvent = timeStamp;
                 status     = NextEventResponse.GroupOK;
             }
             //Mark the group as having bad data
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
         //Dont add anything but keep processing
         else
         {
             status = NextEventResponse.GroupOK;
         }
     }
     // if the change event is yellow add its' data
     else if (eventType == EventType.ChangeToYellow)
     {
         // check to see that the last event was not a change to yellow
         if (yellowLineY == 0)
         {
             //check that the greenline y coordinate was already added
             //then add the data
             if (startTime != DateTime.MinValue && greenLineY != 0)
             {
                 yellowLineY = (timeStamp - startTime).TotalSeconds;
                 yellowEvent = timeStamp;
                 status      = NextEventResponse.GroupOK;
             }
             //flag the group as bad data
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
         //keep processing
         else
         {
             status = NextEventResponse.GroupOK;
         }
     }
     //check to see if the event is a change to red
     else if (eventType == EventType.ChangeToRed)
     {
         //check to see if the green, yellow, and starting red was added
         //if not create the next group
         if (startTime == DateTime.MinValue && yellowLineY == 0 && greenLineY == 0 && redLineY == 0)
         {
             startTime = timeStamp;
             status    = NextEventResponse.GroupOK;
         }
         //add the event to the existing group
         else
         {
             //if the yellow and green y coordinates have been added and the
             // start time is valid add the red event as the ending red
             if (startTime != DateTime.MinValue && yellowLineY != 0 && greenLineY != 0)
             {
                 redLineY = (timeStamp - startTime).TotalSeconds;
                 status   = NextEventResponse.GroupComplete;
                 endTime  = timeStamp;
             }
             //mark the group as missing data
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
     }
     //keep processing
     else
     {
         status = NextEventResponse.GroupOK;
     }
 }
示例#2
0
 public void NextEvent(EventType eventType, DateTime timeStamp)
 {
     //if the event is yellow add its' data
     if (eventType == EventType.BeginYellowClearance)
     {
         //Check for bad data
         if (startTime != DateTime.MinValue)
         {
             yellowClearanceBeginY = 0;
             yellowClearanceEvent  = timeStamp;
             status = NextEventResponse.GroupOK;
         }
         //Mark the group as having bad data
         else
         {
             status = NextEventResponse.GroupMissingData;
         }
     }
     // if the change event is red clearance add its' data
     else if (eventType == EventType.BeginRedClearance)
     {
         // check to see that the last event was not a change to red clearance
         if (RedClearanceBeginY == 0 && yellowClearanceEvent != DateTime.MinValue)
         {
             if (startTime != DateTime.MinValue)
             {
                 redClearanceBeginY = (timeStamp - startTime).TotalSeconds;
                 redClearanceEvent  = timeStamp;
                 status             = NextEventResponse.GroupOK;
             }
             //flag the group as bad data
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
         //keep processing
         else
         {
             status = NextEventResponse.GroupMissingData;
         }
     }
     //check to see if the event is a change to red
     else if (eventType == EventType.BeginRed)
     {
         if (RedBeginY == 0)
         {
             if (startTime != DateTime.MinValue && yellowClearanceEvent != DateTime.MinValue &&
                 RedClearanceEvent != DateTime.MinValue)
             {
                 redEvent  = timeStamp;
                 redBeginY = (timeStamp - startTime).TotalSeconds;
                 status    = NextEventResponse.GroupOK;
             }
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
     }
     // if the change event is red clearance add its' data
     else if (eventType == EventType.EndRed)
     {
         // check to see that the last event was not a change to red end
         if (redEndY == 0)
         {
             if (startTime != DateTime.MinValue && YellowClearanceEvent != DateTime.MinValue &&
                 RedEvent != DateTime.MinValue && RedClearanceEvent != DateTime.MinValue)
             {
                 redEndY     = (timeStamp - startTime).TotalSeconds;
                 redEndEvent = timeStamp;
                 status      = NextEventResponse.GroupComplete;
                 endTime     = timeStamp;
             }
             //flag the group as bad data
             else
             {
                 status = NextEventResponse.GroupMissingData;
             }
         }
         //keep processing
         else
         {
             status = NextEventResponse.GroupOK;
         }
     }
     //keep processing
     else
     {
         status = NextEventResponse.GroupOK;
     }
 }