KlassenDLL im Main integriert
This commit is contained in:
9
SanSystem/CSVParser/AcceptedCSVFormats.cs
Normal file
9
SanSystem/CSVParser/AcceptedCSVFormats.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace CSVParser
|
||||
{
|
||||
public enum AcceptedCSVFormats
|
||||
{
|
||||
UVRELINING,
|
||||
BLUELIGHT
|
||||
|
||||
}
|
||||
}
|
||||
73
SanSystem/CSVParser/BlueLight.cs
Normal file
73
SanSystem/CSVParser/BlueLight.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SanShared;
|
||||
using SanShared.Exceptions;
|
||||
|
||||
namespace CSVParser
|
||||
{
|
||||
public class BlueLight : CSVParser
|
||||
{
|
||||
public BlueLight(string csvFile) : base(csvFile)
|
||||
{
|
||||
}
|
||||
|
||||
public override List<UVcsvStrukture> ReadCSVStrukture()
|
||||
{
|
||||
List<UVcsvStrukture> result = new List<UVcsvStrukture>();
|
||||
DateTime zeit;
|
||||
double temperatur;
|
||||
double druck;
|
||||
double geschwindigkeit;
|
||||
|
||||
|
||||
bool gestarted = false;
|
||||
foreach (string partial in Input)
|
||||
{
|
||||
UVcsvStrukture strukture = new UVcsvStrukture();
|
||||
string[] parts = partial.Split(',');
|
||||
|
||||
string datum = parts[1].Replace("\"", "");
|
||||
string uhrzeit = parts[2].Replace("\"", "");
|
||||
|
||||
if (datum.Equals("Date")) continue;
|
||||
|
||||
|
||||
if (!DateTime.TryParse(datum + " " + uhrzeit, out zeit))
|
||||
throw new CSVImportException("Konnte die datum uhrzeit nicht konventieren");
|
||||
|
||||
double.TryParse(parts[3].Replace("\"","").Replace('.', ','), out temperatur);
|
||||
double.TryParse(parts[4].Replace("\"",""), out geschwindigkeit);
|
||||
double.TryParse(parts[5].Replace("\"","").Replace('.', ','), out druck);
|
||||
|
||||
|
||||
string x = (druck*1000).ToString();
|
||||
|
||||
if (geschwindigkeit > 100) geschwindigkeit = 0;
|
||||
if (geschwindigkeit > 50) geschwindigkeit = 1;
|
||||
/*
|
||||
*
|
||||
* Geschwindigkeit wird in Meter angegeben pro stunde
|
||||
* : 60 :60 * 100 = 36;
|
||||
*/
|
||||
geschwindigkeit = geschwindigkeit / 36.00;
|
||||
|
||||
strukture.Zeitstempel = zeit;
|
||||
strukture.Druck = int.Parse(x);
|
||||
strukture.Geschwindigkeit = geschwindigkeit;
|
||||
strukture.Temperatur = temperatur;
|
||||
|
||||
if (!geschwindigkeit.Equals(0) && gestarted.Equals(false))
|
||||
gestarted = true;
|
||||
|
||||
if(gestarted == true)
|
||||
result.Add(strukture);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
28
SanSystem/CSVParser/CSVParser.cs
Normal file
28
SanSystem/CSVParser/CSVParser.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using SanShared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CSVParser
|
||||
{
|
||||
public abstract class CSVParser : IReadCSVData
|
||||
{
|
||||
private string csvFile;
|
||||
public CSVParser(string csvFile)
|
||||
{
|
||||
this.csvFile = csvFile;
|
||||
}
|
||||
public virtual string[] Input
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!File.Exists(csvFile)) throw new FileNotFoundException(csvFile);
|
||||
return File.ReadAllLines(csvFile);
|
||||
}
|
||||
}
|
||||
public abstract List<UVcsvStrukture> ReadCSVStrukture();
|
||||
}
|
||||
}
|
||||
25
SanSystem/CSVParser/CsvParserFactory.cs
Normal file
25
SanSystem/CSVParser/CsvParserFactory.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SanShared;
|
||||
|
||||
namespace CSVParser
|
||||
{
|
||||
public static class CsvParserFactory
|
||||
{
|
||||
public static IReadCSVData ReadCSVFile(AcceptedCSVFormats csvFormat, string csvFile)
|
||||
{
|
||||
switch (csvFormat)
|
||||
{
|
||||
case AcceptedCSVFormats.UVRELINING:
|
||||
return new UVRelining(csvFile);
|
||||
case AcceptedCSVFormats.BLUELIGHT:
|
||||
return new BlueLight(csvFile);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(csvFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
SanSystem/CSVParser/UVRelining.cs
Normal file
56
SanSystem/CSVParser/UVRelining.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using SanShared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CSVParser
|
||||
{
|
||||
public class UVRelining : CSVParser
|
||||
{
|
||||
public UVRelining(string csvFile) : base(csvFile)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="csvFile"></param>
|
||||
/// <returns></returns>
|
||||
public override List<UVcsvStrukture> ReadCSVStrukture()
|
||||
{
|
||||
/*
|
||||
* Die Geschwindigkeit wird in cm / sekunde angegeben
|
||||
*/
|
||||
List<UVcsvStrukture> result = new List<UVcsvStrukture>();
|
||||
|
||||
DateTime zeit;
|
||||
double temperatur;
|
||||
double druck;
|
||||
int geschwindigkeit;
|
||||
foreach (string pars in Input)
|
||||
{
|
||||
UVcsvStrukture uVcsvStrukture = new UVcsvStrukture();
|
||||
string[] parts = pars.Split(',');
|
||||
if (
|
||||
parts[0].Equals("Group1") ||
|
||||
parts[1].Equals("(END)") ||
|
||||
parts[1].Equals("(START)")
|
||||
) continue;
|
||||
DateTime.TryParse(parts[0], out zeit);
|
||||
double.TryParse(parts[1].Replace('.', ','), out temperatur);
|
||||
double.TryParse(parts[2].Replace('.', ','), out druck);
|
||||
int.TryParse(parts[3], out geschwindigkeit);
|
||||
|
||||
|
||||
uVcsvStrukture.Zeitstempel = zeit;
|
||||
uVcsvStrukture.Druck = 1;//druck;
|
||||
uVcsvStrukture.Temperatur = temperatur;
|
||||
uVcsvStrukture.Geschwindigkeit = geschwindigkeit;
|
||||
result.Add(uVcsvStrukture);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user