Newer
Older
' Copyright 2014 European Union.
' Licensed under the EUPL (the 'Licence');
'
' * You may not use this work except in compliance with the Licence.
' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
' * Unless required by applicable law or agreed to in writing,
' software distributed under the Licence is distributed on an "AS IS" basis,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'
' See the LICENSE.txt for the specific language governing permissions and limitations.

Markus QUARITSCH
committed
'Option Infer On
Imports System.Collections.Generic
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Linq
Imports System.Text.RegularExpressions
Imports System.Windows.Forms.DataVisualization.Charting
Imports TUGraz.VECTO.Input_Files
Imports TUGraz.VectoCommon.InputData
Imports TUGraz.VectoCommon.Models
Imports TUGraz.VectoCommon.Utils
Imports TUGraz.VectoCore.InputData.FileIO.JSON

Markus QUARITSCH
committed
Imports TUGraz.VectoCore.InputData.Reader
Imports TUGraz.VectoCore.Models.Declaration
Imports TUGraz.VectoCore.Models.SimulationComponent.Data
Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine

Markus QUARITSCH
committed
Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox
''' <summary>
''' Job Editor. Create/Edit VECTO job files (.vecto)
''' </summary>
''' <remarks></remarks>
Public Class VectoJobForm
Private _changed As Boolean = False
Private _pgDriver As TabPage
Private _pgDriverOn As Boolean = True
Private _auxDialog As VehicleAuxiliariesDialog
'AA-TB
'Populate Advanced Auxiliaries
Private Sub PopulateAdvancedAuxiliaries()
'Scan the program directory for DLL's which are AdvancedAuxiliaries and display
Dim aList As Dictionary(Of String, AdvancedAuxiliary) = DiscoverAdvancedAuxiliaries()
cboAdvancedAuxiliaries.DataSource = aList.Select(Function(x) x.Value).ToList()
cboAdvancedAuxiliaries.DisplayMember = "AuxiliaryName"
End Sub
'Initialise form
Private Sub F02_GEN_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim x As Integer
_auxDialog = New VehicleAuxiliariesDialog
_pgDriver = TabPgDriver
For x = 0 To TabControl1.TabCount - 1
TabControl1.TabPages(x).Show()
Next
LvAux.Columns(2).Width = -2
'Declaration Mode
If Cfg.DeclMode Then
LvAux.Columns(2).Text = "Technology"
Else
LvAux.Columns(2).Text = "Input File"
End If
TbAuxPAdd.Enabled = Not Cfg.DeclMode
CbEngOnly.Enabled = Not Cfg.DeclMode
GrCycles.Enabled = Not Cfg.DeclMode
GrVACC.Enabled = Not Cfg.DeclMode
PnStartStop.Enabled = Not Cfg.DeclMode
RdOff.Enabled = Not Cfg.DeclMode
GrLAC.Enabled = Not Cfg.DeclMode
ButAuxAdd.Enabled = Not Cfg.DeclMode
ButAuxRem.Enabled = Not Cfg.DeclMode
PnEcoRoll.Enabled = Not Cfg.DeclMode
_changed = False
'AA-TB
PopulateAdvancedAuxiliaries()
'Attempt to select that found in Config
End Sub
'Close - Check for unsaved changes
Private Sub F02_GEN_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason <> CloseReason.ApplicationExitCall And e.CloseReason <> CloseReason.WindowsShutDown Then
e.Cancel = ChangeCheckCancel()
End If
End Sub
'Set generic values for Declaration mode
Private Sub DeclInit()
If Not Cfg.DeclMode Then Exit Sub
LvCycles.Items.Clear()
CbEngOnly.Checked = False
TbDesMaxFile.Text = ""
If Not RdEcoRoll.Checked Then RdOverspeed.Checked = True
CbLookAhead.Checked = True
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat() 'cDeclaration.SSspeed
TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat() 'cDeclaration.SStime
TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat() ' cDeclaration.SSdelay
tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat()
tbLacDfTargetSpeedFile.Text = ""
tbLacDfVelocityDropFile.Text = ""
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat() 'cDeclaration.Overspeed
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat() _
' cDeclaration.Underspeed
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat() 'cDeclaration.ECvmin
If _
LvAux.Items.Count <> 5 OrElse

Markus QUARITSCH
committed
(LvAux.Items(0).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.Fan OrElse
LvAux.Items(1).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.SteeringPump OrElse
LvAux.Items(2).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.HeatingVentilationAirCondition OrElse
LvAux.Items(3).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.ElectricSystem OrElse
LvAux.Items(4).Text <> VectoCore.Configuration.Constants.Auxiliaries.IDs.PneumaticSystem) Then
LvAux.Items.Clear()

Markus QUARITSCH
committed
LvAux.Items.Add(GetTechListForAux(AuxiliaryType.Fan, DeclarationData.Fan))

Markus QUARITSCH
committed
LvAux.Items.Add(GetTechListForAux(AuxiliaryType.SteeringPump, DeclarationData.SteeringPump))

Markus QUARITSCH
committed
LvAux.Items.Add(GetTechListForAux(AuxiliaryType.HVAC, DeclarationData.HeatingVentilationAirConditioning))

Markus QUARITSCH
committed
LvAux.Items.Add(GetTechListForAux(AuxiliaryType.ElectricSystem, DeclarationData.ElectricSystem))

Markus QUARITSCH
committed
LvAux.Items.Add(GetTechListForAux(AuxiliaryType.PneumaticSystem, DeclarationData.PneumaticSystem))
End If
End Sub

Markus QUARITSCH
committed
Protected Function GetTechListForAux(type As AuxiliaryType, aux As IDeclarationAuxiliaryTable) _

Markus QUARITSCH
committed
As ListViewItem
listViewItem = New ListViewItem(type.Key())
listViewItem.SubItems.Add(type.Name())
Dim auxtech As String() = aux.GetTechnologies()
If auxtech.Count > 1 Then
End Function
'Show/Hide "Driver Assist" Tab
Private Sub SetDrivertab(onOff As Boolean)
If onOff Then
If Not _pgDriverOn Then
_pgDriverOn = True
TabControl1.TabPages.Insert(1, _pgDriver)
End If
Else
If _pgDriverOn Then
_pgDriverOn = False
TabControl1.Controls.Remove(_pgDriver)
End If
End If
End Sub
#Region "Browse Buttons"
Private Sub ButtonVEH_Click(sender As Object, e As EventArgs) Handles ButtonVEH.Click

