From 5566382572fa05655ad4cef0d8984617b1c4b203 Mon Sep 17 00:00:00 2001
From: DIPPOLD Martin <Dippold@ivt.tugraz.at>
Date: Mon, 10 Nov 2014 08:09:19 +0100
Subject: [PATCH]   * Correction HS calculation   * Correction length
 calculation for the first section in the dat-file when there is a gap between
 the first and second MS.   * Update length calculation in csms-file to check
 if specified length from user and coordinates are the same   * New Version
 number.

---
 CHANGES.md                               |  8 ++++++
 CSE/Calculation/Signal_identification.vb | 24 +++++++++++++----
 CSE/Calculation/main_calculation_call.vb | 34 +++++++++++-------------
 CSE/declaration_public.vb                |  2 +-
 4 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index fdd9457..9cc36e4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,13 @@
 VECTO-CSE: Changes
 ===================
+#### 2014-09-30: v2.0.1-beta3 ####
+Mostly TUG improvements:
+
+  * Correction HS calculation
+  * Correction length calculation for the first section in the dat-file when there is a gap between the first and second MS.
+  * Update length calculation in csms-file to check if specified length from user and coordinates are the same
+  * New Version number.
+  
 #### 2014-09-30: v2.0.1-beta2 ####
 Mostly TUG improvements:
 
diff --git a/CSE/Calculation/Signal_identification.vb b/CSE/Calculation/Signal_identification.vb
index c97935f..39548c7 100644
--- a/CSE/Calculation/Signal_identification.vb
+++ b/CSE/Calculation/Signal_identification.vb
@@ -47,7 +47,9 @@ Module Signal_identification
         Dim i As Integer
         Dim first As Boolean = True
         Dim AddSec As Boolean = False
+        Dim LenDiff As Boolean = False
         Dim Aae As Double
+        Dim len(MSCOrg.meID.Count - 1) As Double
         Dim UTMCoordP As New cUTMCoord
         Dim UTMCoordV As New cUTMCoord
 
@@ -59,6 +61,7 @@ Module Signal_identification
             UTMCoordP = UTM(MSCOrg.latS(i) / 60, MSCOrg.longS(i) / 60)
             UTMCoordV = UTM(MSCOrg.latE(i) / 60, MSCOrg.longE(i) / 60)
             Aae = QuadReq(UTMCoordV.Easting - UTMCoordP.Easting, UTMCoordV.Northing - UTMCoordP.Northing)
+            len(i) = Math.Sqrt(Math.Pow(UTMCoordV.Easting - UTMCoordP.Easting, 2) + Math.Pow(UTMCoordV.Northing - UTMCoordP.Northing, 2))
             MSCVirt.meID.Add(MSCOrg.meID(i))
             MSCVirt.dID.Add(MSCOrg.dID(i))
             MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, 0, -Crt.trigger_delta_y_max))
@@ -71,20 +74,31 @@ Module Signal_identification
                     MSCVirt.NewSec.Add(True)
                     MSCVirt.meID.Add(0)
                     MSCVirt.dID.Add(MSCOrg.dID(i))
-                    MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -Crt.trigger_delta_y_max))
-                    MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), Crt.trigger_delta_y_max))
+                    MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, len(i), -Crt.trigger_delta_y_max))
+                    MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, len(i), Crt.trigger_delta_y_max))
                     MSCVirt.Head.Add(MSCOrg.head(i))
                 End If
             ElseIf i = MSCOrg.meID.Count - 1 Then
                 MSCVirt.NewSec.Add(True)
                 MSCVirt.meID.Add(0)
                 MSCVirt.dID.Add(MSCOrg.dID(i))
-                MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), -Crt.trigger_delta_y_max))
-                MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, MSCOrg.len(i), Crt.trigger_delta_y_max))
+                MSCVirt.KoordA.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, len(i), -Crt.trigger_delta_y_max))
+                MSCVirt.KoordE.Add(KleinPkt(UTMCoordP.Easting, UTMCoordP.Northing, Aae, len(i), Crt.trigger_delta_y_max))
                 MSCVirt.Head.Add(MSCOrg.head(i))
             End If
         Next i
 
