pcdshub / lcls-twincat-optics

TwinCAT 3 Motion Control for LCLS Optics
https://pcdshub.github.io/lcls-twincat-optics/
Other
0 stars 6 forks source link

State Mover Function Blocks #16

Open nrwslac opened 1 year ago

nrwslac commented 1 year ago

Optics State Mover FBs should be moved to and called from the optics library.

nrwslac commented 1 year ago

_Originally posted by @nrwslac in https://github.com/pcdshub/lcls-plc-tmo-optics/pull/32#discussion_r1116320401_

nrwslac commented 1 year ago

I guess it isn't possible to re-use state mover function blocks for similar devices with different state enumeration types. By design the state move function blocks declare an enum type. @ZLLentz @klauer any thoughts about this?

ZLLentz commented 1 year ago

iirc the declaration of the enum type (instead of say, just making it an integer) was to make pytmc pick up the enum strings for use in the IOC. If there's some other/better way of accomplishing that I'm all ears, I'm not satisfied with what we currently need to do to prop up a new state mover that just differs by an enum.

klauer commented 1 year ago

Right - the enum lets pytmc:

In terms of auto-generation by introspecting standard code structures, I think the enum is the best we can do. It does fail us in that sometimes we want better string identifiers for each of the values, though.

I'm not sure what would be better - and it if would be worth complicating pytmc to account for it. I'd be open to new proposals, of course.

ZLLentz commented 1 year ago

There may be ways to reorganize the motion library code so that you only need to provide and pragma an enum and you don't need to do anything special in the function block. But yeah I don't think there's a way to get around the enum that isn't messier when we bubble up to the IOC.