Skip to content

[GUI] Object type of an existing object cannot be changed (e.g. ARRAY to RECORD) #243

Open

Description

@NobseVomBerg

What I see

In EDSEditorGUI the "Object Type" box on the object page is disabled (comboBox_objectType.Enabled = false in DeviceODView.Designer.cs, never enabled at run time). The type of an existing object can therefore not be changed. The only place in the GUI that sets an object type is the "New index" dialog.

This matters for CANopenNode V4: an ARRAY has one attribute for all elements, so an object whose elements need different access has to be a RECORD (see #242, which tells the user to make the access equal or to change the object type to RECORD). Today that means deleting the object and creating it again, or editing the project file by hand.

Related finding in the library

ODentry.ObjectTypeString(string objectType) in libEDSsharp/eds.cs ignores its argument:

public void ObjectTypeString(string objectType)
{
    this.objecttype = Enum.IsDefined(typeof(ObjectType), objecttype) ? objecttype : ObjectType.VAR;
}

It tests and assigns the field objecttype, not the parameter objectType. This is so since af4d323 (2022-10-25); before that commit the method switched on the string. It has no visible effect at the moment, because the only caller with an argument (DeviceODView, on save) passes the value of the disabled box, but enabling the box alone would not be enough.

Checked on main (38e2016) and on v4.2.3: after ObjectTypeString("ARRAY") on a RECORD the object is still a RECORD.

Question

Is the box disabled on purpose? Two ways to help CANopenNode users with such objects come to mind:

  1. Let the user change an existing object between ARRAY and RECORD in the GUI: enable the box for objects with sub-objects (or add a "Convert to RECORD" command) and make ObjectTypeString(string) use its argument. The project file, the EDS and the generated OD.c then agree.
  2. An opt-in setting, stored in the project file so that GUI and CLI export the same, that lets the CANopenNode V4 exporter write an ARRAY with different element attributes as OD_obj_record_t. The EDS keeps the ARRAY, but the generated storage changes from a C array to a struct, so application code is affected.

I would prefer the first. Would a PR for it be welcome?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions