Skip to content

Commit

Permalink
removed canopen xml support (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrof authored Apr 4, 2024
1 parent fd5c2a5 commit addcce3
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 1,083 deletions.
139 changes: 6 additions & 133 deletions EDSEditorGUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ You should have received a copy of the GNU General Public License
using System.Windows.Forms;
using System.IO;
using libEDSsharp;
using Xml2CSharp;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace ODEditor
Expand Down Expand Up @@ -141,13 +140,6 @@ void ProfileAddClick(object sender, EventArgs e)
CanOpenXDD_1_1 coxml_1_1 = new CanOpenXDD_1_1();
eds = coxml_1_1.ReadXML(filename);
break;

case ".xml":
CanOpenXML coxml = new CanOpenXML();
coxml.readXML(filename);
Bridge b = new Bridge();
eds = b.convert(coxml.dev);
break;
}

if (eds == null)
Expand Down Expand Up @@ -197,11 +189,8 @@ private void openEDSfile(string path,InfoSection.Filetype ft)
try
{
EDSsharp eds = new EDSsharp();
Device dev;

eds.Loadfile(path);
Bridge bridge = new Bridge(); //tell me again why bridge is not static?
dev = bridge.convert(eds);

DeviceView device = new DeviceView(eds, network);

Expand Down Expand Up @@ -289,13 +278,12 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
Warnings.warning_list.Clear();

OpenFileDialog odf = new OpenFileDialog();
odf.Filter = "All supported files (*.xdd;*.xdc;*.xpd;*.eds;*.dcf;*.xml)|*.xdd;*.xdc;*.xpd;*.eds;*.dcf;*.xml|"
odf.Filter = "All supported files (*.xdd;*.xdc;*.xpd;*.eds;*.dcf)|*.xdd;*.xdc;*.xpd;*.eds;*.dcf|"
+ "CANopen XDD (*.xdd)|*.xdd|"
+ "CANopen XDC (*.xdc)|*.xdc|"
+ "CANopen XPD (*.xpd)|*.xpd|"
+ "Electronic Data Sheet (*.eds)|*.eds|"
+ "Device Configuration File (*.dcf)|*.dcf|"
+ "CANopenNode XML, old (*.xml)|*.xml";
+ "Device Configuration File (*.dcf)|*.dcf";

if (odf.ShowDialog() == DialogResult.OK)
{
Expand All @@ -308,10 +296,6 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
openXDDfile(odf.FileName);
break;

case ".xml":
openXMLfile(odf.FileName);
break;

case ".eds":
openEDSfile(odf.FileName, InfoSection.Filetype.File_EDS);
break;
Expand Down Expand Up @@ -383,50 +367,6 @@ private void openXDDfile(string path)



}

private void openXMLfile(string path)
{

try
{
EDSsharp eds;
Device dev; //one day this will be multiple devices

CanOpenXML coxml = new CanOpenXML();
coxml.readXML(path);

Bridge b = new Bridge();

eds = b.convert(coxml.dev);
eds.projectFilename = path;

dev = coxml.dev;

tabControl1.TabPages.Add(eds.di.ProductName);

DeviceView device = new DeviceView(eds, network);
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
eds.OnDataDirty += Eds_onDataDirty;

tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);

device.Dock = DockStyle.Fill;
device.dispatch_updateOD();

network.Add(eds);
}
catch (Exception ex)
{
Warnings.warning_list.Add(ex.ToString());
}

if (Warnings.warning_list.Count != 0)
{
WarningsFrm frm = new WarningsFrm();
frm.Show();
}

}

private void Device_UpdateODViewForEDS(object sender, UpdateODViewEventArgs e)
Expand Down Expand Up @@ -545,8 +485,7 @@ private void exportDeviceFileToolStripMenuItem_Click(object sender, EventArgs e)
+ "Electronic Data Sheet (*.eds)|*.eds|"
+ "Device Configuration File (*.dcf)|*.dcf|"
+ "Documentation (*.md)|*.md|"
+ "CANopen XDD v1.0, old (*.xdd)|*.xdd|"
+ "CANopenNode XML, old (*.xml)|*.xml";
+ "CANopen XDD v1.0, old (*.xdd)|*.xdd";

sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.projectFilename);
sfd.RestoreDirectory = true;
Expand Down Expand Up @@ -633,16 +572,6 @@ void dosave(DeviceView dv, string FileName, bool xddfileVersion_1_1, bool stripp
dv.eds.mdfilename = FileName;
break;

case ".xml":
Bridge b = new Bridge();
Device d = b.convert(dv.eds);

CanOpenXML coxml = new CanOpenXML();
coxml.dev = d;
coxml.writeXML(FileName);
dv.eds.xmlfilename = FileName;
break;

case ".xdd":
case ".xdc":
case ".xpd":
Expand Down Expand Up @@ -752,16 +681,12 @@ void OpenRecentFile(object sender, EventArgs e)
if (ext != null)
ext = ext.ToLower();

if ( ext == ".xml" )
openXMLfile(filepath);
if (ext == ".xdd" || ext == ".xdc" || ext == ".xpd")
openXDDfile(filepath);
if ( ext == ".eds" )
openEDSfile(filepath, InfoSection.Filetype.File_EDS);
if (ext == ".dcf")
openEDSfile(filepath, InfoSection.Filetype.File_DCF);
if (ext == ".nxml")
openNetworkfile(filepath);

}

Expand Down Expand Up @@ -857,8 +782,7 @@ private void saveNetworkXmlToolStripMenuItem_Click(object sender, EventArgs e)

sfd.Filter = "CANopen Network XDD v1.1 (*.nxdd)|*.nxdd|"
+ "CANopen Network XDC v1.1 (*.nxdc)|*.nxdc|"
+ "CANopen Network XDD v1.0, old (*.nxdd)|*.nxdd|"
+ "CANopenNode network XML, old (*.nxml)|*.nxml";
+ "CANopen Network XDD v1.0, old (*.nxdd)|*.nxdd";

sfd.InitialDirectory = Path.GetDirectoryName(networkfilename);
sfd.RestoreDirectory = true;
Expand All @@ -868,12 +792,6 @@ private void saveNetworkXmlToolStripMenuItem_Click(object sender, EventArgs e)
{
switch (sfd.FilterIndex)
{
case 4: // .nxml
NetworkXML net = new NetworkXML();
net.writeXML(sfd.FileName, network);
addtoMRU(sfd.FileName);
break;

case 3: // .nxdd V1.0
CanOpenXDD xdd = new CanOpenXDD();
xdd.writeMultiXML(sfd.FileName, network);
Expand All @@ -896,19 +814,14 @@ private void loadNetworkXmlToolStripMenuItem_Click(object sender, EventArgs e)
{

OpenFileDialog odf = new OpenFileDialog();
odf.Filter = "All supported files (*.nxdd;*.nxdc;*.nxml)|*.nxdd;*.nxdc;*.nxml|"
odf.Filter = "All supported files (*.nxdd;*.nxdc)|*.nxdd;*.nxdc|"
+ "CANopen Network XDD (*.nxdd)|*.nxdd|"
+ "CANopen Network XDC (*.nxdc)|*.nxdc|"
+ "CANopenNode network XML, old (*.nxml)|*.nxml";
+ "CANopen Network XDC (*.nxdc)|*.nxdc|";

if (odf.ShowDialog() == DialogResult.OK)
{
switch (Path.GetExtension(odf.FileName).ToLower())
{
case ".nxml":
openNetworkfile(odf.FileName);
break;

case ".nxdd":
case ".nxdc":
openXDDNetworkfile(odf.FileName);
Expand Down Expand Up @@ -954,38 +867,6 @@ private void openXDDNetworkfile(string file)

}

private void openNetworkfile(string file)
{
NetworkXML net = new NetworkXML();
List<Device> devs = net.readXML(file);

foreach (Device d in devs)
{
Bridge b = new Bridge();

EDSsharp eds = b.convert(d);
//eds.filename = path; //fixme: We need to save the projectfilename or SaveAs will throw an exception

tabControl1.TabPages.Add(eds.di.ProductName);


DeviceView device = new DeviceView(eds, network);

tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
device.Dock = DockStyle.Fill;

network.Add(eds);
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
eds.OnDataDirty += Eds_onDataDirty;

device.dispatch_updateOD();

addtoMRU(file);
}

networkfilename = file;
}

private void networkPDOToolStripMenuItem_Click(object sender, EventArgs e)
{

Expand Down Expand Up @@ -1309,10 +1190,6 @@ private void ODEditor_MainForm_DragDrop(object sender, DragEventArgs e)
openXDDfile(fileName);
break;

case ".xml":
openXMLfile(fileName);
break;

case ".eds":
openEDSfile(fileName, InfoSection.Filetype.File_EDS);
break;
Expand All @@ -1321,10 +1198,6 @@ private void ODEditor_MainForm_DragDrop(object sender, DragEventArgs e)
openEDSfile(fileName, InfoSection.Filetype.File_DCF);
break;

case ".nxml":
openNetworkfile(fileName);
break;

case ".nxdc":
case ".nxdd":
openXDDNetworkfile(fileName);
Expand Down
21 changes: 1 addition & 20 deletions EDSSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ static void Main(string[] args)
openXDDfile(infile, outfile,type);
break;

case ".xml":
openXMLfile(infile,outfile,type);
break;

case ".eds":
openEDSfile(infile, outfile,InfoSection.Filetype.File_EDS,type);
break;
Expand All @@ -76,7 +72,7 @@ static void Main(string[] args)
}
else
{
Console.WriteLine("Usage EDSEditor --type [CanOpenNode|CanOpenNodeV4] --infile file.[xdd|eds|xml] --outfile [CO_OD.c|OD]");
Console.WriteLine("Usage EDSEditor --type [CanOpenNode|CanOpenNodeV4] --infile file.[xdd|eds] --outfile [CO_OD.c|OD]");
}
}
catch(Exception e)
Expand Down Expand Up @@ -117,21 +113,6 @@ private static void exportCOOD(string outpath,ExporterFactory.Exporter type)

}

private static void openXMLfile(string path,string outpath,ExporterFactory.Exporter exportertype)
{

CanOpenXML coxml = new CanOpenXML();
coxml.readXML(path);

Bridge b = new Bridge();

eds = b.convert(coxml.dev);

eds.projectFilename = path;
exportCOOD(outpath,exportertype);

}

private static void openXDDfile(string path, string outpath,ExporterFactory.Exporter exportertype)
{
CanOpenXDD_1_1 coxml_1_1 = new CanOpenXDD_1_1();
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ Library
* Read EDS/DCF/XDC file and parse contents to approprate classes
* Dump EDS/DCF classes via ToString()
* Save EDS/DCF classes back to EDS file
* Read CanOpenNode xml project file
* Write CanOpenNode xmlproject file
* Switch formats between EDS/DCF and CanOpenNode XML (note to EDS will result in
data loss as the format supports less information).
* Export C and H files in CanOpenNode format CO_OD.c and CO_OD.h
* EDS/DCF supports modules
* EDS/DCF supports compactPDO (read only) 1*
Expand All @@ -88,8 +84,6 @@ GUI
* Open multiple devices
* Open EDS/DCF/XDC files
* Save EDS/DCF/XDC files
* Open CanOpenNode XML Project file
* Save CanOpenNode XML File
* View OD Entries and explore the Object Dictionary
* Add new OD entries
* Delete exisiting OD entries
Expand Down
Loading

0 comments on commit addcce3

Please sign in to comment.