+        ' Controll the spezified csms length
+        For i = 1 To MSCOrg.meID.Count - 1
+            If Math.Abs(len(i) - MSCOrg.len(i)) > Crt.leng_crit Then
+                If Not LenDiff Then logme(9, False, "Length difference between given coordinates and spezified section length in *.csms file!")
+                logme(9, False, "SecID(" & MSCOrg.meID(i) & "), DirID(" & MSCOrg.dID(i) & "), spez. Len(" & MSCOrg.len(i) & "), coord. Len(" & Math.Round(len(i), 2) & ")")
+                LenDiff = True
+            End If
+        Next i
+        ' Exit the programm
+        If LenDiff Then Throw New Exception(format("Length difference between given coordinates and spezified section length in *.csms file! Please correct the length!"))
+
         Return True
     End Function
 
@@ -582,7 +596,7 @@ Module Signal_identification
                 End If
             Else
                 ' Finish calculation after a valid section
-                If run > 0 And firstIn = False Then
+                If firstIn = False Then
                     ' Calculate the results from the last section
                     ErgValues(tCompErg.v_veh)(run) = ErgValues(tCompErg.v_veh)(run) / anz
                     ErgValues(tCompErg.dist)(run) = CalcData(tCompCali.dist)(i - 1) - ErgValues(tCompErg.dist)(run)
diff --git a/CSE/Calculation/main_calculation_call.vb b/CSE/Calculation/main_calculation_call.vb
index e7e11f5..faed7db 100644
--- a/CSE/Calculation/main_calculation_call.vb
+++ b/CSE/Calculation/main_calculation_call.vb
@@ -803,25 +803,21 @@ Public Module main_calculation_call
 
         ' Check if enough valid sections in both directionsection
         For i = 0 To SecCount.NameSec.Count - 1
-            For j = i + 1 To SecCount.NameSec.Count - 1
-                If Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), ",") + 1, InStr(SecCount.NameSec(i), ")") - (InStr(SecCount.NameSec(i), ",") + 1))) = Trim(Mid(SecCount.NameSec(j), InStr(SecCount.NameSec(j), ",") + 1, InStr(SecCount.NameSec(j), ")") - (InStr(SecCount.NameSec(j), ",") + 1))) Then
-                    ' If enought sections in both directions are detected
-                    If SecCount.AnzSec(i) >= Crt.segruns_min_HS And SecCount.AnzSec(j) >= Crt.segruns_min_HS Then
-                        ' Count the valid tests per HeadID
-                        Dim headId = Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), ",") + 1, InStr(SecCount.NameSec(i), ")") - (InStr(SecCount.NameSec(i), ",") + 1)))
-                        Select Case headId
-                            Case 1
-                                anzHS1 += SecCount.AnzSec(i) + SecCount.AnzSec(j)
-                            Case 2
-                                anzHS2 += SecCount.AnzSec(i) + SecCount.AnzSec(j)
-                            Case Else
-                                Throw New Exception(format("Unknown headID({0})!", headId))
-                        End Select
-                    Else
-                        Throw New Exception(format("Not enough valid data({0}) for high speed tests available in section({1})!", SecCount.AnzSec(i), Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))))
-                    End If
-                End If
-            Next j
+            ' If enought runs in the direction are detected
+            If SecCount.AnzSec(i) >= Crt.segruns_min_HS Then
+                ' Count the valid tests per HeadID
+                Dim headId = Trim(Mid(SecCount.NameSec(i), InStr(SecCount.NameSec(i), ",") + 1, InStr(SecCount.NameSec(i), ")") - (InStr(SecCount.NameSec(i), ",") + 1)))
+                Select Case headId
+                    Case 1
+                        anzHS1 += SecCount.AnzSec(i)
+                    Case 2
+                        anzHS2 += SecCount.AnzSec(i)
+                    Case Else
+                        Throw New Exception(format("Unknown headID({0})!", headId))
+                End Select
+            Else
+                Throw New Exception(format("Not enough valid data({0}) for high speed tests available in section({1})!", SecCount.AnzSec(i), Trim(Mid(SecCount.NameSec(i), 1, InStr(SecCount.NameSec(i), "(") - 2))))
+            End If
         Next i
 
         ' Ceck if enough sections are detected
diff --git a/CSE/declaration_public.vb b/CSE/declaration_public.vb
index 33afaae..8d76ca4 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 = "VECTO_CSE"                ' Name of the programm
-    Public Const AppVers As String = "2.0.1-beta2"              ' Version of the Programm
+    Public Const AppVers As String = "2.0.1-beta3"              ' Version of the Programm
     Public AppDate As String                                    ' Date of the compilation of the programm
 
     ' Control variables
-- 
GitLab