From 33eee124c8d1e81eda621e1ca0dfe819258de9d2 Mon Sep 17 00:00:00 2001
From: Martin Dippold <Dippold@ivt.tugraz.at>
Date: Fri, 3 Feb 2017 14:08:35 +0100
Subject: [PATCH] * New version number * Validity criterias for calibration run
 extended (see technical annex) * New calibration criterias
 (v_veh_1s_delta_CAL, v_veh_ave_delta_CAL)

---
 CHANGES.md                                  |   7 +
 CSE/AirDrag.vbproj                          |   4 +
 CSE/Calculation/Minor_routines_calculate.vb |  14 +-
 CSE/Calculation/Signal_identification.vb    | 177 +++++++++++++++++++-
 CSE/Calculation/main_calculation_call.vb    |  52 +++++-
 CSE/Classes/cValidSec.vb                    |  12 ++
 CSE/GUI/F_Main.Designer.vb                  | 101 +++++++++--
 CSE/GUI/F_Main.vb                           |  10 +-
 CSE/IO/cCriteria.vb                         |  16 ++
 CSE/IO/output.vb                            |   2 +
 CSE/My Project/AssemblyInfo.vb              |   4 +-
 CSE/declaration_public.vb                   |   2 +-
 12 files changed, 364 insertions(+), 37 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index aadef37..756b9ef 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,12 @@
 VECTO-CSE: Changes
 ===================
+#### 2017-02-03: v3.0.7 ####
+TUG improvements:
+
+  * New version number
+  * Validity criterias for calibration run extended (see technical annex)
+  * New calibration criterias (v_veh_1s_delta_CAL, v_veh_ave_delta_CAL)
+
 #### 2017-01-13: v3.0.5/6 ####
 TUG improvements:
 
diff --git a/CSE/AirDrag.vbproj b/CSE/AirDrag.vbproj
index ab75fad..cea30ed 100644
--- a/CSE/AirDrag.vbproj
+++ b/CSE/AirDrag.vbproj
@@ -71,6 +71,9 @@
   <PropertyGroup>
     <ApplicationIcon>Resources\AirDrag.ico</ApplicationIcon>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationManifest>My Project\app.manifest</ApplicationManifest>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -221,6 +224,7 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
+    <None Include="My Project\app.manifest" />
     <None Include="My Project\Application.myapp">
       <Generator>MyApplicationCodeGenerator</Generator>
       <LastGenOutput>Application.Designer.vb</LastGenOutput>
diff --git a/CSE/Calculation/Minor_routines_calculate.vb b/CSE/Calculation/Minor_routines_calculate.vb
index b1d9cca..384564b 100644
--- a/CSE/Calculation/Minor_routines_calculate.vb
+++ b/CSE/Calculation/Minor_routines_calculate.vb
@@ -125,13 +125,17 @@ Module Minor_routines_calculate
             If Sprung And lauf = 0 Then
                 zEnd = tI(lauf) - 1
                 pos = 0
+            ElseIf Sprung And lauf = laufE Then
+                zEnd = tI(lauf)
+                t0 = tI(lauf - 1)
+                pos = tI(lauf - 1)
             ElseIf Sprung And lauf <> 0 Then
                 zEnd = TI(lauf) - 1
                 t0 = TI(lauf - 1)
-                pos = TI(lauf - 1)
+                pos = tI(lauf - 1)
             Else
-                pos = TI(lauf)
-                t0 = TI(lauf)
+                pos = tI(lauf)
+                t0 = tI(lauf)
                 zEnd = TimeX.Count - 1
             End If
 
@@ -196,6 +200,10 @@ Module Minor_routines_calculate
             If Sprung And lauf = 0 Then
                 zEnd = tI(lauf) - 1
                 pos = 0
+            ElseIf Sprung And lauf = laufE Then
+                zEnd = tI(lauf)
+                t0 = tI(lauf - 1)
+                pos = tI(lauf - 1)
             ElseIf Sprung And lauf <> 0 Then
                 zEnd = tI(lauf) - 1
                 t0 = tI(lauf - 1)
diff --git a/CSE/Calculation/Signal_identification.vb b/CSE/Calculation/Signal_identification.vb
index 0cad9d2..883144a 100644
--- a/CSE/Calculation/Signal_identification.vb
+++ b/CSE/Calculation/Signal_identification.vb
@@ -450,20 +450,30 @@ Module Signal_identification
                     ErgValues(tCompErg.vair_ic).Add(InputData(tComp.vair_ic)(i))
                     ErgValues(tCompErg.beta_ic).Add(InputData(tComp.beta_ic)(i))
                     ErgValues(tCompErg.user_valid).Add(InputData(tComp.user_valid)(i))
+
+                    If MSCX.tUse Then
+                        ErgValues(tCompErg.v_MSC).Add(0)
+                    Else
+                        ErgValues(tCompErg.v_MSC).Add(0)
+                        ErgValues(tCompErg.v_MSC_GPS).Add(InputData(tComp.v_veh_GPS)(i))
+                    End If
+
                     If i = 0 Then
                         ' First data Point lies in a section. This is not allowed and set this section to invalid
                         ErgValues(tCompErg.valid).Add(0)
                         ErgValues(tCompErg.used).Add(0)
+                    ElseIf i = CalcData(tCompCali.SecID).Count - 1 Then
+                        ' Last data Point lies in a section. This is not allowed and set this section to invalid
+                        ErgValues(tCompErg.valid).Add(0)
+                        ErgValues(tCompErg.used).Add(0)
+                        ErgValues(tCompErg.delta_t)(run) = ErgValues(tCompErg.delta_t)(run) - CalcData(tCompCali.t)(i - 1)
+                        ErgValues(tCompErg.v_MSC)(run) = (ErgValues(tCompErg.s_MSC)(run) / ErgValues(tCompErg.delta_t)(run)) * 3.6
+                        ErgValues(tCompErg.user_valid)(run) = 0
                     Else
                         ErgValues(tCompErg.valid).Add(1)
                         ErgValues(tCompErg.used).Add(1)
                     End If
-                    If MSCX.tUse Then
-                        ErgValues(tCompErg.v_MSC).Add(0)
-                    Else
-                        ErgValues(tCompErg.v_MSC).Add(0)
-                        ErgValues(tCompErg.v_MSC_GPS).Add(InputData(tComp.v_veh_GPS)(i))
-                    End If
+
                     For Each sKV In ErgValues
                         If ErgValues(sKV.Key).Count <= run Then
                             ErgValues(sKV.Key).Add(0)
@@ -490,6 +500,27 @@ Module Signal_identification
                         Next
 
                         anz += 1
