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>
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"
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)
Private Enum EXECUTION_STATE As Integer
''' 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"
Private Sub FB_Initialize()
FileBrowserFolderHistoryIninialized = False
Try
COREvers = VectoSimulationCore.VersionNumber()
Catch ex As Exception
LogFile.WriteToLog(MessageType.Err, ex.StackTrace)
End Try
FolderFileBrowser = New FileBrowser("WorkDir", True)
TextFileBrowser = New FileBrowser("FileLists")
JobfileFileBrowser = New FileBrowser("vecto")
VehicleFileBrowser = New FileBrowser("vveh")
VehicleXMLFileBrowser = New FileBrowser("vveh_xml")
ManRXMLFileBrowser = new FileBrowser("xml")
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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"}
ManRXMLFileBrowser.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()
VehicleXMLFileBrowser.Close()
ManRXMLFileBrowser.Close()
FuelConsumptionMapFileBrowser.Close()
DrivingCycleFileBrowser.Close()
FullLoadCurveFileBrowser.Close()
EngineFileBrowser.Close()
GearboxFileBrowser.Close()
DriverAccelerationFileBrowser.Close()
AuxFileBrowser.Close()
GearboxShiftPolygonFileBrowser.Close()
RetarderLossMapFileBrowser.Close()
TransmissionLossMapFileBrowser.Close()
PtoLossMapFileBrowser.Close()
PTODrivingCycleFileBrowser.Close()
TorqueConverterFileBrowser.Close()
TorqueConverterShiftPolygonFileBrowser.Close()
CrossWindCorrectionFileBrowser.Close()
ModalResultsFileBrowser.Close()
End Sub
'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
btStartV3.Enabled = Not lock
End Sub
#Region "Form Init/Close"
'Initialise
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim x As Integer
_guIlocked = False
_checkLock = False
_genCheckAllLock = False
_genChecked = 0
'Load Tabs properly (otherwise problem with ListViews)
For x = 0 To TabControl1.TabCount - 1
TabControl1.TabPages(x).Show()
Next
Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
'FileLists
_jobListView = New FileListView(MyConfPath & "joblist.txt")
_jobListView.LVbox = LvGEN
_cycleListView = New FileListView(MyConfPath & "cyclelist.txt")
'Resize columns ... after Loading the @file-lists
LvGEN.Columns(1).Width = - 2
LvMsg.Columns(2).Width = - 2
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()
' 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
If level = "Warn" 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})
End If
End If
End Sub
'Declaration mode GUI settings
Private Sub DeclOnOff()
If Cfg.DeclMode Then
Text = "VECTO " & COREvers & " - Declaration Mode"
Cfg.DeclInit()
Else
Text = "VECTO " & COREvers
End If
If Cfg.DeclMode Then
_lastModeName = "Declaration"
Else
_lastModeName = "Engineering"
End If
LbDecl.Visible = Cfg.DeclMode
End Sub
'Shown Event (Form-Load finished) ... here StartUp Forms are loaded (DEV, GEN/ADV- Editor ..)
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
'Close
Private Sub F01_MAINForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
'Config save
SetOptions()
Cfg.Save()
'File browser instances close
FB_Close()
End Sub
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
'Open file - Job, vehicle, engine, gearbox or signature file
Public Sub OpenVectoFile(file As String)
If Not IO.File.Exists(file) Then
GUIMsg(MessageType.Err, "File not found! (" & file & ")")
MsgBox("File not found! (" & file & ")", MsgBoxStyle.Critical)
Else
Select Case UCase(GetExtension(file))
Case ".VGBX"
If Not GearboxForm.Visible Then
GearboxForm.Show()
Else
GearboxForm.JobDir = ""
If GearboxForm.WindowState = FormWindowState.Minimized Then _
GearboxForm.WindowState = FormWindowState.Normal
GearboxForm.BringToFront()
End If
Try
GearboxForm.OpenGbx(file, VehicleCategory.RigidTruck)
Catch ex As Exception
MsgBox("Failed to open Gearbox File: " + ex.Message)
End Try
Case ".VVEH"
If Not VehicleForm.Visible Then
VehicleForm.Show()
Else
VehicleForm.JobDir = ""
If VehicleForm.WindowState = FormWindowState.Minimized Then _
VehicleForm.WindowState = FormWindowState.Normal
VehicleForm.BringToFront()
End If
Try
VehicleForm.OpenVehicle(file)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File")
End Try
Case ".VENG"
If Not EngineForm.Visible Then
EngineForm.Show()
Else
EngineForm.JobDir = ""
If EngineForm.WindowState = FormWindowState.Minimized Then _
EngineForm.WindowState = FormWindowState.Normal
EngineForm.BringToFront()
End If
Try
EngineForm.OpenEngineFile(file)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Engine File")
End Try
Case ".VECTO"
OpenVECTOeditor(file)
Case Else
MsgBox("Type '" & GetExtension(file) & "' unknown!", MsgBoxStyle.Critical)
End Select
End If
End Sub
#Region "Events"
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
Private Sub ButtonGENremove_Click(sender As Object, e As EventArgs) _
Handles ButtonGENremove.Click
RemoveJobFile()
End Sub
Private Sub ButtonGENadd_Click(sender As Object, e As EventArgs) _
Handles ButtonGENadd.Click
AddJobFile()
End Sub
Private Sub ListViewGEN_KeyDown(sender As Object, e As KeyEventArgs) _
Handles LvGEN.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
If Not _guIlocked Then RemoveJobFile()
Case Keys.Enter
OpenJobFile()
End Select
End Sub
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
Private Sub LvGEN_ItemChecked(sender As Object, e As ItemCheckedEventArgs) _
Handles LvGEN.ItemChecked
If e.Item.Checked Then
_genChecked += 1
Else
_genChecked -= 1
End If
If _checkLock Then Exit Sub
UpdateJobTabText()
End Sub
Private Sub ChBoxAllGEN_CheckedChanged(sender As Object, e As EventArgs) _
Handles ChBoxAllGEN.CheckedChanged
If _genCheckAllLock And ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub
CheckAllGen(ChBoxAllGEN.Checked)
End Sub
Private Sub CheckAllGen(check As Boolean)
Dim x As ListViewItem
_checkLock = True
LvGEN.BeginUpdate()
For Each x In LvGEN.Items
x.Checked = check
Next
LvGEN.EndUpdate()
_checkLock = False
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub
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
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
Private Sub BtGENup_Click(sender As Object, e As EventArgs) Handles BtGENup.Click
MoveItem(LvGEN, True)
End Sub
Private Sub BtGENdown_Click(sender As Object, e As EventArgs) Handles BtGENdown.Click
MoveItem(LvGEN, False)
End Sub
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
'Remove selected file(s) from job list
Private Sub RemoveJobFile()
Dim lastindx As Integer
Dim selIx() As Integer
Dim i As Integer
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()
_checkLock = True
ReDim selIx(LvGEN.SelectedItems.Count - 1)
LvGEN.SelectedIndices.CopyTo(selIx, 0)
lastindx = LvGEN.SelectedIndices(LvGEN.SelectedItems.Count - 1)
For i = UBound(selIx) To 0 Step - 1
LvGEN.Items.RemoveAt(selIx(i))
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()
_checkLock = False
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub
'Browse for job file(s) and add to job list with AddToJobListView
Private Sub AddJobFile()
Dim x As String()
Dim chck As Boolean = False
x = New String() {""}
Dim extensions As String = "vecto"
Dim inputDataExtensions As String() = New String() {"xml"}
If (inputDataExtensions.Any()) Then _
extensions = String.Join(",", extensions, String.Join(",", inputDataExtensions))
'STANDARD/BATCH
If JobfileFileBrowser.OpenDialog("", True, extensions) Then
chck = True
x = JobfileFileBrowser.Files
End If
If chck Then AddToJobListView(x)
End Sub
'Open file in list
Private Sub OpenJobFile()
Dim f As String
If LvGEN.SelectedItems.Count < 1 Then
If LvGEN.Items.Count = 1 Then
LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If
f = LvGEN.SelectedItems(0).SubItems(0).Text
f = FileRepl(f)
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
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
Dim fList As String()
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
pDim = UBound(path)
ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern
'******************************************* Begin Update '*******************************************
LvGEN.BeginUpdate()
_checkLock = True
LvGEN.SelectedIndices.Clear()
If pDim = 0 Then
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
'Status reset
LvGEN.Items(f).SubItems(1).Text = txt
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
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()
lbFound:
Next
LvGEN.EndUpdate()
_checkLock = False
'******************************************* End Update '*******************************************
'Number update
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub
'Add File to job listview (single file)
Public Sub AddToJobListView(path As String, Optional ByVal txt As String = " ")
Dim p(0) As String
p(0) = path
AddToJobListView(p, txt)
End Sub
'Update job files counter in tab titel
Private Sub UpdateJobTabText()
Dim count As Integer = LvGEN.Items.Count
TabPageGEN.Text = String.Format("Job Files ( {0} / {1} )", _genChecked, count)
_genCheckAllLock = True
If _genChecked = 0 Then
ChBoxAllGEN.CheckState = CheckState.Unchecked
ElseIf _genChecked = count Then
ChBoxAllGEN.CheckState = CheckState.Checked
Else
ChBoxAllGEN.CheckState = CheckState.Indeterminate
End If
_genCheckAllLock = False
End Sub
#Region "Toolstrip"
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
'New Job file
Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click
OpenVECTOeditor("<New>")
End Sub
'Open input file
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))
End If
End Sub
Private Sub GENEditorToolStripMenuItem1_Click(sender As Object, e As EventArgs) _
Handles GENEditorToolStripMenuItem1.Click
OpenVECTOeditor("<New>")
End Sub
Private Sub VEHEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles VEHEditorToolStripMenuItem.Click
If Not VehicleForm.Visible Then
VehicleForm.Show()
Else
If VehicleForm.WindowState = FormWindowState.Minimized Then VehicleForm.WindowState = FormWindowState.Normal
VehicleForm.BringToFront()
End If
End Sub
Private Sub EngineEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles EngineEditorToolStripMenuItem.Click
If Not EngineForm.Visible Then
EngineForm.Show()
Else
If EngineForm.WindowState = FormWindowState.Minimized Then EngineForm.WindowState = FormWindowState.Normal
EngineForm.BringToFront()
End If
End Sub
Private Sub GearboxEditorToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles GearboxEditorToolStripMenuItem.Click
If Not GearboxForm.Visible Then
GearboxForm.Show()
Else
If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal
GearboxForm.BringToFront()
End If
End Sub
Private Sub GraphToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles GraphToolStripMenuItem.Click
Dim graphForm As New GraphForm
graphForm.Show()
End Sub
Private Sub OpenLogToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles OpenLogToolStripMenuItem.Click
Process.Start(MyAppPath & "log.txt")
End Sub
Private Sub SettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles SettingsToolStripMenuItem.Click
Settings.ShowDialog()
End Sub
Private Sub UserManualToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles UserManualToolStripMenuItem.Click
If File.Exists(MyAppPath & "User Manual\help.html") Then
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
Private Sub UpdateNotesToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles UpdateNotesToolStripMenuItem.Click
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()
End Sub
Private Sub AboutVECTOToolStripMenuItem1_Click(sender As Object, e As EventArgs) _
Handles AboutVECTOToolStripMenuItem1.Click
AboutBox.ShowDialog()
End Sub
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
'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
Dim listViewItem As ListViewItem
If _guIlocked Then Exit Sub
'Cache Selected Items
y1 = listView.SelectedItems.Count - 1
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
listView.BeginUpdate()
'Delete Selected Items
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))
Next
listView.EndUpdate()
End Sub
#Region "job/cycle file List - Context Menu"
'Save List
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))
Else
_cycleListView.SaveList(TextFileBrowser.Files(0))
End If
End If
End Sub
'Load List
Private Sub LoadListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles LoadListToolStripMenuItem.Click
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
'Load Default List
Private Sub LoadDefaultListToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles LoadDefaultListToolStripMenuItem.Click
_genChecked = LvGEN.CheckedItems.Count
UpdateJobTabText()
Else
_cycleListView.LoadList()
'Clear List
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
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'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()
LvGEN.SelectedItems.Clear()
If LvGEN.CheckedItems.Count = 0 Then
GUIMsg(MessageType.Err, "No job file selected!")
Exit Sub
End If
Status("Launching VECTO ...")
JobFileList.Clear()
JobFileList.AddRange(
From listViewItem As ListViewItem In LvGEN.CheckedItems.Cast (Of ListViewItem)()
Select fFileRepl = FileRepl(listViewItem.SubItems(0).Text))
SetOptions()
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()
End If
End Sub
Private Sub VectoWorkerV3_OnDoWork(theSender As Object, e As DoWorkEventArgs)
Dim sender As BackgroundWorker = TryCast(theSender, BackgroundWorker)
If sender Is Nothing Then Exit Sub
AllowSleepOff()
Dim sumFileWriter As FileOutputWriter = New FileOutputWriter(JobFileList(0))
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
Physics.AirDensity = Cfg.AirDensity.SI (Of KilogramPerCubicMeter)()
End If
'dictionary of run-identifiers to fileWriters (used for output directory of modfile)
Dim fileWriters As Dictionary(Of Integer, FileOutputWriter) = New Dictionary(Of Integer, FileOutputWriter)
'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})
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
End If
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})