From 89be852c4d27c5bf84f24402fe4d0704c1de0ae3 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 25 May 2020 19:21:16 +0200
Subject: [PATCH] allow to override lookahead coasting from GUI for evaluation
 (not persistent, HACK!)

---
 VECTO/GUI/MainForm.Designer.vb | 91 ++++++++++++++++++++++++++++++----
 VECTO/GUI/MainForm.vb          | 11 ++++
 2 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/VECTO/GUI/MainForm.Designer.vb b/VECTO/GUI/MainForm.Designer.vb
index c4b227b659..b130f5f2bb 100644
--- a/VECTO/GUI/MainForm.Designer.vb
+++ b/VECTO/GUI/MainForm.Designer.vb
@@ -59,10 +59,16 @@ Partial Class MainForm
         Me.ButtonGENadd = New System.Windows.Forms.Button()
         Me.TabPgOptions = New System.Windows.Forms.TabPage()
         Me.PanelOptAllg = New System.Windows.Forms.Panel()
+        Me.GroupBox5 = New System.Windows.Forms.GroupBox()
+        Me.Label4 = New System.Windows.Forms.Label()
+        Me.tbMinSpeedLAC = New System.Windows.Forms.TextBox()
+        Me.Label3 = New System.Windows.Forms.Label()
+        Me.Label2 = New System.Windows.Forms.Label()
         Me.GroupBox4 = New System.Windows.Forms.GroupBox()
         Me.BtTCfileBrowse = New System.Windows.Forms.Button()
         Me.tbOutputFolder = New System.Windows.Forms.TextBox()
         Me.GroupBox3 = New System.Windows.Forms.GroupBox()
+        Me.cbSaveVectoRunData = New System.Windows.Forms.CheckBox()
         Me.cbActVmod = New System.Windows.Forms.CheckBox()
         Me.cbValidateRunData = New System.Windows.Forms.CheckBox()
         Me.GroupBox2 = New System.Windows.Forms.GroupBox()
@@ -119,13 +125,14 @@ Partial Class MainForm
         Me.OpenInGraphWindowToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
         Me.ShowInFolderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
         Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
-        Me.cbSaveVectoRunData = New System.Windows.Forms.CheckBox()
+        Me.Label5 = New System.Windows.Forms.Label()
         Me.StatusBAR.SuspendLayout
         Me.TabControl1.SuspendLayout
         Me.TabPageGEN.SuspendLayout
         CType(Me.PictureBox1,System.ComponentModel.ISupportInitialize).BeginInit
         Me.TabPgOptions.SuspendLayout
         Me.PanelOptAllg.SuspendLayout
+        Me.GroupBox5.SuspendLayout
         Me.GroupBox4.SuspendLayout
         Me.GroupBox3.SuspendLayout
         Me.GroupBox2.SuspendLayout
@@ -380,6 +387,7 @@ Partial Class MainForm
         '
         'PanelOptAllg
         '
+        Me.PanelOptAllg.Controls.Add(Me.GroupBox5)
         Me.PanelOptAllg.Controls.Add(Me.GroupBox4)
         Me.PanelOptAllg.Controls.Add(Me.GroupBox3)
         Me.PanelOptAllg.Controls.Add(Me.GroupBox2)
@@ -389,6 +397,53 @@ Partial Class MainForm
         Me.PanelOptAllg.Size = New System.Drawing.Size(1022, 290)
         Me.PanelOptAllg.TabIndex = 0
         '
+        'GroupBox5
+        '
+        Me.GroupBox5.Controls.Add(Me.Label5)
+        Me.GroupBox5.Controls.Add(Me.Label4)
+        Me.GroupBox5.Controls.Add(Me.tbMinSpeedLAC)
+        Me.GroupBox5.Controls.Add(Me.Label3)
+        Me.GroupBox5.Controls.Add(Me.Label2)
+        Me.GroupBox5.Location = New System.Drawing.Point(183, 57)
+        Me.GroupBox5.Name = "GroupBox5"
+        Me.GroupBox5.Size = New System.Drawing.Size(260, 100)
+        Me.GroupBox5.TabIndex = 20
+        Me.GroupBox5.TabStop = false
+        Me.GroupBox5.Text = "Look-Ahead Coasting Override"
+        '
+        'Label4
+        '
+        Me.Label4.AutoSize = true
+        Me.Label4.Location = New System.Drawing.Point(10, 44)
+        Me.Label4.Name = "Label4"
+        Me.Label4.Size = New System.Drawing.Size(0, 13)
+        Me.Label4.TabIndex = 3
+        '
+        'tbMinSpeedLAC
+        '
+        Me.tbMinSpeedLAC.Location = New System.Drawing.Point(96, 17)
+        Me.tbMinSpeedLAC.Name = "tbMinSpeedLAC"
+        Me.tbMinSpeedLAC.Size = New System.Drawing.Size(56, 20)
+        Me.tbMinSpeedLAC.TabIndex = 2
+        '
+        'Label3
+        '
+        Me.Label3.AutoSize = true
+        Me.Label3.Location = New System.Drawing.Point(158, 20)
+        Me.Label3.Name = "Label3"
+        Me.Label3.Size = New System.Drawing.Size(38, 13)
+        Me.Label3.TabIndex = 1
+        Me.Label3.Text = "[km/h]"
+        '
+        'Label2
+        '
+        Me.Label2.AutoSize = true
+        Me.Label2.Location = New System.Drawing.Point(7, 20)
+        Me.Label2.Name = "Label2"
+        Me.Label2.Size = New System.Drawing.Size(64, 13)
+        Me.Label2.TabIndex = 0
+        Me.Label2.Text = "Min. Speed:"
+        '
         'GroupBox4
         '
         Me.GroupBox4.Controls.Add(Me.BtTCfileBrowse)