Markus QUARITSCH
committed
If VehicleFileBrowser.OpenDialog(FileRepl(TbVEH.Text, GetPath(VectoFile))) Then
TbVEH.Text = GetFilenameWithoutDirectory(VehicleFileBrowser.Files(0), GetPath(VectoFile))
End If
End Sub
Private Sub ButtonMAP_Click(sender As Object, e As EventArgs) Handles ButtonMAP.Click

Markus QUARITSCH
committed
If EngineFileBrowser.OpenDialog(FileRepl(TbENG.Text, GetPath(VectoFile))) Then
TbENG.Text = GetFilenameWithoutDirectory(EngineFileBrowser.Files(0), GetPath(VectoFile))
End If
End Sub
Private Sub ButtonGBX_Click(sender As Object, e As EventArgs) Handles ButtonGBX.Click

Markus QUARITSCH
committed
If GearboxFileBrowser.OpenDialog(FileRepl(TbGBX.Text, GetPath(VectoFile))) Then
TbGBX.Text = GetFilenameWithoutDirectory(GearboxFileBrowser.Files(0), GetPath(VectoFile))
End If
End Sub
Private Sub BtDesMaxBr_Click_1(sender As Object, e As EventArgs) Handles BtDesMaxBr.Click

Markus QUARITSCH
committed
If DriverAccelerationFileBrowser.OpenDialog(FileRepl(TbDesMaxFile.Text, GetPath(VectoFile))) Then

Markus QUARITSCH
committed
TbDesMaxFile.Text = GetFilenameWithoutDirectory(DriverAccelerationFileBrowser.Files(0), GetPath(VectoFile))
End If
End Sub
Private Sub BtAccOpen_Click(sender As Object, e As EventArgs) Handles BtAccOpen.Click

Markus QUARITSCH
committed
OpenFiles(FileRepl(TbDesMaxFile.Text, GetPath(VectoFile)))
End Sub
#End Region
#Region "Open Buttons"
'Open Vehicle Editor
Private Sub ButOpenVEH_Click(sender As Object, e As EventArgs) Handles ButOpenVEH.Click
Dim f As String

Markus QUARITSCH
committed
f = FileRepl(TbVEH.Text, GetPath(VectoFile))
'Thus Veh-file is returned

Markus QUARITSCH
committed
VehicleForm.JobDir = GetPath(VectoFile)
VehicleForm.AutoSendTo = True
If Not Trim(f) = "" Then
If Not File.Exists(f) Then
MsgBox("File not found!")
Exit Sub
End If
End If
If Not VehicleForm.Visible Then
VehicleForm.Show()
Else
If VehicleForm.WindowState = FormWindowState.Minimized Then VehicleForm.WindowState = FormWindowState.Normal
VehicleForm.BringToFront()
End If
If Not Trim(f) = "" Then
Try
VehicleForm.OpenVehicle(f)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error loading Vehicle File")
End Try
End If
End Sub
'Open Engine Editor
Private Sub ButOpenENG_Click(sender As Object, e As EventArgs) Handles ButOpenENG.Click
Dim f As String

Markus QUARITSCH
committed
f = FileRepl(TbENG.Text, GetPath(VectoFile))
'Thus Veh-file is returned

Markus QUARITSCH
committed
EngineForm.JobDir = GetPath(VectoFile)
EngineForm.AutoSendTo = True
If Not Trim(f) = "" Then
If Not File.Exists(f) Then
MsgBox("File not found!")
Exit Sub
End If
End If
If Not EngineForm.Visible Then
EngineForm.Show()
Else
If EngineForm.WindowState = FormWindowState.Minimized Then EngineForm.WindowState = FormWindowState.Normal
EngineForm.BringToFront()
End If
If Not Trim(f) = "" Then EngineForm.OpenEngineFile(f)
End Sub
'Open Gearbox Editor
Private Sub ButOpenGBX_Click(sender As Object, e As EventArgs) Handles ButOpenGBX.Click
Dim f As String

Markus QUARITSCH
committed
f = FileRepl(TbGBX.Text, GetPath(VectoFile))
'Thus Veh-file is returned

Markus QUARITSCH
committed
GearboxForm.JobDir = GetPath(VectoFile)
GearboxForm.AutoSendTo = True
If Not Trim(f) = "" Then
If Not File.Exists(f) Then
MsgBox("File not found!")
Exit Sub
End If
End If
If Not GearboxForm.Visible Then
GearboxForm.Show()
Else
If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal
GearboxForm.BringToFront()
End If

Markus QUARITSCH
committed
If Not Trim(f) = "" Then GearboxForm.OpenGbx(f)
End Sub
#End Region
#Region "Toolbar"
'New
Private Sub ToolStripBtNew_Click(sender As Object, e As EventArgs) Handles ToolStripBtNew.Click
End Sub
'Open
Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click

Markus QUARITSCH
committed
If JobfileFileBrowser.OpenDialog(VectoFile, False, "vecto") Then VECTOload2Form(JobfileFileBrowser.Files(0))
End Sub
'Save
Private Sub ToolStripBtSave_Click(sender As Object, e As EventArgs) Handles ToolStripBtSave.Click
Save()
End Sub
'Save As
Private Sub ToolStripBtSaveAs_Click(sender As Object, e As EventArgs) Handles ToolStripBtSaveAs.Click

Markus QUARITSCH
committed
If JobfileFileBrowser.SaveDialog(VectoFile) Then Call VECTOsave(JobfileFileBrowser.Files(0))
End Sub
'Send to Job file list in main form
Private Sub ToolStripBtSendTo_Click(sender As Object, e As EventArgs) Handles ToolStripBtSendTo.Click
If ChangeCheckCancel() Then Exit Sub

Markus QUARITSCH
committed
If VectoFile = "" Then
MsgBox("File not found!" & ChrW(10) & ChrW(10) & "Save file and try again.")
Else

Markus QUARITSCH
committed
MainForm.AddToJobListView(VectoFile)
End If
End Sub
'Help
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
If File.Exists(MyAppPath & "User Manual\help.html") Then
My.Computer.Registry.ClassesRoot.OpenSubKey("\http\shell\open\command\").GetValue("").ToString
Dim defaultBrowserPath As String =
Regex.Match(browserRegistryString, "(\"".*?\"")").Captures(0).ToString
Process.Start(defaultBrowserPath,
String.Format("""{0}{1}""", MyAppPath, "User Manual\help.html#job-editor"))
Else
MsgBox("User Manual not found!", MsgBoxStyle.Critical)
End If
End Sub
#End Region
'Save ("Save" or "Save As" when new file)
Private Function Save() As Boolean

Markus QUARITSCH
committed
If VectoFile = "" Then
If JobfileFileBrowser.SaveDialog("") Then

Markus QUARITSCH
committed
VectoFile = JobfileFileBrowser.Files(0)
Else
Return False
End If
End If

Markus QUARITSCH
committed
Try
Return VECTOsave(VectoFile)
Catch ex As Exception
MsgBox("Error when saving file" + Environment.NewLine + ex.Message)
Return False
End Try
End Function
'Open file
Public Sub VECTOload2Form(file As String)

Markus QUARITSCH
committed
If ChangeCheckCancel() Then Exit Sub
'Read GEN

Markus QUARITSCH
committed
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file),
IEngineeringInputDataProvider)
Dim vectoJob As IEngineeringJobInputData = inputData.JobInputData()