+
+                        ' Last data Point lies in a section. This is not allowed and set this section to invalid
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ' Calculate the results from the last section
+                            ErgValues(tCompErg.delta_t)(run) = CalcData(tCompCali.t)(i) - ErgValues(tCompErg.delta_t)(run)
+                            ErgValues(tCompErg.v_veh_CAN)(run) = ErgValues(tCompErg.v_veh_CAN)(run) / anz
+                            ErgValues(tCompErg.vair_ic)(run) = ErgValues(tCompErg.vair_ic)(run) / anz
+                            ErgValues(tCompErg.beta_ic)(run) = ErgValues(tCompErg.beta_ic)(run) / anz
+                            ErgValues(tCompErg.v_MSC)(run) = (ErgValues(tCompErg.s_MSC)(run) / ErgValues(tCompErg.delta_t)(run)) * 3.6
+                            ErgValues(tCompErg.user_valid)(run) = 0
+                            If Not MSCX.tUse Then
+                                ErgValues(tCompErg.v_MSC_GPS)(run) = ErgValues(tCompErg.v_MSC_GPS)(run) / anz
+                            End If
+                            For Each sKVE In InputUndefData
+                                ErgValuesUndef(sKVE.Key)(run) = ErgValuesUndef(sKVE.Key)(run) / anz
+                            Next
+
+                            ' Set the section to invalid
+                            ErgValues(tCompErg.valid)(run) = 0
+                            ErgValues(tCompErg.used)(run) = 0
+                        End If
                     Else
                         ' Calculate the results from the last section
                         ErgValues(tCompErg.delta_t)(run) = CalcData(tCompCali.t)(i - 1) - ErgValues(tCompErg.delta_t)(run)
@@ -540,6 +571,15 @@ Module Signal_identification
 
                         anz = 1
                         run += 1
+
+                        ' Last data Point lies in a section. This is not allowed and set this section to invalid
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.valid)(run) = 0
+                            ErgValues(tCompErg.used)(run) = 0
+                            ErgValues(tCompErg.user_valid)(run) = 0
+                            ErgValues(tCompErg.delta_t)(run) = ErgValues(tCompErg.delta_t)(run) - CalcData(tCompCali.t)(i - 1)
+                            ErgValues(tCompErg.v_MSC)(run) = (ErgValues(tCompErg.s_MSC)(run) / ErgValues(tCompErg.delta_t)(run)) * 3.6
+                        End If
                     End If
                 End If
             Else
@@ -605,11 +645,22 @@ Module Signal_identification
                     ErgValues(tCompErg.dist)(run) = (CalcData(tCompCali.dist)(i))
                     firstIn = False
                     anz += 1
+
+                    ' Last data Point lies in a section. This is not allowed but done for correct calculation
+                    If i = CalcData(tCompCali.SecID).Count - 1 Then
+                        ErgValues(tCompErg.dist)(run) = (CalcData(tCompCali.v_veh_c)(i) / 3.6) * (1 / HzIn2)
+                    End If
                 Else
                     If (CalcData(tCompCali.SecID)(i) = CalcData(tCompCali.SecID)(i - 1)) And (CalcData(tCompCali.DirID)(i) = CalcData(tCompCali.DirID)(i - 1)) Then
                         ' Build the sum
                         ErgValues(tCompErg.v_veh)(run) += CalcData(tCompCali.v_veh_c)(i)
                         anz += 1
+
+                        ' Last data Point lies in a section. This is not allowed but done for correct calculation
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.v_veh)(run) = ErgValues(tCompErg.v_veh)(run) / anz
+                            ErgValues(tCompErg.dist)(run) = CalcData(tCompCali.dist)(i) - ErgValues(tCompErg.dist)(run)
+                        End If
                     Else
                         ' Calculate the results from the last section
                         ErgValues(tCompErg.v_veh)(run) = ErgValues(tCompErg.v_veh)(run) / anz
@@ -620,6 +671,11 @@ Module Signal_identification
                         anz = 1
                         ErgValues(tCompErg.v_veh)(run) = (CalcData(tCompCali.v_veh_c)(i))
                         ErgValues(tCompErg.dist)(run) = (CalcData(tCompCali.dist)(i))
+
+                        ' Last data Point lies in a section. This is not allowed but done for correct calculation
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.dist)(run) = (CalcData(tCompCali.v_veh_c)(run) / 3.6) * (1 / HzIn2)
+                        End If
                     End If
                 End If
             Else
@@ -672,6 +728,16 @@ Module Signal_identification
                         ErgValues(tCompErg.vair_uf)(run) += CalcData(tCompCali.vair_uf)(i)
                         If ErgValues(tCompErg.v_wind_1s_max)(run) < CalcData(tCompCali.vwind_1s)(i) Then ErgValues(tCompErg.v_wind_1s_max)(run) = CalcData(tCompCali.vwind_1s)(i)
                         anz += 1
+
+                        ' If last point lies inside of a section (Not allowed only for correct calculation)
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.v_wind_avg)(run) = ErgValues(tCompErg.v_wind_avg)(run) / anz
+                            ErgValues(tCompErg.v_wind_1s)(run) = ErgValues(tCompErg.v_wind_1s)(run) / anz
+                            ErgValues(tCompErg.beta_avg)(run) = ErgValues(tCompErg.beta_avg)(run) / anz
+                            ErgValues(tCompErg.vair)(run) = ErgValues(tCompErg.vair)(run) / anz
+                            ErgValues(tCompErg.beta_uf)(run) = ErgValues(tCompErg.beta_uf)(run) / anz
+                            ErgValues(tCompErg.vair_uf)(run) = ErgValues(tCompErg.vair_uf)(run) / anz
+                        End If
                     Else
                         ' Calculate the results from the last section
                         ErgValues(tCompErg.v_wind_avg)(run) = ErgValues(tCompErg.v_wind_avg)(run) / anz
@@ -713,6 +779,44 @@ Module Signal_identification
         Return True
     End Function
 
+    ' Calculate the corrected vehicle speed
+    Public Function fCalcSpeedValCalib() As Boolean
+        ' Declaration
+        Dim i, run As Integer
+        Dim firstIn As Boolean = True
+
+        ' Initialise
+        run = 0
+
+        ' Calculate the moving average
+        fMoveAve(CalcData(tCompCali.t), CalcData(tCompCali.v_veh_c), CalcData(tCompCali.v_veh_1s))
+
+        ' Calculate the section averages
+        For i = 0 To CalcData(tCompCali.SecID).Count - 1
+            If CalcData(tCompCali.SecID)(i) <> 0 Then
+                If firstIn Then
+                    ErgValues(tCompErg.v_veh_1s_max)(run) = (CalcData(tCompCali.v_veh_1s)(i))
+                    ErgValues(tCompErg.v_veh_1s_min)(run) = (CalcData(tCompCali.v_veh_1s)(i))
+
+                    firstIn = False
+                Else
+                    If (CalcData(tCompCali.SecID)(i) = CalcData(tCompCali.SecID)(i - 1)) And (CalcData(tCompCali.DirID)(i) = CalcData(tCompCali.DirID)(i - 1)) Then
+                        ' Find min/max
+                        If ErgValues(tCompErg.v_veh_1s_max)(run) < CalcData(tCompCali.v_veh_1s)(i) Then ErgValues(tCompErg.v_veh_1s_max)(run) = CalcData(tCompCali.v_veh_1s)(i)
+                        If ErgValues(tCompErg.v_veh_1s_min)(run) > CalcData(tCompCali.v_veh_1s)(i) Then ErgValues(tCompErg.v_veh_1s_min)(run) = CalcData(tCompCali.v_veh_1s)(i)
+                    Else
+                        ' Start with a new section
+                        run += 1
+                        ErgValues(tCompErg.v_veh_1s_max)(run) = (CalcData(tCompCali.v_veh_1s)(i))
+                        ErgValues(tCompErg.v_veh_1s_min)(run) = (CalcData(tCompCali.v_veh_1s)(i))
+                    End If
+                End If
+            End If
+        Next i
+
+        Return True
+    End Function
+
     ' Calculate the corrected vehicle speed
     Public Function fCalcSpeedVal(ByVal Altdata As List(Of cAlt), ByVal vehicleX As cVehicle, ByVal coastingSeq As Integer, ByRef r_dyn_ref As Double) As Boolean
         ' Declaration