@@ -429,6 +484,16 @@ Partial Class MainForm
         Me.GroupBox3.TabStop = false
         Me.GroupBox3.Text = "Misc"
         '
+        'cbSaveVectoRunData
+        '
+        Me.cbSaveVectoRunData.AutoSize = true
+        Me.cbSaveVectoRunData.Location = New System.Drawing.Point(7, 86)
+        Me.cbSaveVectoRunData.Name = "cbSaveVectoRunData"
+        Me.cbSaveVectoRunData.Size = New System.Drawing.Size(166, 17)
+        Me.cbSaveVectoRunData.TabIndex = 19
+        Me.cbSaveVectoRunData.Text = "Export ModelData (EXPERT!)"
+        Me.cbSaveVectoRunData.UseVisualStyleBackColor = true
+        '
         'cbActVmod
         '
         Me.cbActVmod.Location = New System.Drawing.Point(6, 34)
@@ -855,15 +920,15 @@ Partial Class MainForm
         Me.ShowInFolderToolStripMenuItem.Size = New System.Drawing.Size(173, 22)
         Me.ShowInFolderToolStripMenuItem.Text = "Show in Folder"
         '
-        'cbSaveVectoRunData
+        'Label5
         '
-        Me.cbSaveVectoRunData.AutoSize = true
-        Me.cbSaveVectoRunData.Location = New System.Drawing.Point(7, 86)
-        Me.cbSaveVectoRunData.Name = "cbSaveVectoRunData"
-        Me.cbSaveVectoRunData.Size = New System.Drawing.Size(166, 17)
-        Me.cbSaveVectoRunData.TabIndex = 19
-        Me.cbSaveVectoRunData.Text = "Export ModelData (EXPERT!)"
-        Me.cbSaveVectoRunData.UseVisualStyleBackColor = true
+        Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0,Byte))
+        Me.Label5.Location = New System.Drawing.Point(7, 48)
+        Me.Label5.Name = "Label5"
+        Me.Label5.Size = New System.Drawing.Size(247, 36)
+        Me.Label5.TabIndex = 4
+        Me.Label5.Text = "Overrides Look-Ahead Coasting in declaration mode. Leave empty to use default beh"& _ 
+    "aviour."
         '
         'MainForm
         '
@@ -887,6 +952,8 @@ Partial Class MainForm
         CType(Me.PictureBox1,System.ComponentModel.ISupportInitialize).EndInit
         Me.TabPgOptions.ResumeLayout(false)
         Me.PanelOptAllg.ResumeLayout(false)
+        Me.GroupBox5.ResumeLayout(false)
+        Me.GroupBox5.PerformLayout
         Me.GroupBox4.ResumeLayout(false)
         Me.GroupBox4.PerformLayout
         Me.GroupBox3.ResumeLayout(false)
@@ -1002,4 +1069,10 @@ End Sub
     Friend WithEvents tbOutputFolder As TextBox
     Friend WithEvents BtTCfileBrowse As Button
     Friend WithEvents cbSaveVectoRunData As CheckBox
+    Friend WithEvents GroupBox5 As GroupBox
+    Friend WithEvents Label4 As Label
+    Friend WithEvents tbMinSpeedLAC As TextBox
+    Friend WithEvents Label3 As Label
+    Friend WithEvents Label2 As Label
+    Friend WithEvents Label5 As Label
 End Class
diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb
index c480ad7897..2c021df474 100644
--- a/VECTO/GUI/MainForm.vb
+++ b/VECTO/GUI/MainForm.vb
@@ -53,6 +53,7 @@ Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration
 Imports TUGraz.VectoCore.InputData.FileIO.XML.Engineering
 Imports TUGraz.VectoCore.Models.Simulation
 Imports TUGraz.VectoCore.Models.Declaration
+Imports TUGraz.VectoCore.Models.SimulationComponent.Data
 Imports TUGraz.VectoCore.OutputData
 Imports TUGraz.VectoCore.OutputData.FileIO
 Imports TUGraz.VectoCore.Utils
@@ -1007,7 +1008,16 @@ Imports TUGraz.VectoCore.Utils
                     fileWriters.Add(runId, fileWriter)
                 Next
 
+                ' TODO MQ-20200525: Remove the following loop in production (or after evaluation of LAC!!
+                If not string.IsNullOrWhiteSpace(tbMinSpeedLAC.Text) then
+                    for Each run as JobContainer.RunEntry In jobContainer.Runs
+                        dim tmpDriver as DriverData = CType(run.Run, VectoRun).GetContainer().RunData.DriverData
+                        tmpDriver.LookAheadCoasting.Enabled = True
+                        tmpDriver.LookAheadCoasting.MinSpeed = tbMinSpeedLAC.Text.ToDouble().KMPHtoMeterPerSecond()
+                    Next
+                end if
 
+                    
                 sender.ReportProgress(0,
                                       New VectoProgress _
                                          With {.Target = "ListBox",
@@ -2139,6 +2149,7 @@ Imports TUGraz.VectoCore.Utils
         tbOutputFolder.Text = Path.GetFullPath(filePath)
     End Sub
 
+    
 End Class
 
 
-- 
GitLab