Newer
Older
' This file is part of VECTO.
'
' Copyright © 2012-2016 European Union
'
' Developed by Graz University of Technology,
' Institute of Internal Combustion Engines and Thermodynamics,
' Institute of Technical Informatics
'
' VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
' by the European Commission - subsequent versions of the EUPL (the "Licence");
' You may not use VECTO except in compliance with the Licence.
' You may obtain a copy of the Licence at:
'
' https://joinup.ec.europa.eu/community/eupl/og_page/eupl
'
' Unless required by applicable law or agreed to in writing, VECTO
' distributed under the Licence is distributed on an "AS IS" basis,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the Licence for the specific language governing permissions and
' limitations under the Licence.
'
' Authors:
' Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
' Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
' Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
' Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
' Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
' Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.IO
Imports System.Linq
Imports TUGraz.VectoCore.Models.Simulation.Impl

Markus Quaritsch
committed
Imports TUGraz.VectoCore.InputData.FileIO.JSON
Imports System.Xml
Imports System.Xml.Linq
Imports Microsoft.VisualBasic.FileIO
Imports TUGraz.VectoCommon.Exceptions

Markus Quaritsch
committed
Imports TUGraz.VectoCommon.InputData
Imports TUGraz.VectoCommon.Models

Markus Quaritsch
committed
Imports TUGraz.VectoCommon.Resources

Markus Quaritsch
committed
Imports TUGraz.VectoCommon.Utils
Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration
Imports TUGraz.VectoCore.InputData.FileIO.XML.Engineering

Markus Quaritsch
committed
Imports TUGraz.VectoCore.OutputData
Imports TUGraz.VectoCore.OutputData.FileIO

Markus Quaritsch
committed
Imports TUGraz.VectoCore.Utils
''' <summary>
''' Main application form. Loads at application start. Closing form ends application.
''' </summary>
''' <remarks></remarks>

Markus Quaritsch
committed
Public Class MainForm
Private _jobListView As FileListView
Private _cycleListView As FileListView
Private _lastModeName As String
Private _conMenTarget As ListView
Private _conMenTarJob As Boolean
Private _checkLock As Boolean
Private _genChecked As Integer
Private _genCheckAllLock As Boolean
#Region "SLEEP Control - Prevent sleep while VECTO is running"

