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
Imports TUGraz.VectoCore.InputData.FileIO.JSON
Imports System.Threading
Imports NLog
Imports NLog.Config
Imports NLog.Targets

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

Markus Quaritsch
committed
Public Class F_MAINForm
Private JobListView As cFileListView
Private CycleListView As cFileListView
Private LastModeName As String
Private ConMenTarget As ListView
Private ConMenTarJob As Boolean
Private MODpath As String
Private MODVehList As Int32()
Private CycleTabPage As TabPage
Private CycleTabPageVisible As Boolean
Private ComLineShutDown As Boolean
Private CheckedItems As List(Of ListViewItem)
Private DEVpage As TabPage
Private CmDEVitem As ListViewItem
Private CheckLock As Boolean
Private GENchecked As Integer
Private DRIchecked As Integer
Private GENcheckAllLock As Boolean
Private DRIcheckAllLock As Boolean
Private CbDeclLock As Boolean = False
#Region "SLEEP Control - Prevent sleep while VECTO is running"
Private Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As Long) As Long
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS Or tEXECUTION_STATE.ES_SYSTEM_REQUIRED)
#If Not PLATFORM = "x86" Then
SetThreadExecutionState(tEXECUTION_STATE.ES_CONTINUOUS)
Private Enum tEXECUTION_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"
114
115
116
117
118
119
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Private Sub FB_Initialize()
FB_Init = False
Try
VECTO_Global.COREvers = Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString()
Catch ex As Exception
LogFile.WriteToLog(tMsgID.Err, ex.StackTrace)
End Try
fbFolder = New cFileBrowser("WorkDir", True)
fbFileLists = New cFileBrowser("FileLists")
fbVECTO = New cFileBrowser("vecto")
fbVEH = New cFileBrowser("vveh")
fbMAP = New cFileBrowser("vmap")
fbDRI = New cFileBrowser("vdri")
fbFLD = New cFileBrowser("vfld")
fbENG = New cFileBrowser("veng")
fbGBX = New cFileBrowser("vgbx")
fbACC = New cFileBrowser("vacc")
fbAUX = New cFileBrowser("vaux")
fbGBS = New cFileBrowser("vgbs")
fbRLM = New cFileBrowser("vrlm")
fbTLM = New cFileBrowser("vtlm")
fbTCC = New cFileBrowser("vtcc")
fbCDx = New cFileBrowser("vcdx")
fbVMOD = New cFileBrowser("vmod")
'-------------------------------------------------------
fbFileLists.Extensions = New String() {"txt"}
fbVECTO.Extensions = New String() {"vecto"}
fbVEH.Extensions = New String() {"vveh"}
fbMAP.Extensions = New String() {"vmap"}
fbDRI.Extensions = New String() {"vdri"}
fbFLD.Extensions = New String() {"vfld"}
fbENG.Extensions = New String() {"veng"}
fbGBX.Extensions = New String() {"vgbx"}
fbACC.Extensions = New String() {"vacc"}
fbAUX.Extensions = New String() {"vaux"}
fbGBS.Extensions = New String() {"vgbs"}
fbRLM.Extensions = New String() {"vrlm"}
fbTLM.Extensions = New String() {"vtlm"}
fbTCC.Extensions = New String() {"vtcc"}
fbCDx.Extensions = New String() {"vcdv", "vcdb"}
fbVMOD.Extensions = New String() {"vmod"}
End Sub
Private Sub FB_Close()
fbFolder.Close()
fbFileLists.Close()
fbVECTO.Close()
fbVEH.Close()
fbMAP.Close()
fbDRI.Close()
fbFLD.Close()
fbENG.Close()
fbGBX.Close()
fbACC.Close()
fbAUX.Close()
fbGBS.Close()
fbRLM.Close()
fbTLM.Close()
fbTCC.Close()
fbCDx.Close()
fbVMOD.Close()
End Sub
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
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
'VECTO-Launcher
Public Sub VECTO_Launcher()
Dim ProgOverall As Boolean
Dim GEN0 As cVECTO
'Called when VECTO already running
If VECTOworker.IsBusy Then
GUImsg(tMsgID.Err, "VECTO is already running!")
Exit Sub
End If
'Delete GENlist-Selection
Me.LvGEN.SelectedItems.Clear()
'If more than 100 calculations, ask whether to write by-second results
If _
Cfg.BatchMode And ((Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) > 100) And
Me.ChBoxModOut.Checked _
Then
Select Case _
MsgBox(
"You are about to run Batch Mode with " &
(Me.LvGEN.CheckedItems.Count) * (Me.LvDRI.CheckedItems.Count) &
" calculations!" & ChrW(10) & "Do you still want to write modal results?", MsgBoxStyle.YesNoCancel)
Case MsgBoxResult.No
Me.ChBoxModOut.Checked = False
Case MsgBoxResult.Cancel
GUImsg(tMsgID.Normal, "Aborted by User")
Exit Sub
End Select
End If
'Status
Status("Launching VECTO...")
'Define Job-0list
'Define File / Cycle list
SetJobList()
'Zyklus-Liste definieren (falls nicht BATCH-Modus wird in SetCycleList nur die Liste gelöscht und nicht neu belegt) |@@| Define Cycle-list (if not BATCH mode in SetCycleList deleted only the list and not reassigned)
SetCycleList()
If JobFileList.Count = 0 Then
GUImsg(tMsgID.Err, "No job file selected!")
Exit Sub
End If
'Check whether Overall-progbar is needed
If Cfg.BatchMode Or JobFileList.Count > 1 Or Cfg.DeclMode Then
ProgOverall = True
Else
GEN0 = New cVECTO
GEN0.FilePath = JobFileList(0)
If Not GEN0.ReadFile Then
GUImsg(tMsgID.Err, "Failed to job file (" & fFILE(JobFileList(0), True) & ")!")
Exit Sub
End If
ProgOverall = (GEN0.CycleFiles.Count > 1)
End If
'Launch through Job_Launcher
Job_Launcher(ProgOverall)
End Sub
'Lock certain GUI elements while VECTO is running
Private Sub LockGUI(ByVal Lock As Boolean)
GUIlocked = Lock
Me.PanelOptAllg.Enabled = Not Lock
Me.GrBoxSTD.Enabled = Not Lock
Me.GrBoxBATCH.Enabled = Not Lock
Me.BtGENup.Enabled = Not Lock
Me.BtGENdown.Enabled = Not Lock
Me.ButtonGENadd.Enabled = Not Lock
Me.ButtonGENremove.Enabled = Not Lock
Me.LvGEN.LabelEdit = Not Lock
Me.ChBoxAllGEN.Enabled = Not Lock
Me.BtDRIup.Enabled = Not Lock
Me.BtDRIdown.Enabled = Not Lock
Me.ButtonDRIadd.Enabled = Not Lock
Me.ButtonDRIremove.Enabled = Not Lock
Me.LvDRI.LabelEdit = Not Lock
Me.ChBoxAllDRI.Enabled = Not Lock
Button1.Enabled = Not Lock
btStartV3.Enabled = Not Lock
If DEV.Enabled Then
Me.LvDEVoptions.Enabled = Not Lock
End If
End Sub
'Define job file list
Private Sub SetJobList()
Dim LV0 As ListViewItem
Dim x As Integer
JobFileList.Clear()
CheckedItems.Clear()
x = -1
For Each LV0 In Me.LvGEN.CheckedItems
x += 1
LV0.SubItems(1).Text = ""
CheckedItems.Add(LV0)
SetCheckedItemColor(x, tJobStatus.Queued)
JobFileList.Add(fFileRepl(LV0.SubItems(0).Text))
Next
End Sub
'Define cycle list (BATCH mode only)
Private Sub SetCycleList()
Dim LV0 As ListViewItem
JobCycleList.Clear()
If Cfg.BatchMode Then
For Each LV0 In Me.LvDRI.CheckedItems
JobCycleList.Add(fFileRepl(LV0.SubItems(0).Text))
Next
End If
End Sub
'Job Launcher
Private Sub Job_Launcher(ByVal ProgOverallEnabled As Boolean)
If VECTOworker.IsBusy Then Exit Sub
'Load Options from Options Tab
SetOptions()
'Save Config
Cfg.ConfigSAVE()
If DEV.Enabled Then DEV.SaveToFile()
'Reset Msg-output
ClearMSG()
'Disable Options
LockGUI(True)
'Button switch
Button1.Enabled = True
Me.Button1.Text = "STOP"
Me.Button1.Image = My.Resources.Stop_icon
'ProgBars start
If ProgOverallEnabled Then
Me.ToolStripProgBarOverall.Value = 0
Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Marquee
Me.ToolStripProgBarOverall.Visible = True
End If
ProgBarCtrl.ProgJobInt = 0
ProgSecStart()
'BG-Worker start
VECTOworker.RunWorkerAsync()
End Sub
'Abort Job
Private Sub JobAbort()
Me.Button1.Enabled = False
Me.Button1.Text = "Aborting..."
Me.Button1.Image = My.Resources.Play_icon_gray
VECTOworker.CancelAsync()
End Sub
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
393
394
395
396
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
'DoWork - Start Calculations
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
'Prevent SLEEP
AllowSleepOFF()
If SetCulture Then
Try
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
Catch ex As Exception
GUImsg(tMsgID.Err, "Failed to set thread culture 'en-US'! Check system decimal- and group- separators!")
End Try
End If
e.Result = VECTO()
End Sub
'Progress Report - Progressbar, Messages, etc.
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object,
ByVal e As System.ComponentModel.ProgressChangedEventArgs) _
Handles BackgroundWorker1.ProgressChanged
Dim x As cWorkProg
x = e.UserState
Select Case x.Target
Case tWorkMsgType.StatusListBox
MSGtoForm(e.UserState.ID, e.UserState.Msg, x.Source, x.Link)
Case tWorkMsgType.StatusBar
Status(e.UserState.Msg)
Case tWorkMsgType.ProgBars
Me.ToolStripProgBarOverall.Value = e.ProgressPercentage
ProgSecStart()
Case tWorkMsgType.JobStatus
CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg
SetCheckedItemColor(x.FileIndex, x.Status)
Case tWorkMsgType.CycleStatus
Try
Me.LvDRI.CheckedItems(x.FileIndex).SubItems(1).Text = x.Msg
Catch ex As Exception
End Try
Case tWorkMsgType.InitProgBar
Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous
Case Else ' tWorkMsgType.Abort
JobAbort()
End Select
End Sub
'Work completed
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object,
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
Dim Result As tCalcResult
'Progbar reset
Me.ToolStripProgBarOverall.Visible = False
Me.ToolStripProgBarOverall.Style = ProgressBarStyle.Continuous
Me.ToolStripProgBarOverall.Value = 0
ProgSecStop()
'So ListView-Item Colors (Warning = Yellow, etc..) are correctly visible
Me.LvGEN.SelectedIndices.Clear()
Result = e.Result
'ShutDown when Unexpected Error
If e.Error IsNot Nothing Then
MsgBox("An Unexpected Error occurred!" & ChrW(10) & ChrW(10) &
e.Error.Message.ToString, MsgBoxStyle.Critical, "Unexpected Error")
LogFile.WriteToLog(tMsgID.Err, ">>>Unexpected Error:" & e.Error.ToString())
Me.Close()
End If
'Options enable / GUI reset
LockGUI(False)
Me.Button1.Text = "START V2.2"
Me.Button1.Image = My.Resources.Play_icon
Status(LastModeName & " Mode")
'Command Line Shutdown
If ComLineShutDown Then Me.Close()
'Auto Shutdown
If Me.ChBoxAutoSD.Checked Then
Me.ChBoxAutoSD.Checked = False
If Not Result = tCalcResult.Abort Then
If F_ShutDown.ShutDown Then
GUImsg(tMsgID.Warn, "Shutting down...")
Me.Close()
End If
End If
End If
'SLEEP reactivate
AllowSleepON()
End Sub
#End Region
#End Region
#Region "Form Init/Close"
'Initialise
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim x As Integer
GUIlocked = False
CheckLock = False
GENcheckAllLock = False
DRIcheckAllLock = False
DRIchecked = 0
GENchecked = 0
CheckedItems = New List(Of ListViewItem)
'Load Tabs properly (otherwise problem with ListViews)
For x = 0 To Me.TabControl1.TabCount - 1
Me.TabControl1.TabPages(x).Show()
Next
CycleTabPageVisible = True
CycleTabPage = Me.TabPageDRI
DEVpage = Me.TabPageDEV
'Me.TabControl1.Controls.Remove(DEVpage)
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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
FB_Initialize()
Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
'FileLists
JobListView = New cFileListView(MyConfPath & "joblist.txt")
JobListView.LVbox = Me.LvGEN
CycleListView = New cFileListView(MyConfPath & "cyclelist.txt")
CycleListView.LVbox = Me.LvDRI
JobListView.LoadList()
'Load GUI Options (here, the GEN/ADV/DRI lists are loaded)
LoadOptions()
'Resize columns ... after Loading the @file-lists
Me.LvGEN.Columns(1).Width = -2
Me.LvDRI.Columns(1).Width = -2
Me.LvMsg.Columns(2).Width = -2
'Initialize BackgroundWorker
VECTOworker = Me.BackgroundWorker1
VECTOworker.WorkerReportsProgress = True
VECTOworker.WorkerSupportsCancellation = True
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()
'License check
If False And Not Lic.LICcheck() Then
MsgBox("License File invalid!" & vbCrLf & vbCrLf & Lic.FailMsg)
If Lic.CreateActFile(MyAppPath & "ActivationCode.dat") Then
MsgBox("Activation File created.")
Else
MsgBox("Failed to create Activation File! Is Directory Read-Only?")
End If
Me.Close()
Else
GUImsg(tMsgID.Normal, "License File validated.")
If Lic.TimeWarn Then GUImsg(tMsgID.Warn, "License expiring date (y/m/d): " & Lic.ExpTime)
End If
DEV.Enabled = True ' Lic.LicFeature(9)
If DEV.Enabled Then
DEV.LoadFromFile()
LoadDEVconfigs()
End If
DeclOnOff()
'Init Log Writer for Listening to VectoCore Nlog
Dim config As LoggingConfiguration = LogManager.Configuration
Dim methodCallTarget As MethodCallTarget = New MethodCallTarget()
methodCallTarget.ClassName = "VECTO.F_MAINForm, vecto"
methodCallTarget.MethodName = "LogMessage"
methodCallTarget.Name = "WarningLogger"
methodCallTarget.Parameters.Add(New MethodCallParameter("${level}"))
methodCallTarget.Parameters.Add(New MethodCallParameter("${message}"))
config.LoggingRules.Add(New LoggingRule("*", LogLevel.Warn, methodCallTarget))
LogManager.Configuration = config
End Sub
Public Shared Sub LogMessage(level As String, message As String)
Try
If level = "Warn" Then
VECTOworkerV3.ReportProgress(100, New With {.Target = "ListBoxWarning", .Message = message})
ElseIf level = "Error" Or level = "Fatal" Then
VECTOworkerV3.ReportProgress(100, New With {.Target = "ListBoxError", .Message = message})
End If
Catch e As InvalidOperationException
End Try
End Sub
'Declaration mode GUI settings
Private Sub DeclOnOff()
If Cfg.DeclMode Then
Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers & " - Declaration Mode"
Me.CbBatch.Checked = False
Cfg.DeclInit()
Else
Me.Text = "VECTO " & VECTOvers & " / VectoCore " & COREvers
End If
If Cfg.DeclMode Then
LastModeName = "Declaration"
Else
If Cfg.BatchMode Then
LastModeName = "Batch"
Else
LastModeName = "Engineering"
End If
End If
If DEV.Enabled Then
If Not Cfg.DeclMode Then
If Not Me.TabControl1.TabPages.Contains(DEVpage) Then _
Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage)
LoadDEVconfigs()
Else
If Me.TabControl1.TabPages.Contains(DEVpage) Then Me.TabControl1.Controls.Remove(DEVpage)
DEV.SetDefault()
End If
End If
Status(LastModeName & " Mode")
Me.LoadOptions()
Me.LbDecl.Visible = Cfg.DeclMode
Me.PnDeclOpt.Enabled = Not Cfg.DeclMode
End Sub
'Shown Event (Form-Load finished) ... here StartUp Forms are loaded (DEV, GEN/ADV- Editor ..)
Private Sub F01_MAINForm_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Dim fwelcome As F_Welcome
'DEV Form
'If DEV.Enabled And Not Cfg.DeclMode Then
' Me.TabControl1.TabPages.Insert(Me.TabControl1.TabPages.Count, DEVpage)
'End If
'VECTO Init
Declaration.Init()
'Command Line Args
If Command() <> "" Then
CmdLineCtrl(My.Application.CommandLineArgs)
Else
If Cfg.FirstRun Then
Cfg.FirstRun = False
fwelcome = New F_Welcome
fwelcome.ShowDialog()
End If
End If
End Sub
'Open file
Private Sub CmdLineCtrl(ByVal ComLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String))
Dim bBATCH As Boolean
Dim bRUN As Boolean
Dim x As Object
Dim str As String
Dim ComFile As String = ""
Dim vecFiles As New List(Of String)
Dim driFiles As New List(Of String)
bBATCH = False
bRUN = False
ComFile = sKey.NoFile
'Read Command-Line Args
For Each x In ComLineArgs
str = Trim(Replace(x.ToString, ChrW(34), ""))
Select Case UCase(str)
Case "-BATCH"
bBATCH = True
Case "-CLOSE"
ComLineShutDown = True
Case "-RUN"
bRUN = True
Case Else
Select Case UCase(fEXT(str))
Case ".VECTO"
vecFiles.Add(fFileRepl(str))
Case ".VDRI"
driFiles.Add(fFileRepl(str))
Case Else
ComFile = fFileRepl(str)
End Select
End Select
Next
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
'Mode switch and load Driving Cycles
If bBATCH Then
Me.CbBatch.Checked = True
If driFiles.Count > 0 Then
LvDRI.Items.Clear()
AddToCycleListView(driFiles.ToArray)
End If
Else
Me.CbBatch.Checked = False
End If
'Load Vecto files or open editor (if only one file)
If vecFiles.Count > 0 Then
If vecFiles.Count > 1 Or bRUN Then
LvGEN.Items.Clear()
AddToJobListView(vecFiles.ToArray)
Else
ComFile = vecFiles(0)
End If
End If
'Run or open file editor if file is specified
If bRUN Then
VECTO_Launcher()
Else
If ComFile <> sKey.NoFile Then OpenVectoFile(ComFile)
End If
End Sub
'Close
Private Sub F01_MAINForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles Me.FormClosing
'Save File-Lists
SaveFileLists()
'Close log
LogFile.CloseLog()
'Config save
SetOptions()
Cfg.ConfigSAVE()
If DEV.Enabled Then DEV.SaveToFile()
'File browser instances close
FB_Close()
End Sub
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
'Open file - Job, vehicle, engine, gearbox or signature file
Public Sub OpenVectoFile(ByVal File As String)
If Not IO.File.Exists(File) Then
GUImsg(tMsgID.Err, "File not found! (" & File & ")")
MsgBox("File not found! (" & File & ")", MsgBoxStyle.Critical)
Else
Select Case UCase(fEXT(File))
Case ".VGBX"
If Not F_GBX.Visible Then
F_GBX.Show()
Else
F_GBX.JobDir = ""
If F_GBX.WindowState = FormWindowState.Minimized Then F_GBX.WindowState = FormWindowState.Normal
F_GBX.BringToFront()
End If
F_GBX.openGBX(File)
Case ".VVEH"
If Not F_VEH.Visible Then
F_VEH.Show()
Else
F_VEH.JobDir = ""
If F_VEH.WindowState = FormWindowState.Minimized Then F_VEH.WindowState = FormWindowState.Normal
F_VEH.BringToFront()
End If
F_VEH.openVEH(File)
Case ".VENG"
If Not F_ENG.Visible Then
F_ENG.Show()
Else
F_ENG.JobDir = ""
If F_ENG.WindowState = FormWindowState.Minimized Then F_ENG.WindowState = FormWindowState.Normal
F_ENG.BringToFront()
End If
F_ENG.openENG(File)
Case ".VECTO"
OpenVECTOeditor(File)
Case ".VSIG"
OpenSigFile(File)
Case Else
MsgBox("Type '" & fEXT(File) & "' unknown!", MsgBoxStyle.Critical)
End Select
End If
End Sub
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
Private Sub ButtonGENremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ButtonGENremove.Click
RemoveJobFile()
End Sub
Private Sub ButtonGENadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ButtonGENadd.Click
AddJobFile()
End Sub
Private Sub ButtonGENoptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ButtonGENopt.Click
ConMenTarget = Me.LvGEN
ConMenTarJob = True
'Locked functions show/hide
Me.LoadListToolStripMenuItem.Enabled = Not GUIlocked
Me.LoadDefaultListToolStripMenuItem.Enabled = Not GUIlocked
Me.ClearListToolStripMenuItem.Enabled = Not GUIlocked
Me.ConMenFilelist.Show(Control.MousePosition)
End Sub
Private Sub ListViewGEN_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.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(ByVal sender As Object, ByVal e As System.EventArgs) Handles LvGEN.DoubleClick
If Me.LvGEN.SelectedItems.Count > 0 Then
Me.LvGEN.SelectedItems(0).Checked = Not Me.LvGEN.SelectedItems(0).Checked
OpenJobFile()
End If
End Sub
Private Sub LvGEN_ItemChecked(sender As Object, e As System.Windows.Forms.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(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ChBoxAllGEN.CheckedChanged
If GENcheckAllLock And Me.ChBoxAllGEN.CheckState = CheckState.Indeterminate Then Exit Sub
CheckAllGEN(Me.ChBoxAllGEN.Checked)
End Sub
Private Sub CheckAllGEN(ByVal Check As Boolean)
Dim x As ListViewItem
CheckLock = True
Me.LvGEN.BeginUpdate()
For Each x In Me.LvGEN.Items
x.Checked = Check
Next
Me.LvGEN.EndUpdate()
CheckLock = False
GENchecked = Me.LvGEN.CheckedItems.Count
UpdateJobTabText()
End Sub
Private Sub ListGEN_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _
Handles LvGEN.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub ListGEN_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _
Handles LvGEN.DragDrop
Dim f As String()
f = CType(e.Data.GetData(DataFormats.FileDrop), Array)
AddToJobListView(f)
End Sub
Private Sub BtGENup_Click(sender As System.Object, e As System.EventArgs) Handles BtGENup.Click
MoveItem(LvGEN, True)
End Sub
Private Sub BtGENdown_Click(sender As System.Object, e As System.EventArgs) Handles BtGENdown.Click
MoveItem(LvGEN, False)
End Sub
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
'Remove selected file(s) from job list
Private Sub RemoveJobFile()
Dim lastindx As Integer
Dim SelIx() As Integer
Dim i As Integer
If Me.LvGEN.SelectedItems.Count < 1 Then
If Me.LvGEN.Items.Count = 1 Then
Me.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() {""}
'STANDARD/BATCH
If fbVECTO.OpenDialog("", True, "vecto") Then
Chck = True
x = fbVECTO.Files
End If
If Chck Then AddToJobListView(x)
End Sub
'Open file in list
Private Sub OpenJobFile()
Dim f As String
If Me.LvGEN.SelectedItems.Count < 1 Then
If Me.LvGEN.Items.Count = 1 Then
Me.LvGEN.Items(0).Selected = True
Else
Exit Sub
End If
End If
f = Me.LvGEN.SelectedItems(0).SubItems(0).Text
f = fFileRepl(f)
If Not IO.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(ByVal Path As String(), Optional ByVal Txt As String = " ")
Dim pDim As Int16
Dim p As Int16
Dim f As Int16
Dim fList As String()
Dim fListDim As Int16 = -1
Dim ListViewItem0 As ListViewItem
'If VECTO runs: Cancel operation (because Mode-change during calculation is not very clever)
If VECTOworker.IsBusy Then Exit Sub
pDim = UBound(Path)
ReDim fList(0) 'um Nullverweisausnahme-Warnung zu verhindern
'******************************************* Begin Update '*******************************************
Me.LvGEN.BeginUpdate()
CheckLock = True
Me.LvGEN.SelectedIndices.Clear()
If pDim = 0 Then
fListDim = Me.LvGEN.Items.Count - 1
ReDim fList(fListDim)
For f = 0 To fListDim
fList(f) = fFileRepl(Me.LvGEN.Items(f).SubItems(0).Text)
Next
End If