diff --git a/BerichtGen/Bericht.cs b/BerichtGen/Bericht.cs index 8324310..dd4a5d7 100644 --- a/BerichtGen/Bericht.cs +++ b/BerichtGen/Bericht.cs @@ -97,7 +97,7 @@ namespace BerichtGen } finally { - pdf.Dispose(); + //pdf.Dispose(); } } @@ -150,6 +150,7 @@ namespace BerichtGen if(args.FieldName == "UVImage") { string source = args.FieldValue.ToString(); + if (!File.Exists(source)) return; args.Image = Image.FromFile(source); } } diff --git a/KlassenBIB/InlinerSanierung.cs b/KlassenBIB/InlinerSanierung.cs index 0d78cd1..b87f453 100644 --- a/KlassenBIB/InlinerSanierung.cs +++ b/KlassenBIB/InlinerSanierung.cs @@ -23,6 +23,8 @@ namespace KlassenBIB double harzbedarf = 1.8; uint rueckholgeschwindigkeit = 24; bool geschlosseneEnde = false; + DateTime anfangAushaertung; + DateTime endeAushaertung; /// /// Gibt den kompletten Harzbedarf auf die Haltungslänge bezogen zurück @@ -88,6 +90,9 @@ namespace KlassenBIB {"UVImage","" } }; + double LaengeGesamt = this.Inspektionsobjekt.Haltungslaenge + this.Inspektionsobjekt.Schachtlaenge; + + grunddaten["AG_Vorname"] = ""; grunddaten["KLP_Nummer"] = ""; grunddaten["KLP_Datum"] = DateTime.Now.ToShortDateString(); @@ -113,19 +118,19 @@ namespace KlassenBIB grunddaten["KL_HD_true"] = ""; grunddaten["KL_mech_true"] = ""; grunddaten["KL_rob_true"] = ""; - grunddaten["KL_HD_date"] = ""; + grunddaten["KL_HD_date"] = this.Datum.HasValue ? this.Datum.Value.ToShortDateString() : ""; grunddaten["KL_Besatzung"] = ""; - grunddaten["liner_laenge"] = ""; + grunddaten["liner_laenge"] = LaengeGesamt; grunddaten["Charge_Liner"] = this.LinerChargenummer; grunddaten["Charge_Harz"] = this.HarzChargenummer; - grunddaten["harz_bedarf_m"] = ""; - grunddaten["gesamt_harz"] = ""; + grunddaten["harz_bedarf_m"] = harzbedarf; + grunddaten["gesamt_harz"] = LaengeGesamt * harzbedarf; grunddaten["temperatur_harz"] = this.HarzKalibrierTemperatur; grunddaten["datum_kalibrierung"] = this.DatumKalibrierung.ToShortDateString(); grunddaten["walzen_abstand"] = this.KalibierWalzenAbstand; grunddaten["vakuum"] = this.KalibrierUnterdruck; - grunddaten["time_start"] = ""; - grunddaten["time_ende"] = ""; + grunddaten["time_start"] = this.AnfangAushaertung; + grunddaten["time_ende"] = this.EndeAushaertung; grunddaten["UVImage"] = Path.Combine(destinationPath, "linerGraph.jpg"); return grunddaten; @@ -162,5 +167,7 @@ namespace KlassenBIB public double HarzBedarf { get => harzbedarf; set => harzbedarf = value; } public string HarzTyp { get => harzTyp; set => harzTyp = value; } public string LinerTyp { get => linerTyp; set => linerTyp = value; } + public DateTime AnfangAushaertung { get => anfangAushaertung; set => anfangAushaertung = value; } + public DateTime EndeAushaertung { get => endeAushaertung; set => endeAushaertung = value; } } } diff --git a/SanShared/ITemperature.cs b/SanShared/ITemperature.cs index b9dae5b..d7221f8 100644 --- a/SanShared/ITemperature.cs +++ b/SanShared/ITemperature.cs @@ -8,6 +8,6 @@ namespace SanShared { public interface ITemperature { - double GetTemperatur(); + double GetTemperatur(out string message); } } diff --git a/SanShared/SanShared.csproj b/SanShared/SanShared.csproj index 8eb78c6..cbece24 100644 --- a/SanShared/SanShared.csproj +++ b/SanShared/SanShared.csproj @@ -46,6 +46,7 @@ + \ No newline at end of file diff --git a/SanShared/UVcsvStrukture.cs b/SanShared/UVcsvStrukture.cs new file mode 100644 index 0000000..a7ff8e5 --- /dev/null +++ b/SanShared/UVcsvStrukture.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SanShared +{ + public class UVcsvStrukture + { + DateTime zeitstempel; + double temperatur; + double druck; + + public DateTime Zeitstempel { get => zeitstempel; set => zeitstempel = value; } + public double Temperatur { get => temperatur; set => temperatur = value; } + public double Druck { get => druck; set => druck = value; } + } +} diff --git a/SanSystem/HelpFunktion.cs b/SanSystem/HelpFunktion.cs new file mode 100644 index 0000000..8fe1415 --- /dev/null +++ b/SanSystem/HelpFunktion.cs @@ -0,0 +1,41 @@ +using SanShared; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SanSystem +{ + static class HelpFunktion + { + public static List ParseCSVFile(string csvFile) + { + List result = new List(); + + if (!File.Exists(csvFile)) return null; + string[] input = File.ReadAllLines(csvFile); + int counter = 0; + + DateTime zeit; + foreach (string pars in input) + { + UVcsvStrukture uVcsvStrukture = new UVcsvStrukture(); + string[] parts = pars.Split(','); + if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue; + DateTime.TryParse(parts[0], out zeit); + double temperatur = double.Parse(parts[1].Replace('.', ',')); + double druck = double.Parse(parts[2].Replace('.', ',')); + counter++; + + uVcsvStrukture.Zeitstempel = zeit; + uVcsvStrukture.Druck = druck; + uVcsvStrukture.Temperatur = temperatur; + result.Add(uVcsvStrukture); + } + + return result; + } + } +} diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index 0361ac6..d25791f 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -107,6 +107,7 @@ frmMain.cs + diff --git a/SanSystem/UCInliner.Designer.cs b/SanSystem/UCInliner.Designer.cs index e6b6bc8..359a77c 100644 --- a/SanSystem/UCInliner.Designer.cs +++ b/SanSystem/UCInliner.Designer.cs @@ -30,8 +30,7 @@ { this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.btn_create_graph = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); + this.btn_create_protokol = new System.Windows.Forms.Button(); this.ftpProgress = new System.Windows.Forms.ProgressBar(); this.btn_transfer_ftp = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); @@ -71,7 +70,6 @@ this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); - this.btn_create_protokol = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -94,8 +92,6 @@ // tabPage2 // this.tabPage2.Controls.Add(this.btn_create_protokol); - this.tabPage2.Controls.Add(this.btn_create_graph); - this.tabPage2.Controls.Add(this.button1); this.tabPage2.Controls.Add(this.ftpProgress); this.tabPage2.Controls.Add(this.btn_transfer_ftp); this.tabPage2.Controls.Add(this.label1); @@ -119,25 +115,15 @@ this.tabPage2.Text = "Vorraussetzungen"; this.tabPage2.UseVisualStyleBackColor = true; // - // btn_create_graph + // btn_create_protokol // - this.btn_create_graph.Location = new System.Drawing.Point(443, 487); - this.btn_create_graph.Name = "btn_create_graph"; - this.btn_create_graph.Size = new System.Drawing.Size(138, 67); - this.btn_create_graph.TabIndex = 32; - this.btn_create_graph.Text = "UVGraphic erzeugen"; - this.btn_create_graph.UseVisualStyleBackColor = true; - this.btn_create_graph.Click += new System.EventHandler(this.btn_create_graph_Click); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(829, 197); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(199, 66); - this.button1.TabIndex = 30; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.btn_create_protokol.Location = new System.Drawing.Point(626, 484); + this.btn_create_protokol.Name = "btn_create_protokol"; + this.btn_create_protokol.Size = new System.Drawing.Size(107, 69); + this.btn_create_protokol.TabIndex = 33; + this.btn_create_protokol.Text = "Protokoll erzeugen"; + this.btn_create_protokol.UseVisualStyleBackColor = true; + this.btn_create_protokol.Click += new System.EventHandler(this.btn_create_protokol_Click); // // ftpProgress // @@ -152,7 +138,7 @@ this.btn_transfer_ftp.Name = "btn_transfer_ftp"; this.btn_transfer_ftp.Size = new System.Drawing.Size(224, 126); this.btn_transfer_ftp.TabIndex = 28; - this.btn_transfer_ftp.Text = "button1"; + this.btn_transfer_ftp.Text = "Daten von der Anlage downloaden"; this.btn_transfer_ftp.UseVisualStyleBackColor = true; this.btn_transfer_ftp.Click += new System.EventHandler(this.btn_transfer_ftp_Click); // @@ -558,16 +544,6 @@ this.label9.TabIndex = 0; this.label9.Text = "Harz"; // - // btn_create_protokol - // - this.btn_create_protokol.Location = new System.Drawing.Point(626, 484); - this.btn_create_protokol.Name = "btn_create_protokol"; - this.btn_create_protokol.Size = new System.Drawing.Size(107, 69); - this.btn_create_protokol.TabIndex = 33; - this.btn_create_protokol.Text = "Protokoll erzeugen"; - this.btn_create_protokol.UseVisualStyleBackColor = true; - this.btn_create_protokol.Click += new System.EventHandler(this.btn_create_protokol_Click); - // // UCInliner // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -634,8 +610,6 @@ private System.Windows.Forms.DateTimePicker dt_eingebaut; private System.Windows.Forms.Button btn_transfer_ftp; private System.Windows.Forms.ProgressBar ftpProgress; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button btn_create_graph; private System.Windows.Forms.Button btn_create_protokol; } } diff --git a/SanSystem/UCInliner.cs b/SanSystem/UCInliner.cs index 1fcb7d4..4b4f9ff 100644 --- a/SanSystem/UCInliner.cs +++ b/SanSystem/UCInliner.cs @@ -111,10 +111,11 @@ namespace SanSystem private void btn_get_temp_Click(object sender, EventArgs e) { ITemperature temperature = TempCAN.TemperaturBuilder.Temperatur(TempCAN.TemperaturSchnittstellen.TINKERFORGE); - - double temperatur = temperature.GetTemperatur(); + string message = ""; + double temperatur = temperature.GetTemperatur(out message); inliner.TempAusen = temperatur; - + + if (!message.Equals("")) MessageBox.Show(message); txt_temp_aussen.Update(); } @@ -163,7 +164,7 @@ namespace SanSystem string ordner = _tdateiname[_tdateiname.Length - 2]; newClient.DownloadFile(Path.Combine(destinationPath, ordner, dateiname), file); - //client.DeleteFile(file); + newClient.DeleteFile(file); } } @@ -177,7 +178,7 @@ namespace SanSystem private void btn_transfer_ftp_Click(object sender, EventArgs e) { filenames.Clear(); - if (MessageBox.Show("Bitte stellen Sie sicher, dass der Server antwortet und dass nur die Dateien vorhanden sind!", "WARNUNG", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.OK) + if (MessageBox.Show("Bitte stellen Sie sicher, dass der Server antwortet und dass nur die Dateien vorhanden sind!, Bitte beachten Sie, dass das fenster einfrieren kann", "WARNUNG", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.OK) { DownloadFromUV(); } @@ -199,25 +200,8 @@ namespace SanSystem } } - private void button1_Click(object sender, EventArgs e) - { - Hashtable grunddaten = new Hashtable() - { - {"KL_Wetter","Trocken" } - }; - List bilderO = new List(); - bilderO.Add(new BilderObject() - { - ImgID = 1, - Kommentar = "TestBild", - Path = @"C:\Users\Damian\Desktop\SanVerwaltung\SanSystem\bin\Debug\projekte\18-850\SW01-SW02\Schachtanbindung\4d0a1627-bd51-48d6-a27e-a4c6691b02d2.jpg" - }); - BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("", "", "","", grunddaten,bilderO); - options.ShowDialog(); - } - - - private static ChartControl getGraph(string csvFile) + + private static ChartControl getGraph(List input) { Size size = new Size(600, 400); @@ -245,21 +229,16 @@ namespace SanSystem ChartSeries temperaturChart = new ChartSeries("Temperatur", ChartSeriesType.Line); ChartSeries druckChart = new ChartSeries("Druck", ChartSeriesType.Line); - if (!File.Exists(csvFile)) return null; - string[] input = File.ReadAllLines(csvFile); + int counter = 0; - foreach (string pars in input) + + foreach (UVcsvStrukture pars in input) { - string[] parts = pars.Split(','); - if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue; - double temperatur = double.Parse(parts[1].Replace('.', ',')); - double druck = double.Parse(parts[2].Replace('.', ',')); - - temperaturChart.Points.Add(counter, temperatur); - druckChart.Points.Add(counter, druck); + temperaturChart.Points.Add(counter, pars.Temperatur); + druckChart.Points.Add(counter, pars.Druck); counter++; - } + temperaturChart.YAxis = axis; druckChart.YAxis = axis0; @@ -295,24 +274,32 @@ namespace SanSystem return chartControl; } - private void btn_create_graph_Click(object sender, EventArgs e) - { - Stopwatch watch = new Stopwatch(); + private bool AccessCSV() + { string myPath = Path.Combine(destinationPath, "Trend"); + if (!Directory.Exists(myPath)) + return false; + IEnumerable files = Directory.EnumerateFiles(myPath, "*.csv", SearchOption.AllDirectories); - - ChartControl chart = getGraph(files.Last()); - if (chart == null) MessageBox.Show("Konnte CSV nicht finden!"); + + List struktures = HelpFunktion.ParseCSVFile(files.Last()); + + inliner.AnfangAushaertung = struktures.Select(x => x.Zeitstempel).Min(); + inliner.EndeAushaertung = struktures.Select(x => x.Zeitstempel).Max(); + ChartControl chart = getGraph(struktures); + if (chart == null) return false; else chart.SaveImage(Path.Combine(destinationPath, "linerGraph.jpg")); - - watch.Stop(); - MessageBox.Show((watch.ElapsedTicks) + " s"); + return true; } private void btn_create_protokol_Click(object sender, EventArgs e) { + if(!AccessCSV()) + { + MessageBox.Show("Warnung, es wurden keine Daten von der Anlage geladen, Grafik konnte nicht erstellt werden"); + } Hashtable hashtable = inliner.MakeProtokoll(destinationPath); DirectoryInfo directory = Directory.GetParent(destinationPath); string speicherpfad = directory.FullName; diff --git a/SanSystem/documents/JUME/KalibrierungAuflistung.docx b/SanSystem/documents/JUME/KalibrierungAuflistung.docx index 1558d10..5157b1d 100644 Binary files a/SanSystem/documents/JUME/KalibrierungAuflistung.docx and b/SanSystem/documents/JUME/KalibrierungAuflistung.docx differ diff --git a/SanSystem/documents/JUME/liner_einbau.docx b/SanSystem/documents/JUME/liner_einbau.docx index bdbdd0f..6ec8dc7 100644 Binary files a/SanSystem/documents/JUME/liner_einbau.docx and b/SanSystem/documents/JUME/liner_einbau.docx differ diff --git a/TempCAN/TinkerForgeTemperatur.cs b/TempCAN/TinkerForgeTemperatur.cs index f7462aa..d640008 100644 --- a/TempCAN/TinkerForgeTemperatur.cs +++ b/TempCAN/TinkerForgeTemperatur.cs @@ -14,6 +14,7 @@ namespace TempCAN private static int PORT = 4223; private static string UID = "dW3"; double temperatur; + bool erfolg = true; public TinkerForgeTemperatur() { @@ -21,15 +22,27 @@ namespace TempCAN BrickletTemperature t = new BrickletTemperature(UID, ipcon); ipcon.Connect(HOST, PORT); - short temp = t.GetTemperature(); + short temp; + try + { + temp = t.GetTemperature(); + + } + catch(Tinkerforge.TimeoutException) + { + temp = 100; + erfolg = false; + } temperatur = (temp / 100.0); ipcon.Disconnect(); t = null; ipcon = null; } - public double GetTemperatur() + public double GetTemperatur(out string message) { + message = ""; + if (!erfolg) message = "Es konnte keine Verbindung mit der TemperaturSystem aufgebaut werden"; return temperatur; } }