74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
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;
|
|
|
|
}
|
|
}
|
|
}
|