Newer
Older
Imports System.Collections.Generic
Public Class cVECTO
Public Mode As tVECTOmode
Public CurrentMission As cMission
Public Missions As Dictionary(Of tMission, cMission)
Public SegmentTable As cSegmentTable
Public Sub New()
Mode = tVECTOmode.Declaration
End Sub
Public Function Init() As Boolean
Dim file As New cFile_V3
Dim m0 As cMission
Dim s0 As cSegmentTableEntry
Dim line As String()
Dim i As Integer
'Initialize
Missions = New Dictionary(Of tMission, cMission)
SegmentTable = New cSegmentTable
If Not IO.Directory.Exists(MyDeclPath) Then
GUImsg(tMsgID.Err, "Failed to load Declaration Config!")
Return False
End If
'Missions
If Not file.OpenRead(MyDeclPath & "Missions.csv") Then
GUImsg(tMsgID.Err, "Failed to load Declaration Config (Mission Definitions)!")
Return False
End If
Try
'Header
line = file.ReadLine
'Data
Do While Not file.EndOfFile
m0 = New cMission
line = file.ReadLine
m0.MissionID = CType(CInt(line(0)), tMission)
m0.NameStr = line(1)
m0.CyclePath = MyDeclPath & line(2)
Missions.Add(m0.MissionID, m0)
Loop
Catch ex As Exception
GUImsg(tMsgID.Err, "Failed to load Declaration Config (Mission Definitions)!")
file.Close()
Return False
End Try
file.Close()
'Segment Table
If Not file.OpenRead(MyDeclPath & "SegmentTable.csv") Then
GUImsg(tMsgID.Err, "Failed to load Declaration Config (Segment Table)!")
Return False
End If
Try
'Header
line = file.ReadLine
'Data
Do While Not file.EndOfFile
line = file.ReadLine
s0 = New cSegmentTableEntry
s0.VehCat = CType(CInt(line(0)), tVehCat)
s0.AxleConf = CType(CInt(line(1)), tAxleConf)
s0.MaxGVW = CSng(line(2))
s0.VehClass = line(3)
For i = 4 To 13
If Trim(UCase(line((i)))) = "X" Or Trim(UCase(line((i)))) = "XX" Then
s0.MissionList.Add(CType(CInt(i - 4), tMission))
End If
Next
SegmentTable.SegTableEntries.Add(s0)
Loop
Catch ex As Exception
file.Close()
GUImsg(tMsgID.Err, "Failed to load Declaration Config (Segment Table)!")
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
Return False
End Try
GUImsg(tMsgID.Normal, "Declaration Config loaded.")
Return True
End Function
End Class
Public Class cMission
Public MissionID As tMission
Public NameStr As String
Public CyclePath As String
End Class
Public Class cSegmentTable
Public SegTableEntries As New List(Of cSegmentTableEntry)
Public Function ConfigIsValid(ByVal VehCat As tVehCat, ByVal AxleConf As tAxleConf, ByVal MaxGVW As Single) As Boolean
Dim s0 As cSegmentTableEntry
For Each s0 In SegTableEntries
If s0.VehCat = VehCat And s0.AxleConf = AxleConf And s0.MaxGVW > MaxGVW Then
Return True
End If
Next
Return False
End Function
Public Function SetRef(ByRef SegTableEntryRef As cSegmentTableEntry, ByVal VehCat As tVehCat, ByVal AxleConf As tAxleConf, ByVal MaxGVW As Single) As Boolean
Dim s0 As cSegmentTableEntry
For Each s0 In SegTableEntries
If s0.VehCat = VehCat And s0.AxleConf = AxleConf And s0.MaxGVW > MaxGVW Then
SegTableEntryRef = s0
Return True
End If
Next
SegTableEntryRef = Nothing
Return False
End Function
End Class
Public Class cSegmentTableEntry
Public VehCat As tVehCat
Public AxleConf As tAxleConf
Public MaxGVW As Single
Public VehClass As String
Public MissionList As New List(Of tMission)
End Class