diff --git a/VECTO/GUI/GearboxForm.Designer.vb b/VECTO/GUI/GearboxForm.Designer.vb index 709c8b9920416bb3af79e769cc4782274ce0ca31..73232fd36e0620e3934e3a9ccf2adb5e5d7b10a6 100644 --- a/VECTO/GUI/GearboxForm.Designer.vb +++ b/VECTO/GUI/GearboxForm.Designer.vb @@ -134,6 +134,7 @@ Partial Class GearboxForm Me.Label35 = New System.Windows.Forms.Label() Me.gbTCAccMin = New System.Windows.Forms.GroupBox() Me.lblGbxInfo = New System.Windows.Forms.Label() + Me.btnExportXML = New System.Windows.Forms.Button() Me.ToolStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -1041,6 +1042,15 @@ Partial Class GearboxForm Me.lblGbxInfo.Size = New System.Drawing.Size(0, 13) Me.lblGbxInfo.TabIndex = 51 ' + 'btnExportXML + ' + Me.btnExportXML.Location = New System.Drawing.Point(468, 648) + Me.btnExportXML.Name = "btnExportXML" + Me.btnExportXML.Size = New System.Drawing.Size(102, 23) + Me.btnExportXML.TabIndex = 52 + Me.btnExportXML.Text = "Export as XML" + Me.btnExportXML.UseVisualStyleBackColor = True + ' 'GearboxForm ' Me.AcceptButton = Me.ButOK @@ -1048,6 +1058,7 @@ Partial Class GearboxForm Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ButCancel Me.ClientSize = New System.Drawing.Size(877, 696) + Me.Controls.Add(Me.btnExportXML) Me.Controls.Add(Me.lblGbxInfo) Me.Controls.Add(Me.gbTCAccMin) Me.Controls.Add(Me.gbPowershiftLosses) @@ -1198,4 +1209,5 @@ Partial Class GearboxForm Friend WithEvents Label35 As System.Windows.Forms.Label Friend WithEvents gbTCAccMin As System.Windows.Forms.GroupBox Friend WithEvents lblGbxInfo As System.Windows.Forms.Label + Friend WithEvents btnExportXML As System.Windows.Forms.Button End Class diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 40f6a17f37f80cc25ad80bab3900fb354869c9e3..8a37f6d2399e7476a8f260559f2d3f9164ea39a4 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -15,6 +15,9 @@ Imports System.IO Imports System.Linq Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting +Imports System.Xml.Linq +Imports Microsoft.WindowsAPICodePack.Dialogs +Imports TUGraz.IVT.VectoXML.Writer Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models @@ -101,7 +104,7 @@ Public Class GearboxForm TbMinTimeBetweenShifts.Text = DeclarationData.Gearbox.MinTimeBetweenGearshifts.ToGUIFormat() 'cDeclaration.MinTimeBetweenGearshift(GStype) - TbTqResv.Text = (DeclarationData.Gearbox.TorqueReserve * 100).ToGUIFormat() ' cDeclaration.TqResv + TbTqResv.Text = (DeclarationData.Gearbox.TorqueReserve * 100).ToGUIFormat() ' cDeclaration.TqResv TbTqResvStart.Text = (DeclarationData.Gearbox.TorqueReserveStart * 100).ToGUIFormat() 'cDeclaration.TqResvStart TbStartSpeed.Text = DeclarationData.Gearbox.StartSpeed.ToGUIFormat() 'cDeclaration.StartSpeed TbStartAcc.Text = DeclarationData.Gearbox.StartAcceleration.ToGUIFormat() ' cDeclaration.StartAcc @@ -361,6 +364,34 @@ Public Class GearboxForm 'Save file Private Function SaveGbx(file As String) As Boolean + + Dim gearbox As Gearbox = FillGearboxData(file) + + + + If Not gearbox.SaveFile Then + MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical) + Return False + End If + + If AutoSendTo Then + If VectoJobForm.Visible Then + If UCase(FileRepl(VectoJobForm.TbGBX.Text, JobDir)) <> UCase(file) Then _ + VectoJobForm.TbGBX.Text = GetFilenameWithoutDirectory(file, JobDir) + VectoJobForm.UpdatePic() + End If + End If + + GearboxFileBrowser.UpdateHistory(file) + Text = GetFilenameWithoutPath(file, True) + LbStatus.Text = "" + + _changed = False + + Return True + End Function + + Private Function FillGearboxData(file As String) As Gearbox Dim gearbox As Gearbox Dim i As Integer @@ -408,28 +439,7 @@ Public Class GearboxForm gearbox.TCCUpshiftMinAcceleration = tbTCCUpshiftMinAcceleration.Text.ToDouble(0) gearbox.PSShiftTime = tbATShiftTime.Text.ToDouble(0) - - - If Not gearbox.SaveFile Then - MsgBox("Cannot safe to " & file, MsgBoxStyle.Critical) - Return False - End If - - If AutoSendTo Then - If VectoJobForm.Visible Then - If UCase(FileRepl(VectoJobForm.TbGBX.Text, JobDir)) <> UCase(file) Then _ - VectoJobForm.TbGBX.Text = GetFilenameWithoutDirectory(file, JobDir) - VectoJobForm.UpdatePic() - End If - End If - - GearboxFileBrowser.UpdateHistory(file) - Text = GetFilenameWithoutPath(file, True) - LbStatus.Text = "" - - _changed = False - - Return True + Return gearbox End Function #Region "Change Events" @@ -956,6 +966,21 @@ Public Class GearboxForm GetPath(_gbxFile)) End If End Sub + + Private Sub btnExportXML_Click(sender As Object, e As EventArgs) Handles btnExportXML.Click + + If (Cfg.DeclMode) Then + Dim dialog As CommonOpenFileDialog = New CommonOpenFileDialog() + dialog.IsFolderPicker = True + If (dialog.ShowDialog() = CommonFileDialogResult.Cancel) Then + Exit Sub + End If + Dim data As Gearbox = FillGearboxData(_gbxFile) + + Dim export As XDocument = New XMLDeclarationWriter(data.Vendor).GenerateVectoComponent(data, data) + export.Save(Path.Combine(dialog.FileName, data.ModelName + ".xml")) + End If + End Sub End Class diff --git a/VECTO/GUI/MainForm.resx b/VECTO/GUI/MainForm.resx index 7a10cc6bc771ee05159f0a0d4132dbe37d358569..1ab95c20be0eb1a9777f7aae6720fb67961848f1 100644 --- a/VECTO/GUI/MainForm.resx +++ b/VECTO/GUI/MainForm.resx @@ -223,9 +223,6 @@ <metadata name="CmOpenFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>732, 12</value> </metadata> - <metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>850, 12</value> - </metadata> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>49</value> </metadata> diff --git a/VECTO/GUI/XMLExportJobDialog.vb b/VECTO/GUI/XMLExportJobDialog.vb index 8eebeeb9c7ff6060aecd9b09e1151eb8db47e294..d067bca88731244519aa2dc25103c2cb1cc89491 100644 --- a/VECTO/GUI/XMLExportJobDialog.vb +++ b/VECTO/GUI/XMLExportJobDialog.vb @@ -70,7 +70,7 @@ Public Class XMLExportJobDialog Throw New Exception("Input data is not in declaration mode") End If Dim document As XDocument = - New XMLDeclarationWriter(tbDestination.Text, tbVendor.Text).GenerateVectoJob(declarationData) + New XMLDeclarationWriter(tbVendor.Text).GenerateVectoJob(declarationData) document.Save(Path.Combine(tbDestination.Text, declarationData.JobInputData().JobName + ".xml")) MessageBox.Show("Successfully exported") Close() diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs index dcacbf4a120495711b7cdc990688f1724bd4599a..86ff41cbfd54f7dc93552f4c6e37f9bb0d47c70b 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using TUGraz.VectoCommon.InputData; @@ -12,7 +13,7 @@ namespace TUGraz.IVT.VectoXML.Writer //private readonly XNamespace _vectoNs = @"../../../API/VectoInput.xsd"; - public XMLDeclarationWriter(string basePath, string vendor) : base(basePath, vendor) + public XMLDeclarationWriter(string vendor) : base(null, vendor) { tns = "urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6"; rootNamespace = "urn:tugraz:ivt:VectoAPI:DeclarationInput:v0.6"; @@ -40,6 +41,33 @@ namespace TUGraz.IVT.VectoXML.Writer return job; } + public XDocument GenerateVectoComponent(IGearboxDeclarationInputData data, + ITorqueConverterDeclarationInputData torqueConverter) + { + return GenerateComponentDocument(CreateGearbox(data, torqueConverter)); + } + + public XDocument GenerateVectoComponent(IAxleGearInputData data) + { + return GenerateComponentDocument(CreateAxlegear(data)); + } + + protected XDocument GenerateComponentDocument(XElement content) + { + var xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance"); + var component = new XDocument(); + component.Add(new XElement(rootNamespace + XMLNames.VectoInputDeclaration, + new XAttribute("schemaVersion", SchemaVersion), + new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), + new XAttribute("xmlns", tns), + new XAttribute(XNamespace.Xmlns + "tns", rootNamespace), + new XAttribute(xsi + "schemaLocation", + string.Format("{0} {1}VectoInput.xsd", rootNamespace, SchemaLocationBaseUrl)), + content) + ); + return component; + } + protected XElement[] CreateDeclarationJob(IDeclarationInputDataProvider data) { return new[] { @@ -73,7 +101,7 @@ namespace TUGraz.IVT.VectoXML.Writer new XElement(tns + XMLNames.Vehicle_PTOType, "None"), new XElement(tns + XMLNames.Vehicle_Components, CreateEngine(data.EngineInputData), - CreateGearbox(gearbox, data), + CreateGearbox(gearbox, gearbox.Type.AutomaticTransmission() ? data.TorqueConverterInputData : null), angledrive.Type == AngledriveType.SeparateAngledrive ? CreateAngleDrive(angledrive) : null, retarder.Type.IsDedicatedComponent() ? CreateRetarder(retarder) : null, CreateAxlegear(data.AxleGearInputData), @@ -109,7 +137,8 @@ namespace TUGraz.IVT.VectoXML.Writer ); } - protected XElement CreateGearbox(IGearboxDeclarationInputData gbxData, IDeclarationInputDataProvider inputData) + protected XElement CreateGearbox(IGearboxDeclarationInputData gbxData, + ITorqueConverterDeclarationInputData torqueConverter) { var gears = new XElement(tns + XMLNames.Gearbox_Gears); var i = 1; @@ -132,12 +161,15 @@ namespace TUGraz.IVT.VectoXML.Writer new XElement(tns + XMLNames.Gearbox_TransmissionType, GearboxtypeToXML(gbxData.Type)), gears ), - gbxData.Type.AutomaticTransmission() ? CreateTorqueConverter(inputData.TorqueConverterInputData) : null); + gbxData.Type.AutomaticTransmission() ? CreateTorqueConverter(torqueConverter) : null); } private XElement CreateTorqueConverter(ITorqueConverterDeclarationInputData data) { + if (data == null) { + throw new Exception("Torque Converter is required!"); + } return new XElement(tns + XMLNames.Component_TorqueConverter, new XElement(tns + XMLNames.ComponentDataWrapper, new XElement(tns + XMLNames.TorqueConverter_Characteristics,