Markus QUARITSCH
committed
If Cfg.DeclMode <> vectoJob.SavedInDeclarationMode Then
Select Case WrongMode()
Case 1
Close()
MainForm.RbDecl.Checked = Not MainForm.RbDecl.Checked
MainForm.OpenVectoFile(file)
Case -1
Exit Sub
End Select
End If

Markus QUARITSCH
committed
VectoFile = file

Markus QUARITSCH
committed
_basePath = Path.GetDirectoryName(file)
'Update Form
'Files -----------------------------

Markus QUARITSCH
committed
TbVEH.Text = GetRelativePath(inputData.VehicleInputData.Source, _basePath)
TbENG.Text = GetRelativePath(inputData.EngineInputData.Source, _basePath)
TbGBX.Text = GetRelativePath(inputData.GearboxInputData.Source, _basePath)
'Start/Stop

Markus QUARITSCH
committed
Dim driver As IDriverEngineeringInputData = inputData.DriverInputData
ChBStartStop.Checked = driver.StartStop.Enabled
TbSSspeed.Text = driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat()

Markus QUARITSCH
committed
TbSStime.Text = driver.StartStop.MinTime.ToGUIFormat()
TbSSdelay.Text = driver.StartStop.Delay.ToGUIFormat()

Markus QUARITSCH
committed
If (Cfg.DeclMode) Then
TbDesMaxFile.Text = ""
'AA-TB
'Try and Select any previously selected Auxiliary Type
Dim declarationInput As IDeclarationInputDataProvider = CType(inputData, IDeclarationInputDataProvider)
Dim auxInput As IAuxiliariesDeclarationInputData = declarationInput.AuxiliaryInputData()

Markus QUARITSCH
committed
cboAdvancedAuxiliaries.SelectedIndex = 0

Markus QUARITSCH
committed
LvAux.Items.Clear()
Dim entry As IAuxiliaryDeclarationInputData
For Each entry In auxInput.Auxiliaries
'If entry.AuxiliaryType = AuxiliaryDemandType.Constant Then Continue For
Try
Dim lv0 As ListViewItem = New ListViewItem
lv0.SubItems(0).Text = AuxiliaryTypeHelper.GetAuxKey(entry.Type)
lv0.SubItems.Add(AuxiliaryTypeHelper.ToString(entry.Type))
lv0.SubItems.Add(String.Join(", ", entry.Technology))
LvAux.Items.Add(lv0)
Catch ex As Exception
End Try

Markus QUARITSCH
committed
Next
Else
'VACC
TbDesMaxFile.Text =
If(driver.AccelerationCurve Is Nothing, "", GetRelativePath(driver.AccelerationCurve.Source, _basePath))

Markus QUARITSCH
committed
Dim auxInput As IAuxiliariesEngineeringInputData = inputData.AuxiliaryInputData()
For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items
If _
AuxiliaryModelHelper.Parse(item.AssemblyName) = auxInput.AuxiliaryAssembly AndAlso
auxInput.AuxiliaryVersion = item.AuxiliaryVersion _

Markus QUARITSCH
committed
Then
cboAdvancedAuxiliaries.SelectedItem = item
Exit For
End If
Next
'AA-TB
'Assign any previously saved Axiliary FilePath
txtAdvancedAuxiliaryFile.Text =
If _
(IO.File.Exists(auxInput.AdvancedAuxiliaryFilePath), GetRelativePath(auxInput.AdvancedAuxiliaryFilePath, _basePath),
"")

Markus QUARITSCH
committed
LvAux.Items.Clear()
For Each entry As IAuxiliaryEngineeringInputData In auxInput.Auxiliaries
If entry.AuxiliaryType = AuxiliaryDemandType.Constant Then
TbAuxPAdd.Text = entry.ConstantPowerDemand.ToGUIFormat()
Continue For
End If

Markus QUARITSCH
committed
Dim lv0 As ListViewItem = New ListViewItem
lv0.SubItems(0).Text = entry.ID
lv0.SubItems.Add(entry.AuxiliaryType.ToString())
lv0.SubItems.Add(If(entry.DemandMap Is Nothing, "", entry.DemandMap.Source))
LvAux.Items.Add(lv0)
Next

Markus QUARITSCH
committed
End If
Try
Dim sb As ICycleData
For Each sb In vectoJob.Cycles
Dim lv0 As ListViewItem = New ListViewItem
lv0.Text = GetRelativePath(sb.CycleData.Source, Path.GetDirectoryName(Path.GetFullPath(file))) 'sb.Name
LvCycles.Items.Add(lv0)
Next
Catch ex As Exception
End Try

Markus QUARITSCH
committed
CbEngOnly.Checked = vectoJob.EngineOnlyMode

Markus QUARITSCH
committed
If driver.OverSpeedEcoRoll.Mode = DriverMode.EcoRoll Then
RdEcoRoll.Checked = True

Markus QUARITSCH
committed
ElseIf driver.OverSpeedEcoRoll.Mode = DriverMode.Overspeed Then
RdOverspeed.Checked = True
Else
RdOff.Checked = True
End If
TbOverspeed.Text = driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat()
TbUnderSpeed.Text = driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat()
TbVmin.Text = driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat()

Markus QUARITSCH
committed
CbLookAhead.Checked = driver.Lookahead.Enabled
'TbAlookahead.Text = CStr(VEC0.ALookahead)
tbLacMinSpeed.Text = driver.Lookahead.MinSpeed.AsKmph.ToGUIFormat()
'TbVminLA.Text = CStr(VEC0.VMinLa)