Markus Quaritsch
committed
Private Declare Function SetThreadExecutionState Lib "kernel32" (esFlags As Long) As Long
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS Or EXECUTION_STATE.ES_SYSTEM_REQUIRED)
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS)
''' Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared.
ES_CONTINUOUS = &H80000000
''' Forces the display to be on by resetting the display idle timer.
ES_DISPLAY_REQUIRED = &H2
''' Forces the system to be in the working state by resetting the system idle timer.
ES_SYSTEM_REQUIRED = &H1
End Enum
#End Region
#Region "FileBrowser Init/Close"
FileBrowserFolderHistoryIninialized = False

Markus Quaritsch
committed
COREvers = VectoSimulationCore.VersionNumber()
LogFile.WriteToLog(MessageType.Err, ex.StackTrace)
FolderFileBrowser = New FileBrowser("WorkDir", True)
TextFileBrowser = New FileBrowser("FileLists")
JobfileFileBrowser = New FileBrowser("vecto")
VehicleFileBrowser = New FileBrowser("vveh")
VehicleXMLFileBrowser = New FileBrowser("vveh_xml")
FuelConsumptionMapFileBrowser = New FileBrowser("vmap")
DrivingCycleFileBrowser = New FileBrowser("vdri")
FullLoadCurveFileBrowser = New FileBrowser("vfld")
EngineFileBrowser = New FileBrowser("veng")
GearboxFileBrowser = New FileBrowser("vgbx")
DriverAccelerationFileBrowser = New FileBrowser("vacc")
AuxFileBrowser = New FileBrowser("vaux")
GearboxShiftPolygonFileBrowser = New FileBrowser("vgbs")
RetarderLossMapFileBrowser = New FileBrowser("vrlm")
TransmissionLossMapFileBrowser = New FileBrowser("vtlm")
PtoLossMapFileBrowser = New FileBrowser("vptol")
PTODrivingCycleFileBrowser = New FileBrowser("vptoc")
TorqueConverterFileBrowser = New FileBrowser("vtcc")
TorqueConverterShiftPolygonFileBrowser = New FileBrowser("vgbs")
CrossWindCorrectionFileBrowser = New FileBrowser("vcdx")
DriverDecisionFactorVelocityDropFileBrowser = New FileBrowser("DfVelocityDrop")
DriverDecisionFactorTargetSpeedFileBrowser = New FileBrowser("DfTargetSpeed")
DriverDecisionFactorVelocityDropFileBrowser.Extensions = New String() {"csv"}
DriverDecisionFactorTargetSpeedFileBrowser.Extensions = New String() {"csv"}
ModalResultsFileBrowser = New FileBrowser("vmod")
'-------------------------------------------------------
TextFileBrowser.Extensions = New String() {"txt"}
JobfileFileBrowser.Extensions = New String() {"vecto"}
VehicleFileBrowser.Extensions = New String() {"vveh"}
VehicleXMLFileBrowser.Extensions = New String() {"xml"}
FuelConsumptionMapFileBrowser.Extensions = New String() {"vmap"}
DrivingCycleFileBrowser.Extensions = New String() {"vdri"}
FullLoadCurveFileBrowser.Extensions = New String() {"vfld"}
EngineFileBrowser.Extensions = New String() {"veng"}
GearboxFileBrowser.Extensions = New String() {"vgbx"}
DriverAccelerationFileBrowser.Extensions = New String() {"vacc"}
AuxFileBrowser.Extensions = New String() {"vaux"}
GearboxShiftPolygonFileBrowser.Extensions = New String() {"vgbs"}
RetarderLossMapFileBrowser.Extensions = New String() {"vrlm"}
TransmissionLossMapFileBrowser.Extensions = New String() {"vtlm"}
PtoLossMapFileBrowser.Extensions = New String() {"vptol"}
PTODrivingCycleFileBrowser.Extensions = New String() {"vptoc"}
TorqueConverterFileBrowser.Extensions = New String() {"vtcc"}
TorqueConverterShiftPolygonFileBrowser.Extensions = New String() {"vgbs"}
CrossWindCorrectionFileBrowser.Extensions = New String() {"vcdv", "vcdb"}
ModalResultsFileBrowser.Extensions = New String() {"vmod"}
End Sub
Private Sub FB_Close()
FolderFileBrowser.Close()
TextFileBrowser.Close()
JobfileFileBrowser.Close()
VehicleFileBrowser.Close()
FuelConsumptionMapFileBrowser.Close()
DrivingCycleFileBrowser.Close()
FullLoadCurveFileBrowser.Close()
EngineFileBrowser.Close()
GearboxFileBrowser.Close()
DriverAccelerationFileBrowser.Close()
AuxFileBrowser.Close()
GearboxShiftPolygonFileBrowser.Close()
RetarderLossMapFileBrowser.Close()
TransmissionLossMapFileBrowser.Close()
PTODrivingCycleFileBrowser.Close()
TorqueConverterFileBrowser.Close()
TorqueConverterShiftPolygonFileBrowser.Close()
CrossWindCorrectionFileBrowser.Close()
ModalResultsFileBrowser.Close()
'Lock certain GUI elements while VECTO is running
Private Sub LockGUI(lock As Boolean)
_guIlocked = lock
BtGENup.Enabled = Not lock
BtGENdown.Enabled = Not lock
ButtonGENadd.Enabled = Not lock
ButtonGENremove.Enabled = Not lock
LvGEN.LabelEdit = Not lock
ChBoxAllGEN.Enabled = Not lock
#Region "Form Init/Close"

Michael KRISPER
committed
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
_guIlocked = False
_checkLock = False
_genCheckAllLock = False
_genChecked = 0
'Load Tabs properly (otherwise problem with ListViews)

Michael KRISPER
committed
For x = 0 To TabControl1.TabCount - 1
TabControl1.TabPages(x).Show()

Michael KRISPER
committed
Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
_jobListView = New FileListView(MyConfPath & "joblist.txt")
_jobListView.LVbox = LvGEN
_cycleListView = New FileListView(MyConfPath & "cyclelist.txt")
LoadOptions()
'Resize columns ... after Loading the @file-lists

Markus Quaritsch
committed
LvGEN.Columns(1).Width = -2
LvMsg.Columns(2).Width = -2
'Initialize BackgroundWorker
VectoWorkerV3 = New BackgroundWorker()
AddHandler VectoWorkerV3.DoWork, AddressOf VectoWorkerV3_OnDoWork
AddHandler VectoWorkerV3.ProgressChanged, AddressOf VectoWorkerV3_OnProgressChanged
AddHandler VectoWorkerV3.RunWorkerCompleted, AddressOf VectoWorkerV3_OnRunWorkerCompleted
VectoWorkerV3.WorkerReportsProgress = True
VectoWorkerV3.WorkerSupportsCancellation = True
'Set mode (Batch/Standard)
ModeUpdate()
DeclOnOff()
End Sub
' ReSharper disable once UnusedMember.Global -- used via Logging Framework!
Public Shared Sub LogMethod(level As String, message As String)
If VectoWorkerV3.IsBusy AndAlso Not VectoWorkerV3.CancellationPending Then
VectoWorkerV3.ReportProgress(100, New VectoProgress With {.Target = "ListBoxWarning", .Message = message})
ElseIf level = "Error" Or level = "Fatal" Then
VectoWorkerV3.ReportProgress(100, New VectoProgress With {.Target = "ListBoxError", .Message = message})
'Declaration mode GUI settings
Private Sub DeclOnOff()
If Cfg.DeclMode Then
Text = "VECTO " & COREvers & " - Declaration Mode"
Text = "VECTO " & COREvers
End If
If Cfg.DeclMode Then

Michael KRISPER
committed
LoadOptions()

Michael KRISPER
committed
LbDecl.Visible = Cfg.DeclMode
End Sub
'Shown Event (Form-Load finished) ... here StartUp Forms are loaded (DEV, GEN/ADV- Editor ..)

Michael KRISPER
committed
Private Sub F01_MAINForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown
Dim fwelcome As WelcomeDialog
If Cfg.FirstRun Then
Cfg.FirstRun = False
fwelcome = New WelcomeDialog
fwelcome.ShowDialog()
End If
End Sub
'Open file
'Close

Michael KRISPER
committed
Private Sub F01_MAINForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
'Save File-Lists
SaveFileLists()
'Close log
LogFile.CloseLog()
'Config save
SetOptions()

Michael KRISPER
committed
Cfg.Save()
'File browser instances close
FB_Close()
End Sub
'Open file - Job, vehicle, engine, gearbox or signature file
Public Sub OpenVectoFile(file As String)
GUIMsg(MessageType.Err, "File not found! (" & file & ")")
MsgBox("File not found! (" & file & ")", MsgBoxStyle.Critical)
If Not GearboxForm.Visible Then
GearboxForm.Show()
GearboxForm.JobDir = ""
If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal
GearboxForm.BringToFront()

Markus Quaritsch
committed
Try

Markus Quaritsch
committed
GearboxForm.OpenGbx(file, VehicleCategory.RigidTruck)

Markus Quaritsch
committed
Catch ex As Exception
MsgBox("Failed to open Gearbox File: " + ex.Message)
End Try
If Not VehicleForm.Visible Then
VehicleForm.Show()
VehicleForm.JobDir = ""
If VehicleForm.WindowState = FormWindowState.Minimized Then VehicleForm.WindowState = FormWindowState.Normal
VehicleForm.BringToFront()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File")
End Try
If Not EngineForm.Visible Then
EngineForm.Show()
EngineForm.JobDir = ""
If EngineForm.WindowState = FormWindowState.Minimized Then EngineForm.WindowState = FormWindowState.Normal
EngineForm.BringToFront()

Markus Quaritsch
committed
Try
EngineForm.OpenEngineFile(file)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Engine File")
End Try
MsgBox("Type '" & GetExtension(file) & "' unknown!", MsgBoxStyle.Critical)
End Select
End If
End Sub
#Region "Events"

Michael KRISPER
committed
Private Sub ButtonGENremove_Click(sender As Object, e As EventArgs) _
Handles ButtonGENremove.Click
RemoveJobFile()
End Sub

Michael KRISPER
committed
Private Sub ButtonGENadd_Click(sender As Object, e As EventArgs) _
Handles ButtonGENadd.Click
AddJobFile()
End Sub

Michael KRISPER
committed
Private Sub ListViewGEN_KeyDown(sender As Object, e As KeyEventArgs) _
Handles LvGEN.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
Case Keys.Enter
OpenJobFile()
End Select
End Sub

Michael KRISPER
committed
Private Sub ListViewGEN_DoubleClick(sender As Object, e As EventArgs) Handles LvGEN.DoubleClick
If LvGEN.SelectedItems.Count > 0 Then
LvGEN.SelectedItems(0).Checked = Not LvGEN.SelectedItems(0).Checked
OpenJobFile()
End If
End Sub

Michael KRISPER
committed
Private Sub LvGEN_ItemChecked(sender As Object, e As ItemCheckedEventArgs) _
Handles LvGEN.ItemChecked
If e.Item.Checked Then
UpdateJobTabText()
End Sub

Michael KRISPER
committed
Private Sub ChBoxAllGEN_CheckedChanged(sender As Object, e As EventArgs) _
Handles ChBoxAllGEN.CheckedChanged
If _genCheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub
Private Sub CheckAllGen(check As Boolean)

Michael KRISPER
committed
LvGEN.BeginUpdate()

Michael KRISPER
committed
For Each x In LvGEN.Items

Michael KRISPER
committed
LvGEN.EndUpdate()
UpdateJobTabText()
End Sub

Michael KRISPER
committed
Private Sub ListGEN_DragEnter(sender As Object, e As DragEventArgs) _
Handles LvGEN.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Michael KRISPER
committed
Private Sub ListGEN_DragDrop(sender As Object, e As DragEventArgs) _
Handles LvGEN.DragDrop
Dim f As String()
f = CType(e.Data.GetData(DataFormats.FileDrop), String())
AddToJobListView(f)
End Sub

Michael KRISPER
committed
Private Sub BtGENup_Click(sender As Object, e As EventArgs) Handles BtGENup.Click
MoveItem(LvGEN, True)
End Sub

Michael KRISPER
committed
Private Sub BtGENdown_Click(sender As Object, e As EventArgs) Handles BtGENdown.Click
MoveItem(LvGEN, False)
End Sub
'Remove selected file(s) from job list
Private Sub RemoveJobFile()
Dim lastindx As Integer

Michael KRISPER
committed
If LvGEN.SelectedItems.Count < 1 Then
If LvGEN.Items.Count = 1 Then
LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If
LvGEN.BeginUpdate()
ReDim selIx(LvGEN.SelectedItems.Count - 1)
LvGEN.SelectedIndices.CopyTo(selIx, 0)
lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1)

Markus Quaritsch
committed
For i = UBound(selIx) To 0 Step -1
Next
If lastindx < LvGEN.Items.Count Then
LvGEN.Items(lastindx).Selected = True
Else
If LvGEN.Items.Count > 0 Then LvGEN.Items(LvGEN.Items.Count - 1).Selected = True
End If
LvGEN.EndUpdate()
UpdateJobTabText()
End Sub
'Browse for job file(s) and add to job list with AddToJobListView
Private Sub AddJobFile()
Dim x As String()
Dim inputDataExtensions As String() = New String() {"xml"}
If (inputDataExtensions.Any()) Then extensions = String.Join(",", extensions, String.Join(",", inputDataExtensions))
If JobfileFileBrowser.OpenDialog("", True, extensions) Then
x = JobfileFileBrowser.Files
End Sub
'Open file in list
Private Sub OpenJobFile()
Dim f As String

Michael KRISPER
committed
If LvGEN.SelectedItems.Count < 1 Then
If LvGEN.Items.Count = 1 Then
LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If

Michael KRISPER
committed
f = LvGEN.SelectedItems(0).SubItems(0).Text
If Path.GetExtension(f) <> VectoCore.Configuration.Constants.FileExtensions.VectoJobFile Then
MsgBox("Job File " + f + " can not be opened in Job Editor. Try importing the file.")
Exit Sub
End If

Michael KRISPER
committed
If Not File.Exists(f) Then
MsgBox(f & " not found!")
Else
OpenVECTOeditor(f)
End If
End Sub
'Add File to job listview (multiple files)
Private Sub AddToJobListView(path As String(), Optional ByVal txt As String = " ")
Dim pDim As Integer
Dim p As Integer
Dim f As Integer

Markus Quaritsch
committed
Dim fListDim As Integer = -1
Dim listViewItem As ListViewItem
'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever)
If VectoWorkerV3.IsBusy Then Exit Sub
ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern
'******************************************* Begin Update '*******************************************

Michael KRISPER
committed
LvGEN.BeginUpdate()

Michael KRISPER
committed
LvGEN.SelectedIndices.Clear()

Michael KRISPER
committed
fListDim = LvGEN.Items.Count - 1
ReDim fList(fListDim)
For f = 0 To fListDim
fList(f) = FileRepl(LvGEN.Items(f).SubItems(0).Text)
Next
End If
For p = 0 To pDim
If pDim = 0 Then
For f = 0 To fListDim
'If file already exists in the list: Do not append (only when a single file)
If UCase(path(p)) = UCase(fList(f)) Then

Michael KRISPER
committed
LvGEN.Items(f).BackColor = Color.FromKnownColor(KnownColor.Window)
LvGEN.Items(f).ForeColor = Color.FromKnownColor(KnownColor.WindowText)
'Element auswählen und anhaken |@@| Element selection and hook

Michael KRISPER
committed
LvGEN.Items(f).Selected = True
LvGEN.Items(f).Checked = True
LvGEN.Items(f).EnsureVisible()
GoTo lbFound
End If
Next
End If
'Otherwise: Add File (without WorkDir)
listViewItem = New ListViewItem(path(p)) 'fFileWD(Path(p)))
listViewItem.SubItems.Add(" ")
listViewItem.Checked = True
listViewItem.Selected = True
LvGEN.Items.Add(listViewItem)
listViewItem.EnsureVisible()

Markus Quaritsch
committed
lbFound:

Michael KRISPER
committed
LvGEN.EndUpdate()
'******************************************* End Update '*******************************************
'Add File to job listview (single file)
Public Sub AddToJobListView(path As String, Optional ByVal txt As String = " ")
p(0) = path
AddToJobListView(p, txt)
'Update job files counter in tab titel
Private Sub UpdateJobTabText()
TabPageGEN.Text = String.Format("Job Files ( {0} / {1} )", _genChecked, count)

Michael KRISPER
committed
ChBoxAllGEN.CheckState = CheckState.Unchecked

Michael KRISPER
committed
ChBoxAllGEN.CheckState = CheckState.Checked

Michael KRISPER
committed
ChBoxAllGEN.CheckState = CheckState.Indeterminate
#Region "Toolstrip"

Michael KRISPER
committed
Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click
OpenVECTOeditor("<New>")
End Sub
'Open input file

Michael KRISPER
committed
Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click
If JobfileFileBrowser.OpenDialog("", False, "vecto,vveh,vgbx,veng") Then
OpenVectoFile(JobfileFileBrowser.Files(0))

Michael KRISPER
committed
Private Sub GENEditorToolStripMenuItem1_Click(sender As Object, e As EventArgs) _
Handles GENEditorToolStripMenuItem1.Click
OpenVECTOeditor("<New>")
End Sub

Michael KRISPER
committed
Private Sub VEHEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles VEHEditorToolStripMenuItem.Click
If Not VehicleForm.Visible Then
VehicleForm.Show()
If VehicleForm.WindowState = FormWindowState.Minimized Then VehicleForm.WindowState = FormWindowState.Normal
VehicleForm.BringToFront()

Michael KRISPER
committed
Private Sub EngineEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles EngineEditorToolStripMenuItem.Click
If Not EngineForm.Visible Then
EngineForm.Show()
If EngineForm.WindowState = FormWindowState.Minimized Then EngineForm.WindowState = FormWindowState.Normal
EngineForm.BringToFront()

Michael KRISPER
committed
Private Sub GearboxEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles GearboxEditorToolStripMenuItem.Click
If Not GearboxForm.Visible Then
GearboxForm.Show()
If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal
GearboxForm.BringToFront()

Michael KRISPER
committed
Private Sub GraphToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles GraphToolStripMenuItem.Click
Dim graphForm As New GraphForm
graphForm.Show()

Michael KRISPER
committed
Private Sub OpenLogToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles OpenLogToolStripMenuItem.Click

Michael KRISPER
committed
Process.Start(MyAppPath & "log.txt")

Michael KRISPER
committed
Private Sub SettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles SettingsToolStripMenuItem.Click
Settings.ShowDialog()

Michael KRISPER
committed
Private Sub UserManualToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles UserManualToolStripMenuItem.Click

Michael KRISPER
committed
If File.Exists(MyAppPath & "User Manual\help.html") Then

Michael KRISPER
committed
Dim defaultBrowserPath As String = BrowserUtils.GetDefaultBrowserPath()
Process.Start(defaultBrowserPath, String.Format("""file://{0}{1}""", MyAppPath, "User Manual\help.html"))
Else
MsgBox("User Manual not found!", MsgBoxStyle.Critical)
End If
End Sub

Michael KRISPER
committed
Private Sub UpdateNotesToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles UpdateNotesToolStripMenuItem.Click

Michael KRISPER
committed
If File.Exists(MyAppPath & "User Manual\Release Notes.pdf") Then
Process.Start(MyAppPath & "User Manual\Release Notes.pdf")
Else
MsgBox("Release Notes not found!", MsgBoxStyle.Critical)
End If
End Sub
Private Sub ReportBugViaCITnetToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles ReportBugViaCITnetToolStripMenuItem.Click
JiraDialog.ShowDialog()

Michael KRISPER
committed
Private Sub AboutVECTOToolStripMenuItem1_Click(sender As Object, e As EventArgs) _
Handles AboutVECTOToolStripMenuItem1.Click
AboutBox.ShowDialog()
'Move job/cycle file up or down in list view
Private Sub MoveItem(ByRef listView As ListView, moveUp As Boolean)
Dim x As Integer
Dim y As Integer
Dim y1 As Integer
Dim items() As String
Dim check() As Boolean
Dim index() As Integer
ReDim items(y1)
ReDim check(y1)
ReDim index(y1)
y = 0
For Each x In listView.SelectedIndices
items(y) = listView.Items(x).SubItems(0).Text
check(y) = listView.Items(x).Checked
If moveUp Then
If x = 0 Then Exit Sub
index(y) = x - 1
Else
If x = listView.Items.Count - 1 Then Exit Sub
index(y) = x + 1
End If
y += 1
Next
For Each listViewItem In listView.SelectedItems
listViewItem.Remove()
Next
'Items select and Insert
For y = 0 To y1
If Not check(y) Then _genChecked += 1
listViewItem = listView.Items.Insert(index(y), items(y))
listViewItem.SubItems.Add(" ")
listViewItem.Checked = check(y)
listView.SelectedIndices.Add(index(y))
#Region "job/cycle file List - Context Menu"

Michael KRISPER
committed
Private Sub SaveListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles SaveListToolStripMenuItem.Click
If TextFileBrowser.SaveDialog("") Then
If _conMenTarJob Then
_jobListView.SaveList(TextFileBrowser.Files(0))
_cycleListView.SaveList(TextFileBrowser.Files(0))
End If
End If
End Sub
'Load List

Michael KRISPER
committed
Private Sub LoadListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles LoadListToolStripMenuItem.Click
If TextFileBrowser.OpenDialog("") Then
If _conMenTarJob Then 'GEN
_jobListView.LoadList(TextFileBrowser.Files(0))
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
Else 'DRI
'Mode toggle
_cycleListView.LoadList(TextFileBrowser.Files(0))
End If
End If
End Sub
'Load Default List

Michael KRISPER
committed
Private Sub LoadDefaultListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles LoadDefaultListToolStripMenuItem.Click
End If
End Sub
'Clear List

Michael KRISPER
committed
Private Sub ClearListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles ClearListToolStripMenuItem.Click
_conMenTarget.Items.Clear()
If _conMenTarJob Then
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End If
End Sub
'VECTO Start button - Calls VECTO_Launcher or aborts calculation
Private Sub btStartV3_Click(sender As Object, e As EventArgs) Handles btStartV3.Click
If Not VectoWorkerV3.IsBusy Then
'Save Lists for Crash
SaveFileLists()
If LvGEN.CheckedItems.Count = 0 Then
GUIMsg(MessageType.Err, "No job file selected!")
Status("Launching VECTO ...")
JobFileList.AddRange(

Markus Quaritsch
committed
From listViewItem As ListViewItem In LvGEN.CheckedItems.Cast(Of ListViewItem)()
Select fFileRepl = FileRepl(listViewItem.SubItems(0).Text))

Michael KRISPER
committed
Cfg.Save()
ClearMsg()
LockGUI(True)
btStartV3.Enabled = True
btStartV3.Text = "STOP"
btStartV3.Image = My.Resources.Stop_icon
ToolStripProgBarOverall.Value = 0
ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous
ToolStripProgBarOverall.Visible = True
VectoWorkerV3.RunWorkerAsync()
Else
btStartV3.Enabled = False
btStartV3.Text = "Aborting..."
btStartV3.Image = My.Resources.Play_icon_gray
VectoWorkerV3.CancelAsync()
Private Sub VectoWorkerV3_OnDoWork(theSender As Object, e As DoWorkEventArgs)
Dim sender As BackgroundWorker = TryCast(theSender, BackgroundWorker)
If sender Is Nothing Then Exit Sub

Michael KRISPER
committed
Dim sumFileWriter As FileOutputWriter = New FileOutputWriter(JobFileList(0))

Michael KRISPER
committed
Dim sumWriter As SummaryDataContainer = New SummaryDataContainer(sumFileWriter)
Dim jobContainer As JobContainer = New JobContainer(sumWriter)
Dim mode As ExecutionMode
If Cfg.DeclMode Then
mode = ExecutionMode.Declaration
Else
mode = ExecutionMode.Engineering

Markus Quaritsch
committed
Physics.AirDensity = Cfg.AirDensity.SI(Of KilogramPerCubicMeter)()

Michael KRISPER
committed
'dictionary of run-identifiers to fileWriters (used for output directory of modfile)

Michael KRISPER
committed
Dim fileWriters As Dictionary(Of Integer, FileOutputWriter) = New Dictionary(Of Integer, FileOutputWriter)

Michael KRISPER
committed
'list of finished runs
Dim finishedRuns As List(Of Integer) = New List(Of Integer)
For Each jobFile As String In JobFileList
Try
sender.ReportProgress(0,
New VectoProgress With {.Target = "ListBox", .Message = "Reading File " + jobFile, .Link = jobFile})

Michael KRISPER
committed
Dim extension As String = Path.GetExtension(jobFile)
Dim input As IInputDataProvider = Nothing
Select Case extension
Case VectoCore.Configuration.Constants.FileExtensions.VectoJobFile
input = JSONInputDataFactory.ReadJsonJob(jobFile)
Case ".xml"
Dim xDocument As XDocument = xDocument.Load(jobFile)
Dim rootNode As String = If(xDocument Is Nothing, "", xDocument.Root.Name.LocalName)
Select Case rootNode
Case XMLNames.VectoInputEngineering
input = New XMLEngineeringInputDataProvider(jobFile, True)
Case XMLNames.VectoInputDeclaration
input = New XMLDeclarationInputDataProvider(XmlReader.Create(jobFile), True)
End Select
End Select
If input Is Nothing Then
sender.ReportProgress(0,
New VectoProgress With {.Target = "ListBoxError", .Message = "No Input Provider for job: " + jobFile})
Continue For
Dim fileWriter As FileOutputWriter = New FileOutputWriter(jobFile)
Dim runsFactory As SimulatorFactory = New SimulatorFactory(mode, input, fileWriter)
runsFactory.WriteModalResults = Cfg.ModOut
runsFactory.ModalResults1Hz = Cfg.Mod1Hz
runsFactory.Validate = cbValidateRunData.Checked
runsFactory.ActualModalData = cbActVmod.Checked
For Each runId As Integer In jobContainer.AddRuns(runsFactory)
fileWriters.Add(runId, fileWriter)
Next
sender.ReportProgress(0,
New VectoProgress With {.Target = "ListBox", .Message = "Finished Reading Data for job: " + jobFile})

Michael KRISPER
committed
Catch ex As Exception
MsgBox(String.Format("ERROR running job {0}: {1}", jobFile, ex.Message), MsgBoxStyle.Critical)
sender.ReportProgress(0, New VectoProgress With {.Target = "ListBoxError", .Message = ex.Message})

Michael KRISPER
committed
'print detected cycles
For Each cycle As JobContainer.CycleTypeDescription In jobContainer.GetCycleTypes()
sender.ReportProgress(0,
New VectoProgress _
With {.Target = "ListBox", .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)})