private void checkBoxAutoMode_CheckedChanged(object sender, EventArgs e) { CheckBox CB = (CheckBox)sender; if (CB.Checked) { ButtonWHMessungStart.Enabled = false; //WH Messung ist nicht erlaubt ButtonWHMessungStop.Enabled = false; for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) //Beendet alle Wh Messungen { Arduino.Datensatz168p[i].WhMessungAn = false; } for (int i = 1; i <= Arduino.Datensatz168p.Count(); i++) { Thread.Sleep(300); Arduino.Send_Komando(PassivBMS.Parameter(i)); } Thread.Sleep(200); BWStop = true; if (!StatusWorker.IsBusy) { StatusWorker.RunWorkerAsync(); } Thread.Sleep(500); AutoModeWorker.RunWorkerAsync(); } else { ButtonWHMessungStart.Enabled = true; ButtonWHMessungStop.Enabled = true; AutoModeWorker.CancelAsync(); } }
private void tabPage3_Enter(object sender, EventArgs e) { BWStop = true; if (BWeinmal) { for (int i = 1; i <= Arduino.Datensatz168p.Count(); i++) { Thread.Sleep(300); Arduino.Send_Komando(PassivBMS.Parameter(i)); } Thread.Sleep(200); BWeinmal = false; int j = Arduino.Datensatz168p.Count;// Anzahl von Geräten for (int i = 1; i <= j; i++) { ChartAkkuzellen.Series["Akkuzellen"].Points.AddXY(i, 3.0); ChartAkkuzellen.Series["Akkuzellen"].Points[i - 1].IsValueShownAsLabel = true; ChartAkkuzellen.Series["Akkuzellen"].Points[i - 1].Font = new Font(FontFamily.GenericSansSerif, 20.0F, FontStyle.Regular, GraphicsUnit.Pixel); } } if (!StatusWorker.IsBusy) { StatusWorker.RunWorkerAsync(); } }
public void EventHandlerAliveWorker(object sender, DoWorkEventArgs e) { for (int i = 1; i <= Arduino.Datensatz168p.Count(); i++) { Arduino.Send_Komando(PassivBMS.BMStoString(i) + ",alive,:X"); System.Threading.Thread.Sleep(2000); } }
private void ButtonLaden_Click(object sender, EventArgs e) { int j = Arduino.Datensatz168p.Count;// Anzahl von Geräten for (int i = 1; i <= j; i++) { Arduino.Send_Komando(PassivBMS.Parameter(i)); Thread.Sleep(500); } }
private void Sync_Click(object sender, EventArgs e) { int j = Arduino.Datensatz168p.Count;// Anzahl von Geräten for (int i = 1; i <= j; i++) { Arduino.Send_Komando(PassivBMS.Sync(i)); Thread.Sleep(300); } }
public void EventHandlerStatusWorker(object sender, DoWorkEventArgs e) { int j = Arduino.Datensatz168p.Count;// Anzahl von Geräten for (int i = 1; i <= j; i++) { Arduino.Send_Komando(PassivBMS.Status(i)); Thread.Sleep(200); } }
void EventHandlerConnect(object sender, ThresholdReachedEventArgs e) { if (e.Verbunden) { for (int i = 1; i <= Arduino.Datensatz168p.Count(); i++) { Thread.Sleep(300); Arduino.Send_Komando(PassivBMS.Parameter(i)); } Thread.Sleep(200); } }
private void CheckBoxMosfet_CheckedChanged(object sender, EventArgs e) { CheckBox isONorOFF = (CheckBox)sender; if (isONorOFF.Checked) { Arduino.Send_Komando(PassivBMS.Mosfet(comboBoxAuswahl.Text, true)); } else { Arduino.Send_Komando(PassivBMS.Mosfet(comboBoxAuswahl.Text, false)); } }
private void ButtonSpeichern_Click(object sender, EventArgs e)//Nur die Änderungen werden übertragen an den jeweiligen Kontroller { if (TextBoxmvinRef.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].mvinRef)) { Arduino.Send_Komando(PassivBMS.mvinRef(comboBoxAuswahl.Text, TextBoxmvinRef.Text)); Thread.Sleep(300); } if (TextBoxaref.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].aref)) { Arduino.Send_Komando(PassivBMS.aRef(comboBoxAuswahl.Text, TextBoxaref.Text)); Thread.Sleep(300); } if (TextBoxrLast.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].rLast)) { Arduino.Send_Komando(PassivBMS.rLast(comboBoxAuswahl.Text, TextBoxrLast.Text)); Thread.Sleep(300); } if (TextBoxmaxALast.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].maxALast)) { Arduino.Send_Komando(PassivBMS.maxALast(comboBoxAuswahl.Text, TextBoxmaxALast.Text)); Thread.Sleep(300); } if (TextBoxvinRef.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vinRef)) { Arduino.Send_Komando(PassivBMS.vinRef(comboBoxAuswahl.Text, TextBoxvinRef.Text)); Thread.Sleep(300); } if (TextBoxvmin.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vmin)) { Arduino.Send_Komando(PassivBMS.vmin(comboBoxAuswahl.Text, TextBoxvmin.Text)); Thread.Sleep(300); } if (TextBoxvmax.Text != Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vmax)) { Arduino.Send_Komando(PassivBMS.vmax(comboBoxAuswahl.Text, TextBoxvmax.Text)); Thread.Sleep(300); } Arduino.Send_Komando(PassivBMS.Parameter(comboBoxAuswahl.Text.Replace(",", "."))); Thread.Sleep(300);//Läde die Daten neu TextBoxmvinRef.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].mvinRef); TextBoxaref.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].aref); TextBoxrLast.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].rLast); TextBoxmaxALast.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].maxALast); TextBoxvinRef.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vinRef); TextBoxvmin.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vmin); TextBoxvmax.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(comboBoxAuswahl.Text) - 1].vmax); }
public void EventHandlerAutoModeWorkerFetig(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { // Fehler } for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) { if (Arduino.Datensatz168p[i].mFet)// Deaktiviert alle Mosfets damit diese nicht an bleiben { Arduino.Datensatz168p[i].mFet = false; Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, false)); System.Threading.Thread.Sleep(50); } } }
public void EventHandlerAutoModeWorker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; int k = 0; double summe = 0; double ergebnis = 0; double abweichung = 0.01; while (!worker.CancellationPending) { summe = 0; k = 0; ergebnis = 0; System.Threading.Thread.Sleep(1000); for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) { summe += Arduino.Datensatz168p[i].vin; k++; } ergebnis = summe / k; for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) { if (Arduino.Datensatz168p[i].vin - ergebnis > abweichung) { if (!Arduino.Datensatz168p[i].mFet) { Arduino.Datensatz168p[i].mFet = true; Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, true)); System.Threading.Thread.Sleep(100); } } else { if (Arduino.Datensatz168p[i].mFet) { Arduino.Datensatz168p[i].mFet = false; Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, false)); System.Threading.Thread.Sleep(100); } } } } }
public void EventHandlerWHMessungWorker(object sender, DoWorkEventArgs e) { for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) { if (Arduino.Datensatz168p[i].WhMessungAn)//Messung für den Datensatz ist nicht an { Arduino.Send_Komando(PassivBMS.WhMessung(i + 1)); System.Threading.Thread.Sleep(1000); if (Arduino.Datensatz168p[i].WHMessungAnzahl > 2)// Erst ab den dritten Dattensatz beginng die Messung { if (Arduino.Datensatz168p[i].Whtime != Arduino.Datensatz168p[i].time) { deltT = Convert.ToDouble(Arduino.Datensatz168p[i].Whtime - Arduino.Datensatz168p[i].time); Arduino.Datensatz168p[i].WhMessungErgebnis += deltT * Arduino.Datensatz168p[i].vin * Arduino.Datensatz168p[i].alast / 1000 / 60 / 60;//Umrechung in Wh Arduino.Datensatz168p[i].Whtime = Arduino.Datensatz168p[i].time; Arduino.Datensatz168p[i].WhMessung.Add(Convert.ToString(deltT) + "," + Convert.ToString(Arduino.Datensatz168p[i].vin) + "," + Convert.ToString(Arduino.Datensatz168p[i].alast)); Arduino.Datensatz168p[i].Whtime = Arduino.Datensatz168p[i].time; } } else { Arduino.Datensatz168p[i].WhMessungMessungVinStart = Arduino.Datensatz168p[i].vin; Arduino.Datensatz168p[i].Whtime = Arduino.Datensatz168p[i].time; } Arduino.Datensatz168p[i].WHMessungAnzahl++; } else { if (Arduino.Datensatz168p[i].mFet) { Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, false)); Arduino.Datensatz168p[i].mFet = false; } } if (Arduino.Datensatz168p[i].fehler)//Bricht die Messung ab da ein Fehler aufgetreten ist { Thread.Sleep(1000); Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, false)); Arduino.Datensatz168p[i].mFet = false; break; } } }
private void ButtonWHMessungStart_Click(object sender, EventArgs e) { utcDate = DateTime.UtcNow; utcDate = utcDate.AddHours(2.0); Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].mFet = true; Arduino.Send_Komando(PassivBMS.Mosfet(AuswahlBMS, true)); Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungAn = true; Arduino.Send_Komando(PassivBMS.WhMessung(AuswahlBMS)); Thread.Sleep(300); Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungStartzeit = utcDate; TextBoxWhMessungZeitStart.Text = Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungStartzeit.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")); Thread.Sleep(100); TextBoxWhMessungVinStart.Text = ""; TextBoxWhMessungZeitEnde.Text = ""; TextBoxWhMessungVinEnde.Text = ""; TextBoxWhMessungAnzahl.Text = ""; TextBoxWhMessung.Text = ""; Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WHMessungAnzahl = 0; if (!WHMessungWorker.IsBusy)// WH messung läuft bereits und kann nicht zweimal gestartet werden Alle Messungen müssen vorher beenden werden { WHMessungWorker.RunWorkerAsync(); } }
public void EventHandlerWHMessungWorkerFetig(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { // Fehler } int abbrechen = 0; TextBoxWhMessungAnzahl.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessung.Count()); TextBoxWhMessung.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungErgebnis); Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungEndezeit = DateTime.UtcNow; Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungEndezeit.AddHours(2.0); TextBoxWhMessungZeitEnde.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungEndezeit); Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungMessungVinEnde = Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].vin; TextBoxWhMessungVinEnde.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].vin); TextBoxWhMessungVinStart.Text = Convert.ToString(Arduino.Datensatz168p[Convert.ToInt32(AuswahlBMS) - 1].WhMessungMessungVinStart); for (int i = 0; i < Arduino.Datensatz168p.Count(); i++) { if (Arduino.Datensatz168p[Convert.ToInt32(i)].WhMessungAn) { abbrechen++; } else { if (Arduino.Datensatz168p[Convert.ToInt32(i)].mFet) { Arduino.Send_Komando(PassivBMS.Mosfet(i + 1, false)); Arduino.Datensatz168p[i].mFet = false; } } } if (abbrechen != 0)//Bricht den Background Worker ab wenn keine Messungen meher an sind { WHMessungWorker.RunWorkerAsync(); } }