Markus QUARITSCH
committed
tbLacPreviewFactor.Text = driver.Lookahead.LookaheadDistanceFactor.ToGUIFormat()
tbDfCoastingOffset.Text = driver.Lookahead.CoastingDecisionFactorOffset.ToGUIFormat()
tbDfCoastingScale.Text = driver.Lookahead.CoastingDecisionFactorScaling.ToGUIFormat()
tbLacDfTargetSpeedFile.Text = If(driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup Is Nothing, "",
GetRelativePath(driver.Lookahead.CoastingDecisionFactorTargetSpeedLookup.Source, _basePath))
tbLacDfVelocityDropFile.Text = If(driver.Lookahead.CoastingDecisionFactorVelocityDropLookup Is Nothing, "",
GetRelativePath(driver.Lookahead.CoastingDecisionFactorVelocityDropLookup.Source, _basePath))
'-------------------------------------------------------------
DeclInit()
EngineForm.AutoSendTo = False
GearboxForm.AutoSendTo = False
VehicleForm.AutoSendTo = False
Dim x As Integer = Len(file)
While Mid(file, x, 1) <> "\" And x > 0
x = x - 1
End While
Text = Mid(file, x + 1, Len(file) - x)
_changed = False
ToolStripStatusLabelGEN.Text = "" 'file & " opened."
UpdatePic()
'-------------------------------------------------------------
End Sub
'Save file
Private Function VECTOsave(file As String) As Boolean
Dim message As String = String.Empty
'AA-TB
'Validation of Auxiliary Types/Advanced Auxiliaries
'if not classic, check the file is valid, if not fail the operation and alert user.
If cboAdvancedAuxiliaries.SelectedIndex > 0 Then
'resolve absolute path for auxiliary file.

Markus QUARITSCH
committed
Dim absoluteAAUxFile As String = ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)

Markus QUARITSCH
committed
Dim aaAssemblyName As String = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName
Dim aaAssemblyVersion As String = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion
If Not ValidateAAUXFile(absoluteAAUxFile, aaAssemblyName, aaAssemblyVersion, message) Then
MessageBox.Show(
String.Format("You have selected an advanced auxiliary *Auxiliary Type*, but the file specified is invalid :{0}",
message))
Return False
End If
End If

Markus QUARITSCH
committed
Dim vectoJob As VectoJob = New VectoJob
vectoJob.FilePath = file
'Files ------------------------------------------------- -----------------

Markus QUARITSCH
committed
vectoJob.PathVeh = TbVEH.Text
vectoJob.PathEng = TbENG.Text
For Each lv0 As ListViewItem In LvCycles.Items

Markus QUARITSCH
committed
Dim sb As SubPath = New SubPath

Markus QUARITSCH
committed
sb.Init(GetPath(file), lv0.Text)

Markus QUARITSCH
committed
vectoJob.CycleFiles.Add(sb)

Markus QUARITSCH
committed
vectoJob.PathGbx = TbGBX.Text
'Start/Stop

Markus QUARITSCH
committed
vectoJob.StartStop = ChBStartStop.Checked
vectoJob.StartStopMaxSpeed = TbSSspeed.Text.ToDouble()
vectoJob.StartStopTime = TbSStime.Text.ToDouble()
vectoJob.StartStopDelay = TbSSdelay.Text.ToDouble()
'a_DesMax

Markus QUARITSCH
committed
vectoJob.DesMaxFile = TbDesMaxFile.Text

Markus QUARITSCH
committed
vectoJob.AuxiliaryAssembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AssemblyName
vectoJob.AuxiliaryVersion = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary).AuxiliaryVersion
vectoJob.AdvancedAuxiliaryFilePath = txtAdvancedAuxiliaryFile.Text
For Each lv0 As ListViewItem In LvAux.Items

Markus QUARITSCH
committed
Dim auxEntry As VectoJob.AuxEntry = New VectoJob.AuxEntry
If Cfg.DeclMode Then
auxEntry.TechnologyList.Clear()
auxEntry.TechnologyList.Add(lv0.SubItems(2).Text)

Markus QUARITSCH
committed
auxEntry.Path.Init(GetPath(file), lv0.SubItems(2).Text)
End If
auxEntry.Type = lv0.SubItems(1).Text

Markus QUARITSCH
committed
vectoJob.AuxPaths.Add(lv0.SubItems(0).Text, auxEntry)
vectoJob.AuxPAdd = TbAuxPAdd.Text.ToDouble(0)

Markus QUARITSCH
committed
vectoJob.EngineOnly = CbEngOnly.Checked

Markus QUARITSCH
committed
vectoJob.EcoRollOn = RdEcoRoll.Checked
vectoJob.OverSpeedOn = RdOverspeed.Checked
vectoJob.OverSpeed = TbOverspeed.Text.ToDouble(0)
vectoJob.UnderSpeed = TbUnderSpeed.Text.ToDouble(0)
vectoJob.VMin = TbVmin.Text.ToDouble(0)
vectoJob.LookAheadOn = CbLookAhead.Checked
'vec0.ALookahead = CSng(fTextboxToNumString(TbAlookahead.Text))
'vec0.VMinLa = CSng(fTextboxToNumString(TbVminLA.Text))

Markus QUARITSCH
committed
vectoJob.LookAheadMinSpeed = tbLacMinSpeed.Text.ToDouble(0)
vectoJob.LacPreviewFactor = tbLacPreviewFactor.Text.ToDouble(0)
vectoJob.LacDfOffset = tbDfCoastingOffset.Text.ToDouble(0)
vectoJob.LacDfScale = tbDfCoastingScale.Text.ToDouble(0)
vectoJob.LacDfTargetSpeedFile = tbLacDfTargetSpeedFile.Text
vectoJob.LacDfVelocityDropFile = tbLacDfVelocityDropFile.Text
'------------------------------------------------------------
'SAVE

Markus QUARITSCH
committed
If Not vectoJob.SaveFile Then
MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical)
Return False
End If

Markus QUARITSCH
committed
VectoFile = file

Markus QUARITSCH
committed
file = GetFilenameWithoutPath(VectoFile, True)
Text = file
ToolStripStatusLabelGEN.Text = ""

Markus QUARITSCH
committed
MainForm.AddToJobListView(VectoFile)
_changed = False
Return True
End Function
'New file
If ChangeCheckCancel() Then Exit Sub
'Files
TbVEH.Text = ""
TbENG.Text = ""
LvCycles.Items.Clear()
TbGBX.Text = ""
TbDesMaxFile.Text = ""
'Start/Stop
TbSSspeed.Text = DeclarationData.Driver.StartStop.MaxSpeed.AsKmph.ToGUIFormat()