@@ -890,6 +994,20 @@ Module Signal_identification
                     ErgValues(tCompErg.n_ec_float_min)(run) = (CalcData(tCompCali.n_ec_float)(i))
                     ErgValues(tCompErg.t_ground)(run) = (InputData(tComp.t_ground)(i))
 
+                    ' Last point lies inside of a section (Not allowed only for correct calculation)
+                    If i = CalcData(tCompCali.SecID).Count - 1 Then
+                        ErgValues(tCompErg.beta_abs)(run) = Math.Abs(ErgValues(tCompErg.beta_avg)(run))
+                        ErgValues(tCompErg.vp_H2O)(run) = ((ErgValues(tCompErg.rh_stat)(run) / 100) * 611 * 10 ^ ((7.5 * ErgValues(tCompErg.t_amb_stat)(run)) / (237 + ErgValues(tCompErg.t_amb_stat)(run))))
+                        ErgValues(tCompErg.rho_air)(run) = (ErgValues(tCompErg.p_amb_stat)(run) * 100 - ErgValues(tCompErg.vp_H2O)(run)) / (287.05 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) + ErgValues(tCompErg.vp_H2O)(run) / (461.9 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15))
+                        If ErgValues(tCompErg.RunID)(run) = IDHS Then
+                            ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS
+                        Else
+                            ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * Crt.rr_corr_factor
+                        End If
+                        ErgValues(tCompErg.r_dyn)(run) = (30 * igear * vehicleX.axleRatio * ErgValues(tCompErg.v_veh)(run) / 3.6) / (ErgValues(tCompErg.n_ec)(run) * Math.PI)
+                        ErgValues(tCompErg.tq_grd)(run) = ErgValues(tCompErg.F_grd)(run) * ErgValues(tCompErg.r_dyn)(run)
+                    End If
+
                     firstIn = False
                     anz += 1
                 Else
@@ -927,6 +1045,39 @@ Module Signal_identification
                         If ErgValues(tCompErg.n_ec_float_min)(run) > CalcData(tCompCali.n_ec_float)(i) Then ErgValues(tCompErg.n_ec_float_min)(run) = CalcData(tCompCali.n_ec_float)(i)
                         ErgValues(tCompErg.t_ground)(run) += (InputData(tComp.t_ground)(i))
                         anz += 1
+
+                        ' Last point lies inside of a section (Not allowed only for correct calculation)
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.n_ec)(run) = ErgValues(tCompErg.n_ec)(run) / anz
+                            ErgValues(tCompErg.tq_sum)(run) = ErgValues(tCompErg.tq_sum)(run) / anz
+                            ErgValues(tCompErg.tq_sum_1s)(run) = ErgValues(tCompErg.tq_sum_1s)(run) / anz
+                            ErgValues(tCompErg.tq_sum_float)(run) = ErgValues(tCompErg.tq_sum_float)(run) / anz
+                            ErgValues(tCompErg.t_float)(run) = ErgValues(tCompErg.t_float)(run) / anz
+                            ErgValues(tCompErg.F_trac)(run) = ErgValues(tCompErg.F_trac)(run) / anz
+                            ErgValues(tCompErg.v_veh_acc)(run) = ErgValues(tCompErg.v_veh_acc)(run) / anz
+                            ErgValues(tCompErg.a_veh_avg)(run) = ErgValues(tCompErg.a_veh_avg)(run) / anz
+                            ErgValues(tCompErg.F_acc)(run) = ErgValues(tCompErg.F_acc)(run) / anz
+                            ErgValues(tCompErg.F_grd)(run) = ErgValues(tCompErg.F_grd)(run) / anz
+                            ErgValues(tCompErg.F_res)(run) = ErgValues(tCompErg.F_res)(run) / anz
+                            ErgValues(tCompErg.v_veh_1s)(run) = ErgValues(tCompErg.v_veh_1s)(run) / anz
+                            ErgValues(tCompErg.v_veh_float)(run) = ErgValues(tCompErg.v_veh_float)(run) / anz
+                            ErgValues(tCompErg.t_amb_veh)(run) = ErgValues(tCompErg.t_amb_veh)(run) / anz
+                            ErgValues(tCompErg.t_amb_stat)(run) = ErgValues(tCompErg.t_amb_stat)(run) / anz
+                            ErgValues(tCompErg.p_amb_stat)(run) = ErgValues(tCompErg.p_amb_stat)(run) / anz
+                            ErgValues(tCompErg.rh_stat)(run) = ErgValues(tCompErg.rh_stat)(run) / anz
+                            ErgValues(tCompErg.v_air_sq)(run) = ErgValues(tCompErg.v_air_sq)(run) / anz
+                            ErgValues(tCompErg.beta_abs)(run) = Math.Abs(ErgValues(tCompErg.beta_avg)(run))
+                            ErgValues(tCompErg.vp_H2O)(run) = ((ErgValues(tCompErg.rh_stat)(run) / 100) * 611 * 10 ^ ((7.5 * ErgValues(tCompErg.t_amb_stat)(run)) / (237 + ErgValues(tCompErg.t_amb_stat)(run))))
+                            ErgValues(tCompErg.rho_air)(run) = (ErgValues(tCompErg.p_amb_stat)(run) * 100 - ErgValues(tCompErg.vp_H2O)(run)) / (287.05 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) + ErgValues(tCompErg.vp_H2O)(run) / (461.9 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15))
+                            If ErgValues(tCompErg.RunID)(run) = IDHS Then
+                                ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS
+                            Else
+                                ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * Crt.rr_corr_factor
+                            End If
+                            ErgValues(tCompErg.t_ground)(run) = ErgValues(tCompErg.t_ground)(run) / anz
+                            ErgValues(tCompErg.r_dyn)(run) = (30 * igear * vehicleX.axleRatio * ErgValues(tCompErg.v_veh)(run) / 3.6) / (ErgValues(tCompErg.n_ec)(run) * Math.PI)
+                            ErgValues(tCompErg.tq_grd)(run) = ErgValues(tCompErg.F_grd)(run) * ErgValues(tCompErg.r_dyn)(run)
+                        End If
                     Else
                         ' Calculate the results from the last section
                         ErgValues(tCompErg.n_ec)(run) = ErgValues(tCompErg.n_ec)(run) / anz
@@ -994,6 +1145,20 @@ Module Signal_identification
                         ErgValues(tCompErg.n_ec_float_max)(run) = (CalcData(tCompCali.n_ec_float)(i))
                         ErgValues(tCompErg.n_ec_float_min)(run) = (CalcData(tCompCali.n_ec_float)(i))
                         ErgValues(tCompErg.t_ground)(run) = (InputData(tComp.t_ground)(i))
