Skip to content

Commit

Permalink
Merge pull request #132 from dls-controls/pvxslibs
Browse files Browse the repository at this point in the history
Use pvxslibs instead of qsrv
  • Loading branch information
coretl authored Jul 5, 2023
2 parents c826477 + 6a99229 commit dc24736
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 156 deletions.
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 @@ -74,10 +74,6 @@
sources = sources,
include_dirs = include_dirs,
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 @@ -108,6 +104,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')
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'

def qform_string(rec):
rec.add_info("Q:form", "String")
return rec

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

0 comments on commit dc24736

Please sign in to comment.