/// <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;
 }
Exemple #2
0
 /// <summary>
 /// Returns the clock time for an UTC time.
 /// </summary>
 /// <param name="utcTime">The UTC time.</param>
 /// <returns>The clock time for the specified UTC time.</returns>
 /// <exception cref="System.ArgumentNullException">The UTC time is null.</exception>
 /// <exception cref="System.ArgumentException">The specified time is not an UTC time.</exception>
 public ClockTime TransformToClockTime(ClockTime utcTime) 
 {
     if (utcTime == null)
         throw new ArgumentNullException("utcTime", "The UTC time is null.");
     if (!utcTime.ReferenceSystem.Equals(Clocks.UTC))
         throw new ArgumentException("The specified time is not an UTC time.", "utcTime");
     return new ClockTime(utcTime.Instant + Offset, this, null);
 }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     healthBar   = GameObject.FindGameObjectWithTag("HpBar");
     targetPanel = GameObject.FindGameObjectWithTag("TargetPanel");
     MyImage     = GameObject.FindGameObjectWithTag("MyImage");
     clock       = GameObject.FindGameObjectWithTag("Clock").GetComponent <ClockTime>();
     DisableTextBox();
 }
Exemple #4
0
 /// <summary>
 /// Returns the UTC time for a clock time.
 /// </summary>
 /// <param name="clockTime">The clock time.</param>
 /// <returns>The UTC time for the specified clock time.</returns>
 /// <exception cref="System.ArgumentNullException">The clock time is null.</exception>
 /// <exception cref="System.ArgumentException">The specified time is not referenced in the current clock.</exception>
 public ClockTime TransformToUTCTime(ClockTime clockTime)
 {
     if (clockTime == null)
         throw new ArgumentNullException("clockTime", "The clock time is null.");
     if (!clockTime.ReferenceSystem.Equals(this))
         throw new ArgumentException("The specified time is not referenced in the current clock.", "clockTime");
     return new ClockTime(clockTime.Instant - Offset, this, null);
 }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
#if (UNITY_ANDROID || UNITY_IPHONE)
        Application.targetFrameRate = 30;
#endif

        clock    = GameObject.FindGameObjectWithTag("Clock").GetComponent <ClockTime>();
        tutorial = GameObject.Find("Tutorial").GetComponent <Tutorial>();
    }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Clock" /> class.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="remarks">The remarks.</param>
        /// <param name="aliases">The aliases.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="basis">The basis.</param>
        /// <param name="referenceEvent">The reference event.</param>
        /// <param name="referenceInstant">The reference instant.</param>
        /// <param name="offset">The offset.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The identifier is null.
        /// or
        /// The calendar basis is null.
        /// </exception>
        public Clock(String identifier, String name, String remarks, String[] aliases, String scope, Calendar basis, String referenceEvent, Instant referenceInstant, Duration offset)
            : base(identifier, name, remarks, aliases, scope) 
        {
            if (basis == null)
                throw new ArgumentNullException("basis", "The calendar basis is null.");

            CalendarBasis = basis;
            ReferenceEvent = referenceEvent;
            ReferenceTime = new ClockTime(referenceInstant, this, null);
            Offset = offset;
        }
Exemple #7
0
 // Use this for initialization
 void Start()
 {
     black       = GetComponent <Image>();
     black.color = new Color(0, 0, 0, 0);
     afternoon   = transform.FindChild("Background").FindChild("Afternoon").gameObject;
     morning     = transform.FindChild("Background").FindChild("Morning").gameObject;
     evening     = transform.FindChild("Background").FindChild("Evening").gameObject;
     night       = transform.FindChild("Background").FindChild("Night").gameObject;
     warning     = transform.FindChild("Background").FindChild("Warning").gameObject;
     npcManager  = GameObject.FindGameObjectWithTag("NPCManager").GetComponent <NPCManager>();
     clock       = GameObject.FindGameObjectWithTag("Clock").GetComponent <ClockTime>();
     Init();
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     npcList            = new List <GameObject>();
     responsibilityNpcs = new List <GameObject>();
     spawnPoint         = new Vector3(-790, 0, -22); //(-501, 0, 951);
     spawnTime          = 5;
     usedIds            = new List <string>();
     invObj             = GameObject.Find("Inventory");
     database           = invObj.GetComponent <ItemDatabase>();
     clock    = GameObject.FindGameObjectWithTag("Clock").GetComponent <ClockTime>();
     tutorial = GameObject.Find("Tutorial").GetComponent <Tutorial>();
     heads    = GameObject.Find("Heads").GetComponent <Heads>();
 }
Exemple #9
0
            public override void Invoke()
            {
                var o = Order.Config;

                Execute(Order.Place(ClockTime.AddDays(Gamma.Sample(DefaultRS,
                                                                   Config.GracePeriod_Mean[o.Origin, o.Destination],
                                                                   Config.GracePeriod_CoeffVar[o.Origin, o.Destination])
                                                      )));
                Log("Demand Arrive [{0}] -> [{1}] {2}",
                    Order.Config.Origin, Order.Config.Destination, Order.ExpectedDeliveryTime);
                This.OrdersToAssign.Add(Order);
                Execute(new DispatchEvent());
            }
Exemple #10
0
        public Task <ClockTime> GetNowClockTime()
        {
            var utcNow = DateTime.UtcNow;
            var tzNow  = TimeZoneInfo.ConvertTimeFromUtc(utcNow, _timeZone);

            var clockTime = new ClockTime()
            {
                Now      = tzNow,
                TimeZone = _timeZone
            };

            return(Task.FromResult(clockTime));
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        private bool IsTimeOverlap(ClockTime startTime, ClockTime stopTime, ClockTimeInterval interval)
        {
            ClockTimeInterval differentialInterval = ClockTimeInterval.GetInterval(startTime, stopTime);

            while (true)
            {
                if (differentialInterval.Hour == 0 && differentialInterval.Minute == 0)
                {
                    return(true);
                }
                else if (differentialInterval.Hour < 0 || differentialInterval.Minute < 0)
                {
                    return(false);
                }
                differentialInterval.SubtractInterval(interval);
            }
        }
Exemple #13
0
 private Tools.Planner GetPlanner(Participant participant, string plannerName)
 {
     try
     {
         DataTable         plannerSample = DbAdapter.GetPlanner(participant.Name, plannerName);
         DayOfWeek         firstDay      = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), plannerSample.Rows[0]["Planner_FirstDay"].ToString());
         ClockTime         startTime     = ExtractClockTime(plannerSample.Rows[0]["Planner_StartTime"].ToString());
         ClockTime         stopTime      = ExtractClockTime(plannerSample.Rows[0]["Planner_StopTime"].ToString());
         ClockTimeInterval interval      = ExtractClockTimeInterval(plannerSample.Rows[0]["Planner_Interval"].ToString());
         DataTable         task          = ExtractTask(firstDay, startTime, stopTime, interval, DbAdapter.GetTask(participant.Name, plannerName));
         return(new Tools.Planner(participant, plannerName, firstDay, startTime, stopTime, interval, task));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #14
0
 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");
     }
 }
Exemple #15
0
        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);
        }
Exemple #16
0
        private Task[] CreateCounterTaskList2(NotificationBase notification)
        {
            List <Task> tasks = new List <Task>();

            if (notification is StartupNotification)
            {
                //2.--关于计数任务------------------------------------------------------------
                StartupNotification MyStartNotifi        = notification as StartupNotification;
                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "startup");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);

                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;
                tasks.Add(MyTaskCount);

                //2.--关于心跳任务------------------------------------------------------------
                TaskSubscribeAlive MyTaskAlive = new TaskSubscribeAlive();
                MyTaskAlive.task_type           = TaskType.TASK_ALIVE;
                MyTaskAlive.serverTask_ID       = 100;// GetTaskID;
                MyTaskAlive.activity_state      = true;
                MyTaskAlive.store_taskSpecified = true;
                MyTaskAlive.store_task          = true;

                Date MyDate = new Date();
                MyDate.kind = DateType.DATE_DONT_CARE;
                MyDate.day_of_monthSpecified = false;
                MyDate.day_of_weekSpecified  = false;

                ClockTime MyStartTime = new ClockTime();
                MyStartTime.hours   = 0;
                MyStartTime.minutes = 0;
                MyStartTime.seconds = 20;

                TimeTrigger MyTimeTrigger = new TimeTrigger();
                MyTimeTrigger.date          = MyDate;
                MyTimeTrigger.cycle         = "PT10M";
                MyTimeTrigger.random_offset = "PT0S";
                MyTimeTrigger.start         = MyStartTime;

                Trigger MyTrigger2 = new Trigger();
                MyTrigger2.Item     = MyTimeTrigger;
                MyTaskAlive.trigger = MyTrigger2;

                tasks.Add(MyTaskAlive);

                //-----------------------------------------------------------------------------
            }

            if (notification is AliveNotification)
            {
                StartupNotification MyStartNotifi = notification as StartupNotification;

                HellaAPCECOMannager MyHellaAPCECOManager = new HellaAPCECOMannager();
                HellaApcHelper      MyHellaApcHelper     = new HellaApcHelper(MyStartNotifi.customer_ID, "keepalive");
                uint GetTaskID = HellaApcHelper.DoUpdateWork(MyHellaAPCECOManager, MyHellaApcHelper);


                TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

                MyTaskCount.task_type           = TaskType.TASK_COUNT;
                MyTaskCount.serverTask_ID       = GetTaskID; //1000;
                MyTaskCount.activity_state      = true;
                MyTaskCount.store_taskSpecified = true;
                MyTaskCount.store_task          = true;

                CountingGateID MyCountingGateID = new CountingGateID();
                MyCountingGateID.id          = "10";
                MyTaskCount.counting_gate_id = MyCountingGateID;

                CountEvent MyCountEvent = new CountEvent();
                MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;

                EventTrigger MyEventTrigger = new EventTrigger();
                MyEventTrigger.Item = MyCountEvent;

                Trigger MyTrigger = new Trigger();
                MyTrigger.Item = MyEventTrigger;

                MyTaskCount.trigger = MyTrigger;

                tasks.Add(MyTaskCount);
            }

            return(tasks.ToArray());
        }
