public override String ToString() { if (TimerArray == null) { return ""; } StringBuilder sb = new StringBuilder(); List<int> temp = new List<int>(TimerArray); temp.Sort(); for (int i = 1; i <= temp.Count; i++) { int timerId = temp[i - 1]; int j = TimerArray.IndexOf(timerId) + 1; sb.AppendLine("clock" + timerId + ":[" + Matrix[0][j]*-1 + "," + (Matrix[j][0] == int.MaxValue ? Constants.INFINITE : Matrix[j][0].ToString()) + "];"); } return sb.ToString(); }
/// <summary> /// Return the next avaiable TimerID /// Old timer ID can be reused if possible /// </summary> /// <returns></returns> public int GetNewTimerID() { if (TimerArray == null) { return 1; } int dimention = TimerArray.Count; if (TimedRefinementAssertion) { for (int k = 1; k <= dimention; k++) { if (Matrix[k][0] == 0 && Matrix[0][k] == 0 && TimerArray[k - 1] != 1) { return TimerArray[k - 1]; } } } else { for (int k = 1; k <= dimention; k++) { if (Matrix[k][0] == 0 && Matrix[0][k] == 0) { return TimerArray[k - 1]; } } } List<int> temp = new List<int>(TimerArray); temp.Sort(); int timerCounter = 1; foreach (int i in temp) { if (i > timerCounter) { break; } timerCounter++; } Contract.Assert(timerCounter > 0, "Get New Timer ID Failure"); return timerCounter; }