dls-controls / pythonSoftIOC

Embed an EPICS IOC in a Python process
Apache License 2.0
32 stars 7 forks source link

PINI flag is not set on In records when .set() is used #67

Closed AlexanderWells-diamond closed 2 years ago

AlexanderWells-diamond commented 2 years ago

In builder.py's _in_record function we see this code:

if 'initial_value' in fields:
        fields.setdefault('PINI', 'YES')

There is no equivalent code for when .set() is called. This means that In records do not process on startup correctly such that caget sees the value. For example run the following IOC in a terminal:

# Import the basic framework components.
from softioc import softioc, builder, asyncio_dispatcher
import numpy
# Create an asyncio dispatcher, the event loop is now running
dispatcher = asyncio_dispatcher.AsyncioDispatcher()

# Set the record prefix
builder.SetDeviceName("PREFIX")

# Create some records
li = builder.longIn("TEST")

li.set(10)

# Boilerplate get the IOC started
builder.LoadDatabase()
softioc.iocInit(dispatcher)

# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())

And from another do caget:

[...]$ caget PREFIX:TEST
PREFIX:TEST                    0

And we see that the .set() has not taken effect.