Markus QUARITSCH
committed
TbSStime.Text = DeclarationData.Driver.StartStop.MinTime.ToGUIFormat()
TbSSdelay.Text = DeclarationData.Driver.StartStop.Delay.ToGUIFormat()
ChBStartStop.Checked = False
LvAux.Items.Clear()
CbEngOnly.Checked = False
RdOff.Checked = True
CbLookAhead.Checked = True
'TbAlookahead.Text = "-0.5"
TbOverspeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed.AsKmph.ToGUIFormat()
TbUnderSpeed.Text = DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed.AsKmph.ToGUIFormat()
TbVmin.Text = DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed.AsKmph.ToGUIFormat()

Markus QUARITSCH
committed
'TbVminLA.Text = "50"
tbLacMinSpeed.Text = DeclarationData.Driver.LookAhead.MinimumSpeed.AsKmph.ToGUIFormat()

Markus QUARITSCH
committed
tbLacPreviewFactor.Text = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor.ToGUIFormat()
tbDfCoastingOffset.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset.ToGUIFormat()
tbDfCoastingScale.Text = DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling.ToGUIFormat()
tbLacDfTargetSpeedFile.Text = ""
tbLacDfVelocityDropFile.Text = ""
'---------------------------------------------------
DeclInit()
EngineForm.AutoSendTo = False

Markus QUARITSCH
committed
VectoFile = ""
Text = "Job Editor"
ToolStripStatusLabelGEN.Text = ""
_changed = False
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
UpdatePic()
End Sub
#Region "Track changes"
#Region "'Change' Events"
Private Sub TextBoxVEH_TextChanged(sender As Object, e As EventArgs) _
Handles TbVEH.TextChanged
UpdatePic()
Change()
End Sub
Private Sub TextBoxMAP_TextChanged(sender As Object, e As EventArgs) _
Handles TbENG.TextChanged
UpdatePic()
Change()
End Sub
Private Sub TextBoxFLD_TextChanged(sender As Object, e As EventArgs) _
Handles TbGBX.TextChanged
UpdatePic()
Change()
End Sub
Private Sub TbDesMaxFile_TextChanged_1(sender As Object, e As EventArgs) Handles TbDesMaxFile.TextChanged
Change()
End Sub
Private Sub TBSSspeed_TextChanged(sender As Object, e As EventArgs) Handles TbSSspeed.TextChanged
Change()
End Sub
Private Sub TBSStime_TextChanged(sender As Object, e As EventArgs) _
Handles TbSStime.TextChanged, TbSSdelay.TextChanged
Change()
End Sub
Private Sub TbOverspeed_TextChanged(sender As Object, e As EventArgs) Handles TbOverspeed.TextChanged
Change()
End Sub
Private Sub TbUnderSpeed_TextChanged(sender As Object, e As EventArgs) Handles TbUnderSpeed.TextChanged
Change()
End Sub
Private Sub TbVmin_TextChanged(sender As Object, e As EventArgs) _
Handles TbVmin.TextChanged
Change()
End Sub
Private Sub LvCycles_AfterLabelEdit(sender As Object, e As LabelEditEventArgs) _
Handles LvCycles.AfterLabelEdit
Change()
End Sub
#End Region
Private Sub Change()
If Not _changed Then
ToolStripStatusLabelGEN.Text = "Unsaved changes in current file"
_changed = True
End If
End Sub
' "Save changes? "... Returns True if User aborts
Private Function ChangeCheckCancel() As Boolean
If _changed Then
Select Case MsgBox("Save changes ?", MsgBoxStyle.YesNoCancel)
Case MsgBoxResult.Yes
Return Not Save()
Case MsgBoxResult.Cancel
Return True
Case Else 'MsgBoxResult.No
_changed = False
Return False
End Select
Else
Return False
End If
End Function
#End Region
#Region "Aux Listview"
Private Sub ButAuxAdd_Click(sender As Object, e As EventArgs) Handles ButAuxAdd.Click

Markus QUARITSCH
committed
_auxDialog.VehPath = GetPath(VectoFile)
_auxDialog.TbPath.Text = ""
_auxDialog.CbType.SelectedIndex = -1
_auxDialog.CbType.Text = ""
_auxDialog.TbID.Text = "" '!!! Set Type before ID, because changing the type will overwrite the id !!!
If _auxDialog.ShowDialog = DialogResult.OK Then
Dim lv0 As ListViewItem
For Each lv0 In LvAux.Items
If lv0.SubItems(0).Text = id Then
MsgBox("ID '" & id & "' already defined!", MsgBoxStyle.Critical)
_auxDialog.TbID.SelectAll()
_auxDialog.TbID.Focus()
GoTo lbDlog
End If
Next
lv0 = New ListViewItem
lv0.SubItems(0).Text = UCase(Trim(_auxDialog.TbID.Text))
lv0.SubItems.Add(Trim(_auxDialog.CbType.Text))
lv0.SubItems.Add(Trim(_auxDialog.TbPath.Text))
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
LvAux.Items.Add(lv0)
Change()
End If
End Sub
Private Sub ButAuxRem_Click(sender As Object, e As EventArgs) Handles ButAuxRem.Click
RemoveAuxItem()
End Sub
Private Sub LvAux_DoubleClick(sender As Object, e As EventArgs) Handles LvAux.DoubleClick
EditAuxItem()
End Sub
Private Sub LvAux_KeyDown(sender As Object, e As KeyEventArgs) Handles LvAux.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
If Not Cfg.DeclMode Then RemoveAuxItem()
Case Keys.Enter
EditAuxItem()
End Select
End Sub
Private Sub EditAuxItem()
If LvAux.SelectedItems.Count = 0 Then
Exit Sub
End If

Markus QUARITSCH
committed
Dim selItem As ListViewItem = LvAux.SelectedItems(0)

