diff --git a/CSE/CSE.vbproj b/CSE/CSE.vbproj index 81eb3e92069c5717a1224323626cf39b986a075b..5663925cc65f5da210b05af545671cdd15603359 100644 --- a/CSE/CSE.vbproj +++ b/CSE/CSE.vbproj @@ -105,25 +105,24 @@ <ItemGroup> <Compile Include="Classes\cGenShp.vb" /> <Compile Include="Classes\cMSC.vb" /> - <Compile Include="Classes\cJsonFile.vb" /> + <Compile Include="IO\cJsonFile.vb" /> <Compile Include="Classes\CResult.vb" /> - <Compile Include="Classes\cPreferences.vb" /> - <Compile Include="Classes\cSemanticVersion.vb" /> + <Compile Include="IO\cPreferences.vb" /> + <Compile Include="cSemanticVersion.vb" /> <Compile Include="Classes\csKey.vb" /> <Compile Include="Classes\cUTMCoord.vb" /> <Compile Include="Classes\cValidSec.vb" /> - <Compile Include="Classes\cVehicle.vb" /> + <Compile Include="IO\cVehicle.vb" /> <Compile Include="Classes\cVirtMSC.vb" /> - <Compile Include="Export\Minor_routines_output.vb" /> - <Compile Include="Export\output.vb" /> - <Compile Include="Export\OutputTest.vb" /> + <Compile Include="IO\output.vb" /> + <Compile Include="IO\OutputTest.vb" /> <Compile Include="Calculation\Minor_routines_calculate.vb" /> <Compile Include="Calculation\main_calculation_call.vb" /> <Compile Include="Calculation\Signal_identification.vb" /> <Compile Include="Calculation\sub_linear_regression.vb" /> - <Compile Include="Import\read_input.vb" /> + <Compile Include="IO\input.vb" /> <Compile Include="GUI\Export_GUI.vb" /> - <Compile Include="GUI\minor_routines_GUI.vb" /> + <Compile Include="GUI\utils_GUI.vb" /> <Compile Include="GUI\cFileBrowser.vb" /> <Compile Include="GUI\F_Preferences.designer.vb"> <DependentUpon>F_Preferences.vb</DependentUpon> @@ -172,7 +171,7 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> <Compile Include="ApplicationEvents.vb" /> - <Compile Include="Minor_routines.vb" /> + <Compile Include="utils.vb" /> <Compile Include="Classes\cFile_v3.vb" /> <Compile Include="CSE_Globals.vb" /> <Compile Include="CSE_Types.vb" /> diff --git a/CSE/Export/Minor_routines_output.vb b/CSE/Export/Minor_routines_output.vb deleted file mode 100644 index 720bd0dee6723c9dc40568672f14ccee535d9d55..0000000000000000000000000000000000000000 --- a/CSE/Export/Minor_routines_output.vb +++ /dev/null @@ -1,714 +0,0 @@ -Module Minor_routines_output - ' Generate the output sequence for input data - Public Sub AddToErg(ByVal EnumID As tComp, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesI.ContainsKey(EnumID) Then - ErgEntriesI.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListI.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for undefined input data - Public Sub AddToErg(ByVal EnumID As String, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Dic = "InputUndefData" Then - If Not ErgEntriesIU.ContainsKey(EnumID) Then - ErgEntriesIU.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListIU.Add(EnumID) - End If - ElseIf Dic = "ErgValuesUndef" Then - If Not ErgEntriesRU.ContainsKey(EnumID) Then - ErgEntriesRU.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListRU.Add(EnumID) - End If - End If - End Sub - - ' Generate the output sequence for calculated data - Public Sub AddToErg(ByVal EnumID As tCompCali, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesC.ContainsKey(EnumID) Then - ErgEntriesC.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListC.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for calculated data - Public Sub AddToErg(ByVal EnumID As tCompErg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesR.ContainsKey(EnumID) Then - ErgEntriesR.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListR.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for regression calculated data - Public Sub AddToErg(ByVal EnumID As tCompErgReg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesReg.ContainsKey(EnumID) Then - ErgEntriesReg.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListReg.Add(EnumID) - End If - End Sub - - ' Generate the head output string - Public Function ErgHead(ByVal Dic As String) As String - Dim s As New System.Text.StringBuilder - Dim key As String - Dim First As Boolean - - First = True - If Dic = "InputData" Then - For Each key In ErgEntryListI - If Not First Then s.Append(",") - s.Append(ErgEntriesI(key).Head) - First = False - Next - ElseIf Dic = "InputUndefData" Then - For Each key In ErgEntryListIU - If Not First Then s.Append(",") - s.Append(ErgEntriesIU(key).Head) - First = False - Next - ElseIf Dic = "CalcData" Then - For Each key In ErgEntryListC - If Not First Then s.Append(",") - s.Append(ErgEntriesC(key).Head) - First = False - Next - ElseIf Dic = "ErgValues" Then - For Each key In ErgEntryListR - If Not First Then s.Append(",") - s.Append(ErgEntriesR(key).Head) - First = False - Next - ElseIf Dic = "ErgValuesUndef" Then - For Each key In ErgEntryListRU - If Not First Then s.Append(",") - s.Append(ErgEntriesRU(key).Head) - First = False - Next - ElseIf Dic = "ErgValuesReg" Then - For Each key In ErgEntryListReg - If Not First Then s.Append(",") - s.Append(ErgEntriesReg(key).Head) - First = False - Next - End If - - Return s.ToString - End Function - - ' Generate the unit output string - Public Function ErgUnits(ByVal Dic As String) As String - Dim s As New System.Text.StringBuilder - Dim First As Boolean - Dim key As String - - First = True - If Dic = "InputData" Then - For Each key In ErgEntryListI - If Not First Then s.Append(",") - s.Append(ErgEntriesI(key).Unit) - First = False - Next - ElseIf Dic = "InputUndefData" Then - For Each key In ErgEntryListIU - If Not First Then s.Append(",") - s.Append(ErgEntriesIU(key).Unit) - First = False - Next - ElseIf Dic = "CalcData" Then - For Each key In ErgEntryListC - If Not First Then s.Append(",") - s.Append(ErgEntriesC(key).Unit) - First = False - Next - ElseIf Dic = "ErgValues" Then - For Each key In ErgEntryListR - If Not First Then s.Append(",") - s.Append(ErgEntriesR(key).Unit) - First = False - Next - ElseIf Dic = "ErgValuesUndef" Then - For Each key In ErgEntryListRU - If Not First Then s.Append(",") - s.Append(ErgEntriesRU(key).Unit) - First = False - Next - ElseIf Dic = "ErgValuesReg" Then - For Each key In ErgEntryListReg - If Not First Then s.Append(",") - s.Append(ErgEntriesReg(key).Unit) - First = False - Next - End If - - Return s.ToString - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tCompCali, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of tCompCali, List(Of Double)) - Dim KV As KeyValuePair(Of tCompCali, List(Of Double)) - Dim KVd As KeyValuePair(Of tCompCali, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of tCompCali, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = ValuesX(tCompCali.t) - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(tCompCali.t).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of tCompCali, List(Of Double)) - Summe = New Dictionary(Of tCompCali, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - If KV.Key <> tCompCali.t Then Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(tCompCali.t).Count - 1 - tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'Conclude Second - NewValues(tCompCali.t).Add(tMid) - - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tCompCali.t Then Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - If KV.Key <> tCompCali.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tComp, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of tComp, List(Of Double)) - Dim KV As KeyValuePair(Of tComp, List(Of Double)) - Dim KVd As KeyValuePair(Of tComp, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of tComp, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = ValuesX(tComp.t) - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(tComp.t).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of tComp, List(Of Double)) - Summe = New Dictionary(Of tComp, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - If KV.Key <> tComp.t Then Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(tComp.t).Count - 1 - tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'Conclude Second - NewValues(tComp.t).Add(tMid) - - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByVal TimesX As List(Of Double), ByRef ValuesX As Dictionary(Of String, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of String, List(Of Double)) - Dim KV As KeyValuePair(Of String, List(Of Double)) - Dim KVd As KeyValuePair(Of String, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of String, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = TimesX - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(ValuesX.First.Key).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of String, List(Of Double)) - Summe = New Dictionary(Of String, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(ValuesX.First.Key).Count - 1 - tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - 'New Sum /Num no start - For Each KV In ValuesX - Summe(KV.Key) = 0 - Next - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function -End Module diff --git a/CSE/GUI/Export_GUI.vb b/CSE/GUI/Export_GUI.vb index eb803128c0802aa21de63af7263496c061d6d5a1..cff16a41ea93efc7c13ba22d440d7acc50cb1b47 100644 --- a/CSE/GUI/Export_GUI.vb +++ b/CSE/GUI/Export_GUI.vb @@ -7,8 +7,8 @@ Dim Jobname As String - If fEXT(JobFile) <> "csjob" Then - Jobname = fPath(JobFile) & "\" & fName(JobFile, False) & ".csjob" + If fEXT(JobFile) <> ".csjob" Then + Jobname = joinPaths(fPath(JobFile), fName(JobFile, False) & ".csjob") Else Jobname = JobFile End If diff --git a/CSE/GUI/F_Main.vb b/CSE/GUI/F_Main.vb index 59a43221615fdcb50d7b7be9a336835cdbdc987f..05dec25930953cc2d56b8c7c92a9956d2ccec3d0 100644 --- a/CSE/GUI/F_Main.vb +++ b/CSE/GUI/F_Main.vb @@ -205,7 +205,7 @@ Public Class F_Main If OutFolder <> Nothing Then ' Generate the folder if it is desired Dim resEx As MsgBoxResult - resEx = MsgBox("Output folder doesn´t exist! Create Folder?", MsgBoxStyle.YesNo, "Create folder?") + resEx = MsgBox(format("Output-folder({0}) doesn´t exist! \n\nCreate Folder?", OutFolder), MsgBoxStyle.YesNo, "Create folder?") If resEx = MsgBoxResult.Yes Then MkDir(OutFolder) Else @@ -358,7 +358,7 @@ Public Class F_Main If OutFolder <> Nothing Then ' Generate the folder if it is desired Dim resEx As MsgBoxResult - resEx = MsgBox("Output folder doesn´t exist! Create Folder?", MsgBoxStyle.YesNo, "Create folder?") + resEx = MsgBox(format("Output-folder({0}) doesn´t exist! \n\nCreate Folder?", OutFolder), MsgBoxStyle.YesNo, "Create folder?") If resEx = MsgBoxResult.Yes Then MkDir(OutFolder) Else @@ -399,10 +399,10 @@ Public Class F_Main If (JobFile <> Nothing) Then ' Clear the GUI fClear_VECTO_Form(False) - OutFolder = fPath(JobFile) & "\Results\" + OutFolder = joinPaths(fPath(JobFile), "Results\") ' Identify the given Jobfile - If fEXT(JobFile) <> "txt" And fEXT(JobFile) <> "csjob" Then + If fEXT(JobFile) <> ".txt" And fEXT(JobFile) <> ".csjob" Then fInfWarErr(8, False, "The Inputfile is not a regular VECTO-File: " & JobFile) Else ' Read the Jobfile and insert the data in the GUI @@ -419,7 +419,7 @@ Public Class F_Main ' Open the filebrowser to select the folder and name of the Jobfile If fbVECTO.SaveDialog(JobFile) Then JobFile = fbVECTO.Files(0) - OutFolder = fPath(JobFile) & "\Results\" + OutFolder = joinPaths(fPath(JobFile), "Results\") Me.Text = Formname & " " & JobFile End If If (JobFile = Nothing) Then diff --git a/CSE/GUI/minor_routines_GUI.vb b/CSE/GUI/utils_GUI.vb similarity index 99% rename from CSE/GUI/minor_routines_GUI.vb rename to CSE/GUI/utils_GUI.vb index ee4502e70064326ea3378e8768392da9d4c8c4de..240969c8b184d7387c1971d432b4e3ec74eda660 100644 --- a/CSE/GUI/minor_routines_GUI.vb +++ b/CSE/GUI/utils_GUI.vb @@ -1,6 +1,6 @@ Imports Newtonsoft.Json.Linq -Module minor_routines_GUI +Module utils_GUI ' Clear the GUI Public Function fClear_VECTO_Form(ByVal Komplet As Boolean, Optional ByVal Fields As Boolean = True) As Boolean @@ -374,7 +374,7 @@ Module minor_routines_GUI If (File = Nothing) Then fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Return False - ElseIf (Not File.EndsWith(endung)) And Not (File = varOutStr) Then + ElseIf (Not File.EndsWith(endung, StringComparison.OrdinalIgnoreCase)) And Not (File = varOutStr) Then fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Return False End If diff --git a/CSE/Export/OutputTest.vb b/CSE/IO/OutputTest.vb similarity index 100% rename from CSE/Export/OutputTest.vb rename to CSE/IO/OutputTest.vb diff --git a/CSE/Classes/cJsonFile.vb b/CSE/IO/cJsonFile.vb similarity index 100% rename from CSE/Classes/cJsonFile.vb rename to CSE/IO/cJsonFile.vb diff --git a/CSE/Classes/cPreferences.vb b/CSE/IO/cPreferences.vb similarity index 100% rename from CSE/Classes/cPreferences.vb rename to CSE/IO/cPreferences.vb diff --git a/CSE/Classes/cVehicle.vb b/CSE/IO/cVehicle.vb similarity index 100% rename from CSE/Classes/cVehicle.vb rename to CSE/IO/cVehicle.vb diff --git a/CSE/Import/read_input.vb b/CSE/IO/input.vb similarity index 99% rename from CSE/Import/read_input.vb rename to CSE/IO/input.vb index e10b711c872634622bf61c020448aabd537939dd..cd9aa9bb6ca032fcf87308a267114b87e5b662d9 100644 --- a/CSE/Import/read_input.vb +++ b/CSE/IO/input.vb @@ -1,5 +1,5 @@ ' Read the input data -Public Module read_input +Public Module input ' Read the measurement section config file Function ReadInputMSC(ByRef MSCX As cMSC, ByVal MSCfile As String, Optional ByVal calibration As Boolean = True) As Boolean ' Declarations @@ -79,7 +79,7 @@ Public Module read_input Return False End If - If fPath(MSCX.AltPath(i)) = Nothing Then MSCX.AltPath(i) = fPath(MSCfile) & "\" & MSCX.AltPath(i) + If fPath(MSCX.AltPath(i)) = Nothing Then MSCX.AltPath(i) = joinPaths(fPath(MSCfile), MSCX.AltPath(i)) fControlInput(MSCX.AltPath(i), 3, "csalt") If Not FileIO.FileSystem.FileExists(MSCX.AltPath(i)) Then fInfWarErrBW(9, False, "Altitude correction = on, altitude file doesen´t exist: " & MSCX.AltPath(i)) diff --git a/CSE/Export/output.vb b/CSE/IO/output.vb similarity index 54% rename from CSE/Export/output.vb rename to CSE/IO/output.vb index 610d9f84619b5dc93807af8929eb31d8adf5ffe8..584151a1f0844a2c1177e706ba4b031ff8530941 100644 --- a/CSE/Export/output.vb +++ b/CSE/IO/output.vb @@ -483,4 +483,717 @@ AddToErg(tCompErgReg.t_tire_HS_min, fCompName(tCompErgReg.t_tire_HS_min), fCompUnit(tCompErgReg.t_tire_HS_min), "ErgValuesReg") AddToErg(tCompErgReg.t_tire_HS_max, fCompName(tCompErgReg.t_tire_HS_max), fCompUnit(tCompErgReg.t_tire_HS_max), "ErgValuesReg") End Sub + + ' Generate the output sequence for input data + Public Sub AddToErg(ByVal EnumID As tComp, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesI.ContainsKey(EnumID) Then + ErgEntriesI.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListI.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for undefined input data + Public Sub AddToErg(ByVal EnumID As String, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Dic = "InputUndefData" Then + If Not ErgEntriesIU.ContainsKey(EnumID) Then + ErgEntriesIU.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListIU.Add(EnumID) + End If + ElseIf Dic = "ErgValuesUndef" Then + If Not ErgEntriesRU.ContainsKey(EnumID) Then + ErgEntriesRU.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListRU.Add(EnumID) + End If + End If + End Sub + + ' Generate the output sequence for calculated data + Public Sub AddToErg(ByVal EnumID As tCompCali, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesC.ContainsKey(EnumID) Then + ErgEntriesC.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListC.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for calculated data + Public Sub AddToErg(ByVal EnumID As tCompErg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesR.ContainsKey(EnumID) Then + ErgEntriesR.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListR.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for regression calculated data + Public Sub AddToErg(ByVal EnumID As tCompErgReg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesReg.ContainsKey(EnumID) Then + ErgEntriesReg.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListReg.Add(EnumID) + End If + End Sub + + ' Generate the head output string + Public Function ErgHead(ByVal Dic As String) As String + Dim s As New System.Text.StringBuilder + Dim key As String + Dim First As Boolean + + First = True + If Dic = "InputData" Then + For Each key In ErgEntryListI + If Not First Then s.Append(",") + s.Append(ErgEntriesI(key).Head) + First = False + Next + ElseIf Dic = "InputUndefData" Then + For Each key In ErgEntryListIU + If Not First Then s.Append(",") + s.Append(ErgEntriesIU(key).Head) + First = False + Next + ElseIf Dic = "CalcData" Then + For Each key In ErgEntryListC + If Not First Then s.Append(",") + s.Append(ErgEntriesC(key).Head) + First = False + Next + ElseIf Dic = "ErgValues" Then + For Each key In ErgEntryListR + If Not First Then s.Append(",") + s.Append(ErgEntriesR(key).Head) + First = False + Next + ElseIf Dic = "ErgValuesUndef" Then + For Each key In ErgEntryListRU + If Not First Then s.Append(",") + s.Append(ErgEntriesRU(key).Head) + First = False + Next + ElseIf Dic = "ErgValuesReg" Then + For Each key In ErgEntryListReg + If Not First Then s.Append(",") + s.Append(ErgEntriesReg(key).Head) + First = False + Next + End If + + Return s.ToString + End Function + + ' Generate the unit output string + Public Function ErgUnits(ByVal Dic As String) As String + Dim s As New System.Text.StringBuilder + Dim First As Boolean + Dim key As String + + First = True + If Dic = "InputData" Then + For Each key In ErgEntryListI + If Not First Then s.Append(",") + s.Append(ErgEntriesI(key).Unit) + First = False + Next + ElseIf Dic = "InputUndefData" Then + For Each key In ErgEntryListIU + If Not First Then s.Append(",") + s.Append(ErgEntriesIU(key).Unit) + First = False + Next + ElseIf Dic = "CalcData" Then + For Each key In ErgEntryListC + If Not First Then s.Append(",") + s.Append(ErgEntriesC(key).Unit) + First = False + Next + ElseIf Dic = "ErgValues" Then + For Each key In ErgEntryListR + If Not First Then s.Append(",") + s.Append(ErgEntriesR(key).Unit) + First = False + Next + ElseIf Dic = "ErgValuesUndef" Then + For Each key In ErgEntryListRU + If Not First Then s.Append(",") + s.Append(ErgEntriesRU(key).Unit) + First = False + Next + ElseIf Dic = "ErgValuesReg" Then + For Each key In ErgEntryListReg + If Not First Then s.Append(",") + s.Append(ErgEntriesReg(key).Unit) + First = False + Next + End If + + Return s.ToString + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tCompCali, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of tCompCali, List(Of Double)) + Dim KV As KeyValuePair(Of tCompCali, List(Of Double)) + Dim KVd As KeyValuePair(Of tCompCali, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of tCompCali, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = ValuesX(tCompCali.t) + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(tCompCali.t).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of tCompCali, List(Of Double)) + Summe = New Dictionary(Of tCompCali, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + If KV.Key <> tCompCali.t Then Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(tCompCali.t).Count - 1 + tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'Conclude Second + NewValues(tCompCali.t).Add(tMid) + + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tCompCali.t Then Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + If KV.Key <> tCompCali.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tComp, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of tComp, List(Of Double)) + Dim KV As KeyValuePair(Of tComp, List(Of Double)) + Dim KVd As KeyValuePair(Of tComp, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of tComp, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = ValuesX(tComp.t) + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(tComp.t).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of tComp, List(Of Double)) + Summe = New Dictionary(Of tComp, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + If KV.Key <> tComp.t Then Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(tComp.t).Count - 1 + tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'Conclude Second + NewValues(tComp.t).Add(tMid) + + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByVal TimesX As List(Of Double), ByRef ValuesX As Dictionary(Of String, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of String, List(Of Double)) + Dim KV As KeyValuePair(Of String, List(Of Double)) + Dim KVd As KeyValuePair(Of String, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of String, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = TimesX + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(ValuesX.First.Key).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of String, List(Of Double)) + Summe = New Dictionary(Of String, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(ValuesX.First.Key).Count - 1 + tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + 'New Sum /Num no start + For Each KV In ValuesX + Summe(KV.Key) = 0 + Next + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function End Module diff --git a/CSE/Classes/cSemanticVersion.vb b/CSE/cSemanticVersion.vb similarity index 100% rename from CSE/Classes/cSemanticVersion.vb rename to CSE/cSemanticVersion.vb diff --git a/CSE/Minor_routines.vb b/CSE/utils.vb similarity index 97% rename from CSE/Minor_routines.vb rename to CSE/utils.vb index aed080569990509e7ef9f2b6d5163fe0c69693e1..553097436507fe357fb38988f800b4876b4be332 100644 --- a/CSE/Minor_routines.vb +++ b/CSE/utils.vb @@ -3,7 +3,7 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Schema Imports System.Text.RegularExpressions -Module Minor_routines +Module utils ''' <summary> ''' Utility to check compatibility when reading files, ie 1.0.1-somePre is compatible with [1.0.0--, 2.0.0--) @@ -42,8 +42,9 @@ Module Minor_routines Pfad = Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) If Not MitEndung Then - x = Pfad.LastIndexOf(".") - If x > 0 Then Pfad = Microsoft.VisualBasic.Left(Pfad, x) + Dim ext = fEXT(Pfad) + + Pfad = Pfad.Remove(Pfad.Length - ext.Length) End If Return Pfad @@ -60,17 +61,16 @@ Module Minor_routines Return Microsoft.VisualBasic.Left(Pfad, x) End Function - ' Identification from the filenend + ' Identification from the filenend, including dot('.') Public Function fEXT(ByVal Pfad As String) As String - Dim x As Int16 - - x = Pfad.LastIndexOf(".") + Dim ext = IO.Path.GetExtension(Pfad) - If x = -1 Then - Return "" - Else - Return Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x - 1) + If ext.Equals(".json", StringComparison.OrdinalIgnoreCase) Then + Dim prevExt = IO.Path.GetExtension(Pfad.Remove(Pfad.Length - 5)) ' 5 = ".json".Length + ext = prevExt & ext End If + + Return ext End Function