+
+                        ' Last point lies inside of a section (Not allowed only for correct calculation)
+                        If i = CalcData(tCompCali.SecID).Count - 1 Then
+                            ErgValues(tCompErg.beta_abs)(run) = Math.Abs(ErgValues(tCompErg.beta_avg)(run))
+                            ErgValues(tCompErg.vp_H2O)(run) = ((ErgValues(tCompErg.rh_stat)(run) / 100) * 611 * 10 ^ ((7.5 * ErgValues(tCompErg.t_amb_stat)(run)) / (237 + ErgValues(tCompErg.t_amb_stat)(run))))
+                            ErgValues(tCompErg.rho_air)(run) = (ErgValues(tCompErg.p_amb_stat)(run) * 100 - ErgValues(tCompErg.vp_H2O)(run)) / (287.05 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15)) + ErgValues(tCompErg.vp_H2O)(run) / (461.9 * (ErgValues(tCompErg.t_amb_veh)(run) + 273.15))
+                            If ErgValues(tCompErg.RunID)(run) = IDHS Then
+                                ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * f_rollHS
+                            Else
+                                ErgValues(tCompErg.F_res_ref)(run) = ErgValues(tCompErg.F_res)(run) * Crt.rr_corr_factor
+                            End If
+                            ErgValues(tCompErg.r_dyn)(run) = (30 * igear * vehicleX.axleRatio * ErgValues(tCompErg.v_veh)(run) / 3.6) / (ErgValues(tCompErg.n_ec)(run) * Math.PI)
+                            ErgValues(tCompErg.tq_grd)(run) = ErgValues(tCompErg.F_grd)(run) * ErgValues(tCompErg.r_dyn)(run)
+                        End If
                     End If
                 End If
             Else
diff --git a/CSE/Calculation/main_calculation_call.vb b/CSE/Calculation/main_calculation_call.vb
index db6d197..53f803a 100644
--- a/CSE/Calculation/main_calculation_call.vb
+++ b/CSE/Calculation/main_calculation_call.vb
@@ -206,7 +206,7 @@ Public Module main_calculation_call
         run = 0
 
         ' Check if the calibration run has the same and enough sections measured
-        fCheckCalib(run, Change)
+        fCheckCalib(run, vehicleX, Change)
 
         Do While Change
             ' Initialise Parameter
@@ -233,8 +233,11 @@ Public Module main_calculation_call
             ' Calculate the average values for v_wind, beta and v_wind_1s_max
             fWindBetaAirErg()
 
+            ' Calculate the other speed run relevant values
+            fCalcSpeedValCalib()
+
             ' Check if the calibration run is valid
-            fCheckCalib(run, Change)
+            fCheckCalib(run, vehicleX, Change)
 
             ' Error
             If run > 10 Then
@@ -423,12 +426,13 @@ Public Module main_calculation_call
     End Function
 
     ' Function to check if the calibration run is valid
-    Sub fCheckCalib(ByVal Run As Integer, ByRef Change As Boolean)
+    Sub fCheckCalib(ByVal Run As Integer, ByVal vehicleX As cVehicle, ByRef Change As Boolean)
         ' Declaration
         Dim i, j, k, anz As Integer
         Dim control As Boolean
         Dim SecCount As New cValidSec
         Dim OldValid(ErgValues(tCompErg.SecID).Count - 1), OldUse(ErgValues(tCompErg.SecID).Count - 1) As Boolean
+        Dim lim_v_veh_avg_max_CAL, lim_v_veh_avg_min_CAL As Single
 
         ' Initialisation
         Change = False
@@ -442,16 +446,30 @@ Public Module main_calculation_call
         ' Reset the ErgValues for the criterias
         ResetErgVal(True)
 
+        ' Get the speed limit (!!use same criterias like for the HS test)
+        fgetSpeedLim(vehicleX, lim_v_veh_avg_max_CAL, lim_v_veh_avg_min_CAL)
+
         ' Set the values
         For i = 0 To ErgValues(tCompErg.SecID).Count - 1
             If ErgValues(tCompErg.v_wind_avg)(i) < Crt.v_wind_avg_max_CAL Then ErgValues(tCompErg.val_vWind)(i) = 1
             If Math.Abs(ErgValues(tCompErg.beta_avg)(i)) < Crt.beta_avg_max_CAL Then ErgValues(tCompErg.val_beta)(i) = 1
             If ErgValues(tCompErg.v_wind_1s_max)(i) < Crt.v_wind_1s_max_CAL Then ErgValues(tCompErg.val_vWind_1s)(i) = 1
             If ErgValues(tCompErg.user_valid)(i) = 1 Then ErgValues(tCompErg.val_User)(i) = 1
+            If Run = 0 Then
+                ' Only by initialisation. Otherwise its always false
+                ErgValues(tCompErg.val_vVeh_avg)(i) = 1
+            Else
+                ' Check by calibration
+                If ErgValues(tCompErg.v_veh)(i) < lim_v_veh_avg_max_CAL And _
+                   ErgValues(tCompErg.v_veh)(i) > lim_v_veh_avg_min_CAL Then ErgValues(tCompErg.val_vVeh_avg)(i) = 1
+            End If
+            If ErgValues(tCompErg.v_veh_1s_max)(i) < (ErgValues(tCompErg.v_veh)(i) + Crt.v_veh_1s_delta_CAL) And _
+               ErgValues(tCompErg.v_veh_1s_min)(i) > (ErgValues(tCompErg.v_veh)(i) - Crt.v_veh_1s_delta_CAL) Then ErgValues(tCompErg.val_vVeh_1s)(i) = 1
 
             ' Check if all criterias are valid
             If ErgValues(tCompErg.val_vWind)(i) = 1 And ErgValues(tCompErg.val_beta)(i) = 1 And _
-               ErgValues(tCompErg.val_vWind_1s)(i) = 1 And ErgValues(tCompErg.val_User)(i) = 1 Then
+               ErgValues(tCompErg.val_vWind_1s)(i) = 1 And ErgValues(tCompErg.val_User)(i) = 1 And _
+               ErgValues(tCompErg.val_vVeh_avg)(i) = 1 And ErgValues(tCompErg.val_vVeh_1s)(i) = 1 Then
                 ErgValues(tCompErg.valid)(i) = 1
                 ErgValues(tCompErg.used)(i) = 1
             Else
@@ -460,7 +478,7 @@ Public Module main_calculation_call
             End If
         Next i
 
-        ' Count the valid sections in both rounds
+        ' Count the valid sections in both rounds and calculate the average vehicle speed
         For i = 0 To ErgValues(tCompErg.SecID).Count - 1
             ' Initialisation
             control = False
@@ -471,8 +489,10 @@ Public Module main_calculation_call
                 SecCount.ValidSec.Add(False)
                 If ErgValues(tCompErg.valid)(i) = 1 Then
                     SecCount.AnzSec.Add(1)
+                    SecCount.vVeh.Add(ErgValues(tCompErg.v_veh)(i))
                 Else
                     SecCount.AnzSec.Add(0)
+                    SecCount.vVeh.Add(0)
                 End If
             End If
 
@@ -483,15 +503,17 @@ Public Module main_calculation_call
                 End If
             Next k
 
-            ' Count the valid section
+            ' Count the valid section and calculate the average vehicle speed
             If control = False Then
                 If i = ErgValues(tCompErg.SecID).Count - 1 Then
                     SecCount.NameSec.Add(ErgValues(tCompErg.SecID)(i) & " (" & ErgValues(tCompErg.DirID)(i) & ")")
                     SecCount.ValidSec.Add(False)
                     If ErgValues(tCompErg.valid)(i) = 1 Then
                         SecCount.AnzSec.Add(1)
+                        SecCount.vVeh.Add(ErgValues(tCompErg.v_veh)(i))
                     Else
                         SecCount.AnzSec.Add(0)
+                        SecCount.vVeh.Add(0)
                     End If
                 Else
                     For j = i + 1 To ErgValues(tCompErg.SecID).Count - 1
@@ -501,8 +523,10 @@ Public Module main_calculation_call
                             SecCount.ValidSec.Add(False)
                             If ErgValues(tCompErg.valid)(i) = 1 Then
                                 SecCount.AnzSec.Add(1)
+                                SecCount.vVeh.Add(ErgValues(tCompErg.v_veh)(i))
                             Else
                                 SecCount.AnzSec.Add(0)
+                                SecCount.vVeh.Add(0)
                             End If
                         End If
 
@@ -510,24 +534,28 @@ Public Module main_calculation_call
                         If ErgValues(tCompErg.SecID)(i) = ErgValues(tCompErg.SecID)(j) And ErgValues(tCompErg.DirID)(i) = ErgValues(tCompErg.DirID)(j) Then
                             If ErgValues(tCompErg.valid)(j) = 1 Then
                                 SecCount.AnzSec(SecCount.AnzSec.Count - 1) += 1
+                                SecCount.vVeh(SecCount.vVeh.Count - 1) += ErgValues(tCompErg.v_veh)(j)
                             End If
                         End If
                     Next j
                 End If
             End If
         Next i
+        'Calculate average vehicle speed
+        SecCount.calcAveSpeed()
 
         ' Ceck if enough sections are detected
         If SecCount.AnzSec.Count - 1 < 1 Then
             Throw New Exception(format("Insufficient numbers of valid measurement sections({0}) available!", SecCount.AnzSec.Count))
         End If
 
-        ' Check if enough valid sections in both directionsection
+        ' Check if enough valid sections in both directions and average vehicle speeds differ not more then v_veh_ave_delta_CAL
         For i = 0 To SecCount.NameSec.Count - 1
             For j = i + 1 To SecCount.NameSec.Count - 1
                 If Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2)) = Trim(Mid(SecCount.NameSec(j), 1, InStr(SecCount.NameSec(j), "(") - 2)) Then
                     ' If enough sections in both directions are detected
-                    If SecCount.AnzSec(i) >= Crt.segruns_min_CAL And SecCount.AnzSec(j) >= Crt.segruns_min_CAL Then
+                    If SecCount.AnzSec(i) >= Crt.segruns_min_CAL And SecCount.AnzSec(j) >= Crt.segruns_min_CAL And _
+                       Math.Abs(SecCount.vVeh(i) - SecCount.vVeh(j)) < Crt.v_veh_ave_delta_CAL Then
                         ' Set the whole sections on valid
                         SecCount.ValidSec(i) = True
                         SecCount.ValidSec(j) = True
@@ -559,6 +587,10 @@ Public Module main_calculation_call
                         '    End If
                         'End If
                     Else
+                        If Math.Abs(SecCount.vVeh(i) - SecCount.vVeh(j)) > Crt.v_veh_ave_delta_CAL Then
+                            logme(8, False, format("Deviation of average speeds per heading is to high ({0} km/h) in SecID: {1}! Section is set to invalid", Math.Round(Math.Abs(SecCount.vVeh(i) - SecCount.vVeh(j)), 3), ErgValues(tCompErg.SecID)(i)))
+                        End If
+
                         SecCount.ValidSec(i) = False
                         SecCount.ValidSec(j) = False
                         For k = 0 To ErgValues(tCompErg.SecID).Count - 1
@@ -570,7 +602,7 @@ Public Module main_calculation_call
             Next j
         Next i
 
-        ' Ceck if enough sections are valid
+        ' Check if enough sections are valid
         anz = 0
         For i = 0 To SecCount.ValidSec.Count - 1
             If SecCount.ValidSec(i) Then
@@ -1172,6 +1204,8 @@ Public Module main_calculation_call
                 ErgValues(tCompErg.val_vWind)(i) = 0
                 ErgValues(tCompErg.val_beta)(i) = 0
                 ErgValues(tCompErg.val_vWind_1s)(i) = 0
+                ErgValues(tCompErg.val_vVeh_avg)(i) = 0
+                ErgValues(tCompErg.val_vVeh_1s)(i) = 0
                 ErgValues(tCompErg.val_User)(i) = 0
             Next i
         Else
diff --git a/CSE/Classes/cValidSec.vb b/CSE/Classes/cValidSec.vb
index 82a1ade..6c7eeeb 100644
--- a/CSE/Classes/cValidSec.vb
+++ b/CSE/Classes/cValidSec.vb
@@ -13,11 +13,23 @@ Public Class cValidSec
     Public NameSec As List(Of String)                   ' Name of the section
     Public AnzSec As List(Of Integer)                   ' Number of valid sections
     Public ValidSec As List(Of Boolean)                 ' Verify if enough sections in both directions
+    Public vVeh As List(Of Double)                      ' Average vehicle speed
 
     ' Initialise the parameter
     Public Sub New()
         NameSec = New List(Of String)
         AnzSec = New List(Of Integer)
         ValidSec = New List(Of Boolean)
+        vVeh = New List(Of Double)
+    End Sub
+
+    ' calculate the average speed values
+    Public Sub calcAveSpeed()
+        ' Declaration
+        Dim i As Integer
+
+        For i = 0 To AnzSec.Count - 1
+            If AnzSec(i) > 0 Then vVeh(i) /= AnzSec(i)
+        Next
     End Sub
 End Class
diff --git a/CSE/GUI/F_Main.Designer.vb b/CSE/GUI/F_Main.Designer.vb
index 6041b05..ab48133 100644
--- a/CSE/GUI/F_Main.Designer.vb
+++ b/CSE/GUI/F_Main.Designer.vb
@@ -200,6 +200,12 @@ Partial Class F_Main
         Me.TB_v_veh_avg_min_LS = New System.Windows.Forms.TextBox()
         Me.Label79 = New System.Windows.Forms.Label()
         Me.GroupBox13 = New System.Windows.Forms.GroupBox()
+        Me.Label2 = New System.Windows.Forms.Label()
+        Me.Label23 = New System.Windows.Forms.Label()
+        Me.Lv_veh_ave_delta_CAL = New System.Windows.Forms.Label()
+        Me.TB_v_veh_ave_delta_CAL = New System.Windows.Forms.TextBox()
+        Me.TB_v_veh_1s_delta_CAL = New System.Windows.Forms.TextBox()
+        Me.Lv_veh_1s_delta_CAL = New System.Windows.Forms.Label()
         Me.Label19 = New System.Windows.Forms.Label()
         Me.Label40 = New System.Windows.Forms.Label()
         Me.TB_v_wind_avg_max_CAL = New System.Windows.Forms.TextBox()
@@ -968,7 +974,7 @@ Partial Class F_Main
         Me.TabControlOutMsg.Controls.Add(Me.TabPageWar)
         Me.TabControlOutMsg.Controls.Add(Me.TabPageErr)
         Me.TabControlOutMsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
-        Me.TabControlOutMsg.Location = New System.Drawing.Point(8, 567)
+        Me.TabControlOutMsg.Location = New System.Drawing.Point(8, 606)
         Me.TabControlOutMsg.Margin = New System.Windows.Forms.Padding(2)
         Me.TabControlOutMsg.Multiline = True
         Me.TabControlOutMsg.Name = "TabControlOutMsg"
@@ -1076,7 +1082,7 @@ Partial Class F_Main
         Me.TabControl1.Location = New System.Drawing.Point(8, 72)
         Me.TabControl1.Name = "TabControl1"
         Me.TabControl1.SelectedIndex = 0
