diff --git a/libEDSsharp/Bridge.cs b/libEDSsharp/Bridge.cs index f3b22a70..22ca0bdd 100644 --- a/libEDSsharp/Bridge.cs +++ b/libEDSsharp/Bridge.cs @@ -19,9 +19,7 @@ You should have received a copy of the GNU General Public License using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Globalization; using Xml2CSharp; using System.Text.RegularExpressions; @@ -191,24 +189,32 @@ public Device convert(EDSsharp eds) dev.Other.DeviceIdentity = new DeviceIdentity(); dev.Other.DeviceIdentity.ProductName = eds.di.ProductName; - //dev.Other.DeviceIdentity.ProductText = new ProductText(); - //dev.Other.DeviceIdentity.ProductText.Description + dev.Other.DeviceIdentity.ProductNumber = eds.di.ProductNumber; + dev.Other.DeviceIdentity.ProductText = new ProductText(); + dev.Other.DeviceIdentity.ProductText.Description = new Description(); + dev.Other.DeviceIdentity.ProductText.Description.Text = eds.fi.Description; + if (eds.di.concreteNodeId!=-1) dev.Other.DeviceIdentity.ConcreteNoideId = eds.di.concreteNodeId.ToString(); dev.Other.DeviceIdentity.VendorName = eds.di.VendorName; + dev.Other.DeviceIdentity.VendorNumber = eds.di.VendorNumber; - //dev.Other.File = new Other.File(); dev.Other.File = new File(); dev.Other.File.FileName = eds.fi.FileName; - dev.Other.File.FileCreationDate = eds.fi.CreationDate; - dev.Other.File.FileCreationTime = eds.fi.CreationTime; + dev.Other.File.FileCreationDate = eds.fi.CreationDateTime.ToString("MM-dd-yyyy"); + dev.Other.File.FileCreationTime = eds.fi.CreationDateTime.ToString("h:mmtt"); dev.Other.File.FileCreator = eds.fi.CreatedBy; + dev.Other.File.FileModificationDate = eds.fi.ModificationDateTime.ToString("MM-dd-yyyy"); + dev.Other.File.FileModificationTime = eds.fi.ModificationDateTime.ToString("h:mmtt"); + dev.Other.File.FileModifedBy = eds.fi.ModifiedBy; + dev.Other.File.FileVersion = eds.fi.FileVersion.ToString(); + dev.Other.File.FileRevision = eds.fi.FileRevision; dev.Other.File.ExportFolder = eds.fi.exportFolder; @@ -392,8 +398,13 @@ public EDSsharp convert(Device dev) } eds.di.ProductName = dev.Other.DeviceIdentity.ProductName; - //dev.Other.DeviceIdentity.ProductText + eds.di.ProductNumber = dev.Other.DeviceIdentity.ProductNumber; + + if(dev.Other.DeviceIdentity.ProductText!=null && dev.Other.DeviceIdentity.ProductText.Description!=null & dev.Other.DeviceIdentity.ProductText.Description.Text!=null) + eds.fi.Description = dev.Other.DeviceIdentity.ProductText.Description.Text; + eds.di.VendorName = dev.Other.DeviceIdentity.VendorName; + eds.di.VendorNumber = dev.Other.DeviceIdentity.VendorNumber; if (dev.Other.DeviceIdentity.ConcreteNoideId != null) { @@ -404,12 +415,38 @@ public EDSsharp convert(Device dev) eds.di.concreteNodeId = -1; } + string dtcombined; + eds.fi.FileName = dev.Other.File.FileName; - eds.fi.CreationDate = dev.Other.File.FileCreationDate; - eds.fi.CreationTime = dev.Other.File.FileCreationTime; + + dtcombined = string.Format("{0} {1}", dev.Other.File.FileCreationTime, dev.Other.File.FileCreationDate); + try + { + eds.fi.CreationDateTime = DateTime.ParseExact(dtcombined, "h:mmtt MM-dd-yyyy", CultureInfo.InvariantCulture); + eds.fi.CreationDate = eds.fi.CreationDateTime.ToString("MM-dd-yyyy"); + eds.fi.CreationTime = eds.fi.CreationDateTime.ToString("h:mmtt"); + + } + catch(Exception e) { } + eds.fi.CreatedBy = dev.Other.File.FileCreator; eds.fi.exportFolder = dev.Other.File.ExportFolder; + dtcombined = string.Format("{0} {1}", dev.Other.File.FileModificationTime, dev.Other.File.FileModificationDate); + try + { + eds.fi.ModificationDateTime = DateTime.ParseExact(dtcombined, "h:mmtt MM-dd-yyyy", CultureInfo.InvariantCulture); + eds.fi.ModificationDate = eds.fi.ModificationDateTime.ToString("MM-dd-yyyy"); + eds.fi.ModificationTime = eds.fi.ModificationDateTime.ToString("h:mmtt"); + } + catch (Exception e) { } + + + + + eds.fi.ModifiedBy = dev.Other.File.FileModifedBy; + + dev.Other.Capabilities = dev.Other.Capabilities; try @@ -424,6 +461,8 @@ public EDSsharp convert(Device dev) eds.fi.FileVersion = 0; } + eds.fi.FileRevision = dev.Other.File.FileRevision; + eds.fi.EDSVersion = "4.0"; //FIX me any other approprate defaults for eds here?? diff --git a/libEDSsharp/CanOpenXML.cs b/libEDSsharp/CanOpenXML.cs index 4a4cb6f3..cbb5cafd 100644 --- a/libEDSsharp/CanOpenXML.cs +++ b/libEDSsharp/CanOpenXML.cs @@ -195,8 +195,16 @@ public class File { public string FileCreationDate { get; set; } [XmlAttribute(AttributeName="fileCreationTime")] public string FileCreationTime { get; set; } - [XmlAttribute(AttributeName="fileVersion")] + [XmlAttribute(AttributeName = "fileModifedBy")] + public string FileModifedBy { get; set; } + [XmlAttribute(AttributeName = "fileMotifcationDate")] + public string FileModificationDate { get; set; } + [XmlAttribute(AttributeName = "fileModificationTime")] + public string FileModificationTime { get; set; } + [XmlAttribute(AttributeName="fileVersion")] public string FileVersion { get; set; } + [XmlAttribute(AttributeName = "fileRevision")] + public byte FileRevision { get; set; } [XmlAttribute(AttributeName = "exportFolder")] public string ExportFolder { get; set; } @@ -214,10 +222,14 @@ public class ProductText { public class DeviceIdentity { [XmlElement(ElementName="vendorName")] public string VendorName { get; set; } - [XmlElement(ElementName="productName")] + [XmlElement(ElementName = "vendorNumber")] + public uint VendorNumber { get; set; } + [XmlElement(ElementName="productName")] public string ProductName { get; set; } - [XmlElement(ElementName="productText")] - public ProductText ProductText { get; set; } + [XmlElement(ElementName="productNumber")] + public uint ProductNumber { get; set; } + [XmlElement(ElementName = "productText")] + public ProductText ProductText { get; set; } [XmlElement(ElementName = "concreteNoideId")] public string ConcreteNoideId { get; set; } } diff --git a/libEDSsharp/eds.cs b/libEDSsharp/eds.cs index 64b189e1..41aa7cd4 100644 --- a/libEDSsharp/eds.cs +++ b/libEDSsharp/eds.cs @@ -480,12 +480,14 @@ public class FileInfo : InfoSection [EdsExport] public string CreatedBy = "";//=CANFestival //max245 - + public DateTime ModificationDateTime;// + [EdsExport] public string ModificationTime=""; [EdsExport] public string ModificationDate=""; + [EdsExport] public string ModifiedBy="";//=CANFestival //max244 @@ -1019,7 +1021,6 @@ public EDSsharp() fi.FileVersion = 1; fi.FileRevision = 1; - //FixMe too need a extra function to sort the data out; fi.CreationDateTime = DateTime.Now; fi.ModificationDateTime = DateTime.Now; @@ -1208,6 +1209,7 @@ public void loadfile(string filename) if (eds.ContainsKey("Comments")) c.parse(eds["Comments"]); + updatePDOcount(); } // catch(Exception e) @@ -1222,6 +1224,20 @@ public void savefile(string filename) updatePDOcount(); + //generate date times in DS306 format; h:mmtt MM-dd-yyyy + + fi.CreationDate = fi.CreationDateTime.ToString("MM-dd-yyyy"); + fi.CreationTime = fi.CreationDateTime.ToString("h:mmtt"); + + fi.ModificationDate = fi.ModificationDateTime.ToString("MM-dd-yyyy"); + fi.ModificationTime = fi.ModificationDateTime.ToString("h:mmtt"); + + fi.FileName = filename; + + fi.EDSVersion = "4.0"; + fi.EDSVersionMajor = 4; + fi.EDSVersionMinor = 0; + StreamWriter writer = File.CreateText(filename); fi.write(writer); di.write(writer);