Esempio n. 1
0
        public IntervalCycleTimer(string path = "./TimerConfig.json")
        {
            string json;

            using (StreamReader sr = new StreamReader(path))
            {
                json = sr.ReadToEnd();
                Console.WriteLine("Read configure done\n Now building the timer...");
                IntervalCycle_TimerConfigure ICTC = Newtonsoft.Json.JsonConvert.
                                                    DeserializeObject <IntervalCycle_TimerConfigure>(json);
                this.timerConfigure = ICTC;
                this.startTime      = this.timerConfigure.startTime;
                this.endTime        = this.timerConfigure.endTime;
                this.originTimeSpan = this.timerConfigure.originTimeSpan;
                this.expire         = this.timerConfigure.expire;
                this.endSig         = false;
                this.alarm          = this.timerConfigure.alarm;
                this.pause          = true;
                this.timerOption    = this.timerConfigure.timerOption;
                this.diffTimeSpan   = this.timerConfigure.diffTimeSpan;
                this.currentTime    = System.DateTime.Now;
                this.pauseTime      = this.timerConfigure.pauseTime;
                this.interval       = ICTC.interval;
                this.count          = ICTC.count;
                this.intervalSpan   = new System.TimeSpan(0, 0, this.interval);
            }
        }
Esempio n. 2
0
        public override void load(string path)
        {
            IntervalCycle_TimerConfigure ictc = new IntervalCycle_TimerConfigure();
            string json;

            using (StreamReader sr = new StreamReader(path))
            {
                json = sr.ReadToEnd();
                Console.WriteLine("Read configure done.");
                ictc                = JsonConvert.DeserializeObject <IntervalCycle_TimerConfigure>(json);
                this.startTime      = ictc.startTime;
                this.endTime        = ictc.endTime;
                this.originTimeSpan = ictc.originTimeSpan;
                this.expire         = ictc.expire;
                this.endSig         = false;
                this.alarm          = ictc.alarm;
                this.pause          = true;
                this.timerOption    = ictc.timerOption;
                this.diffTimeSpan   = ictc.diffTimeSpan;
                this.pauseTime      = ictc.pauseTime;
                this.interval       = ictc.interval;
                this.count          = ictc.count;
            }
        }