Markus QUARITSCH
committed
_auxDialog.VehPath = GetPath(VectoFile)
_auxDialog.CbType.SelectedIndex = -1
_auxDialog.CbType.Text = selItem.SubItems(1).Text
_auxDialog.TbID.Text = selItem.SubItems(0).Text 'After Type-set!
If Cfg.DeclMode Then
_auxDialog.CbTech.Text = selItem.SubItems(2).Text
_auxDialog.TbPath.Text = ""
_auxDialog.CbTech.SelectedIndex = -1
_auxDialog.TbPath.Text = selItem.SubItems(2).Text
If _auxDialog.ShowDialog = DialogResult.OK Then
selItem.SubItems(0).Text = UCase(Trim(_auxDialog.TbID.Text))
selItem.SubItems(1).Text = Trim(_auxDialog.CbType.Text)
If Cfg.DeclMode Then
selItem.SubItems(2).Text = Trim(_auxDialog.CbTech.Text)
selItem.SubItems(2).Text = Trim(_auxDialog.TbPath.Text)
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
894
895
896
897
898
899
900
End If
Change()
End If
End Sub
Private Sub RemoveAuxItem()
Dim i As Integer
If LvAux.SelectedItems.Count = 0 Then
If LvAux.Items.Count = 0 Then
Exit Sub
Else
LvAux.Items(LvAux.Items.Count - 1).Selected = True
End If
End If
i = LvAux.SelectedItems(0).Index
LvAux.SelectedItems(0).Remove()
If LvAux.Items.Count > 0 Then
If i < LvAux.Items.Count Then
LvAux.Items(i).Selected = True
Else
LvAux.Items(LvAux.Items.Count - 1).Selected = True
End If
LvAux.Focus()
End If
Change()
End Sub
#End Region
'OK (Save & Close)
Private Sub ButSave_Click(sender As Object, e As EventArgs) Handles ButOK.Click
If Not Save() Then Exit Sub
Close()
End Sub
'Cancel
Private Sub ButCancel_Click(sender As Object, e As EventArgs) Handles ButCancel.Click
Close()
End Sub
#Region "Cycle list"
Private Sub LvCycles_DoubleClick(sender As Object, e As EventArgs) Handles LvCycles.DoubleClick
If LvCycles.SelectedItems.Count > 0 Then _

Markus QUARITSCH
committed
OpenFiles(FileRepl(LvCycles.SelectedItems(0).SubItems(0).Text, GetPath(VectoFile)))
End Sub
Private Sub LvCycles_KeyDown(sender As Object, e As KeyEventArgs) Handles LvCycles.KeyDown
Select Case e.KeyCode
Case Keys.Delete, Keys.Back
RemoveCycle()
Case Keys.Enter
If LvCycles.SelectedItems.Count > 0 Then LvCycles.SelectedItems(0).BeginEdit()
End Select
End Sub
Private Sub BtDRIadd_Click(sender As Object, e As EventArgs) Handles BtDRIadd.Click

Markus QUARITSCH
committed
Dim genDir As String = GetPath(VectoFile)
If DrivingCycleFileBrowser.OpenDialog("", True) Then

Markus QUARITSCH
committed
Dim s As String
For Each s In DrivingCycleFileBrowser.Files

Markus QUARITSCH
committed
LvCycles.Items.Add(GetFilenameWithoutDirectory(s, genDir))
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
Next
Change()
End If
End Sub
Private Sub BtDRIrem_Click(sender As Object, e As EventArgs) Handles BtDRIrem.Click
RemoveCycle()
End Sub
Private Sub RemoveCycle()
Dim i As Integer
If LvCycles.SelectedItems.Count = 0 Then
If LvCycles.Items.Count = 0 Then
Exit Sub
Else
LvCycles.Items(LvCycles.Items.Count - 1).Selected = True
End If
End If
i = LvCycles.SelectedItems(0).Index
LvCycles.SelectedItems(0).Remove()
If LvCycles.Items.Count > 0 Then
If i < LvCycles.Items.Count Then
LvCycles.Items(i).Selected = True
Else
LvCycles.Items(LvCycles.Items.Count - 1).Selected = True
End If
LvCycles.Focus()
End If
Change()
End Sub
#End Region
#Region "Enable/Disable GUI controls"
'Engine only mode changed
Private Sub CbEngOnly_CheckedChanged(sender As Object, e As EventArgs) Handles CbEngOnly.CheckedChanged
CheckEngOnly()
Change()
End Sub
Private Sub CheckEngOnly()
ButOpenVEH.Enabled = onOff
TbVEH.Enabled = onOff
ButtonVEH.Enabled = onOff
ButOpenGBX.Enabled = onOff
TbGBX.Enabled = onOff
ButtonGBX.Enabled = onOff
GrAux.Enabled = onOff
End Sub
'Start/Stop changed
Private Sub ChBStartStop_CheckedChanged_1(sender As Object, e As EventArgs) _
Handles ChBStartStop.CheckedChanged
Change()
If Not Cfg.DeclMode Then PnStartStop.Enabled = ChBStartStop.Checked
End Sub
'LAC changed
Private Sub CbLookAhead_CheckedChanged(sender As Object, e As EventArgs) _
Handles CbLookAhead.CheckedChanged
Change()

Markus QUARITSCH
committed
pnLookAheadCoasting.Enabled = CbLookAhead.Checked
End Sub
'EcoRoll / Overspeed changed
Private Sub RdOff_CheckedChanged(sender As Object, e As EventArgs) _
Handles RdOff.CheckedChanged, RdOverspeed.CheckedChanged, RdEcoRoll.CheckedChanged
Dim ecoRoll As Boolean
Dim overspeed As Boolean
Change()
ecoRoll = RdEcoRoll.Checked
overspeed = RdOverspeed.Checked
TbOverspeed.Enabled = overspeed Or ecoRoll
Label13.Enabled = overspeed Or ecoRoll
Label14.Enabled = overspeed Or ecoRoll
TbUnderSpeed.Enabled = ecoRoll
Label22.Enabled = ecoRoll
Label20.Enabled = ecoRoll
TbVmin.Enabled = overspeed Or ecoRoll
Label23.Enabled = overspeed Or ecoRoll
Label21.Enabled = overspeed Or ecoRoll
End Sub
#End Region
Public Sub UpdatePic()
TbHVCclass.Text = ""
TbVehCat.Text = ""
TbMass.Text = ""
TbAxleConf.Text = ""
TbEngTxt.Text = ""
TbGbxTxt.Text = ""
PicVehicle.Image = Nothing
PicBox.Image = Nothing

Markus QUARITSCH
committed
UpdateVehiclePic()

Markus QUARITSCH
committed
Dim chart As Chart = Nothing
UpdateEnginePic(chart)

Markus QUARITSCH
committed
UpdateGearboxPic(chart)

Markus QUARITSCH
committed
If chart Is Nothing Then Return
Dim chartArea As ChartArea = New ChartArea()
chartArea.Name = "main"
chartArea.AxisX.Title = "engine speed [1/min]"
chartArea.AxisX.TitleFont = New Font("Helvetica", 10)
chartArea.AxisX.LabelStyle.Font = New Font("Helvetica", 8)
chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot
chartArea.AxisY.Title = "engine torque [Nm]"
chartArea.AxisY.TitleFont = New Font("Helvetica", 10)
chartArea.AxisY.LabelStyle.Font = New Font("Helvetica", 8)
chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot
chartArea.AxisX.Minimum = 300
chartArea.BorderDashStyle = ChartDashStyle.Solid
chartArea.BorderWidth = 1

Markus QUARITSCH
committed
chart.Update()
Dim img As Bitmap = New Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb)

