Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pvxslibs instead of qsrv #132

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 182 additions & 138 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_dso>=2.1", "epicscorelibs>=7.0.7.99.0.0"]
requires = ["setuptools", "wheel", "setuptools_dso>=2.1", "epicscorelibs>=7.0.7.99.0.2"]
build-backend = "setuptools.build_meta:__legacy__"
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ useful =
dev =
pytest-cov
pytest-flake8
# Flake8 5.0 starts printing error, so pin to avoid it:
# AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder'
flake8 <5.0.0
# Higher version of sphinx require importlib-metadata version that conflicts with other packages
sphinx ==4.3.2
sphinx-rtd-theme-github-versions
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
devIocStats_src, devIocStats_os, devIocStats_default
],
dsos = [
'epicscorelibs.lib.qsrv',
'epicscorelibs.lib.pvAccessIOC',
'epicscorelibs.lib.pvAccess',
'epicscorelibs.lib.pvData',
'epicscorelibs.lib.dbRecStd',
'epicscorelibs.lib.dbCore',
'epicscorelibs.lib.ca',
Expand Down Expand Up @@ -95,6 +91,7 @@ def install_for_development(self):
install_requires = [
# Dependency version declared in pyproject.toml
epicscorelibs.version.abi_requires(),
"pvxslibs>=1.2.2",
"numpy",
"epicsdbbuilder>=1.4"
],
Expand Down
12 changes: 9 additions & 3 deletions softioc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'''Python soft IOC module.'''
import os
import ctypes

from epicscorelibs import path
from setuptools_dso.runtime import find_dso
import epicscorelibs.path
import pvxslibs.path
from epicscorelibs.ioc import \
iocshRegisterCommon, registerRecordDeviceDriver, pdbbase

Expand All @@ -17,11 +20,14 @@

# Need to do this before calling anything in device.py
iocshRegisterCommon()
for dbd in ('base.dbd', 'PVAServerRegister.dbd', 'qsrv.dbd'):
dbLoadDatabase(dbd, os.path.join(path.base_path, 'dbd'), None)
base_dbd_path = os.path.join(epicscorelibs.path.base_path, 'dbd')
dbLoadDatabase('base.dbd', base_dbd_path, None)
dbLoadDatabase('pvxsIoc.dbd', pvxslibs.path.dbd_path, None)
iocStats = os.path.join(os.path.dirname(__file__), "iocStats", "devIocStats")
dbLoadDatabase('devIocStats.dbd', iocStats, None)

ctypes.CDLL(find_dso('pvxslibs.lib.pvxsIoc'), ctypes.RTLD_GLOBAL)
os.environ.setdefault('PVXS_QSRV_ENABLE', 'YES')
Comment on lines +29 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pvxslibs needs to be loaded here, rather than linked in like dbCore, etc

if registerRecordDeviceDriver(pdbbase):
raise RuntimeError('Error registering')

Expand Down
11 changes: 7 additions & 4 deletions softioc/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,23 @@ def _long_string(fields):

fields.setdefault('initial_value', '')
fields['_wf_nelm'] = length
fields['_wf_dtype'] = numpy.dtype('uint8')
fields['_wf_dtype'] = numpy.dtype('int8')

fields['NELM'] = length
fields['FTVL'] = 'UCHAR'
fields['FTVL'] = 'CHAR'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but only if FTVL is CHAR


def qform_string(rec):
rec.add_info("Q:form", "String")
return rec
Comment on lines +269 to +271
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes QSRV2 treat a waveform as a string...


def longStringIn(name, **fields):
_long_string(fields)
_set_in_defaults(fields)
return PythonDevice.long_stringin(name, **fields)
return qform_string(PythonDevice.long_stringin(name, **fields))

def longStringOut(name, **fields):
_long_string(fields)
return PythonDevice.long_stringout(name, **fields)
return qform_string(PythonDevice.long_stringout(name, **fields))



Expand Down
20 changes: 15 additions & 5 deletions tests/expected_records.db
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ record(ao, "TS-DI-TEST-01:AO")
field(OUT, "@TS-DI-TEST-01:AO")
}

record(waveform, "TS-DI-TEST-01:AVERYLONGRECORDSUFFIXTOMAKELONGPV")
{
field(DISP, "1")
field(DTYP, "PythonLongStringIn")
field(FTVL, "CHAR")
field(INP, "@TS-DI-TEST-01:AVERYLONGRECORDSUFFIXTOMAKELONGPV")
field(NELM, "51")
field(PINI, "YES")
field(SCAN, "I/O Intr")
info(Q:form, "String")
}

record(bi, "TS-DI-TEST-01:BOOLIN")
{
field(DISP, "1")
Expand Down Expand Up @@ -53,13 +65,11 @@ record(longout, "TS-DI-TEST-01:LONGOUT")

record(waveform, "TS-DI-TEST-01:LONGSTRING")
{
field(DISP, "1")
field(DTYP, "PythonLongStringIn")
field(FTVL, "UCHAR")
field(DTYP, "PythonLongStringOut")
field(FTVL, "CHAR")
field(INP, "@TS-DI-TEST-01:LONGSTRING")
field(NELM, "256")
field(PINI, "YES")
field(SCAN, "I/O Intr")
info(Q:form, "String")
}

record(mbbi, "TS-DI-TEST-01:MBBI")
Expand Down
6 changes: 5 additions & 1 deletion tests/sim_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def update_sin_wf(value):
WaveformOut('WAVEFORM_OUT', wf, on_update = on_update)
Waveform('WAVEFORM2', length = 10)

longStringIn('LONGSTRING', length = 256)
longStringOut('LONGSTRING', length = 256)
longStringIn(
'AVERYLONGRECORDSUFFIXTOMAKELONGPV',
initial_value="A long string that is more than 40 characters long"
)

create_records()

Expand Down
6 changes: 6 additions & 0 deletions tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ async def test_asyncio_ioc(asyncio_ioc):
from p4p.client.asyncio import Context
with Context("pva") as ctx:
assert await ctx.get(pre + ":AI") == 23.45
long_pv = pre + ":AVERYLONGRECORDSUFFIXTOMAKELONGPV"
long_str = "A long string that is more than 40 characters long"
assert await ctx.get(long_pv) == long_str
assert await ctx.get(long_pv + ".NAME") == long_pv
await ctx.put(pre + ":LONGSTRING", long_str)
assert await ctx.get(pre + ":LONGSTRING") == long_str

conn.send("D") # "Done"
select_and_recv(conn, "D") # "Done"
Expand Down