Exemple #17
0
 public Schedule(ClockTime departure, ClockTime arrival)
 {
     _departure = departure;
     _arrival   = arrival;
 }
Exemple #18
0
 public static int ClockTimeToSecond(ClockTime clockTime)
 {
     return(clockTime.hour * 3600 + clockTime.minute * 60 + clockTime.second);
 }
		public void Additions()
		{
			var obj = new ClockTime(0, 23, 59);
			var temp = obj.Add(24);
			Assert.AreEqual(new ClockTime(0, 23, 59), temp);
		}
		public void Comparison()
		{
			var left = new ClockTime(0, 0, 0);
			var right = new ClockTime(0, 0, 1);
			Assert.IsTrue(left < right);
		}
		public void Equality()
		{
			var left = new ClockTime(0, 0, 0);
			var right = new ClockTime(0, 0, 0);
			Assert.AreEqual(left, right);
		}
		public void Invalid_Constructors()
		{
			try { var obj = new ClockTime(-1, 0, 0); Assert.Fail(); }
			catch (ArgumentException) { }
		}
Exemple #23
0
 //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 ScheduleMovie(Movie movie, ClockTime clockTime)
 {
 }
Exemple #25
0
        private Task[] CreateCounterTaskList3(uint mTaskid)
        {
            //启动时请求任务
            List <Task> tasks = new List <Task>();
            //2.--关于计数任务------------------------------------------------------------
            TaskSubscribeCounting MyTaskCount = new TaskSubscribeCounting();

            MyTaskCount.task_type           = TaskType.TASK_COUNT;
            MyTaskCount.serverTask_ID       = mTaskid;
            MyTaskCount.activity_state      = true;
            MyTaskCount.store_taskSpecified = true;
            MyTaskCount.store_task          = true;

            CountingGateID MyCountingGateID = new CountingGateID();

            MyCountingGateID.id          = "10";
            MyTaskCount.counting_gate_id = MyCountingGateID;

            CountEvent MyCountEvent = new CountEvent();

            MyCountEvent.count_event_type = CountEventType.COUNT_EVENT_DELTA_SUM_IN_OUT;
            MyCountEvent.delta            = 1;
            EventTrigger MyEventTrigger = new EventTrigger();

            MyEventTrigger.Item = MyCountEvent;

            Trigger MyTrigger = new Trigger();

            MyTrigger.Item = MyEventTrigger;

            MyTaskCount.trigger = MyTrigger;
            tasks.Add(MyTaskCount);

            //2.--关于心跳任务------------------------------------------------------------
            TaskSubscribeAlive MyTaskAlive = new TaskSubscribeAlive();

            MyTaskAlive.task_type           = TaskType.TASK_ALIVE;
            MyTaskAlive.serverTask_ID       = mTaskid;
            MyTaskAlive.activity_state      = true;
            MyTaskAlive.store_taskSpecified = true;
            MyTaskAlive.store_task          = true;

            Date MyDate = new Date();

            MyDate.kind = DateType.DATE_DONT_CARE;
            MyDate.day_of_monthSpecified = false;
            MyDate.day_of_weekSpecified  = false;

            ClockTime MyStartTime = new ClockTime();

            MyStartTime.hours   = 0;
            MyStartTime.minutes = 0;
            MyStartTime.seconds = 20;

            TimeTrigger MyTimeTrigger = new TimeTrigger();

            MyTimeTrigger.date          = MyDate;
            MyTimeTrigger.cycle         = "PT10M";
            MyTimeTrigger.random_offset = "PT0S";
            MyTimeTrigger.start         = MyStartTime;

            Trigger MyTrigger2 = new Trigger();

            MyTrigger2.Item     = MyTimeTrigger;
            MyTaskAlive.trigger = MyTrigger2;

            tasks.Add(MyTaskAlive);
            return(tasks.ToArray());
        }