Protokolll inhalt erweitert

This commit is contained in:
Husky
2018-07-14 15:57:50 +02:00
parent 2ee98ea823
commit 85607e926c
12 changed files with 134 additions and 90 deletions

View File

@@ -97,7 +97,7 @@ namespace BerichtGen
} }
finally finally
{ {
pdf.Dispose(); //pdf.Dispose();
} }
} }
@@ -150,6 +150,7 @@ namespace BerichtGen
if(args.FieldName == "UVImage") if(args.FieldName == "UVImage")
{ {
string source = args.FieldValue.ToString(); string source = args.FieldValue.ToString();
if (!File.Exists(source)) return;
args.Image = Image.FromFile(source); args.Image = Image.FromFile(source);
} }
} }

View File

@@ -23,6 +23,8 @@ namespace KlassenBIB
double harzbedarf = 1.8; double harzbedarf = 1.8;
uint rueckholgeschwindigkeit = 24; uint rueckholgeschwindigkeit = 24;
bool geschlosseneEnde = false; bool geschlosseneEnde = false;
DateTime anfangAushaertung;
DateTime endeAushaertung;
/// <summary> /// <summary>
/// Gibt den kompletten Harzbedarf auf die Haltungslänge bezogen zurück /// Gibt den kompletten Harzbedarf auf die Haltungslänge bezogen zurück
@@ -88,6 +90,9 @@ namespace KlassenBIB
{"UVImage","" } {"UVImage","" }
}; };
double LaengeGesamt = this.Inspektionsobjekt.Haltungslaenge + this.Inspektionsobjekt.Schachtlaenge;
grunddaten["AG_Vorname"] = ""; grunddaten["AG_Vorname"] = "";
grunddaten["KLP_Nummer"] = ""; grunddaten["KLP_Nummer"] = "";
grunddaten["KLP_Datum"] = DateTime.Now.ToShortDateString(); grunddaten["KLP_Datum"] = DateTime.Now.ToShortDateString();
@@ -113,19 +118,19 @@ namespace KlassenBIB
grunddaten["KL_HD_true"] = ""; grunddaten["KL_HD_true"] = "";
grunddaten["KL_mech_true"] = ""; grunddaten["KL_mech_true"] = "";
grunddaten["KL_rob_true"] = ""; grunddaten["KL_rob_true"] = "";
grunddaten["KL_HD_date"] = ""; grunddaten["KL_HD_date"] = this.Datum.HasValue ? this.Datum.Value.ToShortDateString() : "";
grunddaten["KL_Besatzung"] = ""; grunddaten["KL_Besatzung"] = "";
grunddaten["liner_laenge"] = ""; grunddaten["liner_laenge"] = LaengeGesamt;
grunddaten["Charge_Liner"] = this.LinerChargenummer; grunddaten["Charge_Liner"] = this.LinerChargenummer;
grunddaten["Charge_Harz"] = this.HarzChargenummer; grunddaten["Charge_Harz"] = this.HarzChargenummer;
grunddaten["harz_bedarf_m"] = ""; grunddaten["harz_bedarf_m"] = harzbedarf;
grunddaten["gesamt_harz"] = ""; grunddaten["gesamt_harz"] = LaengeGesamt * harzbedarf;
grunddaten["temperatur_harz"] = this.HarzKalibrierTemperatur; grunddaten["temperatur_harz"] = this.HarzKalibrierTemperatur;
grunddaten["datum_kalibrierung"] = this.DatumKalibrierung.ToShortDateString(); grunddaten["datum_kalibrierung"] = this.DatumKalibrierung.ToShortDateString();
grunddaten["walzen_abstand"] = this.KalibierWalzenAbstand; grunddaten["walzen_abstand"] = this.KalibierWalzenAbstand;
grunddaten["vakuum"] = this.KalibrierUnterdruck; grunddaten["vakuum"] = this.KalibrierUnterdruck;
grunddaten["time_start"] = ""; grunddaten["time_start"] = this.AnfangAushaertung;
grunddaten["time_ende"] = ""; grunddaten["time_ende"] = this.EndeAushaertung;
grunddaten["UVImage"] = Path.Combine(destinationPath, "linerGraph.jpg"); grunddaten["UVImage"] = Path.Combine(destinationPath, "linerGraph.jpg");
return grunddaten; return grunddaten;
@@ -162,5 +167,7 @@ namespace KlassenBIB
public double HarzBedarf { get => harzbedarf; set => harzbedarf = value; } public double HarzBedarf { get => harzbedarf; set => harzbedarf = value; }
public string HarzTyp { get => harzTyp; set => harzTyp = value; } public string HarzTyp { get => harzTyp; set => harzTyp = value; }
public string LinerTyp { get => linerTyp; set => linerTyp = 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; }
} }
} }