-        Me.TabControl1.Size = New System.Drawing.Size(913, 488)
+        Me.TabControl1.Size = New System.Drawing.Size(913, 529)
         Me.TabControl1.TabIndex = 35
         '
         'TPMain
@@ -1088,7 +1094,7 @@ Partial Class F_Main
         Me.TPMain.Location = New System.Drawing.Point(4, 22)
         Me.TPMain.Name = "TPMain"
         Me.TPMain.Padding = New System.Windows.Forms.Padding(3)
-        Me.TPMain.Size = New System.Drawing.Size(905, 462)
+        Me.TPMain.Size = New System.Drawing.Size(905, 468)
         Me.TPMain.TabIndex = 0
         Me.TPMain.Text = "Main"
         Me.TPMain.UseVisualStyleBackColor = True
@@ -1131,7 +1137,7 @@ Partial Class F_Main
         Me.TPCriteria.Location = New System.Drawing.Point(4, 22)
         Me.TPCriteria.Name = "TPCriteria"
         Me.TPCriteria.Padding = New System.Windows.Forms.Padding(3)
-        Me.TPCriteria.Size = New System.Drawing.Size(905, 462)
+        Me.TPCriteria.Size = New System.Drawing.Size(905, 503)
         Me.TPCriteria.TabIndex = 1
         Me.TPCriteria.Text = "Criteria"
         Me.TPCriteria.UseVisualStyleBackColor = True
@@ -1468,7 +1474,7 @@ Partial Class F_Main
         Me.GroupBox9.Controls.Add(Me.PBInfoIconCrt)
         Me.GroupBox9.Location = New System.Drawing.Point(6, 199)
         Me.GroupBox9.Name = "GroupBox9"
-        Me.GroupBox9.Size = New System.Drawing.Size(894, 269)
+        Me.GroupBox9.Size = New System.Drawing.Size(894, 298)
         Me.GroupBox9.TabIndex = 44
         Me.GroupBox9.TabStop = False
         Me.GroupBox9.Text = "Dataset validity criteria"
@@ -2055,13 +2061,19 @@ Partial Class F_Main
         '
         'GroupBox13
         '
+        Me.GroupBox13.Controls.Add(Me.Label2)
+        Me.GroupBox13.Controls.Add(Me.Label23)
+        Me.GroupBox13.Controls.Add(Me.Lv_veh_ave_delta_CAL)
+        Me.GroupBox13.Controls.Add(Me.TB_v_veh_ave_delta_CAL)
+        Me.GroupBox13.Controls.Add(Me.TB_v_veh_1s_delta_CAL)
+        Me.GroupBox13.Controls.Add(Me.Lv_veh_1s_delta_CAL)
         Me.GroupBox13.Controls.Add(Me.Label19)
         Me.GroupBox13.Controls.Add(Me.Label40)
         Me.GroupBox13.Controls.Add(Me.TB_v_wind_avg_max_CAL)
-        Me.GroupBox13.Controls.Add(Me.LvWind1sCALMax)
-        Me.GroupBox13.Controls.Add(Me.LvWindAveCALMax)
         Me.GroupBox13.Controls.Add(Me.LDsMinCAL)
         Me.GroupBox13.Controls.Add(Me.TB_segruns_min_CAL)
+        Me.GroupBox13.Controls.Add(Me.LvWind1sCALMax)
+        Me.GroupBox13.Controls.Add(Me.LvWindAveCALMax)
         Me.GroupBox13.Controls.Add(Me.TB_beta_avg_max_CAL)
         Me.GroupBox13.Controls.Add(Me.Label44)
         Me.GroupBox13.Controls.Add(Me.Label42)
@@ -2069,15 +2081,67 @@ Partial Class F_Main
         Me.GroupBox13.Controls.Add(Me.LBetaAveCALMax)
         Me.GroupBox13.Location = New System.Drawing.Point(6, 19)
         Me.GroupBox13.Name = "GroupBox13"
-        Me.GroupBox13.Size = New System.Drawing.Size(211, 127)
+        Me.GroupBox13.Size = New System.Drawing.Size(211, 178)
         Me.GroupBox13.TabIndex = 79
         Me.GroupBox13.TabStop = False
         Me.GroupBox13.Text = "Calibration run"
         '
+        'Label2
+        '
+        Me.Label2.AutoSize = True
+        Me.Label2.Location = New System.Drawing.Point(173, 129)
+        Me.Label2.Name = "Label2"
+        Me.Label2.Size = New System.Drawing.Size(38, 13)
+        Me.Label2.TabIndex = 92
+        Me.Label2.Text = "[km/h]"
+        '
+        'Label23
+        '
+        Me.Label23.AutoSize = True
+        Me.Label23.Location = New System.Drawing.Point(173, 103)
+        Me.Label23.Name = "Label23"
+        Me.Label23.Size = New System.Drawing.Size(38, 13)
+        Me.Label23.TabIndex = 91
+        Me.Label23.Text = "[km/h]"
+        '
+        'Lv_veh_ave_delta_CAL
+        '
+        Me.Lv_veh_ave_delta_CAL.AutoSize = True
+        Me.Lv_veh_ave_delta_CAL.Location = New System.Drawing.Point(6, 129)
+        Me.Lv_veh_ave_delta_CAL.Name = "Lv_veh_ave_delta_CAL"
+        Me.Lv_veh_ave_delta_CAL.Size = New System.Drawing.Size(116, 13)
+        Me.Lv_veh_ave_delta_CAL.TabIndex = 88
+        Me.Lv_veh_ave_delta_CAL.Text = "v_veh_ave_delta_CAL"
+        '
+        'TB_v_veh_ave_delta_CAL
+        '
+        Me.TB_v_veh_ave_delta_CAL.Location = New System.Drawing.Point(128, 126)
+        Me.TB_v_veh_ave_delta_CAL.Name = "TB_v_veh_ave_delta_CAL"
+        Me.TB_v_veh_ave_delta_CAL.Size = New System.Drawing.Size(45, 20)
+        Me.TB_v_veh_ave_delta_CAL.TabIndex = 87
+        Me.TB_v_veh_ave_delta_CAL.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
+        '
+        'TB_v_veh_1s_delta_CAL
+        '
+        Me.TB_v_veh_1s_delta_CAL.Location = New System.Drawing.Point(128, 100)
+        Me.TB_v_veh_1s_delta_CAL.Name = "TB_v_veh_1s_delta_CAL"
+        Me.TB_v_veh_1s_delta_CAL.Size = New System.Drawing.Size(45, 20)
+        Me.TB_v_veh_1s_delta_CAL.TabIndex = 90
+        Me.TB_v_veh_1s_delta_CAL.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
+        '
+        'Lv_veh_1s_delta_CAL
+        '
+        Me.Lv_veh_1s_delta_CAL.AutoSize = True
+        Me.Lv_veh_1s_delta_CAL.Location = New System.Drawing.Point(6, 103)
+        Me.Lv_veh_1s_delta_CAL.Name = "Lv_veh_1s_delta_CAL"
+        Me.Lv_veh_1s_delta_CAL.Size = New System.Drawing.Size(109, 13)
+        Me.Lv_veh_1s_delta_CAL.TabIndex = 89
+        Me.Lv_veh_1s_delta_CAL.Text = "v_veh_1s_delta_CAL"
+        '
         'Label19
         '
         Me.Label19.AutoSize = True
