Example #1
0
        private void addSubItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selecteditemsub.Tag != null)
            {
                ODentry od = (ODentry)selecteditemsub.Tag;

                if (od.parent != null)
                {
                    od = od.parent;
                }

                if (od.objecttype == ObjectType.ARRAY)
                {
                    ODentry newsub = new ODentry();
                    newsub.parent     = od;
                    newsub.datatype   = od.datatype;
                    newsub.accesstype = od.accesstype;
                    newsub.PDOtype    = od.PDOtype;
                    newsub.index      = od.index;
                    newsub.objecttype = ObjectType.VAR;
                    newsub.subindex   = (UInt16)od.subobjects.Count;
                    od.subobjects.Add((UInt16)(od.subobjects.Count), newsub);

                    UInt16 def = EDSsharp.ConvertToUInt16(od.subobjects[0].defaultvalue);

                    def++;
                    od.subobjects[0].defaultvalue = def.ToString();
                }

                if (od.objecttype == ObjectType.REC)
                {
                    DataType dt = od.datatype;

                    NewIndex ni = new NewIndex(eds, dt, od.objecttype, od);

                    if (ni.ShowDialog() == DialogResult.OK)
                    {
                        ODentry newsub = new ODentry();
                        newsub.parent         = od;
                        newsub.datatype       = ni.dt;
                        newsub.accesstype     = od.accesstype;
                        newsub.PDOtype        = od.PDOtype;
                        newsub.index          = od.index;
                        newsub.objecttype     = ObjectType.VAR;
                        newsub.subindex       = (UInt16)od.subobjects.Count;
                        newsub.parameter_name = ni.name;

                        od.subobjects.Add((UInt16)(od.subobjects.Count), newsub);

                        UInt16 def = EDSsharp.ConvertToUInt16(od.subobjects[0].defaultvalue);
                        def++;
                        od.subobjects[0].defaultvalue = def.ToString();
                    }
                }

                eds.dirty = true;
                updateselectedindexdisplay(selectedobject.index);
                validateanddisplaydata();
            }
        }
Example #2
0
        private void addNewObjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewIndex ni = new NewIndex(eds);

            if (ni.ShowDialog() == DialogResult.OK)
            {
                eds.dirty = true;

                ODentry od = new ODentry();

                od.objecttype      = ni.ot;
                od.index           = ni.index;
                od.StorageLocation = "RAM";
                od.defaultvalue    = "";
                od.accesstype      = EDSsharp.AccessType.rw;
                od.datatype        = ni.dt;
                od.parameter_name  = ni.name;

                if (od.objecttype == ObjectType.REC || od.objecttype == ObjectType.ARRAY)
                {
                    {
                        ODentry sod = new ODentry();

                        sod.objecttype      = ObjectType.VAR;
                        sod.subindex        = 0;
                        sod.index           = ni.index;
                        sod.StorageLocation = "RAM";
                        sod.defaultvalue    = String.Format("{0}", ni.nosubindexes);
                        sod.accesstype      = EDSsharp.AccessType.ro;
                        sod.datatype        = DataType.UNSIGNED8;
                        sod.parent          = od;

                        sod.parameter_name = "max sub-index";


                        od.subobjects.Add(0, sod);
                    }

                    for (int p = 0; p < ni.nosubindexes; p++)
                    {
                        ODentry sod = new ODentry();

                        sod.objecttype      = ObjectType.VAR;
                        sod.subindex        = (UInt16)(p + 1);
                        sod.index           = ni.index;
                        sod.StorageLocation = "RAM";
                        sod.defaultvalue    = "";
                        sod.accesstype      = EDSsharp.AccessType.rw;
                        sod.datatype        = ni.dt;
                        sod.parent          = od;

                        od.subobjects.Add((ushort)(p + 1), sod);
                    }
                }

                eds.ods.Add(od.index, od);

                //Now switch to it as well Bug #26

                updateselectedindexdisplay(od.index);
                selectedobject = eds.ods[od.index];
                validateanddisplaydata();


                populateindexlists();
            }
        }