View File

@@ -8,6 +8,6 @@ namespace SanShared
{ {
public interface ITemperature public interface ITemperature
{ {
double GetTemperatur(); double GetTemperatur(out string message);
} }
} }

View File

@@ -46,6 +46,7 @@
<Compile Include="IMakeProtokol.cs" /> <Compile Include="IMakeProtokol.cs" />
<Compile Include="ITemperature.cs" /> <Compile Include="ITemperature.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UVcsvStrukture.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -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; }
}
}

41
SanSystem/HelpFunktion.cs Normal file
View File

@@ -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<UVcsvStrukture> ParseCSVFile(string csvFile)
{
List<UVcsvStrukture> result = new List<UVcsvStrukture>();
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;
}
}
}

View File

@@ -107,6 +107,7 @@
<DependentUpon>frmMain.cs</DependentUpon> <DependentUpon>frmMain.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Global.cs" /> <Compile Include="Global.cs" />
<Compile Include="HelpFunktion.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UCInliner.cs"> <Compile Include="UCInliner.cs">

View File

@@ -30,8 +30,7 @@
{ {
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.btn_create_graph = new System.Windows.Forms.Button(); this.btn_create_protokol = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.ftpProgress = new System.Windows.Forms.ProgressBar(); this.ftpProgress = new System.Windows.Forms.ProgressBar();
this.btn_transfer_ftp = new System.Windows.Forms.Button(); this.btn_transfer_ftp = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
@@ -71,7 +70,6 @@
this.label11 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label();
this.label9 = 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.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout(); this.tabPage2.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
@@ -94,8 +92,6 @@
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.btn_create_protokol); 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.ftpProgress);
this.tabPage2.Controls.Add(this.btn_transfer_ftp); this.tabPage2.Controls.Add(this.btn_transfer_ftp);
this.tabPage2.Controls.Add(this.label1); this.tabPage2.Controls.Add(this.label1);
@@ -119,25 +115,15 @@
this.tabPage2.Text = "Vorraussetzungen"; this.tabPage2.Text = "Vorraussetzungen";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// btn_create_graph // btn_create_protokol
// //
this.btn_create_graph.Location = new System.Drawing.Point(443, 487); this.btn_create_protokol.Location = new System.Drawing.Point(626, 484);
this.btn_create_graph.Name = "btn_create_graph"; this.btn_create_protokol.Name = "btn_create_protokol";
this.btn_create_graph.Size = new System.Drawing.Size(138, 67); this.btn_create_protokol.Size = new System.Drawing.Size(107, 69);
this.btn_create_graph.TabIndex = 32; this.btn_create_protokol.TabIndex = 33;
this.btn_create_graph.Text = "UVGraphic erzeugen"; this.btn_create_protokol.Text = "Protokoll erzeugen";
this.btn_create_graph.UseVisualStyleBackColor = true; this.btn_create_protokol.UseVisualStyleBackColor = true;
this.btn_create_graph.Click += new System.EventHandler(this.btn_create_graph_Click); this.btn_create_protokol.Click += new System.EventHandler(this.btn_create_protokol_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);
// //
// ftpProgress // ftpProgress
// //
@@ -152,7 +138,7 @@
this.btn_transfer_ftp.Name = "btn_transfer_ftp"; this.btn_transfer_ftp.Name = "btn_transfer_ftp";
this.btn_transfer_ftp.Size = new System.Drawing.Size(224, 126); this.btn_transfer_ftp.Size = new System.Drawing.Size(224, 126);
this.btn_transfer_ftp.TabIndex = 28; 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.UseVisualStyleBackColor = true;
this.btn_transfer_ftp.Click += new System.EventHandler(this.btn_transfer_ftp_Click); this.btn_transfer_ftp.Click += new System.EventHandler(this.btn_transfer_ftp_Click);
// //
@@ -558,16 +544,6 @@
this.label9.TabIndex = 0; this.label9.TabIndex = 0;
this.label9.Text = "Harz"; 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 // UCInliner
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
@@ -634,8 +610,6 @@
private System.Windows.Forms.DateTimePicker dt_eingebaut; private System.Windows.Forms.DateTimePicker dt_eingebaut;
private System.Windows.Forms.Button btn_transfer_ftp; private System.Windows.Forms.Button btn_transfer_ftp;
private System.Windows.Forms.ProgressBar ftpProgress; 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; private System.Windows.Forms.Button btn_create_protokol;
} }
} }

View File