-        Me.Label19.Location = New System.Drawing.Point(173, 101)
+        Me.Label19.Location = New System.Drawing.Point(173, 155)
         Me.Label19.Name = "Label19"
         Me.Label19.Size = New System.Drawing.Size(16, 13)
         Me.Label19.TabIndex = 86
@@ -2121,7 +2185,7 @@ Partial Class F_Main
         'LDsMinCAL
         '
         Me.LDsMinCAL.AutoSize = True
-        Me.LDsMinCAL.Location = New System.Drawing.Point(6, 101)
+        Me.LDsMinCAL.Location = New System.Drawing.Point(6, 155)
         Me.LDsMinCAL.Name = "LDsMinCAL"
         Me.LDsMinCAL.Size = New System.Drawing.Size(92, 13)
         Me.LDsMinCAL.TabIndex = 42
@@ -2129,7 +2193,7 @@ Partial Class F_Main
         '
         'TB_segruns_min_CAL
         '
-        Me.TB_segruns_min_CAL.Location = New System.Drawing.Point(128, 98)
+        Me.TB_segruns_min_CAL.Location = New System.Drawing.Point(128, 152)
         Me.TB_segruns_min_CAL.Name = "TB_segruns_min_CAL"
         Me.TB_segruns_min_CAL.Size = New System.Drawing.Size(45, 20)
         Me.TB_segruns_min_CAL.TabIndex = 41
@@ -2180,16 +2244,17 @@ Partial Class F_Main
         '
         'TBInfoCrt
         '
-        Me.TBInfoCrt.Location = New System.Drawing.Point(37, 152)
+        Me.TBInfoCrt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
+        Me.TBInfoCrt.Location = New System.Drawing.Point(40, 203)
         Me.TBInfoCrt.Multiline = True
         Me.TBInfoCrt.Name = "TBInfoCrt"
-        Me.TBInfoCrt.Size = New System.Drawing.Size(180, 110)
+        Me.TBInfoCrt.Size = New System.Drawing.Size(177, 89)
         Me.TBInfoCrt.TabIndex = 83
         '
         'PBInfoIconCrt
         '
         Me.PBInfoIconCrt.Image = Global.AirDrag.My.Resources.Resources.Info
-        Me.PBInfoIconCrt.Location = New System.Drawing.Point(6, 152)
+        Me.PBInfoIconCrt.Location = New System.Drawing.Point(9, 203)
         Me.PBInfoIconCrt.Name = "PBInfoIconCrt"
         Me.PBInfoIconCrt.Size = New System.Drawing.Size(25, 30)
         Me.PBInfoIconCrt.TabIndex = 81
@@ -2491,7 +2556,7 @@ Partial Class F_Main
         '
         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
-        Me.ClientSize = New System.Drawing.Size(932, 727)
+        Me.ClientSize = New System.Drawing.Size(932, 773)
         Me.Controls.Add(Me.LB_SelMode)
         Me.Controls.Add(Me.TabControl1)
         Me.Controls.Add(Me.PictureBox2)
@@ -2777,5 +2842,11 @@ Partial Class F_Main
     Friend WithEvents GroupBox8 As System.Windows.Forms.GroupBox
     Friend WithEvents GroupBox6 As System.Windows.Forms.GroupBox
     Friend WithEvents GroupBox16 As System.Windows.Forms.GroupBox
+    Friend WithEvents Label2 As System.Windows.Forms.Label
+    Friend WithEvents Label23 As System.Windows.Forms.Label
+    Friend WithEvents Lv_veh_ave_delta_CAL As System.Windows.Forms.Label
+    Friend WithEvents TB_v_veh_ave_delta_CAL As System.Windows.Forms.TextBox
+    Friend WithEvents TB_v_veh_1s_delta_CAL As System.Windows.Forms.TextBox
+    Friend WithEvents Lv_veh_1s_delta_CAL As System.Windows.Forms.Label
 
 End Class
diff --git a/CSE/GUI/F_Main.vb b/CSE/GUI/F_Main.vb
index dba2ab9..c3c5965 100644
--- a/CSE/GUI/F_Main.vb
+++ b/CSE/GUI/F_Main.vb
@@ -580,6 +580,8 @@ Public Class F_Main
         Crt.v_wind_avg_max_CAL = TB_v_wind_avg_max_CAL.Text
         Crt.v_wind_1s_max_CAL = TB_v_wind_1s_max_CAL.Text
         Crt.beta_avg_max_CAL = TB_beta_avg_max_CAL.Text
+        Crt.v_veh_1s_delta_CAL = TB_v_veh_1s_delta_CAL.Text
+        Crt.v_veh_ave_delta_CAL = TB_v_veh_ave_delta_CAL.Text
         ' Low and high speed test
         Crt.leng_crit = TB_leng_crit.Text
         ' Low speed test
@@ -647,6 +649,8 @@ Public Class F_Main
         TB_v_wind_avg_max_CAL.Text = Crt.v_wind_avg_max_CAL
         TB_v_wind_1s_max_CAL.Text = Crt.v_wind_1s_max_CAL
         TB_beta_avg_max_CAL.Text = Crt.beta_avg_max_CAL
+        TB_v_veh_1s_delta_CAL.Text = Crt.v_veh_1s_delta_CAL
+        TB_v_veh_ave_delta_CAL.Text = Crt.v_veh_ave_delta_CAL
         ' Low and high speed test
         TB_leng_crit.Text = Crt.leng_crit
         ' Low speed test
@@ -766,6 +770,8 @@ Public Class F_Main
         TB_v_wind_avg_max_CAL.Enabled = SetState
         TB_v_wind_1s_max_CAL.Enabled = SetState
         TB_beta_avg_max_CAL.Enabled = SetState
+        TB_v_veh_1s_delta_CAL.Enabled = SetState
+        TB_v_veh_ave_delta_CAL.Enabled = SetState
         ' Low and high speed test
         TB_leng_crit.Enabled = SetState
         ' Low speed test
@@ -1061,7 +1067,7 @@ Public Class F_Main
 
     ' Check if the input is a number
     Private Sub TextBox_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TB_length_MS_max.KeyPress, TB_delta_rr_max.KeyPress, _
