jisotalo / ads-client

Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
https://jisotalo.fi/ads-client/
MIT License
80 stars 17 forks source link

Adding support for ExtendedEnumInfos #163

Closed jisotalo closed 1 day ago

jisotalo commented 2 days ago

When running tests against TwinCAT 3.1.4026, a warning is shown:

WARNING: Data type Tc2_System.E_OpenPath (UINT) has flag "ExtendedEnumInfos" which is not supported. Things might not work now. Please open an issue at Github

Adding support for it.

jisotalo commented 1 day ago

Done! The following works with TC 3.1.4026 and ads-client 2.0.0-beta.5

TYPE E_ExtendedEnum :
(
    Disabled    := 0, //Machine is disabled
    Starting    := 50, //Machine is starting
    Running     := 100, //Machine is running
    Stopping    := 200, //Machine is stopping

    {attribute 'ads-client-enum-attribute' := 'example-enum-value-ääö'}
    Unknown     := -99 //Machine is ääöööÄÄÖö
);
END_TYPE
const res = await client.getDataType('E_ExtendedEnum');
console.log(inspect(res.enumInfos));
/*
[
  {
    name: 'Disabled',
    value: 0,
    comment: 'Machine is disabled',
    attributes: [
      {
        name: 'ads-client-enum-attribute',
        value: 'example-enum-value-ääö'
      }
    ]
  },
  {
    name: 'Starting',
    value: 50,
    comment: 'Machine is starting',
    attributes: []
  },
  {
    name: 'Running',
    value: 100,
    comment: 'Machine is running',
    attributes: []
  },
  {
    name: 'Stopping',
    value: 200,
    comment: 'Machine is stopping',
    attributes: []
  },
  {
    name: 'Unknown',
    value: -99,
    comment: 'Machine is ääöööÄÄÖö',
    attributes: []
  }
]
*/