Skip to content

Commit dc24736

Browse files
authored
Merge pull request #132 from dls-controls/pvxslibs
Use pvxslibs instead of qsrv
2 parents c826477 + 6a99229 commit dc24736

File tree

9 files changed

+229
-156
lines changed

9 files changed

+229
-156
lines changed

Pipfile.lock

Lines changed: 182 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools_dso>=2.1", "epicscorelibs>=7.0.7.99.0.0"]
2+
requires = ["setuptools", "wheel", "setuptools_dso>=2.1", "epicscorelibs>=7.0.7.99.0.2"]
33
build-backend = "setuptools.build_meta:__legacy__"

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ useful =
4848
dev =
4949
pytest-cov
5050
pytest-flake8
51+
# Flake8 5.0 starts printing error, so pin to avoid it:
52+
# AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder'
53+
flake8 <5.0.0
5154
# Higher version of sphinx require importlib-metadata version that conflicts with other packages
5255
sphinx ==4.3.2
5356
sphinx-rtd-theme-github-versions

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
sources = sources,
7575
include_dirs = include_dirs,
7676
dsos = [
77-
'epicscorelibs.lib.qsrv',
78-
'epicscorelibs.lib.pvAccessIOC',
79-
'epicscorelibs.lib.pvAccess',
80-
'epicscorelibs.lib.pvData',
8177
'epicscorelibs.lib.dbRecStd',
8278
'epicscorelibs.lib.dbCore',
8379
'epicscorelibs.lib.ca',
@@ -108,6 +104,7 @@ def install_for_development(self):
108104
install_requires = [
109105
# Dependency version declared in pyproject.toml
110106
epicscorelibs.version.abi_requires(),
107+
"pvxslibs>=1.2.2",
111108
"numpy",
112109
"epicsdbbuilder>=1.4"
113110
],

softioc/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'''Python soft IOC module.'''
22
import os
3+
import ctypes
34

4-
from epicscorelibs import path
5+
from setuptools_dso.runtime import find_dso
6+
import epicscorelibs.path
7+
import pvxslibs.path
58
from epicscorelibs.ioc import \
69
iocshRegisterCommon, registerRecordDeviceDriver, pdbbase
710

@@ -17,11 +20,14 @@
1720

1821
# Need to do this before calling anything in device.py
1922
iocshRegisterCommon()
20-
for dbd in ('base.dbd', 'PVAServerRegister.dbd', 'qsrv.dbd'):
21-
dbLoadDatabase(dbd, os.path.join(path.base_path, 'dbd'), None)
23+
base_dbd_path = os.path.join(epicscorelibs.path.base_path, 'dbd')
24+
dbLoadDatabase('base.dbd', base_dbd_path, None)
25+
dbLoadDatabase('pvxsIoc.dbd', pvxslibs.path.dbd_path, None)
2226
iocStats = os.path.join(os.path.dirname(__file__), "iocStats", "devIocStats")
2327
dbLoadDatabase('devIocStats.dbd', iocStats, None)
2428

29+
ctypes.CDLL(find_dso('pvxslibs.lib.pvxsIoc'), ctypes.RTLD_GLOBAL)
30+
os.environ.setdefault('PVXS_QSRV_ENABLE', 'YES')
2531
if registerRecordDeviceDriver(pdbbase):
2632
raise RuntimeError('Error registering')
2733

softioc/builder.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,23 @@ def _long_string(fields):
261261

262262
fields.setdefault('initial_value', '')
263263
fields['_wf_nelm'] = length
264-
fields['_wf_dtype'] = numpy.dtype('uint8')
264+
fields['_wf_dtype'] = numpy.dtype('int8')
265265

266266
fields['NELM'] = length
267-
fields['FTVL'] = 'UCHAR'
267+
fields['FTVL'] = 'CHAR'
268268

269+
def qform_string(rec):
270+
rec.add_info("Q:form", "String")
271+
return rec
269272

270273
def longStringIn(name, **fields):
271274
_long_string(fields)
272275
_set_in_defaults(fields)
273-
return PythonDevice.long_stringin(name, **fields)
276+
return qform_string(PythonDevice.long_stringin(name, **fields))
274277

275278
def longStringOut(name, **fields):
276279
_long_string(fields)
277-
return PythonDevice.long_stringout(name, **fields)
280+
return qform_string(PythonDevice.long_stringout(name, **fields))
278281

279282

280283

tests/expected_records.db

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ record(ao, "TS-DI-TEST-01:AO")
1414
field(OUT, "@TS-DI-TEST-01:AO")
1515
}
1616

17+
record(waveform, "TS-DI-TEST-01:AVERYLONGRECORDSUFFIXTOMAKELONGPV")
18+
{
19+
field(DISP, "1")
20+
field(DTYP, "PythonLongStringIn")
21+
field(FTVL, "CHAR")
22+
field(INP, "@TS-DI-TEST-01:AVERYLONGRECORDSUFFIXTOMAKELONGPV")
23+
field(NELM, "51")
24+
field(PINI, "YES")
25+
field(SCAN, "I/O Intr")
26+
info(Q:form, "String")
27+
}
28+
1729
record(bi, "TS-DI-TEST-01:BOOLIN")
1830
{
1931
field(DISP, "1")
@@ -53,13 +65,11 @@ record(longout, "TS-DI-TEST-01:LONGOUT")
5365

5466
record(waveform, "TS-DI-TEST-01:LONGSTRING")
5567
{
56-
field(DISP, "1")
57-
field(DTYP, "PythonLongStringIn")
58-
field(FTVL, "UCHAR")
68+
field(DTYP, "PythonLongStringOut")
69+
field(FTVL, "CHAR")
5970
field(INP, "@TS-DI-TEST-01:LONGSTRING")
6071
field(NELM, "256")
61-
field(PINI, "YES")
62-
field(SCAN, "I/O Intr")
72+
info(Q:form, "String")
6373
}
6474

6575
record(mbbi, "TS-DI-TEST-01:MBBI")

tests/sim_records.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def update_sin_wf(value):
6363
WaveformOut('WAVEFORM_OUT', wf, on_update = on_update)
6464
Waveform('WAVEFORM2', length = 10)
6565

66-
longStringIn('LONGSTRING', length = 256)
66+
longStringOut('LONGSTRING', length = 256)
67+
longStringIn(
68+
'AVERYLONGRECORDSUFFIXTOMAKELONGPV',
69+
initial_value="A long string that is more than 40 characters long"
70+
)
6771

6872
create_records()
6973

tests/test_asyncio.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ async def test_asyncio_ioc(asyncio_ioc):
5252
from p4p.client.asyncio import Context
5353
with Context("pva") as ctx:
5454
assert await ctx.get(pre + ":AI") == 23.45
55+
long_pv = pre + ":AVERYLONGRECORDSUFFIXTOMAKELONGPV"
56+
long_str = "A long string that is more than 40 characters long"
57+
assert await ctx.get(long_pv) == long_str
58+
assert await ctx.get(long_pv + ".NAME") == long_pv
59+
await ctx.put(pre + ":LONGSTRING", long_str)
60+
assert await ctx.get(pre + ":LONGSTRING") == long_str
5561

5662
conn.send("D") # "Done"
5763
select_and_recv(conn, "D") # "Done"

0 commit comments

Comments
 (0)