Markus QUARITSCH
committed
chart.DrawToBitmap(img, New Rectangle(0, 0, PicBox.Width, PicBox.Height))

Markus QUARITSCH
committed
PicBox.Image = img
End Sub

Markus QUARITSCH
committed
Private Sub UpdateGearboxPic(ByRef chartArea As Chart)
Dim s As Series
Dim i As Integer

Markus QUARITSCH
committed
Dim gearbox As IGearboxEngineeringInputData = Nothing
Dim gearboxFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbGBX.Text), TbGBX.Text)
If File.Exists(gearboxFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(gearboxFile),
IEngineeringInputDataProvider)
gearbox = inputData.GearboxInputData
Catch
End Try
End If

Markus QUARITSCH
committed
If gearbox Is Nothing Then Return
TbGbxTxt.Text = String.Format("{0}-Speed {1} {2}", gearbox.Gears.Count, gearbox.Type.ShortName(), gearbox.ModelName)

Markus QUARITSCH
committed
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
If Cfg.DeclMode Then
For i = 1 To gearbox.Gears.Count
'If FLD0.Init(ENG0.Nidle) Then '' use engine from below...
'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle)
'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1,
' engine.FullLoadCurve, gears,
' engine,
' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text,
' CultureInfo.InvariantCulture),
' (.rdyn / 1000.0).SI(Of Meter))
's = New Series
's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(),
' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList())
's.ChartType = SeriesChartType.FastLine
's.BorderWidth = 2
's.Color = Color.DarkRed
's.Name = "Upshift curve (" & i & ")"
'MyChart.Series.Add(s)
's = New Series
's.Points.DataBindXY(
' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(),
' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList())
's.ChartType = SeriesChartType.FastLine
's.BorderWidth = 2
's.Color = Color.DarkRed
's.Name = "Downshift curve (" & i & ")"
'MyChart.Series.Add(s)
'End If
' OkCount += 1
' pmax = FLD0.Pfull(FLD0.EngineRatedSpeed)
'End If
Next
Else
For Each gear As ITransmissionInputData In gearbox.Gears
If gear.ShiftPolygon Is Nothing OrElse gear.ShiftPolygon.Rows.Count = 0 Then Continue For
Dim shiftPolygon As ShiftPolygon = ShiftPolygonReader.Create(gear.ShiftPolygon)
s = New Series

Markus QUARITSCH
committed
s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(),
shiftPolygon.Upshift.Select(Function(x) x.Torque.Value()).ToArray())

Markus QUARITSCH
committed
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkRed
s.Name = "Upshift curve"
' MyChart.Series.Add(s) 'MQ 2016-06-20: do not plot shift lines in engine dialog
s = New Series

Markus QUARITSCH
committed
s.Points.DataBindXY(shiftPolygon.Downshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(),
shiftPolygon.Downshift.Select(Function(x) x.Torque.Value()).ToArray())

Markus QUARITSCH
committed
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkRed
s.Name = "Downshift curve"
'MyChart.Series.Add(s) 'MQ 2016-06-20:do not plot shift lines in engine dialog
Next
End If
End Sub

Markus QUARITSCH
committed
Private Sub UpdateEnginePic(ByRef chart As Chart)
Dim s As Series
Dim pmax As Double

Markus QUARITSCH
committed
Dim engine As IEngineEngineeringInputData = Nothing
Dim engineFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbENG.Text), TbENG.Text)
If File.Exists(engineFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(engineFile),
IEngineeringInputDataProvider)
engine = inputData.EngineInputData
Catch
Return
End Try
End If

Markus QUARITSCH
committed
'engine.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile))

Markus QUARITSCH
committed
'Create plot
chart = New Chart
chart.Width = PicBox.Width
chart.Height = PicBox.Height

Markus QUARITSCH
committed
'Dim FLD0 As EngineFullLoadCurve = New EngineFullLoadCurve

Markus QUARITSCH
committed
If engine Is Nothing Then Return

Markus QUARITSCH
committed
engine.IdleSpeed.Value()

Markus QUARITSCH
committed
Dim fullLoadCurve As FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray())
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.DarkBlue
s.Name = "Full load"
chart.Series.Add(s)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray())
s.ChartType = SeriesChartType.FastLine
s.BorderWidth = 2
s.Color = Color.Blue
s.Name = "Motoring"
chart.Series.Add(s)

Markus QUARITSCH
committed
pmax = fullLoadCurve.MaxPower.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed)

Markus QUARITSCH
committed
TbEngTxt.Text = String.Format("{0} l {1} kw {2}", (engine.Displacement.Value() * 1000).ToString("0.0"),
pmax.ToString("#"), engine.ModelName)

Markus QUARITSCH
committed
Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap)

Markus QUARITSCH
committed
s = New Series
s.Points.DataBindXY(fuelConsumptionMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(),
fuelConsumptionMap.Entries.Select(Function(x) x.Torque.Value()).ToArray())
s.ChartType = SeriesChartType.Point
s.MarkerSize = 3
s.Color = Color.Red
s.Name = "Map"
chart.Series.Add(s)
End Sub

Markus QUARITSCH
committed
Private Sub UpdateVehiclePic()
Dim HDVclass As String

Markus QUARITSCH
committed
Dim vehicle As IVehicleEngineeringInputData = Nothing

Markus QUARITSCH
committed
Dim vehicleFile As String =
If(Not String.IsNullOrWhiteSpace(VectoFile), Path.Combine(Path.GetDirectoryName(VectoFile), TbVEH.Text), TbVEH.Text)
If File.Exists(vehicleFile) Then
Try
Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(vehicleFile),
IEngineeringInputDataProvider)
vehicle = inputData.VehicleInputData
Catch
End Try
End If

Markus QUARITSCH
committed
If vehicle Is Nothing Then Return

Markus QUARITSCH
committed
Dim maxMass As Kilogram = vehicle.GrossVehicleMassRating 'CSng(fTextboxToNumString(TbMassMass.Text))

Markus QUARITSCH
committed
Dim s0 As Segment = Nothing
Try
s0 = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI(Of Kilogram),
True)
Catch
End Try
If s0 Is Nothing Then
HDVclass = "-"
Else
HDVclass = s0.VehicleClass.GetClassNumber()

Markus QUARITSCH
committed
If Cfg.DeclMode Then
LvCycles.Items.Clear()
Dim m0 As Mission
For Each m0 In s0.Missions
LvCycles.Items.Add(m0.MissionType.ToString())
Next
End If
End If

Markus QUARITSCH
committed
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _
'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False))
TbHVCclass.Text = String.Format("HDV Class {0}", HDVclass)

