Esempio n. 1
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;
                    dv.dispatch_updateOD();
                }
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
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();
                }
            }
        }
Esempio n. 4
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();
                    }

                    dv.dispatch_updateOD();
                }
            }
        }
Esempio n. 5
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;
        }
Esempio 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();
        }
Esempio n. 7
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();
        }
Esempio n. 8
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();
            }
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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();
            }
        }
Esempio n. 11
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();
            }
        }