/// <summary> /// The guest clock will always be synchronized to UTC when booted /// The guest clock will be synchronized to the host's configured timezone when booted /// (Not Implemented) The guest clock will be synchronized to the requested timezone using the timezone attribute /// (Not Implement) The guest clock will have an arbitrary offset applied relative to UTC or localtime, depending on the basis attribute. The delta relative to UTC (or localtime) is specified in seconds, using the adjustment attribute. /// </summary> /// <param name="offset"></param> public void setClockOffset(ClockTime offset) { if (offset == ClockTime.timezone || offset == ClockTime.variable) { throw new ArgumentException(offset.ToString() + " Is not implemented"); } ClockTime _ClockOffset = offset; }
/// <summary> /// Returns a string representation. /// </summary> /// <returns></returns> public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); sb.AppendLine("Real world time: " + realWorldTime.ToString()); sb.AppendLine("Sim time: " + simTime.ToString()); sb.AppendLine("Request ID: " + requestID.ToString()); return(sb.ToString()); }
/// <summary> /// Returns a string representation. /// </summary> /// <returns></returns> public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); sb.AppendLine("Real world time: " + realWorldTime.ToString()); sb.AppendLine("Reason: " + reason.ToString()); sb.AppendLine("Frozen behavior: " + frozenBehavior.ToString()); sb.AppendLine("Request ID: " + requestID.ToString()); return(sb.ToString()); }
private DataTable GenerateTasks(ClockTime startTime, ClockTime stopTime, ClockTimeInterval interval, List <DayOfWeek> IncludedDays) { DataTable task = GetTasksDataTable(); ClockTime clockTime = new ClockTime(); foreach (var day in IncludedDays) { clockTime.Hour = startTime.Hour; clockTime.Minute = startTime.Minute; while (clockTime != stopTime) { task.Rows.Add(day, clockTime.ToString(), null); clockTime.AddInterval(interval); } } return(task); }
private DataTable ExtractTask(DayOfWeek firstDay, ClockTime startTime, ClockTime stopTime, ClockTimeInterval interval, DataTable taskSample) { DataTable task = new DataTable(); #region columns definition List <string> IncludedDaysSample = (taskSample.AsEnumerable().Select(x => x["Task_Day"].ToString()).Distinct().ToList()); List <DayOfWeek> IncludedDays = IncludedDaysSample.ConvertAll(new Converter <string, DayOfWeek>(StringToDayOfWeek)); ChangeWeekDaysOrder(IncludedDays, firstDay); task.Columns.AddRange(IncludedDays.ConvertAll(new Converter <DayOfWeek, DataColumn>(DayOfWeekToDataColumn)).ToArray()); #endregion #region table values definition List <object> DataRowEquivalent = new List <object>(); ClockTime clockTime = new ClockTime(startTime.Hour, startTime.Minute); while (clockTime != stopTime) { DataRow[] dataRows = taskSample.Select($"Task_Time = '{clockTime.ToString()}'"); foreach (DataColumn dataColumn in task.Columns) { foreach (DataRow dataRow in dataRows) { if (dataColumn.ColumnName == dataRow["Task_Day"].ToString()) { DataRowEquivalent.Add(dataRow["TaskType_Name"]); break; } } } task.Rows.Add(DataRowEquivalent.ToArray()); DataRowEquivalent.Clear(); clockTime.AddInterval(interval); } #endregion return(task); }
//Synchronize hour with server private void ServerConnection_MessageDateTime(object sender, ProtocolMessageEventArgs <DateTimeMessage> e) { AssignTimeAndFactor(e.Message.TimeFactor, e.Message.DateTime); logger.Info("Received Server date time for syncing : {0}, local time was : {1}", e.Message.DateTime, ClockTime.ToString()); }
private void CreatePlanner(Participant participant, string plannerName, DayOfWeek firstDay, List <DayOfWeek> IncludedDays, string startTimeSample, string stopTimeSample, string intervalSample) { if (plannerName.Length != 0 && startTimeSample.Length != 0 && stopTimeSample.Length != 0 && intervalSample.Length != 0) { if (!ExtractPlanners(DbAdapter.GetPlanners(this.Participant.Name)).Contains(plannerName)) { if (IsTimeFormatCorrect(startTimeSample) && IsTimeFormatCorrect(stopTimeSample) && IsTimeFormatCorrect(intervalSample)) { ClockTime startTime = ExtractClockTime(startTimeSample); ClockTime stopTime = ExtractClockTime(stopTimeSample); ClockTimeInterval interval = ExtractClockTimeInterval(intervalSample); if (IsTimeOverlap(startTime, stopTime, interval)) { try { DataTable task = GenerateTasks(startTime, stopTime, interval, IncludedDays); DbAdapter.CreatePlanner(participant.Name, plannerName, firstDay.ToString(), startTime.ToString(), stopTime.ToString(), interval.ToString(), task); AdjustPlannerListBox(); OpenPlanner(participant, plannerName); } catch (Exception exception) { MessageBox.Show(exception.Message); } } else { MessageBox.Show($"Cannot create planner of given time values"); } } else { MessageBox.Show("Time values must be expressed as hh:mm"); } } else { MessageBox.Show($"Planner {plannerName} already exists"); } } else { MessageBox.Show("All fields must be non-empty"); } }