-        TB_t_ground_max.KeyPress, TB_t_amb_max.KeyPress, TB_t_amb_min.KeyPress, TB_delta_Hz_max.KeyPress, TB_acc_corr_avg.KeyPress, TB_delta_parallel_max.KeyPress, TB_trigger_delta_x_max.KeyPress, TB_trigger_delta_y_max.KeyPress, _
+        TB_t_ground_max.KeyPress, TB_t_amb_max.KeyPress, TB_t_amb_min.KeyPress, TB_delta_Hz_max.KeyPress, TB_acc_corr_avg.KeyPress, TB_delta_parallel_max.KeyPress, TB_trigger_delta_x_max.KeyPress, TB_trigger_delta_y_max.KeyPress, TB_v_veh_1s_delta_CAL.KeyPress, TB_v_veh_ave_delta_CAL.KeyPress, _
         TB_delta_head_max.KeyPress, TB_segruns_min_CAL.KeyPress, TB_segruns_min_LS.KeyPress, TB_segruns_min_HS.KeyPress, TB_segruns_min_head_HS.KeyPress, TB_tq_sum_1s_delta_HS.KeyPress, TB_v_veh_1s_delta_HS.KeyPress, TB_beta_avg_max_HS.KeyPress, TB_v_veh_avg_min_HS.KeyPress, _
         TB_v_wind_1s_max_HS.KeyPress, TB_v_wind_avg_max_HS.KeyPress, TB_delta_n_ec_HS.KeyPress, TB_tq_sum_float_delta_LS.KeyPress, TB_v_veh_float_delta_LS.KeyPress, TB_v_veh_avg_max_LS.KeyPress, TB_v_veh_avg_min_LS.KeyPress, TB_slope_max.KeyPress, TB_length_MS_min.KeyPress, TB_delta_n_ec_LS.KeyPress, _
         TB_leng_crit.KeyPress, TB_beta_avg_max_CAL.KeyPress, TB_v_wind_1s_max_CAL.KeyPress, TB_v_wind_avg_max_CAL.KeyPress, TB_dist_float.KeyPress, TB_dist_gridpoints_max.KeyPress, TB_dist_grid_ms_max.KeyPress, TB_v_veh_avg_max_HS.KeyPress, TB_delta_v_avg_min_HS.KeyPress, TB_delta_CdxA_anemo.KeyPress
@@ -1221,6 +1227,8 @@ Public Class F_Main
             TB_v_wind_avg_max_CAL, LvWindAveCALMax, _
             TB_v_wind_1s_max_CAL, LvWind1sCALMax, _
             TB_beta_avg_max_CAL, LBetaAveCALMax, _
+            TB_v_veh_1s_delta_CAL, Lv_veh_1s_delta_CAL, _
+            TB_v_veh_ave_delta_CAL, Lv_veh_ave_delta_CAL, _
             TB_leng_crit, LLengCrit, _
             TB_v_veh_avg_min_LS, LB_v_veh_avg_min_LS, _
             TB_v_veh_avg_max_LS, LB_v_veh_avg_max_LS, _
diff --git a/CSE/IO/cCriteria.vb b/CSE/IO/cCriteria.vb
index 96a9600..98e61a6 100644
--- a/CSE/IO/cCriteria.vb
+++ b/CSE/IO/cCriteria.vb
@@ -57,6 +57,8 @@ Public Class cCriteria
         g.v_wind_avg_max_CAL = 5
         g.v_wind_1s_max_CAL = 8
         g.beta_avg_max_CAL = 5
+        g.v_veh_1s_delta_CAL = 1
+        g.v_veh_ave_delta_CAL = 2
 
         g.leng_crit = 3
 
@@ -194,6 +196,14 @@ Public Class cCriteria
                             "description": "Maximum average beta (calibration).", 
                             "units": "°", 
                         },
+                        "v_veh_1s_delta_CAL": {"type": "number", "required": true, 
+                            "description": "+/- maximum deviation of 1s average vehicle speed from average vehicle speed over entire section (calibration).", 
+                            "units": "km/h", 
+                        },
+                        "v_veh_ave_delta_CAL": {"type": "number", "required": true, 
+                            "description": "+/- maximum deviation of average speeds per heading (calibration).", 
+                            "units": "km/h", 
+                        },
 
                         "leng_crit": {"type": "number", "required": true, 
                             "description": "Maximum absolute difference of distance driven with length of section as specified in configuration", 
@@ -347,6 +357,8 @@ Public Class cCriteria
     Public v_wind_avg_max_CAL As Single
     Public v_wind_1s_max_CAL As Single
     Public beta_avg_max_CAL As Single
+    Public v_veh_1s_delta_CAL As Single
+    Public v_veh_ave_delta_CAL As Single
     Public v_veh_avg_max_LS As Single
     Public v_veh_avg_min_LS As Single
     Public v_veh_float_delta_LS As Single
@@ -401,6 +413,8 @@ Public Class cCriteria
         Me.v_wind_avg_max_CAL = g("v_wind_avg_max_CAL")
         Me.v_wind_1s_max_CAL = g("v_wind_1s_max_CAL")
         Me.beta_avg_max_CAL = g("beta_avg_max_CAL")
+        Me.v_veh_1s_delta_CAL = g("v_veh_1s_delta_CAL")
+        Me.v_veh_ave_delta_CAL = g("v_veh_ave_delta_CAL")
 
         Me.v_veh_avg_max_LS = g("v_veh_avg_max_LS")
         Me.v_veh_avg_min_LS = g("v_veh_avg_min_LS")
@@ -461,6 +475,8 @@ Public Class cCriteria
         g.v_wind_avg_max_CAL = Me.v_wind_avg_max_CAL
         g.v_wind_1s_max_CAL = Me.v_wind_1s_max_CAL
         g.beta_avg_max_CAL = Me.beta_avg_max_CAL
+        g.v_veh_1s_delta_CAL = Me.v_veh_1s_delta_CAL
+        g.v_veh_ave_delta_CAL = Me.v_veh_ave_delta_CAL
 
         g.leng_crit = Me.leng_crit
 
diff --git a/CSE/IO/output.vb b/CSE/IO/output.vb
index f417a1e..663b223 100644
--- a/CSE/IO/output.vb
+++ b/CSE/IO/output.vb
@@ -387,6 +387,8 @@ Module output
             AddToErg(tCompErg.val_vWind, fCompName(tCompErg.val_vWind), fCompUnit(tCompErg.val_vWind), "ErgValues")
             AddToErg(tCompErg.val_vWind_1s, fCompName(tCompErg.val_vWind_1s), fCompUnit(tCompErg.val_vWind_1s), "ErgValues")
             AddToErg(tCompErg.val_beta, fCompName(tCompErg.val_beta), fCompUnit(tCompErg.val_beta), "ErgValues")
+            AddToErg(tCompErg.val_vVeh_avg, fCompName(tCompErg.val_vVeh_avg), fCompUnit(tCompErg.val_vVeh_avg), "ErgValues")
+            AddToErg(tCompErg.val_vVeh_1s, fCompName(tCompErg.val_vVeh_1s), fCompUnit(tCompErg.val_vVeh_1s), "ErgValues")
         End If
 
         If Not calibration Then
diff --git a/CSE/My Project/AssemblyInfo.vb b/CSE/My Project/AssemblyInfo.vb
index 2cd22c0..b907527 100644
--- a/CSE/My Project/AssemblyInfo.vb	
+++ b/CSE/My Project/AssemblyInfo.vb	
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
 ' übernehmen, indem Sie "*" eingeben:
 ' <Assembly: AssemblyVersion("1.0.*")> 
 
-<Assembly: AssemblyVersion("2.0.1.0")> 
-<Assembly: AssemblyFileVersion("2.0.1.0")> 
+<Assembly: AssemblyVersion("3.0.7.0")> 
+<Assembly: AssemblyFileVersion("3.0.7.0")> 
diff --git a/CSE/declaration_public.vb b/CSE/declaration_public.vb
index 29f036d..e754d3b 100644
--- a/CSE/declaration_public.vb
+++ b/CSE/declaration_public.vb
@@ -13,7 +13,7 @@ Module declaration_public
 
     ' Description of the form
     Public Const AppName As String = "Air Drag"                 ' Name of the programm
-    Public Const AppVers As String = "3.0.6"                    ' Version of the Programm
+    Public Const AppVers As String = "3.0.7"                    ' Version of the Programm
     Public AppDate As String                                    ' Date of the compilation of the programm
 
     ' Control variables
-- 
GitLab