From c9ab05be949cecbd9ee4b9ff32996cefc0735455 Mon Sep 17 00:00:00 2001 From: "ankostis@host:STUW025" <ankostis@gmail.com> Date: Wed, 25 Jun 2014 11:36:21 +0200 Subject: [PATCH] Prepare for release, as v2.0.1-beta0 * Removed unused cResults class. * Minor fix in logging-window. --- CHANGES.md | 13 ++- CSE/CSE.vbproj | 1 - CSE/IO/cJsonFile.vb | 14 +++ CSE/IO/cResults.vb | 195 -------------------------------------- CSE/declaration_public.vb | 2 +- CSE/utils.vb | 9 +- 6 files changed, 27 insertions(+), 207 deletions(-) delete mode 100644 CSE/IO/cResults.vb diff --git a/CHANGES.md b/CHANGES.md index 8c46935..16e8263 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,11 @@ VECTO-CSE: Changes =================== -TODO: 2014-06-??: v2.0.1 +TODO: 2014-06-25: v2.0.1 -------------------- Mostly JRC contributions (see VECTO-29 & VECTO-35): - * IO: JSON-ize preferences, vehicle, job & criteria-files EXCEPT from Track-file and Output-values. + * IO: JSON-ize preferences, vehicle, job & criteria-files EXCEPT from Track-file. * IO: CSVize all the rest files with a single header line and use '#' for comment lines. * IO: Separate config/ from Declaration/ folders. * UI: Provide default-values and help-messages in GUI/files with infos fetched from JSON-schemas. @@ -30,11 +30,14 @@ Mostly JRC contributions (see VECTO-29 & VECTO-35): More analytically: -#### 2014-06-23: v2.0.1-pre3 #### +#### 2014-06-23: v2.0.1-beta0 #### TUG & JRC improvements: - * Changed comment symbol in CSV files from 'c' --> '#' - * Unify hunits into header labels. + * json: Store run-results within the Job-file. + * csv: Ensure result-files are valid CSVs. + * csv: Changed comment symbol in CSV files from 'c' --> '#' + * csv: Unify hunits into header labels. +##### Internal: * Use Exceptions instead of CancelAsync() and error-flags in calc-routines and input.vb. * Remove unused distVincenty() func. diff --git a/CSE/CSE.vbproj b/CSE/CSE.vbproj index d139b2f..17f2a44 100644 --- a/CSE/CSE.vbproj +++ b/CSE/CSE.vbproj @@ -116,7 +116,6 @@ <Compile Include="Classes\cValidSec.vb" /> <Compile Include="IO\cVehicle.vb" /> <Compile Include="Classes\cVirtMSC.vb" /> - <Compile Include="IO\cResults.vb" /> <Compile Include="IO\output.vb" /> <Compile Include="IO\OutputTest.vb" /> <Compile Include="Calculation\Minor_routines_calculate.vb" /> diff --git a/CSE/IO/cJsonFile.vb b/CSE/IO/cJsonFile.vb index 54de586..9217f95 100644 --- a/CSE/IO/cJsonFile.vb +++ b/CSE/IO/cJsonFile.vb @@ -19,6 +19,17 @@ Imports System.Globalization ''' • /Header/BodySchema: The JSON-schema of the body will be placed HERE, for documenting file. ''' When true, it is always replaced by the Body's schema on the next save. When false, it overrides ''' application's choice and is not replaced ever. +''' +''' +''' How to Override: +''' ---------------- +''' You can extend it to add Body-content in 2 ways (and a combination o0f both is possible): +''' • With Properties: Add Properties that on Get/Set write/read directly from the body-content, +''' so the object is always in sync with the JSON-content. +''' • With public fields: Add fields that do not have any side-effect, but then the JSON-content +''' needs to get synced with those fields. This is achieved by overriding thefollowing 2 methods: +''' +''' In any case, ''' </remarks> Public MustInherit Class cJsonFile Implements ICloneable @@ -109,8 +120,11 @@ When False, it overrides Application's choice and is not replaced ever.", ''' <remarks>To signify validation-failure it can throw an exception or add err-messages into the supplied list</remarks> Protected MustOverride Sub ValidateBody(ByVal isStrict As Boolean, ByVal validateMsgs As IList(Of String)) + ''' <summary>Override this to read the JSON-content and update any fields on this instance</summary> Protected Overridable Sub OnContentUpdated() End Sub + + ''' <summary>Override this to update the JSON-content from any fields on this instance before storing it</summary> Protected Overridable Sub OnBeforeContentStored() End Sub diff --git a/CSE/IO/cResults.vb b/CSE/IO/cResults.vb deleted file mode 100644 index 30f7b6b..0000000 --- a/CSE/IO/cResults.vb +++ /dev/null @@ -1,195 +0,0 @@ -Imports Newtonsoft.Json.Linq -Imports Newtonsoft.Json.Schema - -Public Class cResults - Inherits cJsonFile - - Protected Overrides Function HeaderOverlay() As JObject - Return JObject.Parse(<json>{ - "Title": "vecto-cse RESULTS", - "FileVersion": "1.0.0", - }</json>.Value) - End Function - - - '' Default values are Decleration - Private Shared Function BuildBody() As JObject - Dim b, g As Object - b = New JObject() - - g = New JObject() - b.Calibration = g - g.fv_veh = 0 - g.fa_pe = 1 - g.fv_pe = 0 - g.beta_ame = 0 - - g = New JObject() - b.Evaluation = g - g.CdxA = 0 - g.beta = 0 - g.delta_CdxA = 0 - g.CdxA0 = 0 - g.CdxA0_opt2 = 0 - - g = New JObject() - b.Validity = g - g.valid_t_tire = True - g.valid_t_amb = True - g.valid_RRC = True - - Return b - End Function - - ''' <param name="isStrictBody">when true, more strict validation</param> - Public Shared Function JSchemaStr(Optional ByVal isStrictBody As Boolean = False) As String - Dim allowAdditionalProps_str As String = (Not isStrictBody).ToString.ToLower - Return <json>{ - "title": "Schema for vecto-cse RESULTS", - "type": "object", "additionalProperties": <%= allowAdditionalProps_str %>, - "required": true, - "properties": { - "Calibration": { - "type": "object", - "required": true, - "additionalProperties": <%= allowAdditionalProps_str %>, - "properties": { - "fv_veh": {"type": "number", "required": true, - "description": "Calibration factor for vehicle speed.", - }, - "fv_pe": {"type": "number", "required": true, - "description": "Calibration factor for air speed (position error).", - }, - "fa_pe": {"type": "number", "required": true, - "description": "Position error correction factor for measured air inflow angle (beta).", - }, - "beta_ame": {"type": "number", "required": true, - "description": "Calibration factor for beta (misalignment).", - "units": "°", - }, - } - }, - "Evaluation": { - "type": "object", - "required": true, - "additionalProperties": <%= allowAdditionalProps_str %>, - "properties": { - "CdxA": {"type": "number", "required": true, - "description": "Average CdxA before yaw angle correction", - "units": "m^2", - }, - "beta": {"type": "number", "required": true, - "description": "Average absolute yaw angle from high speed tests.", - "units": "m^2", - }, - "delta_CdxA": {"type": "number", "required": true, - "description": "Correction of CdxA for yaw angle.", - "units": "m^2", - }, - "CdxA0": {"type": "number", "required": true, - "description": "Correction of CdxA for zero yaw angle.", - "units": "m^2", - }, - "CdxA0_opt2": {"type": "number", "required": true, - "description": "Average CdxA for zero yaw angle (yaw angle correction performed before averaging of measurement sections).", - "units": "m^2", - }, - } - }, - "Validity": { - "type": "object", - "required": true, - "additionalProperties": <%= allowAdditionalProps_str %>, - "properties": { - "valid_t_tire": {"type": "boolean", "required": true, - "description": "Invalid if the maximum ambient temperature exceeded.", - }, - "valid_t_amb": {"type": "boolean", "required": true, - "description": "Invalid if the ambient temperature fallen below minimum.", - }, - "valid_RRC": {"type": "boolean", "required": true, - "description": "Invalid if the ambient temperature higher than allowed.", - }, - } - }, - }, - }</json>.Value - End Function - - - ''' <summary>creates defaults</summary> - ''' <remarks>See cJsonFile() constructor</remarks> - Sub New(Optional ByVal skipValidation As Boolean = False) - MyBase.New(BuildBody, skipValidation) - End Sub - ''' <summary>Reads from file or creates defaults</summary> - Sub New(ByVal foreignBody As JToken, Optional ByVal skipValidation As Boolean = False) - MyBase.New(foreignBody, skipValidation) - End Sub - - - Protected Overrides Function BodySchemaStr() As String - Return JSchemaStr() - End Function - - ''' <exception cref="SystemException">includes all validation errors</exception> - ''' <param name="isStrictBody">when true, no additional json-properties allowed in the data, when nothing, use value from Header</param> - Protected Overrides Sub ValidateBody(ByVal isStrictBody As Boolean, ByVal validateMsgs As IList(Of String)) - '' Check version - '' - Const fromVersion = "1.0.0--" - Const toVersion = "2.0.0--" ' The earliest pre-release. - If Not IsSemanticVersionsSupported(Me.FileVersion, fromVersion, toVersion) Then - validateMsgs.Add(format("Unsupported FileVersion({0}, was not in between [{1}, {2})", Me.FileVersion, fromVersion, toVersion)) - Return - End If - - '' Check schema - '' - Dim schema = JsonSchema.Parse(JSchemaStr(isStrictBody)) - ValidateJson(Body, schema, validateMsgs) - - If validateMsgs.Any() Then Return - - '' Check others - '' - End Sub - -#Region "json props" - ''' <summary>Override it to set custome fields</summary> - Protected Overrides Sub OnBeforeContentStored() - Dim g, b As Object - b = Me.Body - - g = b("Calibration") - g.fv_veh = Job.fv_veh - g.fa_pe = Job.fa_pe - g.fv_pe = Job.fv_pe - g.beta_ame = Job.beta_ame - - g = b("Evaluation") - g.CdxA = Job.CdxA - g.beta = Job.beta - g.delta_CdxA = Job.delta_CdxA - g.CdxA0 = Job.CdxA0 - g.CdxA0_opt2 = Job.CdxA0_opt2 - - g = b("Validity") - g.valid_t_tire = Job.valid_t_tire - g.valid_t_amb = Job.valid_t_amb - g.valid_RRC = Job.valid_RRC - End Sub - - ''' <summary>Do not invoke this method in vain...</summary> - Property Results As cResults - Get - Return New cResults(Me.Body("Results"), True) - End Get - Set(ByVal value As cResults) - Me.Body("Results") = value.Body - End Set - End Property - -#End Region ' json props - -End Class diff --git a/CSE/declaration_public.vb b/CSE/declaration_public.vb index f24e89e..7431732 100644 --- a/CSE/declaration_public.vb +++ b/CSE/declaration_public.vb @@ -2,7 +2,7 @@ ' Description of the form Public Const AppName As String = "VECTO_CSE" ' Name of the programm - Public Const AppVers As String = "2.0.1-pre3" ' Version of the Programm + Public Const AppVers As String = "2.0.1-beta0" ' Version of the Programm Public AppDate As String ' Date of the compilation of the programm ' Control variables diff --git a/CSE/utils.vb b/CSE/utils.vb index e299d38..6cc2070 100644 --- a/CSE/utils.vb +++ b/CSE/utils.vb @@ -263,15 +263,16 @@ Module utils Dim printEx = False Dim lbox As ListBox + Dim mtext = text If (ex IsNot Nothing) Then printEx = (logFileLevel > 1 AndAlso Prefs.logLevel <= 2) - text = format("{0} (Check {1} for details)", text, IIf(printEx, "error/warn tab", "log-file")) + mtext = format("{0} (Check {1} for details)", text, IIf(printEx, "error/warn tab", "log-file")) End If ' Always write to log-msg tab. '' lbox = F_Main.ListBoxMSG - lbox.Items.Add(text) + lbox.Items.Add(mtext) F_Main.TabPageMSG.Text = format("Messages({0})", lbox.Items.Count) ' Set the Scrollbars in the Listboxes at the end lbox.TopIndex = lbox.Items.Count - 1 @@ -295,9 +296,7 @@ Module utils End If lbox.TopIndex = lbox.Items.Count - 1 - F_Main.TabPageWar.Text = format("Warnings({0})", lbox.Items.Count) - - + lbox.Text = format("{0}({1})", label, lbox.Items.Count) End Sub -- GitLab