Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 6cd55366 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

round trailer payload to the next hundredth kilogram

parent 8e7fac25
No related branches found
No related tags found
No related merge requests found
...@@ -46,20 +46,20 @@ namespace HashingCmd ...@@ -46,20 +46,20 @@ namespace HashingCmd
{ {
public delegate void HashingAction(string filename, VectoHash h); public delegate void HashingAction(string filename, VectoHash h);
private const string Usage = @" private const string Usage = @"
hashingcmd.exe (-h | [-v] [[-s] -x] [-c] [-r]) <file.xml> <file2.xml> <file3.xml> hashingcmd.exe (-h | [-v] [[-s] -x] [-c] [-r]) <file.xml> <file2.xml> <file3.xml>
"; ";
private const string Help = @" private const string Help = @"
hashingcmd.exe hashingcmd.exe
-h: print help -h: print help
-v: verify hashed file -v: verify hashed file
-s: create hashed file -s: create hashed file
-x: validate generated XML against VECTO XML schema -x: validate generated XML against VECTO XML schema
-c: compute hash and write to stdout -c: compute hash and write to stdout
-r: read hash from file and write to stdout -r: read hash from file and write to stdout
"; ";
private static readonly Dictionary<string, HashingAction> Actions = new Dictionary<string, HashingAction> { private static readonly Dictionary<string, HashingAction> Actions = new Dictionary<string, HashingAction> {
......
Imports System.IO Imports System.IO
Imports System.Xml.Linq Imports System.Xml.Linq
Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.Exceptions
Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.InputData
Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Models
Imports TUGraz.VectoCore.OutputData.XML Imports TUGraz.VectoCore.OutputData.XML
Public Class XMLExportJobDialog Public Class XMLExportJobDialog
Private _mode As ExecutionMode Private _mode As ExecutionMode
Private _data As IInputDataProvider Private _data As IInputDataProvider
Public Sub Initialize(data As IInputDataProvider) Public Sub Initialize(data As IInputDataProvider)
Dim source As String Dim source As String
Dim allowSingleFile As Boolean Dim allowSingleFile As Boolean
Dim eng As IEngineeringInputDataProvider = CType(data, IEngineeringInputDataProvider) Dim eng As IEngineeringInputDataProvider = CType(data, IEngineeringInputDataProvider)
If (Not eng Is Nothing AndAlso Not eng.JobInputData().SavedInDeclarationMode) Then If (Not eng Is Nothing AndAlso Not eng.JobInputData().SavedInDeclarationMode) Then
source = eng.JobInputData().JobName source = eng.JobInputData().JobName
_mode = ExecutionMode.Engineering _mode = ExecutionMode.Engineering
allowSingleFile = True allowSingleFile = True
Else Else
Dim decl As IDeclarationInputDataProvider = CType(data, IDeclarationInputDataProvider) Dim decl As IDeclarationInputDataProvider = CType(data, IDeclarationInputDataProvider)
If (Not decl Is Nothing AndAlso decl.JobInputData().SavedInDeclarationMode) Then If (Not decl Is Nothing AndAlso decl.JobInputData().SavedInDeclarationMode) Then
source = decl.JobInputData().JobName source = decl.JobInputData().JobName
_mode = ExecutionMode.Declaration _mode = ExecutionMode.Declaration
allowSingleFile = False allowSingleFile = False
Else Else
Throw New VectoException("Input data is neither declaration nor engineering mode!") Throw New VectoException("Input data is neither declaration nor engineering mode!")
End If End If
End If End If
_data = data _data = data
tbJobfile.Text = source tbJobfile.Text = source
tbMode.Text = If(_mode = ExecutionMode.Engineering, "Engineering Mode", "Declaration Mode") tbMode.Text = If(_mode = ExecutionMode.Engineering, "Engineering Mode", "Declaration Mode")
cbSingleFile.Checked = True cbSingleFile.Checked = True
cbSingleFile.Enabled = allowSingleFile cbSingleFile.Enabled = allowSingleFile
End Sub End Sub
Private Sub btnBrowseOutputDir_Click(sender As Object, e As EventArgs) Handles BtTCfileBrowse.Click Private Sub btnBrowseOutputDir_Click(sender As Object, e As EventArgs) Handles BtTCfileBrowse.Click
If Not FolderFileBrowser.OpenDialog("") Then If Not FolderFileBrowser.OpenDialog("") Then
Exit Sub Exit Sub
End If End If
Dim filePath As String = FolderFileBrowser.Files(0) Dim filePath As String = FolderFileBrowser.Files(0)
tbDestination.Text = Path.GetFullPath(filePath) tbDestination.Text = Path.GetFullPath(filePath)
End Sub End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Close() Close()
End Sub End Sub
Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
If (String.IsNullOrWhiteSpace(tbDestination.Text) OrElse Not Directory.Exists(tbDestination.Text)) Then If (String.IsNullOrWhiteSpace(tbDestination.Text) OrElse Not Directory.Exists(tbDestination.Text)) Then
MessageBox.Show("Output directory is invalid", "Invalid Output", MessageBoxButtons.OK) MessageBox.Show("Output directory is invalid", "Invalid Output", MessageBoxButtons.OK)
Exit Sub Exit Sub
End If End If
If (_mode = ExecutionMode.Engineering) Then If (_mode = ExecutionMode.Engineering) Then
Dim engineeringData As IEngineeringInputDataProvider = CType(_data, IEngineeringInputDataProvider) Dim engineeringData As IEngineeringInputDataProvider = CType(_data, IEngineeringInputDataProvider)
If (engineeringData Is Nothing OrElse engineeringData.JobInputData().SavedInDeclarationMode) Then If (engineeringData Is Nothing OrElse engineeringData.JobInputData().SavedInDeclarationMode) Then
Throw New Exception("Input data is not in engineering mode!") Throw New Exception("Input data is not in engineering mode!")
End If End If
Dim document As XDocument = Dim document As XDocument =
New XMLEngineeringWriter(tbDestination.Text, cbSingleFile.Checked, tbVendor.Text).GenerateVectoJob(engineeringData) New XMLEngineeringWriter(tbDestination.Text, cbSingleFile.Checked, tbVendor.Text).GenerateVectoJob(engineeringData)
document.Save(Path.Combine(tbDestination.Text, engineeringData.JobInputData().JobName + ".xml")) document.Save(Path.Combine(tbDestination.Text, engineeringData.JobInputData().JobName + ".xml"))
MessageBox.Show("Successfully exported") MessageBox.Show("Successfully exported")
Close() Close()
Else Else
Dim declarationData As IDeclarationInputDataProvider = CType(_data, IDeclarationInputDataProvider) Dim declarationData As IDeclarationInputDataProvider = CType(_data, IDeclarationInputDataProvider)
If (declarationData Is Nothing OrElse Not declarationData.JobInputData().SavedInDeclarationMode) Then If (declarationData Is Nothing OrElse Not declarationData.JobInputData().SavedInDeclarationMode) Then
Throw New Exception("Input data is not in declaration mode") Throw New Exception("Input data is not in declaration mode")
End If End If
Dim document As XDocument = Dim document As XDocument =
New XMLDeclarationWriter(tbVendor.Text).GenerateVectoJob(declarationData) New XMLDeclarationWriter(tbVendor.Text).GenerateVectoJob(declarationData)
document.Save(Path.Combine(tbDestination.Text, declarationData.JobInputData().JobName + ".xml")) document.Save(Path.Combine(tbDestination.Text, declarationData.JobInputData().JobName + ".xml"))
MessageBox.Show("Successfully exported") MessageBox.Show("Successfully exported")
Close() Close()
End If End If
End Sub End Sub
End Class End Class
\ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/ */
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
...@@ -88,8 +89,8 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -88,8 +89,8 @@ namespace TUGraz.VectoCore.Models.Declaration
/// </summary> /// </summary>
public static Kilogram GetPayloadForTrailerWeight(Kilogram grossVehicleWeight, Kilogram curbWeight, bool lowLoading) public static Kilogram GetPayloadForTrailerWeight(Kilogram grossVehicleWeight, Kilogram curbWeight, bool lowLoading)
{ {
return (Payloads.LookupTrailer(grossVehicleWeight, curbWeight) / (lowLoading ? 7.5 : 1)).LimitTo(0.SI<Kilogram>(), return (Math.Round((Payloads.LookupTrailer(grossVehicleWeight, curbWeight) / (lowLoading ? 7.5 : 1)).LimitTo(0.SI<Kilogram>(),
grossVehicleWeight - curbWeight); grossVehicleWeight - curbWeight).Value() / 100, 0) * 100).SI<Kilogram>();
} }
public static int PoweredAxle() public static int PoweredAxle()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment