diff --git a/CHANGES.md b/CHANGES.md index d75560a5bfb220894cb9d01784ed30c1e1bb88c7..1280e7aa2440dca4f11b05d0413692b52dc767f9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,8 +12,9 @@ TODO: 2014-06-??: v2.0.1 * Possible to use any editor (not only notepad.exe) for viewing files. * Welcome developers with README.md, CHANGES.md and COPYING.txt files. ##### Internal: - * Improve logging-API so now a single log-routine is used everywhere(instead of 3 different ones). * Implement an API for writing Header/Body json-files. + * Apply Object-oriented design weith resource-management when I/O files. + * Improve logging-API so now a single log-routine is used everywhere(instead of 3 different ones). * General restructuring of the folders and names in the project. More analytically: diff --git a/CSE/ApplicationEvents.vb b/CSE/ApplicationEvents.vb index cfed1b5b51e0f1bc3a832fb4d8622664b85b7dd0..5204e7d347d0c33a8c1b092bd531f98eaff6e875 100644 --- a/CSE/ApplicationEvents.vb +++ b/CSE/ApplicationEvents.vb @@ -27,71 +27,86 @@ End Sub Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup - ' Declaration - Dim fiAss As New IO.FileInfo(joinPaths(Application.Info.DirectoryPath, Application.Info.AssemblyName & ".exe")) + Try + ' Declaration + Dim fiAss As New IO.FileInfo(joinPaths(Application.Info.DirectoryPath, Application.Info.AssemblyName & ".exe")) - AppPreferences = New cPreferences(True) ' !!!Skip schema-validation here, or else app hangs as zombie! (do it instead when creating new for Dialog) + Prefs = New cPreferences(True) ' !!!Skip schema-validation here, or else app hangs as zombie! (do it instead when creating new for Dialog) + 'F_Main.installJob(New cJob()) NO! cannot instantiate form without JOB/Crt. + Job = New cJob(True) ' !!!Skip schema + Crt = Job.Criteria - ' Path to the *.exe - MyPath = My.Application.Info.DirectoryPath & "\" - PreferencesPath = joinPaths(MyPath, "config", "preferences.json") - ' Generateion of folder for the file history if not exists - FB_FilHisDir = joinPaths(MyPath, "config", "fileHistory\") - If Not IO.Directory.Exists(FB_FilHisDir) Then IO.Directory.CreateDirectory(FB_FilHisDir) + ' Path to the *.exe + MyPath = My.Application.Info.DirectoryPath & "\" + PrefsPath = joinPaths(MyPath, "config", "preferences.json") - ' compile date - AppDate = fiAss.LastWriteTime.Date + ' Generateion of folder for the file history if not exists + FB_FilHisDir = joinPaths(MyPath, "config", "fileHistory\") + If Not IO.Directory.Exists(FB_FilHisDir) Then IO.Directory.CreateDirectory(FB_FilHisDir) - ' Licencemodul - Lic.FilePath = joinPaths(MyPath, "License.dat") - Lic.AppVersion = AppVers + ' compile date + AppDate = fiAss.LastWriteTime.Date - ' Declaration from the filebrowser optionen - fbVECTO = New cFileBrowser("CSE") - fbVECTO.Extensions = New String() {"csjob.json", "csjob"} + ' Licencemodul + Lic.FilePath = joinPaths(MyPath, "License.dat") + Lic.AppVersion = AppVers - fbTXT = New cFileBrowser("TXT") - fbTXT.Extensions = New String() {"txt"} + ' Declaration from the filebrowser optionen + fbVECTO = New cFileBrowser("CSE") + fbVECTO.Extensions = New String() {"csjob.json", "csjob"} - fbExe = New cFileBrowser("EXE") - fbExe.Extensions = New String() {"exe"} + fbTXT = New cFileBrowser("TXT") + fbTXT.Extensions = New String() {"txt"} - fbCSV = New cFileBrowser("CSV") - fbCSV.Extensions = New String() {"csv", "txt"} + fbExe = New cFileBrowser("EXE") + fbExe.Extensions = New String() {"exe"} - fbDir = New cFileBrowser("DIR", True) + fbCSV = New cFileBrowser("CSV") + fbCSV.Extensions = New String() {"csv", "txt"} - fbWorkDir = New cFileBrowser("DIR", True) + fbDir = New cFileBrowser("DIR", True) - fbVEH = New cFileBrowser("VEH.json") - fbVEH.Extensions = New String() {"csveh.json"} + fbWorkDir = New cFileBrowser("DIR", True) - fbAMB = New cFileBrowser("AMB") - fbAMB.Extensions = New String() {"csamb"} + fbVEH = New cFileBrowser("VEH.json") + fbVEH.Extensions = New String() {"csveh.json"} - fbALT = New cFileBrowser("ALT") - fbALT.Extensions = New String() {"csalt"} + fbAMB = New cFileBrowser("AMB") + fbAMB.Extensions = New String() {"csamb"} - fbVEL = New cFileBrowser("VEL") - fbVEL.Extensions = New String() {"csdat"} + fbALT = New cFileBrowser("ALT") + fbALT.Extensions = New String() {"csalt"} - fbMSC = New cFileBrowser("MSC") - fbMSC.Extensions = New String() {"csms"} + fbVEL = New cFileBrowser("VEL") + fbVEL.Extensions = New String() {"csdat"} - ' Initialise the key array - sKey = New csKey + fbMSC = New cFileBrowser("MSC") + fbMSC.Extensions = New String() {"csms"} + + ' Initialise the key array + sKey = New csKey + + 'Dim currentDomain As AppDomain = AppDomain.CurrentDomain + 'AddHandler currentDomain.UnhandledException, AddressOf Me.MyApplicationDomain_UnhandledException + Catch ex As Exception + MsgBox(format("{0} failed on init due to: \n\i{1}", AppName, ex), MsgBoxStyle.Critical, format("{0} failed to Start!", AppName)) + End Try - 'Dim currentDomain As AppDomain = AppDomain.CurrentDomain - 'AddHandler currentDomain.UnhandledException, AddressOf Me.MyApplicationDomain_UnhandledException End Sub Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal ev As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException - fInfWarErr(9, False, format("Unhandled exception: {0}", ev.Exception.Message), ev.Exception) + Dim ex As Exception = ev.Exception + If AppFormStarted Then + logme(9, False, format("Unhandled exception: \i{0}", ex.Message), ex) + ev.ExitApplication = False + Else + MsgBox(format("{0} failed after init due to: \n\i{1}", AppName, ex), MsgBoxStyle.Critical, format("{0} failed to Start!", AppName)) + End If End Sub 'Private Sub MyApplicationDomain_UnhandledException(ByVal sender As Object, ByVal ev As UnhandledExceptionEventArgs) ' Dim ex As Exception = DirectCast(ev.ExceptionObject, Exception) - ' fInfWarErr(9, False, format("Worked's unhandled exception: {0}", ex.Message), ex) + ' logme(9, False, format("Worked's unhandled exception: {0}", ex.Message), ex) 'End Sub End Class diff --git a/CSE/CSE.vbproj b/CSE/CSE.vbproj index ad406cf7496fdcddcddba08cb36e914c6da49118..fb07c4e08d2546c88d13b885564e60b86cc02562 100644 --- a/CSE/CSE.vbproj +++ b/CSE/CSE.vbproj @@ -174,7 +174,6 @@ <Compile Include="utils.vb" /> <Compile Include="Classes\cFile_v3.vb" /> <Compile Include="CSE_Globals.vb" /> - <Compile Include="CSE_Types.vb" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="GUI\F_Preferences.resx"> diff --git a/CSE/CSE_Globals.vb b/CSE/CSE_Globals.vb index 8a7322206d8d20d2144870f298585edfe08a2e6b..af5d6700fc4fde265c19173a1a2e63ca0982b6c7 100644 --- a/CSE/CSE_Globals.vb +++ b/CSE/CSE_Globals.vb @@ -1,4 +1,191 @@ Module CSE_Globals + Public Enum tComp + t + lati + longi + hdg + v_veh_GPS + v_veh_CAN + vair_ar + beta_ar + n_eng + tq_l + tq_r + t_amb_veh + t_tire + p_tire + fc + trigger + user_valid + Undefined + End Enum + + Public Enum tCompWeat + t + t_amb_stat + p_amp_stat + rh_stat + Undefined + End Enum + + Public Enum tCompCali + t + zone_UTM + lati_UTM + longi_UTM + trigger_c + SecID + DirID + lati_root + longi_root + v_veh_c + vair_ic + vair_uf + beta_ic + beta_uf + vwind_ha + vwind_c + vwind_1s + vair_c + vair_c_sq + beta_c + dist + dist_root + alt + slope_deg + omega_wh + omega_p_wh + tq_sum + tq_sum_1s + t_float + tq_sum_float + F_trac + v_veh_acc + a_veh_avg + F_acc + F_grd + F_res + v_veh_1s + v_veh_float + t_amp_veh + t_amp_stat + p_amp_stat + rh_stat + End Enum + + Public Enum tCompErg + SecID + DirID + RunID + HeadID + delta_t + v_veh + v_MSC + v_MSC_GPS + s_MSC + v_veh_CAN + vair_ar + vair_ic + vair_uf + vair + beta_ar + beta_ic + beta_uf + user_valid + valid + used + calcT + n_eng + v_wind_avg + v_wind_1s + v_wind_1s_max + beta_avg + dist + omega_wh + omega_p_wh + tq_sum_1s + t_float + tq_sum_float + F_trac + F_res_ref + v_veh_avg + a_veh_avg + F_acc + F_grd + F_res + v_veh_1s + v_veh_float + t_amb_veh + t_amb_stat + p_amb_stat + rh_stat + v_air_sq + v_veh_1s_max + v_veh_1s_min + v_veh_float_max + v_veh_float_min + beta_abs + tq_sum + tq_sum_1s_max + tq_sum_1s_min + tq_sum_float_max + tq_sum_float_min + vp_H2O + rho_air + t_tire + p_tire + F0_ref_singleDS + F0_singleDS + F2_ref_singleDS + RRC_singleDS + CdxA_singleDS + val_User + val_vVeh_avg + val_vVeh_1s + val_vVeh_f + val_vWind + val_vWind_1s + val_tq_f + val_tq_1s + val_beta + val_dist + End Enum + + Public Enum tCompErgReg + SecID + DirID + F0 + F0_LS1 + F0_LS2 + F0_ref + F2_ref + F0_LS1_ref + F2_LS1_ref + F0_LS2_ref + F2_LS2_ref + roh_air_LS + beta_abs_HS + RRC + RRC_LS1 + RRC_LS2 + RRC_valid + CdxA + delta_CdxA + CdxA0 + F0_95 + F2_95 + R_sq + t_tire_LS_min + t_tire_LS_max + t_tire_HS_min + t_tire_HS_max + valid_t_tire + 't_amb + 't_amb_min + 't_amb_max + End Enum + + Public Function fComp(ByVal sK As String) As tComp sK = Trim(UCase(sK)) Select Case sK @@ -732,52 +919,4 @@ Return "ERROR" End Select End Function - - ' Function with the standard parameter - Public Sub StdParameter() - ' Standard values - trigger_delta_x_max = 10 ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (driving direction) - trigger_delta_y_max = 100 ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (perpendicular to driving direction) - delta_head_max = 10 ' [°]; +/- maximum deviation from heading as read from the csdat-file to the heading from csms-file for a valid dataset - segruns_min_CAL = 5 ' [#]; Minimum number of valid datasets required for the calibration test (per combination of MS ID and DIR ID) - segruns_min_LS = 1 ' [#]; Minimum number of valid datasets required for the low speed test (per combination of MS ID and DIR ID) - segruns_min_HS = 2 ' [#]; Minimum number of valid datasets required for the high speed test (per combination of MS ID and DIR ID) - segruns_min_head_MS = 10 ' [#]; Minimum TOTAL number of valid datasets required for the high speed test per heading - delta_Hz_max = 1 ' [%]; maximum allowed deviation of timestep-size in csdat-file from 100Hz - acc_corr_avg = 1 ' [s] averaging of vehicle speed for correction of acceleration forces - dist_float = 25 ' [m]; Distance used for calculation of floating average signal used for stabilitay criteria in low speed tests - roh_air_ref = 1.1884 ' [kg/m^3] Reference air density - - ' Determination constances - delta_parallel_max = 20 ' [°]; maximum heading difference for measurement section (parallelism criteria for test track layout) - v_wind_avg_max_CAL = 5 ' [m/s]; maximum average wind speed during calibration test - beta_avg_max_CAL = 5 ' [°]; maximum average beta during calibration test - v_wind_1s_max_CAL = 8 ' [m/s]; maximum gust wind speed during calibration test - v_veh_avg_max_LS = 16 ' [km/h]; maximum average vehicle speed for low speed test - v_veh_avg_min_LS = 9 ' [km/h]; minimum average vehicle speed for low speed test - v_wind_avg_max_LS = 5 ' [m/s]; maximum average wind speed during low speed test - v_wind_1s_max_LS = 8 ' [m/s]; maximum gust wind speed during low speed test - v_veh_float_delta_LS = 0.15 ' [km/h]; +/- maximum deviation of floating average vehicle speed from average vehicle speed over entire section (low speed test) - tq_sum_float_delta_LS = 0.1 ' [-]; +/- maximum relative deviation of floating average torque from average torque over entire section (low speed test) - v_veh_avg_min_HS = 80 ' [km/h]; minimum average vehicle speed for high speed test - v_wind_avg_max_HS = 5 ' [m/s]; maximum average wind speed during high speed test - v_wind_1s_max_HS = 8 ' [m/s]; maximum gust wind speed during high speed test - beta_avg_max_HS = 3 ' [°]; maximum average beta during high speed test - v_veh_1s_delta_HS = 0.3 ' [km/h]; +/- maximum deviation of 1s average vehicle speed from average vehicle speed over entire section (high speed test) - tq_sum_1s_delta_HS = 0.1 ' [-]; +/- maximum relative deviation of 1s average torque from average torque over entire section (high speed test) - leng_crit = 3 ' [m]; maximum absolute difference of distance driven with lenght of section as specified in configuration - delta_t_tyre_max = 5 ' [°C]; maximum variation of tyre temperature between high speed tests and low speed tests - delta_rr_corr_max = 0.3 ' [kg/t]; maximum difference of RRC from the two low speed runs - t_amb_var = 3 ' [°C]; maximum variation of ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) - t_amb_max = 35 ' [°C]; Maximum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) - t_amb_tarmac = 25 ' [°C]; Maximum temperature below which no documentation of tarmac conditions is necessary - t_amb_min = 0 ' [°C]; Minimum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) - - ' Evaluation - accel_correction = False - gradient_correction = False - - ' Output - hz_out = 1 - End Sub End Module diff --git a/CSE/CSE_Types.vb b/CSE/CSE_Types.vb deleted file mode 100644 index 74a36612084026b45ae6ae556549429ceea1fca6..0000000000000000000000000000000000000000 --- a/CSE/CSE_Types.vb +++ /dev/null @@ -1,187 +0,0 @@ -Public Enum tComp - t - lati - longi - hdg - v_veh_GPS - v_veh_CAN - vair_ar - beta_ar - n_eng - tq_l - tq_r - t_amb_veh - t_tire - p_tire - fc - trigger - user_valid - Undefined -End Enum - -Public Enum tCompWeat - t - t_amb_stat - p_amp_stat - rh_stat - Undefined -End Enum - -Public Enum tCompCali - t - zone_UTM - lati_UTM - longi_UTM - trigger_c - SecID - DirID - lati_root - longi_root - v_veh_c - vair_ic - vair_uf - beta_ic - beta_uf - vwind_ha - vwind_c - vwind_1s - vair_c - vair_c_sq - beta_c - dist - dist_root - alt - slope_deg - omega_wh - omega_p_wh - tq_sum - tq_sum_1s - t_float - tq_sum_float - F_trac - v_veh_acc - a_veh_avg - F_acc - F_grd - F_res - v_veh_1s - v_veh_float - t_amp_veh - t_amp_stat - p_amp_stat - rh_stat -End Enum - -Public Enum tCompErg - SecID - DirID - RunID - HeadID - delta_t - v_veh - v_MSC - v_MSC_GPS - s_MSC - v_veh_CAN - vair_ar - vair_ic - vair_uf - vair - beta_ar - beta_ic - beta_uf - user_valid - valid - used - calcT - n_eng - v_wind_avg - v_wind_1s - v_wind_1s_max - beta_avg - dist - omega_wh - omega_p_wh - tq_sum_1s - t_float - tq_sum_float - F_trac - F_res_ref - v_veh_avg - a_veh_avg - F_acc - F_grd - F_res - v_veh_1s - v_veh_float - t_amb_veh - t_amb_stat - p_amb_stat - rh_stat - v_air_sq - v_veh_1s_max - v_veh_1s_min - v_veh_float_max - v_veh_float_min - beta_abs - tq_sum - tq_sum_1s_max - tq_sum_1s_min - tq_sum_float_max - tq_sum_float_min - vp_H2O - rho_air - t_tire - p_tire - F0_ref_singleDS - F0_singleDS - F2_ref_singleDS - RRC_singleDS - CdxA_singleDS - val_User - val_vVeh_avg - val_vVeh_1s - val_vVeh_f - val_vWind - val_vWind_1s - val_tq_f - val_tq_1s - val_beta - val_dist -End Enum - -Public Enum tCompErgReg - SecID - DirID - F0 - F0_LS1 - F0_LS2 - F0_ref - F2_ref - F0_LS1_ref - F2_LS1_ref - F0_LS2_ref - F2_LS2_ref - roh_air_LS - beta_abs_HS - RRC - RRC_LS1 - RRC_LS2 - RRC_valid - CdxA - delta_CdxA - CdxA0 - F0_95 - F2_95 - R_sq - t_tire_LS_min - t_tire_LS_max - t_tire_HS_min - t_tire_HS_max - valid_t_tire - 't_amb - 't_amb_min - 't_amb_max -End Enum - - diff --git a/CSE/Calculation/Minor_routines_calculate.vb b/CSE/Calculation/Minor_routines_calculate.vb index 15f532a055bdd11db7397df4d508ee57d0a617bd..b40edd1c509facabcb6418a090bc7c4114d2e1b9 100644 --- a/CSE/Calculation/Minor_routines_calculate.vb +++ b/CSE/Calculation/Minor_routines_calculate.vb @@ -36,7 +36,7 @@ ElseIf Dy < 0 And DX = 0 Then QuadReq = 180 Else - fInfWarErr(9, False, "The angle definition is not possible") + logme(9, False, "The angle definition is not possible") QuadReq = "x" End If End Function @@ -57,9 +57,9 @@ 'Check whether Time is not reversed For i = 1 To TimeX.Count - 1 If i = 1 Then tstep = TimeX(i) - TimeX(i - 1) - If tstep + (tstep * delta_Hz_max / 100) < Math.Abs(TimeX(i) - TimeX(i - 1)) Or tstep - (tstep * delta_Hz_max / 100) > Math.Abs(TimeX(i) - TimeX(i - 1)) Then + If tstep + (tstep * crt.delta_Hz_max / 100) < Math.Abs(TimeX(i) - TimeX(i - 1)) Or tstep - (tstep * crt.delta_Hz_max / 100) > Math.Abs(TimeX(i) - TimeX(i - 1)) Then If Sprung Then - fInfWarErr(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") + logme(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") Return False Else Sprung = True @@ -128,9 +128,9 @@ 'Check whether Time is not reversed For i = 1 To TimeX.Count - 1 If i = 1 Then tstep = TimeX(i) - TimeX(i - 1) - If tstep + (tstep * delta_Hz_max / 100) < Math.Abs(TimeX(i) - TimeX(i - 1)) Or tstep - (tstep * delta_Hz_max / 100) > Math.Abs(TimeX(i) - TimeX(i - 1)) Then + If tstep + (tstep * crt.delta_Hz_max / 100) < Math.Abs(TimeX(i) - TimeX(i - 1)) Or tstep - (tstep * crt.delta_Hz_max / 100) > Math.Abs(TimeX(i) - TimeX(i - 1)) Then If Sprung Then - fInfWarErr(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") + logme(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") Return False Else Sprung = True @@ -203,7 +203,7 @@ 'Check whether Time is not reversed For z = 1 To UBound(TimeX) If TimeX(z) < TimeX(z - 1) Then - fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & TimeX(z - 1) & "[s], t(" & z & ") = " & TimeX(z) & "[s]") + logme(9, False, "Time step invalid! t(" & z - 1 & ") = " & TimeX(z - 1) & "[s], t(" & z & ") = " & TimeX(z) & "[s]") Return False End If Next z @@ -339,12 +339,12 @@ Dim vline(), Line() As String ' Output on the GUI - fInfWarErr(5, False, "Read altitude file") + logme(5, False, "Read altitude file") ' Open the MSC spezification file If Not FileInAlt.OpenRead(File) Then ' Error if the file is not available - fInfWarErr(9, False, "Can´t find the altitude file: " & File) + logme(9, False, "Can´t find the altitude file: " & File) Return False End If @@ -353,7 +353,7 @@ vline = FileInAlt.ReadLine If dist < vline(0) Then - fInfWarErr(9, False, "The distance is lower then the minimum in the altitude file") + logme(9, False, "The distance is lower then the minimum in the altitude file") BWorker.CancelAsync() fAltInterp = 0 End If @@ -431,7 +431,7 @@ ' Erreor message wehen lambda can not be calculated If i = 0 Then - fInfWarErr(9, False, "Was not able to calculate the distance and bearing between koordinates.") + logme(9, False, "Was not able to calculate the distance and bearing between koordinates.") BWorker.CancelAsync() Return 0 ' formula failed to converge End If diff --git a/CSE/Calculation/Signal_identification.vb b/CSE/Calculation/Signal_identification.vb index a8587cad0dab0a5fa744d1754e5c7ed2d820a0bf..c20ebde1088ad550dee320fed69eb38984497d16 100644 --- a/CSE/Calculation/Signal_identification.vb +++ b/CSE/Calculation/Signal_identification.vb @@ -1,6 +1,8 @@ -Module Signal_identification +Imports CSE.cCriteria +Module Signal_identification + ' Divide the signal into there directions - Public Function fIdentifyMS(ByVal MSC As cMSC, ByRef vMSC As cVirtMSC, Optional virtMSC As Boolean = True, Optional ByVal SectionDev As Boolean = True) As Boolean + Public Function fIdentifyMS(ByVal MSC As cMSC, ByRef vMSC As cVirtMSC, Optional ByVal virtMSC As Boolean = True, Optional ByVal SectionDev As Boolean = True) As Boolean If virtMSC Then ' Calculation of the virtual MSC points fvirtMSC(MSC, vMSC) @@ -8,7 +10,7 @@ If SectionDev Then ' Output on the GUI - fInfWarErr(6, False, "Identifying the sections") + logme(6, False, "Identifying the sections") ' Devide the measured data into there sections DevInSec(vMSC) @@ -16,7 +18,7 @@ ' Leap in time control If JumpPoint <> -1 Then If CalcData(tCompCali.SecID)(JumpPoint) <> 0 Then - fInfWarErr(9, False, "The detected leap in time is inside a measurement section. This is not allowed!") + logme(9, False, "The detected leap in time is inside a measurement section. This is not allowed!") BWorker.CancelAsync() Return False End If @@ -52,8 +54,8 @@ Aae = QuadReq(UTMCoordV.Easting - UTMCoordP.Easting, UTMCoordV.Northing - UTMCoordP.Northing) MSCVirt.meID.Add(MSCOrg.meID(i)) MSCVirt.dID.Add(MSCOrg.dID(i)) - MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, 0, -trigger_delta_y_max)) - MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, 0, trigger_delta_y_max)) + MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, 0, -Crt.trigger_delta_y_max)) + MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, 0, Crt.trigger_delta_y_max)) MSCVirt.NewSec.Add(False) MSCVirt.Head.Add(MSCOrg.head(i)) @@ -62,16 +64,16 @@ MSCVirt.NewSec.Add(True) MSCVirt.meID.Add(0) MSCVirt.dID.Add(MSCOrg.dID(i)) - MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -trigger_delta_y_max)) - MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), trigger_delta_y_max)) + MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -Crt.trigger_delta_y_max)) + MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), Crt.trigger_delta_y_max)) MSCVirt.Head.Add(MSCOrg.head(i)) End If ElseIf i = MSCOrg.meID.Count - 1 Then MSCVirt.NewSec.Add(True) MSCVirt.meID.Add(0) MSCVirt.dID.Add(MSCOrg.dID(i)) - MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -trigger_delta_y_max)) - MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), trigger_delta_y_max)) + MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -Crt.trigger_delta_y_max)) + MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), Crt.trigger_delta_y_max)) MSCVirt.Head.Add(MSCOrg.head(i)) End If Next i @@ -111,7 +113,7 @@ h = Math.Sqrt((DXep ^ 2 + DYep ^ 2) - p ^ 2) ' Appropriate if the point is in the detection area - If h <= trigger_delta_x_max And p > 0 And q > 0 Then + If h <= Crt.trigger_delta_x_max And p > 0 And q > 0 Then Return True Else Return False @@ -211,7 +213,7 @@ ' Set the direction ID For j = 1 To UBound(SecTest) If SecTest(j) Then - If Math.Abs(InputData(tComp.hdg)(i) - vMSCX.Head(j)) <= delta_head_max Then + If Math.Abs(InputData(tComp.hdg)(i) - vMSCX.Head(j)) <= Crt.delta_head_max Then DirID = vMSCX.dID(j) End If End If @@ -385,8 +387,8 @@ ' Calculate the section average values For i = 0 To CalcData(tCompCali.SecID).Count - 1 - CalcData(tCompCali.vair_ic).Add(InputData(tComp.vair_ar)(i) * AnemIC(0) + AnemIC(1)) - CalcData(tCompCali.beta_ic).Add(InputData(tComp.beta_ar)(i) * AnemIC(2) + AnemIC(3)) + CalcData(tCompCali.vair_ic).Add(InputData(tComp.vair_ar)(i) * Job.Anemometer(0) + Job.Anemometer(1)) + CalcData(tCompCali.beta_ic).Add(InputData(tComp.beta_ar)(i) * Job.Anemometer(2) + Job.Anemometer(3)) For Each sKVC In CalcData If CalcData(sKVC.Key).Count <= i Then CalcData(sKVC.Key).Add(0) @@ -663,7 +665,7 @@ End Function ' Calculate the corrected vehicle speed - Public Function fCalcSpeedVal(ByVal orgMSCX As cMSC, ByVal vehicleX As cVehicle, ByVal TestRunX As Integer) As Boolean + Public Function fCalcSpeedVal(ByVal orgMSCX As cMSC, ByVal vehicleX As cVehicle, ByVal coastingSeq As Integer) As Boolean ' Declaration Dim i, j, run, anz, RunIDx As Integer Dim firstIn As Boolean = True @@ -672,9 +674,9 @@ ' Initialise run = 0 anz = 0 - If TestRunX = 1 Or TestRunX = 3 Then + If coastingSeq = 0 Or coastingSeq = 2 Then igear = vehicleX.gearRatio_low - If TestRunX = 1 Then + If coastingSeq = 0 Then RunIDx = IDLS1 Else RunIDx = IDLS2 @@ -700,16 +702,16 @@ ' Time If CalcData(tCompCali.v_veh_c)(i) < (2.5 * 3.6) Then - CalcData(tCompCali.t_float)(i) = dist_float / 2.5 + CalcData(tCompCali.t_float)(i) = Crt.dist_float / 2.5 Else - CalcData(tCompCali.t_float)(i) = dist_float / (CalcData(tCompCali.v_veh_c)(i) / 3.6) + CalcData(tCompCali.t_float)(i) = Crt.dist_float / (CalcData(tCompCali.v_veh_c)(i) / 3.6) End If ' F trac raw CalcData(tCompCali.F_trac)(i) = (InputData(tComp.tq_l)(i) + InputData(tComp.tq_r)(i)) * CalcData(tCompCali.omega_wh)(i) / (CalcData(tCompCali.v_veh_c)(i) / 3.6) - If gradient_correction Then + If Crt.gradient_correction Then If CalcData(tCompCali.SecID)(i) <> 0 Then ' Altitude CalcData(tCompCali.alt)(i) = fAltInterp(orgMSCX.AltPath(fSecPos(orgMSCX, CalcData(tCompCali.SecID)(i), CalcData(tCompCali.DirID)(i))), CalcData(tCompCali.dist_root)(i)) @@ -723,7 +725,7 @@ For j = 0 To InputWeatherData(tCompWeat.t).Count - 1 If j = 0 Then If CalcData(tCompCali.t)(i) < InputWeatherData(tCompWeat.t)(j) And j = 0 Then - fInfWarErr(9, False, "The test time is outside the range of the data from the stationary weather station.") + logme(9, False, "The test time is outside the range of the data from the stationary weather station.") BWorker.CancelAsync() Return False ElseIf CalcData(tCompCali.t)(i) >= InputWeatherData(tCompWeat.t)(j) And CalcData(tCompCali.t)(i) < InputWeatherData(tCompWeat.t)(j + 1) Then @@ -741,7 +743,7 @@ End If End If If j = InputWeatherData(tCompWeat.t).Count - 1 Then - fInfWarErr(9, False, "The test time is outside the range of the data from the stationary weather station.") + logme(9, False, "The test time is outside the range of the data from the stationary weather station.") BWorker.CancelAsync() Return False End If @@ -752,7 +754,7 @@ fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.tq_sum), CalcData(tCompCali.tq_sum_float), CalcData(tCompCali.t_float)) fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.tq_sum), CalcData(tCompCali.tq_sum_1s)) fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.v_veh_c), CalcData(tCompCali.v_veh_1s)) - fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.v_veh_c), CalcData(tCompCali.v_veh_acc), acc_corr_avg) + fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.v_veh_c), CalcData(tCompCali.v_veh_acc), Crt.acc_corr_avg) fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.v_veh_c), CalcData(tCompCali.v_veh_float), CalcData(tCompCali.t_float)) ' Calculate the remaining values @@ -764,14 +766,14 @@ CalcData(tCompCali.a_veh_avg)(i) = (CalcData(tCompCali.v_veh_acc)(i + 1) - CalcData(tCompCali.v_veh_acc)(i - 1)) / (3.6 * 2) * HzIn End If - If gradient_correction Then + If Crt.gradient_correction Then If CalcData(tCompCali.SecID)(i) <> 0 Then ' Slope Deg If i > 0 And i < CalcData(tCompCali.SecID).Count - 1 Then If CalcData(tCompCali.SecID)(i - 1) = CalcData(tCompCali.SecID)(i) And CalcData(tCompCali.SecID)(i + 1) = CalcData(tCompCali.SecID)(i) Then If (CalcData(tCompCali.dist_root)(i + 1) - CalcData(tCompCali.dist_root)(i - 1)) = 0 Then CalcData(tCompCali.slope_deg)(i) = 0 - fInfWarErr(9, False, "Standstill or loss of vehicle speed signal inside MS not permitted (Error at line " & i & ")") + logme(9, False, "Standstill or loss of vehicle speed signal inside MS not permitted (Error at line " & i & ")") BWorker.CancelAsync() Else CalcData(tCompCali.slope_deg)(i) = (Math.Asin((CalcData(tCompCali.alt)(i + 1) - CalcData(tCompCali.alt)(i - 1)) / (CalcData(tCompCali.dist_root)(i + 1) - CalcData(tCompCali.dist_root)(i - 1)))) * 180 / Math.PI @@ -789,8 +791,8 @@ ' Force trajectory CalcData(tCompCali.F_res)(i) = CalcData(tCompCali.F_trac)(i) - If accel_correction Then CalcData(tCompCali.F_res)(i) -= CalcData(tCompCali.F_acc)(i) - If gradient_correction Then CalcData(tCompCali.F_res)(i) -= CalcData(tCompCali.F_grd)(i) + If Crt.accel_correction Then CalcData(tCompCali.F_res)(i) -= CalcData(tCompCali.F_acc)(i) + If Crt.gradient_correction Then CalcData(tCompCali.F_res)(i) -= CalcData(tCompCali.F_grd)(i) Next i @@ -892,9 +894,9 @@ ErgValues(tCompErg.vp_H2O)(run) = ((ErgValues(tCompErg.rh_stat)(run) / 100) * 611 * 10 ^ ((7.5 * ErgValues(tCompErg.t_amb_stat)(run)) / (237 + ErgValues(tCompErg.t_amb_stat)(run)))) ErgValues(tCompErg.rho_air)(run) = (ErgValues(tCompErg.p_amb_stat)(run) * 100 - ErgValues(tCompErg.vp_H2O)(run)) / (287.05 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) + ErgValues(tCompErg.vp_H2O)(run) / (461.9 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) If ErgValues(tCompErg.RunID)(run) = IDHS Then - ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS * (roh_air_ref / ErgValues(tCompErg.rho_air)(run)) + ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS * (Crt.roh_air_ref / ErgValues(tCompErg.rho_air)(run)) Else - ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * rr_corr_factor * (roh_air_ref / ErgValues(tCompErg.rho_air)(run)) + ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * Crt.rr_corr_factor * (Crt.roh_air_ref / ErgValues(tCompErg.rho_air)(run)) End If ErgValues(tCompErg.t_tire)(run) = ErgValues(tCompErg.t_tire)(run) / anz If OptPar(1) Then ErgValues(tCompErg.p_tire)(run) = ErgValues(tCompErg.p_tire)(run) / anz @@ -963,9 +965,9 @@ ErgValues(tCompErg.vp_H2O)(run) = ((ErgValues(tCompErg.rh_stat)(run) / 100) * 611 * 10 ^ ((7.5 * ErgValues(tCompErg.t_amb_stat)(run)) / (237 + ErgValues(tCompErg.t_amb_stat)(run)))) ErgValues(tCompErg.rho_air)(run) = (ErgValues(tCompErg.p_amb_stat)(run) * 100 - ErgValues(tCompErg.vp_H2O)(run)) / (287.05 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) + ErgValues(tCompErg.vp_H2O)(run) / (461.9 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) If ErgValues(tCompErg.RunID)(run) = IDHS Then - ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS * (roh_air_ref / ErgValues(tCompErg.rho_air)(run)) + ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS * (Crt.roh_air_ref / ErgValues(tCompErg.rho_air)(run)) Else - ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * rr_corr_factor * (roh_air_ref / ErgValues(tCompErg.rho_air)(run)) + ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * Crt.rr_corr_factor * (Crt.roh_air_ref / ErgValues(tCompErg.rho_air)(run)) End If ErgValues(tCompErg.t_tire)(run) = ErgValues(tCompErg.t_tire)(run) / anz If OptPar(1) Then ErgValues(tCompErg.p_tire)(run) = ErgValues(tCompErg.p_tire)(run) / anz diff --git a/CSE/Calculation/main_calculation_call.vb b/CSE/Calculation/main_calculation_call.vb index 6892bad31dc78f65004a8e3e7f4d0240c29b364e..ee229f97882145c3b91fe00ab93f8832e75589b4 100644 --- a/CSE/Calculation/main_calculation_call.vb +++ b/CSE/Calculation/main_calculation_call.vb @@ -20,16 +20,16 @@ Dim vMSC As New cVirtMSC ' Read the input data - fInfWarErr(7, False, "Reading Input Files...") - Dim vehicle As New cVehicle(Vehspez) - ReadInputMSC(MSC, MSCCSpez, isCalibrate) - ReadDataFile(DataSpez(0), MSC) + logme(7, False, "Reading Input Files...") + Dim vehicle As New cVehicle(Job.vehicle_fpath) + ReadInputMSC(MSC, Job.track_fpath, isCalibrate) + ReadDataFile(Job.calibration_fpath, MSC) ' Exit function if error is detected If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErr(7, False, "Calculating the calibration run...") + logme(7, False, "Calculating the calibration run...") ' Identify the signal measurement sections fIdentifyMS(MSC, vMSC) @@ -38,7 +38,7 @@ If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErr(6, False, "Calculating the calibration run parameter") + logme(6, False, "Calculating the calibration run parameter") ' Calculate the results from the calibration test fCalcCalib(MSC, vehicle) @@ -47,24 +47,23 @@ 'If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErr(7, False, "Writing the output files...") + logme(7, False, "Writing the output files...") ' Output - fOutDataCalc1Hz(DataSpez(0), isCalibrate) - fOutCalcRes(DataSpez, isCalibrate) + fOutDataCalc1Hz(Job.calibration_fpath, isCalibrate) + fOutCalcRes(isCalibrate) Else - ' Declarations Dim MSC As New cMSC Dim vMSC As New cVirtMSC ' Output on the GUI - fInfWarErr(7, False, "Calculating the speed runs...") + logme(7, False, "Calculating the speed runs...") ' Read the input files - fInfWarErr(7, False, "Reading Input Files...") - Dim vehicle As New cVehicle(Vehspez) - ReadInputMSC(MSC, MSCTSpez, isCalibrate) - ReadWeather(Ambspez) + logme(7, False, "Reading Input Files...") + Dim vehicle As New cVehicle(Job.vehicle_fpath) + ReadInputMSC(MSC, Job.MSCTSpez, isCalibrate) + ReadWeather(Job.ambient_fpath) ' Calculation of the virtual MSC points fIdentifyMS(MSC, vMSC, , False) @@ -73,22 +72,22 @@ If BWorker.CancellationPending Then Return False ' Output which test are calculated - For i = 1 To UBound(DataSpez) - If i = 2 Or i = 4 Then + For i = 0 To UBound(Job.coasting_fpaths) + If i = 0 Or i = 2 Then ' Output on the GUI - If i = 2 Then - fInfWarErr(7, False, "Calculating the first low speed run...") + If i = 0 Then + logme(7, False, "Calculating the first low speed run...") Else - fInfWarErr(7, False, "Calculating the second low speed run...") + logme(7, False, "Calculating the second low speed run...") End If Else ' Output on the GUI - fInfWarErr(7, False, "Calculating the high speed run...") + logme(7, False, "Calculating the high speed run...") End If ' Output on the GUI - fInfWarErr(6, False, "Reading the data file...") - ReadDataFile(DataSpez(i), MSC) + logme(6, False, "Reading the data file...") + ReadDataFile(Job.coasting_fpaths(i), MSC) ' Exit function if error is detected If BWorker.CancellationPending Then Return False @@ -100,19 +99,19 @@ If BWorker.CancellationPending Then Return False ' Calculate the run - fCalcRun(MSC, vehicle, i - 1) + fCalcRun(MSC, vehicle, i) ' Exit function if error is detected If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErr(6, False, "Writing the output files...") + logme(6, False, "Writing the output files...") ' Output - fOutDataCalc1Hz(DataSpez(i), isCalibrate) + fOutDataCalc1Hz(Job.coasting_fpaths(i), isCalibrate) ' Save the Result dictionaries - fSaveDic(i - 1) + fSaveDic(i) ' Exit function if error is detected If BWorker.CancellationPending Then Return False @@ -133,8 +132,8 @@ ' Exit function if error is detected If BWorker.CancellationPending Then ' Write the summerised output file - fInfWarErr(7, False, "Writing the summarised output file...") - fOutCalcRes(DataSpez, isCalibrate) + logme(7, False, "Writing the summarised output file...") + fOutCalcRes(isCalibrate) Return False End If @@ -142,8 +141,8 @@ fCalcReg(vehicle) ' Write the summerised output file - fInfWarErr(7, False, "Writing the summarised output file...") - fOutCalcRes(DataSpez, isCalibrate) + logme(7, False, "Writing the summarised output file...") + fOutCalcRes(isCalibrate) ' Check if all is valid For i = 0 To ErgValuesReg(tCompErgReg.SecID).Count - 1 @@ -152,13 +151,13 @@ Next i ' Output of the final data - fOutCalcResReg(DataSpez) + fOutCalcResReg() ' Write the results on the GUI - fInfWarErr(7, False, "Results from the calculation") - fInfWarErr(6, False, "average absolute beta HS test: " & Math.Round(beta, 4)) - fInfWarErr(6, False, "delta CdxA correction: " & Math.Round(delta_CdxA, 4)) - fInfWarErr(6, False, "CdxA(0): " & Math.Round(CdxA0, 4)) + logme(7, False, "Results from the calculation") + logme(6, False, "average absolute beta HS test: " & Math.Round(beta, 4)) + logme(6, False, "delta CdxA correction: " & Math.Round(delta_CdxA, 4)) + logme(6, False, "CdxA(0): " & Math.Round(CdxA0, 4)) ' Clear the dictionaries ErgValuesComp = Nothing @@ -221,7 +220,7 @@ ' Error If run > 10 Then - fInfWarErr(9, False, "The calibration is not possible because iteration for valid datasets does not converge (n>10)") + logme(9, False, "The calibration is not possible because iteration for valid datasets does not converge (n>10)") Change = False BWorker.CancelAsync() Return False @@ -232,7 +231,7 @@ End Function ' Calculate the speed run parameter - Function fCalcRun(ByVal MSCX As cMSC, ByVal vehicleX As cVehicle, ByVal TestRun As Integer) As Boolean + Function fCalcRun(ByVal MSCX As cMSC, ByVal vehicleX As cVehicle, ByVal coastingSeq As Integer) As Boolean ' Calculate the corrected vehicle speed fCalcCorVveh() @@ -246,10 +245,10 @@ fWindBetaAirErg() ' Calculate the other speed run relevant values - fCalcSpeedVal(MSCX, vehicleX, TestRun) + fCalcSpeedVal(MSCX, vehicleX, coastingSeq) ' Evaluate the valid sections - fCalcValidSec(MSCX, TestRun) + fCalcValidSec(MSCX, coastingSeq) Return True End Function @@ -309,7 +308,7 @@ ' error message if the CAN velocity is 0 For i = 0 To UBound(CalcX) If ave_vn(i) = 0 And VSec(i) = 1 Then - fInfWarErr(9, False, "The measured vehicle velocity (v_veh_CAN) is 0 in section: " & CalcX(i)) + logme(9, False, "The measured vehicle velocity (v_veh_CAN) is 0 in section: " & CalcX(i)) BWorker.CancelAsync() Return False End If @@ -484,7 +483,7 @@ ' Set the values For i = 0 To ErgValues(tCompErg.SecID).Count - 1 - If ErgValues(tCompErg.v_wind_avg)(i) < v_wind_avg_max_CAL And Math.Abs(ErgValues(tCompErg.beta_avg)(i)) < beta_avg_max_CAL And ErgValues(tCompErg.v_wind_1s_max)(i) < v_wind_1s_max_CAL And ErgValues(tCompErg.user_valid)(i) = 1 Then + If ErgValues(tCompErg.v_wind_avg)(i) < Crt.v_wind_avg_max_CAL And Math.Abs(ErgValues(tCompErg.beta_avg)(i)) < Crt.beta_avg_max_CAL And ErgValues(tCompErg.v_wind_1s_max)(i) < Crt.v_wind_1s_max_CAL And ErgValues(tCompErg.user_valid)(i) = 1 Then ErgValues(tCompErg.valid)(i) = 1 ErgValues(tCompErg.used)(i) = 1 Else @@ -552,7 +551,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErr(9, False, "Insufficent numbers of valid measurement sections available") + logme(9, False, "Insufficent numbers of valid measurement sections available") BWorker.CancelAsync() Return False End If @@ -562,7 +561,7 @@ For j = i + 1 To SecCount.NameSec.Count - 1 If Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2)) = Trim(Mid(SecCount.NameSec(j), 1, InStr(SecCount.NameSec(j), "(") - 2)) Then ' If enought sections in both directions are detected - If SecCount.AnzSec(i) >= segruns_min_CAL And SecCount.AnzSec(j) >= segruns_min_CAL Then + If SecCount.AnzSec(i) >= Crt.segruns_min_CAL And SecCount.AnzSec(j) >= Crt.segruns_min_CAL Then ' Set the whole sections on valid SecCount.ValidSec(i) = True SecCount.ValidSec(j) = True @@ -613,7 +612,7 @@ End If Next i If anz < 2 Then - fInfWarErr(9, False, "Insufficent numbers of valid measurement sections available") + logme(9, False, "Insufficent numbers of valid measurement sections available") BWorker.CancelAsync() Return False End If @@ -701,7 +700,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErr(9, False, "Insufficent numbers of valid measurement sections in the low speed test available") + logme(9, False, "Insufficent numbers of valid measurement sections in the low speed test available") BWorker.CancelAsync() Return False End If @@ -712,7 +711,7 @@ If Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2)) = Trim(Mid(SecCount.NameSec(j), 1, InStr(SecCount.NameSec(j), "(") - 2)) And _ Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), "(") + 1, InStr(SecCount.NameSec(i), ",") - (InStr(SecCount.NameSec(i), "(") + 1))) = Trim(Mid(SecCount.NameSec(j), InStr(SecCount.NameSec(j), "(") + 1, InStr(SecCount.NameSec(j), ",") - (InStr(SecCount.NameSec(j), "(") + 1))) Then ' If enought sections in both directions are detected - If SecCount.AnzSec(i) >= segruns_min_LS And SecCount.AnzSec(j) >= segruns_min_LS Then + If SecCount.AnzSec(i) >= Crt.segruns_min_LS And SecCount.AnzSec(j) >= Crt.segruns_min_LS Then ' If not both the same number If Not SecCount.AnzSec(i) = SecCount.AnzSec(j) Then @@ -741,7 +740,7 @@ End If End If Else - fInfWarErr(9, False, "Not enough valid data for low speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) + logme(9, False, "Not enough valid data for low speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) End If End If Next j @@ -817,7 +816,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErr(9, False, "Insufficent numbers of valid measurement sections in the high speed test available") + logme(9, False, "Insufficent numbers of valid measurement sections in the high speed test available") BWorker.CancelAsync() Return False End If @@ -827,7 +826,7 @@ For j = i + 1 To SecCount.NameSec.Count - 1 If Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), ",") + 1, InStr(SecCount.NameSec(i), ")") - (InStr(SecCount.NameSec(i), ",") + 1))) = Trim(Mid(SecCount.NameSec(j), InStr(SecCount.NameSec(j), ",") + 1, InStr(SecCount.NameSec(j), ")") - (InStr(SecCount.NameSec(j), ",") + 1))) Then ' If enought sections in both directions are detected - If SecCount.AnzSec(i) >= segruns_min_HS And SecCount.AnzSec(j) >= segruns_min_HS Then + If SecCount.AnzSec(i) >= Crt.segruns_min_HS And SecCount.AnzSec(j) >= Crt.segruns_min_HS Then ' Count the valid tests per HeadID Select Case Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), ",") + 1, InStr(SecCount.NameSec(i), ")") - (InStr(SecCount.NameSec(i), ",") + 1))) Case 1 @@ -835,12 +834,12 @@ Case 2 anzHS2 += SecCount.AnzSec(i) + SecCount.AnzSec(j) Case Else - fInfWarErr(9, False, "headID not known") + logme(9, False, "headID not known") BWorker.CancelAsync() Return False End Select Else - fInfWarErr(9, False, "Not enough valid data for high speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) + logme(9, False, "Not enough valid data for high speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) BWorker.CancelAsync() End If End If @@ -848,8 +847,8 @@ Next i ' Ceck if enough sections are detected - If anzHS1 < segruns_min_head_MS Or anzHS2 < segruns_min_head_MS Then - fInfWarErr(9, False, "Number of valid high speed datasets too low") + If anzHS1 < Crt.segruns_min_head_MS Or anzHS2 < Crt.segruns_min_head_MS Then + logme(9, False, "Number of valid high speed datasets too low") BWorker.CancelAsync() 'Return False End If @@ -892,26 +891,26 @@ End Function ' Evaluate the Valid sections - Function fCalcValidSec(ByVal MSCX As cMSC, ByVal RunTestX As Integer) As Boolean + Function fCalcValidSec(ByVal MSCX As cMSC, ByVal coastingSeq As Integer) As Boolean ' Declaration Dim i As Integer ' Evaluation - Select Case RunTestX - Case 1, 3 ' Low speed test + Select Case coastingSeq + Case 0, 2 ' Low speed test For i = 0 To ErgValues(tCompErg.SecID).Count - 1 ' Identify whitch criteria is not valid If ErgValues(tCompErg.user_valid)(i) = 1 Then ErgValues(tCompErg.val_User)(i) = 1 - If ErgValues(tCompErg.v_veh)(i) < v_veh_avg_max_LS And _ - ErgValues(tCompErg.v_veh)(i) > v_veh_avg_min_LS Then ErgValues(tCompErg.val_vVeh_avg)(i) = 1 - If ErgValues(tCompErg.v_wind_avg)(i) < v_wind_avg_max_LS Then ErgValues(tCompErg.val_vWind)(i) = 1 - If ErgValues(tCompErg.v_wind_1s_max)(i) < v_wind_1s_max_LS Then ErgValues(tCompErg.val_vWind_1s)(i) = 1 - If ErgValues(tCompErg.v_veh_float_max)(i) < (ErgValues(tCompErg.v_veh)(i) + v_veh_float_delta_LS) And _ - ErgValues(tCompErg.v_veh_float_min)(i) > (ErgValues(tCompErg.v_veh)(i) - v_veh_float_delta_LS) Then ErgValues(tCompErg.val_vVeh_f)(i) = 1 - If ErgValues(tCompErg.tq_sum_float_max)(i) < (ErgValues(tCompErg.tq_sum)(i) * (1 + tq_sum_float_delta_LS)) And _ - ErgValues(tCompErg.tq_sum_float_min)(i) > (ErgValues(tCompErg.tq_sum)(i) * (1 - tq_sum_float_delta_LS)) Then ErgValues(tCompErg.val_tq_f)(i) = 1 - If ErgValues(tCompErg.dist)(i) < fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) + leng_crit And _ - ErgValues(tCompErg.dist)(i) > fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) - leng_crit Then ErgValues(tCompErg.val_dist)(i) = 1 + If ErgValues(tCompErg.v_veh)(i) < Crt.v_veh_avg_max_LS And _ + ErgValues(tCompErg.v_veh)(i) > Crt.v_veh_avg_min_LS Then ErgValues(tCompErg.val_vVeh_avg)(i) = 1 + If ErgValues(tCompErg.v_wind_avg)(i) < Crt.v_wind_avg_max_LS Then ErgValues(tCompErg.val_vWind)(i) = 1 + If ErgValues(tCompErg.v_wind_1s_max)(i) < Crt.v_wind_1s_max_LS Then ErgValues(tCompErg.val_vWind_1s)(i) = 1 + If ErgValues(tCompErg.v_veh_float_max)(i) < (ErgValues(tCompErg.v_veh)(i) + Crt.v_veh_float_delta_LS) And _ + ErgValues(tCompErg.v_veh_float_min)(i) > (ErgValues(tCompErg.v_veh)(i) - Crt.v_veh_float_delta_LS) Then ErgValues(tCompErg.val_vVeh_f)(i) = 1 + If ErgValues(tCompErg.tq_sum_float_max)(i) < (ErgValues(tCompErg.tq_sum)(i) * (1 + Crt.tq_sum_float_delta_LS)) And _ + ErgValues(tCompErg.tq_sum_float_min)(i) > (ErgValues(tCompErg.tq_sum)(i) * (1 - Crt.tq_sum_float_delta_LS)) Then ErgValues(tCompErg.val_tq_f)(i) = 1 + If ErgValues(tCompErg.dist)(i) < fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) + Crt.leng_crit And _ + ErgValues(tCompErg.dist)(i) > fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) - Crt.leng_crit Then ErgValues(tCompErg.val_dist)(i) = 1 ' Check if all criterias are valid If ErgValues(tCompErg.val_User)(i) = 1 And ErgValues(tCompErg.val_vVeh_avg)(i) = 1 And ErgValues(tCompErg.val_vWind)(i) = 1 And _ @@ -928,20 +927,20 @@ ErgValues(tCompErg.val_vVeh_1s)(i) = 1 ErgValues(tCompErg.val_tq_1s)(i) = 1 Next i - Case 2 ' high speed test + Case Else ' high speed test For i = 0 To ErgValues(tCompErg.SecID).Count - 1 ' Identify whitch criteria is not valid If ErgValues(tCompErg.user_valid)(i) = 1 Then ErgValues(tCompErg.val_User)(i) = 1 - If ErgValues(tCompErg.v_veh)(i) > v_veh_avg_min_HS Then ErgValues(tCompErg.val_vVeh_avg)(i) = 1 - If ErgValues(tCompErg.v_wind_avg)(i) < v_wind_avg_max_HS Then ErgValues(tCompErg.val_vWind)(i) = 1 - If ErgValues(tCompErg.v_wind_1s_max)(i) < v_wind_1s_max_HS Then ErgValues(tCompErg.val_vWind_1s)(i) = 1 - If ErgValues(tCompErg.beta_abs)(i) < beta_avg_max_HS Then ErgValues(tCompErg.val_beta)(i) = 1 - If ErgValues(tCompErg.v_veh_1s_max)(i) < (ErgValues(tCompErg.v_veh)(i) + v_veh_1s_delta_HS) And _ - ErgValues(tCompErg.v_veh_1s_min)(i) > (ErgValues(tCompErg.v_veh)(i) - v_veh_1s_delta_HS) Then ErgValues(tCompErg.val_vVeh_1s)(i) = 1 - If ErgValues(tCompErg.tq_sum_1s_max)(i) < (ErgValues(tCompErg.tq_sum)(i) * (1 + tq_sum_1s_delta_HS)) And _ - ErgValues(tCompErg.tq_sum_1s_min)(i) > (ErgValues(tCompErg.tq_sum)(i) * (1 - tq_sum_1s_delta_HS)) Then ErgValues(tCompErg.val_tq_1s)(i) = 1 - If ErgValues(tCompErg.dist)(i) < fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) + leng_crit And _ - ErgValues(tCompErg.dist)(i) > fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) - leng_crit Then ErgValues(tCompErg.val_dist)(i) = 1 + If ErgValues(tCompErg.v_veh)(i) > Crt.v_veh_avg_min_HS Then ErgValues(tCompErg.val_vVeh_avg)(i) = 1 + If ErgValues(tCompErg.v_wind_avg)(i) < Crt.v_wind_avg_max_HS Then ErgValues(tCompErg.val_vWind)(i) = 1 + If ErgValues(tCompErg.v_wind_1s_max)(i) < Crt.v_wind_1s_max_HS Then ErgValues(tCompErg.val_vWind_1s)(i) = 1 + If ErgValues(tCompErg.beta_abs)(i) < Crt.beta_avg_max_HS Then ErgValues(tCompErg.val_beta)(i) = 1 + If ErgValues(tCompErg.v_veh_1s_max)(i) < (ErgValues(tCompErg.v_veh)(i) + Crt.v_veh_1s_delta_HS) And _ + ErgValues(tCompErg.v_veh_1s_min)(i) > (ErgValues(tCompErg.v_veh)(i) - Crt.v_veh_1s_delta_HS) Then ErgValues(tCompErg.val_vVeh_1s)(i) = 1 + If ErgValues(tCompErg.tq_sum_1s_max)(i) < (ErgValues(tCompErg.tq_sum)(i) * (1 + Crt.tq_sum_1s_delta_HS)) And _ + ErgValues(tCompErg.tq_sum_1s_min)(i) > (ErgValues(tCompErg.tq_sum)(i) * (1 - Crt.tq_sum_1s_delta_HS)) Then ErgValues(tCompErg.val_tq_1s)(i) = 1 + If ErgValues(tCompErg.dist)(i) < fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) + Crt.leng_crit And _ + ErgValues(tCompErg.dist)(i) > fSecLen(MSCX, ErgValues(tCompErg.SecID)(i), ErgValues(tCompErg.DirID)(i)) - Crt.leng_crit Then ErgValues(tCompErg.val_dist)(i) = 1 ' Check if all criterias are valid If ErgValues(tCompErg.val_User)(i) = 1 And ErgValues(tCompErg.val_vVeh_avg)(i) = 1 And ErgValues(tCompErg.val_vWind)(i) = 1 And ErgValues(tCompErg.val_vWind_1s)(i) = 1 And _ @@ -963,13 +962,13 @@ End Function ' Save the Dictionaries - Function fSaveDic(ByVal TestRunX As Integer) As Boolean + Function fSaveDic(ByVal coastingSeq As Integer) As Boolean ' Declaration Dim sKV As New KeyValuePair(Of tCompErg, List(Of Double)) Dim sKVUndef As New KeyValuePair(Of String, List(Of Double)) ' Initialisation - If TestRunX = 1 Then + If coastingSeq = 0 Then ErgValuesComp = New Dictionary(Of tCompErg, List(Of Double)) ErgValuesUndefComp = New Dictionary(Of String, List(Of Double)) UnitsErgUndefComp = New Dictionary(Of String, List(Of String)) @@ -989,11 +988,7 @@ Else ' Add the ResultValues to the complet dictionary For Each sKV In ErgValues - Dim o = ErgValuesComp(sKV.Key) - If (o Is Nothing) Then - Else - ErgValuesComp(sKV.Key).AddRange(ErgValues(sKV.Key)) - End If + ErgValuesComp(sKV.Key).AddRange(ErgValues(sKV.Key)) Next For Each sKVUndef In ErgValuesUndef ErgValuesUndefComp(sKVUndef.Key).AddRange(ErgValuesUndef(sKVUndef.Key)) diff --git a/CSE/Calculation/sub_linear_regression.vb b/CSE/Calculation/sub_linear_regression.vb index efc37b2091241875854740a0bcfa2e546d72f8bd..a116b4e11e9cf243ea74ab45c9bae17fa4cd0148 100644 --- a/CSE/Calculation/sub_linear_regression.vb +++ b/CSE/Calculation/sub_linear_regression.vb @@ -10,7 +10,7 @@ Dim EnumStr As tCompErgReg ' Output on the GUI - fInfWarErr(7, False, "Calculate the linear regression...") + logme(7, False, "Calculate the linear regression...") ' Initialisation lauf = -1 @@ -207,10 +207,10 @@ ' Save the values ErgValuesComp(tCompErg.F0_ref_singleDS)(PosHS(j)) = F0 - ErgValuesComp(tCompErg.F0_singleDS)(PosHS(j)) = F0 * (ErgValuesComp(tCompErg.rho_air)(PosHS(j)) / roh_air_ref) + ErgValuesComp(tCompErg.F0_singleDS)(PosHS(j)) = F0 * (ErgValuesComp(tCompErg.rho_air)(PosHS(j)) / Crt.roh_air_ref) ErgValuesComp(tCompErg.F2_ref_singleDS)(PosHS(j)) = F2 ErgValuesComp(tCompErg.RRC_singleDS)(PosHS(j)) = (ErgValuesComp(tCompErg.F0_singleDS)(PosHS(j)) / (vehicle.testMass * 9.81)) * 1000 - ErgValuesComp(tCompErg.CdxA_singleDS)(PosHS(j)) = 2 * F2 / roh_air_ref + ErgValuesComp(tCompErg.CdxA_singleDS)(PosHS(j)) = 2 * F2 / Crt.roh_air_ref Next j '***** Calculate the linear regression for LS1 @@ -228,7 +228,7 @@ ' Save the values ErgValuesReg(tCompErgReg.F0_LS1_ref).Add(F0) - ErgValuesReg(tCompErgReg.F0_LS1).Add(F0 * (Roh_air_LS1 / numLS1) / roh_air_ref) + ErgValuesReg(tCompErgReg.F0_LS1).Add(F0 * (Roh_air_LS1 / numLS1) / Crt.roh_air_ref) ErgValuesReg(tCompErgReg.F2_LS1_ref).Add(F2) ErgValuesReg(tCompErgReg.RRC_LS1).Add((ErgValuesReg(tCompErgReg.F0_LS1)(lauf) / (vehicle.testMass * 9.81)) * 1000) @@ -247,11 +247,11 @@ ' Save the values ErgValuesReg(tCompErgReg.F0_LS2_ref).Add(F0) - ErgValuesReg(tCompErgReg.F0_LS2).Add(F0 * (Roh_air_LS2 / numLS2) / roh_air_ref) + ErgValuesReg(tCompErgReg.F0_LS2).Add(F0 * (Roh_air_LS2 / numLS2) / Crt.roh_air_ref) ErgValuesReg(tCompErgReg.F2_LS2_ref).Add(F2) ErgValuesReg(tCompErgReg.RRC_LS2).Add((ErgValuesReg(tCompErgReg.F0_LS2)(lauf) / (vehicle.testMass * 9.81)) * 1000) - If Math.Abs(ErgValuesReg(tCompErgReg.RRC_LS1)(lauf) - ErgValuesReg(tCompErgReg.RRC_LS2)(lauf)) > delta_rr_corr_max Then + If Math.Abs(ErgValuesReg(tCompErgReg.RRC_LS1)(lauf) - ErgValuesReg(tCompErgReg.RRC_LS2)(lauf)) > Crt.delta_rr_corr_max Then ErgValuesReg(tCompErgReg.RRC_valid).Add(0) Else ErgValuesReg(tCompErgReg.RRC_valid).Add(1) @@ -280,14 +280,14 @@ ' Calculate additional values ErgValuesReg(tCompErgReg.roh_air_LS)(lauf) = ErgValuesReg(tCompErgReg.roh_air_LS)(lauf) / (numLS1 + numLS2) ErgValuesReg(tCompErgReg.beta_abs_HS)(lauf) = ErgValuesReg(tCompErgReg.beta_abs_HS)(lauf) / (numHS) - ErgValuesReg(tCompErgReg.F0).Add(F0 * (ErgValuesReg(tCompErgReg.roh_air_LS)(lauf) / roh_air_ref)) + ErgValuesReg(tCompErgReg.F0).Add(F0 * (ErgValuesReg(tCompErgReg.roh_air_LS)(lauf) / Crt.roh_air_ref)) ErgValuesReg(tCompErgReg.RRC).Add(ErgValuesReg(tCompErgReg.F0)(lauf) / (vehicle.testMass * 9.81) * 1000) - ErgValuesReg(tCompErgReg.CdxA).Add(2 * F2 / roh_air_ref) + ErgValuesReg(tCompErgReg.CdxA).Add(2 * F2 / Crt.roh_air_ref) ErgValuesReg(tCompErgReg.delta_CdxA).Add(fCalcGenShp(ErgValuesReg(tCompErgReg.beta_abs_HS)(lauf), vehicle)) ErgValuesReg(tCompErgReg.CdxA0).Add(ErgValuesReg(tCompErgReg.CdxA)(lauf) - ErgValuesReg(tCompErgReg.delta_CdxA)(lauf)) - If ErgValuesReg(tCompErgReg.t_tire_LS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_HS_max)(lauf) - delta_t_tyre_max) Or _ - ErgValuesReg(tCompErgReg.t_tire_LS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_LS_max)(lauf) - delta_t_tyre_max) Or _ - ErgValuesReg(tCompErgReg.t_tire_HS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_HS_max)(lauf) - delta_t_tyre_max) Then + If ErgValuesReg(tCompErgReg.t_tire_LS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_HS_max)(lauf) - Crt.delta_t_tyre_max) Or _ + ErgValuesReg(tCompErgReg.t_tire_LS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_LS_max)(lauf) - Crt.delta_t_tyre_max) Or _ + ErgValuesReg(tCompErgReg.t_tire_HS_min)(lauf) < (ErgValuesReg(tCompErgReg.t_tire_HS_max)(lauf) - Crt.delta_t_tyre_max) Then ErgValuesReg(tCompErgReg.valid_t_tire).Add(0) Else ErgValuesReg(tCompErgReg.valid_t_tire).Add(1) @@ -321,17 +321,17 @@ ' Test validation t_amb_f = t_amb_f / t_amb_num - If (t_amb_f - t_amb_min_f) > t_amb_var Or (t_amb_max_f - t_amb_f) > t_amb_var Then - fInfWarErr(9, False, "Invalid test - variation of ambient temperature (at the vehicle) outside boundaries") + If (t_amb_f - t_amb_min_f) > Crt.t_amb_var Or (t_amb_max_f - t_amb_f) > Crt.t_amb_var Then + logme(9, False, "Invalid test - variation of ambient temperature (at the vehicle) outside boundaries") valid_t_amb = False End If - If t_amb_max_f > t_amb_max Then - fInfWarErr(9, False, "Invalid test - maximum ambient temperature exceeded") - ElseIf t_amb_min_f < t_amb_min Then - fInfWarErr(9, False, "Invalid test - fallen below minimum ambient temperature") - ElseIf t_amb_max_f > t_amb_tarmac Then - fInfWarErr(9, False, "Invalid test - Ambient temperature higher than " & t_amb_tarmac & "°C") + If t_amb_max_f > Crt.t_amb_max Then + logme(9, False, "Invalid test - maximum ambient temperature exceeded") + ElseIf t_amb_min_f < Crt.t_amb_min Then + logme(9, False, "Invalid test - fallen below minimum ambient temperature") + ElseIf t_amb_max_f > Crt.t_amb_tarmac Then + logme(9, False, "Invalid test - Ambient temperature higher than " & Crt.t_amb_tarmac & "°C") End If Return True @@ -414,10 +414,10 @@ End If If i = GenShape.x_val(pos).Length - 1 And beta > GenShape.x_val(pos)(i + 1) Then ValueX = 0 - fInfWarErr(8, False, "The calculated yaw angle is higher than the greatest value in the generic curve. Delta_CdxA is set to 0!") + logme(8, False, "The calculated yaw angle is higher than the greatest value in the generic curve. Delta_CdxA is set to 0!") ElseIf i = 0 And GenShape.x_val(pos)(i) > beta Then ValueX = 0 - fInfWarErr(8, False, "The calculated yaw angle is lower than the lowest value in the generic curve. Delta_CdxA is set to 0!") + logme(8, False, "The calculated yaw angle is lower than the lowest value in the generic curve. Delta_CdxA is set to 0!") End If Next i diff --git a/CSE/Classes/cFile_v3.vb b/CSE/Classes/cFile_v3.vb index d8d07a87880e33d4ac0ae08c90f3ae7f00309276..75ccce7e5b92b103ee4b2b6614e077b2aadbc00b 100644 --- a/CSE/Classes/cFile_v3.vb +++ b/CSE/Classes/cFile_v3.vb @@ -142,7 +142,7 @@ lb10: Try Me.Close() Catch ex As Exception - fInfWarErr(8, False, format( _ + logme(8, False, format( _ "Skipped exception while closing file_v3({0}) due to: {1}", Me.Path, ex.Message), ex) End Try End Sub diff --git a/CSE/GUI/FB_Dialog.vb b/CSE/GUI/FB_Dialog.vb index 3609793beca97bae302a7bbcded31e5ef0807f31..52114e3608e5ca7986aa1b9590f52a2f5f820a54 100644 --- a/CSE/GUI/FB_Dialog.vb +++ b/CSE/GUI/FB_Dialog.vb @@ -131,7 +131,7 @@ Public Class FB_Dialog HasExt = True Else 'Check ob Datei mit Ext angegeben - HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) + HasExt = (Microsoft.VisualBasic.Len(fEXT(path)) > 1) End If 'Falls Datei ohne Endung (nach bForceExt-Abfrage) und nicht existiert dann primäre Endung hinzufügen If Not HasExt Then @@ -687,7 +687,7 @@ Public Class FB_Dialog 'ButtonWorkDir_Click Private Sub ButtonWorkDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonWorkDir.Click - SetFolder(AppPreferences.workingDir) + SetFolder(Prefs.workingDir) End Sub 'ButtonDesktop_Click diff --git a/CSE/GUI/F_Main.Designer.vb b/CSE/GUI/F_Main.Designer.vb index c614fdc637c2e07f8fe7e3caa7b9a0720ece0338..5fc3289cb8ccc93356ab2d0f3b811cada459bdf9 100644 --- a/CSE/GUI/F_Main.Designer.vb +++ b/CSE/GUI/F_Main.Designer.vb @@ -1157,7 +1157,7 @@ Partial Class F_Main Me.TabPageMSG.Padding = New System.Windows.Forms.Padding(2) Me.TabPageMSG.Size = New System.Drawing.Size(522, 93) Me.TabPageMSG.TabIndex = 0 - Me.TabPageMSG.Text = "Messages" + Me.TabPageMSG.Text = "Messages(0)" Me.TabPageMSG.UseVisualStyleBackColor = True ' 'ListBoxMSG diff --git a/CSE/GUI/F_Main.vb b/CSE/GUI/F_Main.vb index de1ac8a8a2ed8ae9120935a142e922c9de26890e..53cce791a7af491f28d494cc618480d8f674d5b7 100644 --- a/CSE/GUI/F_Main.vb +++ b/CSE/GUI/F_Main.vb @@ -3,7 +3,6 @@ Public Class F_Main ' Declarations Private ToolstripSave As Boolean = False - Private ToolstripSaveAs As Boolean = False Private Formname As String = "Job configurations" Private ErrorExit As Boolean = True Private Cali As Boolean = True @@ -15,7 +14,7 @@ Public Class F_Main Dim NoLegFile As Boolean = False ' Initialisation - hz_out = 1 + crt.hz_out = 1 PBInfoIcon.Visible = False TBInfo.Visible = False @@ -27,15 +26,16 @@ Public Class F_Main ' Write the beginning in the Log fWriteLog(1) + AppFormStarted = True ' Load the config file ' Try - AppPreferences = New cPreferences(PreferencesPath) + Prefs = New cPreferences(PrefsPath) Catch ex As Exception - fInfWarErr(9, False, format( _ + logme(9, False, format( _ "Failed loading Preferences({0}) due to: {1}\n\iThis is normal the first time you launch the application.", _ - PreferencesPath, ex.Message), ex) + PrefsPath, ex.Message), ex) configL = False End Try @@ -46,13 +46,13 @@ Public Class F_Main '' Create working dir if not exists. '' - If Not IO.Directory.Exists(AppPreferences.workingDir) Then - IO.Directory.CreateDirectory(AppPreferences.workingDir) + If Not IO.Directory.Exists(Prefs.workingDir) Then + IO.Directory.CreateDirectory(Prefs.workingDir) End If 'Lizenz checken If Not Lic.LICcheck() Then - fInfWarErr(9, True, Lic.FailMsg) + logme(9, True, Lic.FailMsg) CreatActivationFileToolStripMenuItem_Click(sender, e) Me.Close() End If @@ -61,15 +61,14 @@ Public Class F_Main '' If Not configL Then Try - AppPreferences.Store(PreferencesPath) - fInfWarErr(7, False, format("Stored new Preferences({0}).", PreferencesPath)) + Prefs.Store(PrefsPath) + logme(7, False, format("Stored new Preferences({0}).", PrefsPath)) Catch ex As Exception - fInfWarErr(9, False, format("Failed storing default Preferences({0}) due to: {1}", PreferencesPath, ex.Message), ex) + logme(9, False, format("Failed storing default Preferences({0}) due to: {1}", PrefsPath, ex.Message), ex) End Try End If End Sub - ' Main Tab #Region "Main" ' Close the GUI Private Sub CSEMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed @@ -80,7 +79,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the vehiclefile Private Sub ButtonSelectVeh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectVeh.Click ' Open the filebrowser with the *.csveh parameter - If fbVEH.OpenDialog(AppPreferences.workingDir, False) Then + If fbVEH.OpenDialog(Prefs.workingDir, False) Then If (fbVEH.Files(0) <> Nothing) Then Me.TextBoxVeh1.Text = fbVEH.Files(0) End If @@ -90,16 +89,16 @@ Public Class F_Main ' Open the vehiclefile in the Notepad Private Sub ButtonVeh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonVeh.Click If IO.File.Exists(Me.TextBoxVeh1.Text) Then - System.Diagnostics.Process.Start(AppPreferences.editor, Me.TextBoxVeh1.Text) + System.Diagnostics.Process.Start(Prefs.editor, Me.TextBoxVeh1.Text) Else - fInfWarErr(9, True, "No such Inputfile: " & Me.TextBoxVeh1.Text) + logme(9, True, "No such Inputfile: " & Me.TextBoxVeh1.Text) End If End Sub ' Open the filebrowser for the selection of the weatherfile Private Sub ButtonSelectWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectWeather.Click ' Open the filebrowser with the *.cswea parameter - If fbAMB.OpenDialog(AppPreferences.workingDir, False) Then + If fbAMB.OpenDialog(Prefs.workingDir, False) Then If (fbAMB.Files(0) <> Nothing) Then Me.TextBoxWeather.Text = fbAMB.Files(0) End If @@ -109,9 +108,9 @@ Public Class F_Main ' Open the weatherfile in the Notepad Private Sub ButtonWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonWeather.Click If IO.File.Exists(Me.TextBoxWeather.Text) Then - System.Diagnostics.Process.Start(AppPreferences.editor, Me.TextBoxWeather.Text) + System.Diagnostics.Process.Start(Prefs.editor, Me.TextBoxWeather.Text) Else - fInfWarErr(9, True, "No such Inputfile: " & Me.TextBoxWeather.Text) + logme(9, True, "No such Inputfile: " & Me.TextBoxWeather.Text) End If End Sub @@ -123,7 +122,7 @@ Public Class F_Main ' Save button Private Sub ButtonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSave.Click - ToolStripMenuItemSave_Click(sender, e) + SaveJobImpl(False) End Sub ' Calibration elements @@ -131,7 +130,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the datafile from the calibration run Private Sub ButtonSelectDataC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectDataC.Click ' Open the filebrowser with the *.csdat parameter - If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then + If fbVEL.OpenDialog(Prefs.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataC.Text = fbVEL.Files(0) End If @@ -155,7 +154,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the measure section config file (MSC) Private Sub ButtonSelectMSCC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectMSCC.Click ' Open the filebrowser with the *.csmsc parameter - If fbMSC.OpenDialog(AppPreferences.workingDir, False) Then + If fbMSC.OpenDialog(Prefs.workingDir, False) Then If (fbMSC.Files(0) <> Nothing) Then Me.TextBoxMSCC.Text = fbMSC.Files(0) End If @@ -199,7 +198,7 @@ Public Class F_Main Cali = True ' Save the Jobfiles - ToolStripMenuItemSave_Click(sender, e) + SaveJobImpl(False) ' Check if outfolder exist. If not then generate the folder If Not System.IO.Directory.Exists(OutFolder) Then @@ -213,7 +212,7 @@ Public Class F_Main Exit Sub End If Else - fInfWarErr(9, False, "No outputfolder is given!") + logme(9, False, "No outputfolder is given!") Exit Sub End If End If @@ -222,7 +221,7 @@ Public Class F_Main Me.ListBoxMSG.Items.Clear() fClear_VECTO_Form(False, False) - fInfWarErr(7, False, format("Starting CALIBRATION: \n\i* Job: {0}\n* Out: {1}", JobFile, OutFolder)) + logme(7, False, format("Starting CALIBRATION: \n\i* Job: {0}\n* Out: {1}", JobFile, OutFolder)) ' Start the calculation in the backgroundworker Me.BackgroundWorkerVECTO.RunWorkerAsync() @@ -239,7 +238,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the measure section file from the test run Private Sub ButtonSelectMSCT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectMSCT.Click ' Open the filebrowser with the *.csmsc parameter - If fbMSC.OpenDialog(AppPreferences.workingDir, False) Then + If fbMSC.OpenDialog(Prefs.workingDir, False) Then If (fbMSC.Files(0) <> Nothing) Then Me.TextBoxMSCT.Text = fbMSC.Files(0) End If @@ -263,7 +262,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the first low speed data file from the test run Private Sub ButtonSelectDataLS1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectDataLS1.Click ' Open the filebrowser with the *.csdat parameter - If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then + If fbVEL.OpenDialog(Prefs.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataLS1.Text = fbVEL.Files(0) End If @@ -287,7 +286,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the high speed data file from the test run Private Sub ButtonSelectDataHS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectDataHS.Click ' Open the filebrowser with the *.csdat parameter - If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then + If fbVEL.OpenDialog(Prefs.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataHS.Text = fbVEL.Files(0) End If @@ -311,7 +310,7 @@ Public Class F_Main ' Open the filebrowser for the selection of the second low speed data file from the test run Private Sub ButtonSelectDataLS2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectDataLS2.Click ' Open the filebrowser with the *.csdat parameter - If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then + If fbVEL.OpenDialog(Prefs.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataLS2.Text = fbVEL.Files(0) End If @@ -354,7 +353,7 @@ Public Class F_Main fWriteLog(2, 4, "----- Speed runs ") ' Save the Jobfiles - ToolStripMenuItemSave_Click(sender, e) + SaveJobImpl(False) ' Check if outfolder exist. If not then generate the folder If Not System.IO.Directory.Exists(OutFolder) Then @@ -368,7 +367,7 @@ Public Class F_Main Exit Sub End If Else - fInfWarErr(9, False, "No outputfolder is given!") + logme(9, False, "No outputfolder is given!") Exit Sub End If End If @@ -377,7 +376,7 @@ Public Class F_Main fClear_VECTO_Form(False, False) ' Write the Calculation status in the Messageoutput and in the Log - fInfWarErr(7, False, format("Starting EVALUATION: \n\i* Job: {0}\n* Out: {1}", JobFile, OutFolder)) + logme(7, False, format("Starting EVALUATION: \n\i* Job: {0}\n* Out: {1}", JobFile, OutFolder)) ' Start the calculation in the backgroundworker Me.BackgroundWorkerVECTO.RunWorkerAsync() @@ -400,7 +399,7 @@ Public Class F_Main ' Menu open Private Sub ToolStripMenuItemOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemOpen.Click ' Open the filebrowser with the *.csjob parameter - If fbVECTO.OpenDialog(AppPreferences.workingDir, False) Then + If fbVECTO.OpenDialog(Prefs.workingDir, False) Then JobFile = fbVECTO.Files(0) If (JobFile <> Nothing) Then @@ -412,26 +411,36 @@ Public Class F_Main '' Read Jobfile and populate GUI '' Try + Dim newJob As cJob If JobFile.EndsWith(".csjob.json") Then - Dim job = New cJob(JobFile) - job.Validate() - job.PopulateApp() - UI_PopulateFromJob() - UI_PopulateFromCriteria() + newJob = New cJob(JobFile) Else - cJob.fReadOldJobFile() + newJob = New cJob(True) + newJob.fReadOldJobFile() End If + newJob.Validate() + installJob(newJob) + UI_PopulateFromJob() + UI_PopulateFromCriteria() Catch ex As Exception - fInfWarErr(9, False, format("Failed reading Job-file({0}) due to: {1}", JobFile, ex.Message), ex) + logme(9, False, format("Failed reading Job-file({0}) due to: {1}", JobFile, ex.Message), ex) End Try End If End If End Sub ' Menu Save - Private Sub ToolStripMenuItemSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSave.Click + Private Sub MenuItemSaveJob(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSave.Click + SaveJobImpl(False) + End Sub + ' Menu Save as + Private Sub MenuItemSaveAs(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSaveAs.Click + SaveJobImpl(True) + End Sub + + Private Sub SaveJobImpl(ByVal isSaveAs As Boolean) ' Identify if the file should save under a new name - If JobFile = Nothing Or ToolstripSaveAs Then + If JobFile = Nothing Or isSaveAs Then ' Open the filebrowser to select the folder and name of the Jobfile If fbVECTO.SaveDialog(JobFile) Then JobFile = fbVECTO.Files(0) @@ -448,23 +457,10 @@ Public Class F_Main UI_PopulateToCriteria() ' Write the file - Dim job As New cJob() If Not JobFile.EndsWith(".csjob.json", StringComparison.OrdinalIgnoreCase) Then JobFile = joinPaths(fPath(JobFile), fName(JobFile, False) & ".csjob.json") End If - job.Store(JobFile) - End Sub - - ' Menu Save as - Private Sub ToolStripMenuItemSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSaveAs.Click - ' Define that the file should save under an other name - ToolstripSaveAs = True - - ' Save the File - ToolStripMenuItemSave_Click(sender, e) - - ' Reset the value - ToolstripSaveAs = False + Job.Store(JobFile) End Sub ' Menu Exit @@ -477,7 +473,7 @@ Public Class F_Main #Region "Tools" ' Menu open the Log Private Sub ToolStripMenuItemLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemLog.Click - System.Diagnostics.Process.Start(AppPreferences.editor, joinPaths(MyPath, "log.txt")) + System.Diagnostics.Process.Start(Prefs.editor, joinPaths(MyPath, "log.txt")) End Sub ' Menu open the config file @@ -491,7 +487,7 @@ Public Class F_Main ' Create activation file Private Sub CreatActivationFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreatActivationFileToolStripMenuItem.Click Lic.CreateActFile(MyPath & "ActivationCode.dat") - fInfWarErr(7, True, "Activation code created under: " & MyPath & "ActivationCode.dat") + logme(7, True, "Activation code created under: " & MyPath & "ActivationCode.dat") End Sub ' Menu open the Infobox @@ -506,7 +502,7 @@ Public Class F_Main Try System.Diagnostics.Process.Start(manual_fname) Catch ex As Exception - fInfWarErr(8, False, format("Failed opening User Manual({0}) due to: {1}", manual_fname, ex.Message), ex) + logme(8, False, format("Failed opening User Manual({0}) due to: {1}", manual_fname, ex.Message), ex) End Try End Sub #End Region @@ -532,8 +528,9 @@ Public Class F_Main ' Set all textboxes to standard Private Sub ButtonToStd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonToStd.Click ' Set the parameter to standard - StdParameter() - ' Write parameter on GUI + + installJob(New cJob()) + UI_PopulateFromJob() UI_PopulateFromCriteria() End Sub @@ -551,29 +548,29 @@ Public Class F_Main ' CheckBox for the acceleration calibration Private Sub CheckBoxAcc_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxAcc.CheckedChanged - accel_correction = CheckBoxAcc.Checked + crt.accel_correction = CheckBoxAcc.Checked End Sub ' Checkbox for the gradient correction Private Sub CheckBoxGrd_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxGrd.CheckedChanged - gradient_correction = CheckBoxGrd.Checked + crt.gradient_correction = CheckBoxGrd.Checked End Sub ' Change in the 1Hz radio button Private Sub RB1Hz_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RB1Hz.CheckedChanged If RB1Hz.Checked Then - hz_out = 1 + crt.hz_out = 1 Else - hz_out = 100 + crt.hz_out = 100 End If End Sub ' Change in the 100Hz radio button Private Sub RB100Hz_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RB100Hz.CheckedChanged If RB100Hz.Checked Then - hz_out = 100 + crt.hz_out = 100 Else - hz_out = 1 + crt.hz_out = 1 End If End Sub #End Region @@ -587,6 +584,7 @@ Public Class F_Main '##### START THE CALCULATION ##### '################################# + '' FIXME: Stop abusing worker-Thread with Globals, use DoWorkEventArgsfor that instead!! calculation(Cali) '################################# @@ -614,16 +612,16 @@ Public Class F_Main ' If an Error is detected If e.Error IsNot Nothing Then - fInfWarErr(8, False, format("{0} ended with exception: {1}", op, e.Error), e.Error) + logme(8, False, format("{0} ended with exception: {1}", op, e.Error.Message), e.Error) Else If e.Cancelled Then If ErrorExit Then - fInfWarErr(8, False, format("{0} ended with exception: {1}", op, e.Error), e.Error) + logme(8, False, format("{0} ended with some unknown error!", op)) Else - fInfWarErr(7, False, format("{0} aborted by user.", op)) + logme(7, False, format("{0} aborted by user.", op)) End If Else - fInfWarErr(7, False, format("{0} ended OK.", op)) + logme(7, False, format("{0} ended OK.", op)) If Cali Then Me.ButtonEval.Enabled = True End If End If @@ -645,39 +643,27 @@ Public Class F_Main ' Function to get all parameter from the GUI Function UI_PopulateToJob(Optional ByVal validate As Boolean = False, Optional ByVal calib As Boolean = True) As Boolean - ' Declaration - Dim i As Integer - ' Read the data from the textboxes (General) - Vehspez = TextBoxVeh1.Text - Ambspez = TextBoxWeather.Text - AnemIC(0) = TextBoxAirf.Text - AnemIC(1) = TextBoxAird.Text - AnemIC(2) = TextBoxbetaf.Text - AnemIC(3) = TextBoxbetad.Text + Job.vehicle_fpath = TextBoxVeh1.Text + Job.ambient_fpath = TextBoxWeather.Text + Job.Anemometer(0) = TextBoxAirf.Text + Job.Anemometer(1) = TextBoxAird.Text + Job.Anemometer(2) = TextBoxbetaf.Text + Job.Anemometer(3) = TextBoxbetad.Text ' Appropriate the inputfiles from calibration run - DataSpez(0) = TextBoxDataC.Text - MSCCSpez = TextBoxMSCC.Text + Job.calibration_fpath = TextBoxDataC.Text + Job.track_fpath = TextBoxMSCC.Text ' Appropriate the inputfiles from test run - DataSpez(1) = TextBoxDataLS1.Text - DataSpez(2) = TextBoxDataHS.Text - DataSpez(3) = TextBoxDataLS2.Text - MSCTSpez = TextBoxMSCT.Text - rr_corr_factor = TextBoxRRC.Text + Job.low1_fpath = TextBoxDataLS1.Text + Job.high_fpath = TextBoxDataHS.Text + Job.low2_fpath = TextBoxDataLS2.Text + Job.MSCTSpez = TextBoxMSCT.Text + Crt.rr_corr_factor = TextBoxRRC.Text If validate Then - ' Control the input - fControlPath(Vehspez, 1) - fControlPath(Ambspez, 2) - fControlPath(MSCCSpez, 3) - If Not calib Then - ''fControlPath(MSCTSpez, 4) - For i = 0 To UBound(DataSpez) - fControlPath(DataSpez(i), 4 + i + 1) - Next i - End If + Job.Validate() End If Return True @@ -686,77 +672,77 @@ Public Class F_Main ' Get the parameters from option tab Sub UI_PopulateToCriteria() ' Evaluation box - accel_correction = CheckBoxAcc.Checked - gradient_correction = CheckBoxGrd.Checked + crt.accel_correction = CheckBoxAcc.Checked + crt.gradient_correction = CheckBoxGrd.Checked ' Output box - If RB1Hz.Checked Then hz_out = 1 - If RB100Hz.Checked Then hz_out = 100 + If RB1Hz.Checked Then crt.hz_out = 1 + If RB100Hz.Checked Then crt.hz_out = 100 'Parameter boxes ' General valid criteria - delta_t_tyre_max = TBDeltaTTireMax.Text - delta_rr_corr_max = TBDeltaRRCMax.Text - t_amb_var = TBTambVar.Text - t_amb_tarmac = TBTambTamac.Text - t_amb_max = TBTambMax.Text - t_amb_min = TBTambMin.Text + crt.delta_t_tyre_max = TBDeltaTTireMax.Text + crt.delta_rr_corr_max = TBDeltaRRCMax.Text + crt.t_amb_var = TBTambVar.Text + crt.t_amb_tarmac = TBTambTamac.Text + crt.t_amb_max = TBTambMax.Text + crt.t_amb_min = TBTambMin.Text ' General - delta_Hz_max = TBDeltaHzMax.Text - roh_air_ref = TBRhoAirRef.Text - acc_corr_avg = TBAccCorrAve.Text - delta_parallel_max = TBDeltaParaMax.Text + crt.delta_Hz_max = TBDeltaHzMax.Text + crt.roh_air_ref = TBRhoAirRef.Text + crt.acc_corr_avg = TBAccCorrAve.Text + crt.delta_parallel_max = TBDeltaParaMax.Text ' Identification of measurement section - trigger_delta_x_max = TBDeltaXMax.Text - trigger_delta_y_max = TBDeltaYMax.Text - delta_head_max = TBDeltaHeadMax.Text + crt.trigger_delta_x_max = TBDeltaXMax.Text + crt.trigger_delta_y_max = TBDeltaYMax.Text + crt.delta_head_max = TBDeltaHeadMax.Text ' Requirements on number of valid datasets - segruns_min_CAL = TBDsMinCAL.Text - segruns_min_LS = TBDsMinLS.Text - segruns_min_HS = TBDsMinHS.Text - segruns_min_head_MS = TBDsMinHeadHS.Text + crt.segruns_min_CAL = TBDsMinCAL.Text + crt.segruns_min_LS = TBDsMinLS.Text + crt.segruns_min_HS = TBDsMinHS.Text + crt.segruns_min_head_MS = TBDsMinHeadHS.Text ' DataSet validity criteria - dist_float = TBDistFloat.Text + crt.dist_float = TBDistFloat.Text ' Calibration - v_wind_avg_max_CAL = TBvWindAveCALMax.Text - v_wind_1s_max_CAL = TBvWind1sCALMax.Text - beta_avg_max_CAL = TBBetaAveCALMax.Text + crt.v_wind_avg_max_CAL = TBvWindAveCALMax.Text + crt.v_wind_1s_max_CAL = TBvWind1sCALMax.Text + crt.beta_avg_max_CAL = TBBetaAveCALMax.Text ' Low and high speed test - leng_crit = TBLengCrit.Text + crt.leng_crit = TBLengCrit.Text ' Low speed test - v_wind_avg_max_LS = TBvWindAveLSMax.Text - v_wind_1s_max_LS = TBvWind1sLSMax.Text - v_veh_avg_max_LS = TBvVehAveLSMax.Text - v_veh_avg_min_LS = TBvVehAveLSMin.Text - v_veh_float_delta_LS = TBvVehFloatD.Text - tq_sum_float_delta_LS = TBTqSumFloatD.Text + crt.v_wind_avg_max_LS = TBvWindAveLSMax.Text + crt.v_wind_1s_max_LS = TBvWind1sLSMax.Text + crt.v_veh_avg_max_LS = TBvVehAveLSMax.Text + crt.v_veh_avg_min_LS = TBvVehAveLSMin.Text + crt.v_veh_float_delta_LS = TBvVehFloatD.Text + crt.tq_sum_float_delta_LS = TBTqSumFloatD.Text ' High speed test - v_wind_avg_max_HS = TBvWindAveHSMax.Text - v_wind_1s_max_HS = TBvWind1sHSMax.Text - v_veh_avg_min_HS = TBvVehAveHSMin.Text - beta_avg_max_HS = TBBetaAveHSMax.Text - v_veh_1s_delta_HS = TBvVeh1sD.Text - tq_sum_1s_delta_HS = TBTq1sD.Text + crt.v_wind_avg_max_HS = TBvWindAveHSMax.Text + crt.v_wind_1s_max_HS = TBvWind1sHSMax.Text + crt.v_veh_avg_min_HS = TBvVehAveHSMin.Text + crt.beta_avg_max_HS = TBBetaAveHSMax.Text + crt.v_veh_1s_delta_HS = TBvVeh1sD.Text + crt.tq_sum_1s_delta_HS = TBTq1sD.Text End Sub Sub UI_PopulateFromJob() ' Transfer the data to the GUI ' General - TextBoxVeh1.Text = Vehspez - TextBoxAirf.Text = AnemIC(0) - TextBoxAird.Text = AnemIC(1) - TextBoxbetaf.Text = AnemIC(2) - TextBoxbetad.Text = AnemIC(3) - TextBoxWeather.Text = Ambspez + TextBoxVeh1.Text = Job.vehicle_fpath + TextBoxAirf.Text = Job.Anemometer(0) + TextBoxAird.Text = Job.Anemometer(1) + TextBoxbetaf.Text = Job.Anemometer(2) + TextBoxbetad.Text = Job.Anemometer(3) + TextBoxWeather.Text = Job.ambient_fpath ' Calibration - TextBoxMSCC.Text = MSCCSpez - TextBoxDataC.Text = DataSpez(0) + TextBoxMSCC.Text = Job.track_fpath + TextBoxDataC.Text = Job.calibration_fpath ' Test - TextBoxMSCT.Text = MSCTSpez - TextBoxRRC.Text = rr_corr_factor - TextBoxDataLS1.Text = DataSpez(1) - TextBoxDataHS.Text = DataSpez(2) - TextBoxDataLS2.Text = DataSpez(3) + TextBoxMSCT.Text = Job.MSCTSpez + TextBoxRRC.Text = Crt.rr_corr_factor + TextBoxDataLS1.Text = Job.low1_fpath + TextBoxDataHS.Text = Job.high_fpath + TextBoxDataLS2.Text = Job.low2_fpath End Sub @@ -764,56 +750,56 @@ Public Class F_Main Sub UI_PopulateFromCriteria() ' Write the Standard values in the textboxes ' General valid criteria - TBDeltaTTireMax.Text = delta_t_tyre_max - TBDeltaRRCMax.Text = delta_rr_corr_max - TBTambVar.Text = t_amb_var - TBTambTamac.Text = t_amb_tarmac - TBTambMax.Text = t_amb_max - TBTambMin.Text = t_amb_min + TBDeltaTTireMax.Text = crt.delta_t_tyre_max + TBDeltaRRCMax.Text = crt.delta_rr_corr_max + TBTambVar.Text = crt.t_amb_var + TBTambTamac.Text = crt.t_amb_tarmac + TBTambMax.Text = crt.t_amb_max + TBTambMin.Text = crt.t_amb_min ' General - TBDeltaHzMax.Text = delta_Hz_max - TBRhoAirRef.Text = roh_air_ref - TBAccCorrAve.Text = acc_corr_avg - TBDeltaParaMax.Text = delta_parallel_max + TBDeltaHzMax.Text = crt.delta_Hz_max + TBRhoAirRef.Text = crt.roh_air_ref + TBAccCorrAve.Text = crt.acc_corr_avg + TBDeltaParaMax.Text = crt.delta_parallel_max ' Identification of measurement section - TBDeltaXMax.Text = trigger_delta_x_max - TBDeltaYMax.Text = trigger_delta_y_max - TBDeltaHeadMax.Text = delta_head_max + TBDeltaXMax.Text = crt.trigger_delta_x_max + TBDeltaYMax.Text = crt.trigger_delta_y_max + TBDeltaHeadMax.Text = crt.delta_head_max ' Requirements on number of valid datasets - TBDsMinCAL.Text = segruns_min_CAL - TBDsMinLS.Text = segruns_min_LS - TBDsMinHS.Text = segruns_min_HS - TBDsMinHeadHS.Text = segruns_min_head_MS + TBDsMinCAL.Text = crt.segruns_min_CAL + TBDsMinLS.Text = crt.segruns_min_LS + TBDsMinHS.Text = crt.segruns_min_HS + TBDsMinHeadHS.Text = crt.segruns_min_head_MS ' DataSet validity criteria - TBDistFloat.Text = dist_float + TBDistFloat.Text = crt.dist_float ' Calibration - TBvWindAveCALMax.Text = v_wind_avg_max_CAL - TBvWind1sCALMax.Text = v_wind_1s_max_CAL - TBBetaAveCALMax.Text = beta_avg_max_CAL + TBvWindAveCALMax.Text = crt.v_wind_avg_max_CAL + TBvWind1sCALMax.Text = crt.v_wind_1s_max_CAL + TBBetaAveCALMax.Text = crt.beta_avg_max_CAL ' Low and high speed test - TBLengCrit.Text = leng_crit + TBLengCrit.Text = crt.leng_crit ' Low speed test - TBvWindAveLSMax.Text = v_wind_avg_max_LS - TBvWind1sLSMax.Text = v_wind_1s_max_LS - TBvVehAveLSMax.Text = v_veh_avg_max_LS - TBvVehAveLSMin.Text = v_veh_avg_min_LS - TBvVehFloatD.Text = v_veh_float_delta_LS - TBTqSumFloatD.Text = tq_sum_float_delta_LS + TBvWindAveLSMax.Text = crt.v_wind_avg_max_LS + TBvWind1sLSMax.Text = crt.v_wind_1s_max_LS + TBvVehAveLSMax.Text = crt.v_veh_avg_max_LS + TBvVehAveLSMin.Text = crt.v_veh_avg_min_LS + TBvVehFloatD.Text = crt.v_veh_float_delta_LS + TBTqSumFloatD.Text = crt.tq_sum_float_delta_LS ' High speed test - TBvWindAveHSMax.Text = v_wind_avg_max_HS - TBvWind1sHSMax.Text = v_wind_1s_max_HS - TBvVehAveHSMin.Text = v_veh_avg_min_HS - TBBetaAveHSMax.Text = beta_avg_max_HS - TBvVeh1sD.Text = v_veh_1s_delta_HS - TBTq1sD.Text = tq_sum_1s_delta_HS + TBvWindAveHSMax.Text = crt.v_wind_avg_max_HS + TBvWind1sHSMax.Text = crt.v_wind_1s_max_HS + TBvVehAveHSMin.Text = crt.v_veh_avg_min_HS + TBBetaAveHSMax.Text = crt.beta_avg_max_HS + TBvVeh1sD.Text = crt.v_veh_1s_delta_HS + TBTq1sD.Text = crt.tq_sum_1s_delta_HS ' Evaluation box - CheckBoxAcc.Checked = accel_correction - CheckBoxGrd.Checked = gradient_correction + CheckBoxAcc.Checked = crt.accel_correction + CheckBoxGrd.Checked = crt.gradient_correction ' Output - If hz_out = 1 Then + If crt.hz_out = 1 Then RB1Hz.Checked = True - ElseIf hz_out = 100 Then + ElseIf crt.hz_out = 100 Then RB100Hz.Checked = True End If End Sub @@ -852,7 +838,8 @@ Public Class F_Main ButtonEval.Enabled = False ' Option parameters to standard - StdParameter() + installJob(New cJob) + UI_PopulateFromJob() UI_PopulateFromCriteria() End If diff --git a/CSE/GUI/F_Preferences.vb b/CSE/GUI/F_Preferences.vb index 8fe8fb78c41b963f22a7615b1ab25757100e7242..6abbb8384d39e7a48138ff0c11d5c614054b89ea 100644 --- a/CSE/GUI/F_Preferences.vb +++ b/CSE/GUI/F_Preferences.vb @@ -24,7 +24,7 @@ Public Class F_Preferences updateControlsFromSchema(schema, ctrl, Label) Next - UI_PopulateFrom(AppPreferences) + UI_PopulateFrom(Prefs) End Sub Private Sub UI_PopulateFrom(ByVal value As cPreferences) @@ -60,22 +60,22 @@ Public Class F_Preferences ' Ok button Private Sub StorePrefs(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click Try - Dim newPrefs As cPreferences = AppPreferences.Clone() + Dim newPrefs As cPreferences = Prefs.Clone() UI_PopulateTo(newPrefs) ' Write the config file - newPrefs.Store(PreferencesPath) - AppPreferences = newPrefs ' Replace active prefs if successful. + newPrefs.Store(PrefsPath) + Prefs = newPrefs ' Replace active prefs if successful. ' Message for the restart of VECTO RestartN = True - fInfWarErr(7, True, format("Stored Preferences({0}). \n\nDo you want to restart VECTO now?", PreferencesPath)) + logme(7, True, format("Stored Preferences({0}). \n\nDo you want to restart VECTO now?", PrefsPath)) ' Close the window Me.Close() Catch ex As Exception - fInfWarErr(9, True, format("Failed storing Preferences({0}) due to: {1} \n Preferences left unmodified!", _ - PreferencesPath, ex.Message), ex) + logme(9, True, format("Failed storing Preferences({0}) due to: {1} \n Preferences left unmodified!", _ + PrefsPath, ex.Message), ex) End Try End Sub @@ -83,11 +83,11 @@ Public Class F_Preferences ' Ok button Private Sub ReloadPrefs(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReload.Click Try - AppPreferences = New cPreferences(PreferencesPath) - UI_PopulateFrom(AppPreferences) + Prefs = New cPreferences(PrefsPath) + UI_PopulateFrom(Prefs) Catch ex As Exception - fInfWarErr(9, True, format("Failed loading Preferences({0}) due to: {1}", _ - PreferencesPath, ex.Message), ex) + logme(9, True, format("Failed loading Preferences({0}) due to: {1}", _ + PrefsPath, ex.Message), ex) End Try End Sub @@ -114,7 +114,7 @@ Public Class F_Preferences ' Set the MSG box to default if it is leave without an input Private Sub TextBoxMSG_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles logLevel.Leave - If Me.logLevel.Text = Nothing Then Me.logLevel.Text = AppPreferences.PropDefault("logLevel") + If Me.logLevel.Text = Nothing Then Me.logLevel.Text = Prefs.PropDefault("logLevel") End Sub ' Changes in the MSG --> Change the lable @@ -148,7 +148,7 @@ Public Class F_Preferences ' Set the LogSize to default if it is leave without an input Private Sub TextBoxLogSize_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles logSize.Leave, TextBox1.Leave - If Me.logSize.Text = Nothing Then Me.logSize.Text = AppPreferences.PropDefault("logSize") + If Me.logSize.Text = Nothing Then Me.logSize.Text = Prefs.PropDefault("logSize") End Sub End Class diff --git a/CSE/GUI/cFileBrowser.vb b/CSE/GUI/cFileBrowser.vb index ee3c759e7d9888504bedd88a5c68eaa11c515ff8..83618bb88663367e4836b1f39cd8b5be7043708a 100644 --- a/CSE/GUI/cFileBrowser.vb +++ b/CSE/GUI/cFileBrowser.vb @@ -56,14 +56,8 @@ Public Class cFileBrowser End Function 'SaveDialog - Return true if all is ok - Public Function SaveDialog(ByVal path As String, Optional ByVal ForceExt As Boolean = True, Optional ByVal Ext As String = "") As Boolean - Dim x As eExtMode - If ForceExt Then - x = eExtMode.ForceExt - Else - x = eExtMode.SingleExt - End If - Return CustomDialog(path, False, True, x, False, Ext, "Save As") + Public Function SaveDialog(ByVal path As String, Optional ByVal forceExt As eExtMode = eExtMode.SingleExt, Optional ByVal Ext As String = "") As Boolean + Return CustomDialog(path, False, True, forceExt, False, Ext, "Save As") End Function ' Open the Dialog - Return true if all is ok diff --git a/CSE/IO/OutputTest.vb b/CSE/IO/OutputTest.vb index 3914200b341f48db2e4f0cac3c9e8e06013c16d9..e4ae6ff7ced71e04e50890f8d5dc4d1b2715e85b 100644 --- a/CSE/IO/OutputTest.vb +++ b/CSE/IO/OutputTest.vb @@ -23,7 +23,7 @@ End If ' Write on GUI - fInfWarErr(5, False, "Write output-file (*.csv)") + logme(5, False, "Write output-file (*.csv)") ' Generate the file name NameOutFile = OutFolder & fName(Datafile, False) & "_test.csv" @@ -64,7 +64,7 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + logme(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True diff --git a/CSE/IO/cCriteria.vb b/CSE/IO/cCriteria.vb index 44b3ed050d9034c1c5d62a4fa5d13d650d5d9284..b84b6c10e18949d15aa23376266f96e9fa187e8b 100644 --- a/CSE/IO/cCriteria.vb +++ b/CSE/IO/cCriteria.vb @@ -14,63 +14,9 @@ Public Class cCriteria Private ForeignBody As JToken - ' Defaults specified here. - Protected Shared Function BuildBody() As JObject - Dim b, g As Object - b = New JObject() - - g = New JObject() - b.Processing = g - g.roh_air_ref = roh_air_ref - g.accel_correction = accel_correction - g.gradient_correction = gradient_correction - g.hz_out = hz_out - g.rr_corr_factor = rr_corr_factor - g.acc_corr_avg = acc_corr_avg - g.dist_float = dist_float - - g = New JObject() - b.Validation = g - g.trigger_delta_x_max = trigger_delta_x_max - g.trigger_delta_y_max = trigger_delta_y_max - g.delta_head_max = delta_head_max - g.segruns_min_CAL = segruns_min_CAL - g.segruns_min_LS = segruns_min_LS - g.segruns_min_HS = segruns_min_HS - g.segruns_min_head_MS = segruns_min_head_MS - g.delta_Hz_max = delta_Hz_max - g.delta_parallel_max = delta_parallel_max - - g.v_wind_avg_max_CAL = v_wind_avg_max_CAL - g.v_wind_1s_max_CAL = v_wind_1s_max_CAL - g.beta_avg_max_CAL = beta_avg_max_CAL - - g.leng_crit = leng_crit - - g.v_wind_avg_max_LS = v_wind_avg_max_LS - g.v_wind_1s_max_LS = v_wind_1s_max_LS - g.v_veh_avg_min_LS = v_veh_avg_min_LS - g.v_veh_avg_max_LS = v_veh_avg_max_LS - g.v_veh_float_delta_LS = v_veh_float_delta_LS - g.tq_sum_float_delta_LS = tq_sum_float_delta_LS - - g.v_wind_avg_max_HS = v_wind_avg_max_HS - g.v_wind_1s_max_HS = v_wind_1s_max_HS - g.beta_avg_max_HS = beta_avg_max_HS - g.v_veh_avg_min_HS = v_veh_avg_min_HS - g.v_veh_1s_delta_HS = v_veh_1s_delta_HS - g.tq_sum_1s_delta_HS = tq_sum_1s_delta_HS - g.delta_t_tyre_max = delta_t_tyre_max - g.delta_rr_corr_max = delta_rr_corr_max - g.t_amb_var = t_amb_var - g.t_amb_tarmac = t_amb_tarmac - g.t_amb_max = t_amb_max - g.t_amb_min = t_amb_min - - Return b - End Function - Function std() As JObject + '' Default values are Decleration + Public Shared Function BuildBody() As JObject Dim b, g As Object b = New JObject() @@ -96,11 +42,12 @@ Public Class cCriteria g.delta_Hz_max = 1 g.delta_parallel_max = 20 + g.v_wind_avg_max_CAL = 5 g.v_wind_1s_max_CAL = 8 g.beta_avg_max_CAL = 5 - g.leng_crit = 10 + g.leng_crit = 3 g.v_wind_avg_max_LS = 5 g.v_wind_1s_max_LS = 8 @@ -110,17 +57,18 @@ Public Class cCriteria g.tq_sum_float_delta_LS = 0.1 g.v_wind_avg_max_HS = 5 - g.v_wind_1s_max_HS = 10 + g.v_wind_1s_max_HS = 8 g.beta_avg_max_HS = 3 g.v_veh_avg_min_HS = 80 g.v_veh_1s_delta_HS = 0.3 g.tq_sum_1s_delta_HS = 0.1 + g.delta_t_tyre_max = 5 g.delta_rr_corr_max = 0.3 + g.t_amb_min = 0 + g.t_amb_max = 35 g.t_amb_var = 3 g.t_amb_tarmac = 25 - g.t_amb_max = 35 - g.t_amb_min = 0 Return b End Function @@ -185,10 +133,10 @@ Public Class cCriteria "delta_t_tyre_max": {"type": "number", "required": true, }, "delta_rr_corr_max": {"type": "number", "required": true, }, + "t_amb_min": {"type": "number", "required": true, }, + "t_amb_max": {"type": "number", "required": true, }, "t_amb_var": {"type": "number", "required": true, }, "t_amb_tarmac": {"type": "number", "required": true, }, - "t_amb_max": {"type": "number", "required": true, }, - "t_amb_min": {"type": "number", "required": true, }, } }, }, @@ -200,14 +148,17 @@ Public Class cCriteria ''' <remarks>See cJsonFile() constructor</remarks> Sub New(Optional ByVal skipValidation As Boolean = False) MyBase.New(BuildBody, skipValidation) + PopulateApp() End Sub ''' <summary>Reads from file or creates defaults</summary> ''' <param name="inputFilePath">the fpath of the file to read data from</param> Sub New(ByVal inputFilePath As String, Optional ByVal skipValidation As Boolean = False) MyBase.New(inputFilePath, skipValidation) + PopulateApp() End Sub Sub New(ByVal foreignBody As JToken, Optional ByVal skipValidation As Boolean = False) MyBase.New(foreignBody, skipValidation) + PopulateApp() End Sub @@ -239,53 +190,154 @@ Public Class cCriteria End Sub #Region "json props" + ' Processing params + Public rr_corr_factor As Double ' Rolling resistance correction factor + Public accel_correction As Boolean = False ' Variable for the acceleration correction + Public gradient_correction As Boolean = False ' Variable for the gradient correction + Public hz_out As Integer = 1 ' Hz result file output + Public acc_corr_avg As Single ' [s] averaging of vehicle speed for correction of acceleration forces + Public dist_float As Single ' [m]; Distance used for calculation of floatinig average signal used for stabilitay criteria in low speed tests + Public roh_air_ref As Single ' [kg/m^3] Reference air density + + ' Criteria + Public trigger_delta_x_max As Single ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (driving direction) + Public trigger_delta_y_max As Single ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (perpendicular to driving direction) + Public delta_head_max As Single ' [°]; +/- maximum deviation from heading as read from the csdat-file to the heading from csms-file for a valid dataset + Public segruns_min_CAL As Integer ' [#]; Minimum number of valid datasets required for the calibration test (per combination of MS ID and DIR ID) + Public segruns_min_LS As Integer ' [#]; Minimum number of valid datasets required for the low speed test (per combination of MS ID and DIR ID) + Public segruns_min_HS As Integer ' [#]; Minimum number of valid datasets required for the high speed test (per combination of MS ID and DIR ID) + Public segruns_min_head_MS As Integer ' [#]; Minimum TOTAL number of valid datasets required for the high speed test per heading + Public delta_Hz_max As Single ' [%]; maximum allowed deviation of timestep-size in csdat-file from 100Hz + Public delta_parallel_max As Single ' [°]; maximum heading difference for measurement section (parallelism criteria for test track layout) + Public leng_crit As Single ' [m]; maximum absolute difference of distance driven with lenght of section as specified in configuration + Public v_wind_avg_max_CAL As Single ' [m/s]; maximum average wind speed during calibration test + Public v_wind_1s_max_CAL As Single ' [m/s]; maximum gust wind speed during calibration test + Public beta_avg_max_CAL As Single ' [°]; maximum average beta during calibration test + Public v_wind_avg_max_LS As Single ' [m/s]; maximum average wind speed during low speed test + Public v_wind_1s_max_LS As Single ' [m/s]; maximum gust wind speed during low speed test + Public v_veh_avg_max_LS As Single ' [km/h]; maximum average vehicle speed for low speed test + Public v_veh_avg_min_LS As Single ' [km/h]; minimum average vehicle speed for low speed test + Public v_veh_float_delta_LS As Single ' [km/h]; +/- maximum deviation of floating average vehicle speed from average vehicle speed over entire section (low speed test) + Public tq_sum_float_delta_LS As Single ' [-]; +/- maximum relative deviation of floating average torque from average torque over entire section (low speed test) + Public v_wind_avg_max_HS As Single ' [m/s]; maximum average wind speed during high speed test + Public v_wind_1s_max_HS As Single ' [m/s]; maximum gust wind speed during high speed test + Public v_veh_avg_min_HS As Single ' [km/h]; minimum average vehicle speed for high speed test + Public beta_avg_max_HS As Single ' [°]; maximum average beta during high speed test + Public v_veh_1s_delta_HS As Single ' [km/h]; +/- maximum deviation of 1s average vehicle speed from average vehicle speed over entire section (high speed test) + Public tq_sum_1s_delta_HS As Single ' [-]; +/- maximum relative deviation of 1s average torque from average torque over entire section (high speed test) + Public delta_t_tyre_max As Single ' [°C]; maximum variation of tyre temperature between high speed tests and low speed tests + Public delta_rr_corr_max As Single ' [kg/t]; maximum difference of RRC from the two low speed runs + Public t_amb_min As Single ' [°C]; Minimum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) + Public t_amb_max As Single ' [°C]; Maximum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) + Public t_amb_var As Single ' [°C]; maximum variation of ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) + Public t_amb_tarmac As Single ' [°C]; Maximum temperature below which no documentation of tarmac conditions is necessary + + + Overrides Sub Store(ByVal fpath As String) + Dim g, b As Object + b = Me.Body + + g = b.Processing + g.roh_air_ref = Me.roh_air_ref + g.accel_correction = Me.accel_correction + g.gradient_correction = Me.gradient_correction + g.hz_out = Me.hz_out + g.rr_corr_factor = Me.rr_corr_factor + g.acc_corr_avg = Me.acc_corr_avg + g.dist_float = Me.dist_float + + g = b.Validation + g.trigger_delta_x_max = Me.trigger_delta_x_max + g.trigger_delta_y_max = Me.trigger_delta_y_max + g.delta_head_max = Me.delta_head_max + g.segruns_min_CAL = Me.segruns_min_CAL + g.segruns_min_LS = Me.segruns_min_LS + g.segruns_min_HS = Me.segruns_min_HS + g.segruns_min_head_MS = Me.segruns_min_head_MS + g.delta_Hz_max = Me.delta_Hz_max + g.delta_parallel_max = Me.delta_parallel_max + + g.v_wind_avg_max_CAL = Me.v_wind_avg_max_CAL + g.v_wind_1s_max_CAL = Me.v_wind_1s_max_CAL + g.beta_avg_max_CAL = Me.beta_avg_max_CAL + + g.leng_crit = Me.leng_crit + + g.v_wind_avg_max_LS = Me.v_wind_avg_max_LS + g.v_wind_1s_max_LS = Me.v_wind_1s_max_LS + g.v_veh_avg_min_LS = Me.v_veh_avg_min_LS + g.v_veh_avg_max_LS = Me.v_veh_avg_max_LS + g.v_veh_float_delta_LS = Me.v_veh_float_delta_LS + g.tq_sum_float_delta_LS = Me.tq_sum_float_delta_LS + + g.v_wind_avg_max_HS = Me.v_wind_avg_max_HS + g.v_wind_1s_max_HS = Me.v_wind_1s_max_HS + g.beta_avg_max_HS = Me.beta_avg_max_HS + g.v_veh_avg_min_HS = Me.v_veh_avg_min_HS + g.v_veh_1s_delta_HS = Me.v_veh_1s_delta_HS + g.tq_sum_1s_delta_HS = Me.tq_sum_1s_delta_HS + + g.delta_t_tyre_max = Me.delta_t_tyre_max + g.delta_rr_corr_max = Me.delta_rr_corr_max + g.t_amb_var = Me.t_amb_var + g.t_amb_tarmac = Me.t_amb_tarmac + g.t_amb_max = Me.t_amb_max + g.t_amb_min = Me.t_amb_min + + MyBase.Store(fpath) + End Sub Sub PopulateApp() - Dim g, p As JToken + Dim g, p As Object p = Me.Body g = p("Processing") - rr_corr_factor = g("rr_corr_factor") - accel_correction = g("accel_correction") - gradient_correction = g("gradient_correction") - hz_out = g("hz_out") - roh_air_ref = g("roh_air_ref") - acc_corr_avg = g("acc_corr_avg") - dist_float = g("dist_float") + Me.rr_corr_factor = g("rr_corr_factor") + Me.accel_correction = g("accel_correction") + Me.gradient_correction = g("gradient_correction") + Me.hz_out = g("hz_out") + Me.roh_air_ref = g("roh_air_ref") + Me.acc_corr_avg = g("acc_corr_avg") + Me.dist_float = g("dist_float") g = p("Validation") - trigger_delta_x_max = g("trigger_delta_x_max") - trigger_delta_y_max = g("trigger_delta_y_max") - delta_head_max = g("delta_head_max") - segruns_min_CAL = g("segruns_min_CAL") - segruns_min_LS = g("segruns_min_LS") - segruns_min_HS = g("segruns_min_HS") - segruns_min_head_MS = g("segruns_min_head_MS") - delta_Hz_max = g("delta_Hz_max") - delta_parallel_max = g("delta_parallel_max") - leng_crit = g("leng_crit") - delta_t_tyre_max = g("delta_t_tyre_max") - delta_rr_corr_max = g("delta_rr_corr_max") - t_amb_var = g("t_amb_var") - t_amb_tarmac = g("t_amb_tarmac") - t_amb_max = g("t_amb_max") - t_amb_min = g("t_amb_min") - v_wind_avg_max_CAL = g("v_wind_avg_max_CAL") - v_wind_1s_max_CAL = g("v_wind_1s_max_CAL") - beta_avg_max_CAL = g("beta_avg_max_CAL") - v_wind_avg_max_LS = g("v_wind_avg_max_LS") - v_wind_1s_max_LS = g("v_wind_1s_max_LS") - v_veh_avg_max_LS = g("v_veh_avg_max_LS") - v_veh_avg_min_LS = g("v_veh_avg_min_LS") - v_veh_float_delta_LS = g("v_veh_float_delta_LS") - tq_sum_float_delta_LS = g("tq_sum_float_delta_LS") - v_wind_avg_max_HS = g("v_wind_avg_max_HS") - v_veh_avg_min_HS = g("v_veh_avg_min_HS") - v_wind_1s_max_HS = g("v_wind_1s_max_HS") - beta_avg_max_HS = g("beta_avg_max_HS") - v_veh_1s_delta_HS = g("v_veh_1s_delta_HS") - tq_sum_1s_delta_HS = g("tq_sum_1s_delta_HS") + Me.trigger_delta_x_max = g("trigger_delta_x_max") + Me.trigger_delta_y_max = g("trigger_delta_y_max") + Me.delta_head_max = g("delta_head_max") + Me.segruns_min_CAL = g("segruns_min_CAL") + Me.segruns_min_LS = g("segruns_min_LS") + Me.segruns_min_HS = g("segruns_min_HS") + Me.segruns_min_head_MS = g("segruns_min_head_MS") + Me.delta_Hz_max = g("delta_Hz_max") + Me.delta_parallel_max = g("delta_parallel_max") + + Me.leng_crit = g("leng_crit") + + Me.v_wind_avg_max_CAL = g("v_wind_avg_max_CAL") + Me.v_wind_1s_max_CAL = g("v_wind_1s_max_CAL") + Me.beta_avg_max_CAL = g("beta_avg_max_CAL") + + Me.v_wind_avg_max_LS = g("v_wind_avg_max_LS") + Me.v_wind_1s_max_LS = g("v_wind_1s_max_LS") + Me.v_veh_avg_max_LS = g("v_veh_avg_max_LS") + Me.v_veh_avg_min_LS = g("v_veh_avg_min_LS") + Me.v_veh_float_delta_LS = g("v_veh_float_delta_LS") + Me.tq_sum_float_delta_LS = g("tq_sum_float_delta_LS") + + Me.v_wind_avg_max_HS = g("v_wind_avg_max_HS") + Me.v_veh_avg_min_HS = g("v_veh_avg_min_HS") + Me.v_wind_1s_max_HS = g("v_wind_1s_max_HS") + Me.beta_avg_max_HS = g("beta_avg_max_HS") + Me.v_veh_1s_delta_HS = g("v_veh_1s_delta_HS") + Me.tq_sum_1s_delta_HS = g("tq_sum_1s_delta_HS") + + Me.delta_t_tyre_max = g("delta_t_tyre_max") + Me.delta_rr_corr_max = g("delta_rr_corr_max") + Me.t_amb_var = g("t_amb_var") + Me.t_amb_tarmac = g("t_amb_tarmac") + Me.t_amb_max = g("t_amb_max") + Me.t_amb_min = g("t_amb_min") End Sub #End Region ' json props diff --git a/CSE/IO/cJob.vb b/CSE/IO/cJob.vb index 83133dc3f4b1482ac169d95f0d4982644a82cf92..b79af1e8ecfbca250508993de6ff61be55ce1800 100644 --- a/CSE/IO/cJob.vb +++ b/CSE/IO/cJob.vb @@ -15,11 +15,14 @@ Public Class cJob ' Defaults specified here. Protected Shared Function BuildBody() As JObject Dim b As Object = New JObject() - b.fpathVehicle = Vehspez - b.fpathAmbient = Ambspez - b.Anemometer = New JArray(AnemIC.ToList()) - b.fpathTrack = MSCCSpez - b.fpathRunData = New JArray(DataSpez.ToList()) + b.vehicle_fpath = "" + b.ambient_fpath = "" + b.Anemometer = New JArray(0, 0, 0, 0) + b.track_fpath = "" + b.calibration_fpath = "" + b.low1_fpath = "" + b.high_fpath = "" + b.low2_fpath = "" b.Criteria = New cCriteria().Body Return b End Function @@ -32,9 +35,9 @@ Public Class cJob "type": "object", "additionalProperties": <%= allowAdditionalProps_str %>, "required": true, "properties": { - "fpathVehicle": { + "vehicle_fpath": { "type": "string", - "pattern": "\\.csveh(\\.json)?$", + <!-- "pattern": "\\.csveh(\\.json)?$", --> "required": true, "description": "File-path to Vehicle file (*.csveh)", }, @@ -47,28 +50,41 @@ Public Class cJob "minItems": 4, "maxItems": 4, "description": "The 4 Anemomenter instrument calibration factors in this order: v_air f, v_air d, beta f, beta d", }, - "fpathAmbient": { + "ambient_fpath": { "type": "string", - "pattern": "\\.csamb$", + <!-- "pattern": "\\.csamb$", --> "required": true, "description": "File-path to the Ambient(Weather) file (*.csamb)", }, - "fpathTrack": { + "track_fpath": { "type": "string", - "pattern": "\\.csms$", + <!-- "pattern": "\\.csms$", --> "required": true, "description": "File-path to Track-sections (*.csmsc).", }, - "fpathRunData": { - "type": "array", + "calibration_fpath": { + "type": "string", + <!-- "pattern": "\\.csdat$", --> "required": true, - "items": { - "type": "string", - "pattern": "\\.csdat$", - "description": "File-path to a measurement-file (*.csdat)", - }, - "minItems": 4, "maxItems": 4, - "description": "The 4 File-paths to the measurement-files (*.csdat) in this order: Calibration, Low1, High, Low2", + "description": "File-path to a measurement-file (*.csdat)", + }, + "low1_fpath": { + "type": "string", + <!-- "pattern": "\\.csdat$", --> + "required": true, + "description": "File-path to a measurement-file (*.csdat)", + }, + "high_fpath": { + "type": "string", + <!-- "pattern": "\\.csdat$", --> + "required": true, + "description": "File-path to a measurement-file (*.csdat)", + }, + "low2_fpath": { + "type": "string", + <!-- "pattern": "\\.csdat$", --> + "required": true, + "description": "File-path to a measurement-file (*.csdat)", }, "Criteria": <%= cCriteria.JSchemaStr(allowAdditionalProps) %>, } @@ -123,79 +139,174 @@ Public Class cJob #Region "json props" - Sub PopulateApp() - Dim b As JToken - b = Me.Body - - Vehspez = b("fpathVehicle") - Ambspez = b("fpathAmbient") - MSCCSpez = b("fpathTrack") - MSCTSpez = b("fpathTrack") - AnemIC = (From i In b("Anemometer") Select (Single.Parse(i))).ToArray - DataSpez = (From i In b("fpathRunData") Select (i.ToString)).ToArray + Public Property vehicle_fpath As String + Get + Return getRootedPath(Me.Body("vehicle_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("vehicle_fpath") = Nothing Else Me.Body("vehicle_fpath") = value + End Set + End Property + + + Public Property ambient_fpath As String + Get + Return getRootedPath(Me.Body("ambient_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("ambient_fpath") = Nothing Else Me.Body("ambient_fpath") = value + End Set + End Property + Public Property track_fpath As String + Get + Return getRootedPath(Me.Body("track_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("track_fpath") = Nothing Else Me.Body("track_fpath") = value + End Set + End Property + Public Property MSCTSpez As String + Get + Return getRootedPath(Me.Body("track_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("track_fpath") = Nothing Else Me.Body("track_fpath") = value + End Set + End Property + Public Property Anemometer As Single() + Get + Return (From i In Me.Body("Anemometer") Select (Single.Parse(i))).ToArray + End Get + Set(ByVal value As Single()) + Me.Body("Anemometer") = New JArray(value.ToList()) + End Set + End Property + + Public Property calibration_fpath As String + Get + Return getRootedPath(Me.Body("calibration_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("calibration_fpath") = Nothing Else Me.Body("calibration_fpath") = value + End Set + End Property + Public Property low1_fpath As String + Get + Return getRootedPath(Me.Body("low1_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("low1_fpath") = Nothing Else Me.Body("low1_fpath") = value + End Set + End Property + Public Property high_fpath As String + Get + Return getRootedPath(Me.Body("high_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("high_fpath") = Nothing Else Me.Body("high_fpath") = value + End Set + End Property + Public Property low2_fpath As String + Get + Return getRootedPath(Me.Body("low2_fpath"), Prefs.workingDir) + End Get + Set(ByVal value As String) + value = getAnySubPath(value, Prefs.workingDir) + + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! + If value Is Nothing Then Me.Body("low2_fpath") = Nothing Else Me.Body("low2_fpath") = value + End Set + End Property + + Public ReadOnly Property coasting_fpaths As String() + Get + Return {low1_fpath, high_fpath, low2_fpath} + End Get + End Property + + + ''' <summary>Do not invoke this method in vain...</summary> + ReadOnly Property Criteria As cCriteria + Get + Return New cCriteria(Me.Body("Criteria"), True) + End Get + End Property - Dim crtBody = b("Criteria") - Dim crt As cCriteria = New cCriteria(crtBody, True) - - crt.PopulateApp() - End Sub ' Function for reading the jobfile - Public Shared Sub fReadOldJobFile() + Public Sub fReadOldJobFile() ' Declarations - Dim lauf, i As Integer - Dim Info As String = "" + Dim i As Integer Dim Line() As String - Using FileInVECTO As New cFile_V3 + Dim crt As Object = Me.Criteria - ' Initialisation - lauf = 0 + Using FileInVECTO As New cFile_V3 ' Open the jobfile FileInVECTO.OpenReadWithEx(JobFile) ' Read the data from the jobfile - Vehspez = FileInVECTO.ReadLine(0) - Ambspez = FileInVECTO.ReadLine(0) + vehicle_fpath = FileInVECTO.ReadLine(0) + ambient_fpath = FileInVECTO.ReadLine(0) Line = FileInVECTO.ReadLine - For i = 0 To UBound(AnemIC) - 1 - AnemIC(i) = Line(i) + Dim factors(3) As Single + For i = 0 To UBound(factors) - 1 + factors(i) = Line(i) Next i + Anemometer = factors ' Calibration test files - MSCCSpez = FileInVECTO.ReadLine(0) - DataSpez(0) = FileInVECTO.ReadLine(0) + track_fpath = FileInVECTO.ReadLine(0) + calibration_fpath = FileInVECTO.ReadLine(0) ' Test run files MSCTSpez = FileInVECTO.ReadLine(0) - rr_corr_factor = FileInVECTO.ReadLine(0) - For i = 1 To UBound(DataSpez) - DataSpez(i) = FileInVECTO.ReadLine(0) - Next i + crt.rr_corr_factor = FileInVECTO.ReadLine(0) + + low1_fpath = FileInVECTO.ReadLine(0) + high_fpath = FileInVECTO.ReadLine(0) + low2_fpath = FileInVECTO.ReadLine(0) ' Appropriate the Checkboxes ' Acceleration Correction Line = FileInVECTO.ReadLine - accel_correction = CBool(Line(0)) + crt.accel_correction = CBool(Line(0)) 'CSEMain.CheckBoxAcc.Checked = False ' Gradient correction Line = FileInVECTO.ReadLine - gradient_correction = CBool(Line(0)) + crt.gradient_correction = CBool(Line(0)) 'CSEMain.CheckBoxGrd.Checked = False ' Output sequence Line = FileInVECTO.ReadLine - If IsNumeric(Line(0)) Then - If Line(0) = 1 Then - hz_out = 1 - ElseIf Line(0) = 100 Then - hz_out = 100 - Else - hz_out = 1 - End If + If Line(0) = 1 OrElse Line(0) = 100 Then + crt.hz_out = Line(0) + Else + crt.hz_out = 1 End If ' Read the parameters @@ -208,73 +319,73 @@ Public Class cJob If IsNumeric(Line(0)) Then Select Case i Case 1 ' TBDeltaTTireMax - delta_t_tyre_max = Line(0) + crt.delta_t_tyre_max = Line(0) Case 2 ' TBDeltaRRCMax.Text - delta_rr_corr_max = Line(0) + crt.delta_rr_corr_max = Line(0) Case 3 ' TBTambVar - t_amb_var = Line(0) + crt.t_amb_var = Line(0) Case 4 ' TBTambTamac - t_amb_tarmac = Line(0) + crt.t_amb_tarmac = Line(0) Case 5 ' TBTambMax - t_amb_max = Line(0) + crt.t_amb_max = Line(0) Case 6 ' TBTambMin - t_amb_min = Line(0) + crt.t_amb_min = Line(0) Case 7 ' TBContHz - delta_Hz_max = Line(0) + crt.delta_Hz_max = Line(0) Case 8 ' TBRhoAirRef - roh_air_ref = Line(0) + crt.roh_air_ref = Line(0) Case 9 ' TBAveSecAcc - acc_corr_avg = Line(0) + crt.acc_corr_avg = Line(0) Case 10 ' TBDeltaHeadMax - delta_parallel_max = Line(0) + crt.delta_parallel_max = Line(0) Case 11 ' TBContSecL - trigger_delta_x_max = Line(0) + crt.trigger_delta_x_max = Line(0) Case 12 ' TBLRec - trigger_delta_y_max = Line(0) + crt.trigger_delta_y_max = Line(0) Case 13 ' TBContAng - delta_head_max = Line(0) + crt.delta_head_max = Line(0) Case 14 ' TBNSecAnz - segruns_min_CAL = Line(0) + crt.segruns_min_CAL = Line(0) Case 15 ' TBNSecAnzLS - segruns_min_LS = Line(0) + crt.segruns_min_LS = Line(0) Case 16 ' TBNSecAnzHS - segruns_min_HS = Line(0) + crt.segruns_min_HS = Line(0) Case 17 ' TBMSHSMin - segruns_min_head_MS = Line(0) + crt.segruns_min_head_MS = Line(0) Case 18 ' TBDistFloat - dist_float = Line(0) + crt.dist_float = Line(0) Case 19 ' TBvWindAveCALMax - v_wind_avg_max_CAL = Line(0) + crt.v_wind_avg_max_CAL = Line(0) Case 20 ' TBvWind1sCALMax - v_wind_1s_max_CAL = Line(0) + crt.v_wind_1s_max_CAL = Line(0) Case 21 ' TBBetaAveCALMax - beta_avg_max_CAL = Line(0) + crt.beta_avg_max_CAL = Line(0) Case 22 ' TBLengCrit - leng_crit = Line(0) + crt.leng_crit = Line(0) Case 23 ' TBvWindAveLSMax - v_wind_avg_max_LS = Line(0) + crt.v_wind_avg_max_LS = Line(0) Case 24 ' TBvWind1sLSMin - v_wind_1s_max_LS = Line(0) + crt.v_wind_1s_max_LS = Line(0) Case 25 ' TBvVehAveLSMax - v_veh_avg_max_LS = Line(0) + crt.v_veh_avg_max_LS = Line(0) Case 26 ' TBvVehAveLSMin - v_veh_avg_min_LS = Line(0) + crt.v_veh_avg_min_LS = Line(0) Case 27 ' TBvVehFloatD - v_veh_float_delta_LS = Line(0) + crt.v_veh_float_delta_LS = Line(0) Case 28 ' TBTqSumFloatD - tq_sum_float_delta_LS = Line(0) + crt.tq_sum_float_delta_LS = Line(0) Case 29 ' TBvWindAveHSMax - v_wind_avg_max_HS = Line(0) + crt.v_wind_avg_max_HS = Line(0) Case 30 ' TBvWind1sHSMax - v_wind_1s_max_HS = Line(0) + crt.v_wind_1s_max_HS = Line(0) Case 31 ' TBvVehAveHSMin - v_veh_avg_min_HS = Line(0) + crt.v_veh_avg_min_HS = Line(0) Case 32 ' TBBetaAveHSMax - beta_avg_max_HS = Line(0) + crt.beta_avg_max_HS = Line(0) Case 33 ' TBvVeh1sD - v_veh_1s_delta_HS = Line(0) + crt.v_veh_1s_delta_HS = Line(0) Case 34 ' TBTq1sD - tq_sum_1s_delta_HS = Line(0) + crt.tq_sum_1s_delta_HS = Line(0) End Select Else Throw New ArgumentException(format("The given value in the Job-file({0}) at position({1}) is not a number!", JobFile, i)) @@ -289,15 +400,6 @@ Public Class cJob Throw New ArgumentException(format("Premature ending of the Job-file({0})!", JobFile)) End If - ' Control the input files - '' TDOD: Use Validate() - fControlInput(Vehspez, 1, "csveh.json") - fControlInput(Ambspez, 2, "csamb") - fControlInput(MSCCSpez, 3, "csms") - fControlInput(MSCTSpez, 4, "csms") - For i = 0 To UBound(DataSpez) - fControlInput(DataSpez(i), 4 + i + 1, "csdat") - Next i End Using diff --git a/CSE/IO/cJsonFile.vb b/CSE/IO/cJsonFile.vb index 24f74dcf67a811659487f1175837f5fe450de71f..b9028d057e8ea786c7922676446da0a680d7e979 100644 --- a/CSE/IO/cJsonFile.vb +++ b/CSE/IO/cJsonFile.vb @@ -121,7 +121,7 @@ Public MustInherit Class cJsonFile Dim strictHeader = True strictHeader = False '' Try to read even bad headers. - fInfWarErr(4, False, format("Reading JSON-file({0})...", inputFilePath)) + logme(4, False, format("Reading JSON-file({0})...", inputFilePath)) Me.Content = ReadJsonFile(inputFilePath) 'Me.Header = Content("Header") @@ -153,7 +153,7 @@ Public MustInherit Class cJsonFile End Sub ''' <summary>Validates and Writing to the config file</summary> - Sub Store(ByVal fpath As String) + Overridable Sub Store(ByVal fpath As String) Me.UpdateHeader() Me.Validate(Me.StrictBody) @@ -170,7 +170,7 @@ Public MustInherit Class cJsonFile '' Decide whether to add username in "CreatedBy". '' Dim username = "" - If AppPreferences Is Nothing OrElse Not AppPreferences.hideUsername Then + If Prefs Is Nothing OrElse Not Prefs.hideUsername Then username = System.Security.Principal.WindowsIdentity.GetCurrent().Name & "@" End If h("CreatedBy") = format("{0}{1}(lic: {2})", username, Lic.LicString, Lic.GUID) @@ -190,8 +190,8 @@ Public MustInherit Class cJsonFile Dim bodySchema = h("BodySchema") If bodySchema IsNot Nothing AndAlso bodySchema.Type = JTokenType.Boolean Then isIncludeSchema = bodySchema - ElseIf AppPreferences IsNot Nothing Then - isIncludeSchema = AppPreferences.IncludeSchemas + ElseIf Prefs IsNot Nothing Then + isIncludeSchema = Prefs.includeSchemas Else isIncludeSchema = False End If @@ -225,7 +225,7 @@ Public MustInherit Class cJsonFile '' Validate Body by subclass Dim hsb = Me.Header("StrictBody") - Dim strictBody As Boolean = IIf(hsb Is Nothing, AppPreferences.StrictBodies, hsb) + Dim strictBody As Boolean = IIf(hsb Is Nothing, Prefs.strictBodies, hsb) Me.ValidateBody(strictBody, validateMsgs) If (validateMsgs.Any()) Then diff --git a/CSE/IO/cPreferences.vb b/CSE/IO/cPreferences.vb index 3e5b810f48876e6089ee9225ee77183096a63f00..d7b3c187a97bc3dbb95720d5445f42fcf4624f0c 100644 --- a/CSE/IO/cPreferences.vb +++ b/CSE/IO/cPreferences.vb @@ -142,53 +142,14 @@ in the `/Header/CreatedBy` property of JSON-files, for protecting its privacy.", #Region "json props" Public Property workingDir As String Get - Dim value As String = Me.Body("workingDir") - If value Is Nothing OrElse String.IsNullOrWhiteSpace(value) Then - Return MyPath - ElseIf IO.Path.IsPathRooted(value) Then - Return value - Else - Return joinPaths(MyPath, value) - End If + Return getRootedPath(Me.Body("workingDir"), MyPath) End Get Set(ByVal value As String) - If value IsNot Nothing Then - '' Convert emtpy-paths into MyPath and store them as null. - '' - value = value.Trim() - If value.Length = 0 Then - value = Nothing - Else - '' Convert MyPath-prefixed paths into relative ones. - '' - Dim myPlainPath = IO.Path.GetFullPath(StripBackslash(MyPath)) - value = IO.Path.GetFullPath(value) - If value.StartsWith(myPlainPath, StringComparison.OrdinalIgnoreCase) Then - value = value.Substring(myPlainPath.Length) - If (value.StartsWith("\")) Then - value = value.Substring(1) - End If + value = getAnySubPath(value, MyPath) - If value.Length = 0 Then - value = Nothing - End If - End If - - '' Store MyPath as null. - '' - If String.Equals(value, MyPath, StringComparison.OrdinalIgnoreCase) Then - value = Nothing - End If - End If - End If - - '' NOTE: Early-binding makes Nulls end-up as 'string' schema-type. + '' NOTE: Early-binding makes schema-type always a 'string', and will fail later! '' - If value Is Nothing Then - Me.Body("workingDir") = Nothing - Else - Me.Body("workingDir") = value - End If + If value Is Nothing Then Me.Body("workingDir") = Nothing Else Me.Body("workingDir") = value End Set End Property diff --git a/CSE/IO/input.vb b/CSE/IO/input.vb index 745a1b81a3da6defe260edc6e28d5ae0cbd9891f..0da2e8f754a901a78bb244dc0cc774ab485201f3 100644 --- a/CSE/IO/input.vb +++ b/CSE/IO/input.vb @@ -10,12 +10,12 @@ Public Module input ' Read the filelist with the MSC spezifications ' Output on the GUI - fInfWarErr(5, False, "Read MS configuration file") + logme(5, False, "Read MS configuration file") ' Open the MSC spezification file If Not FileInMSCSpez.OpenRead(MSCfile) Then ' Error if the file is not available - fInfWarErr(9, False, "Can´t find the MS configuration specification file: " & MSCfile) + logme(9, False, "Can´t find the MS configuration specification file: " & MSCfile) Return False End If @@ -36,11 +36,11 @@ Public Module input MSCX.longS.Add(Line(5)) MSCX.latE.Add(Line(6)) MSCX.longE.Add(Line(7)) - If gradient_correction Then MSCX.AltPath.Add(Line(8)) + If Crt.gradient_correction Then MSCX.AltPath.Add(Line(8)) Loop Catch ex As Exception ' Falls kein gültiger Wert eingegeben wurde - fInfWarErr(9, False, "Invalid value in the trigger data file: " & fName(MSCfile, True)) + logme(9, False, "Invalid value in the trigger data file: " & fName(MSCfile, True)) BWorker.CancelAsync() Return False End Try @@ -56,14 +56,14 @@ Public Module input RefHead = MSCX.head(i) MSCX.headID.Add(1) Else - If Math.Abs(MSCX.head(i) - RefHead) < delta_parallel_max Then + If Math.Abs(MSCX.head(i) - RefHead) < Crt.delta_parallel_max Then MSCX.headID.Add(1) Continue For - ElseIf (Math.Abs(MSCX.head(i) - RefHead + 180) < delta_parallel_max Or Math.Abs(MSCX.head(i) - RefHead - 180) < delta_parallel_max) Then + ElseIf (Math.Abs(MSCX.head(i) - RefHead + 180) < Crt.delta_parallel_max Or Math.Abs(MSCX.head(i) - RefHead - 180) < Crt.delta_parallel_max) Then MSCX.headID.Add(2) Continue For Else - fInfWarErr(9, False, "Measurement section with invalid headings identified (test track not parallel) at line: " & i) + logme(9, False, "Measurement section with invalid headings identified (test track not parallel) at line: " & i) BWorker.CancelAsync() Return False End If @@ -72,17 +72,16 @@ Public Module input ' Control the altitude path For i = 1 To MSCX.meID.Count - 1 - If gradient_correction Then + If Crt.gradient_correction Then If MSCX.AltPath(i) = Nothing Then - fInfWarErr(9, False, "Altitude correction = on, missing altitude file at line: " & i) + logme(9, False, "Altitude correction = on, missing altitude file at line: " & i) BWorker.CancelAsync() Return False End If 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 - fInfWarErr(9, False, "Altitude correction = on, altitude file doesen´t exist: " & MSCX.AltPath(i)) + logme(9, False, "Altitude correction = on, altitude file doesen´t exist: " & MSCX.AltPath(i)) BWorker.CancelAsync() Return False End If @@ -116,14 +115,14 @@ Public Module input 'Abort if there's no file If Datafile = "" OrElse Not IO.File.Exists(Datafile) Then - fInfWarErr(9, False, "Weather data file not found (" & Datafile & ") !") + logme(9, False, "Weather data file not found (" & Datafile & ") !") BWorker.CancelAsync() Return False End If 'Open file If Not FileInWeather.OpenRead(Datafile) Then - fInfWarErr(9, False, "Failed to open file (" & Datafile & ") !") + logme(9, False, "Failed to open file (" & Datafile & ") !") BWorker.CancelAsync() Return False End If @@ -148,7 +147,7 @@ Public Module input Else ' Check if component is already defined If WeathCheck(Comp) Then - fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + logme(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -164,7 +163,7 @@ Public Module input ' Check if all required data is given For Each sKVW In WeathCheck If Not WeathCheck(sKVW.Key) Then - fInfWarErr(9, False, "Missing signal for " & fCompName(sKVW.Key)) + logme(9, False, "Missing signal for " & fCompName(sKVW.Key)) BWorker.CancelAsync() Return False End If @@ -185,7 +184,7 @@ Public Module input Next sKV Loop Catch ex As Exception - fInfWarErr(9, False, "Error during file read! Line number: " & tdim + 1 & " (" & Datafile & ")") + logme(9, False, "Error during file read! Line number: " & tdim + 1 & " (" & Datafile & ")") BWorker.CancelAsync() Return False End Try @@ -240,14 +239,14 @@ Public Module input 'Abort if there's no file If Datafile = "" OrElse Not IO.File.Exists(Datafile) Then - fInfWarErr(9, False, "Measurement data file not found (" & Datafile & ") !") + logme(9, False, "Measurement data file not found (" & Datafile & ") !") BWorker.CancelAsync() Return False End If 'Open file If Not FileInMeasure.OpenRead(Datafile) Then - fInfWarErr(9, False, "Failed to open file (" & Datafile & ") !") + logme(9, False, "Failed to open file (" & Datafile & ") !") BWorker.CancelAsync() Return False End If @@ -286,7 +285,7 @@ Public Module input ' Check if the component is already defined If InputUndefData.ContainsKey(txt) Then - fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + logme(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -298,7 +297,7 @@ Public Module input Else ' Check if component is already defined If MeasCheck(Comp) Then - fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + logme(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -317,7 +316,7 @@ Public Module input Select Case sKVM.Key Case tComp.trigger If MSCX.tUse Then - fInfWarErr(9, False, "No trigger signal detected, but trigger_used in MS config activated!") + logme(9, False, "No trigger signal detected, but trigger_used in MS config activated!") BWorker.CancelAsync() Return False End If @@ -329,7 +328,7 @@ Public Module input Case tComp.user_valid valid_set = True Case Else - fInfWarErr(9, False, "Missing signal for " & fCompName(sKVM.Key)) + logme(9, False, "Missing signal for " & fCompName(sKVM.Key)) BWorker.CancelAsync() Return False End Select @@ -350,9 +349,9 @@ Public Module input If sKV.Key = tComp.t Then CalcData(tCompCali.t).Add(CDbl(Line(sKV.Value))) If tDim >= 2 Then - If Math.Abs((InputData(sKV.Key)(tDim - 1) - InputData(sKV.Key)(tDim - 2)) / (1 / HzIn) - 1) * 100 > delta_Hz_max Then + If Math.Abs((InputData(sKV.Key)(tDim - 1) - InputData(sKV.Key)(tDim - 2)) / (1 / HzIn) - 1) * 100 > Crt.delta_Hz_max Then If ErrDat Then - fInfWarErr(9, False, "The input data is not recorded at " & HzIn & "Hz at line: " & JumpPoint & " and " & tDim) + logme(9, False, "The input data is not recorded at " & HzIn & "Hz at line: " & JumpPoint & " and " & tDim) BWorker.CancelAsync() Return False Else @@ -367,7 +366,7 @@ Public Module input If Not ZoneChange Then If tDim > 1 Then If CalcData(tCompCali.zone_UTM).Last <> UTMCoord.Zone Then - fInfWarErr(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") + logme(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") ZoneChange = True End If End If @@ -385,7 +384,7 @@ Public Module input If Not ZoneChange Then If tDim > 1 Then If CalcData(tCompCali.zone_UTM).Last <> UTMCoord.Zone Then - fInfWarErr(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") + logme(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") ZoneChange = True End If End If @@ -422,7 +421,7 @@ Public Module input Next Loop Catch ex As Exception - fInfWarErr(9, False, "Error during file read! Line number: " & tDim + 1 & " (" & Datafile & ")") + logme(9, False, "Error during file read! Line number: " & tDim + 1 & " (" & Datafile & ")") BWorker.CancelAsync() Return False End Try @@ -445,7 +444,7 @@ Public Module input CalcData(tCompCali.longi_UTM)(i) = UTMCoord.Easting Next i If Zone1CentralMeridian > 180 Then - fInfWarErr(9, False, "The adjustment is not possible because the data lie to far away from each other to fit into one UTM stripe") + logme(9, False, "The adjustment is not possible because the data lie to far away from each other to fit into one UTM stripe") BWorker.CancelAsync() Return False End If @@ -474,7 +473,7 @@ Public Module input ' Open the shape generic file If Not FileInGenShp.OpenRead(GenShpFile) Then ' Falls File nicht vorhanden, abbrechen mit Fehler - fInfWarErr(9, True, "Can´t find the generic shape file: " & GenShpFile) + logme(9, True, "Can´t find the generic shape file: " & GenShpFile) Return False End If @@ -496,7 +495,7 @@ Public Module input If GenShape.veh_class.Contains(Line(pos)) Then For j = 0 To GenShape.veh_class.Count - 1 If GenShape.veh_class(j) = Line(pos) And GenShape.veh_conf(j) = Line2(pos) Then - fInfWarErr(9, True, "The vehicle class with this configuration is already defined. Please control your generic shape file!") + logme(9, True, "The vehicle class with this configuration is already defined. Please control your generic shape file!") Return False End If Next diff --git a/CSE/IO/output.vb b/CSE/IO/output.vb index bb081e0aeb9a6c792804dec3f25ec52a4e596ecf..8fefbc95857d7f18a89a4605bab63584ea7c82ea 100644 --- a/CSE/IO/output.vb +++ b/CSE/IO/output.vb @@ -17,7 +17,7 @@ ErgEntriesC = New Dictionary(Of tCompCali, CResult) ErgEntryListC = New List(Of tCompCali) GenErgOutData(calibration) - If hz_out = 1 Then + If Crt.hz_out = 1 Then ConvTo1Hz(InputData(tComp.t), InputUndefData) ConvTo1Hz(InputData) ConvTo1Hz(CalcData) @@ -29,11 +29,11 @@ End If ' Write on GUI - fInfWarErr(5, False, "Writing output-file (*.csv)") + logme(5, False, "Writing output-file (*.csv)") ' Generate the file name NameOutFile = "" - Select Case hz_out + Select Case Crt.hz_out Case 1 NameOutFile = OutFolder & fName(Datafile, False) & "_1Hz.csv" Case 100 @@ -80,16 +80,16 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + logme(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True End Function ' Function for the output of the result data - Function fOutCalcRes(ByVal Datafile() As String, ByVal calibration As Boolean) As Boolean - ' Declaration - Dim i As Integer + Function fOutCalcRes(ByVal calibration As Boolean) As Boolean + Dim calibration_fpath = Job.calibration_fpath + Dim coasting_fpaths() = Job.coasting_fpaths Dim NameOutFile, key As String Using FileOut As New cFile_V3 Dim first As Boolean @@ -109,7 +109,7 @@ End If ' Write on GUI - fInfWarErr(5, False, "Writing result-file (*.csv)") + logme(5, False, "Writing result-file (*.csv)") ' Generate the file name NameOutFile = OutFolder & fName(JobFile, False) & "_MS_CAL.csv" @@ -123,11 +123,11 @@ ' Filekopf FileOut.WriteLine("Resultfile Programm " & AppName & " " & AppVers & " Comp " & AppDate) If calibration Then - FileOut.WriteLine("Datafile: ", Datafile(1)) + FileOut.WriteLine("Datafile: ", calibration_fpath) Else - FileOut.WriteLine("Datafile LS1: ", Datafile(2)) - FileOut.WriteLine("Datafile HS: ", Datafile(3)) - FileOut.WriteLine("Datafile LS2: ", Datafile(4)) + FileOut.WriteLine("Datafile LS1: ", coasting_fpaths(0)) + FileOut.WriteLine("Datafile HS: ", coasting_fpaths(1)) + FileOut.WriteLine("Datafile LS2: ", coasting_fpaths(2)) End If FileOut.WriteLine("") FileOut.WriteLine("Results") @@ -183,16 +183,15 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + logme(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True End Function ' Function for the output of the result data of the regression - Function fOutCalcResReg(ByVal Datafile() As String) As Boolean - ' Declaration - Dim i As Integer + Function fOutCalcResReg() As Boolean + Dim coasting_fpaths() = Job.coasting_fpaths Dim NameOutFile, key As String Using FileOut As New cFile_V3 Dim first As Boolean @@ -210,7 +209,7 @@ End If ' Write on GUI - fInfWarErr(5, False, "Writing result-file (*.csv)") + logme(5, False, "Writing result-file (*.csv)") ' Generate the file name NameOutFile = OutFolder & fName(JobFile, False) & "_CSE.csv" @@ -220,9 +219,9 @@ ' Filekopf FileOut.WriteLine("Resultfile Programm " & AppName & " " & AppVers & " Comp " & AppDate) - FileOut.WriteLine("Datafile LS1: ", Datafile(2)) - FileOut.WriteLine("Datafile HS: ", Datafile(3)) - FileOut.WriteLine("Datafile LS2: ", Datafile(4)) + FileOut.WriteLine("Datafile LS1: ", coasting_fpaths(0)) + FileOut.WriteLine("Datafile HS: ", coasting_fpaths(1)) + FileOut.WriteLine("Datafile LS2: ", coasting_fpaths(2)) FileOut.WriteLine("") FileOut.WriteLine("Results") FileOut.WriteLine("fv_veh:", fv_veh, "[-] calibration factor for vehicle speed") @@ -277,7 +276,7 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + logme(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True @@ -653,7 +652,7 @@ For z = 1 To ValuesX.Item(tCompCali.t).Count - 1 If fTime(z) < fTime(z - 1) Then If Sprung Then - fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + logme(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") Return False Else Sprung = True @@ -844,7 +843,7 @@ For z = 1 To ValuesX.Item(tComp.t).Count - 1 If fTime(z) < fTime(z - 1) Then If Sprung Then - fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + logme(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") Return False Else Sprung = True @@ -1035,7 +1034,7 @@ For z = 1 To ValuesX.Item(ValuesX.First.Key).Count - 1 If fTime(z) < fTime(z - 1) Then If Sprung Then - fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + logme(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") Return False Else Sprung = True diff --git a/CSE/declaration_public.vb b/CSE/declaration_public.vb index 636c22e926236e0b35049951ea58cc9e5b727b60..6c2c72219defe16ca1d314dece85718cf44ee575 100644 --- a/CSE/declaration_public.vb +++ b/CSE/declaration_public.vb @@ -10,6 +10,16 @@ Public NameFK() As String = ({"", "Vehicle", "Weather", "Altitude", "MS Config calibration", "MS Config test", "Data Calib", "Data LS1", "Data HS", "Data LS2"}) Public AnzeigeMessage() As String = ({"", "", "", " + ", " ~ ", " * ", " - ", "", "", ""}) + Public AppFormStarted = False + Public PrefsPath As String + Public Prefs As cPreferences + Public Job As cJob ' The values for the 'Main' tab (and Criteria) + Public Crt As cCriteria ' The values for the 'Options' tab + Public Sub installJob(ByVal newJob As cJob) + Job = newJob + Crt = newJob.Criteria + End Sub + ' General Path variables Public MyPath As String ' Path of the *.exe Public RestartN As Boolean = False ' Restart of the *.exe @@ -28,68 +38,16 @@ Public Const f_rollHS = 1 ' Constant value for HS rolling resistance Public Zone1CentralMeridian = -177 ' Central UTM zone meridian (Will be changed by zone adjustment) - ' Processing params - Public rr_corr_factor As Double ' Rolling resistance correction factor - Public accel_correction As Boolean = False ' Variable for the acceleration correction - Public gradient_correction As Boolean = False ' Variable for the gradient correction - Public hz_out As Integer = 1 ' Hz result file output - Public acc_corr_avg As Single ' [s] averaging of vehicle speed for correction of acceleration forces - Public dist_float As Single ' [m]; Distance used for calculation of floatinig average signal used for stabilitay criteria in low speed tests - Public roh_air_ref As Single ' [kg/m^3] Reference air density - - ' Criteria - Public trigger_delta_x_max As Single ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (driving direction) - Public trigger_delta_y_max As Single ' [m]; +/- size of the control area around a MS start/end point where a trigger signal is valid (perpendicular to driving direction) - Public delta_head_max As Single ' [°]; +/- maximum deviation from heading as read from the csdat-file to the heading from csms-file for a valid dataset - Public segruns_min_CAL As Integer ' [#]; Minimum number of valid datasets required for the calibration test (per combination of MS ID and DIR ID) - Public segruns_min_LS As Integer ' [#]; Minimum number of valid datasets required for the low speed test (per combination of MS ID and DIR ID) - Public segruns_min_HS As Integer ' [#]; Minimum number of valid datasets required for the high speed test (per combination of MS ID and DIR ID) - Public segruns_min_head_MS As Integer ' [#]; Minimum TOTAL number of valid datasets required for the high speed test per heading - Public delta_Hz_max As Single ' [%]; maximum allowed deviation of timestep-size in csdat-file from 100Hz - Public delta_parallel_max As Single ' [°]; maximum heading difference for measurement section (parallelism criteria for test track layout) - Public leng_crit As Single ' [m]; maximum absolute difference of distance driven with lenght of section as specified in configuration - Public v_wind_avg_max_CAL As Single ' [m/s]; maximum average wind speed during calibration test - Public v_wind_1s_max_CAL As Single ' [m/s]; maximum gust wind speed during calibration test - Public beta_avg_max_CAL As Single ' [°]; maximum average beta during calibration test - Public v_wind_avg_max_LS As Single ' [m/s]; maximum average wind speed during low speed test - Public v_wind_1s_max_LS As Single ' [m/s]; maximum gust wind speed during low speed test - Public v_veh_avg_max_LS As Single ' [km/h]; maximum average vehicle speed for low speed test - Public v_veh_avg_min_LS As Single ' [km/h]; minimum average vehicle speed for low speed test - Public v_veh_float_delta_LS As Single ' [km/h]; +/- maximum deviation of floating average vehicle speed from average vehicle speed over entire section (low speed test) - Public tq_sum_float_delta_LS As Single ' [-]; +/- maximum relative deviation of floating average torque from average torque over entire section (low speed test) - Public v_wind_avg_max_HS As Single ' [m/s]; maximum average wind speed during high speed test - Public v_wind_1s_max_HS As Single ' [m/s]; maximum gust wind speed during high speed test - Public v_veh_avg_min_HS As Single ' [km/h]; minimum average vehicle speed for high speed test - Public beta_avg_max_HS As Single ' [°]; maximum average beta during high speed test - Public v_veh_1s_delta_HS As Single ' [km/h]; +/- maximum deviation of 1s average vehicle speed from average vehicle speed over entire section (high speed test) - Public tq_sum_1s_delta_HS As Single ' [-]; +/- maximum relative deviation of 1s average torque from average torque over entire section (high speed test) - Public delta_t_tyre_max As Single ' [°C]; maximum variation of tyre temperature between high speed tests and low speed tests - Public delta_rr_corr_max As Single ' [kg/t]; maximum difference of RRC from the two low speed runs - Public t_amb_var As Single ' [°C]; maximum variation of ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) - Public t_amb_max As Single ' [°C]; Maximum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) - Public t_amb_tarmac As Single ' [°C]; Maximum temperature below which no documentation of tarmac conditions is necessary - Public t_amb_min As Single ' [°C]; Minimum ambient temperature (measured at the vehicle) during the tests (evaluated based on the used datasets only) ' Constances for the array declaration Public JumpPoint As Integer = -1 ' Point at that a jump in the time-resolved data is detected Public OptPar() As Boolean = ({True, True, True}) ' Array to identify if optional parameters are given - ' Spezification files - Public Vehspez As String ' Vehicle specification file - Public AnemIC(3) As Single ' Anemometer instrument calibration factors - Public Ambspez As String ' Ambient conditions file - Public DataSpez(3) As String ' Data specification file - Public MSCCSpez As String ' Measurement section configuration file (Calibration run) - Public MSCTSpez As String ' Measurement section configuration file (Test run) - ' Boolean for the programm control Public endofall As Boolean = False ' Variable if enough input data in the files Public FileBlock As Boolean = False ' Variable if a file is blocked by an other process - Public PreferencesPath As String - Public AppPreferences As cPreferences - 'File browser Public FB_Drives() As String Public FB_Init As Boolean = False diff --git a/CSE/utils.vb b/CSE/utils.vb index 8320d7f08d1b2cc8457cd97cd47930987b9d477b..b8f1defb99c78959262de5dff7b3b80aa716754b 100644 --- a/CSE/utils.vb +++ b/CSE/utils.vb @@ -90,16 +90,54 @@ Module utils Return obj.Aggregate(Function(x, y) IO.Path.Combine(x.ToString(), y.ToString())) End Function - Function StripBackslash(ByVal path As String) As String + Function StripFinalBackslash(ByVal path As String) As String If path Is Nothing Then Return Nothing - ElseIf (path.Last = "\"c) Then - Return path.Substring(0, path.Length - 1) + ElseIf (path.EndsWith("\")) Then + Return path.Remove(path.Length - 1) Else Return path End If End Function + ''' <summary>Add root to the path if it is a relative one</summary> + ''' <returns>the root if path null/empty</returns> + Function getRootedPath(ByVal pathToRoot, ByVal root) + If String.IsNullOrWhiteSpace(pathToRoot) Then + Return root + ElseIf IO.Path.IsPathRooted(pathToRoot) Then + Return pathToRoot + End If + Return joinPaths(root, pathToRoot) + End Function + + ''' <summary>Check if path has the specified as parent and return it as relative then</summary> + ''' <returns>the parent if path null/empty/invalid, null if path = parent</returns> + ''' <exception cref="ArgumentException">if parent not a valid path</exception> + Function getAnySubPath(ByVal pathToCheck As String, ByVal parent As String) + If String.IsNullOrWhiteSpace(pathToCheck) Then Return parent + + '' Prepare Absolute-paths for comparison, and + '' scream if parent invalid. + '' + parent = IO.Path.GetFullPath(StripFinalBackslash(parent)) + Try + pathToCheck = IO.Path.GetFullPath(pathToCheck) + Catch ex As Exception + Return parent + End Try + + If pathToCheck.StartsWith(parent, StringComparison.OrdinalIgnoreCase) Then + pathToCheck = pathToCheck.Substring(parent.Length) + + If pathToCheck.StartsWith(IO.Path.DirectorySeparatorChar) Then pathToCheck = pathToCheck.Substring(1) + If pathToCheck.Length = 0 OrElse pathToCheck = IO.Path.DirectorySeparatorChar Then + pathToCheck = Nothing + End If + End If + + Return pathToCheck + End Function #End Region ' File paths' ' Function for a linear interpolation @@ -163,7 +201,7 @@ Module utils ' Functions for the information depiction on the GUI with the backgroundworker (Info, Warning, Error) #Region "Logging" ''' <summary>Output from Informations\Warnings\Errors on the GUI, even from within the Backgoundworker</summary> - Sub fInfWarErr(ByVal logLevel As Integer, ByVal MsgBoxOut As Boolean, _ + Sub logme(ByVal logLevel As Integer, ByVal MsgBoxOut As Boolean, _ ByVal text As String, Optional ByVal ex As Exception = Nothing) ' Declaration @@ -175,14 +213,14 @@ Module utils Select Case logLevel Case 5 To 7 ' Info logFileLevel = 1 - tabLabel = "Info" + tabLabel = "Messages" Case 8 ' Warning logFileLevel = 2 - tabLabel = "Warning" + tabLabel = "Warnings" StyleOut = MsgBoxStyle.Exclamation Case 9 ' Error logFileLevel = 3 - tabLabel = "Error" + tabLabel = "Errors" StyleOut = MsgBoxStyle.Critical End Select @@ -191,7 +229,7 @@ Module utils '' Print only filtered msgs in log-window '' - If logLevel >= AppPreferences.logLevel Then + If logLevel >= Prefs.logLevel Then Dim wintext = AnzeigeMessage(logLevel) & text If BWorker.IsBusy Then '' If in Worker-thread, update GUI through a ProgressChanged event @@ -229,20 +267,18 @@ Module utils ' Write to Log-windows Select Case logFileLevel - Case 1 ' Info - F_Main.ListBoxMSG.Items.Add(text) Case 2 ' Warning F_Main.ListBoxMSG.Items.Add(text) F_Main.ListBoxWar.Items.Add(text) - F_Main.TabPageWar.Text = tabLabel & " (" & F_Main.ListBoxWar.Items.Count & ")" + F_Main.TabPageWar.Text = format("Warnings({0})", F_Main.ListBoxWar.Items.Count) Case 3 ' Error - F_Main.ListBoxMSG.Items.Add(text) F_Main.ListBoxErr.Items.Add(text) - F_Main.TabPageErr.Text = tabLabel & " (" & F_Main.ListBoxErr.Items.Count & ")" - F_Main.TabControlOutMsg.SelectTab(2) + F_Main.TabPageErr.Text = format("Errors({0})", F_Main.ListBoxErr.Items.Count) Case Else '' ignored End Select + F_Main.ListBoxMSG.Items.Add(text) + F_Main.TabPageMSG.Text = format("Messages({0})", F_Main.ListBoxMSG.Items.Count) ' Set the Scrollbars in the Listboxes at the end F_Main.ListBoxMSG.TopIndex = F_Main.ListBoxMSG.Items.Count - 1 @@ -281,7 +317,7 @@ Module utils Function fWriteLog(ByVal eventType As Integer, Optional ByVal logLevel As Integer = 4, Optional ByVal text As String = "", _ Optional ByVal ex As Exception = Nothing) As Boolean - If Not AppPreferences.writeLog Then Return True + If Not Prefs.writeLog Then Return True Dim LogFilenam As String = joinPaths(MyPath, "log.txt") @@ -292,7 +328,7 @@ Module utils '' Truncate log-file if size exceeded on session-start. '' Dim fInf As New System.IO.FileInfo(LogFilenam) - If fInf.Exists AndAlso fInf.Length > AppPreferences.logSize * Math.Pow(10, 6) Then + If fInf.Exists AndAlso fInf.Length > Prefs.logSize * Math.Pow(10, 6) Then fLoeschZeilen(LogFilenam, System.IO.File.ReadAllLines(LogFilenam).Length / 2) End If ElseIf eventType = 3 Then @@ -545,35 +581,11 @@ Module utils #Region "GUI" - Sub fControlPath(ByVal fpath As String, ByVal fileKindNumber As Integer) - Dim fileKind = NameFK(fileKindNumber) - If (fpath = Nothing) Then - Throw New ArgumentException(format("Unspecified {0} Input-file!", fileKind)) - ElseIf Not IO.File.Exists(fpath) Then '' TODO: Drop this needless check after all files are read with bubbling exceptions. - Throw New ArgumentException(format("Cannot find {0} Input-file({1})!", fileKind, fpath)) - End If - - fWriteLog(2, 4, fileKind & " File: " & fpath) - End Sub - - ' Polling after the right fileending - Function fControlInput(ByVal File As String, ByVal position As Integer, ByVal endung As String) As Boolean - ' If no file, file with the wrong ending or the default is given then writes a warning - 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, StringComparison.OrdinalIgnoreCase)) Then - fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") - Return False - End If - Return True - End Function - Sub updateControlsFromSchema(ByVal schema As JObject, ByVal ctrl As Control, ByVal label As Control) Try Dim pschema = schema.SelectToken(".properties." & ctrl.Name) If pschema Is Nothing Then - fInfWarErr(8, False, format("Schema2GUI: Could not find schema for Control({0})!\n\iSchema: {1}", ctrl.Name, schema)) + logme(8, False, format("Schema2GUI: Could not find schema for Control({0})!\n\iSchema: {1}", ctrl.Name, schema)) Return End If @@ -610,7 +622,7 @@ Module utils Catch ex As Exception - fInfWarErr(8, False, format("Schema2GUI: Skipped exception: {0} ", ex.Message), ex) + logme(8, False, format("Schema2GUI: Skipped exception: {0} ", ex.Message), ex) End Try End Sub