public TemperatureHistory() { Main.conn.eventTempHistory += addNotify; history = new TemperatureList(); history.maxTime = DateTime.UtcNow.Ticks; history.minTime = history.maxTime - 36000000000; hourHistory = null; lists = new LinkedList <TemperatureList>(); currentHour = -1; currentHistory = history; setupColor(); /* NSUserDefaults *d = NSUserDefaults.standardUserDefaults; * NSArray *arr = [NSArray arrayWithObjects:@"tempBackgroundColor", * @"tempGridColor",@"tempAxisColor",@"tempFontColor", * @"tempExtruderColor",@"tempAvgExtruderColor", * @"tempBedColor",@"tempAvgBedColor",@"tempTargetExtruderColor",@"tempTargetBedColor", * @"tempOutputColor",@"tempAvgOutputColor", * @"tempShowExtruder",@"tempShowAverage",@"tempShowBed",@"tempAutoscroll", * @"tempShowOutput",@"tempShowTarget",@"tempZoomLevel", * @"tempAverageSeconds",@"tempExtruderWidth",@"tempAvgExtruderWidth", * @"tempTargetExtruderWidth",@"tempBedWidth",@"tempAvgBedWidth", * @"tempTargetBedWidth",@"tempAvgOutputWidth", * nil]; * bindingsArray = arr.retain; * zoomLevel = [[NSArray arrayWithObjects:[NSNumber numberWithDouble:3600], * [NSNumber numberWithDouble:1800], * [NSNumber numberWithDouble:900],[NSNumber numberWithDouble:300], * [NSNumber numberWithDouble:100],[NSNumber numberWithDouble:60], * nil] retain]; */ xpos = 100; // for(NSString *key in arr) // [d addObserver:self forKeyPath:key options:NSKeyValueObservingOptionNew context:NULL]; ToolStripMenuItem item = new ToolStripMenuItem(Trans.T("L_PAST_60_MINUTES"), null, Main.main.selectTimePeriod); item.Tag = 0; lists.AddLast(history); Main.main.timeperiodMenuItem.DropDownItems.Add(item); CurrentPos = 0; }
public void addNotify(TemperatureEntry ent) { history.entries.AddLast(ent); // Remove old entries long time = DateTime.UtcNow.Ticks; long ltime = (long)time; long lhour = ltime / 36000000000; double mintime = time - 36000000000; while (history.entries.First.Value.time < mintime) history.entries.RemoveFirst(); // Create average values int nExtruder = 0, nBed = 0, nOut = 0; float sumExtruder = 0, sumBed = 0, sumOutput = 0; mintime = DateTime.UtcNow.Ticks - avgPeriod * 10000000; foreach (TemperatureEntry e in history.entries) { if (e.time < mintime) continue; if (e.extruder > -1000) { nExtruder++; sumExtruder += e.extruder; } if (e.bed > -1000) { nBed++; sumBed += e.bed; } if (e.output > -1000) { nOut++; sumOutput += e.output; } } if (nExtruder > 0) ent.avgExtruder = sumExtruder / (float)nExtruder; if (nBed > 0) ent.avgBed = sumBed / (float)nBed; if (nOut > 0) ent.avgOutput = sumOutput / (float)nOut; history.maxTime = time; history.minTime = time - 36000000000; if (lhour != currentHour) { currentHour = lhour; DateTime now = DateTime.Now; string stime = now.ToString("MMMM dd, HH"); ToolStripMenuItem item = new ToolStripMenuItem(stime,null, Main.main.selectTimePeriod); item.Tag = lists.Count; hourHistory = new TemperatureList(); hourHistory.minTime = lhour * 36000000000; hourHistory.maxTime = hourHistory.minTime + 36000000000; lists.AddLast(hourHistory); Main.main.timeperiodMenuItem.DropDownItems.Add(item); } hourHistory.entries.AddLast(ent); if (Main.main.tabControlView.SelectedIndex == 1) Main.main.tabPageTemp.Refresh(); }
public TemperatureHistory() { Main.conn.eventTempHistory += addNotify; history = new TemperatureList(); history.maxTime = DateTime.UtcNow.Ticks; history.minTime = history.maxTime - 36000000000; hourHistory = null; lists = new LinkedList<TemperatureList>(); currentHour = -1; currentHistory = history; setupColor(); /* NSUserDefaults *d = NSUserDefaults.standardUserDefaults; NSArray *arr = [NSArray arrayWithObjects:@"tempBackgroundColor", @"tempGridColor",@"tempAxisColor",@"tempFontColor", @"tempExtruderColor",@"tempAvgExtruderColor", @"tempBedColor",@"tempAvgBedColor",@"tempTargetExtruderColor",@"tempTargetBedColor", @"tempOutputColor",@"tempAvgOutputColor", @"tempShowExtruder",@"tempShowAverage",@"tempShowBed",@"tempAutoscroll", @"tempShowOutput",@"tempShowTarget",@"tempZoomLevel", @"tempAverageSeconds",@"tempExtruderWidth",@"tempAvgExtruderWidth", @"tempTargetExtruderWidth",@"tempBedWidth",@"tempAvgBedWidth", @"tempTargetBedWidth",@"tempAvgOutputWidth", nil]; bindingsArray = arr.retain; zoomLevel = [[NSArray arrayWithObjects:[NSNumber numberWithDouble:3600], [NSNumber numberWithDouble:1800], [NSNumber numberWithDouble:900],[NSNumber numberWithDouble:300], [NSNumber numberWithDouble:100],[NSNumber numberWithDouble:60], nil] retain]; */ xpos = 100; // for(NSString *key in arr) // [d addObserver:self forKeyPath:key options:NSKeyValueObservingOptionNew context:NULL]; ToolStripMenuItem item = new ToolStripMenuItem(Trans.T("L_PAST_60_MINUTES"),null,Main.main.selectTimePeriod); item.Tag = 0; lists.AddLast(history); Main.main.timeperiodMenuItem.DropDownItems.Add(item); CurrentPos = 0; }
public void addNotify(TemperatureEntry ent) { history.entries.AddLast(ent); // Remove old entries long time = DateTime.UtcNow.Ticks; long ltime = (long)time; long lhour = ltime / 36000000000; double mintime = time - 36000000000; while (history.entries.First.Value.time < mintime) { history.entries.RemoveFirst(); } // Create average values int nExtruder = 0, nBed = 0, nOut = 0; float sumExtruder = 0, sumBed = 0, sumOutput = 0; mintime = DateTime.UtcNow.Ticks - avgPeriod * 10000000; foreach (TemperatureEntry e in history.entries) { if (e.time < mintime) { continue; } if (e.extruder > -1000) { nExtruder++; sumExtruder += e.extruder; } if (e.bed > -1000) { nBed++; sumBed += e.bed; } if (e.output > -1000) { nOut++; sumOutput += e.output; } } if (nExtruder > 0) { ent.avgExtruder = sumExtruder / (float)nExtruder; } if (nBed > 0) { ent.avgBed = sumBed / (float)nBed; } if (nOut > 0) { ent.avgOutput = sumOutput / (float)nOut; } history.maxTime = time; history.minTime = time - 36000000000; if (lhour != currentHour) { currentHour = lhour; DateTime now = DateTime.Now; string stime = now.ToString("MMMM dd, HH"); ToolStripMenuItem item = new ToolStripMenuItem(stime, null, Main.main.selectTimePeriod); item.Tag = lists.Count; hourHistory = new TemperatureList(); hourHistory.minTime = lhour * 36000000000; hourHistory.maxTime = hourHistory.minTime + 36000000000; lists.AddLast(hourHistory); Main.main.timeperiodMenuItem.DropDownItems.Add(item); } hourHistory.entries.AddLast(ent); if (Main.main.tabControlView.SelectedIndex == 1) { Main.main.tabPageTemp.Refresh(); } }