private int count; // Each overturn will add to the count. // Build from json. public CycleCountTimer(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..."); CycleCount_TimerConfigure CCTC = Newtonsoft.Json.JsonConvert.DeserializeObject <CycleCount_TimerConfigure>(json); this.timerConfigure = CCTC; 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.limit = CCTC.limit - 1; this.count = CCTC.count; } }
public override void load(string path) { CycleCount_TimerConfigure cctc = new CycleCount_TimerConfigure(); string json; using (StreamReader sr = new StreamReader(path)) { json = sr.ReadToEnd(); Console.WriteLine("Read configure done."); cctc = JsonConvert.DeserializeObject <CycleCount_TimerConfigure>(json); this.startTime = cctc.startTime; this.endTime = cctc.endTime; this.originTimeSpan = cctc.originTimeSpan; this.expire = cctc.expire; this.endSig = false; this.alarm = cctc.alarm; this.pause = true; this.timerOption = cctc.timerOption; this.diffTimeSpan = cctc.diffTimeSpan; this.pauseTime = cctc.pauseTime; this.limit = cctc.limit; this.count = cctc.count; } }