DiamondLightSource / pythonSoftIOC

Embed an EPICS IOC in a Python process
Apache License 2.0
31 stars 9 forks source link

Feature request: `python -m pvxslibs.ioc` #137

Closed coretl closed 1 year ago

coretl commented 1 year ago

I have monkeypatched this like so:

import ctypes
import os

import pvxslibs.path
from epicscorelibs import ioc
from setuptools_dso.runtime import find_dso

pvxsIoc = ctypes.CDLL(find_dso("pvxslibs.lib.pvxsIoc"), ctypes.RTLD_GLOBAL)
os.environ.setdefault("PVXS_QSRV_ENABLE", "YES")

orig_dbld = ioc.dbLoadDatabase

def dbLoadDatabase(dbd, dbdpath, substitutions):
    if dbd == b"qsrv.dbd":
        orig_dbld(b"pvxsIoc.dbd", pvxslibs.path.dbd_path.encode(), None)
    elif dbd == b"PVAServerRegister.dbd":
        pass
    else:
        orig_dbld(dbd, dbdpath, substitutions)

ioc.dbLoadDatabase = dbLoadDatabase

if __name__ == "__main__":
    ioc.main()

But obviously this is a hack.

Maybe the best way to support this is to pass in a list of tuples of (dbd, dbdpath) to epicscorelibs.ioc.main, defaulting to the existing qsrv.dbd and PVAServerRegister.dbd, and then call it with a different set in pvxslibs.ioc?

Shall I make a PR for this? Or is there a better way?

coretl commented 1 year ago

Oops, wrong repo