public DeltaSolSample(ResolVBus.DeltaSolData data) { this.temp1 = data.TemperatureSensor1; this.temp2 = data.TemperatureSensor2; this.temp3 = data.TemperatureSensor3; this.pump = data.Pump; }
public void Acquire() { try { ResolVBus.Frame[] frames = this.port.ReceiveFrames(); if ((frames != null) && (frames.Length > 0)) { ResolVBus.DeltaSolData data = new ResolVBus.DeltaSolData(frames); this.Publish(data); } } catch { this.deltaSolData = null; } }
private static void DumpDeltaSol() { ResolVBus.Port resol = new ResolVBus.Port("COM4"); ResolVBus.DeltaSolData deltaSol = new ResolVBus.DeltaSolData(resol.ReceiveFrames()); System.Console.Out.WriteLine("DeltaSol: {5} {0}°C, {1}°C, {2}°C, {3}%, {4}h", deltaSol.TemperatureSensor1, deltaSol.TemperatureSensor2, deltaSol.TemperatureSensor3, deltaSol.Pump, deltaSol.TotalPumpTime, System.DateTime.Now.ToShortTimeString()); }
public void RunThread() { try { System.Threading.Thread.Sleep(Settings.Default.PollInterval * 1000); while (true) { try { MaxComm.SolarMaxData solarMaxData1 = this.maxComm.SolarMaxData1; MaxComm.SolarMaxData solarMaxData2 = this.maxComm.SolarMaxData2; ResolVBus.DeltaSolData deltaSolData = this.resol.DeltaSolData; // TODO: store resulting data... System.Console.WriteLine(System.DateTime.Now.ToShortTimeString()); if (deltaSolData != null) { lock (this.exclusion) { this.deltaSolSamples.Add(new Data.DeltaSolSample(deltaSolData)); while (this.deltaSolSamples.Count > Settings.Default.LogSampleCount) { this.deltaSolSamples.RemoveAt(0); } } System.Console.WriteLine("DeltaSol: {0}°C, {1}°C, {2}°C, {3}%, {4}h", deltaSolData.TemperatureSensor1, deltaSolData.TemperatureSensor2, deltaSolData.TemperatureSensor3, deltaSolData.Pump, deltaSolData.TotalPumpTime); } else { lock (this.exclusion) { if (this.deltaSolSamples.Count > 0) { this.deltaSolSamples.RemoveAt(0); } } } if (solarMaxData1 != null) { lock (this.exclusion) { this.solarMaxSamples1.Add(new Data.SolarMaxSample(solarMaxData1)); while (this.solarMaxSamples1.Count > Settings.Default.LogSampleCount) { this.solarMaxSamples1.RemoveAt(0); } } System.Console.WriteLine("SolarMax{0}: {1}W, DC: {2}V {3}A, AC: {4}V {5}A", solarMaxData1.Id, solarMaxData1.PowerAC, solarMaxData1.VoltageDC, solarMaxData1.CurrentDC, solarMaxData1.VoltageAC, solarMaxData1.CurrentAC); } else { lock (this.exclusion) { if (this.solarMaxSamples1.Count > 0) { this.solarMaxSamples1.RemoveAt(0); } } } if (solarMaxData2 != null) { lock (this.exclusion) { this.solarMaxSamples2.Add(new Data.SolarMaxSample(solarMaxData2)); while (this.solarMaxSamples2.Count > Settings.Default.LogSampleCount) { this.solarMaxSamples2.RemoveAt(0); } } System.Console.WriteLine("SolarMax{0}: {1}W, DC: {2}V {3}A, AC: {4}V {5}A", solarMaxData2.Id, solarMaxData2.PowerAC, solarMaxData2.VoltageDC, solarMaxData2.CurrentDC, solarMaxData2.VoltageAC, solarMaxData2.CurrentAC); } else { lock (this.exclusion) { if (this.solarMaxSamples2.Count > 0) { this.solarMaxSamples2.RemoveAt(0); } } } } catch { } System.Threading.Thread.Sleep(System.Math.Max(Settings.Default.LogInterval, 10) * 1000); } } catch (System.Threading.ThreadInterruptedException) { } }
private void Publish(ResolVBus.DeltaSolData data) { this.deltaSolData = data; }