@@ -111,10 +111,11 @@ namespace SanSystem
private void btn_get_temp_Click(object sender, EventArgs e) private void btn_get_temp_Click(object sender, EventArgs e)
{ {
ITemperature temperature = TempCAN.TemperaturBuilder.Temperatur(TempCAN.TemperaturSchnittstellen.TINKERFORGE); ITemperature temperature = TempCAN.TemperaturBuilder.Temperatur(TempCAN.TemperaturSchnittstellen.TINKERFORGE);
string message = "";
double temperatur = temperature.GetTemperatur(); double temperatur = temperature.GetTemperatur(out message);
inliner.TempAusen = temperatur; inliner.TempAusen = temperatur;
if (!message.Equals("")) MessageBox.Show(message);
txt_temp_aussen.Update(); txt_temp_aussen.Update();
} }
@@ -163,7 +164,7 @@ namespace SanSystem
string ordner = _tdateiname[_tdateiname.Length - 2]; string ordner = _tdateiname[_tdateiname.Length - 2];
newClient.DownloadFile(Path.Combine(destinationPath, ordner, dateiname), file); 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) private void btn_transfer_ftp_Click(object sender, EventArgs e)
{ {
filenames.Clear(); 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(); DownloadFromUV();
} }
@@ -199,25 +200,8 @@ namespace SanSystem
} }
} }
private void button1_Click(object sender, EventArgs e)
{
Hashtable grunddaten = new Hashtable()
{
{"KL_Wetter","Trocken" }
};
List<BilderObject> bilderO = new List<BilderObject>();
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(List<UVcsvStrukture> input)
private static ChartControl getGraph(string csvFile)
{ {
Size size = new Size(600, 400); Size size = new Size(600, 400);
@@ -245,21 +229,16 @@ namespace SanSystem
ChartSeries temperaturChart = new ChartSeries("Temperatur", ChartSeriesType.Line); ChartSeries temperaturChart = new ChartSeries("Temperatur", ChartSeriesType.Line);
ChartSeries druckChart = new ChartSeries("Druck", ChartSeriesType.Line); ChartSeries druckChart = new ChartSeries("Druck", ChartSeriesType.Line);
if (!File.Exists(csvFile)) return null;
string[] input = File.ReadAllLines(csvFile);
int counter = 0; int counter = 0;
foreach (string pars in input)
foreach (UVcsvStrukture pars in input)
{ {
string[] parts = pars.Split(','); temperaturChart.Points.Add(counter, pars.Temperatur);
if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue; druckChart.Points.Add(counter, pars.Druck);
double temperatur = double.Parse(parts[1].Replace('.', ','));
double druck = double.Parse(parts[2].Replace('.', ','));
temperaturChart.Points.Add(counter, temperatur);
druckChart.Points.Add(counter, druck);
counter++; counter++;
} }
temperaturChart.YAxis = axis; temperaturChart.YAxis = axis;
druckChart.YAxis = axis0; druckChart.YAxis = axis0;
@@ -295,24 +274,32 @@ namespace SanSystem
return chartControl; 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"); string myPath = Path.Combine(destinationPath, "Trend");
if (!Directory.Exists(myPath))
return false;
IEnumerable<string> files = Directory.EnumerateFiles(myPath, "*.csv", SearchOption.AllDirectories); IEnumerable<string> files = Directory.EnumerateFiles(myPath, "*.csv", SearchOption.AllDirectories);
ChartControl chart = getGraph(files.Last()); List<UVcsvStrukture> struktures = HelpFunktion.ParseCSVFile(files.Last());
if (chart == null) MessageBox.Show("Konnte CSV nicht finden!");
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 else
chart.SaveImage(Path.Combine(destinationPath, "linerGraph.jpg")); chart.SaveImage(Path.Combine(destinationPath, "linerGraph.jpg"));
return true;
watch.Stop();
MessageBox.Show((watch.ElapsedTicks) + " s");
} }
private void btn_create_protokol_Click(object sender, EventArgs e) 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); Hashtable hashtable = inliner.MakeProtokoll(destinationPath);
DirectoryInfo directory = Directory.GetParent(destinationPath); DirectoryInfo directory = Directory.GetParent(destinationPath);
string speicherpfad = directory.FullName; string speicherpfad = directory.FullName;

View File

@@ -14,6 +14,7 @@ namespace TempCAN
private static int PORT = 4223; private static int PORT = 4223;
private static string UID = "dW3"; private static string UID = "dW3";
double temperatur; double temperatur;
bool erfolg = true;
public TinkerForgeTemperatur() public TinkerForgeTemperatur()
{ {
@@ -21,15 +22,27 @@ namespace TempCAN
BrickletTemperature t = new BrickletTemperature(UID, ipcon); BrickletTemperature t = new BrickletTemperature(UID, ipcon);
ipcon.Connect(HOST, PORT); 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); temperatur = (temp / 100.0);
ipcon.Disconnect(); ipcon.Disconnect();
t = null; t = null;
ipcon = 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; return temperatur;
} }
} }