Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 063dfa14 authored by Raphael LUZ's avatar Raphael LUZ
Browse files

Merge with JSON

parents fe808e30 a3e74ebc
No related branches found
No related tags found
No related merge requests found
Showing with 8514 additions and 286 deletions
File added
File added
This diff is collapsed.
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
Json.NET
http://james.newtonking.com/projects/json-net.aspx
http://www.codeplex.com/json/
https://github.com/JamesNK/Newtonsoft.Json
Description:
Json.NET is a popular high-performance JSON framework for .NET
-Flexible JSON serializer for converting between .NET objects and JSON
-LINQ to JSON for manually reading and writing JSON
-High performance, faster than .NET's built-in JSON serializers
-Write indented, easy to read JSON
-Convert JSON to and from XML
-Supports .NET 2, .NET 3.5, .NET 4, .NET 4.5, Silverlight, Windows Phone and Windows 8 Store
Documentation:
http://james.newtonking.com/projects/json/help/
Versions:
Json.NET has different libaries for the various .NET Framework versions.
-Net45:
.NET latest (4.5)
-Net40:
.NET 4.0
-Net35:
.NET 3.5
-Net20:
.NET 2.0
-WinRT:
Windows 8 Store
-Portable45:
.NET 4.5, Windows Phone 8, Windows 8 Store
-Portable40:
.NET 4.0, Windows Phone 7, Windows 8 Store, Silverlight 4
Notes:
Microsoft stopped support for the Compact Framework in Visual Studio 2010.
For a Compact Framework 3.5 build download Json.NET 3.5.
For a Silverlight 3.0 build download Json.NET 3.5.
\ No newline at end of file
......@@ -69,9 +69,9 @@ Engine Power</span> [kW]<br>
[rpm]<br>
<br><br>
<a name="fld"></a><span style="font-weight: bold;">Full Load and Drag Curve</span>
<a name="fld"></a><span style="font-weight: bold;">Full Load and Drag Curves</span>
(.vfld)<br>
<div style="margin-left: 40px;">Stationary full load curve described as a function of engine speed by <span style="font-weight: bold;">Max. Torque</span> (column 2). Engine <span style="font-weight: bold;">Motoring Torque</span> is described in column 3. Transient effects on full-load torque built up are considered by a PT1 approach. The related <span style="font-weight: bold;">PT1 time constant</span> is considered in the model as a function of engine speed and has to be specified in column 4.&nbsp;</div><br>
<div style="margin-left: 40px;">Stationary full load curve described as a function of engine speed by <span style="font-weight: bold;">Max. Torque</span> (column 2). Engine <span style="font-weight: bold;">Motoring Torque</span> is described in column 3. Transient effects on full-load torque built up are considered by a PT1 approach. The related <span style="font-weight: bold;">PT1 time constant</span> is considered in the model as a function of engine speed and has to be specified in column 4. <br><br>Different .vfld files can be assigned to each gear or range of gears. See "Add gears" below.<br></div><br>
<div style="margin-left: 40px;"><span style="font-weight: bold;">Format</span>
(comma-separated, dot = decimal-mark):
</div>
......
......@@ -235,8 +235,8 @@ input for Air Speed and Yaw Angle, see <a href="../fileformat/VDRI.html">.vdri f
for .vcdv/.vcdb files</span><br>
</div>
<br><br><div style="margin-left: 40px;"><img style="width: 22px; height: 22px;" alt="" src="../pics/misc/OpenFile.PNG"> <span style="font-weight: bold;">Open file</span> with <a href="../../GRAPHi/documentation/HTML%20Manual/mainwindow.html">GRAPHi</a> or an user-defined tool (see <a href="settings.html#opencmd">File Open Command)</a>.<br></div><br><br>
<a name="retard"></a><span style="font-weight: bold;">Retarder</span><br>
<div style="margin-left: 40px;">If available a <span style="font-weight: bold;">Retarder Torque Loss Map</span> can be defined here. Three options are available:<br>
<a name="retard"></a><span style="font-weight: bold;">Retarder Losses</span><br>
<div style="margin-left: 40px;">If available a <span style="font-weight: bold;">Retarder Torque Loss Map</span> can be defined here to consider losses caused by the retarder (even if not actively in use). <br><span style="font-weight: bold; color: red;">Note: Do not use this function if the retarder's losses are already included in the <a href="GBX-Editor.html#gears">Transmission Loss Maps</a>!</span><br><br>Three options are available:<br>
<ul>
<li>None</li>
<li>Primary (before gearbox): The rpm ratio is relative to the
......
VECTO ?.? (future release) TODO
- User Manual:
"Don't use secondary retarder if retarder losses are already defined in transmission loss maps"
Engine/FLD Editor
New Eco Roll
GBX
......
......@@ -27,7 +27,7 @@ Public Class F_FileSign
Lic.FileSigning.NewFile()
Lic.FileSigning.Comment = "User-created"
Lic.FileSigning.Mode = vectolic.cFileSigning.tMode.Manual
For Each lv0 In Me.lvFiles.Items
......@@ -46,17 +46,9 @@ Public Class F_FileSign
Me.TbLicStr.Text = Lic.FileSigning.CreatorLicStr
Me.TbPubKey.Text = Lic.FileSigning.PubKey
Me.LbMode.Text = Lic.FileSigning.Comment
Me.LbMode.Text = Lic.FileSigning.ModeConv(Lic.FileSigning.Mode)
Me.LbDateStr.Text = Lic.FileSigning.DateStr
If Lic.FileSigning.FilesOK.Count > 0 Then
For Each lv0 In Me.lvFiles.Items
lv0.SubItems(1).Text = Lic.FileSigning.FilesMsg(lv0.Index)
......@@ -93,8 +85,8 @@ Public Class F_FileSign
Me.TbLicStr.Text = Lic.FileSigning.CreatorLicStr
Me.TbPubKey.Text = Lic.FileSigning.PubKey
Me.LbMode.Text = Lic.FileSigning.Comment
If Lic.FileSigning.Comment = "Created by VECTO" Then
Me.LbMode.Text = Lic.FileSigning.ModeConv(Lic.FileSigning.Mode)
If Lic.FileSigning.Mode = vectolic.cFileSigning.tMode.Auto Then
Me.LbMode.ForeColor = Color.DarkGreen
Else
Me.LbMode.ForeColor = Color.Red
......
......@@ -559,9 +559,6 @@ Public Class F_GEN
Exit Sub
End Try
If Gfile.NoJSON Then MsgBox("File format is outdated! Save file again to update to current format!")
'Update Form
If Gfile.PKWja Then
Me.ComboBoxVehType.SelectedIndex = 1
......@@ -703,6 +700,10 @@ Public Class F_GEN
Me.TbAlookahead.Text = CStr(Gfile.a_lookahead)
Me.TbVminLA.Text = CStr(Gfile.vMinLA)
'-------------------------------------------------------------
If Gfile.NoJSON Then MsgBox("File format is outdated! Save file again to update to current format!")
'-------------------------------------------------------------
......
......@@ -213,242 +213,7 @@ Public Class cGEN
End Sub
Public Function SaveFile() As Boolean
Dim fGEN As New cFile_V3
Dim AuxEntryKV As KeyValuePair(Of String, cVEH.cAuxEntry)
'Dim s As String
Dim sb As cSubPath
If Not fGEN.OpenWrite(sFilePath) Then Return False
'fGEN.WriteLine("V" & FormatVersion)
fGEN.WriteLine("c VECTO Input File")
fGEN.WriteLine("c VECTO " & VECTOvers)
fGEN.WriteLine("c " & Now.ToString)
'fGEN.WriteLine("c Heavy Duty (0) or Passenger Car (1)")
'fGEN.WriteLine(Math.Abs(CInt(boPKWja)))
'fGEN.WriteLine("c Transient emission correction (1/0)")
'fGEN.WriteLine(Math.Abs(CInt(bodynkorja)))
'fGEN.WriteLine("c Emission Class (EURO ..)")
'fGEN.WriteLine(ineklasse)
'fGEN.WriteLine("c Gear Shift Mode: NEDC (0), FTP (1), Model - MT (2)")
'fGEN.WriteLine(inizykwael)
'fGEN.WriteLine("c Calculation Mode, EngAnalysis, CreateMap")
'Select Case VehMode
' Case tVehMode.StandardMode
' s = "0"
' Case tVehMode.EngineOnly
' s = "1"
' Case tVehMode.HEV
' s = "2"
' Case Else 'tVehMode.EV
' s = "3"
'End Select
's &= "," & Math.Abs(CInt(EngAnalysis))
's &= "," & Math.Abs(CInt(CreateMap))
'fGEN.WriteLine(s)
'Map creation ------------------------------------------------ ------
'fGEN.WriteLine("c Settings for Emission Map Creation Mode:")
'fGEN.WriteLine("c Increment Pe, n:")
'fGEN.WriteLine(inPschrit & "," & innschrit)
'fGEN.WriteLine("c CutFull,CutDrag,InsertDrag,DragIntp:")
'fGEN.WriteLine(Math.Abs(CInt(bKFcutFull)) & "," & Math.Abs(CInt(bKFcutDrag)) & "," & Math.Abs(CInt(bKFinsertDrag)) & "," & Math.Abs(CInt(bKFDragIntp)))
'fGEN.WriteLine("c Include Gear Shifts (1/0, Standard = 1)")
'fGEN.WriteLine(Math.Abs(CInt(boMapSchaltja)))
'fGEN.WriteLine("c Averageing Period for Modal Values")
'fGEN.WriteLine(iniMsek)
'fGEN.WriteLine("c ICE Type (Otto = 1, Diesel = 0")
'fGEN.WriteLine(Math.Abs(CInt(boottoJa)))
'Kalt Start---------------------------------------------------------------
'fGEN.WriteLine("c Cold Start (1/0)")
'fGEN.WriteLine(Math.Abs(CInt(bokaltst1)))
'fGEN.WriteLine("c t cat start [°C]")
'fGEN.WriteLine(sitkat1)
'fGEN.WriteLine("c t coolant start [°C]")
'fGEN.WriteLine(sitkw1)
'fGEN.WriteLine("c time of start [h.sec]")
'fGEN.WriteLine(sihsstart)
'Dateien------------------------------------------------------------------
fGEN.WriteLine("c Vehicle (.vveh):")
fGEN.WriteLine(stPathVEH.PathOrDummy)
fGEN.WriteLine("c Engine (.veng):")
fGEN.WriteLine(stPathENG.PathOrDummy)
fGEN.WriteLine("c Gearbox (*.vgbx):")
fGEN.WriteLine(stPathGBX.PathOrDummy)
fGEN.WriteLine("c Driving Cycles (.vdri):")
For Each sb In CycleFiles
fGEN.WriteLine(sb.PathOrDummy)
Next
fGEN.WriteLine(sKey.Break)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing transient correction parameters (*.trs):")
'fGEN.WriteLine(stdynspez.PathOrDummy)
'Kalt Start
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the catalyst map (*.maa):")
'fGEN.WriteLine(stkatmap.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the map of cooling water (*.mac):")
'fGEN.WriteLine(stkwmap.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the catalyst warm-up (*.wua):")
'fGEN.WriteLine(stkatkurv.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the engine coolant warm-up (*.wuc):")
'fGEN.WriteLine(stkwkurv.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the cooling parameters for catalyst and engine coolant (*.cdw):")
'fGEN.WriteLine(stcooldown.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the ambient parameters (*.atc)")
'fGEN.WriteLine(sttumgebung.PathOrDummy)
'HEV
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing battery specifications for HEV (*.bat)")
'fGEN.WriteLine(stBatfile.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing specifications of the E-motor for HEV (*emo)")
'fGEN.WriteLine(stEmospez.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the pattern of E-motor on/off for HEV (*ean)")
'fGEN.WriteLine(stEANfile.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the efficiency of additional gearbox for HEV (*get)")
'fGEN.WriteLine(stGetspez.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the control efficiency-File for HEV (*.ste)")
'fGEN.WriteLine(stSTEnam.PathOrDummy)
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c File containing the efficiency-maps for HEV-strategy control (*.ekf)")
'fGEN.WriteLine(stEKFnam.PathOrDummy)
'EXS
'fGEN.WriteLine("c ")
'fGEN.WriteLine("c Exhaust System Simulation (1/0)")
'fGEN.WriteLine(Math.Abs(CInt(boEXSja)))
'fGEN.WriteLine("c Exhaust System Simulation Configuration File")
'fGEN.WriteLine(stPathExs.PathOrDummy)
'SOC-Start Iteration
'fGEN.WriteLine("c SOC Start Iteration (1/0) - HEV only")
'fGEN.WriteLine(Math.Abs(CInt(boSOCnJa)))
''SOC-Start
'fGEN.WriteLine("c SOC Start - (H)EV only")
'fGEN.WriteLine(siSOCstart)
''Getriebe-Verluste-Modell
'fGEN.WriteLine("c Transmission Loss Model")
'fGEN.WriteLine(CStr(GetrMod))
'Coolantsim
'fGEN.WriteLine("c Coolant System Simulation (1/0)")
'fGEN.WriteLine(Math.Abs(CInt(CoolantsimJa)))
'fGEN.WriteLine("c Coolant System Simulation Configuration File")
'fGEN.WriteLine(stCoolantSimPath.PathOrDummy)
fGEN.WriteLine("c Auxiliaries (.vaux)")
For Each AuxEntryKV In AuxPaths
fGEN.WriteLine(Trim(UCase(AuxEntryKV.Key)) & "," & AuxEntryKV.Value.Type & "," & AuxEntryKV.Value.Path.PathOrDummy)
Next
fGEN.WriteLine(sKey.Break)
'a_DesMax
fGEN.WriteLine("c Speed Dependent Desired Acceleration and Braking (.vacc)")
'fGEN.WriteLine(Math.Abs(CInt(DesMaxJa)))
fGEN.WriteLine(stDesMaxFile.PathOrDummy)
'fGEN.WriteLine("c Gear shift behaviour:")
'fGEN.WriteLine("c Gearshift model (Version fast driver)")
'fGEN.WriteLine("c shift up at ratio rpm/rated rpm in actual gear greater than")
'fGEN.WriteLine(CStr(hinauf))
'fGEN.WriteLine("c shift down when rpm/rated rpm in lower gear is higher than")
'fGEN.WriteLine(CStr(hinunter))
'fGEN.WriteLine("c Gearshift model (Version economic driver)")
'fGEN.WriteLine("c shift up at ratio rpm/rated rpm in higher gear greater than")
'fGEN.WriteLine(CStr(lhinauf))
'fGEN.WriteLine("c Shift down when ratio rpm/rated rpm in actual gear is lower than")
'fGEN.WriteLine(CStr(lhinunter))
'fGEN.WriteLine("c Share of version economic driver (0 to 1)")
'fGEN.WriteLine(CStr(pspar))
'fGEN.WriteLine("c Share of version mixed model (0 to 1)")
'fGEN.WriteLine(CStr(pmodell))
fGEN.WriteLine("c Engine Only Mode (1/0)")
fGEN.WriteLine(CStr(Math.Abs(CInt(EngOnly))))
'Start/Stop
fGEN.WriteLine("c ICE Auto-Start/Stop (1/0) - Non HEV only")
fGEN.WriteLine(Math.Abs(CInt(boStartStop)))
fGEN.WriteLine("c Start/Stop Max Speed [km/h]")
fGEN.WriteLine(siStStV)
fGEN.WriteLine("c Start/Stop Min ICE-On Time [s]")
fGEN.WriteLine(siStStT)
fGEN.WriteLine("c Look Ahead reference deceleration [m/2²]")
fGEN.WriteLine(CStr(a_lookahead))
fGEN.WriteLine("c Minimum target speed for Overspeed/Eco-Roll [km/h]")
fGEN.WriteLine(CStr(vMin))
fGEN.WriteLine("c Look-Ahead with Coasting 1/0")
fGEN.WriteLine(CStr(Math.Abs(CInt(LookAheadOn))))
fGEN.WriteLine("c Overspeed 1/0")
fGEN.WriteLine(CStr(Math.Abs(CInt(OverSpeedOn))))
fGEN.WriteLine("c Eco-Roll 1/0")
fGEN.WriteLine(CStr(Math.Abs(CInt(EcoRollOn))))
fGEN.WriteLine("c Allowed OverSpeed [km/h]")
fGEN.WriteLine(CStr(OverSpeed))
fGEN.WriteLine("c Allowed UnderSpeed [km/h]")
fGEN.WriteLine(CStr(UnderSpeed))
fGEN.WriteLine("c Minimum target speed for Look-Ahead with Coasting [km/h]")
fGEN.WriteLine(CStr(vMinLA))
fGEN.WriteLine("c Start/Stop activation delay time [s]")
fGEN.WriteLine(StStDelay)
fGEN.Close()
fGEN = Nothing
Return True
End Function
Public Function ReadFile() As Boolean
Private Function ReadFileOld() As Boolean
Dim file As cFile_V3
Dim line As String()
'Dim txt As String
......@@ -706,7 +471,7 @@ lbEr:
End Function
Public Function SaveFileJSON() As Boolean
Public Function SaveFile() As Boolean
Dim AuxEntryKV As KeyValuePair(Of String, cVEH.cAuxEntry)
'Dim s As String
Dim sb As cSubPath
......@@ -714,6 +479,13 @@ lbEr:
Dim ls As List(Of Object)
Dim dic As Dictionary(Of String, Object)
'Meta
dic = New Dictionary(Of String, Object)
dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")")
dic.Add("Date", Now.ToString)
dic.Add("Version", VECTOvers)
JSON.Content.Add("Info", dic)
'Main Files
JSON.Content.Add("VehicleFile", stPathVEH.PathOrDummy)
JSON.Content.Add("EngineFile", stPathENG.PathOrDummy)
......@@ -781,17 +553,18 @@ lbEr:
End Function
Public Function ReadFileJSON() As Boolean
Public Function ReadFile() As Boolean
Dim AuxEntry As cVEH.cAuxEntry
Dim AuxID As String
Dim MsgSrc As String
Dim SubPath As cSubPath
Dim JSON As New cJSON
Dim str As String
Dim dic As Dictionary(Of String, Object)
Dim dic As Object
MsgSrc = "Main/ReadInp/GEN"
'Flag for "File is not JSON" Warnings
NoJSON = False
If sFilePath = "" Then Return False
......@@ -802,18 +575,18 @@ lbEr:
If Not JSON.ReadFile(sFilePath) Then
NoJSON = True
Try
Return ReadFile()
Return ReadFileOld()
Catch ex As Exception
Return False
End Try
End If
Try
stPathVEH.Init(MyPath, JSON.Content("VehicleFile"))
If JSON.Content.ContainsKey("VehicleFile") Then stPathVEH.Init(MyPath, JSON.Content("VehicleFile"))
stPathENG.Init(MyPath, JSON.Content("EngineFile"))
stPathGBX.Init(MyPath, JSON.Content("GearboxFile"))
If JSON.Content.ContainsKey("GearboxFile") Then stPathGBX.Init(MyPath, JSON.Content("GearboxFile"))
If JSON.Content.ContainsKey("Cycles") Then
For Each str In JSON.Content("Cycles")
......@@ -826,7 +599,7 @@ lbEr:
If JSON.Content.ContainsKey("Aux") Then
For Each dic In JSON.Content("Aux")
AuxID = UCase(Trim(dic("ID")))
AuxID = UCase(Trim(dic("ID").ToString))
If AuxPaths.ContainsKey(AuxID) Then
WorkerMsg(tMsgID.Err, "Multiple definitions of the same auxiliary type (" & AuxID & ")!", MsgSrc)
......@@ -845,7 +618,7 @@ lbEr:
Next
End If
stDesMaxFile.Init(MyPath, JSON.Content("VACC"))
If JSON.Content.ContainsKey("VACC") Then stDesMaxFile.Init(MyPath, JSON.Content("VACC"))
EngOnly = JSON.Content("EngineOnlyMode")
......@@ -856,24 +629,29 @@ lbEr:
End If
If JSON.Content.ContainsKey("StartStop") Then
boStartStop = JSON.Content("StartStop")("Enabled")
siStStV = JSON.Content("StartStop")("MaxSpeed")
siStStT = JSON.Content("StartStop")("MinTime")
StStDelay = JSON.Content("StartStop")("Delay")
dic = JSON.Content("StartStop")
boStartStop = dic("Enabled")
siStStV = dic("MaxSpeed")
siStStT = dic("MinTime")
StStDelay = dic("Delay")
Else
boStartStop = False
End If
If JSON.Content.ContainsKey("LAC") Then
LookAheadOn = JSON.Content("LAC")("Enabled")
a_lookahead = JSON.Content("LAC")("Dec")
vMinLA = JSON.Content("LAC")("MinSpeed")
dic = JSON.Content("LAC")
LookAheadOn = dic("Enabled")
a_lookahead = dic("Dec")
vMinLA = dic("MinSpeed")
Else
LookAheadOn = False
End If
If JSON.Content.ContainsKey("OverSpeedEcoRoll") Then
Select Case UCase(JSON.Content("OverSpeedEcoRoll")("Mode"))
dic = JSON.Content("OverSpeedEcoRoll")
Select Case UCase(dic("Mode").ToString).Trim
Case "ECOROLL"
OverSpeedOn = False
EcoRollOn = True
......@@ -887,13 +665,13 @@ lbEr:
EcoRollOn = False
Case Else
WorkerMsg(tMsgID.Err, "Value '" & JSON.Content("OverSpeedEcoRoll")("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc)
WorkerMsg(tMsgID.Err, "Value '" & dic("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc)
Return False
End Select
vMin = JSON.Content("OverSpeedEcoRoll")("MinSpeed")
OverSpeed = JSON.Content("OverSpeedEcoRoll")("OverSpeed")
UnderSpeed = JSON.Content("OverSpeedEcoRoll")("UnderSpeed")
vMin = dic("MinSpeed")
OverSpeed = dic("OverSpeed")
If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed")
Else
OverSpeedOn = False
......
......@@ -591,7 +591,7 @@ lbNextJob:
'Write file signatures
WorkerMsg(tMsgID.Normal, "Signing files", MsgSrc)
Lic.FileSigning.Comment = "Created by VECTO"
Lic.FileSigning.Mode = vectolic.cFileSigning.tMode.Auto
If Lic.FileSigning.WriteSigFile(SigFile, LicSigAppCode) Then
WorkerMsg(tMsgID.Normal, "Files signed successfully: " & fFILE(SigFile, True), MsgSrc, SigFile)
......
......@@ -82,6 +82,9 @@
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\Third Party Libraries\JSON.Net\Bin\Net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
......
......@@ -2,7 +2,7 @@
Module VECTO_Global
Public Const VECTOvers As String = "1.4 RC2"
Public Const VECTOvers As String = "1.4 RC2 JSON 2"
Public Const LicSigAppCode As String = "VECTO-Release-0093C61E0A2E4BFA9A7ED7E729C56AE4"
Public MyAppPath As String
Public MyConfPath As String
......
Imports System.Collections.Generic
Imports Newtonsoft.Json
'uses JSON.NET http://json.codeplex.com/
Public Class cJSON
Public Content As Dictionary(Of String, Object)
Private fullfile As String
Public ErrorMsg As String
Public Sub New()
Content = New Dictionary(Of String, Object)
......@@ -11,6 +15,79 @@ Public Class cJSON
Public Function ReadFile(ByVal path As String) As Boolean
Dim file As Microsoft.VisualBasic.FileIO.TextFieldParser
Dim str As String
Content.Clear()
'check if file exists
If Not IO.File.Exists(path) Then
ErrorMsg = "file not found"
Return False
End If
'open file
Try
file = New Microsoft.VisualBasic.FileIO.TextFieldParser(path)
Catch ex As Exception
ErrorMsg = ex.Message
Return False
End Try
'Check if file is empty
If file.EndOfData Then
file.Close()
ErrorMsg = "file is empty"
Return False
End If
'read file
str = file.ReadToEnd
'close file
file.Close()
'parse JSON to Dictionary
Try
'JSONobj = JsonConvert.DeserializeObject(str)
Content = JsonConvert.DeserializeObject(str, Content.GetType)
Catch ex As Exception
ErrorMsg = ex.Message
Return False
End Try
Return True
End Function
Public Function WriteFile(ByVal path As String) As Boolean
Dim file As System.IO.StreamWriter
Dim str As String
Dim First As Boolean = True
If Content.Count = 0 Then Return False
Try
str = Newtonsoft.Json.JsonConvert.SerializeObject(Content, Formatting.Indented)
file = My.Computer.FileSystem.OpenTextFileWriter(path, False)
Catch ex As Exception
Return False
End Try
file.Write(str)
file.Close()
Return True
End Function
#Region "old self-made parser"
Private fullfile As String
Private Function ReadFileXXX(ByVal path As String) As Boolean
Dim file As Microsoft.VisualBasic.FileIO.TextFieldParser
Content.Clear()
......@@ -56,7 +133,10 @@ Public Class cJSON
End Function
Public Function WriteFile(ByVal path As String) As Boolean
Private Function WriteFileXXX(ByVal path As String) As Boolean
Dim file As System.IO.StreamWriter
Dim kv As KeyValuePair(Of String, Object)
Dim str As New System.Text.StringBuilder
......@@ -212,11 +292,6 @@ Public Class cJSON
Return str
End Function
Private Function GetObject() As Dictionary(Of String, Object)
Dim MyDic As Dictionary(Of String, Object)
Dim key As String
......@@ -337,6 +412,7 @@ lb20:
End Function
#End Region
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment