Ejemplo n.º 1
0
        private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Warnings.warning_list.Clear();

                if (tabControl1.SelectedTab != null)
                {
                    DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                    SaveFileDialog sfd = new SaveFileDialog();

                    string temp = Path.GetTempFileName();

                    this.UseWaitCursor = true;

                    DocumentationGen docgen = new DocumentationGen();
                    docgen.genhtmldoc(temp, dv.eds);
                    ReportView rv = new ReportView(temp);
                    rv.Show();

                    this.UseWaitCursor = false;
                }
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void saveEDSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                sfd.Filter = "Electronic Data Sheets (*.eds)|*.eds";

                sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.edsfilename);
                sfd.RestoreDirectory = true;
                sfd.FileName         = Path.GetFileNameWithoutExtension(dv.eds.edsfilename);

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    if (dv.eds.edsfilename != sfd.FileName)
                    {
                        dv.eds.dirty = true;
                    }

                    dv.eds.savefile(sfd.FileName);

                    dv.eds.edsfilename = sfd.FileName;
                    dv.dispatch_updateOD();
                }
            }
        }
Ejemplo n.º 3
0
        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

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


                DeviceView device = new DeviceView();

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

                network.Add(eds);
                eds.onDataDirty += Eds_onDataDirty;

                device.dispatch_updateOD();

                addtoMRU(file);
            }

            networkfilename = file;
        }
Ejemplo n.º 4
0
        private void openXDDNetworkfile(string file)
        {
            CanOpenXDD      xdd  = new CanOpenXDD();
            List <EDSsharp> edss = xdd.readMultiXML(file);

            if (edss == null)
            {
                return;
            }

            foreach (EDSsharp eds in edss)
            {
                tabControl1.TabPages.Add(eds.di.ProductName);

                DeviceView device = new DeviceView();

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

                network.Add(eds);
                eds.OnDataDirty += Eds_onDataDirty;

                device.dispatch_updateOD();
            }

            addtoMRU(file);
            networkfilename = file;
        }
Ejemplo n.º 5
0
        private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Warnings.warning_list.Clear();

                if (tabControl1.SelectedTab != null)
                {
                    DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                    SaveFileDialog sfd = new SaveFileDialog();

                    string dir = GetTemporaryDirectory();


                    string csspath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor");
                    csspath = Path.Combine(csspath, "style.css");

                    if (!System.IO.File.Exists(csspath))
                    {
                        csspath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "style.css");
                    }

                    if (System.IO.File.Exists(csspath))
                    {
                        System.IO.File.Copy(csspath, dir + Path.DirectorySeparatorChar + "style.css");
                    }

                    string temp  = dir + Path.DirectorySeparatorChar + "documentation.html";
                    string temp2 = dir + Path.DirectorySeparatorChar + "documentation.md";

                    this.UseWaitCursor = true;

                    DocumentationGen docgen = new DocumentationGen();
                    docgen.genhtmldoc(temp, dv.eds);
                    docgen.genmddoc(temp2, dv.eds);
                    System.Diagnostics.Process.Start("file://" + temp2);
                    if (IsRunningOnMono())
                    {
                        System.Diagnostics.Process.Start("file://" + temp);
                    }
                    else
                    {
                        ReportView rv = new ReportView(temp);
                        rv.Show();
                    }

                    this.UseWaitCursor = false;
                }
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Ejemplo n.º 6
0
        void dosave(DeviceView dv, string FileName)
        {
            switch (Path.GetExtension(FileName))
            {
            case ".eds":
                dv.eds.Savefile(FileName, InfoSection.Filetype.File_EDS);
                dv.eds.edsfilename = FileName;
                break;

            case ".dcf":
                dv.eds.Savefile(FileName, InfoSection.Filetype.File_DCF);
                dv.eds.dcffilename = 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":
                CanOpenXDD coxdd = new CanOpenXDD();
                coxdd.writeXML(FileName, dv.eds);
                dv.eds.xddfilename = FileName;
                dv.eds.Dirty       = false;
                break;
            }

            dv.dispatch_updateOD();
        }
Ejemplo n.º 7
0
        private void saveProjectXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                sfd.Filter = "Canopen Node XML (*.xml)|*.xml";

                sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.xmlfilename);
                sfd.RestoreDirectory = true;
                sfd.FileName         = Path.GetFileNameWithoutExtension(dv.eds.xmlfilename);

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    //dv.eds.savefile(sfd.FileName);

                    Bridge b = new Bridge();
                    Device d = b.convert(dv.eds);

                    CanOpenXML coxml = new CanOpenXML();
                    coxml.dev = d;

                    coxml.writeXML(sfd.FileName);

                    dv.eds.xmlfilename = sfd.FileName;
                    dv.eds.dirty       = false;
                }
            }
        }
Ejemplo n.º 8
0
        private void exportCanOpenNodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0];

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.CheckFileExists = false;

                sfd.FileName         = "CO_OD.c";
                sfd.InitialDirectory = dv.eds.fi.exportFolder;
                sfd.RestoreDirectory = true;

                DialogResult result = sfd.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string savePath = Path.GetDirectoryName(sfd.FileName);
                    dv.eds.fi.exportFolder = savePath;

                    Warnings.warning_list.Clear();

                    CanOpenNodeExporter cone = new CanOpenNodeExporter();
                    cone.export(savePath, dv.eds);

                    if (Warnings.warning_list.Count != 0)
                    {
                        WarningsFrm frm = new WarningsFrm();
                        frm.ShowDialog();
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void saveExportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Attempt to save EDS,XML and export the CanOpen dictionary

            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                //save eds xml and export CO_OD.c and CO_OD.h

                if (dv.eds.edsfilename == null || dv.eds.edsfilename == "")
                {
                    MessageBox.Show("Please manually save as EDS at least once");
                    return;
                }

                if (dv.eds.xmlfilename == null || dv.eds.xmlfilename == "")
                {
                    MessageBox.Show("Please manually save as XML at least once");
                    return;
                }

                if (dv.eds.fi.exportFolder == null || dv.eds.fi.exportFolder == "")
                {
                    MessageBox.Show("Please expot CO_OD.c/h at least once");
                    return;
                }

                //export XML
                Bridge b = new Bridge();
                Device d = b.convert(dv.eds);

                CanOpenXML coxml = new CanOpenXML();
                coxml.dev = d;

                coxml.writeXML(dv.eds.xmlfilename);


                //export EDS
                dv.eds.savefile(dv.eds.edsfilename);

                //export CO_OD.c and CO_OD.h
                CanOpenNodeExporter cone = new CanOpenNodeExporter();
                cone.export(dv.eds.fi.exportFolder, dv.eds);

                if (Warnings.warning_list.Count != 0)
                {
                    WarningsFrm frm = new WarningsFrm();
                    frm.ShowDialog();
                }
            }
        }
Ejemplo n.º 10
0
        private void saveProjectXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0];

                if (dv.eds.xddfilename != null && dv.eds.xddfilename != "")
                {
                    dosave(dv, dv.eds.xddfilename);
                }
                else
                {
                    saveAsToolStripMenuItem_Click(sender, e);
                }
            }
        }
Ejemplo n.º 11
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EDSsharp eds = new EDSsharp();

            eds.di.ProductName = "New Product";

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

            DeviceView device = new DeviceView();

            device.eds       = eds;
            eds.onDataDirty += Eds_onDataDirty;

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

            device.dispatch_updateOD();
        }
Ejemplo n.º 12
0
        private void openXDDfile(string path)
        {
            try
            {
                EDSsharp eds;

                //fixme
                //ISO15745ProfileContainer devs; //one day this will be multiple devices

                CanOpenXDD coxml = new CanOpenXDD();
                eds = coxml.readXML(path);

                if (eds == null)
                {
                    return;
                }

                eds.xddfilename = path;

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

                DeviceView device = new DeviceView();

                eds.OnDataDirty += Eds_onDataDirty;

                device.eds = eds;
                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.ShowDialog();
            }
        }
Ejemplo n.º 13
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                sfd.Filter = "CANopen XDD (*.xdd)|*.xdd";

                sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.xmlfilename);
                sfd.RestoreDirectory = true;
                sfd.FileName         = Path.GetFileNameWithoutExtension(dv.eds.xmlfilename);

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    dosave(dv, sfd.FileName);
                }
            }
        }
Ejemplo n.º 14
0
        private void exportDeviceFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                sfd.Filter = "CANopen Node XML (*.xml)|*.xml|Electronic Data Sheets (*.eds)|*.eds|Device Configuration Files (*.dcf)|*.dcf";

                sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.xmlfilename);
                sfd.RestoreDirectory = true;
                sfd.FileName         = Path.GetFileNameWithoutExtension(dv.eds.xmlfilename);

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    dosave(dv, sfd.FileName);
                }
            }
        }
Ejemplo n.º 15
0
        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.xmlfilename = path;

                dev = coxml.dev;

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

                DeviceView device = new DeviceView();

                eds.onDataDirty += Eds_onDataDirty;

                device.eds = eds;
                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.ShowDialog();
            }
        }
Ejemplo n.º 16
0
        private void closeFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                // tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);

                DeviceView device = (DeviceView)tabControl1.SelectedTab.Controls[0];

                if (device.eds.dirty == true)
                {
                    if (MessageBox.Show("All usaved changes will be lost\n continue?", "Unsaved changes", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }
                }

                network.Remove(device.eds);

                tabControl1.TabPages.Remove(tabControl1.SelectedTab);
            }
        }
Ejemplo n.º 17
0
 private void Eds_onDataDirty(bool dirty, EDSsharp sender)
 {
     foreach (TabPage page in tabControl1.TabPages)
     {
         foreach (Control c in page.Controls)
         {
             if (c.GetType() == typeof(DeviceView))
             {
                 DeviceView d = (DeviceView)c;
                 if (d.eds.dirty == true)
                 {
                     page.BackColor = Color.Red;
                 }
                 else
                 {
                     page.BackColor = default(Color);
                 }
             }
         }
     }
 }
Ejemplo n.º 18
0
 private void ODEditor_MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     foreach (TabPage page in tabControl1.TabPages)
     {
         foreach (Control c in page.Controls)
         {
             if (c.GetType() == typeof(DeviceView))
             {
                 DeviceView d = (DeviceView)c;
                 if (d.eds.dirty == true)
                 {
                     if (MessageBox.Show("Warning you have unsaved changes\n Do you wish to continue", "Unsaved changes", MessageBoxButtons.YesNo) == DialogResult.No)
                     {
                         e.Cancel = true;
                         return;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
        void ProfileAddClick(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0];

                ToolStripMenuItem item = (ToolStripMenuItem)sender;

                string filename = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles" + Path.DirectorySeparatorChar + item.Name;

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

                Bridge b = new Bridge();

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

                eds = b.convert(coxml.dev);

                dev = coxml.dev;

                foreach (KeyValuePair <UInt16, ODentry> kvp in eds.ods)
                {
                    if (!dv.eds.ods.ContainsKey(kvp.Key))
                    {
                        dv.eds.ods.Add(kvp.Key, kvp.Value);
                    }
                }


                dv.dispatch_updateOD();
                dv.dispatch_updatePDOinfo();

                dv.eds.updatePDOcount();
                dv.dispatch_updatedevice();
            }
        }
Ejemplo n.º 20
0
        private void openEDSfile(string path)
        {
            Warnings.warning_list.Clear();

            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.onDataDirty += Eds_onDataDirty;

                device.eds = eds;
                tabControl1.TabPages.Add(eds.di.ProductName);
                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.ShowDialog();
            }
        }
Ejemplo n.º 21
0
        private void saveExportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string temp;

            //Attempt to save EDS,XML and export the CanOpen dictionary

            if (tabControl1.SelectedTab != null)
            {
                DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                SaveFileDialog sfd = new SaveFileDialog();

                //save eds xml and export CO_OD.c and CO_OD.h

                if (dv.eds.edsfilename == null || dv.eds.edsfilename == "")
                {
                    MessageBox.Show("Please manually save as EDS at least once");
                    return;
                }
                temp = Path.GetDirectoryName(dv.eds.edsfilename);
                if (Directory.Exists(temp) != true)
                {
                    MessageBox.Show("File path was removed. Please manually save as EDS once");
                    return;
                }

                if (dv.eds.xmlfilename == null || dv.eds.xmlfilename == "")
                {
                    MessageBox.Show("Please manually save as XML at least once");
                    return;
                }
                temp = Path.GetDirectoryName(dv.eds.xmlfilename);
                if (Directory.Exists(temp) != true)
                {
                    MessageBox.Show("File path was removed. Please manually save as XML once");
                    return;
                }

                if (dv.eds.fi.exportFolder == null || dv.eds.fi.exportFolder == "")
                {
                    MessageBox.Show("Please export CO_OD.c/h at least once");
                    return;
                }
                if (Directory.Exists(dv.eds.fi.exportFolder) != true)
                {
                    MessageBox.Show("File path was removed. Please export CO_OD.c/h once");
                    return;
                }

                //export XML
                Bridge b = new Bridge();
                Device d = b.convert(dv.eds);

                CanOpenXML coxml = new CanOpenXML();
                coxml.dev = d;

                coxml.writeXML(dv.eds.xmlfilename);


                //export EDS
                dv.eds.savefile(dv.eds.edsfilename);

                //export CO_OD.c and CO_OD.h
                CanOpenNodeExporter cone = new CanOpenNodeExporter();

                try
                {
                    cone.export(dv.eds.fi.exportFolder, dv.eds);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Export failed, error message:\n" + ex.ToString());
                    return;
                }

                dv.eds.dirty = false;

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