Initial commit
This commit is contained in:
11
DataGen/DataGen.csproj
Normal file
11
DataGen/DataGen.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DPGetDataContract\DPGetDataContract.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
281
DataGen/ProtokollWriter.cs
Normal file
281
DataGen/ProtokollWriter.cs
Normal file
@@ -0,0 +1,281 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DPGetDataContract;
|
||||
|
||||
namespace DataGen
|
||||
{
|
||||
public class ProtokollWriter : IDPGetDataContract
|
||||
{
|
||||
List<GetDataStructure> messureList = new List<GetDataStructure>();
|
||||
public List<GetDataStructure> ReadMessureList { get => messureList;}
|
||||
|
||||
|
||||
public void GenerateUnterdruck(DateTime startprüfung, double prüfdruck, bool failure=false) {
|
||||
|
||||
int messreiheID = -1;
|
||||
List<GetDataStructure> messreihen = new List<GetDataStructure>();
|
||||
List<double> druckwerte = new List<double>();
|
||||
double druck = 0.0;
|
||||
bool druckerreicht = false;
|
||||
DateTime start = startprüfung;
|
||||
|
||||
prüfdruck = ((prüfdruck - (new Random(DateTime.Now.Millisecond).NextDouble() * 115.8)));
|
||||
#region Anstiegskurve
|
||||
while (!druckerreicht)
|
||||
{
|
||||
start = start.AddSeconds(2);
|
||||
messreiheID++;
|
||||
if (druck <= prüfdruck)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Random zufall = new Random(DateTime.Now.Millisecond);
|
||||
druck -= Convert.ToDouble((zufall.Next(1000, 10000) / 1000.0));
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
});
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
#endregion
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.BEFÜLLPHASE
|
||||
});
|
||||
start = start.AddMinutes(2);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.PRÜFUNGSPHASE
|
||||
});
|
||||
start = start.AddMinutes(15);
|
||||
start = start.AddSeconds(3);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.PRÜFUNGSPHASE
|
||||
});
|
||||
start = start.AddSeconds(2);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.BEFÜLLPHASE
|
||||
});
|
||||
start = start.AddSeconds(2);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
});
|
||||
start = start.AddSeconds(2);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = "0,000",
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
}) ;
|
||||
start = start.AddSeconds(1);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = "0,000",
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
});
|
||||
messureList = messreihen;
|
||||
}
|
||||
public void GenerateÜberdruck(DateTime startprüfung, double prüfdruck, bool failure=false) {
|
||||
List<GetDataStructure> messreihen = new List<GetDataStructure>();
|
||||
string prüfdatum = startprüfung.ToShortDateString();
|
||||
bool Bestanden = !failure;
|
||||
|
||||
List<double> druckwerte = new List<double>();
|
||||
double druck = 0.0;
|
||||
bool druckerreicht = false;
|
||||
int messreiheID = 0;
|
||||
// Anstiegskurve erzeugen
|
||||
DateTime start = startprüfung;
|
||||
|
||||
#region Befüllphase
|
||||
while (!druckerreicht)
|
||||
{
|
||||
start = start.AddSeconds(4);
|
||||
if (failure && druck >= 56)
|
||||
break;
|
||||
if (!failure &&(druck > (prüfdruck * 1.1)))
|
||||
druckerreicht = true;
|
||||
Random zufall = new Random(DateTime.Now.Millisecond);
|
||||
if(!druckerreicht)
|
||||
{
|
||||
druck += Convert.ToDouble((zufall.Next(1000, 10000) / 1000.0));
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Eintrag = messreiheID,
|
||||
Druck = druck.ToString(),
|
||||
Methode = EDataType.BEFÜLLPHASE
|
||||
});
|
||||
messreiheID++;
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
#endregion
|
||||
#region Beruhigungsphase
|
||||
if (!failure)
|
||||
{
|
||||
Random druckabfall = new Random(DateTime.Now.Millisecond);
|
||||
double dp = druckabfall.Next(2, 9) + druckabfall.NextDouble();
|
||||
//double startdruck = druckwerte.Last() - dp;
|
||||
//startdruck += druckabfall.NextDouble();
|
||||
double dpt = dp / 90.0;
|
||||
for (int i = 0; i <= 90; i++)
|
||||
{
|
||||
start = start.AddSeconds(2);
|
||||
druck -= dpt;
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Druck = druck.ToString(),
|
||||
Methode = EDataType.BERUHUNGSZEIT,
|
||||
Datum = start,
|
||||
Eintrag = messreiheID
|
||||
});
|
||||
messreiheID++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int anzahlschritte = 20;
|
||||
double druckabfall = druck / anzahlschritte;
|
||||
for(int i = 0; i <= anzahlschritte; i++)
|
||||
{
|
||||
start = start.AddSeconds(2);
|
||||
druck -= druckabfall;
|
||||
if (druck < 0) druck = 0;
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Druck = druck.ToString(),
|
||||
Methode = EDataType.BERUHUNGSZEIT,
|
||||
Datum = start,
|
||||
Eintrag = messreiheID
|
||||
});
|
||||
messreiheID++;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Prüfungsphase
|
||||
if (!failure)
|
||||
{
|
||||
for (int i = 0; i < 90; i++)
|
||||
{
|
||||
Random Prüfung = new Random(DateTime.Now.Millisecond);
|
||||
double abfall = Prüfung.NextDouble() / 10;
|
||||
start = start.AddSeconds(2);
|
||||
if (abfall <= 0.07 && (i % 2 == 0))
|
||||
{
|
||||
druck -= abfall;
|
||||
|
||||
}
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.PRÜFUNGSPHASE,
|
||||
Druck = druck.ToString()
|
||||
});
|
||||
messreiheID++;
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region EndePrüfung
|
||||
start = start.AddSeconds(2);
|
||||
messreiheID++;
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.ENDEPRÜFUNGMARKER,
|
||||
Druck = druck.ToString()
|
||||
}) ;
|
||||
|
||||
start = start.AddSeconds(4);
|
||||
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Druck = druckwerte.Last().ToString(),
|
||||
Datum = start,
|
||||
Methode = EDataType.ENDEPRÜFUNGMARKER,
|
||||
Eintrag = messreiheID
|
||||
}) ;
|
||||
|
||||
while(druck > 10)
|
||||
{
|
||||
start = start.AddSeconds(2);
|
||||
double abbau = druck / 2;
|
||||
druck -= abbau;
|
||||
druckwerte.Add(druck);
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start,
|
||||
Druck = druck.ToString(),
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
});
|
||||
messreiheID++;
|
||||
}
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start.AddSeconds(2),
|
||||
Druck = "0,0",
|
||||
Eintrag = messreiheID,
|
||||
Methode = EDataType.LEERPHASE
|
||||
});
|
||||
messreihen.Add(new GetDataStructure()
|
||||
{
|
||||
Datum = start.AddSeconds(4),
|
||||
Druck = "0,0",
|
||||
Eintrag = messreiheID+1,
|
||||
Methode = EDataType.ENDEPRÜFUNGMARKER
|
||||
});
|
||||
|
||||
#endregion
|
||||
// Debugger.Break();
|
||||
|
||||
messureList = messreihen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user