Markus QUARITSCH
committed
TbVehCat.Text = vehicle.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True)
TbMass.Text = (vehicle.GrossVehicleMassRating.Value() / 1000) & " t"
TbAxleConf.Text = vehicle.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf)
End Sub
#Region "Open File Context Menu"

Markus QUARITSCH
committed
Private _basePath As String = ""
Private Sub OpenFiles(ParamArray files() As String)
If files.Length = 0 Then Exit Sub
OpenWithToolStripMenuItem.Text = "Open with " & Cfg.OpenCmdName
CmOpenFile.Show(Windows.Forms.Cursor.Position)
End Sub
Private Sub OpenWithToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles OpenWithToolStripMenuItem.Click
If Not FileOpenAlt(_contextMenuFiles(0)) Then MsgBox("Failed to open file!")
End Sub
Private Sub ShowInFolderToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles ShowInFolderToolStripMenuItem.Click
If File.Exists(_contextMenuFiles(0)) Then
Process.Start("explorer", "/select,""" & _contextMenuFiles(0) & "")
Catch ex As Exception
MsgBox("Failed to open file!")
End Try
Else
MsgBox("File not found!")
End If
End Sub
#End Region
'AA-TB
Private Sub picAuxInfo_MouseEnter(sender As Object, e As EventArgs) Handles picAuxInfo.MouseEnter
If cboAdvancedAuxiliaries.SelectedIndex = -1 Then Exit Sub
'Get tooltip

Markus QUARITSCH
committed
Dim item As AdvancedAuxiliary

Markus QUARITSCH
committed
item = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)
If item.AuxiliaryVersion = "CLASSIC" Then
ToolTip1.ToolTipTitle = "Classic Vecto Auxiliaries"
ToolTip1.SetToolTip(picAuxInfo, "Uses original basic auxiliaries calculation")
Else
ToolTip1.ToolTipTitle = "Advanced Auxiliary Information"
ToolTip1.SetToolTip(picAuxInfo, item.AuxiliaryName & " : Version=" & item.AuxiliaryVersion)
End If
End Sub
'AA-TB
Private Sub btnBrowseAAUXFile_Click(sender As Object, e As EventArgs) Handles btnBrowseAAUXFile.Click

Markus QUARITSCH
committed
If String.IsNullOrEmpty(VectoFile) Then
MessageBox.Show(
"Please complete and save a valid new .vecto file before adding/configuring advanced bus auxiliaries.")
Return
End If
Dim aauxFileValidated As Boolean = False
Dim fbAux As New FileBrowser("aaux", False, False)
Dim message As String = String.Empty
Dim absoluteAuxPath As String

Markus QUARITSCH
committed
Dim assembly As AdvancedAuxiliary
'If Classic is selected, then bail
If cboAdvancedAuxiliaries.SelectedIndex = 0 Then Return
'Get Absolute Path for AAUX FILE.

Markus QUARITSCH
committed
absoluteAuxPath = ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)
'Set Extensions
fbAux.Extensions = New String() {"AAUX"}
Try

Markus QUARITSCH
committed
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)
Dim validAAUXFile As Boolean = ValidateAAUXFile(absoluteAuxPath, assembly.AssemblyName,
assembly.AuxiliaryVersion, message)
Dim fileExists As Boolean = File.Exists(absoluteAuxPath)
If fileExists AndAlso validAAUXFile Then
ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion,

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text, VectoFile)
Else
Dim needToFindOrCreateFile As Boolean = True
While needToFindOrCreateFile
'Find / Create file and configure.
If fbAux.CustomDialog(absoluteAuxPath, False, False, FileBrowserFileExtensionMode.ForceExt, False, String.Empty) _
Then

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text = GetFilenameWithoutDirectory(fbAux.Files(0), GetPath(VectoFile))

Markus QUARITSCH
committed
assembly = DirectCast(cboAdvancedAuxiliaries.SelectedItem, AdvancedAuxiliary)

Markus QUARITSCH
committed
File.Exists(ResolveAAUXFilePath(GetPath(VectoFile), txtAdvancedAuxiliaryFile.Text)) OrElse
MsgBox("Do you want to create a new .AAUX file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
needToFindOrCreateFile = False
ConfigureAdvancedAuxiliaries(assembly.AssemblyName, assembly.AuxiliaryVersion,

Markus QUARITSCH
committed
txtAdvancedAuxiliaryFile.Text, VectoFile)
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
End If
Else
needToFindOrCreateFile = False
End If
End While
End If
Catch ex As Exception
MessageBox.Show("There was an error configuring your Advanced Auxiliary File")
End Try
End Sub
'AA-TB
Private Sub cboAdvancedAuxiliaries_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles cboAdvancedAuxiliaries.SelectedIndexChanged
'Enable or otherwise the text box and browser button associated with Advanced Axuiliaries
If cboAdvancedAuxiliaries.SelectedIndex = 0 Then
btnBrowseAAUXFile.Enabled = False
txtAdvancedAuxiliaryFile.Enabled = False
Else
btnBrowseAAUXFile.Enabled = True
txtAdvancedAuxiliaryFile.Enabled = True
End If
End Sub
'AA-TB
Private Sub btnAAUXOpen_Click(sender As Object, e As EventArgs) Handles btnAAUXOpen.Click

Markus QUARITSCH
committed
OpenFiles(FileRepl(txtAdvancedAuxiliaryFile.Text, GetPath(VectoFile)))
End Sub

Markus QUARITSCH
committed
Private Sub btnDfTargetSpeed_Click(sender As Object, e As EventArgs) Handles btnDfTargetSpeed.Click
If DriverDecisionFactorTargetSpeedFileBrowser.OpenDialog(FileRepl(tbLacDfTargetSpeedFile.Text, GetPath(VectoFile))) _

Markus QUARITSCH
committed
Then _
tbLacDfTargetSpeedFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorTargetSpeedFileBrowser.Files(0),

Markus QUARITSCH
committed
GetPath(VectoFile))
End Sub

Markus QUARITSCH
committed
Private Sub btnDfVelocityDrop_Click_1(sender As Object, e As EventArgs) Handles btnDfVelocityDrop.Click
If DriverDecisionFactorVelocityDropFileBrowser.OpenDialog(FileRepl(tbLacDfVelocityDropFile.Text, GetPath(VectoFile))) _
Then _
tbLacDfVelocityDropFile.Text = GetFilenameWithoutDirectory(DriverDecisionFactorVelocityDropFileBrowser.Files(0),
GetPath(VectoFile))
End Sub

Markus QUARITSCH
committed
Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
End Sub
End Class