diff --git a/BUILD.md b/BUILD.md index 9fbae276079863ee097bd3504f62c6db315f56af..a6b0b9d4697f0f8d7014c2f1927c175d0868775b 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,3 +1,6 @@ +VECTO-CSE: Development +====================== + ### BUILD Before compiling you need to add/check references to: * vectolic.dll diff --git a/CHANGES.md b/CHANGES.md index 42fdf5d38c035af72c9eb99f65f409d91d37a3c7..fed2d92b62db42e0b45d5e94ad6d769808484bb1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,13 +1,31 @@ - VECTO-CSE's Changes - =================== +VECTO-CSE: Changes +=================== + +#### 2014-05-29: 2.0.1-pre1 #### +JRC contributions: + * Read/write Vehicle-file as JSON. + * prefsUI: Add Reload button. + * Remember window-location (use .net Settings for that). + * All logs (even those sent to msg-box) are written to log-file, with timestamps and stack-traces. +##### Internal: + * Start saving stack-traces into the log-file. + * Enhance JSON-files with standard header/body behavior. + * Link JSON to GUI controls (labels & toolstips) + * json: Read defaults from schemas. + * Rework logging as a single routine, whether invoked from Background Worker or not. -### 2014-05-23: CSE-2.0.1-pre0 -* Remove the versioning infos from app-name (manual, project-name, folders). -* Possible to use any editor (not only notepad.exe). -* Separate config/ from Declaration/ folders. -* Added README.md, CHANGES.md, COPYING.txt files. +#### 2014-05-23: 2.0.1-pre0 #### +JRC contributions: + * Remove the versioning infos from app-name (manual, project-name, folders). + * Use SemanticVersioning 2.0.0 (see http://semver.org/). + * Possible to use any editor (not only notepad.exe). + * Separate config/ from Declaration/ folders. + * Added README.md, CHANGES.md, COPYING.txt files. +##### Internal: + * Auto create config/ on the 1st run, converted to JSON with transparent error-handling. + * FIX leaking of file-descriptors by using VB's 'Using' statement (class 'cFile_v3' now implements IDisposeable). -#### Internal: -* Auto create config/ on the 1st run, convert it to JSON with transparent error-handling. -* FIX leaking of file-descriptors by using VB's 'Using' statement (class 'cFile_v3' now implements IDisposeable). + +#### 2014-05-14: CSE2.01 #### +1st delivery from TU-Graz under Lot-3. diff --git a/CSE/App.config b/CSE/App.config index e6bcccabcc7bc70ee676c9ae05863f510546989f..6a5baf876d17bd733a10ad6393f02dda1ecaf1b5 100644 --- a/CSE/App.config +++ b/CSE/App.config @@ -1,5 +1,10 @@ <?xml version="1.0" encoding="utf-8" ?> <configuration> + <configSections> + <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > + <section name="CSE.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> + </sectionGroup> + </configSections> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> @@ -12,4 +17,11 @@ <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" /> </startup> + <userSettings> + <CSE.My.MySettings> + <setting name="F_Main_location" serializeAs="String"> + <value>0, 0</value> + </setting> + </CSE.My.MySettings> + </userSettings> </configuration> \ No newline at end of file diff --git a/CSE/Tools/ApplicationEvents.vb b/CSE/ApplicationEvents.vb similarity index 88% rename from CSE/Tools/ApplicationEvents.vb rename to CSE/ApplicationEvents.vb index 36ec3c241f6df53b31e99321b01bc3828aa1221c..f6c95fb6083e36a22c4b0c7128ffa461080a4a3d 100644 --- a/CSE/Tools/ApplicationEvents.vb +++ b/CSE/ApplicationEvents.vb @@ -7,6 +7,7 @@ ' Close the open Filebrowser (Save the History) fbTXT.Close() + fbExe.Close() fbVECTO.Close() fbCSV.Close() fbDir.Close() @@ -29,8 +30,11 @@ ' 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) + ' 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\") @@ -39,9 +43,6 @@ ' compile date AppDate = fiAss.LastWriteTime.Date - AppSettings = New cSettings() - ''AppSettings.Validate() !!!Skip schema-validation here, or else app hangs as zombie! (do it instead when creating new for Dialog) - ' Licencemodul Lic.FilePath = joinPaths(MyPath, "License.dat") Lic.AppVersion = AppVers @@ -63,8 +64,8 @@ fbWorkDir = New cFileBrowser("DIR", True) - fbVEH = New cFileBrowser("VEH") - fbVEH.Extensions = New String() {"csveh"} + fbVEH = New cFileBrowser("VEH.json") + fbVEH.Extensions = New String() {"csveh.json"} fbAMB = New cFileBrowser("AMB") fbAMB.Extensions = New String() {"csamb"} diff --git a/CSE/CSE.vbproj b/CSE/CSE.vbproj index c24326f47da2b738278af801e98403ea27e1af94..5663925cc65f5da210b05af545671cdd15603359 100644 --- a/CSE/CSE.vbproj +++ b/CSE/CSE.vbproj @@ -105,34 +105,35 @@ <ItemGroup> <Compile Include="Classes\cGenShp.vb" /> <Compile Include="Classes\cMSC.vb" /> + <Compile Include="IO\cJsonFile.vb" /> <Compile Include="Classes\CResult.vb" /> - <Compile Include="Classes\cSettings.vb" /> + <Compile Include="IO\cPreferences.vb" /> + <Compile Include="cSemanticVersion.vb" /> <Compile Include="Classes\csKey.vb" /> <Compile Include="Classes\cUTMCoord.vb" /> <Compile Include="Classes\cValidSec.vb" /> - <Compile Include="Classes\cVehicle.vb" /> + <Compile Include="IO\cVehicle.vb" /> <Compile Include="Classes\cVirtMSC.vb" /> - <Compile Include="Export\Minor_routines_output.vb" /> - <Compile Include="Export\output.vb" /> - <Compile Include="Export\OutputTest.vb" /> + <Compile Include="IO\output.vb" /> + <Compile Include="IO\OutputTest.vb" /> <Compile Include="Calculation\Minor_routines_calculate.vb" /> <Compile Include="Calculation\main_calculation_call.vb" /> <Compile Include="Calculation\Signal_identification.vb" /> <Compile Include="Calculation\sub_linear_regression.vb" /> - <Compile Include="Import\read_input.vb" /> + <Compile Include="IO\input.vb" /> <Compile Include="GUI\Export_GUI.vb" /> - <Compile Include="GUI\minor_routines_GUI.vb" /> + <Compile Include="GUI\utils_GUI.vb" /> <Compile Include="GUI\cFileBrowser.vb" /> - <Compile Include="GUI\CSE_Config.designer.vb"> - <DependentUpon>CSE_Config.vb</DependentUpon> + <Compile Include="GUI\F_Preferences.designer.vb"> + <DependentUpon>F_Preferences.vb</DependentUpon> </Compile> - <Compile Include="GUI\CSE_Config.vb"> + <Compile Include="GUI\F_Preferences.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="GUI\CSE_Info.Designer.vb"> - <DependentUpon>CSE_Info.vb</DependentUpon> + <Compile Include="GUI\F_About.Designer.vb"> + <DependentUpon>F_About.vb</DependentUpon> </Compile> - <Compile Include="GUI\CSE_Info.vb"> + <Compile Include="GUI\F_About.vb"> <SubType>Form</SubType> </Compile> <Compile Include="declaration_public.vb" /> @@ -148,10 +149,10 @@ <Compile Include="GUI\FB_FavDlog.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="GUI\CSEMain.Designer.vb"> - <DependentUpon>CSEMain.vb</DependentUpon> + <Compile Include="GUI\F_Main.Designer.vb"> + <DependentUpon>F_Main.vb</DependentUpon> </Compile> - <Compile Include="GUI\CSEMain.vb"> + <Compile Include="GUI\F_Main.vb"> <SubType>Form</SubType> </Compile> <Compile Include="My Project\AssemblyInfo.vb" /> @@ -169,18 +170,18 @@ <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> - <Compile Include="Tools\ApplicationEvents.vb" /> - <Compile Include="Tools\Minor_routines.vb" /> - <Compile Include="Tools\cFile_v3.vb" /> + <Compile Include="ApplicationEvents.vb" /> + <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\CSE_Config.resx"> - <DependentUpon>CSE_Config.vb</DependentUpon> + <EmbeddedResource Include="GUI\F_Preferences.resx"> + <DependentUpon>F_Preferences.vb</DependentUpon> </EmbeddedResource> - <EmbeddedResource Include="GUI\CSE_Info.resx"> - <DependentUpon>CSE_Info.vb</DependentUpon> + <EmbeddedResource Include="GUI\F_About.resx"> + <DependentUpon>F_About.vb</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="GUI\FB_Dialog.resx"> <DependentUpon>FB_Dialog.vb</DependentUpon> @@ -188,8 +189,8 @@ <EmbeddedResource Include="GUI\FB_FavDlog.resx"> <DependentUpon>FB_FavDlog.vb</DependentUpon> </EmbeddedResource> - <EmbeddedResource Include="GUI\CSEMain.resx"> - <DependentUpon>CSEMain.vb</DependentUpon> + <EmbeddedResource Include="GUI\F_Main.resx"> + <DependentUpon>F_Main.vb</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="My Project\Resources.resx"> <Generator>VbMyResourcesResXFileCodeGenerator</Generator> @@ -199,6 +200,7 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> + <None Include="App.config" /> <None Include="My Project\Application.myapp"> <Generator>MyApplicationCodeGenerator</Generator> <LastGenOutput>Application.Designer.vb</LastGenOutput> @@ -294,6 +296,7 @@ <Install>true</Install> </BootstrapperPackage> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/CSE/Calculation/Minor_routines_calculate.vb b/CSE/Calculation/Minor_routines_calculate.vb index 3dfdccb50409af60ce01640576d9e06d1a92c577..15f532a055bdd11db7397df4d508ee57d0a617bd 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 - fInfWarErrBW(9, False, "The angle definition is not possible") + fInfWarErr(9, False, "The angle definition is not possible") QuadReq = "x" End If End Function @@ -59,7 +59,7 @@ 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 Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") + fInfWarErr(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") Return False Else Sprung = True @@ -130,7 +130,7 @@ 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 Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & i - 1 & ") = " & TimeX(i - 1) & "[s], t(" & i & ") = " & TimeX(i) & "[s]") + fInfWarErr(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 - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & TimeX(z - 1) & "[s], t(" & z & ") = " & TimeX(z) & "[s]") + fInfWarErr(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 - fInfWarErrBW(4, False, "Read altitude file") + fInfWarErr(5, False, "Read altitude file") ' Open the MSC spezification file If Not FileInAlt.OpenRead(File) Then ' Error if the file is not available - fInfWarErrBW(9, False, "Can´t find the altitude file: " & File) + fInfWarErr(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 - fInfWarErrBW(9, False, "The distance is lower then the minimum in the altitude file") + fInfWarErr(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 - fInfWarErrBW(9, False, "Was not able to calculate the distance and bearing between koordinates.") + fInfWarErr(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 8fa66050821ac516b0e267626237bf48f1bf092b..2a1b4fa1ebf6797c5131e1c7b121a1fb15f4d190 100644 --- a/CSE/Calculation/Signal_identification.vb +++ b/CSE/Calculation/Signal_identification.vb @@ -8,7 +8,7 @@ If SectionDev Then ' Output on the GUI - fInfWarErrBW(6, False, "Identifing the sections") + fInfWarErr(6, False, "Identifying the sections") ' Devide the measured data into there sections DevInSec(vMSC) @@ -16,7 +16,7 @@ ' Leap in time control If JumpPoint <> -1 Then If CalcData(tCompCali.SecID)(JumpPoint) <> 0 Then - fInfWarErrBW(9, False, "The detected leap in time is inside a measurement section. This is not allowed!") + fInfWarErr(9, False, "The detected leap in time is inside a measurement section. This is not allowed!") BWorker.CancelAsync() Return False End If @@ -673,26 +673,26 @@ run = 0 anz = 0 If TestRunX = 1 Or TestRunX = 3 Then - igear = vehicleX.rat_gl + igear = vehicleX.gearRatio_low If TestRunX = 1 Then RunIDx = IDLS1 Else RunIDx = IDLS2 End If Else - igear = vehicleX.rat_gh + igear = vehicleX.gearRatio_high RunIDx = IDHS End If ' Calculate the other values of the speed run For i = 0 To CalcData(tCompCali.SecID).Count - 1 ' Wheel rotation - CalcData(tCompCali.omega_wh)(i) = (InputData(tComp.n_eng)(i) * Math.PI / (30 * vehicleX.rat_axl * igear)) + CalcData(tCompCali.omega_wh)(i) = (InputData(tComp.n_eng)(i) * Math.PI / (30 * vehicleX.axleRatio * igear)) If i = 0 Or i = CalcData(tCompCali.SecID).Count - 1 Then CalcData(tCompCali.omega_p_wh)(i) = 0 Else - CalcData(tCompCali.omega_p_wh)(i) = ((InputData(tComp.n_eng)(i + 1) - InputData(tComp.n_eng)(i - 1)) / 2) * Math.PI / (30 * vehicleX.rat_axl * igear) + CalcData(tCompCali.omega_p_wh)(i) = ((InputData(tComp.n_eng)(i + 1) - InputData(tComp.n_eng)(i - 1)) / 2) * Math.PI / (30 * vehicleX.axleRatio * igear) End If ' Torque sum @@ -723,7 +723,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 - fInfWarErrBW(9, False, "The test time is outside the range of the data from the stationary weather station.") + fInfWarErr(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 +741,7 @@ End If End If If j = InputWeatherData(tCompWeat.t).Count - 1 Then - fInfWarErrBW(9, False, "The test time is outside the range of the data from the stationary weather station.") + fInfWarErr(9, False, "The test time is outside the range of the data from the stationary weather station.") BWorker.CancelAsync() Return False End If @@ -771,7 +771,7 @@ 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 - fInfWarErrBW(9, False, "Standstill or loss of vehicle speed signal inside MS not permitted (Error at line " & i & ")") + fInfWarErr(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 @@ -781,11 +781,11 @@ End If ' F gradient - CalcData(tCompCali.F_grd)(i) = vehicleX.mveh_ref * 9.81 * Math.Sin(CalcData(tCompCali.slope_deg)(i) * Math.PI / 180) + CalcData(tCompCali.F_grd)(i) = vehicleX.testMass * 9.81 * Math.Sin(CalcData(tCompCali.slope_deg)(i) * Math.PI / 180) End If ' Force acceleration - CalcData(tCompCali.F_acc)(i) = vehicleX.mveh_ref * CalcData(tCompCali.a_veh_ave)(i) + vehicleX.I_wheels * CalcData(tCompCali.omega_wh)(i) * CalcData(tCompCali.omega_p_wh)(i) / (CalcData(tCompCali.v_veh_c)(i) / 3.6) + CalcData(tCompCali.F_acc)(i) = vehicleX.testMass * CalcData(tCompCali.a_veh_ave)(i) + vehicleX.wheelsInertia * CalcData(tCompCali.omega_wh)(i) * CalcData(tCompCali.omega_p_wh)(i) / (CalcData(tCompCali.v_veh_c)(i) / 3.6) ' Force trajectory CalcData(tCompCali.F_res)(i) = CalcData(tCompCali.F_trac)(i) diff --git a/CSE/Calculation/main_calculation_call.vb b/CSE/Calculation/main_calculation_call.vb index 782f17efd52a2281432726ab6f52360d7d0cce72..37211e21155789946050260147a1b21d0c7f0621 100644 --- a/CSE/Calculation/main_calculation_call.vb +++ b/CSE/Calculation/main_calculation_call.vb @@ -1,7 +1,7 @@ Public Module main_calculation_call ' Main calculation - Function calculation(ByVal Cali As Boolean) As Boolean + Function calculation(ByVal isCalibrate As Boolean) As Boolean ' Declaration Dim i As Integer @@ -14,23 +14,22 @@ Units = Nothing UnitsUndef = Nothing - If Cali Then + If isCalibrate Then ' Declarations - Dim vehicle As New cVehicle Dim MSC As New cMSC Dim vMSC As New cVirtMSC ' Read the input data - fInfWarErrBW(7, False, "Reading Input Files...") - readInputVeh(vehicle) - ReadInputMSC(MSC, MSCCSpez, Cali) + fInfWarErr(7, False, "Reading Input Files...") + Dim vehicle As New cVehicle(Vehspez) + ReadInputMSC(MSC, MSCCSpez, isCalibrate) ReadDataFile(DataSpez(1), MSC) ' Exit function if error is detected If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErrBW(7, False, "Calculating the calibration run...") + fInfWarErr(7, False, "Calculating the calibration run...") ' Identify the signal measurement sections fIdentifyMS(MSC, vMSC) @@ -39,7 +38,7 @@ If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErrBW(6, False, "Calculating the calibration run parameter") + fInfWarErr(6, False, "Calculating the calibration run parameter") ' Calculate the results from the calibration test fCalcCalib(MSC, vehicle) @@ -48,24 +47,23 @@ 'If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErrBW(7, False, "Writing the output files...") + fInfWarErr(7, False, "Writing the output files...") ' Output - fOutDataCalc1Hz(DataSpez(1), Cali) - fOutCalcRes(DataSpez, Cali) + fOutDataCalc1Hz(DataSpez(1), isCalibrate) + fOutCalcRes(DataSpez, isCalibrate) Else ' Declarations - Dim vehicle As New cVehicle Dim MSC As New cMSC Dim vMSC As New cVirtMSC ' Output on the GUI - fInfWarErrBW(7, False, "Calculating the speed runs...") + fInfWarErr(7, False, "Calculating the speed runs...") ' Read the input files - fInfWarErrBW(7, False, "Reading Input Files...") - readInputVeh(vehicle) - ReadInputMSC(MSC, MSCTSpez, Cali) + fInfWarErr(7, False, "Reading Input Files...") + Dim vehicle As New cVehicle(Vehspez) + ReadInputMSC(MSC, MSCTSpez, isCalibrate) ReadWeather(Ambspez) ' Calculation of the virtual MSC points @@ -79,17 +77,17 @@ If i = 2 Or i = 4 Then ' Output on the GUI If i = 2 Then - fInfWarErrBW(7, False, "Calculating the first low speed run...") + fInfWarErr(7, False, "Calculating the first low speed run...") Else - fInfWarErrBW(7, False, "Calculating the second low speed run...") + fInfWarErr(7, False, "Calculating the second low speed run...") End If Else ' Output on the GUI - fInfWarErrBW(7, False, "Calculating the high speed run...") + fInfWarErr(7, False, "Calculating the high speed run...") End If ' Output on the GUI - fInfWarErrBW(6, False, "Reading the data file...") + fInfWarErr(6, False, "Reading the data file...") ReadDataFile(DataSpez(i), MSC) ' Exit function if error is detected @@ -108,10 +106,10 @@ If BWorker.CancellationPending Then Return False ' Output on the GUI - fInfWarErrBW(6, False, "Writing the output files...") + fInfWarErr(6, False, "Writing the output files...") ' Output - fOutDataCalc1Hz(DataSpez(i), Cali) + fOutDataCalc1Hz(DataSpez(i), isCalibrate) ' Save the Result dictionaries fSaveDic(i - 1) @@ -135,8 +133,8 @@ ' Exit function if error is detected If BWorker.CancellationPending Then ' Write the summerised output file - fInfWarErrBW(7, False, "Writing the summarised output file...") - fOutCalcRes(DataSpez, Cali) + fInfWarErr(7, False, "Writing the summarised output file...") + fOutCalcRes(DataSpez, isCalibrate) Return False End If @@ -144,8 +142,8 @@ fCalcReg(vehicle) ' Write the summerised output file - fInfWarErrBW(7, False, "Writing the summarised output file...") - fOutCalcRes(DataSpez, Cali) + fInfWarErr(7, False, "Writing the summarised output file...") + fOutCalcRes(DataSpez, isCalibrate) ' Check if all is valid For i = 0 To ErgValuesReg(tCompErgReg.SecID).Count - 1 @@ -157,10 +155,10 @@ fOutCalcResReg(DataSpez) ' Write the results on the GUI - fInfWarErrBW(7, False, "Results from the calculation") - fInfWarErrBW(6, False, "average absolute beta HS test: " & Math.Round(beta, 4)) - fInfWarErrBW(6, False, "delta CdxA correction: " & Math.Round(delta_CdxA, 4)) - fInfWarErrBW(6, False, "CdxA(0): " & Math.Round(CdxA0, 4)) + 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)) ' Clear the dictionaries ErgValuesComp = Nothing @@ -223,7 +221,7 @@ ' Error If run > 10 Then - fInfWarErrBW(9, False, "The calibration is not possible because iteration for valid datasets does not converge (n>10)") + fInfWarErr(9, False, "The calibration is not possible because iteration for valid datasets does not converge (n>10)") Change = False BWorker.CancelAsync() Return False @@ -311,7 +309,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 - fInfWarErrBW(9, False, "The measured vehicle velocity (v_veh_CAN) is 0 in section: " & CalcX(i)) + fInfWarErr(9, False, "The measured vehicle velocity (v_veh_CAN) is 0 in section: " & CalcX(i)) BWorker.CancelAsync() Return False End If @@ -448,17 +446,17 @@ ' Calculate the steps For h = 5 To 95 Step Pstep - vwind_x = vwind_x_ha * Math.Pow((((h / 100) * vehicleX.hv) / vehicleX.ha), 0.2) - vwind_y = vwind_y_ha * Math.Pow((((h / 100) * vehicleX.hv) / vehicleX.ha), 0.2) - vairX = vairX + (Math.Sqrt((vwind_x + CalcData(tCompCali.v_veh_c)(i) / 3.6) ^ 2 + vwind_y ^ 2)) * vehicleX.hv * Pstep / 100 - vwindX = vwindX + (Math.Sqrt(vwind_x ^ 2 + vwind_y ^ 2)) * vehicleX.hv * Pstep / 100 - betaX = betaX + (Math.Atan(vwind_y / (vwind_x + CalcData(tCompCali.v_veh_c)(i) / 3.6)) * 180 / Math.PI) * vehicleX.hv * Pstep / 100 + vwind_x = vwind_x_ha * Math.Pow((((h / 100) * vehicleX.vehHeight) / vehicleX.anemometerHeight), 0.2) + vwind_y = vwind_y_ha * Math.Pow((((h / 100) * vehicleX.vehHeight) / vehicleX.anemometerHeight), 0.2) + vairX = vairX + (Math.Sqrt((vwind_x + CalcData(tCompCali.v_veh_c)(i) / 3.6) ^ 2 + vwind_y ^ 2)) * vehicleX.vehHeight * Pstep / 100 + vwindX = vwindX + (Math.Sqrt(vwind_x ^ 2 + vwind_y ^ 2)) * vehicleX.vehHeight * Pstep / 100 + betaX = betaX + (Math.Atan(vwind_y / (vwind_x + CalcData(tCompCali.v_veh_c)(i) / 3.6)) * 180 / Math.PI) * vehicleX.vehHeight * Pstep / 100 Next h ' Add the calculated values to the calculate arrays - CalcData(tCompCali.vair_c)(i) = (vairX / vehicleX.hv) - CalcData(tCompCali.vwind_c)(i) = (vwindX / vehicleX.hv) - CalcData(tCompCali.beta_c)(i) = (betaX / vehicleX.hv) + CalcData(tCompCali.vair_c)(i) = (vairX / vehicleX.vehHeight) + CalcData(tCompCali.vwind_c)(i) = (vwindX / vehicleX.vehHeight) + CalcData(tCompCali.beta_c)(i) = (betaX / vehicleX.vehHeight) vairX = 0 vwindX = 0 betaX = 0 @@ -554,7 +552,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErrBW(9, False, "Insufficent numbers of valid measurement sections available") + fInfWarErr(9, False, "Insufficent numbers of valid measurement sections available") BWorker.CancelAsync() Return False End If @@ -615,7 +613,7 @@ End If Next i If anz < 2 Then - fInfWarErrBW(9, False, "Insufficent numbers of valid measurement sections available") + fInfWarErr(9, False, "Insufficent numbers of valid measurement sections available") BWorker.CancelAsync() Return False End If @@ -703,7 +701,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErrBW(9, False, "Insufficent numbers of valid measurement sections in the low speed test available") + fInfWarErr(9, False, "Insufficent numbers of valid measurement sections in the low speed test available") BWorker.CancelAsync() Return False End If @@ -743,7 +741,7 @@ End If End If Else - fInfWarErrBW(9, False, "Not enough valid data for low speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) + 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))) End If End If Next j @@ -819,7 +817,7 @@ ' Ceck if enough sections are detected If SecCount.AnzSec.Count - 1 < 1 Then - fInfWarErrBW(9, False, "Insufficent numbers of valid measurement sections in the high speed test available") + fInfWarErr(9, False, "Insufficent numbers of valid measurement sections in the high speed test available") BWorker.CancelAsync() Return False End If @@ -837,12 +835,12 @@ Case 2 anzHS2 += SecCount.AnzSec(i) + SecCount.AnzSec(j) Case Else - fInfWarErrBW(9, False, "headID not known") + fInfWarErr(9, False, "headID not known") BWorker.CancelAsync() Return False End Select Else - fInfWarErrBW(9, False, "Not enough valid data for high speed tests available in section " & Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))) + 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))) BWorker.CancelAsync() End If End If @@ -851,7 +849,7 @@ ' Ceck if enough sections are detected If anzHS1 < ds_min_head_MS Or anzHS2 < ds_min_head_MS Then - fInfWarErrBW(9, False, "Number of valid high speed datasets too low") + fInfWarErr(9, False, "Number of valid high speed datasets too low") BWorker.CancelAsync() 'Return False End If diff --git a/CSE/Calculation/sub_linear_regression.vb b/CSE/Calculation/sub_linear_regression.vb index b01b5a02054458326e6684639d891bdfb1987cdc..c60fe3500c1449889518c9a3327dd27201e0151c 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 - fInfWarErrBW(7, False, "Calculate the linear regression...") + fInfWarErr(7, False, "Calculate the linear regression...") ' Initialisation lauf = -1 @@ -209,7 +209,7 @@ 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.F2_ref_singleDS)(PosHS(j)) = F2 - ErgValuesComp(tCompErg.RRC_singleDS)(PosHS(j)) = (ErgValuesComp(tCompErg.F0_singleDS)(PosHS(j)) / (vehicle.mveh_ref * 9.81)) * 1000 + 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 Next j @@ -230,7 +230,7 @@ ErgValuesReg(tCompErgReg.F0_LS1_ref).Add(F0) ErgValuesReg(tCompErgReg.F0_LS1).Add(F0 * (Roh_air_LS1 / numLS1) / roh_air_ref) ErgValuesReg(tCompErgReg.F2_LS1_ref).Add(F2) - ErgValuesReg(tCompErgReg.RRC_LS1).Add((ErgValuesReg(tCompErgReg.F0_LS1)(lauf) / (vehicle.mveh_ref * 9.81)) * 1000) + ErgValuesReg(tCompErgReg.RRC_LS1).Add((ErgValuesReg(tCompErgReg.F0_LS1)(lauf) / (vehicle.testMass * 9.81)) * 1000) '***** Calculate the linear regression for LS2 ' Redeminisionate the arrays @@ -249,7 +249,7 @@ ErgValuesReg(tCompErgReg.F0_LS2_ref).Add(F0) ErgValuesReg(tCompErgReg.F0_LS2).Add(F0 * (Roh_air_LS2 / numLS2) / roh_air_ref) ErgValuesReg(tCompErgReg.F2_LS2_ref).Add(F2) - ErgValuesReg(tCompErgReg.RRC_LS2).Add((ErgValuesReg(tCompErgReg.F0_LS2)(lauf) / (vehicle.mveh_ref * 9.81)) * 1000) + 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_RRC_max Then ErgValuesReg(tCompErgReg.RRC_valid).Add(0) @@ -281,7 +281,7 @@ 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.RRC).Add(ErgValuesReg(tCompErgReg.F0)(lauf) / (vehicle.mveh_ref * 9.81) * 1000) + ErgValuesReg(tCompErgReg.RRC).Add(ErgValuesReg(tCompErgReg.F0)(lauf) / (vehicle.testMass * 9.81) * 1000) ErgValuesReg(tCompErgReg.CdxA).Add(2 * F2 / 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)) @@ -322,16 +322,16 @@ ' 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 - fInfWarErrBW(9, False, "Invalid test - variation of ambient temperature (at the vehicle) outside boundaries") + fInfWarErr(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 - fInfWarErrBW(9, False, "Invalid test - maximum ambient temperature exceeded") + fInfWarErr(9, False, "Invalid test - maximum ambient temperature exceeded") ElseIf t_amb_min_f < t_amb_min Then - fInfWarErrBW(9, False, "Invalid test - fallen below minimum ambient temperature") + fInfWarErr(9, False, "Invalid test - fallen below minimum ambient temperature") ElseIf t_amb_max_f > t_amb_tarmac Then - fInfWarErrBW(9, False, "Invalid test - Ambient temperature higher than " & t_amb_tarmac & "°C") + fInfWarErr(9, False, "Invalid test - Ambient temperature higher than " & t_amb_tarmac & "°C") End If Return True @@ -400,7 +400,7 @@ ' Find the correct curve For i = 0 To GenShape.veh_class.Count - 1 - If GenShape.veh_class(i) = vehicleX.ID And GenShape.veh_conf(i) = vehicleX.veh_conf Then + If GenShape.veh_class(i) = vehicleX.classCode And CBool(GenShape.veh_conf(i)) = vehicleX.IsRigid Then pos = i Exit For End If @@ -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 - fInfWarErrBW(8, False, "The calculated yaw angle is higher than the greatest value in the generic curve. Delta_CdxA is set to 0!") + fInfWarErr(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 - fInfWarErrBW(8, False, "The calculated yaw angle is lower than the lowest value in the generic curve. Delta_CdxA is set to 0!") + fInfWarErr(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/Tools/cFile_v3.vb b/CSE/Classes/cFile_v3.vb similarity index 96% rename from CSE/Tools/cFile_v3.vb rename to CSE/Classes/cFile_v3.vb index 99aa0ecd0a28f3833337369291e00e322622c74d..aafdcf9de0009eb7624449645fedab0d61a502eb 100644 --- a/CSE/Tools/cFile_v3.vb +++ b/CSE/Classes/cFile_v3.vb @@ -120,16 +120,18 @@ lb10: End Function + ' Close the file Public Sub Dispose() Implements IDisposable.Dispose Try - Close() + Me.Close() Catch ex As Exception - fInfWarErr(9, False, "Failed while closing file_v3 fue to: " & ex.Message) + fInfWarErr(9, False, format( _ + "Skipped exception while closing file_v3({0}) due to: {1}", Me.Path, ex.Message), ex) End Try End Sub - ' Close the file - Public Sub Close() + ' Use Dispose instead. + Private Sub Close() Select Case Mode Case FileMode.Read If FileOpen Then TxtFldParser.Close() diff --git a/CSE/Classes/cSettings.vb b/CSE/Classes/cSettings.vb deleted file mode 100644 index d9eb9ec9763a20385522d9f6319313baeb3dd502..0000000000000000000000000000000000000000 --- a/CSE/Classes/cSettings.vb +++ /dev/null @@ -1,238 +0,0 @@ -Option Strict Off - -Imports Newtonsoft.Json.Linq -Imports Newtonsoft.Json.Schema - -Public Class cSettings - Public Shared Function SettingsPath() As String - Dim settings_fpath As String = joinPaths(MyPath, "config", AppSettingsFName) - - Return settings_fpath - End Function - - - Public Json_Contents As JObject - - ' Default-settings specified here. - Function JsonStr_Contents() As String - Return <json>{ - "Header": { - "FileVersion": "1.0", - "Strict": false, - }, - "Body": { - "WorkingDir": null, - "WriteLog": true, - "LogSize": 2, - "LogLevel": 5, - "Editor": "notepad.exe", - } - }</json>.Value - End Function - - ''' <param name="allowsAdditionalProps">when false, more strict validation</param> - Function JSchemaStr(ByVal allowsAdditionalProps As Boolean) As String - Dim allowsAdditionalProps_str As String = IIf(allowsAdditionalProps, "false", "true") - Return <json>{ - "title": "Vecto_cse-settings.ver1.0", - "type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>, - "properties": { - "Header": { - "type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>, - "required": true, - "properties": { - "FileVersion": { - "type": "string", - "required": true, - }, - "Strict": { - "type": "boolean", - "required": true, - "default": false, - } - } - }, - "Body": { - "type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>, - "required": true, - "properties": { - "WorkingDir": { - "type": ["string", "null"], - "required": false, - "default": null, - "description": "Last used Working Directory Path for input/output files, when null/empty, uses app's dir (default: null)", - }, - "WriteLog": { - "type": "boolean", - "required": true, - "description": "Whether to write messages to log file (default: true)", - }, - "LogSize": { - "type": "integer", - "required": true, - "description": "Allowed Log-file size limit [MiB] (default: 2)", - }, - "LogLevel": { - "type": "integer", - "required": true, - "description": "Message Output Level (default: 5 - 'info')", - }, - "Editor": { - "type": "string", - "required": true, - "description": "Path (or filename if in PATH) of some (text or JSON) editor (default: 'notepad.exe')", - }, - } - } - } - }</json>.Value - End Function - - - ''' <summary>Reads from file or creates defaults</summary> - ''' <param name="inputFilePath">If unspecifed, default settings used, otherwise data read from file</param> - ''' <remarks></remarks> - Sub New(Optional ByVal inputFilePath As String = Nothing) - If (inputFilePath Is Nothing) Then - Me.Json_Contents = JObject.Parse(JsonStr_Contents()) - Else - Me.Json_Contents = ReadJsonFile(inputFilePath) - End If - End Sub - - - ''' <summary>Validates and Writing to the config file</summary> - Sub Store(ByVal settings_fpath As String) - Validate(Me.Strict) - WriteJsonFile(settings_fpath, Json_Contents) - End Sub - - - ''' <exception cref="SystemException">includes all validation errors</exception> - ''' <param name="isStrict">when True, no additional json-properties allowed in the data, when nothing, use value from Header</param> - Friend Sub Validate(Optional ByVal isStrict As Boolean? = Nothing) - Dim allowsAdditionalProps As Boolean = IIf(isStrict Is Nothing, Me.Strict, Not isStrict) - Dim schema = JsonSchema.Parse(JSchemaStr(allowsAdditionalProps)) - Dim validateMsgs As IList(Of String) = New List(Of String) - - ValidateJson(Me.Json_Contents, schema, validateMsgs) - - If (validateMsgs.Any()) Then - Throw New SystemException(format("Invalid Settings due to: {0}", String.Join(vbCrLf, validateMsgs))) - End If - End Sub - - - - Public Overrides Function Equals(ByVal obj As Object) As Boolean - If obj Is Nothing OrElse Not Me.GetType().Equals(obj.GetType()) Then - Return False - Else - Return Me.Json_Contents.Equals(DirectCast(obj, cSettings).Json_Contents) - End If - End Function - - -#Region "json props" - Public ReadOnly Property FileVersion As String - Get - Return Me.Json_Contents("Header")("FileVersion") - End Get - End Property - - Public ReadOnly Property Strict As Boolean - Get - Return Me.Json_Contents("Header")("Strict") - End Get - End Property - - - Public Property WorkingDir As String - Get - Dim value As String = Me.Json_Contents("Body")("WorkingDir") - If value Is Nothing OrElse value.Trim().Length = 0 Then - value = MyPath - End If - - Return value - 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.Last <> "\"c) Then - value = value & "\" - End If - - If value.Length = 1 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 - - If value Is Nothing Then - Me.Json_Contents("Body")("WorkingDir") = Nothing - Else - Me.Json_Contents("Body")("WorkingDir") = value - End If - End Set - End Property - - Public Property WriteLog As Boolean - Get - Return Me.Json_Contents("Body")("WriteLog") - End Get - Set(ByVal value As Boolean) - Me.Json_Contents("Body")("WriteLog") = value - End Set - End Property - - Public Property LogSize As Integer - Get - Return Me.Json_Contents("Body")("LogSize") - End Get - Set(ByVal value As Integer) - Me.Json_Contents("Body")("LogSize") = value - End Set - End Property - - Public Property LogLevel As Integer - Get - Return Me.Json_Contents("Body")("LogLevel") - End Get - Set(ByVal value As Integer) - Me.Json_Contents("Body")("LogLevel") = value - End Set - End Property - - Public Property Editor As String - Get - Return Me.Json_Contents("Body")("Editor") - End Get - Set(ByVal value As String) - If value Is Nothing OrElse value.Trim().Length = 0 Then - value = "notepad.exe" - End If - - Me.Json_Contents("Body")("Editor") = value - End Set - End Property -#End Region ' "json props" -End Class diff --git a/CSE/Classes/cVehicle.vb b/CSE/Classes/cVehicle.vb deleted file mode 100644 index 660dd6cf86d94a0d0db113be39be15520d3db371..0000000000000000000000000000000000000000 --- a/CSE/Classes/cVehicle.vb +++ /dev/null @@ -1,12 +0,0 @@ -Public Class cVehicle - Public ID As Integer ' Vehicle class code [1-16] - Public veh_conf As Integer ' Vehicle configuration - Public mveh_ref As Double ' Vehicle test mass [kg] - Public I_wheels As Double ' Wheels inertia [kgm2] - Public rat_axl As Double ' Axle ratio - Public rat_gh As Double ' Gear ratio high speed - Public rat_gl As Double ' Gear ratio low speed - Public ha As Double ' Anemomenter height [m] - Public hv As Double ' Vehicle height [m] - Public wm As Double ' mask width [m] -End Class diff --git a/CSE/Export/Minor_routines_output.vb b/CSE/Export/Minor_routines_output.vb deleted file mode 100644 index 720bd0dee6723c9dc40568672f14ccee535d9d55..0000000000000000000000000000000000000000 --- a/CSE/Export/Minor_routines_output.vb +++ /dev/null @@ -1,714 +0,0 @@ -Module Minor_routines_output - ' Generate the output sequence for input data - Public Sub AddToErg(ByVal EnumID As tComp, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesI.ContainsKey(EnumID) Then - ErgEntriesI.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListI.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for undefined input data - Public Sub AddToErg(ByVal EnumID As String, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Dic = "InputUndefData" Then - If Not ErgEntriesIU.ContainsKey(EnumID) Then - ErgEntriesIU.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListIU.Add(EnumID) - End If - ElseIf Dic = "ErgValuesUndef" Then - If Not ErgEntriesRU.ContainsKey(EnumID) Then - ErgEntriesRU.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListRU.Add(EnumID) - End If - End If - End Sub - - ' Generate the output sequence for calculated data - Public Sub AddToErg(ByVal EnumID As tCompCali, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesC.ContainsKey(EnumID) Then - ErgEntriesC.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListC.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for calculated data - Public Sub AddToErg(ByVal EnumID As tCompErg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesR.ContainsKey(EnumID) Then - ErgEntriesR.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListR.Add(EnumID) - End If - End Sub - - ' Generate the output sequence for regression calculated data - Public Sub AddToErg(ByVal EnumID As tCompErgReg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) - If Not ErgEntriesReg.ContainsKey(EnumID) Then - ErgEntriesReg.Add(EnumID, New CResult(Head, Unit, Dic)) - ErgEntryListReg.Add(EnumID) - End If - End Sub - - ' Generate the head output string - Public Function ErgHead(ByVal Dic As String) As String - Dim s As New System.Text.StringBuilder - Dim key As String - Dim First As Boolean - - First = True - If Dic = "InputData" Then - For Each key In ErgEntryListI - If Not First Then s.Append(",") - s.Append(ErgEntriesI(key).Head) - First = False - Next - ElseIf Dic = "InputUndefData" Then - For Each key In ErgEntryListIU - If Not First Then s.Append(",") - s.Append(ErgEntriesIU(key).Head) - First = False - Next - ElseIf Dic = "CalcData" Then - For Each key In ErgEntryListC - If Not First Then s.Append(",") - s.Append(ErgEntriesC(key).Head) - First = False - Next - ElseIf Dic = "ErgValues" Then - For Each key In ErgEntryListR - If Not First Then s.Append(",") - s.Append(ErgEntriesR(key).Head) - First = False - Next - ElseIf Dic = "ErgValuesUndef" Then - For Each key In ErgEntryListRU - If Not First Then s.Append(",") - s.Append(ErgEntriesRU(key).Head) - First = False - Next - ElseIf Dic = "ErgValuesReg" Then - For Each key In ErgEntryListReg - If Not First Then s.Append(",") - s.Append(ErgEntriesReg(key).Head) - First = False - Next - End If - - Return s.ToString - End Function - - ' Generate the unit output string - Public Function ErgUnits(ByVal Dic As String) As String - Dim s As New System.Text.StringBuilder - Dim First As Boolean - Dim key As String - - First = True - If Dic = "InputData" Then - For Each key In ErgEntryListI - If Not First Then s.Append(",") - s.Append(ErgEntriesI(key).Unit) - First = False - Next - ElseIf Dic = "InputUndefData" Then - For Each key In ErgEntryListIU - If Not First Then s.Append(",") - s.Append(ErgEntriesIU(key).Unit) - First = False - Next - ElseIf Dic = "CalcData" Then - For Each key In ErgEntryListC - If Not First Then s.Append(",") - s.Append(ErgEntriesC(key).Unit) - First = False - Next - ElseIf Dic = "ErgValues" Then - For Each key In ErgEntryListR - If Not First Then s.Append(",") - s.Append(ErgEntriesR(key).Unit) - First = False - Next - ElseIf Dic = "ErgValuesUndef" Then - For Each key In ErgEntryListRU - If Not First Then s.Append(",") - s.Append(ErgEntriesRU(key).Unit) - First = False - Next - ElseIf Dic = "ErgValuesReg" Then - For Each key In ErgEntryListReg - If Not First Then s.Append(",") - s.Append(ErgEntriesReg(key).Unit) - First = False - Next - End If - - Return s.ToString - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tCompCali, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of tCompCali, List(Of Double)) - Dim KV As KeyValuePair(Of tCompCali, List(Of Double)) - Dim KVd As KeyValuePair(Of tCompCali, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of tCompCali, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = ValuesX(tCompCali.t) - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(tCompCali.t).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of tCompCali, List(Of Double)) - Summe = New Dictionary(Of tCompCali, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - If KV.Key <> tCompCali.t Then Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(tCompCali.t).Count - 1 - tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'Conclude Second - NewValues(tCompCali.t).Add(tMid) - - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tCompCali.t Then Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - If KV.Key <> tCompCali.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tComp, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of tComp, List(Of Double)) - Dim KV As KeyValuePair(Of tComp, List(Of Double)) - Dim KVd As KeyValuePair(Of tComp, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of tComp, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = ValuesX(tComp.t) - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(tComp.t).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of tComp, List(Of Double)) - Summe = New Dictionary(Of tComp, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - If KV.Key <> tComp.t Then Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(tComp.t).Count - 1 - tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'Conclude Second - NewValues(tComp.t).Add(tMid) - - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - If KV.Key <> tComp.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function - - ' Convert the data to 1Hz - Public Function ConvTo1Hz(ByVal TimesX As List(Of Double), ByRef ValuesX As Dictionary(Of String, List(Of Double))) As Boolean - ' Declaration - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer - Dim Time As Double - Dim tEnd, tIns As Double - Dim Finish, Sprung As Boolean - Dim NewValues As Dictionary(Of String, List(Of Double)) - Dim KV As KeyValuePair(Of String, List(Of Double)) - Dim KVd As KeyValuePair(Of String, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of String, Double) - - ' Initialise - Sprung = False - tI = 0 - fTime = TimesX - - 'Check whether Time is not reversed - For z = 1 To ValuesX.Item(ValuesX.First.Key).Count - 1 - If fTime(z) < fTime(z - 1) Then - If Sprung Then - fInfWarErrBW(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") - Return False - Else - Sprung = True - tI = z - End If - End If - Next z - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - If Sprung Then tIns = fTime(tI - 1) - tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of String, List(Of Double)) - Summe = New Dictionary(Of String, Double) - - ' Generate the dictionary folder - For Each KV In ValuesX - NewValues.Add(KV.Key, New List(Of Double)) - Summe.Add(KV.Key, 0) - Next - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - ' Initialise - Anz = 0 - Finish = False - If Sprung Then - laufE = 2 - Else - laufE = 1 - End If - - For lauf = 1 To laufE - ' Set the time range (If a jump is detected to the calculation till the jump) - If Sprung And lauf = 1 Then - tEnd = tIns - zEnd = tI - 1 - pos = 0 - Else - pos = tI - zEnd = ValuesX.Item(ValuesX.First.Key).Count - 1 - tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) - - If Sprung Then - ' Initialise - Anz = 0 - Finish = False - - 'Start-values - tMin = fTime(pos) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(pos) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - 'New Sum /Num no start - For Each KV In ValuesX - Summe(KV.Key) = 0 - Next - End If - End If - - For z = pos To zEnd - 'Next Time-step - Time = fTime(z) - - 'If Time-step > tMax: - Do While (Time >= tMax Or z = zEnd) - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) - Next - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) - Next - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) - Next - End If - - Else - - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next - End If - End If - End If - - If Not Finish Then - - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - - 'Check whether last second - If tMax > tEnd Then - tMax = tEnd - Finish = True - End If - - 'New Sum /Num no start - For Each KV In ValuesX - Summe(KV.Key) = 0 - Next - Anz = 0 - End If - - ' Exit while after the last calculation - If Finish And z = zEnd Then - Exit Do - End If - Loop - - For Each KV In ValuesX - Summe(KV.Key) += ValuesX(KV.Key)(z) - Next - - Anz = Anz + 1 - Next z - Next lauf - - 'Accept New fields - ValuesX = NewValues - - Return True - End Function -End Module diff --git a/CSE/GUI/CSE_Config.vb b/CSE/GUI/CSE_Config.vb deleted file mode 100644 index 00d290ee8f98adb2d7e767c317f236c1ea8093ce..0000000000000000000000000000000000000000 --- a/CSE/GUI/CSE_Config.vb +++ /dev/null @@ -1,128 +0,0 @@ -Public Class CSE_Config - - ' Load confic - Private Sub F03_Options_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load - ' Allocate the data from the confic file (Only by the start) - settings_PopulateFrom(AppSettings) - - ' Define the Infolable - TextBoxMSG_TextChanged(sender, e) - End Sub - - Private Sub settings_PopulateFrom(ByVal value As cSettings) - ' Allocate the data from the confic file (Only by the start) - Me.TextBoxWorDir.Text = value.WorkingDir - Me.TextBoxNotepad.Text = value.Editor - Me.CheckBoxWriteLog.Checked = value.WriteLog - Me.TextBoxMSG.Text = value.LogLevel - Me.TextBoxLogSize.Text = value.LogSize - End Sub - - Private Function settings_PopulateTo() As cSettings - Dim value = New cSettings() - value.Validate() - - value.WorkingDir = Me.TextBoxWorDir.Text - value.Editor = Me.TextBoxNotepad.Text - value.WriteLog = Me.CheckBoxWriteLog.Checked - value.LogLevel = Me.TextBoxMSG.Text - value.LogSize = Me.TextBoxLogSize.Text - - Return value - End Function - - ' Open the filebrowser for selecting the working dir - Private Sub ButtonWorDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectWorDir.Click - If fbWorkDir.OpenDialog(Me.TextBoxWorDir.Text) Then - Me.TextBoxWorDir.Text = fbWorkDir.Files(0) - End If - End Sub - - ' Ok button - Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click - Dim settings_fpath As String = cSettings.SettingsPath() - - ' Write new settings only if settings have changed. - ' - Dim newSettings = settings_PopulateTo() - If (Not AppSettings.Equals(newSettings) Or Not System.IO.File.Exists(settings_fpath)) Then - ' Write the config file - Try - newSettings.Store(settings_fpath) ' Also create 'config' dir if not exists - AppSettings = newSettings - - ' Message for the restart of VECTO - RestartN = True - fInfWarErr(7, False, "Settings changed. Please restart to use the new Settings!") ' XXX: Why double-log for restartng-vecto here?? - fInfWarErr(7, True, format("Settings changed. Please restart to use the new Settings!\n Do you want to restart VECTO now?")) - - Catch ex As Exception - fInfWarErr(9, False, format("Failed storing Settings({0}) due to: {1} \n Settings left unmodified!", settings_fpath, ex.Message)) - End Try - End If - - ' Close the window - Me.Close() - End Sub - - ' Close button - Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCancel.Click - Me.Close() - End Sub - - ' Select the Notepad path - Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectNotepad.Click - If fbExe.OpenDialog(Me.TextBoxWorDir.Text) Then - Me.TextBoxNotepad.Text = fbExe.Files(0) - End If - End Sub - - ' Interception from kyepress events in the MSG box - Private Sub TextBoxMSG_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBoxMSG.KeyPress - Select Case Asc(e.KeyChar) - Case 48 To 56, 8 ' Numbers from 1 till 8 allowed (ASCII) - Case Else ' Eliminate all other inputs - e.Handled = True - End Select - End Sub - - ' 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 TextBoxMSG.Leave - If Me.TextBoxMSG.Text = Nothing Then Me.TextBoxMSG.Text = 5 - End Sub - - ' Changes in the MSG --> Change the lable - Private Sub TextBoxMSG_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxMSG.TextChanged - Select Case Me.TextBoxMSG.Text - Case 0 To 2 ' Show all - Me.LabelInfo.Text = "All" - Case 3 ' No infos with priority 5 (*) - Me.LabelInfo.Text = "No Infos with priority 5 (+)" - Case 4 ' No infos with priority 4 (*) - Me.LabelInfo.Text = "No Infos with priority 4 (~)" - Case 5 ' No infos with priority 3 (*) - Me.LabelInfo.Text = "No Infos with priority 3 (*)" - Case 6 ' No infos with priority 2 (-) - Me.LabelInfo.Text = "No Infos with priority 2 (-)" - Case 7 ' No infos - Me.LabelInfo.Text = "No Infos" - Case Else ' No warnings / infos - Me.LabelInfo.Text = "No Warnings / Infos" - End Select - End Sub - - ' Changes in the LogSizeBox - Private Sub TextBoxLogSize_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBoxLogSize.KeyPress - Select Case Asc(e.KeyChar) - Case 48 To 58, 8 ' Numbers allowed (ASCII) - Case Else ' Eliminate all other input data - e.Handled = True - End Select - End Sub - - ' 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 TextBoxLogSize.Leave - If Me.TextBoxLogSize.Text = Nothing Then Me.TextBoxLogSize.Text = 2 - End Sub -End Class - diff --git a/CSE/GUI/Export_GUI.vb b/CSE/GUI/Export_GUI.vb index 047436e660cedf22bd0796dc6e11b7a9e46440bc..cff16a41ea93efc7c13ba22d440d7acc50cb1b47 100644 --- a/CSE/GUI/Export_GUI.vb +++ b/CSE/GUI/Export_GUI.vb @@ -7,8 +7,8 @@ Dim Jobname As String - If fEXT(JobFile) <> "csjob" Then - Jobname = fPath(JobFile) & "\" & fName(JobFile, False) & ".csjob" + If fEXT(JobFile) <> ".csjob" Then + Jobname = joinPaths(fPath(JobFile), fName(JobFile, False) & ".csjob") Else Jobname = JobFile End If @@ -99,60 +99,4 @@ Return True End Function - - ' Generation or upgrade from the log file - Function fWriteLog(ByVal BegHinEnd As Integer, Optional ByVal InfWarErrEls As Integer = 4, Optional ByVal text As String = "") As Boolean - ' Style 1 ... Write beginning - ' Style 2 ... Add - ' Style 3 ... Write end - - ' Write AppSettings.WriteLog only it is necessary - If AppSettings.WriteLog Then - - ' Declaration - Dim LogFilenam As String = MyPath & "Log.txt" - - ' Decision where should be write - Select Case BegHinEnd - Case 1 ' At the beginning of VECTO - Dim fInf As New System.IO.FileInfo(LogFilenam) - If IO.File.Exists(LogFilenam) Then - If fInf.Length > AppSettings.LogSize * Math.Pow(10, 6) Then - fLoeschZeilen(LogFilenam, System.IO.File.ReadAllLines(LogFilenam).Length / 2) - End If - FileOutLog.OpenWrite(LogFilenam, , True) - Else - FileOutLog.OpenWrite(LogFilenam) - End If - FileOutLog.WriteLine("-----") - - ' Write the start time into the AppSettings.WriteLog - FileOutLog.WriteLine("Starting Session " & CDate(DateAndTime.Now)) - FileOutLog.WriteLine(AppName & " " & AppVers) - FileOutLog.Close() - - Case 2 ' Add a message to the AppSettings.WriteLog - FileOutLog.OpenWrite(LogFilenam, , True) - Select Case InfWarErrEls - Case 1 ' Info - FileOutLog.WriteLine("INFO | " & text) - Case 2 ' Warning - FileOutLog.WriteLine("WARNING | " & text) - Case 3 ' Error - FileOutLog.WriteLine("ERROR | " & text) - Case 4 ' Else - FileOutLog.WriteLine(text) - End Select - FileOutLog.Close() - Case 3 ' At the end - FileOutLog.OpenWrite(LogFilenam, , True) - ' Write the end to the AppSettings.WriteLog - FileOutLog.WriteLine("Closing Session " & CDate(DateAndTime.Now)) - FileOutLog.WriteLine("-----") - FileOutLog.Close() - End Select - End If - - Return True - End Function End Module diff --git a/CSE/GUI/FB_Dialog.vb b/CSE/GUI/FB_Dialog.vb index 2ac7f2c9b0426cc8402db67f1898b210c126e351..3609793beca97bae302a7bbcded31e5ef0807f31 100644 --- a/CSE/GUI/FB_Dialog.vb +++ b/CSE/GUI/FB_Dialog.vb @@ -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(AppSettings.WorkingDir) + SetFolder(AppPreferences.workingDir) End Sub 'ButtonDesktop_Click diff --git a/CSE/GUI/CSE_Info.Designer.vb b/CSE/GUI/F_About.Designer.vb similarity index 99% rename from CSE/GUI/CSE_Info.Designer.vb rename to CSE/GUI/F_About.Designer.vb index 62f19cc7bb6315116d9ca3910ab4c0e5a678242a..f9c2dd250da57fe55918056d7f08d4ba84beb562 100644 --- a/CSE/GUI/CSE_Info.Designer.vb +++ b/CSE/GUI/F_About.Designer.vb @@ -1,5 +1,5 @@ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ -Partial Class CSE_Info +Partial Class F_About Inherits System.Windows.Forms.Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. @@ -22,7 +22,7 @@ Partial Class CSE_Info 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() - Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CSE_Info)) + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(F_About)) Me.Label1 = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() @@ -252,7 +252,7 @@ Partial Class CSE_Info Me.Label13.TabIndex = 20 Me.Label13.Text = "Copyright: 2014 European Union" ' - 'CSE_Info + 'F_Info ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font @@ -282,7 +282,7 @@ Partial Class CSE_Info Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximumSize = New System.Drawing.Size(480, 591) Me.MinimumSize = New System.Drawing.Size(480, 591) - Me.Name = "CSE_Info" + Me.Name = "F_Info" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "About CSE" CType(Me.PictureBoxJRC, System.ComponentModel.ISupportInitialize).EndInit() diff --git a/CSE/GUI/CSE_Config.resx b/CSE/GUI/F_About.resx similarity index 100% rename from CSE/GUI/CSE_Config.resx rename to CSE/GUI/F_About.resx diff --git a/CSE/GUI/CSE_Info.vb b/CSE/GUI/F_About.vb similarity index 73% rename from CSE/GUI/CSE_Info.vb rename to CSE/GUI/F_About.vb index 450d49b756415ee90ef63808acb2c1ba7937fd2f..c1b57dc3c95332e7d0af7272d8b0f30e9c20f45f 100644 --- a/CSE/GUI/CSE_Info.vb +++ b/CSE/GUI/F_About.vb @@ -1,4 +1,4 @@ -Public Class CSE_Info +Public Class F_About 'Initialisation @@ -11,15 +11,15 @@ Public Class CSE_Info System.Diagnostics.Process.Start("mailto:rexeis@ivt.tugraz.at") End Sub - Private Sub LinkJRC1_LinkClicked(sender As Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) + Private Sub LinkJRC1_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) System.Diagnostics.Process.Start("mailto:georgios.fontaras@jrc.ec.europa.eu") End Sub - Private Sub LinkJRC2_LinkClicked(sender As Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) + Private Sub LinkJRC2_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) System.Diagnostics.Process.Start("mailto:panagiota.dilara@jrc.ec.europa.eu") End Sub '---------------------------------------------------------------------------- - Private Sub LinkLicensed_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLicensed.LinkClicked + Private Sub LinkLicensed_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLicensed.LinkClicked System.Diagnostics.Process.Start("https://joinup.ec.europa.eu/software/page/eupl") End Sub @@ -31,7 +31,7 @@ Public Class CSE_Info System.Diagnostics.Process.Start("http://www.tugraz.at/") End Sub '---------------------------------------------------------------------------- - Private Sub PictureBoxJRC_Click(sender As System.Object, e As System.EventArgs) Handles PictureBoxJRC.Click + Private Sub PictureBoxJRC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxJRC.Click System.Diagnostics.Process.Start("http://ec.europa.eu/dgs/jrc/index.cfm") End Sub End Class \ No newline at end of file diff --git a/CSE/GUI/CSEMain.Designer.vb b/CSE/GUI/F_Main.Designer.vb similarity index 99% rename from CSE/GUI/CSEMain.Designer.vb rename to CSE/GUI/F_Main.Designer.vb index 43d7e293ca772f37df2aa35a0749d8022e42cf04..2cee62b6f48fb6ed707c98bf4eec05fe7d871b6c 100644 --- a/CSE/GUI/CSEMain.Designer.vb +++ b/CSE/GUI/F_Main.Designer.vb @@ -1,5 +1,5 @@ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ -Partial Class CSEMain +Partial Class F_Main Inherits System.Windows.Forms.Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. @@ -22,7 +22,7 @@ Partial Class CSEMain 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() - Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CSEMain)) + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(F_Main)) Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() Me.DataToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripMenuItemNew = New System.Windows.Forms.ToolStripMenuItem() @@ -348,7 +348,7 @@ Partial Class CSEMain Me.ToolStripMenuItemOption.Image = Global.CSE.My.Resources.Resources.Optionen Me.ToolStripMenuItemOption.Name = "ToolStripMenuItemOption" Me.ToolStripMenuItemOption.Size = New System.Drawing.Size(144, 22) - Me.ToolStripMenuItemOption.Text = "Options" + Me.ToolStripMenuItemOption.Text = "Preferences" ' 'InfoToolStripMenuItem ' @@ -2409,7 +2409,7 @@ Partial Class CSEMain Me.TBDeltaXMax.Text = "10" Me.TBDeltaXMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' - 'CSEMain + 'F_Main ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font @@ -2419,10 +2419,12 @@ Partial Class CSEMain Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.PictureBox1) Me.Controls.Add(Me.MenuStrip1) + Me.DataBindings.Add(New System.Windows.Forms.Binding("Location", Global.CSE.My.MySettings.Default, "F_Main_location", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) + Me.Location = Global.CSE.My.MySettings.Default.F_Main_location Me.MainMenuStrip = Me.MenuStrip1 Me.MinimumSize = New System.Drawing.Size(686, 717) - Me.Name = "CSEMain" + Me.Name = "F_Main" Me.Text = "VECTO Constant Speed Evaluator" Me.MenuStrip1.ResumeLayout(False) Me.MenuStrip1.PerformLayout() diff --git a/CSE/GUI/CSEMain.resx b/CSE/GUI/F_Main.resx similarity index 100% rename from CSE/GUI/CSEMain.resx rename to CSE/GUI/F_Main.resx diff --git a/CSE/GUI/CSEMain.vb b/CSE/GUI/F_Main.vb similarity index 88% rename from CSE/GUI/CSEMain.vb rename to CSE/GUI/F_Main.vb index 82ff8719dc012f212a59290fa83e592fce806bf9..7a11dc96d6fb6d7de44c27e277e2330877d84b7e 100644 --- a/CSE/GUI/CSEMain.vb +++ b/CSE/GUI/F_Main.vb @@ -1,6 +1,6 @@ Imports System.IO -Public Class CSEMain +Public Class F_Main ' Declarations Private ToolstripSave As Boolean = False Private ToolstripSaveAs As Boolean = False @@ -9,7 +9,7 @@ Public Class CSEMain Private Cali As Boolean = True ' Load the GUI - Private Sub CSEMain_Load(sender As System.Object, e As System.EventArgs) Handles Me.Load + Private Sub CSEMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load ' Declarations Dim configL As Boolean = True Dim NoLegFile As Boolean = False @@ -25,15 +25,17 @@ Public Class CSEMain ' Name of the GUI Me.Text = AppName & " " & AppVers + ' Write the beginning in the Log + fWriteLog(1) + ' Load the config file ' - Dim settings_fpath = cSettings.SettingsPath() Try - Dim fileSettings As New cSettings(settings_fpath) - fileSettings.Validate() - AppSettings = fileSettings + AppPreferences = New cPreferences(PreferencesPath) Catch ex As Exception - fInfWarErr(9, False, format("Failed loading Settings({0}) due to: {1}", settings_fpath, ex.Message)) + fInfWarErr(9, False, format(<str>Failed loading Preferences({0}) due to: {1} +\iThis is normal the first time you launch the application.</str>, _ + PreferencesPath, ex.Message), ex) configL = False End Try @@ -44,13 +46,10 @@ Public Class CSEMain ' Polling if the working dir exist (If not then generate the folder) ' - If Not IO.Directory.Exists(AppSettings.WorkingDir) Then - IO.Directory.CreateDirectory(AppSettings.WorkingDir) + If Not IO.Directory.Exists(AppPreferences.workingDir) Then + IO.Directory.CreateDirectory(AppPreferences.workingDir) End If - ' Write the beginning in the AppSettings.WriteLog - fWriteLog(1) - 'Lizenz checken If Not Lic.LICcheck() Then fInfWarErr(9, True, Lic.FailMsg) @@ -58,13 +57,13 @@ Public Class CSEMain Me.Close() End If - ' Write a defailt config file if failed to read one. + ' Write a defult config file if failed to read one. If Not configL Then Try - AppSettings.Store(settings_fpath) - fInfWarErr(7, False, format("Created Settings({0}).", settings_fpath)) + AppPreferences.Store(PreferencesPath) + fInfWarErr(7, False, format("Stored new Preferences({0}).", PreferencesPath)) Catch ex As Exception - fInfWarErr(9, False, format("Failed storing Settings({0}) due to: {1}", settings_fpath, ex.Message)) + fInfWarErr(9, False, format("Failed storing Preferences({0}) due to: {1}", PreferencesPath, ex.Message), ex) End Try End If End Sub @@ -73,14 +72,14 @@ Public Class CSEMain #Region "Main" ' Close the GUI Private Sub CSEMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed - ' Write the end into the AppSettings.WriteLog + ' Write the end into the Log fWriteLog(3) End Sub ' 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(AppSettings.WorkingDir, False) Then + If fbVEH.OpenDialog(AppPreferences.workingDir, False) Then If (fbVEH.Files(0) <> Nothing) Then Me.TextBoxVeh1.Text = fbVEH.Files(0) End If @@ -90,16 +89,16 @@ Public Class CSEMain ' 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(AppSettings.Editor, Me.TextBoxVeh1.Text) + System.Diagnostics.Process.Start(AppPreferences.editor, Me.TextBoxVeh1.Text) Else - If Not fInfWarErr(9, True, "No such Inputfile: " & Me.TextBoxVeh1.Text) Then Exit Sub + fInfWarErr(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(AppSettings.WorkingDir, False) Then + If fbAMB.OpenDialog(AppPreferences.workingDir, False) Then If (fbAMB.Files(0) <> Nothing) Then Me.TextBoxWeather.Text = fbAMB.Files(0) End If @@ -109,9 +108,9 @@ Public Class CSEMain ' 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(AppSettings.Editor, Me.TextBoxWeather.Text) + System.Diagnostics.Process.Start(AppPreferences.editor, Me.TextBoxWeather.Text) Else - If Not fInfWarErr(9, True, "No such Inputfile: " & Me.TextBoxWeather.Text) Then Exit Sub + fInfWarErr(9, True, "No such Inputfile: " & Me.TextBoxWeather.Text) End If End Sub @@ -131,7 +130,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataC.Text = fbVEL.Files(0) End If @@ -155,7 +154,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbMSC.OpenDialog(AppPreferences.workingDir, False) Then If (fbMSC.Files(0) <> Nothing) Then Me.TextBoxMSCC.Text = fbMSC.Files(0) End If @@ -194,7 +193,7 @@ Public Class CSEMain ' Read the data from the GUI If Not fGetOpt(True, Cali) Then - Me.ButtonCalC.Text = "Calculate" + Me.ButtonCalC.Text = "Calibrate" Exit Sub End If @@ -206,16 +205,16 @@ Public Class CSEMain If OutFolder <> Nothing Then ' Generate the folder if it is desired Dim resEx As MsgBoxResult - resEx = MsgBox("Output folder doesn´t exist! Create Folder?", MsgBoxStyle.YesNo, "Create folder?") + resEx = MsgBox(format("Output-folder({0}) doesn´t exist! \n\nCreate Folder?", OutFolder), MsgBoxStyle.YesNo, "Create folder?") If resEx = MsgBoxResult.Yes Then MkDir(OutFolder) Else - Me.ButtonCalC.Text = "Calculate" + Me.ButtonCalC.Text = "Calibrate" Exit Sub End If Else fInfWarErr(9, False, "No outputfolder is given!") - Me.ButtonCalC.Text = "Calculate" + Me.ButtonCalC.Text = "Calibrate" Exit Sub End If End If @@ -224,9 +223,7 @@ Public Class CSEMain Me.ListBoxMSG.Items.Clear() fClear_VECTO_Form(False, False) - ' Write the Calculation status in the Messageoutput and in the AppSettings.WriteLog - fInfWarErr(7, False, "Starting VECTO CSE calibration calculation...") - If AppSettings.WriteLog Then fWriteLog(2, 4, "------------- Job: " & JobFile & " | Out: " & OutFolder & " | " & CDate(DateAndTime.Now) & "-------------") + fInfWarErr(7, False, format("Starting CALIBRATION: \n\i* Job: {0}\n* Out: {1}", JobFile, OutFolder)) ' Start the calculation in the backgroundworker Me.BackgroundWorkerVECTO.RunWorkerAsync() @@ -238,7 +235,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbMSC.OpenDialog(AppPreferences.workingDir, False) Then If (fbMSC.Files(0) <> Nothing) Then Me.TextBoxMSCT.Text = fbMSC.Files(0) End If @@ -262,7 +259,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataLS1.Text = fbVEL.Files(0) End If @@ -286,7 +283,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataHS.Text = fbVEL.Files(0) End If @@ -310,7 +307,7 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbVEL.OpenDialog(AppPreferences.workingDir, False) Then If (fbVEL.Files(0) <> Nothing) Then Me.TextBoxDataLS2.Text = fbVEL.Files(0) End If @@ -344,8 +341,7 @@ Public Class CSEMain Me.ButtonEval.Text = "Cancel" Cali = False - ' Add into the AppSettings.WriteLog - If AppSettings.WriteLog Then fWriteLog(2, 4, "----- Speed runs ") + fWriteLog(2, 4, "----- Speed runs ") ' Read the data from the GUI If Not fGetOpt(True, Cali) Then @@ -361,7 +357,7 @@ Public Class CSEMain If OutFolder <> Nothing Then ' Generate the folder if it is desired Dim resEx As MsgBoxResult - resEx = MsgBox("Output folder doesn´t exist! Create Folder?", MsgBoxStyle.YesNo, "Create folder?") + resEx = MsgBox(format("Output-folder({0}) doesn´t exist! \n\nCreate Folder?", OutFolder), MsgBoxStyle.YesNo, "Create folder?") If resEx = MsgBoxResult.Yes Then MkDir(OutFolder) Else @@ -378,8 +374,8 @@ Public Class CSEMain ' Clear the MSG on the GUI fClear_VECTO_Form(False, False) - ' Write the Calculation status in the Messageoutput and in the AppSettings.WriteLog - fInfWarErr(7, False, "Starting VECTO CSE test evaluation...") + ' 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)) ' Start the calculation in the backgroundworker Me.BackgroundWorkerVECTO.RunWorkerAsync() @@ -397,15 +393,15 @@ Public Class CSEMain ' 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(AppSettings.WorkingDir, False) Then + If fbVECTO.OpenDialog(AppPreferences.workingDir, False) Then JobFile = fbVECTO.Files(0) If (JobFile <> Nothing) Then ' Clear the GUI fClear_VECTO_Form(False) - OutFolder = fPath(JobFile) & "\Results\" + OutFolder = joinPaths(fPath(JobFile), "Results\") ' Identify the given Jobfile - If fEXT(JobFile) <> "txt" And fEXT(JobFile) <> "csjob" Then + If fEXT(JobFile) <> ".txt" And fEXT(JobFile) <> ".csjob" Then fInfWarErr(8, False, "The Inputfile is not a regular VECTO-File: " & JobFile) Else ' Read the Jobfile and insert the data in the GUI @@ -422,7 +418,7 @@ Public Class CSEMain ' Open the filebrowser to select the folder and name of the Jobfile If fbVECTO.SaveDialog(JobFile) Then JobFile = fbVECTO.Files(0) - OutFolder = fPath(JobFile) & "\Results\" + OutFolder = joinPaths(fPath(JobFile), "Results\") Me.Text = Formname & " " & JobFile End If If (JobFile = Nothing) Then @@ -457,15 +453,15 @@ Public Class CSEMain #End Region #Region "Tools" - ' Menu open the AppSettings.WriteLog + ' 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(AppSettings.Editor, MyPath & "Log.txt") + System.Diagnostics.Process.Start(AppPreferences.editor, joinPaths(MyPath, "log.txt")) End Sub ' Menu open the config file Private Sub ToolStripMenuItemOption_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemOption.Click ' Show the confic GUI - CSE_Config.Show() + F_Preferences.Show() End Sub #End Region @@ -473,14 +469,13 @@ Public Class CSEMain ' 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, False, "Activation code created under: " & MyPath & "ActivationCode.dat") fInfWarErr(7, True, "Activation code created under: " & MyPath & "ActivationCode.dat") End Sub ' Menu open the Infobox Private Sub ToolStripMenuItemAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAbout.Click ' Show the info GUI - CSE_Info.Show() + F_About.Show() End Sub ' Menu open the user manual @@ -489,7 +484,7 @@ Public Class CSEMain Try System.Diagnostics.Process.Start(manual_fname) Catch ex As Exception - fInfWarErr(9, False, format("Failed opening User Manual({0}) due to: {1}", manual_fname, ex.Message)) + fInfWarErr(9, False, format("Failed opening User Manual({0}) due to: {1}", manual_fname, ex.Message), ex) End Try End Sub #End Region @@ -565,12 +560,16 @@ Public Class CSEMain '*********Backgroundworker********* ' Backgroundworker for the calculation in the background - Private Sub BackgroundWorkerVECTO_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorkerVECTO.DoWork + Private Sub BackgroundWorkerVECTO_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) _ + Handles BackgroundWorkerVECTO.DoWork '##### START THE CALCULATION ##### '################################# - - calculation(Cali) + Try + calculation(Cali) + Catch ex As Exception + fInfWarErr(9, False, format("Calculation Failed due to: {0}", ex.Message), ex) + End Try '################################# @@ -581,44 +580,40 @@ Public Class CSEMain End Sub ' Output from messages with the Backgroundworker - Private Sub BackgroundWorkerVECTO_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorkerVECTO.ProgressChanged - ' Declarations - Dim WorkerMsg As CMsg - WorkerMsg = New CMsg - - ' Identify the Message - WorkerMsg = e.UserState - - If e.UserState Is Nothing Then + Private Sub BackgroundWorkerVECTO_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) _ + Handles BackgroundWorkerVECTO.ProgressChanged - Else - ' Call the function for the depiction from the message on the GUI - MsgToForm(WorkerMsg.Styletext, WorkerMsg.Style, WorkerMsg.Text) + Dim workerMsg As cLogMsg = e.UserState + If workerMsg IsNot Nothing Then + workerMsg.forwardLog() End If End Sub ' Identify the ending from the backgroundworker - Private Sub BackgroundWorkerVECTO_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorkerVECTO.RunWorkerCompleted + Private Sub BackgroundWorkerVECTO_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _ + Handles BackgroundWorkerVECTO.RunWorkerCompleted + + Dim op = IIf(Cali, "Calibration", "Evaluation") + ' If an Error is detected If e.Error IsNot Nothing Then - fInfWarErr(7, False, "End with Error") - MsgBox(e.Error.Message) + fInfWarErr(8, True, format("{0} ended with exception: {1}", op, e.Error), e.Error) Else If e.Cancelled Then If ErrorExit Then - fInfWarErr(7, False, "End with Error") + fInfWarErr(8, False, format("{0} ended with exception: {1}", op, e.Error), e.Error) Else - fInfWarErr(7, False, "Aborted by user") + fInfWarErr(7, False, format("{0} aborted by user.", op)) End If Else - fInfWarErr(7, False, "Done") + fInfWarErr(7, False, format("{0} ended OK.", op)) If Cali Then Me.ButtonEval.Enabled = True End If End If ' Reset the calculate button to calculate If Cali Then - Me.ButtonCalC.Text = "Calculate" + Me.ButtonCalC.Text = "Calibrate" Me.TextBoxRVeh.Text = Math.Round(fv_veh, 3).ToString Me.TextBoxRAirPos.Text = Math.Round(fv_pe, 3).ToString Me.TextBoxRBetaMis.Text = Math.Round(beta_ame, 2).ToString diff --git a/CSE/GUI/CSE_Config.designer.vb b/CSE/GUI/F_Preferences.designer.vb similarity index 55% rename from CSE/GUI/CSE_Config.designer.vb rename to CSE/GUI/F_Preferences.designer.vb index 073be3d3f19f27cf45b27813ba123d0163f9786f..1a189193bf7ab6206c33314c493adc16785d71da 100644 --- a/CSE/GUI/CSE_Config.designer.vb +++ b/CSE/GUI/F_Preferences.designer.vb @@ -1,5 +1,5 @@ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ -Partial Class CSE_Config +Partial Class F_Preferences Inherits System.Windows.Forms.Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. @@ -22,37 +22,45 @@ Partial Class CSE_Config 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() - Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CSE_Config)) - Me.TextBoxWorDir = New System.Windows.Forms.TextBox() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(F_Preferences)) + Me.workingDir = New System.Windows.Forms.TextBox() Me.ButtonSelectWorDir = New System.Windows.Forms.Button() Me.GroupBoxWorDir = New System.Windows.Forms.GroupBox() Me.ButtonOK = New System.Windows.Forms.Button() Me.ButtonCancel = New System.Windows.Forms.Button() - Me.CheckBoxWriteLog = New System.Windows.Forms.CheckBox() + Me.writeLog = New System.Windows.Forms.CheckBox() Me.GroupBoxInterface = New System.Windows.Forms.GroupBox() Me.LabelInfo = New System.Windows.Forms.Label() - Me.TextBoxLogSize = New System.Windows.Forms.TextBox() + Me.logSize = New System.Windows.Forms.TextBox() Me.Label16 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label() - Me.TextBoxMSG = New System.Windows.Forms.TextBox() + Me.logLevel = New System.Windows.Forms.TextBox() Me.TabControl1 = New System.Windows.Forms.TabControl() Me.TabPage2 = New System.Windows.Forms.TabPage() Me.GroupBoxNotepad = New System.Windows.Forms.GroupBox() Me.ButtonSelectNotepad = New System.Windows.Forms.Button() - Me.TextBoxNotepad = New System.Windows.Forms.TextBox() + Me.editor = New System.Windows.Forms.TextBox() + Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.strictBodies = New System.Windows.Forms.CheckBox() + Me.includeSchemas = New System.Windows.Forms.CheckBox() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.Label3 = New System.Windows.Forms.Label() + Me.CheckBox1 = New System.Windows.Forms.CheckBox() + Me.ButtonReload = New System.Windows.Forms.Button() Me.GroupBoxWorDir.SuspendLayout() Me.GroupBoxInterface.SuspendLayout() Me.TabControl1.SuspendLayout() Me.TabPage2.SuspendLayout() Me.GroupBoxNotepad.SuspendLayout() + Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' - 'TextBoxWorDir + 'workingDir ' - Me.TextBoxWorDir.Location = New System.Drawing.Point(6, 19) - Me.TextBoxWorDir.Name = "TextBoxWorDir" - Me.TextBoxWorDir.Size = New System.Drawing.Size(444, 20) - Me.TextBoxWorDir.TabIndex = 1 + Me.workingDir.Location = New System.Drawing.Point(6, 19) + Me.workingDir.Name = "workingDir" + Me.workingDir.Size = New System.Drawing.Size(444, 20) + Me.workingDir.TabIndex = 1 ' 'ButtonSelectWorDir ' @@ -67,18 +75,19 @@ Partial Class CSE_Config 'GroupBoxWorDir ' Me.GroupBoxWorDir.Controls.Add(Me.ButtonSelectWorDir) - Me.GroupBoxWorDir.Controls.Add(Me.TextBoxWorDir) + Me.GroupBoxWorDir.Controls.Add(Me.workingDir) Me.GroupBoxWorDir.Location = New System.Drawing.Point(5, 6) Me.GroupBoxWorDir.Name = "GroupBoxWorDir" Me.GroupBoxWorDir.Size = New System.Drawing.Size(490, 51) Me.GroupBoxWorDir.TabIndex = 2 Me.GroupBoxWorDir.TabStop = False - Me.GroupBoxWorDir.Text = "Standard Working Directory" + Me.GroupBoxWorDir.Text = "Working Directory" ' 'ButtonOK ' Me.ButtonOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ButtonOK.Location = New System.Drawing.Point(356, 235) + Me.ButtonOK.DialogResult = System.Windows.Forms.DialogResult.OK + Me.ButtonOK.Location = New System.Drawing.Point(436, 242) Me.ButtonOK.Name = "ButtonOK" Me.ButtonOK.Size = New System.Drawing.Size(75, 23) Me.ButtonOK.TabIndex = 0 @@ -89,78 +98,78 @@ Partial Class CSE_Config ' Me.ButtonCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.ButtonCancel.Location = New System.Drawing.Point(436, 235) + Me.ButtonCancel.Location = New System.Drawing.Point(99, 242) Me.ButtonCancel.Name = "ButtonCancel" Me.ButtonCancel.Size = New System.Drawing.Size(75, 23) Me.ButtonCancel.TabIndex = 1 Me.ButtonCancel.Text = "Cancel" Me.ButtonCancel.UseVisualStyleBackColor = True ' - 'CheckBoxWriteLog + 'writeLog ' - Me.CheckBoxWriteLog.AutoSize = True - Me.CheckBoxWriteLog.Location = New System.Drawing.Point(353, 15) - Me.CheckBoxWriteLog.Name = "CheckBoxWriteLog" - Me.CheckBoxWriteLog.Size = New System.Drawing.Size(129, 17) - Me.CheckBoxWriteLog.TabIndex = 5 - Me.CheckBoxWriteLog.Text = "Write log file (LOG.txt)" - Me.CheckBoxWriteLog.UseVisualStyleBackColor = True + Me.writeLog.AutoSize = True + Me.writeLog.Location = New System.Drawing.Point(13, 58) + Me.writeLog.Name = "writeLog" + Me.writeLog.Size = New System.Drawing.Size(108, 17) + Me.writeLog.TabIndex = 2 + Me.writeLog.Text = "Log-file Enabled?" + Me.writeLog.UseVisualStyleBackColor = True ' 'GroupBoxInterface ' Me.GroupBoxInterface.Controls.Add(Me.LabelInfo) - Me.GroupBoxInterface.Controls.Add(Me.TextBoxLogSize) + Me.GroupBoxInterface.Controls.Add(Me.logSize) Me.GroupBoxInterface.Controls.Add(Me.Label16) Me.GroupBoxInterface.Controls.Add(Me.Label1) - Me.GroupBoxInterface.Controls.Add(Me.TextBoxMSG) - Me.GroupBoxInterface.Controls.Add(Me.CheckBoxWriteLog) + Me.GroupBoxInterface.Controls.Add(Me.logLevel) + Me.GroupBoxInterface.Controls.Add(Me.writeLog) Me.GroupBoxInterface.Location = New System.Drawing.Point(5, 120) Me.GroupBoxInterface.Name = "GroupBoxInterface" - Me.GroupBoxInterface.Size = New System.Drawing.Size(490, 75) + Me.GroupBoxInterface.Size = New System.Drawing.Size(341, 84) Me.GroupBoxInterface.TabIndex = 11 Me.GroupBoxInterface.TabStop = False - Me.GroupBoxInterface.Text = "Interface" + Me.GroupBoxInterface.Text = "Logging && Messages" ' 'LabelInfo ' Me.LabelInfo.AutoSize = True - Me.LabelInfo.Location = New System.Drawing.Point(185, 22) + Me.LabelInfo.Location = New System.Drawing.Point(154, 22) Me.LabelInfo.Name = "LabelInfo" Me.LabelInfo.Size = New System.Drawing.Size(39, 13) Me.LabelInfo.TabIndex = 12 Me.LabelInfo.Text = "Label2" ' - 'TextBoxLogSize + 'logSize ' - Me.TextBoxLogSize.Location = New System.Drawing.Point(440, 38) - Me.TextBoxLogSize.Name = "TextBoxLogSize" - Me.TextBoxLogSize.Size = New System.Drawing.Size(36, 20) - Me.TextBoxLogSize.TabIndex = 11 + Me.logSize.Location = New System.Drawing.Point(299, 55) + Me.logSize.Name = "logSize" + Me.logSize.Size = New System.Drawing.Size(36, 20) + Me.logSize.TabIndex = 3 ' 'Label16 ' Me.Label16.AutoSize = True - Me.Label16.Location = New System.Drawing.Point(356, 41) + Me.Label16.Location = New System.Drawing.Point(181, 59) Me.Label16.Name = "Label16" - Me.Label16.Size = New System.Drawing.Size(78, 13) + Me.Label16.Size = New System.Drawing.Size(112, 13) Me.Label16.TabIndex = 10 - Me.Label16.Text = "Size Limit [MiB]" + Me.Label16.Text = "Log-file size limit [MiB]:" ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(27, 22) + Me.Label1.Location = New System.Drawing.Point(10, 22) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(110, 13) + Me.Label1.Size = New System.Drawing.Size(96, 13) Me.Label1.TabIndex = 7 - Me.Label1.Text = "Output Window Level" + Me.Label1.Text = "Log-window Level:" ' - 'TextBoxMSG + 'logLevel ' - Me.TextBoxMSG.Location = New System.Drawing.Point(143, 19) - Me.TextBoxMSG.Name = "TextBoxMSG" - Me.TextBoxMSG.Size = New System.Drawing.Size(36, 20) - Me.TextBoxMSG.TabIndex = 6 + Me.logLevel.Location = New System.Drawing.Point(112, 19) + Me.logLevel.Name = "logLevel" + Me.logLevel.Size = New System.Drawing.Size(36, 20) + Me.logLevel.TabIndex = 1 ' 'TabControl1 ' @@ -171,18 +180,19 @@ Partial Class CSE_Config Me.TabControl1.Location = New System.Drawing.Point(3, 3) Me.TabControl1.Name = "TabControl1" Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New System.Drawing.Size(508, 226) + Me.TabControl1.Size = New System.Drawing.Size(508, 233) Me.TabControl1.TabIndex = 12 ' 'TabPage2 ' Me.TabPage2.Controls.Add(Me.GroupBoxNotepad) Me.TabPage2.Controls.Add(Me.GroupBoxWorDir) + Me.TabPage2.Controls.Add(Me.GroupBox1) Me.TabPage2.Controls.Add(Me.GroupBoxInterface) Me.TabPage2.Location = New System.Drawing.Point(4, 22) Me.TabPage2.Name = "TabPage2" Me.TabPage2.Padding = New System.Windows.Forms.Padding(3) - Me.TabPage2.Size = New System.Drawing.Size(500, 200) + Me.TabPage2.Size = New System.Drawing.Size(500, 207) Me.TabPage2.TabIndex = 0 Me.TabPage2.Text = "General" Me.TabPage2.UseVisualStyleBackColor = True @@ -190,7 +200,7 @@ Partial Class CSE_Config 'GroupBoxNotepad ' Me.GroupBoxNotepad.Controls.Add(Me.ButtonSelectNotepad) - Me.GroupBoxNotepad.Controls.Add(Me.TextBoxNotepad) + Me.GroupBoxNotepad.Controls.Add(Me.editor) Me.GroupBoxNotepad.Location = New System.Drawing.Point(5, 63) Me.GroupBoxNotepad.Name = "GroupBoxNotepad" Me.GroupBoxNotepad.Size = New System.Drawing.Size(490, 51) @@ -208,30 +218,101 @@ Partial Class CSE_Config Me.ButtonSelectNotepad.Text = "..." Me.ButtonSelectNotepad.UseVisualStyleBackColor = True ' - 'TextBoxNotepad - ' - Me.TextBoxNotepad.Location = New System.Drawing.Point(6, 19) - Me.TextBoxNotepad.Name = "TextBoxNotepad" - Me.TextBoxNotepad.Size = New System.Drawing.Size(444, 20) - Me.TextBoxNotepad.TabIndex = 1 - ' - 'CSE_Config + 'editor + ' + Me.editor.Location = New System.Drawing.Point(6, 19) + Me.editor.Name = "editor" + Me.editor.Size = New System.Drawing.Size(444, 20) + Me.editor.TabIndex = 1 + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.strictBodies) + Me.GroupBox1.Controls.Add(Me.includeSchemas) + Me.GroupBox1.Controls.Add(Me.TextBox1) + Me.GroupBox1.Controls.Add(Me.Label3) + Me.GroupBox1.Controls.Add(Me.CheckBox1) + Me.GroupBox1.Location = New System.Drawing.Point(352, 120) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(152, 84) + Me.GroupBox1.TabIndex = 11 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "JSON" + ' + 'strictBodies + ' + Me.strictBodies.AutoSize = True + Me.strictBodies.Location = New System.Drawing.Point(6, 57) + Me.strictBodies.Name = "strictBodies" + Me.strictBodies.Size = New System.Drawing.Size(91, 17) + Me.strictBodies.TabIndex = 12 + Me.strictBodies.Text = "Strict Bodies?" + Me.strictBodies.UseVisualStyleBackColor = True + ' + 'includeSchemas + ' + Me.includeSchemas.AutoSize = True + Me.includeSchemas.Location = New System.Drawing.Point(6, 21) + Me.includeSchemas.Name = "includeSchemas" + Me.includeSchemas.Size = New System.Drawing.Size(114, 17) + Me.includeSchemas.TabIndex = 12 + Me.includeSchemas.Text = "Include Schemas?" + Me.includeSchemas.UseVisualStyleBackColor = True + ' + 'TextBox1 + ' + Me.TextBox1.Location = New System.Drawing.Point(440, 38) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(36, 20) + Me.TextBox1.TabIndex = 11 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(356, 41) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(78, 13) + Me.Label3.TabIndex = 10 + Me.Label3.Text = "Size Limit [MiB]" + ' + 'CheckBox1 + ' + Me.CheckBox1.AutoSize = True + Me.CheckBox1.Location = New System.Drawing.Point(353, 15) + Me.CheckBox1.Name = "CheckBox1" + Me.CheckBox1.Size = New System.Drawing.Size(129, 17) + Me.CheckBox1.TabIndex = 5 + Me.CheckBox1.Text = "Write log file (log.txt)" + Me.CheckBox1.UseVisualStyleBackColor = True + ' + 'ButtonReload + ' + Me.ButtonReload.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonReload.Location = New System.Drawing.Point(18, 242) + Me.ButtonReload.Name = "ButtonReload" + Me.ButtonReload.Size = New System.Drawing.Size(75, 23) + Me.ButtonReload.TabIndex = 0 + Me.ButtonReload.Text = "Reload" + Me.ButtonReload.UseVisualStyleBackColor = True + ' + 'F_Preferences ' Me.AcceptButton = Me.ButtonOK Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ButtonCancel - Me.ClientSize = New System.Drawing.Size(515, 270) + Me.ClientSize = New System.Drawing.Size(515, 277) Me.Controls.Add(Me.TabControl1) Me.Controls.Add(Me.ButtonCancel) + Me.Controls.Add(Me.ButtonReload) Me.Controls.Add(Me.ButtonOK) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.MinimizeBox = False Me.MinimumSize = New System.Drawing.Size(521, 294) - Me.Name = "CSE_Config" - Me.Text = "Settings" + Me.Name = "F_Preferences" + Me.Text = "Preferences" Me.GroupBoxWorDir.ResumeLayout(False) Me.GroupBoxWorDir.PerformLayout() Me.GroupBoxInterface.ResumeLayout(False) @@ -240,24 +321,33 @@ Partial Class CSE_Config Me.TabPage2.ResumeLayout(False) Me.GroupBoxNotepad.ResumeLayout(False) Me.GroupBoxNotepad.PerformLayout() + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) End Sub - Friend WithEvents TextBoxWorDir As System.Windows.Forms.TextBox + Friend WithEvents workingDir As System.Windows.Forms.TextBox Friend WithEvents ButtonSelectWorDir As System.Windows.Forms.Button Friend WithEvents GroupBoxWorDir As System.Windows.Forms.GroupBox Friend WithEvents ButtonOK As System.Windows.Forms.Button Friend WithEvents ButtonCancel As System.Windows.Forms.Button - Friend WithEvents CheckBoxWriteLog As System.Windows.Forms.CheckBox + Friend WithEvents writeLog As System.Windows.Forms.CheckBox Friend WithEvents GroupBoxInterface As System.Windows.Forms.GroupBox Friend WithEvents TabControl1 As System.Windows.Forms.TabControl Friend WithEvents TabPage2 As System.Windows.Forms.TabPage Friend WithEvents Label1 As System.Windows.Forms.Label - Friend WithEvents TextBoxMSG As System.Windows.Forms.TextBox - Friend WithEvents TextBoxLogSize As System.Windows.Forms.TextBox + Friend WithEvents logLevel As System.Windows.Forms.TextBox + Friend WithEvents logSize As System.Windows.Forms.TextBox Friend WithEvents Label16 As System.Windows.Forms.Label Friend WithEvents GroupBoxNotepad As System.Windows.Forms.GroupBox Friend WithEvents ButtonSelectNotepad As System.Windows.Forms.Button - Friend WithEvents TextBoxNotepad As System.Windows.Forms.TextBox + Friend WithEvents editor As System.Windows.Forms.TextBox Friend WithEvents LabelInfo As System.Windows.Forms.Label + Friend WithEvents ButtonReload As System.Windows.Forms.Button + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents TextBox1 As System.Windows.Forms.TextBox + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox + Friend WithEvents strictBodies As System.Windows.Forms.CheckBox + Friend WithEvents includeSchemas As System.Windows.Forms.CheckBox End Class diff --git a/CSE/GUI/CSE_Info.resx b/CSE/GUI/F_Preferences.resx similarity index 100% rename from CSE/GUI/CSE_Info.resx rename to CSE/GUI/F_Preferences.resx diff --git a/CSE/GUI/F_Preferences.vb b/CSE/GUI/F_Preferences.vb new file mode 100644 index 0000000000000000000000000000000000000000..f4616b9e7558b41552c7f5243b2a040ccd688fe8 --- /dev/null +++ b/CSE/GUI/F_Preferences.vb @@ -0,0 +1,150 @@ +Imports Newtonsoft.Json.Linq + +Public Class F_Preferences + + ' Load confic + Private Sub F03_Options_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Dim controlPairs As IList(Of Control()) = New List(Of Control()) + '' CONTROL LABEL + controlPairs.Add({Me.workingDir, Me.GroupBoxWorDir}) + controlPairs.Add({Me.editor, Me.GroupBoxNotepad}) + controlPairs.Add({Me.writeLog, Nothing}) + controlPairs.Add({Me.logLevel, Label1}) + controlPairs.Add({Me.logSize, Label16}) + controlPairs.Add({Me.includeSchemas, Nothing}) + controlPairs.Add({Me.strictBodies, Nothing}) + + '' Add help-tooltips from Json-Schema. + '' + Dim schema = JObject.Parse(cPreferences.JSchemaStr) + For Each row In controlPairs + Dim ctrl = row(0) + Dim Label = row(1) + updateControlsFromSchema(schema, ctrl, Label) + Next + + UI_PopulateFrom(AppPreferences) + End Sub + + Private Sub UI_PopulateFrom(ByVal value As cPreferences) + ' Allocate the data from the confic file (Only by the start) + Me.workingDir.Text = value.workingDir + Me.editor.Text = value.Editor + Me.writeLog.Checked = value.WriteLog + Me.logLevel.Text = value.LogLevel + Me.logSize.Text = value.LogSize + Me.includeSchemas.Checked = value.IncludeSchemas + Me.strictBodies.Checked = value.StrictBodies + End Sub + + Private Sub UI_PopulateTo(ByVal value As cPreferences) + value.workingDir = Me.workingDir.Text + value.Editor = Me.editor.Text + value.WriteLog = Me.writeLog.Checked + value.LogLevel = Me.logLevel.Text + value.LogSize = Me.logSize.Text + value.IncludeSchemas = Me.includeSchemas.Checked + value.StrictBodies = Me.strictBodies.Checked + End Sub + + ' Open the filebrowser for selecting the working dir + Private Sub ButtonWorDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectWorDir.Click + If fbWorkDir.OpenDialog(Me.workingDir.Text) Then + Me.workingDir.Text = fbWorkDir.Files(0) + End If + End Sub + + ' 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() + UI_PopulateTo(newPrefs) + + ' Write the config file + newPrefs.Store(PreferencesPath) + AppPreferences = 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)) + Catch ex As Exception + fInfWarErr(9, False, format("Failed storing Preferences({0}) due to: {1} \n Preferences left unmodified!", _ + PreferencesPath, ex.Message), ex) + End Try + + ' Close the window + Me.Close() + End Sub + + ' 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) + Catch ex As Exception + fInfWarErr(9, False, format("Failed loading Preferences({0}) due to: {1}", _ + PreferencesPath, ex.Message), ex) + End Try + End Sub + + ' Close button + Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCancel.Click + Me.Close() + End Sub + + ' Select the Notepad path + Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectNotepad.Click + If fbExe.OpenDialog(Me.workingDir.Text) Then + Me.editor.Text = fbExe.Files(0) + End If + End Sub + + ' Interception from kyepress events in the MSG box + Private Sub TextBoxMSG_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles logLevel.KeyPress + Select Case Asc(e.KeyChar) + Case 48 To 56, 8 ' Numbers from 1 till 8 allowed (ASCII) + Case Else ' Eliminate all other inputs + e.Handled = True + End Select + End Sub + + ' 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 = 5 + End Sub + + ' Changes in the MSG --> Change the lable + Private Sub TextBoxMSG_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logLevel.TextChanged + Select Case Me.logLevel.Text + Case 0 To 2 ' Show all + Me.LabelInfo.Text = "All" + Case 3 ' No infos with priority 5 (*) + Me.LabelInfo.Text = "No Infos with priority 5 (+)" + Case 4 ' No infos with priority 4 (*) + Me.LabelInfo.Text = "No Infos with priority 4 (~)" + Case 5 ' No infos with priority 3 (*) + Me.LabelInfo.Text = "No Infos with priority 3 (*)" + Case 6 ' No infos with priority 2 (-) + Me.LabelInfo.Text = "No Infos with priority 2 (-)" + Case 7 ' No infos + Me.LabelInfo.Text = "No Infos" + Case Else ' No warnings / infos + Me.LabelInfo.Text = "No Warnings / Infos" + End Select + End Sub + + ' Changes in the LogSizeBox + Private Sub TextBoxLogSize_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles logSize.KeyPress, TextBox1.KeyPress + Select Case Asc(e.KeyChar) + Case 48 To 58, 8 ' Numbers allowed (ASCII) + Case Else ' Eliminate all other input data + e.Handled = True + End Select + End Sub + + ' 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 = 2 + End Sub +End Class + diff --git a/CSE/GUI/minor_routines_GUI.vb b/CSE/GUI/utils_GUI.vb similarity index 63% rename from CSE/GUI/minor_routines_GUI.vb rename to CSE/GUI/utils_GUI.vb index 035ea1b6cc29ed1941810655c8580876d5ce7d76..d27333dcf9ec30fd9a0cd0099608d95c937e9202 100644 --- a/CSE/GUI/minor_routines_GUI.vb +++ b/CSE/GUI/utils_GUI.vb @@ -1,4 +1,6 @@ -Module minor_routines_GUI +Imports Newtonsoft.Json.Linq + +Module utils_GUI ' Clear the GUI Public Function fClear_VECTO_Form(ByVal Komplet As Boolean, Optional ByVal Fields As Boolean = True) As Boolean @@ -10,27 +12,27 @@ If Fields Then ' Clear the Textboxes or set them to default - CSEMain.TextBoxVeh1.Clear() - CSEMain.TextBoxWeather.Clear() - CSEMain.TextBoxAirf.Text = 1 - CSEMain.TextBoxAird.Text = 0 - CSEMain.TextBoxbetaf.Text = 1 - CSEMain.TextBoxbetad.Text = 0 - CSEMain.CheckBoxAcc.Checked = True - CSEMain.CheckBoxGrd.Checked = False + F_Main.TextBoxVeh1.Clear() + F_Main.TextBoxWeather.Clear() + F_Main.TextBoxAirf.Text = 1 + F_Main.TextBoxAird.Text = 0 + F_Main.TextBoxbetaf.Text = 1 + F_Main.TextBoxbetad.Text = 0 + F_Main.CheckBoxAcc.Checked = True + F_Main.CheckBoxGrd.Checked = False ' Calibration fields - CSEMain.TextBoxDataC.Clear() - CSEMain.TextBoxMSCC.Clear() - CSEMain.TextBoxRRC.Text = 1.0 + F_Main.TextBoxDataC.Clear() + F_Main.TextBoxMSCC.Clear() + F_Main.TextBoxRRC.Text = 1.0 ' Test run fields - CSEMain.TextBoxMSCT.Clear() - CSEMain.TextBoxDataLS1.Clear() - CSEMain.TextBoxDataHS.Clear() - CSEMain.TextBoxDataLS2.Clear() + F_Main.TextBoxMSCT.Clear() + F_Main.TextBoxDataLS1.Clear() + F_Main.TextBoxDataHS.Clear() + F_Main.TextBoxDataLS2.Clear() - CSEMain.ButtonEval.Enabled = False + F_Main.ButtonEval.Enabled = False ' Option parameters to standard StdParameter() @@ -38,11 +40,11 @@ End If ' Clear the Warning and Error box - CSEMain.ListBoxWar.Items.Clear() - CSEMain.ListBoxErr.Items.Clear() - CSEMain.TabControlOutMsg.SelectTab(0) - CSEMain.TabPageErr.Text = "Errors (0)" - CSEMain.TabPageWar.Text = "Warnings (0)" + F_Main.ListBoxWar.Items.Clear() + F_Main.ListBoxErr.Items.Clear() + F_Main.TabControlOutMsg.SelectTab(0) + F_Main.TabPageErr.Text = "Errors (0)" + F_Main.TabPageWar.Text = "Warnings (0)" Return True End Function @@ -50,14 +52,15 @@ Function fControlPath(ByVal Line As String, ByVal position As Integer) As Boolean ' Polling if a path is available If (Line = Nothing) Then - If Not fInfWarErr(9, False, "No " & NameFK(position) & "-Inputfile") Then Return True + fInfWarErr(9, False, "No " & NameFK(position) & "-Inputfile") + Return True ' Polling if the path is an acceptable inputfile ElseIf IsNumeric(Line) Or (Mid(Line, 2, 1) <> ":") Or (Line = varOutStr) Then - If Not fInfWarErr(9, False, "No acceptably " & NameFK(position) & "-Inputfile: " & Line) Then Return True + fInfWarErr(9, False, "No acceptably " & NameFK(position) & "-Inputfile: " & Line) + Return True End If - ' Write the path into the AppSettings.WriteLog - If AppSettings.WriteLog Then fWriteLog(2, 4, NameFK(position) & " File: " & Line) + fWriteLog(2, 4, NameFK(position) & " File: " & Line) Return False End Function @@ -76,7 +79,7 @@ ' Open the jobfile If Not FileInVECTO.OpenRead(JobFile) Then ' Falls File nicht vorhanden, abbrechen mit Fehler - fInfWarErrBW(9, False, "Can´t find the Jobfile file: " & JobFile) + fInfWarErr(9, False, "Can´t find the Jobfile file: " & JobFile) Return False End If @@ -214,27 +217,27 @@ tq_sum_1s_delta = Line(0) End Select Else - fInfWarErrBW(9, False, "The given value in the job file at position: " & i & " is not a number") + fInfWarErr(9, False, "The given value in the job file at position: " & i & " is not a number") BWorker.CancelAsync() Return False End If Loop Catch ex As Exception ' Error - fInfWarErrBW(9, False, "Invalid value in the job file at position: " & i) + fInfWarErr(9, False, "Invalid value in the job file at position: " & i) BWorker.CancelAsync() Return False End Try ' Look if enough parameters are given If i < 34 Then - fInfWarErrBW(9, False, "Not enough parameters given in the job file") + fInfWarErr(9, False, "Not enough parameters given in the job file") BWorker.CancelAsync() Return False End If ' Control the input files - fControlInput(Vehspez, 1, "csveh") + fControlInput(Vehspez, 1, "csveh.json") fControlInput(Ambspez, 2, "csamb") fControlInput(MSCCSpez, 3, "csms") fControlInput(MSCTSpez, 4, "csms") @@ -246,21 +249,21 @@ ' Transfer the data to the GUI ' General - CSEMain.TextBoxVeh1.Text = Vehspez - CSEMain.TextBoxAirf.Text = AnemIC(1) - CSEMain.TextBoxAird.Text = AnemIC(2) - CSEMain.TextBoxbetaf.Text = AnemIC(3) - CSEMain.TextBoxbetad.Text = AnemIC(4) - CSEMain.TextBoxWeather.Text = Ambspez + F_Main.TextBoxVeh1.Text = Vehspez + F_Main.TextBoxAirf.Text = AnemIC(1) + F_Main.TextBoxAird.Text = AnemIC(2) + F_Main.TextBoxbetaf.Text = AnemIC(3) + F_Main.TextBoxbetad.Text = AnemIC(4) + F_Main.TextBoxWeather.Text = Ambspez ' Calibration - CSEMain.TextBoxMSCC.Text = MSCCSpez - CSEMain.TextBoxDataC.Text = DataSpez(1) + F_Main.TextBoxMSCC.Text = MSCCSpez + F_Main.TextBoxDataC.Text = DataSpez(1) ' Test - CSEMain.TextBoxMSCT.Text = MSCTSpez - CSEMain.TextBoxRRC.Text = RRC - CSEMain.TextBoxDataLS1.Text = DataSpez(2) - CSEMain.TextBoxDataHS.Text = DataSpez(3) - CSEMain.TextBoxDataLS2.Text = DataSpez(4) + F_Main.TextBoxMSCT.Text = MSCTSpez + F_Main.TextBoxRRC.Text = RRC + F_Main.TextBoxDataLS1.Text = DataSpez(2) + F_Main.TextBoxDataHS.Text = DataSpez(3) + F_Main.TextBoxDataLS2.Text = DataSpez(4) ' Options WriteParToTB() @@ -369,10 +372,10 @@ 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 - If Not fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Then Return False + fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Return False - ElseIf (fEXT(File) <> endung) And Not (File = varOutStr) Then - If Not fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Then Return False + ElseIf (Not File.EndsWith(endung, StringComparison.OrdinalIgnoreCase)) And Not (File = varOutStr) Then + fInfWarErr(8, False, "The " & NameFK(position) & "-Inputfile is not a regular " & NameFK(position) & "-File") Return False End If Return True @@ -384,23 +387,23 @@ Dim i As Integer ' Read the data from the textboxes (General) - Vehspez = CSEMain.TextBoxVeh1.Text - Ambspez = CSEMain.TextBoxWeather.Text - AnemIC(1) = CSEMain.TextBoxAirf.Text - AnemIC(2) = CSEMain.TextBoxAird.Text - AnemIC(3) = CSEMain.TextBoxbetaf.Text - AnemIC(4) = CSEMain.TextBoxbetad.Text + Vehspez = F_Main.TextBoxVeh1.Text + Ambspez = F_Main.TextBoxWeather.Text + AnemIC(1) = F_Main.TextBoxAirf.Text + AnemIC(2) = F_Main.TextBoxAird.Text + AnemIC(3) = F_Main.TextBoxbetaf.Text + AnemIC(4) = F_Main.TextBoxbetad.Text ' Appropriate the inputfiles from calibration run - DataSpez(1) = CSEMain.TextBoxDataC.Text - MSCCSpez = CSEMain.TextBoxMSCC.Text + DataSpez(1) = F_Main.TextBoxDataC.Text + MSCCSpez = F_Main.TextBoxMSCC.Text ' Appropriate the inputfiles from test run - DataSpez(2) = CSEMain.TextBoxDataLS1.Text - DataSpez(3) = CSEMain.TextBoxDataHS.Text - DataSpez(4) = CSEMain.TextBoxDataLS2.Text - MSCTSpez = CSEMain.TextBoxMSCT.Text - RRC = CSEMain.TextBoxRRC.Text + DataSpez(2) = F_Main.TextBoxDataLS1.Text + DataSpez(3) = F_Main.TextBoxDataHS.Text + DataSpez(4) = F_Main.TextBoxDataLS2.Text + MSCTSpez = F_Main.TextBoxMSCT.Text + RRC = F_Main.TextBoxRRC.Text ' Get the option parameter If Not fgetPar() Then Return False @@ -424,57 +427,57 @@ ' Get the parameters from option tab Function fgetPar() As Boolean ' Evaluation box - If CSEMain.CheckBoxAcc.Checked Then AccC = True - If CSEMain.CheckBoxGrd.Checked Then GradC = True + If F_Main.CheckBoxAcc.Checked Then AccC = True + If F_Main.CheckBoxGrd.Checked Then GradC = True ' Output box - If CSEMain.RB1Hz.Checked Then HzOut = 1 - If CSEMain.RB100Hz.Checked Then HzOut = 100 + If F_Main.RB1Hz.Checked Then HzOut = 1 + If F_Main.RB100Hz.Checked Then HzOut = 100 'Parameter boxes ' General valid criteria - delta_t_tire_max = CSEMain.TBDeltaTTireMax.Text - delta_RRC_max = CSEMain.TBDeltaRRCMax.Text - t_amb_var = CSEMain.TBTambVar.Text - t_amb_tarmac = CSEMain.TBTambTamac.Text - t_amb_max = CSEMain.TBTambMax.Text - t_amb_min = CSEMain.TBTambMin.Text + delta_t_tire_max = F_Main.TBDeltaTTireMax.Text + delta_RRC_max = F_Main.TBDeltaRRCMax.Text + t_amb_var = F_Main.TBTambVar.Text + t_amb_tarmac = F_Main.TBTambTamac.Text + t_amb_max = F_Main.TBTambMax.Text + t_amb_min = F_Main.TBTambMin.Text ' General - delta_Hz_max = CSEMain.TBDeltaHzMax.Text - roh_air_ref = CSEMain.TBRhoAirRef.Text - acc_corr_ave = CSEMain.TBAccCorrAve.Text - delta_parallel_max = CSEMain.TBDeltaParaMax.Text + delta_Hz_max = F_Main.TBDeltaHzMax.Text + roh_air_ref = F_Main.TBRhoAirRef.Text + acc_corr_ave = F_Main.TBAccCorrAve.Text + delta_parallel_max = F_Main.TBDeltaParaMax.Text ' Identification of measurement section - delta_x_max = CSEMain.TBDeltaXMax.Text - delta_y_max = CSEMain.TBDeltaYMax.Text - delta_head_max = CSEMain.TBDeltaHeadMax.Text + delta_x_max = F_Main.TBDeltaXMax.Text + delta_y_max = F_Main.TBDeltaYMax.Text + delta_head_max = F_Main.TBDeltaHeadMax.Text ' Requirements on number of valid datasets - ds_min_CAL = CSEMain.TBDsMinCAL.Text - ds_min_LS = CSEMain.TBDsMinLS.Text - ds_min_HS = CSEMain.TBDsMinHS.Text - ds_min_head_MS = CSEMain.TBDsMinHeadHS.Text + ds_min_CAL = F_Main.TBDsMinCAL.Text + ds_min_LS = F_Main.TBDsMinLS.Text + ds_min_HS = F_Main.TBDsMinHS.Text + ds_min_head_MS = F_Main.TBDsMinHeadHS.Text ' DataSet validity criteria - dist_float = CSEMain.TBDistFloat.Text + dist_float = F_Main.TBDistFloat.Text ' Calibration - v_wind_ave_CAL_max = CSEMain.TBvWindAveCALMax.Text - v_wind_1s_CAL_max = CSEMain.TBvWind1sCALMax.Text - beta_ave_CAL_max = CSEMain.TBBetaAveCALMax.Text + v_wind_ave_CAL_max = F_Main.TBvWindAveCALMax.Text + v_wind_1s_CAL_max = F_Main.TBvWind1sCALMax.Text + beta_ave_CAL_max = F_Main.TBBetaAveCALMax.Text ' Low and high speed test - leng_crit = CSEMain.TBLengCrit.Text + leng_crit = F_Main.TBLengCrit.Text ' Low speed test - v_wind_ave_LS_max = CSEMain.TBvWindAveLSMax.Text - v_wind_1s_LS_max = CSEMain.TBvWind1sLSMax.Text - v_veh_ave_LS_max = CSEMain.TBvVehAveLSMax.Text - v_veh_ave_LS_min = CSEMain.TBvVehAveLSMin.Text - v_veh_float_delta = CSEMain.TBvVehFloatD.Text - tq_sum_float_delta = CSEMain.TBTqSumFloatD.Text + v_wind_ave_LS_max = F_Main.TBvWindAveLSMax.Text + v_wind_1s_LS_max = F_Main.TBvWind1sLSMax.Text + v_veh_ave_LS_max = F_Main.TBvVehAveLSMax.Text + v_veh_ave_LS_min = F_Main.TBvVehAveLSMin.Text + v_veh_float_delta = F_Main.TBvVehFloatD.Text + tq_sum_float_delta = F_Main.TBTqSumFloatD.Text ' High speed test - v_wind_ave_HS_max = CSEMain.TBvWindAveHSMax.Text - v_wind_1s_HS_max = CSEMain.TBvWind1sHSMax.Text - v_veh_ave_HS_min = CSEMain.TBvVehAveHSMin.Text - beta_ave_HS_max = CSEMain.TBBetaAveHSMax.Text - v_veh_1s_delta = CSEMain.TBvVeh1sD.Text - tq_sum_1s_delta = CSEMain.TBTq1sD.Text + v_wind_ave_HS_max = F_Main.TBvWindAveHSMax.Text + v_wind_1s_HS_max = F_Main.TBvWind1sHSMax.Text + v_veh_ave_HS_min = F_Main.TBvVehAveHSMin.Text + beta_ave_HS_max = F_Main.TBBetaAveHSMax.Text + v_veh_1s_delta = F_Main.TBvVeh1sD.Text + tq_sum_1s_delta = F_Main.TBTq1sD.Text Return True End Function @@ -483,70 +486,70 @@ Function WriteParToTB() As Boolean ' Write the Standard values in the textboxes ' General valid criteria - CSEMain.TBDeltaTTireMax.Text = delta_t_tire_max - CSEMain.TBDeltaRRCMax.Text = delta_RRC_max - CSEMain.TBTambVar.Text = t_amb_var - CSEMain.TBTambTamac.Text = t_amb_tarmac - CSEMain.TBTambMax.Text = t_amb_max - CSEMain.TBTambMin.Text = t_amb_min + F_Main.TBDeltaTTireMax.Text = delta_t_tire_max + F_Main.TBDeltaRRCMax.Text = delta_RRC_max + F_Main.TBTambVar.Text = t_amb_var + F_Main.TBTambTamac.Text = t_amb_tarmac + F_Main.TBTambMax.Text = t_amb_max + F_Main.TBTambMin.Text = t_amb_min ' General - CSEMain.TBDeltaHzMax.Text = delta_Hz_max - CSEMain.TBRhoAirRef.Text = roh_air_ref - CSEMain.TBAccCorrAve.Text = acc_corr_ave - CSEMain.TBDeltaParaMax.Text = delta_parallel_max + F_Main.TBDeltaHzMax.Text = delta_Hz_max + F_Main.TBRhoAirRef.Text = roh_air_ref + F_Main.TBAccCorrAve.Text = acc_corr_ave + F_Main.TBDeltaParaMax.Text = delta_parallel_max ' Identification of measurement section - CSEMain.TBDeltaXMax.Text = delta_x_max - CSEMain.TBDeltaYMax.Text = delta_y_max - CSEMain.TBDeltaHeadMax.Text = delta_head_max + F_Main.TBDeltaXMax.Text = delta_x_max + F_Main.TBDeltaYMax.Text = delta_y_max + F_Main.TBDeltaHeadMax.Text = delta_head_max ' Requirements on number of valid datasets - CSEMain.TBDsMinCAL.Text = ds_min_CAL - CSEMain.TBDsMinLS.Text = ds_min_LS - CSEMain.TBDsMinHS.Text = ds_min_HS - CSEMain.TBDsMinHeadHS.Text = ds_min_head_MS + F_Main.TBDsMinCAL.Text = ds_min_CAL + F_Main.TBDsMinLS.Text = ds_min_LS + F_Main.TBDsMinHS.Text = ds_min_HS + F_Main.TBDsMinHeadHS.Text = ds_min_head_MS ' DataSet validity criteria - CSEMain.TBDistFloat.Text = dist_float + F_Main.TBDistFloat.Text = dist_float ' Calibration - CSEMain.TBvWindAveCALMax.Text = v_wind_ave_CAL_max - CSEMain.TBvWind1sCALMax.Text = v_wind_1s_CAL_max - CSEMain.TBBetaAveCALMax.Text = beta_ave_CAL_max + F_Main.TBvWindAveCALMax.Text = v_wind_ave_CAL_max + F_Main.TBvWind1sCALMax.Text = v_wind_1s_CAL_max + F_Main.TBBetaAveCALMax.Text = beta_ave_CAL_max ' Low and high speed test - CSEMain.TBLengCrit.Text = leng_crit + F_Main.TBLengCrit.Text = leng_crit ' Low speed test - CSEMain.TBvWindAveLSMax.Text = v_wind_ave_LS_max - CSEMain.TBvWind1sLSMax.Text = v_wind_1s_LS_max - CSEMain.TBvVehAveLSMax.Text = v_veh_ave_LS_max - CSEMain.TBvVehAveLSMin.Text = v_veh_ave_LS_min - CSEMain.TBvVehFloatD.Text = v_veh_float_delta - CSEMain.TBTqSumFloatD.Text = tq_sum_float_delta + F_Main.TBvWindAveLSMax.Text = v_wind_ave_LS_max + F_Main.TBvWind1sLSMax.Text = v_wind_1s_LS_max + F_Main.TBvVehAveLSMax.Text = v_veh_ave_LS_max + F_Main.TBvVehAveLSMin.Text = v_veh_ave_LS_min + F_Main.TBvVehFloatD.Text = v_veh_float_delta + F_Main.TBTqSumFloatD.Text = tq_sum_float_delta ' High speed test - CSEMain.TBvWindAveHSMax.Text = v_wind_ave_HS_max - CSEMain.TBvWind1sHSMax.Text = v_wind_1s_HS_max - CSEMain.TBvVehAveHSMin.Text = v_veh_ave_HS_min - CSEMain.TBBetaAveHSMax.Text = beta_ave_HS_max - CSEMain.TBvVeh1sD.Text = v_veh_1s_delta - CSEMain.TBTq1sD.Text = tq_sum_1s_delta + F_Main.TBvWindAveHSMax.Text = v_wind_ave_HS_max + F_Main.TBvWind1sHSMax.Text = v_wind_1s_HS_max + F_Main.TBvVehAveHSMin.Text = v_veh_ave_HS_min + F_Main.TBBetaAveHSMax.Text = beta_ave_HS_max + F_Main.TBvVeh1sD.Text = v_veh_1s_delta + F_Main.TBTq1sD.Text = tq_sum_1s_delta ' Evaluation box If AccC Then - CSEMain.CheckBoxAcc.Checked = True + F_Main.CheckBoxAcc.Checked = True Else - CSEMain.CheckBoxAcc.Checked = False + F_Main.CheckBoxAcc.Checked = False End If If GradC Then - CSEMain.CheckBoxGrd.Checked = True + F_Main.CheckBoxGrd.Checked = True Else - CSEMain.CheckBoxGrd.Checked = False + F_Main.CheckBoxGrd.Checked = False End If ' Output If HzOut = 1 Then - CSEMain.RB1Hz.Checked = True + F_Main.RB1Hz.Checked = True ElseIf HzOut = 100 Then - CSEMain.RB100Hz.Checked = True + F_Main.RB100Hz.Checked = True End If Return True End Function - ' Delete lines from the AppSettings.WriteLog + ' Delete lines from the Log Function fLoeschZeilen(ByVal File As String, ByVal Anzahl As Integer, Optional ByVal Zeichen As String = "-") As Boolean ' Declarations Dim i, k As Integer @@ -580,4 +583,49 @@ End Function -End Module \ No newline at end of file + 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)) + Return + End If + + '' Set title on control/label + '' + Dim title = pschema("title") + If title IsNot Nothing Then + If label IsNot Nothing Then + label.Text = title + Else + If TypeOf ctrl Is CheckBox Then + title = title.ToString() & "?" + End If + End If + ctrl.Text = title + End If + + '' Build tooltip. + '' + Dim infos = _ + From pname In {"title", "description", "type", "enum", "default", _ + "minimum", "exclusiveMinimum", "maximum", "exclusiveMaximum"} + Select pschema(pname) + + ''TODO: Include other schema-props in tooltips. + + If infos.Any() Then + Dim msg = schemaInfos2helpMsg(infos.ToArray()) + Dim t = New ToolTip() + t.SetToolTip(ctrl, msg) + t.AutomaticDelay = 300 + t.AutoPopDelay = 10000 + End If + + + Catch ex As Exception + fInfWarErr(8, False, format("Schema2GUI: Skipped exception: {0} ", ex.Message), ex) + End Try + End Sub + +End Module diff --git a/CSE/Export/OutputTest.vb b/CSE/IO/OutputTest.vb similarity index 94% rename from CSE/Export/OutputTest.vb rename to CSE/IO/OutputTest.vb index 91fcf7df8bfd8253e04ffcd0fa702ea46aec4d6f..3914200b341f48db2e4f0cac3c9e8e06013c16d9 100644 --- a/CSE/Export/OutputTest.vb +++ b/CSE/IO/OutputTest.vb @@ -23,7 +23,7 @@ End If ' Write on GUI - fInfWarErrBW(5, False, "Write output-file (*.csv)") + fInfWarErr(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 - fInfWarErrBW(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True diff --git a/CSE/IO/cJsonFile.vb b/CSE/IO/cJsonFile.vb new file mode 100644 index 0000000000000000000000000000000000000000..cc59defd6f4c907f62b488870d3503b67cd126dc --- /dev/null +++ b/CSE/IO/cJsonFile.vb @@ -0,0 +1,307 @@ +Option Strict Off + +Imports Newtonsoft.Json.Linq +Imports Newtonsoft.Json.Schema +Imports System.Globalization + +''' <summary>The parent-class for Head/Body json files. +''' +''' It is responsible for maintaining a "decent" Header by overlaying infos from subclasses, +''' and delegates the Body-building and its validation almost entirely to sub-classes. +''' </summary> +''' <remarks> +''' The /Header/Strict boolean controls whether to allow additional-properties in Body, +''' so it can be used to debug input-files by manually setting it to 'true' with a text-editor. +''' </remarks> +Public MustInherit Class cJsonFile + Implements ICloneable + + Shared dateFrmt As String = "yyyy/MM/dd HH:mm:ss zzz" + + ''' <summary>The json-content for a json-file structured in Header/Body</summary> + ''' <remarks>Note that the content is invalid according to the schema, and has to be specified by sub-classers.</remarks> + Protected Shared Function JsonStr_FileContents() As String + Return <json>{ + "Header": { + "Title": null, + "FileVersion": null, + "AppVersion": null, + "ModifiedDate": null, + "StrictBody": false, + }, + "Body": null + }</json>.Value + End Function + + ''' <summary>The schema for a json-file structured in Header/Body</summary> + Protected Shared Function JSchemaStr_Header(ByVal isStrict As Boolean) As String + Dim requireAll As String = IIf(isStrict, "true", "false") + Return <json>{ + "title": "vecto header/body json-file", + "type": "object", "additionalProperties": false, + "properties": { + "Header": { + "type": "object", "additionalProperties": true, + "required": true, + "properties": { + "Title": { + "type": "string", + "required": <%= requireAll %>, + }, + "FileVersion": { + "type": "string", + "required": true, + }, + "AppVersion": { + "type": "string", + "required": <%= requireAll %>, + }, + "ModifiedDate": { + "type": "string", + "description": "Last-modification date", + "required": <%= requireAll %>, + }, + "StrictBody": { + "title": "Validate body strictly", + "type": "boolean", + "description": "When True, the 'Body' does not accept unknown properties.", + "default": false, + }, + "BodySchema": { + "title": "Body schema", + "type": ["boolean", "object", "null"], + "description": "Body schema is included HERE, for documenting file. \n _ + When null/property missing, application decides what to do. \n _ + When True, it is always replaced by the Body's schema on the next save.\n _ + When False, it overrides Application's choice and is not replaced ever.", + "default": null, + }, + } + }, + "Body": {} + } + }</json>.Value + End Function + + ''' <summary>When a new file is Created or Stored, the contents return from this method is overlayed on /Header/*</summary> + ''' <remarks>The result json must be valid overlaying this header.</remarks> + Protected MustOverride Function HeaderOverlay() As JObject + + ''' <summary>When a instance_with_defauls is Created, it gets its /Body from this method</summary> + ''' <remarks>The result json must be valid after replacing with this body.</remarks> + Protected MustOverride Function BodyContent() As JObject + + ''' <summary>When a instance_with_defauls is Created, it gets its /Body from this method</summary> + ''' <remarks>The result json must be valid after replacing with this body.</remarks> + Public MustOverride Function BodySchema() As JObject + + ''' <summary>Invoked by this class for subclasses to validate file</summary> + ''' <remarks>To signify validation-failure it can throw an exception or add err-messages into the supplied list</remarks> + Protected MustOverride Sub ValidateBody(ByVal isStrict As Boolean, ByVal validateMsgs As IList(Of String)) + + + ''' <summary>The whole json-content receiving any changes, always ready to be written as is.</summary> + Private Content As JObject + + ''' <summary>Cached instance from 'Content', used (tentatively) for perfomance.</summary> + Public ReadOnly Header As JObject + + ''' <summary>Cached instance from 'Content', used (tentatively) for perfomance.</summary> + Public ReadOnly Body As JObject + + ''' <summary>Reads from a file (aka "Load") or creates an instance with defaults + ''' + ''' When reading, it optionally checks version and validates its body with ValidateVersionAndBody(). + ''' When defaulting, the resulted file-version is retrieved from 'CodeVersion' prop and the body from 'BodyStr' prop. + ''' </summary> + ''' <param name="inputFilePath">If unspecifed, create instance_with_defaults, otherwise read json-contents from file</param> + ''' <param name="skipValidation">When false (the default), validates json-contents in both cases (reading or creating-defaults)</param> + ''' <remarks></remarks> + Protected Sub New(Optional ByVal inputFilePath As String = Nothing, Optional ByVal skipValidation As Boolean = False) + Dim strictHeader = True + + If (inputFilePath Is Nothing) Then + Dim jstr = JsonStr_FileContents() + Me.Content = JObject.Parse(jstr) + Me.Header = Content("Header") + UpdateHeader() + + Me.Content("Body") = Me.BodyContent + Me.Body = Content("Body") + Else + strictHeader = False '' Try to read even bad headers. + fInfWarErr(4, False, format("Reading JSON-file({0})...", inputFilePath)) + + Me.Content = ReadJsonFile(inputFilePath) + Me.Header = Content("Header") + Me.Body = Content("Body") + End If + + If Not skipValidation Then + Me.Validate(strictHeader) + End If + End Sub + + ''' <summary>Validates and Writing to the config file</summary> + Sub Store(ByVal fpath As String) + Me.UpdateHeader() + + Me.Validate(Me.StrictBody) + WriteJsonFile(fpath, Content) + End Sub + + ''' <summary>Maintains header's standard props and overlays any props from subclass.</summary> + ''' <remarks>Note that it is invoked early enough, before the new file has acquired a Body.</remarks> + Sub UpdateHeader() + Dim h As JObject = Me.Header + + h("ModifiedDate") = DateTime.Now.ToString(dateFrmt) + h("AppVersion") = AppVers + If h("StrictBody") Is Nothing Then + h("StrictBody") = False + End If + + '' Decide whether to include body-schema in header (for documenting file), + '' by checking the folllowing, ordered by priority: + '' 1. jsonfile:/Header/BodySchema + '' 2. prefs:/Body/IncludeSchemas + '' 2.b. prefschema:/properties/Body/properties/IncludeSchemas/default (implict by cPreferences.IncludeSchemas property) + '' 3. false + Dim isIncludeSchema As Boolean + Dim bodySchema = h("BodySchema") + If bodySchema IsNot Nothing AndAlso bodySchema.Type = JTokenType.Boolean Then + isIncludeSchema = bodySchema + ElseIf AppPreferences IsNot Nothing Then + isIncludeSchema = AppPreferences.IncludeSchemas + Else + isIncludeSchema = False + End If + If isIncludeSchema Then + h("BodySchema") = Me.BodySchema + ElseIf bodySchema Is Nothing Then + h("BodySchema") = Nothing + End If + + '' Overlay subclass's properties. + '' + For Each child As KeyValuePair(Of String, JToken) In Me.HeaderOverlay + h(child.Key) = child.Value + Next + End Sub + + ''' <exception cref="FormatException">includes all validation errors</exception> + ''' <param name="strictHeader">when false, relaxes Header's schema (used on Loading to be more accepting)</param> + Friend Sub Validate(Optional ByVal strictHeader As Boolean = False) + Dim validateMsgs As IList(Of String) = New List(Of String) + + Dim fileSchema = JsonSchema.Parse(JSchemaStr_Header(strictHeader)) + + '' Validate Header + '' + ValidateJson(Me.Content, fileSchema, validateMsgs) + If (validateMsgs.Any()) Then + Throw New FormatException(format("Validating /Header failed due to: {0}", String.Join(vbCrLf, validateMsgs))) + End If + Dim dummy = New cSemanticVersion(Me.FileVersion) '' Just to ensure its syntax. + + '' Validate Body by subclass + Dim hsb = Me.Header("StrictBody") + Dim strictBody As Boolean = IIf(hsb Is Nothing, AppPreferences.StrictBodies, hsb) + Me.ValidateBody(strictBody, validateMsgs) + + If (validateMsgs.Any()) Then + Throw New FormatException(format("Validating /Body failed due to: {0}", String.Join(vbCrLf, validateMsgs))) + End If + End Sub + + + + Public Function Clone() As Object Implements ICloneable.Clone + Dim nobj As cJsonFile = Me.MemberwiseClone() + nobj.Content = Me.Content.DeepClone() + + Return nobj + End Function + + Public Overrides Function Equals(ByVal obj As Object) As Boolean + If obj Is Nothing OrElse Not Me.GetType().Equals(obj.GetType()) Then + Return False + Else + Return JToken.DeepEquals(Me.Content, DirectCast(obj, cJsonFile).Content) + End If + End Function + + ''' <summary>Reads value found by XPath and if notinhg there, fetches default-value schema.</summary> + ''' <param name="propPath">The JSON.net's XPath for a Body property, including the starting dot('.'). + ''' + ''' Examples: + ''' PROP REQUESTED 'propPath' ARGUMENT + ''' -------------- ------------------- + ''' /Body/SomeProp' --> .SomeProp + ''' /Body/someGroup/somePropName --> .someGroup.somePropName'. + ''' </param> + ''' <remarks>Used by sublasses to implement Propety-Get with defaults when non-existent</remarks> + Protected Function BodyGetter(ByVal propPath As String) As JToken + Dim value As JToken = Me.Body.SelectToken(propPath) + If value Is Nothing Then '' No prop existed + '' Return a default from schema (if any). + '' + Dim schemaPath = propPath.Replace(".", ".properties.") + Return Me.BodySchema.SelectToken(schemaPath & ".default") + Else + Return value + End If + End Function + +#Region "json props" + 'Protected ReadOnly Property Header() As JObject + ' Get + ' Return Me.Json_Contents("Header") + ' End Get + 'End Property + 'Protected ReadOnly Property Body() As JObject + ' Get + ' Return Me.Json_Contents("Body") + ' End Get + 'End Property + + + Public ReadOnly Property Title As String + Get + Return Me.Header("Title") + End Get + End Property + Public ReadOnly Property FileVersion As String + Get + Return Me.Header("FileVersion") + End Get + End Property + Public ReadOnly Property AppVersion As String + Get + Return Me.Header("AppVersion") + End Get + End Property + Public ReadOnly Property ModifiedDate As String + Get + Return Me.Header("ModifiedDate") + End Get + End Property + + Public ReadOnly Property StrictBody As Boolean + Get + Dim value = Me.Body("StrictBody") + Return IIf(value Is Nothing OrElse value.Type = JTokenType.Null, False, value) + End Get + End Property + + '' NO, logic behind it more complex, see UpdateHeader() instead. + 'Public ReadOnly Property BodySchema As Boolean + ' Get + ' Dim value = Me.Body("BodySchema") + ' Return IIf(value Is Nothing OrElse value.Type = JTokenType.Null, False, value) + ' End Get + 'End Property + +#End Region ' "json props" + +End Class diff --git a/CSE/IO/cPreferences.vb b/CSE/IO/cPreferences.vb new file mode 100644 index 0000000000000000000000000000000000000000..9fc244aff1ad187c03a975cca11e8c97eab1d227 --- /dev/null +++ b/CSE/IO/cPreferences.vb @@ -0,0 +1,242 @@ +Option Strict Off + +Imports Newtonsoft.Json.Linq +Imports Newtonsoft.Json.Schema + +Public Class cPreferences + Inherits cJsonFile + + Protected Overrides Function HeaderOverlay() As JObject + Return JObject.Parse(<json>{ + "Title": "vecto-cse PREFERENCES", + "FileVersion": "1.0.0", + }</json>.Value) + End Function + + ' Defaults specified here. + Protected Overrides Function BodyContent() As JObject + '' Return empty body since all proprs are optional. + '' They will become concrete on the 1st store. + Return New JObject() + 'Return JObject.Parse(<json>{ + ' "workingDir": null, + ' "writeLog": true, + ' "logSize": 10, + ' "logLevel": 5, + ' "editor": "notepad.exe", + ' }</json>.Value) + End Function + + Public Overrides Function BodySchema() As JObject + Return JObject.Parse(JSchemaStr()) + End Function + + ''' <param name="allowAdditionalProps">when false, more strict validation</param> + Public Shared Function JSchemaStr(Optional ByVal allowAdditionalProps As Boolean = True) As String + Dim allowAdditionalProps_str As String = IIf(allowAdditionalProps, "true", "false") + Return <json>{ + "title": "Schema for vecto-cse PREFERENCES", + "type": "object", "additionalProperties": <%= allowAdditionalProps_str %>, + "required": true, + "properties": { + "workingDir": { + "title": "Working Directory", + "type": ["string", "null"], + "default": null, + "description": "The path of the Working Directory for input/output files. \nWhen null/empty, app's dir implied.", + }, + "writeLog": { + "title": "Log to file", + "type": "boolean", + "default": true, + "description": "Whether to write messages to log file.", + }, + "logSize": { + "title": "Log-file's limit", + "type": "integer", + "minimum": 0, + "default": 10, + "description": "Allowed Log-file size limit [MiB].", + }, + "logLevel": { + "title": "Log-window's Level", + "type": "integer", + "minimum": 0, + "maximum": 10, "exclusiveMaximum": true, + "default": 5, + "description": "Sets the threshold(Level) below from which log-messages are skipped from the log-window. + 0 : All + 3-7 : No infos + 8 : No warnings + 9 : Not even errors! + other : Nothing at all", + }, + "editor": { + "type": "string", + "default": "notepad.exe", + "description": "Path (or just the filename, if in PATH) of a text editor.", + }, + "strictBodies": { + "title": "Strict Bodies", + "type": "boolean", + "default": false, + "description": "Controls whether unknown body-properties are accepted when reading JSON-files. +It is useful for debugging malformed input-files, ie to detect +accidentally renamed properties. +Each file can override it by setting its /Header/StrictBody property.", + }, + "includeSchemas": { + "title": "Include Schemas", + "type": "boolean", + "default": false, + "description": "Controls whether to self-document JSON-files by populating their '/Header/BodySchema' property. +Each file can override it by setting its '/Header/BodySchema' property to false/true.", + }, + } + }</json>.Value + End Function + + + + + ''' <summary>Reads from file or creates defaults</summary> + ''' <param name="inputFilePath">If unspecifed, default prefs used, otherwise data read from file</param> + ''' <remarks>See cJsonFile() constructor</remarks> + Sub New(Optional ByVal inputFilePath As String = Nothing, Optional ByVal skipValidation As Boolean = False) + MyBase.New(inputFilePath, skipValidation) + End Sub + + + ''' <exception cref="SystemException">includes all validation errors</exception> + ''' <param name="strictBody">when True, no additional json-properties allowed in the data, when nothing, use value from Header</param> + Protected Overrides Sub ValidateBody(ByVal strictBody As Boolean, ByVal validateMsgs As IList(Of String)) + '' Check version + '' + Dim fromVersion = "1.0.0--" + Dim toVersion = "2.0.0--" ' The earliest pre-release. + If Not IsSemanticVersionsSupported(Me.FileVersion, fromVersion, toVersion) Then + validateMsgs.Add(format("Unsupported FileVersion({0}, was not in between [{1}, {2})", FileVersion, fromVersion, toVersion)) + Return + End If + + '' Check schema + '' + Dim schema = JsonSchema.Parse(JSchemaStr(Not strictBody)) + ValidateJson(Me.Body, schema, validateMsgs) + End Sub + + + + +#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 + 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.First = "\"c) Then + value = value.Substring(1) + End If + If (value.Last <> "\"c) Then + value = value & "\" + End If + + If value.Length = 1 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. + '' + If value Is Nothing Then + Me.Body("workingDir") = Nothing + Else + Me.Body("workingDir") = value + End If + End Set + End Property + + Public Property writeLog As Boolean + Get + Return BodyGetter(".writeLog") + End Get + Set(ByVal value As Boolean) + Me.Body("writeLog") = value + End Set + End Property + + Public Property logSize As Integer + Get + Return BodyGetter(".logSize") + End Get + Set(ByVal value As Integer) + Me.Body("logSize") = value + End Set + End Property + + Public Property logLevel As Integer + Get + Return BodyGetter(".logLevel") + End Get + Set(ByVal value As Integer) + Me.Body("logLevel") = value + End Set + End Property + + Public Property editor As String + Get + Return BodyGetter(".editor") + End Get + Set(ByVal value As String) + Me.Body("editor") = value + End Set + End Property + + Public Property strictBodies As Boolean + Get + Return BodyGetter(".strictBodies") + End Get + Set(ByVal value As Boolean) + Me.Body("strictBodies") = value + End Set + End Property + + Public Property includeSchemas As Boolean + Get + Return BodyGetter(".includeSchemas") + End Get + Set(ByVal value As Boolean) + Me.Body("includeSchemas") = value + End Set + End Property + +#End Region ' "json props" +End Class diff --git a/CSE/IO/cVehicle.vb b/CSE/IO/cVehicle.vb new file mode 100644 index 0000000000000000000000000000000000000000..d2a5777c892c124f3f4cd60724feccf8c67ce31e --- /dev/null +++ b/CSE/IO/cVehicle.vb @@ -0,0 +1,245 @@ +Imports Newtonsoft.Json.Linq +Imports Newtonsoft.Json.Schema + +Public Enum VehicleConfig + Rigid + Tractor +End Enum + +Public Class cVehicle + Inherits cJsonFile + + Protected Overrides Function HeaderOverlay() As JObject + Return JObject.Parse(<json>{ + "Title": "vecto-cse VEHICLE", + "FileVersion": "1.0.0", + }</json>.Value) + End Function + + + ' Defaults specified here. + Protected Overrides Function BodyContent() As JObject + Return JObject.Parse(<json>{ + "vehClass": null, + "configuration": null, + "vehWidth": null, + "vehHeight": null, + "anemometerHeight": null, + "testMass": null, + "wheelsInertia": null, + "gearRatio_low": null, + "gearRatio_high": null, + "axleRatio": null, + }</json>.Value) + End Function + + ' Default-prefs specified here. + Public Overrides Function BodySchema() As JObject + Return JObject.Parse(JSchemaStr()) + End Function + + ''' <param name="allowAdditionalProps">when false, more strict validation</param> + Public Shared Function JSchemaStr(Optional ByVal allowAdditionalProps As Boolean = True) As String + Dim allowAdditionalProps_str As String = IIf(allowAdditionalProps, "true", "false") + Return <json>{ + "title": "Schema for vecto-cse VEHICLE", + "type": "object", "additionalProperties": <%= allowAdditionalProps_str %>, + "required": true, + "properties": { + "classCode": { + "title": "Class code [1-16]", + "type": "integer", + "required": true, + "description": "The class the vehicle belongs to according to the legislation. +The generic parameters for classes are stored in the GenShape.shp", + }, + "configuration": { + "title": "Vehicle Configuration", + "enum": ["rigid", "tractor"], + "required": true, + "title": "Vehicle is rigid or track'n tractor?", + }, + "vehWidth": { + "title": "Mask width [m]", + "type":"number", + "required": true, + }, + "vehHeight": { + "title": "Vehicle height [m]", + "type":"number", + "required": true, + } , + "anemometerHeight": { + "title": "Anemomenter height [m]", + "type":"number", + "required": true, + }, + "testMass": { + "title": "Vehicle test mass [kg]", + "type":"number", + "required": true, + }, + "wheelsInertia": { + "title": "Wheels inertia [kg*m2]", + "type":"number", + "required": true, + }, + "gearRatio_low": { + "title": "Gear ratio low speed", + "type":"number", + "required": true, + }, + "gearRatio_high": { + "title": "Gear ratio high speed", + "type":"number", + "required": true, + }, + "axleRatio": { + "title": "Axle ratio", + "type":"number", + "required": true, + }, + } + }</json>.Value + End Function + + + ''' <summary>Reads from file or creates defaults</summary> + ''' <param name="inputFilePath">If unspecifed, default prefs used, otherwise data read from file</param> + ''' <remarks>See cJsonFile() constructor</remarks> + Sub New(Optional ByVal inputFilePath As String = Nothing, Optional ByVal skipValidation As Boolean = False) + MyBase.New(inputFilePath, skipValidation) + End Sub + + + ''' <exception cref="SystemException">includes all validation errors</exception> + ''' <param name="strictBody">when true, no additional json-properties allowed in the data, when nothing, use value from Header</param> + Protected Overrides Sub ValidateBody(ByVal strictBody As Boolean, ByVal validateMsgs As IList(Of String)) + '' Check version + '' + Dim fromVersion = "1.0.0--" + Dim toVersion = "2.0.0--" ' The earliest pre-release. + If Not IsSemanticVersionsSupported(Me.FileVersion, fromVersion, toVersion) Then + validateMsgs.Add(format("Unsupported FileVersion({0}, was not in between [{1}, {2})", Me.FileVersion, fromVersion, toVersion)) + Return + End If + + '' Check schema + '' + Dim schema = JsonSchema.Parse(JSchemaStr(Not strictBody)) + ValidateJson(Body, schema, validateMsgs) + + If validateMsgs.Any() Then Return + + '' Check others + '' + '' Check if vehicle class with the given configuration class is available + For i = 0 To GenShape.veh_class.Count - 1 + If GenShape.veh_class(i) = Me.classCode AndAlso CBool(GenShape.veh_conf(i)) = Me.IsRigid Then + fa_pe = GenShape.fa_pe(i) + Return + End If + Next i + + '' The configuration was not found! + '' + validateMsgs.Add(format("The vehicle (class: {0}, configuration {1}) was not found in the generic shape file. \n\iPlease add it in .", Me.classCode, Me.configuration)) + BWorker.CancelAsync() + Return + End Sub + + + +#Region "json props" + Public Property classCode As Integer + Get + Return Me.Body("classCode") + End Get + Set(ByVal value As Integer) + Me.Body("classCode") = value + End Set + End Property + Public Property configuration As VehicleConfig + Get + Dim value As String = Me.Body("configuration") + + Return [Enum].Parse(GetType(VehicleConfig), value, True) + End Get + Set(ByVal value As VehicleConfig) + Me.Body("configuration") = value.ToString() + End Set + End Property + Public Property vehWidth As Double + Get + Return Me.Body("vehWidth") + End Get + Set(ByVal value As Double) + Me.Body("vehWidth") = value + End Set + End Property + Public Property vehHeight As Double + Get + Return Me.Body("vehHeight") + End Get + Set(ByVal value As Double) + Me.Body("vehHeight") = value + End Set + End Property + Public Property anemometerHeight As Double + Get + Return Me.Body("anemometerHeight") + End Get + Set(ByVal value As Double) + Me.Body("anemometerHeight") = value + End Set + End Property + Public Property testMass As Double + Get + Return Me.Body("testMass") + End Get + Set(ByVal value As Double) + Me.Body("testMass") = value + End Set + End Property + Public Property wheelsInertia As Double + Get + Return Me.Body("wheelsInertia") + End Get + Set(ByVal value As Double) + Me.Body("wheelsInertia") = value + End Set + End Property + Public Property gearRatio_low As Double + Get + Return Me.Body("gearRatio_low") + End Get + Set(ByVal value As Double) + Me.Body("gearRatio_low") = value + End Set + End Property + Public Property gearRatio_high As Double + Get + Return Me.Body("gearRatio_high") + End Get + Set(ByVal value As Double) + Me.Body("gearRatio_high") = value + End Set + End Property + Public Property axleRatio As Double + Get + Return Me.Body("axleRatio") + End Get + Set(ByVal value As Double) + Me.Body("axleRatio") = value + End Set + End Property +#End Region ' "json props" + + Public ReadOnly Property IsRigid As Boolean + Get + Return Me.configuration = VehicleConfig.Rigid + End Get + End Property + + +End Class diff --git a/CSE/Import/read_input.vb b/CSE/IO/input.vb similarity index 77% rename from CSE/Import/read_input.vb rename to CSE/IO/input.vb index e5d8dd5d7d7986c83293880719511a2419168d36..6f970c9c7b94ad455a76ba447612801610504138 100644 --- a/CSE/Import/read_input.vb +++ b/CSE/IO/input.vb @@ -1,73 +1,5 @@ ' Read the input data -Public Module read_input - ' Read the vehicle file - Public Function readInputVeh(ByRef vehicleX As cVehicle) As Boolean - ' Input files - Dim i As Integer - Dim vehT As Boolean = False - Using FileInVehSpez As New cFile_V3 - - ' Read the filelist with the vehicle spezifications - ' Output on the GUI - fInfWarErrBW(5, False, "Read vehicle file") - - ' Open the vehicle spezification file - If Not FileInVehSpez.OpenRead(Vehspez) Then - ' Error if the file is not available - fInfWarErrBW(9, False, "Can´t find the vehicle specification file: " & Vehspez) - Return False - End If - - ' Import routine - vehicleX.ID = FileInVehSpez.ReadLine(0) - vehicleX.veh_conf = FileInVehSpez.ReadLine(0) - vehicleX.mveh_ref = FileInVehSpez.ReadLine(0) - vehicleX.I_wheels = FileInVehSpez.ReadLine(0) - vehicleX.rat_axl = FileInVehSpez.ReadLine(0) - vehicleX.rat_gh = FileInVehSpez.ReadLine(0) - vehicleX.rat_gl = FileInVehSpez.ReadLine(0) - vehicleX.ha = FileInVehSpez.ReadLine(0) - vehicleX.hv = FileInVehSpez.ReadLine(0) - vehicleX.wm = FileInVehSpez.ReadLine(0) - - End Using - - - ' Abfrage ob genügend eingabefiles vorhanden sind - If endofall Then - fInfWarErrBW(9, False, "Not enough inputfiles in the vehicle specification file") - BWorker.CancelAsync() - Return False - End If - - ' Check if vehicl class is available - If Not GenShape.veh_class.Contains(vehicleX.ID) Then - ' Error if the vehicle class is not available - fInfWarErrBW(9, False, "The given vehicle class is not specified in the generic shape file. Please add this class to the generic shape file!") - BWorker.CancelAsync() - Return False - End If - - ' Check if vehicle class with the given configuration class is available - For i = 0 To GenShape.veh_class.Count - 1 - If GenShape.veh_class(i) = vehicleX.ID And GenShape.veh_conf(i) = vehicleX.veh_conf Then - vehT = True - fa_pe = GenShape.fa_pe(i) - Exit For - End If - Next i - - ' Check if the configuration is found - If Not vehT Then - ' Error if the vehicle configuration is not available - fInfWarErrBW(9, False, "The given vehicle configuration is not specified in the generic shape file. Please add this class to the generic shape file!") - BWorker.CancelAsync() - Return False - End If - - Return True - End Function - +Public Module input ' Read the measurement section config file Function ReadInputMSC(ByRef MSCX As cMSC, ByVal MSCfile As String, Optional ByVal calibration As Boolean = True) As Boolean ' Declarations @@ -78,12 +10,12 @@ Public Module read_input ' Read the filelist with the MSC spezifications ' Output on the GUI - fInfWarErrBW(5, False, "Read MS configuration file") + fInfWarErr(5, False, "Read MS configuration file") ' Open the MSC spezification file If Not FileInMSCSpez.OpenRead(MSCfile) Then ' Error if the file is not available - fInfWarErrBW(9, False, "Can´t find the MS configuration specification file: " & MSCfile) + fInfWarErr(9, False, "Can´t find the MS configuration specification file: " & MSCfile) Return False End If @@ -108,7 +40,7 @@ Public Module read_input Loop Catch ex As Exception ' Falls kein gültiger Wert eingegeben wurde - fInfWarErrBW(9, False, "Invalid value in the trigger data file: " & fName(MSCfile, True)) + fInfWarErr(9, False, "Invalid value in the trigger data file: " & fName(MSCfile, True)) BWorker.CancelAsync() Return False End Try @@ -131,7 +63,7 @@ Public Module read_input MSCX.headID.Add(2) Continue For Else - fInfWarErrBW(9, False, "Measurement section with invalid headings identified (test track not parallel) at line: " & i) + fInfWarErr(9, False, "Measurement section with invalid headings identified (test track not parallel) at line: " & i) BWorker.CancelAsync() Return False End If @@ -142,15 +74,15 @@ Public Module read_input For i = 1 To MSCX.meID.Count - 1 If GradC Then If MSCX.AltPath(i) = Nothing Then - fInfWarErrBW(9, False, "Altitude correction = on, missing altitude file at line: " & i) + fInfWarErr(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) = fPath(MSCfile) & "\" & MSCX.AltPath(i) + If fPath(MSCX.AltPath(i)) = Nothing Then MSCX.AltPath(i) = joinPaths(fPath(MSCfile), MSCX.AltPath(i)) fControlInput(MSCX.AltPath(i), 3, "csalt") If Not FileIO.FileSystem.FileExists(MSCX.AltPath(i)) Then - fInfWarErrBW(9, False, "Altitude correction = on, altitude file doesen´t exist: " & MSCX.AltPath(i)) + fInfWarErr(9, False, "Altitude correction = on, altitude file doesen´t exist: " & MSCX.AltPath(i)) BWorker.CancelAsync() Return False End If @@ -184,14 +116,14 @@ Public Module read_input 'Abort if there's no file If Datafile = "" OrElse Not IO.File.Exists(Datafile) Then - fInfWarErrBW(9, False, "Weather data file not found (" & Datafile & ") !") + fInfWarErr(9, False, "Weather data file not found (" & Datafile & ") !") BWorker.CancelAsync() Return False End If 'Open file If Not FileInWeather.OpenRead(Datafile) Then - fInfWarErrBW(9, False, "Failed to open file (" & Datafile & ") !") + fInfWarErr(9, False, "Failed to open file (" & Datafile & ") !") BWorker.CancelAsync() Return False End If @@ -216,7 +148,7 @@ Public Module read_input Else ' Check if component is already defined If WeathCheck(Comp) Then - fInfWarErrBW(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -232,7 +164,7 @@ Public Module read_input ' Check if all required data is given For Each sKVW In WeathCheck If Not WeathCheck(sKVW.Key) Then - fInfWarErrBW(9, False, "Missing signal for " & fCompName(sKVW.Key)) + fInfWarErr(9, False, "Missing signal for " & fCompName(sKVW.Key)) BWorker.CancelAsync() Return False End If @@ -253,7 +185,7 @@ Public Module read_input Next sKV Loop Catch ex As Exception - fInfWarErrBW(9, False, "Error during file read! Line number: " & tdim + 1 & " (" & Datafile & ")") + fInfWarErr(9, False, "Error during file read! Line number: " & tdim + 1 & " (" & Datafile & ")") BWorker.CancelAsync() Return False End Try @@ -308,14 +240,14 @@ Public Module read_input 'Abort if there's no file If Datafile = "" OrElse Not IO.File.Exists(Datafile) Then - fInfWarErrBW(9, False, "Measurement data file not found (" & Datafile & ") !") + fInfWarErr(9, False, "Measurement data file not found (" & Datafile & ") !") BWorker.CancelAsync() Return False End If 'Open file If Not FileInMeasure.OpenRead(Datafile) Then - fInfWarErrBW(9, False, "Failed to open file (" & Datafile & ") !") + fInfWarErr(9, False, "Failed to open file (" & Datafile & ") !") BWorker.CancelAsync() Return False End If @@ -354,7 +286,7 @@ Public Module read_input ' Check if the component is already defined If InputUndefData.ContainsKey(txt) Then - fInfWarErrBW(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -366,7 +298,7 @@ Public Module read_input Else ' Check if component is already defined If MeasCheck(Comp) Then - fInfWarErrBW(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) + fInfWarErr(9, False, "Component '" & Line(i) & "' already defined! Column " & i + 1) BWorker.CancelAsync() Return False End If @@ -385,7 +317,7 @@ Public Module read_input Select Case sKVM.Key Case tComp.trigger If MSCX.tUse Then - fInfWarErrBW(9, False, "No trigger signal detected, but trigger_used in MS config activated!") + fInfWarErr(9, False, "No trigger signal detected, but trigger_used in MS config activated!") BWorker.CancelAsync() Return False End If @@ -397,7 +329,7 @@ Public Module read_input Case tComp.user_valid valid_set = True Case Else - fInfWarErrBW(9, False, "Missing signal for " & fCompName(sKVM.Key)) + fInfWarErr(9, False, "Missing signal for " & fCompName(sKVM.Key)) BWorker.CancelAsync() Return False End Select @@ -420,7 +352,7 @@ Public Module read_input 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 ErrDat Then - fInfWarErrBW(9, False, "The input data is not recorded at " & HzIn & "Hz at line: " & JumpPoint & " and " & tDim) + fInfWarErr(9, False, "The input data is not recorded at " & HzIn & "Hz at line: " & JumpPoint & " and " & tDim) BWorker.CancelAsync() Return False Else @@ -435,7 +367,7 @@ Public Module read_input If Not ZoneChange Then If tDim > 1 Then If CalcData(tCompCali.zone_UTM).Last <> UTMCoord.Zone Then - fInfWarErrBW(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") + fInfWarErr(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") ZoneChange = True End If End If @@ -453,7 +385,7 @@ Public Module read_input If Not ZoneChange Then If tDim > 1 Then If CalcData(tCompCali.zone_UTM).Last <> UTMCoord.Zone Then - fInfWarErrBW(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") + fInfWarErr(8, False, "The coordinates lie in different UTM Zones. A zone adjustment will be done!") ZoneChange = True End If End If @@ -490,7 +422,7 @@ Public Module read_input Next Loop Catch ex As Exception - fInfWarErrBW(9, False, "Error during file read! Line number: " & tDim + 1 & " (" & Datafile & ")") + fInfWarErr(9, False, "Error during file read! Line number: " & tDim + 1 & " (" & Datafile & ")") BWorker.CancelAsync() Return False End Try @@ -513,7 +445,7 @@ Public Module read_input CalcData(tCompCali.longi_UTM)(i) = UTMCoord.Easting Next i If Zone1CentralMeridian > 180 Then - fInfWarErrBW(9, False, "The adjustment is not possible because the data lie to far away from each other to fit into one UTM stripe") + fInfWarErr(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 diff --git a/CSE/Export/output.vb b/CSE/IO/output.vb similarity index 53% rename from CSE/Export/output.vb rename to CSE/IO/output.vb index 610d9f84619b5dc93807af8929eb31d8adf5ffe8..89345d391cd6de2af41feb94cf7e0d8720ce4679 100644 --- a/CSE/Export/output.vb +++ b/CSE/IO/output.vb @@ -29,7 +29,7 @@ End If ' Write on GUI - fInfWarErrBW(5, False, "Writing output-file (*.csv)") + fInfWarErr(5, False, "Writing output-file (*.csv)") ' Generate the file name NameOutFile = "" @@ -80,7 +80,7 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErrBW(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True @@ -109,7 +109,7 @@ End If ' Write on GUI - fInfWarErrBW(5, False, "Writing result-file (*.csv)") + fInfWarErr(5, False, "Writing result-file (*.csv)") ' Generate the file name NameOutFile = OutFolder & fName(JobFile, False) & "_MS_CAL.csv" @@ -183,7 +183,7 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErrBW(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True @@ -210,7 +210,7 @@ End If ' Write on GUI - fInfWarErrBW(5, False, "Writing result-file (*.csv)") + fInfWarErr(5, False, "Writing result-file (*.csv)") ' Generate the file name NameOutFile = OutFolder & fName(JobFile, False) & "_CSE.csv" @@ -277,7 +277,7 @@ ' Ausgabe bei blockierter Datei If BWorker.CancellationPending And FileBlock Then - fInfWarErrBW(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") + fInfWarErr(9, False, "Can´t write in file " & NameOutFile & ". File is blocked by another process!") End If Return True @@ -483,4 +483,717 @@ AddToErg(tCompErgReg.t_tire_HS_min, fCompName(tCompErgReg.t_tire_HS_min), fCompUnit(tCompErgReg.t_tire_HS_min), "ErgValuesReg") AddToErg(tCompErgReg.t_tire_HS_max, fCompName(tCompErgReg.t_tire_HS_max), fCompUnit(tCompErgReg.t_tire_HS_max), "ErgValuesReg") End Sub + + ' Generate the output sequence for input data + Public Sub AddToErg(ByVal EnumID As tComp, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesI.ContainsKey(EnumID) Then + ErgEntriesI.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListI.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for undefined input data + Public Sub AddToErg(ByVal EnumID As String, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Dic = "InputUndefData" Then + If Not ErgEntriesIU.ContainsKey(EnumID) Then + ErgEntriesIU.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListIU.Add(EnumID) + End If + ElseIf Dic = "ErgValuesUndef" Then + If Not ErgEntriesRU.ContainsKey(EnumID) Then + ErgEntriesRU.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListRU.Add(EnumID) + End If + End If + End Sub + + ' Generate the output sequence for calculated data + Public Sub AddToErg(ByVal EnumID As tCompCali, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesC.ContainsKey(EnumID) Then + ErgEntriesC.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListC.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for calculated data + Public Sub AddToErg(ByVal EnumID As tCompErg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesR.ContainsKey(EnumID) Then + ErgEntriesR.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListR.Add(EnumID) + End If + End Sub + + ' Generate the output sequence for regression calculated data + Public Sub AddToErg(ByVal EnumID As tCompErgReg, ByVal Head As String, ByVal Unit As String, ByVal Dic As String) + If Not ErgEntriesReg.ContainsKey(EnumID) Then + ErgEntriesReg.Add(EnumID, New CResult(Head, Unit, Dic)) + ErgEntryListReg.Add(EnumID) + End If + End Sub + + ' Generate the head output string + Public Function ErgHead(ByVal Dic As String) As String + Dim s As New System.Text.StringBuilder + Dim key As String + Dim First As Boolean + + First = True + If Dic = "InputData" Then + For Each key In ErgEntryListI + If Not First Then s.Append(",") + s.Append(ErgEntriesI(key).Head) + First = False + Next + ElseIf Dic = "InputUndefData" Then + For Each key In ErgEntryListIU + If Not First Then s.Append(",") + s.Append(ErgEntriesIU(key).Head) + First = False + Next + ElseIf Dic = "CalcData" Then + For Each key In ErgEntryListC + If Not First Then s.Append(",") + s.Append(ErgEntriesC(key).Head) + First = False + Next + ElseIf Dic = "ErgValues" Then + For Each key In ErgEntryListR + If Not First Then s.Append(",") + s.Append(ErgEntriesR(key).Head) + First = False + Next + ElseIf Dic = "ErgValuesUndef" Then + For Each key In ErgEntryListRU + If Not First Then s.Append(",") + s.Append(ErgEntriesRU(key).Head) + First = False + Next + ElseIf Dic = "ErgValuesReg" Then + For Each key In ErgEntryListReg + If Not First Then s.Append(",") + s.Append(ErgEntriesReg(key).Head) + First = False + Next + End If + + Return s.ToString + End Function + + ' Generate the unit output string + Public Function ErgUnits(ByVal Dic As String) As String + Dim s As New System.Text.StringBuilder + Dim First As Boolean + Dim key As String + + First = True + If Dic = "InputData" Then + For Each key In ErgEntryListI + If Not First Then s.Append(",") + s.Append(ErgEntriesI(key).Unit) + First = False + Next + ElseIf Dic = "InputUndefData" Then + For Each key In ErgEntryListIU + If Not First Then s.Append(",") + s.Append(ErgEntriesIU(key).Unit) + First = False + Next + ElseIf Dic = "CalcData" Then + For Each key In ErgEntryListC + If Not First Then s.Append(",") + s.Append(ErgEntriesC(key).Unit) + First = False + Next + ElseIf Dic = "ErgValues" Then + For Each key In ErgEntryListR + If Not First Then s.Append(",") + s.Append(ErgEntriesR(key).Unit) + First = False + Next + ElseIf Dic = "ErgValuesUndef" Then + For Each key In ErgEntryListRU + If Not First Then s.Append(",") + s.Append(ErgEntriesRU(key).Unit) + First = False + Next + ElseIf Dic = "ErgValuesReg" Then + For Each key In ErgEntryListReg + If Not First Then s.Append(",") + s.Append(ErgEntriesReg(key).Unit) + First = False + Next + End If + + Return s.ToString + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tCompCali, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of tCompCali, List(Of Double)) + Dim KV As KeyValuePair(Of tCompCali, List(Of Double)) + Dim KVd As KeyValuePair(Of tCompCali, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of tCompCali, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = ValuesX(tCompCali.t) + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(tCompCali.t).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of tCompCali, List(Of Double)) + Summe = New Dictionary(Of tCompCali, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + If KV.Key <> tCompCali.t Then Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(tCompCali.t).Count - 1 + tEnd = fTime(ValuesX.Item(tCompCali.t).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'Conclude Second + NewValues(tCompCali.t).Add(tMid) + + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tCompCali.t Then Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + If KV.Key <> tCompCali.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByRef ValuesX As Dictionary(Of tComp, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of tComp, List(Of Double)) + Dim KV As KeyValuePair(Of tComp, List(Of Double)) + Dim KVd As KeyValuePair(Of tComp, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of tComp, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = ValuesX(tComp.t) + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(tComp.t).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of tComp, List(Of Double)) + Summe = New Dictionary(Of tComp, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + If KV.Key <> tComp.t Then Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(tComp.t).Count - 1 + tEnd = fTime(ValuesX.Item(tComp.t).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'Conclude Second + NewValues(tComp.t).Add(tMid) + + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + If KV.Key <> tComp.t Then Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function + + ' Convert the data to 1Hz + Public Function ConvTo1Hz(ByVal TimesX As List(Of Double), ByRef ValuesX As Dictionary(Of String, List(Of Double))) As Boolean + ' Declaration + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z, t0, tI, lauf, laufE, zEnd, pos As Integer + Dim Time As Double + Dim tEnd, tIns As Double + Dim Finish, Sprung As Boolean + Dim NewValues As Dictionary(Of String, List(Of Double)) + Dim KV As KeyValuePair(Of String, List(Of Double)) + Dim KVd As KeyValuePair(Of String, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of String, Double) + + ' Initialise + Sprung = False + tI = 0 + fTime = TimesX + + 'Check whether Time is not reversed + For z = 1 To ValuesX.Item(ValuesX.First.Key).Count - 1 + If fTime(z) < fTime(z - 1) Then + If Sprung Then + fInfWarErr(9, False, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]") + Return False + Else + Sprung = True + tI = z + End If + End If + Next z + + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + If Sprung Then tIns = fTime(tI - 1) + tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) + + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of String, List(Of Double)) + Summe = New Dictionary(Of String, Double) + + ' Generate the dictionary folder + For Each KV In ValuesX + NewValues.Add(KV.Key, New List(Of Double)) + Summe.Add(KV.Key, 0) + Next + + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + ' Initialise + Anz = 0 + Finish = False + If Sprung Then + laufE = 2 + Else + laufE = 1 + End If + + For lauf = 1 To laufE + ' Set the time range (If a jump is detected to the calculation till the jump) + If Sprung And lauf = 1 Then + tEnd = tIns + zEnd = tI - 1 + pos = 0 + Else + pos = tI + zEnd = ValuesX.Item(ValuesX.First.Key).Count - 1 + tEnd = fTime(ValuesX.Item(ValuesX.First.Key).Count - 1) + + If Sprung Then + ' Initialise + Anz = 0 + Finish = False + + 'Start-values + tMin = fTime(pos) + tMid = CInt(tMin) + tMax = tMid + 0.5 + + If fTime(pos) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + 'New Sum /Num no start + For Each KV In ValuesX + Summe(KV.Key) = 0 + Next + End If + End If + + For z = pos To zEnd + 'Next Time-step + Time = fTime(z) + + 'If Time-step > tMax: + Do While (Time >= tMax Or z = zEnd) + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + If Time = tMax Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + ValuesX(KVd.Key)(z)) / (Anz + 1)) + Next + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then + + If z < 2 OrElse fTime(z - 1) < tMid Then + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (ValuesX(KVd.Key)(z) - ValuesX(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + ValuesX(KVd.Key)(z - 1)) + Next + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (ValuesX(KVd.Key)(z - 1) - ValuesX(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + ValuesX(KVd.Key)(z - 2)) + Next + End If + + Else + + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next + End If + End If + End If + + If Not Finish Then + + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + + 'Check whether last second + If tMax > tEnd Then + tMax = tEnd + Finish = True + End If + + 'New Sum /Num no start + For Each KV In ValuesX + Summe(KV.Key) = 0 + Next + Anz = 0 + End If + + ' Exit while after the last calculation + If Finish And z = zEnd Then + Exit Do + End If + Loop + + For Each KV In ValuesX + Summe(KV.Key) += ValuesX(KV.Key)(z) + Next + + Anz = Anz + 1 + Next z + Next lauf + + 'Accept New fields + ValuesX = NewValues + + Return True + End Function End Module diff --git a/CSE/My Project/Application.Designer.vb b/CSE/My Project/Application.Designer.vb index dbe40a078b3953a65baca27ec701dd349ced8801..f72be664ffb15fdba9c503bb58aa2f004be614a2 100644 --- a/CSE/My Project/Application.Designer.vb +++ b/CSE/My Project/Application.Designer.vb @@ -32,7 +32,7 @@ Namespace My <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.CSE.CSEMain + Me.MainForm = Global.CSE.F_Main End Sub End Class End Namespace diff --git a/CSE/My Project/Application.myapp b/CSE/My Project/Application.myapp index 300a59a69d3dfa031b7c6288a1a794394c272133..9dc3c437e42518c8a44d9f8cef11b881544882c8 100644 --- a/CSE/My Project/Application.myapp +++ b/CSE/My Project/Application.myapp @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-16"?> <MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <MySubMain>true</MySubMain> - <MainForm>CSEMain</MainForm> + <MainForm>F_Main</MainForm> <SingleInstance>false</SingleInstance> <ShutdownMode>0</ShutdownMode> <EnableVisualStyles>true</EnableVisualStyles> diff --git a/CSE/My Project/Settings.Designer.vb b/CSE/My Project/Settings.Designer.vb index 1eae091cc3de99b68b1aede8db34ee66ee4b60c1..7dad854a95ce9e6dd90d61705bfc0e3264b0e730 100644 --- a/CSE/My Project/Settings.Designer.vb +++ b/CSE/My Project/Settings.Designer.vb @@ -53,6 +53,18 @@ Namespace My Return defaultInstance End Get End Property + + <Global.System.Configuration.UserScopedSettingAttribute(), _ + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ + Global.System.Configuration.DefaultSettingValueAttribute("0, 0")> _ + Public Property F_Main_location() As Global.System.Drawing.Point + Get + Return CType(Me("F_Main_location"),Global.System.Drawing.Point) + End Get + Set + Me("F_Main_location") = value + End Set + End Property End Class End Namespace diff --git a/CSE/My Project/Settings.settings b/CSE/My Project/Settings.settings index 85b890b3c66b9beee248abaddd2ec71f8b1df2b2..0fe4a001e405f6037d0cfd69b9defb489742185e 100644 --- a/CSE/My Project/Settings.settings +++ b/CSE/My Project/Settings.settings @@ -1,7 +1,9 @@ <?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true"> - <Profiles> - <Profile Name="(Default)" /> - </Profiles> - <Settings /> -</SettingsFile> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true"> + <Profiles /> + <Settings> + <Setting Name="F_Main_location" Type="System.Drawing.Point" Scope="User"> + <Value Profile="(Default)">0, 0</Value> + </Setting> + </Settings> +</SettingsFile> \ No newline at end of file diff --git a/CSE/Settings.vb b/CSE/Settings.vb new file mode 100644 index 0000000000000000000000000000000000000000..94ac0c7ac39c3d8a1a715b7dd1c99f9e6dcb9514 --- /dev/null +++ b/CSE/Settings.vb @@ -0,0 +1,11 @@ + +Namespace My + + 'This class allows you to handle specific events on the settings class: + ' The SettingChanging event is raised before a setting's value is changed. + ' The PropertyChanged event is raised after a setting's value is changed. + ' The SettingsLoaded event is raised after the setting values are loaded. + ' The SettingsSaving event is raised before the setting values are saved. + Partial Friend NotInheritable Class MySettings + End Class +End Namespace diff --git a/CSE/cSemanticVersion.vb b/CSE/cSemanticVersion.vb new file mode 100644 index 0000000000000000000000000000000000000000..c1944642fd76f2afa3cfcc2c353feb5a63252ce1 --- /dev/null +++ b/CSE/cSemanticVersion.vb @@ -0,0 +1,537 @@ +''----------------------------------------------------------------------------- +'' <copyright file="SemanticVersion.cs" company="ImaginaryRealities"> +'' Copyright 2013 ImaginaryRealities, LLC +'' </copyright> +'' <summary> +'' This file implements the SemanticVersion class. The SemanticVersion class +'' represents a semantic version number for a program. +'' </summary> +'' <license> +'' Permission is hereby granted, free of charge, to any person obtaining a copy +'' of this software and associated documentation files (the "Software"), to +'' deal in the Software without restriction, including but without limitation +'' the rights to use, copy, modify, merge, publish, distribute, sublicense, +'' and/or sell copies of the Software, and to permit persons to whom the +'' Software is furnished to do so, subject to the following conditions: +'' +'' The above copyright notice and this permission notice shall be included in +'' all copies or substantial portions of the Software. +'' +'' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +'' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +'' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +'' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +'' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +'' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +'' IN THE SOFTWARE. +'' </license> +''----------------------------------------------------------------------------- +'' +'' Copied from: http://www.michaelfcollins3.me/blog/2013/01/23/semantic_versioning_dotnet.html +'' github: https://gist.github.com/mfcollins3/4624831 +'' Adapted to VB.net by ankostis@gmail.com + + +Imports System +Imports System.Diagnostics.CodeAnalysis +Imports System.Globalization +Imports System.Text.RegularExpressions +'Imports System.Diagnostics.Contracts + +''' <summary> +''' Stores a semantic version number for a program. +''' </summary> +<Serializable()> +Public NotInheritable Class cSemanticVersion + Implements IComparable, IComparable(Of cSemanticVersion), IEquatable(Of cSemanticVersion) + + ''' <summary> + ''' A regular expression to detect whether a string contains only + ''' digits. + ''' </summary> + Private Shared ReadOnly AllDigitsRegex As New Regex("^[0-9]+$", RegexOptions.Compiled Or RegexOptions.Singleline) + + ''' <summary> + ''' A regular expression to detect whether a string contains only + ''' digits. + ''' </summary> + Private Shared ReadOnly AlphaRegex As New Regex("^[A-Za-z0-9\-\.]+$", RegexOptions.Compiled Or RegexOptions.Singleline) + + ''' <summary> + ''' The regular expression to use to parse a "strict" semantic version number. + ''' </summary> + Private Shared ReadOnly SemanticVersionRegex As New Regex( _ + "^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<prerelease>[A-Za-z0-9\-\.]+))?(\+(?<build>[A-Za-z0-9\-\.]+))?$", _ + RegexOptions.Compiled Or RegexOptions.Singleline) + + ' ''' <summary> + ' ''' A utility regex used to parse loose version-strings to semantic-versions. + ' ''' </summary> + ' ''' <remarks>See http://search.cpan.org/dist/SemVer/lib/SemVer.pm</remarks> + 'Private Shared ReadOnly regex_1stPart As New Regex( _ + ' "^\s*(?:v(?:e(?:r(?:s(?:i(?:o(?:n)?)?)?)?)?)?)?\s*(?<major>\d+)(?:\.(?<nums>\d+))*(?<prerelease>[^+ ]+)?(\+(?<build>\S+))?", _ + ' RegexOptions.Compiled Or RegexOptions.Singleline, RegexOptions.IgnoreCase`) + + 'Public Shared Function parse(ByVal version As String) As cSemanticVersion + 'End Function + + + ''' <summary> + ''' Initializes a new instance of the <see cref="cSemanticVersion"/> class. + ''' </summary> + ''' <param name="version"> + ''' The semantic version number to be parsed. + ''' </param> + Public Sub New(ByVal version As String) + 'Contract.Requires(Of ArgumentException)(Not String.IsNullOrEmpty(version)) + 'Contract.Ensures(0 <= Me.MajorVersion) + 'Contract.Ensures(0 <= Me.MinorVersion) + 'Contract.Ensures(0 <= Me.PatchVersion) + 'Contract.Ensures(AlphaRegex.Match(Me.PrereleaseVersion).Success) + 'Contract.Ensures(AlphaRegex.Match(Me.BuildVersion).Success) + + Dim match = SemanticVersionRegex.Match(version) + If (Not match.Success) Then + Throw New ArgumentException(String.Format("Invalid Version-string({0})!", version)) + End If + + Me.MajorVersion = Integer.Parse(match.Groups("major").Value, CultureInfo.InvariantCulture) + Me.MinorVersion = Integer.Parse(match.Groups("minor").Value, CultureInfo.InvariantCulture) + Me.PatchVersion = Integer.Parse(match.Groups("patch").Value, CultureInfo.InvariantCulture) + If match.Groups("prerelease").Success Then + Me.PrereleaseVersion = match.Groups("prerelease").Value + End If + If match.Groups("build").Success Then + Me.BuildVersion = match.Groups("build").Value + End If + End Sub + + ''' <summary> + ''' Initializes a new instance of the <see cref="cSemanticVersion"/> class. + ''' </summary> + ''' <param name="majorVersion"> + ''' The major version number. + ''' </param> + ''' <param name="minorVersion"> + ''' The minor version number. + ''' </param> + ''' <param name="patchVersion"> + ''' The patch version number. + ''' </param> + Public Sub New(ByVal majorVersion As Integer, ByVal minorVersion As Integer, ByVal patchVersion As Integer, Optional ByVal prereleaseVersion As String = Nothing, Optional ByVal buildVersion As String = Nothing) + 'Contract.Requires(Of ArgumentException)(0 <= majorVersion) + 'Contract.Requires(Of ArgumentException)(0 <= minorVersion) + 'Contract.Requires(Of ArgumentException)(0 <= patchVersion) + 'Contract.Ensures(0 <= Me.MajorVersion) + 'Contract.Ensures(0 <= Me.MinorVersion) + 'Contract.Ensures(0 <= Me.PatchVersion) + + Me.MajorVersion = majorVersion + Me.MinorVersion = minorVersion + Me.PatchVersion = patchVersion + Me.PrereleaseVersion = prereleaseVersion + Me.BuildVersion = buildVersion + End Sub + + + ''' <summary> + ''' Gets the build number. + ''' </summary> + ''' <value> + ''' The value of this property is a string containing the build + ''' identifier for the version number. + ''' </value> + Public Property BuildVersion As String + + ''' <summary> + ''' Gets the major version number. + ''' </summary> + ''' <value> + ''' The value of this property is a non-negative integer for the major + ''' version number. + ''' </value> + Public Property MajorVersion As Integer + + ''' <summary> + ''' Gets the minor version number. + ''' </summary> + ''' <value> + ''' The value of this property is a non-negative integer for the minor + ''' version number. + ''' </value> + Public Property MinorVersion As Integer + + ''' <summary> + ''' Gets the patch version number. + ''' </summary> + ''' <value> + ''' The value of this property is a non-negative integer for the patch + ''' version number. + ''' </value> + Public Property PatchVersion As Integer + + ''' <summary> + ''' Gets the pre-release version component. + ''' </summary> + ''' <value> + ''' The value of this property is a string containing the pre-release + ''' identifier. + ''' </value> + Public Property PrereleaseVersion As String + + ''' <summary> + ''' Compares two <see cref="cSemanticVersion"/> objects for equality. + ''' </summary> + ''' <param name="version"> + ''' The first <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <param name="other"> + ''' The second semantic version object to compare. + ''' </param> + ''' <returns> + ''' <b>True</b> if the objects are equal, or <b>false</b> if the + ''' objects are not equal. + ''' </returns> + Public Shared Operator =(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + If (version Is Nothing) Then Return other Is Nothing + + Return version.Equals(other) + End Operator + + ''' <summary> + ''' Compares two <see cref="cSemanticVersion"/> objects for equality. + ''' </summary> + ''' <param name="version"> + ''' The first <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <param name="other"> + ''' The second <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <returns> + ''' <b>True</b> if the objects are not equal, or <b>false</b> if the + ''' objects are equal. + ''' </returns> + Public Shared Operator <>(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + If (version Is Nothing) Then Return Not other Is Nothing + + Return Not version.Equals(other) + End Operator + + ''' <summary> + ''' Compares two <see cref="cSemanticVersion"/> objects to determine if + ''' the first object logically precedes the second object. + ''' </summary> + ''' <param name="version"> + ''' The first <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <param name="other"> + ''' The second <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <returns> + ''' <b>True</b> if <paramref name="version"/> precedes + ''' <paramref name="other"/>, otherwise <b>false</b>. + ''' </returns> + Public Shared Operator <(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + 'Contract.Requires(Of ArgumentNullException)(other IsNot Nothing) + + Return 0 > version.CompareTo(other) + End Operator + Public Shared Operator <=(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + 'Contract.Requires(Of ArgumentNullException)(other IsNot Nothing) + + Return 0 >= version.CompareTo(other) + End Operator + + ''' <summary> + ''' Compares two <see cref="cSemanticVersion"/> object to determine if + ''' the first object logically precedes the second object. + ''' </summary> + ''' <param name="version"> + ''' The first <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <param name="other"> + ''' The second <see cref="cSemanticVersion"/> object to compare. + ''' </param> + ''' <returns> + ''' <b>True</b> if <paramref name="version"/> follows + ''' <paramref name="other"/>, otherwise <b>false</b>. + ''' </returns> + Public Shared Operator >(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + + Return 0 < version.CompareTo(other) + End Operator + Public Shared Operator >=(ByVal version As cSemanticVersion, ByVal other As cSemanticVersion) As Boolean + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + 'Contract.Requires(Of ArgumentNullException)(version IsNot Nothing) + + Return 0 <= version.CompareTo(other) + End Operator + + ''' <summary> + ''' Compares two objects. + ''' </summary> + ''' <param name="obj"> + ''' The object to compare to this object. + ''' </param> + ''' <returns> + ''' Returns a value that indicates the relative order of the objects + ''' that are being compared. + ''' <list type="table"> + ''' <listheader> + ''' <term>Value</term> + ''' <description>Meaning</description> + ''' </listheader> + ''' <item> + ''' <term>Less than zero</term> + ''' <description> + ''' This instance precedes <paramref name="obj"/> in the sort order. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Zero</term> + ''' <description> + ''' This instance occurs in the same position in the sort order as + ''' <paramref name="obj"/>. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Greater than zero</term> + ''' <description> + ''' This instance follows <paramref name="obj"/> in the sort order. + ''' </description> + ''' </item> + ''' </list> + ''' </returns> + ''' <exception cref="ArgumentException"> + ''' <paramref name="obj"/> is not a <see cref="cSemanticVersion"/> + ''' object. + ''' </exception> + Public Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo + If obj Is Nothing Then Throw New ArgumentNullException("Other Object is Null!") + If Not TypeOf obj Is cSemanticVersion Then Throw New ArgumentException(String.Format("Other Object({0}) is not a SemanticVersion!", obj)) + + Return Me.CompareTo(DirectCast(obj, cSemanticVersion)) + End Function + + ''' <summary> + ''' Compares the current object with another + ''' <see cref="cSemanticVersion"/> object. + ''' </summary> + ''' <param name="other"> + ''' The other <see cref="cSemanticVersion"/> object to compare to this + ''' instance. + ''' </param> + ''' <returns> + ''' Returns a value that indicates the relative order of the objects + ''' that are being compared. + ''' <list type="table"> + ''' <listheader> + ''' <term>Value</term> + ''' <description>Meaning</description> + ''' </listheader> + ''' <item> + ''' <term>Less than zero</term> + ''' <description> + ''' This instance precedes <paramref name="other"/> in the sort order. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Zero</term> + ''' <description> + ''' This instance occurs in the same position in the sort order as + ''' <paramref name="other"/>. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Greater than zero</term> + ''' <description> + ''' This instance follows <paramref name="other"/> in the sort order. + ''' </description> + ''' </item> + ''' </list> + ''' </returns> + Public Function CompareTo(ByVal other As cSemanticVersion) As Integer Implements IComparable(Of CSE.cSemanticVersion).CompareTo + If (other Is Nothing) Then Throw New ArgumentNullException("other") + + If (other Is Me) Then Return 0 + + Dim result = Me.MajorVersion.CompareTo(other.MajorVersion) + If (0 = result) Then + result = Me.MinorVersion.CompareTo(other.MinorVersion) + If (0 = result) Then + result = Me.PatchVersion.CompareTo(other.PatchVersion) + If (0 = result) Then + result = ComparePrereleaseVersions(Me.PrereleaseVersion, other.PrereleaseVersion) + End If + End If + End If + + Return result + End Function + + ''' <summary> + ''' Compares this instance to another object for equality. + ''' </summary> + ''' <param name="obj"> + ''' The object to compare to this instance. + ''' </param> + ''' <returns> + ''' <b>True</b> if the objects are equal, or <b>false</b> if the + ''' objects are not equal. + ''' </returns> + Public Overrides Function Equals(ByVal obj As Object) As Boolean + If (obj Is Nothing) Then Return False + If (obj Is Me) Then Return True + If (Not TypeOf obj Is cSemanticVersion) Then Return False + + Return Me.Equals(DirectCast(obj, cSemanticVersion)) + End Function + + ''' <summary> + ''' Compares this instance to another <see cref="cSemanticVersion"/> + ''' object for equality. + ''' </summary> + ''' <param name="other"> + ''' The <see cref="cSemanticVersion"/> object to compare to this + ''' instance. + ''' </param> + ''' <returns> + ''' <b>True</b> if the objects are equal, or false if the objects are + ''' not equal. + ''' </returns> + Public Overloads Function Equals(ByVal other As cSemanticVersion) As Boolean Implements IEquatable(Of CSE.cSemanticVersion).Equals + If (other Is Me) Then Return True + + If (other Is Nothing) Then Return False + + Return Me.MajorVersion = other.MajorVersion AndAlso Me.MinorVersion = other.MinorVersion _ + AndAlso Me.PatchVersion = other.PatchVersion AndAlso Me.PrereleaseVersion = other.PrereleaseVersion _ + AndAlso Me.BuildVersion = other.BuildVersion + End Function + + + ''' <summary> + ''' Calculates the hash code for the object. + ''' </summary> + ''' <returns> + ''' The hash code for the object. + ''' </returns> + Public Overrides Function GetHashCode() As Integer + Dim hashCode = 17 + hashCode = (hashCode * 37) + Me.MajorVersion + hashCode = (hashCode * 37) + Me.MinorVersion + hashCode = (hashCode * 37) + Me.PatchVersion + If Me.PrereleaseVersion IsNot Nothing Then + hashCode = (hashCode * 37) + Me.PrereleaseVersion.GetHashCode() + End If + + If Me.BuildVersion IsNot Nothing Then + hashCode = (hashCode * 37) + Me.BuildVersion.GetHashCode() + End If + Return hashCode + End Function + + ''' <summary> + ''' Returns the string representation of the semantic version number. + ''' </summary> + ''' <returns> + ''' The semantic version number. + ''' </returns> + Public Overrides Function ToString() As String + Return String.Format( + CultureInfo.InvariantCulture, + "{0}.{1}.{2}{3}{4}", + Me.MajorVersion, + Me.MinorVersion, + Me.PatchVersion, + IIf(String.IsNullOrEmpty(Me.PrereleaseVersion), String.Empty, "-" + Me.PrereleaseVersion), + IIf(String.IsNullOrEmpty(Me.BuildVersion), String.Empty, "+" + Me.BuildVersion)) + End Function + + ''' <summary> + ''' Compares two build version values to determine precedence. + ''' </summary> + ''' <param name="identifier1"> + ''' The first identifier to compare. + ''' </param> + ''' <param name="identifier2"> + ''' The second identifier to compare. + ''' </param> + ''' <returns> + ''' Returns a value that indicates the relative order of the objects + ''' that are being compared. + ''' <list type="table"> + ''' <listheader> + ''' <term>Value</term> + ''' <description>Meaning</description> + ''' </listheader> + ''' <item> + ''' <term>Less than zero</term> + ''' <description> + ''' <paramref name="identifier1"/> precedes + ''' <paramref name="identifier2"/> in the sort order. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Zero</term> + ''' <description> + ''' The identifiers occur in the same position in the sort order. + ''' </description> + ''' </item> + ''' <item> + ''' <term>Greater than zero</term> + ''' <description> + ''' <paramref name="identifier1"/> follows + ''' <paramref name="identifier2"/> in the sort order. + ''' </description> + ''' </item> + ''' </list> + ''' </returns> + Private Shared Function ComparePrereleaseVersions(ByVal identifier1 As String, ByVal identifier2 As String) As Integer + Dim result As Integer = 0 + Dim hasIdentifier1 = Not String.IsNullOrEmpty(identifier1) + Dim hasIdentifier2 = Not String.IsNullOrEmpty(identifier2) + If (hasIdentifier1 AndAlso Not hasIdentifier2) Then + result = -1 + ElseIf (Not hasIdentifier1 AndAlso hasIdentifier2) Then + result = 1 + ElseIf (hasIdentifier1) Then + Dim dotDelimiter As Char() = {"."c} + Dim parts1 = identifier1.Split(dotDelimiter, StringSplitOptions.RemoveEmptyEntries) + Dim parts2 = identifier2.Split(dotDelimiter, StringSplitOptions.RemoveEmptyEntries) + Dim max = Math.Max(parts1.Length, parts2.Length) + For i = 0 To max + If (i = parts1.Length AndAlso i <> parts2.Length) Then + result = -1 + Exit For + End If + + If (i <> parts1.Length AndAlso i = parts2.Length) Then + result = 1 + Exit For + End If + + Dim part1 = parts1(i) + Dim part2 = parts2(i) + If (AllDigitsRegex.IsMatch(part1) AndAlso AllDigitsRegex.IsMatch(part2)) Then + Dim value1 = Integer.Parse(part1, CultureInfo.InvariantCulture) + Dim value2 = Integer.Parse(part2, CultureInfo.InvariantCulture) + result = value1.CompareTo(value2) + Else + result = String.Compare(part1, part2, StringComparison.Ordinal) + + If (0 <> result) Then + Exit For + End If + End If + Next + End If + + Return result + End Function + +End Class diff --git a/CSE/declaration_public.vb b/CSE/declaration_public.vb index 9eabd9eb44d75ac45587f05dfa4f4d44794baaa1..1dd8656df05a94245aac18a6557ba08d65ae4109 100644 --- a/CSE/declaration_public.vb +++ b/CSE/declaration_public.vb @@ -2,7 +2,7 @@ ' Description of the form Public Const AppName As String = "VECTO_CSE" ' Name of the programm - Public Const AppVers As String = "2.0.1-pre0" ' Version of the Programm + Public Const AppVers As String = "2.0.1-pre1" ' Version of the Programm Public AppDate As String ' Date of the compilation of the programm ' Control variables @@ -87,8 +87,9 @@ Public AccC As Boolean = False ' Variable for the acceleration correction Public GradC As Boolean = False ' Variable for the gradient correction - Public AppSettingsFName As String = "settings.json" - Public AppSettings As cSettings + + Public PreferencesPath As String + Public AppPreferences As cPreferences 'File browser Public FB_Drives() As String diff --git a/CSE/Tools/Minor_routines.vb b/CSE/utils.vb similarity index 50% rename from CSE/Tools/Minor_routines.vb rename to CSE/utils.vb index 2debd428367e1eafdeabdfaa0461a9a903fa8885..3d6ae3ba06e42ed915b07e828594e01aa02bf41d 100644 --- a/CSE/Tools/Minor_routines.vb +++ b/CSE/utils.vb @@ -3,11 +3,37 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Schema Imports System.Text.RegularExpressions -Module Minor_routines +Module utils - ' Functions for the identification from the fileend, -name and for the path identification + ''' <summary> + ''' Utility to check compatibility when reading files, ie 1.0.1-somePre is compatible with [1.0.0--, 2.0.0--) + ''' </summary> + ''' <param name="checkVersion">the version under investigation</param> + ''' <param name="fromVersion">inclusive</param> + ''' <param name="toVersion">exclusive</param> + ''' <returns>true if fromVersion <= checkVersion < toVersion </returns> + ''' <remarks> + ''' All version-strings must be, syntactically, valid as Semantic-versions (see http://semver.org/). + ''' Note that the earliest pre-release segment is the dash('-'), so 1.0.0-- is the earliest possible version from 1.x release train. + ''' </remarks> + Function IsSemanticVersionsSupported(ByVal checkVersion As String, ByVal fromVersion As String, Optional ByVal toVersion As String = Nothing) As Boolean + + Dim cver As New cSemanticVersion(checkVersion) + Dim fver As New cSemanticVersion(fromVersion) + + If toVersion Is Nothing Then + Return fver <= cver + Else + Dim tver As New cSemanticVersion(toVersion) + Return fver <= cver AndAlso cver < tver + End If + + End Function + + + +#Region "File paths" ' Functions for the identification from the fileend, -name and for the path identification -#Region "File paths" ' Identification from the filename Public Function fName(ByVal Pfad As String, ByVal MitEndung As Boolean) As String Dim x As Int16 @@ -16,8 +42,9 @@ Module Minor_routines Pfad = Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) If Not MitEndung Then - x = Pfad.LastIndexOf(".") - If x > 0 Then Pfad = Microsoft.VisualBasic.Left(Pfad, x) + Dim ext = fEXT(Pfad) + + Pfad = Pfad.Remove(Pfad.Length - ext.Length) End If Return Pfad @@ -34,17 +61,16 @@ Module Minor_routines Return Microsoft.VisualBasic.Left(Pfad, x) End Function - ' Identification from the filenend + ' Identification from the filenend, including dot('.') Public Function fEXT(ByVal Pfad As String) As String - Dim x As Int16 - - x = Pfad.LastIndexOf(".") + Dim ext = IO.Path.GetExtension(Pfad) - If x = -1 Then - Return "" - Else - Return Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x - 1) + If ext.Equals(".json", StringComparison.OrdinalIgnoreCase) Then + Dim prevExt = IO.Path.GetExtension(Pfad.Remove(Pfad.Length - 5)) ' 5 = ".json".Length + ext = prevExt & ext End If + + Return ext End Function @@ -135,145 +161,174 @@ Module Minor_routines #End Region ' Functions for the information depiction on the GUI with the backgroundworker (Info, Warning, Error) -#Region " Communication functions" - ' Output from Informations\Warnings\Errors on the GUI - Function fInfWarErr(ByVal Style As Integer, ByVal MsgBoxOut As Boolean, ByVal text As String) As Boolean +#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, _ + ByVal text As String, Optional ByVal ex As Exception = Nothing) + ' Declaration - Dim Styletext As String = "" - Dim StyleOut As String = "" + Dim tabLabel = "Debug" + Dim logFileLevel As Integer = 0 + Dim StyleOut = MsgBoxStyle.Information ' Identify the output style - Select Case Style - Case 0 To 7 ' Info - Styletext = "Info" - StyleOut = MsgBoxStyle.Information + Select Case logLevel + Case 5 To 7 ' Info + logFileLevel = 1 + tabLabel = "Info" Case 8 ' Warning - Styletext = "Warning" + logFileLevel = 2 + tabLabel = "Warning" StyleOut = MsgBoxStyle.Exclamation Case 9 ' Error - Styletext = "Error" + logFileLevel = 3 + tabLabel = "Error" StyleOut = MsgBoxStyle.Critical End Select - ' Output as an messagebox or on the tabcontrols + ' Write to Log-file. + fWriteLog(2, logFileLevel, text, ex) + + '' Print only filtered msgs in log-window + '' + If logLevel >= AppPreferences.logLevel Then + Dim wintext = AnzeigeMessage(logLevel) & text + If BWorker.IsBusy Then + '' If in Worker-thread, update GUI through a ProgressChanged event + '' + Dim WorkerMsg As New cLogMsg(logFileLevel, MsgBoxOut, wintext, ex, tabLabel) + BWorker.ReportProgress(0, WorkerMsg) + Else + updateLogWindow(logFileLevel, wintext, tabLabel) + End If + End If + + '' Output as an messagebox (if requested) + '' If MsgBoxOut Then ' Output in a MsgBox If RestartN Then ' By changes in the confic use other output RestartN = False - If MsgBox(text, MsgBoxStyle.YesNo, Styletext) = MsgBoxResult.Yes Then + If MsgBox(text, MsgBoxStyle.YesNo, tabLabel) = MsgBoxResult.Yes Then RestartN = True - CSEMain.Close() + F_Main.Close() End If Else - MsgBox(text, StyleOut, Styletext) + MsgBox(text, StyleOut, tabLabel) End If - Else - ' Polling the MSG if the message should shown - If Style <= AppSettings.LogLevel Then Return True - - ' Established the text wit the symbol from the style - text = AnzeigeMessage(Style) & text - - ' Output in the AppSettings.WriteLog - Select Case Style - Case 0 To 7 ' Message - CSEMain.ListBoxMSG.Items.Add(text) - If AppSettings.WriteLog Then fWriteLog(2, 4, text) ' Write in the AppSettings.WriteLog - Case 8 ' Warning - CSEMain.ListBoxWar.Items.Add(text) - CSEMain.TabPageWar.Text = Styletext & " (" & CSEMain.ListBoxWar.Items.Count & ")" - If AppSettings.WriteLog Then fWriteLog(2, 2, text) ' Write in the AppSettings.WriteLog - Case 9 ' Error - CSEMain.ListBoxErr.Items.Add(text) - CSEMain.TabPageErr.Text = Styletext & " (" & CSEMain.ListBoxErr.Items.Count & ")" - CSEMain.TabControlOutMsg.SelectTab(2) - If AppSettings.WriteLog Then fWriteLog(2, 3, text) ' Write in the AppSettings.WriteLog - End Select End If + End Sub + + Private Sub updateLogWindow(ByVal logFileLevel As Integer, ByVal text As String, ByVal tabLabel As String) + ' Established the text wit the symbol from the style + + ' 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 & ")" + 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) + Case Else + '' ignored + End Select ' Set the Scrollbars in the Listboxes at the end - CSEMain.ListBoxMSG.TopIndex = CSEMain.ListBoxMSG.Items.Count - 1 - CSEMain.ListBoxWar.TopIndex = CSEMain.ListBoxWar.Items.Count - 1 - CSEMain.ListBoxErr.TopIndex = CSEMain.ListBoxErr.Items.Count - 1 + F_Main.ListBoxMSG.TopIndex = F_Main.ListBoxMSG.Items.Count - 1 + F_Main.ListBoxWar.TopIndex = F_Main.ListBoxWar.Items.Count - 1 + F_Main.ListBoxErr.TopIndex = F_Main.ListBoxErr.Items.Count - 1 - ' Return that the program have an error - If Style = 9 Then - Return False - Else - Return True - End If + End Sub - End Function ' Definition for the Backgroundworker - Public Class CMsg - Public Styletext As String - Public Style As Integer - Public Text As String + Class cLogMsg + Private LogLevel As Integer + Private Text As String + Private Ex As Exception + Private MsgBoxOut As Boolean = False + Private TabLabel + + Public Sub New(ByVal logLevel As Integer, ByVal msgBoxOut As Boolean, ByVal text As String, _ + ByVal ex As Exception, Optional ByVal TabLabel As String = "") + Me.LogLevel = logLevel + Me.MsgBoxOut = msgBoxOut + Me.Text = text + Me.Ex = ex + End Sub + + ' Call for the output from Informations\Warnings\Errors with the backgoundworker + Public Sub forwardLog() + updateLogWindow(LogLevel, Text, TabLabel) + End Sub End Class - ' Output from Informations\Warnings\Errors with the Backgoundworker - Function fInfWarErrBW(ByVal Style As Integer, ByVal MsgBoxOut As Boolean, ByVal text As String) As Boolean - ' Declaration - Dim WorkerMsg As New CMsg + Private logDateFrmt As String = "yyyy/MM/dd HH:mm:ss zzz" - WorkerMsg.Style = Style - WorkerMsg.Text = text + ''' <summary>Format and write log-mesages to file.</summary> + ''' <param name="eventType">1: Session started, 2: Add log, 3: Session ended</param> + 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 - ' Identify the output style - Select Case Style - Case 0 To 7 ' Info - WorkerMsg.Styletext = "Info" - Case 8 ' Warning - WorkerMsg.Styletext = "Warning" - Case 9 ' Error - WorkerMsg.Styletext = "Error" - End Select + If Not AppPreferences.writeLog Then Return True - ' Polling the MSG if the message should shown - If Style <= AppSettings.LogLevel Then Return True + Dim LogFilenam As String = joinPaths(MyPath, "log.txt") - ' Output in the Tabcontrols (Call from Backgroundworker_ProgressChanged) - BWorker.ReportProgress(0, WorkerMsg) + If eventType = 1 Then + logLevel = 1 + text = "Session started: " & AppName & " " & AppVers - ' Return that the program have an error - If Style = 9 Then - Return (False) - Else - Return True + '' 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 + fLoeschZeilen(LogFilenam, System.IO.File.ReadAllLines(LogFilenam).Length / 2) + End If + ElseIf eventType = 3 Then + logLevel = 1 + text = "Session finished: " & AppName & " " & AppVers End If - End Function + Dim slevel As String + Select Case logLevel + Case 1 + slevel = "INFO" + Case 2 + slevel = "WARN" + Case 3 + slevel = "ERROR" + Case Else + slevel = "DEBUG" + End Select - ' Call for the output from Informations\Warnings\Errors with the backgoundworker - Sub MsgToForm(ByVal Styletext As String, ByVal Style As Integer, ByVal Text As String) - ' Established the text wit the symbol from the style - If Not Style = 10 Then Text = AnzeigeMessage(Style) & Text - ' Output in the Tabcontrols on the GUI - Select Case Style - Case 0 To 7 ' Message - CSEMain.ListBoxMSG.Items.Add(Text) - If AppSettings.WriteLog Then fWriteLog(2, 4, Text) ' Write into AppSettings.WriteLog - Case 8 ' Warning - CSEMain.ListBoxWar.Items.Add(Text) - CSEMain.TabPageWar.Text = Styletext & " (" & CSEMain.ListBoxWar.Items.Count & ")" - If AppSettings.WriteLog Then fWriteLog(2, 2, Text) ' Write into AppSettings.WriteLog - Case 9 ' Error - CSEMain.ListBoxErr.Items.Add(Text) - CSEMain.TabPageErr.Text = Styletext & " (" & CSEMain.ListBoxErr.Items.Count & ")" - CSEMain.TabControlOutMsg.SelectTab(2) - If AppSettings.WriteLog Then fWriteLog(2, 3, Text) ' Write into AppSettings.WriteLog - End Select + Try + FileOutLog.OpenWrite(LogFilenam, , True) - ' Set the Scrollbars in the Listboxes at the end - CSEMain.ListBoxMSG.TopIndex = CSEMain.ListBoxMSG.Items.Count - 1 - CSEMain.ListBoxWar.TopIndex = CSEMain.ListBoxWar.Items.Count - 1 - CSEMain.ListBoxErr.TopIndex = CSEMain.ListBoxErr.Items.Count - 1 - End Sub + If eventType = 1 Then FileOutLog.WriteLine("---------------") -#End Region + If ex Is Nothing Then + FileOutLog.WriteLine(format("{0}: {1,-5}| {2}", DateAndTime.Now.ToString(logDateFrmt), slevel, text)) + Else + FileOutLog.WriteLine(format("{0}: {1,-5}| {2}\n\i{3}", DateAndTime.Now.ToString(logDateFrmt), slevel, text, ex)) + End If + + If eventType = 3 Then FileOutLog.WriteLine("---------------") + Finally + FileOutLog.Dispose() + End Try + + Return True + End Function + +#End Region ' Logging #Region "Json" @@ -343,7 +398,55 @@ Module Minor_routines Return value End Function -#End Region ' "Json" + ''' <summary>Builds a human-readable help-string from any non-null schema-properties.</summary> + Function schemaInfos2helpMsg(ByVal ParamArray propSchemaInfos() As JToken) As String + Dim titl = propSchemaInfos(0) + Dim desc = propSchemaInfos(1) + Dim type = propSchemaInfos(2) + Dim chce = propSchemaInfos(3) + Dim dflt = propSchemaInfos(4) + Dim mini = propSchemaInfos(5) + Dim miex = propSchemaInfos(6) '' exclusiveMin + Dim maxi = propSchemaInfos(7) + Dim maex = propSchemaInfos(8) '' exclusiveMax + + Dim sdesc As String = "" + Dim stype As String = "" + Dim senum As String = "" + Dim sdflt As String = "" + Dim slimt As String = "" + + If desc IsNot Nothing Then + sdesc = format(desc.ToString()) + ElseIf titl IsNot Nothing Then + sdesc = format(titl.ToString()) + End If + If type IsNot Nothing Then stype = type.ToString(Newtonsoft.Json.Formatting.None) & ": " + If chce IsNot Nothing Then senum = format("\n- choices: {0}", chce.ToString(Newtonsoft.Json.Formatting.None)) + If dflt IsNot Nothing Then sdflt = format("\n- default: {0}", dflt) + If mini IsNot Nothing OrElse maxi IsNot Nothing Then + Dim infinitySymbol = "" + ChrW(&H221E) + Dim open = "("c + Dim smin = infinitySymbol + Dim smax = infinitySymbol + Dim clos = ")"c + + If mini IsNot Nothing Then + smin = mini + If (miex Is Nothing OrElse Not CBool(miex)) Then open = "["c + End If + If maxi IsNot Nothing Then + smax = maxi + If (maex Is Nothing OrElse Not CBool(maex)) Then clos = "]"c + End If + slimt = format("\n- limits : {0}{1}, {2}{3}", _ + open, smin, smax, clos) + End If + + Return String.Join("", stype, sdesc, senum, sdflt, slimt) + End Function + +#End Region ' Json #Region "Strings" @@ -392,5 +495,4 @@ Module Minor_routines #End Region ' Strings - End Module \ No newline at end of file diff --git a/DemoData/EvaluationDemo.csjob b/DemoData/EvaluationDemo.csjob new file mode 100644 index 0000000000000000000000000000000000000000..49b75cd616477136826a60c1285c8bc0dfb737f7 --- /dev/null +++ b/DemoData/EvaluationDemo.csjob @@ -0,0 +1,74 @@ +c Constant Speed Evaluator VECTO-CSE 2.01 +c General inputfiles +c Path to vehicle specifications file (*.csveh) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\VehicleDemo.csveh +c Path to ambient conditions file (*.csamb) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\AmbientConditionsDemo.csamb +c Anemomenter instrument calibration factors (v_air f, v_air d, beta f, beta d) +1,0,1,0 +c +c Calibration test inputfiles +c Path to measurement section specification file (*.csmsc) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\TrackDemo.csms +c Path to measurement data file from the calibration test (*.csdat) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\DataDemo_CAL.csdat +c +c Constant speed test inputfiles +c Path to measurement section specification file (*.csmsc) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\TrackDemo.csms +c Rolling resistance correction +1 +c Path to measurement data files from the test runs LS1, HS, LS2 (*.csdat) +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\DataDemo_LS1.csdat +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\DataDemo_HS.csdat +J:\TE-Em\Projekte\I_2012_08_HDV_CO2_LOT3\Arbeitsordner\CSE\Release_Packages\2.01\Test\WorkingDir\DemoData\DataDemo_LS2.csdat +c Evaluation settings +c Acceleration correction (yes = 1, no = 0) +0 +c Gradient correction (yes = 1, no = 0) +0 +c Output frequency (1Hz = 1, 100Hz = 100) +1 +c Parameters for general validity criteria +5 +0.3 +3 +25 +35 +0 +c General parameters +1 +1.1884 +1 +20 +c Parameters for identification of measurement section +10 +100 +10 +c Requirements on number of valid datasets +5 +1 +2 +10 +c **DataSet validity criteria** +25 +c *Calibration test* +5 +8 +5 +c *Low and high speed test* +10 +c Low speed test +5 +8 +16 +9 +0.15 +0.1 +c High speed test +5 +8 +80 +3 +0.3 +0.1 diff --git a/DemoData/VehicleDemo.csveh b/DemoData/VehicleDemo.csveh deleted file mode 100644 index e7e922265d60a897347d9848de23748005f5274e..0000000000000000000000000000000000000000 --- a/DemoData/VehicleDemo.csveh +++ /dev/null @@ -1,21 +0,0 @@ -c VECTO-CSE vehicle file -c vehicle class code (1-16) -4 -c vehicle configuration (0=rigid; 1=truck/tractor&trailer) -0 -c vehicle test mass [kg] -25000 -c wheels inertia [kgm²] -90 -c axle ratio [-] -3.6 -c gear ratio high speed [-] -1 -c gear ratio low speed [-] -2.5 -c anemometer height [m] -4.55 -c vehicle height [m] -3.5 -c vehicle width [m] -2.45 diff --git a/DemoData/VehicleDemo.csveh.json b/DemoData/VehicleDemo.csveh.json new file mode 100644 index 0000000000000000000000000000000000000000..6008120a97fe6214df975623a0f1ba5310f3de33 --- /dev/null +++ b/DemoData/VehicleDemo.csveh.json @@ -0,0 +1,21 @@ +{ + "Header": { + "Title": "vecto-cse VEHICLE", + "FileVersion": "1.0.0", + "AppVersion": "2.0.1-pre1", + "ModifiedDate": "2014/05/28 00:33:50 +02:00", + "Strict": true, + }, + "Body": { + "classCode": 4, + "configuration": "rigid", + "vehWidth": 2.45, + "vehHeight": 3.5, + "anemometerHeight": 4.55, + "testMass": 25000.0, + "wheelsInertia": 90.0, + "gearRatio_low": 2.5, + "gearRatio_high": 1, + "axleRatio": 3.6, + } +} \ No newline at end of file diff --git a/README.md b/README.md index f525c9935f9143251c74b109ad796afd1f5ceed3..e90ec773b5b1404c4416448332ff77e48dc160a3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ - VECTO-CSE - ============ - -Copyright: 2014 EUROPEAN COMMISSION -Developed by TU-Graz, on behalf of DG CLIMA, supported by JRC. - +VECTO-CSE +========= A Constant Speed Evaluation tool for tests performed on Heavy-duty vehicles. - +* Copyright : 2014 EUROPEAN COMMISSION +* Developed : by TU-Graz, on behalf of DG CLIMA, supported by JRC. +* License : EUPL ## INSTALLATION: @@ -20,7 +18,7 @@ that it is installed properly. To check whether .Net is installed on your PC and which version, follow this [article](http://support.microsoft.com/kb/318785/en-us). -If not, iInstall it](http://msdn.microsoft.com/en-us/library/vstudio/5a4x27ek(v=vs.100).aspx). +If not, [install it](http://msdn.microsoft.com/en-us/library/vstudio/5a4x27ek%28v=vs.100%29.aspx)!