-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 96: add pilc component template (#661)
* add pilc component template * improve pilc template * pilctimeid * update tests * remove arm from templates * fixes for pilc links * update Changelog
- Loading branch information
Showing
16 changed files
with
389 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#!/usr/bin/env python | ||
# This file is part of nexdatas - Tango Server for NeXus data writer | ||
# | ||
# Copyright (C) 2012-2018 DESY, Jan Kotanski <jkotan@mail.desy.de> | ||
# | ||
# nexdatas is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# nexdatas is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with nexdatas. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
""" pyeval helper functions for pilc """ | ||
|
||
# import json | ||
try: | ||
import tango | ||
except Exception: | ||
import PyTango as tango | ||
|
||
|
||
def triggermode_cb(commonblock, name, triggermode, | ||
nbtriggers, triggersperfile, | ||
hostname, device, | ||
filename, entryname, | ||
insname, pilcfileprefix, pilcfiledir, | ||
timeid=False): | ||
""" code for triggermode_cb datasource | ||
:param commonblock: commonblock of nxswriter | ||
:type commonblock: :obj:`dict`<:obj:`str`, `any`> | ||
:param name: component name | ||
:type name: :obj:`str` | ||
:param triggermode: trigger mode | ||
:type triggermode: :obj:`int` or :obj:`str` | ||
:param nbtriggers: a number of triggers | ||
:type nbtriggers: :obj:`int` | ||
:param triggersperfile: a number of triggers per file | ||
:type triggersperfile: :obj:`int` | ||
:param hostname: tango host name | ||
:type hostname: :obj:`str` | ||
:param device: tango device name | ||
:type device: :obj:`str` | ||
:param filename: master file name | ||
:type filename: :obj:`str` | ||
:param entryname: entry name | ||
:type entryname: :obj:`str` | ||
:param insname: instrument name | ||
:type insname: :obj:`str` | ||
:param pilcfileprefix: pilc file name prefix | ||
:type pilcfileprefix :obj:`str` | ||
:param pilcfiledir: pilc file name directory | ||
:type pilcfiledir :obj:`str` | ||
:param timeid: file id with timestamp | ||
:type timeid: :obj:`bool` | ||
:returns: triggermode | ||
:rtype: :obj:`str` or :obj:`int` | ||
""" | ||
|
||
dp = tango.DeviceProxy('%s/%s' % (hostname, device)) | ||
fpattern = pilcfileprefix.split("/")[-1] | ||
if triggersperfile >= 1: | ||
nbfiles = (nbtriggers + triggersperfile - 1) // triggersperfile | ||
else: | ||
nbfiles = 1 | ||
fields = ["counter", "time", "trigger", | ||
"encoder_1", "encoder_2", | ||
"encoder_3", "encoder_4", "encoder_5"] | ||
nbstart = 0 | ||
filepostfix = ".nxs" | ||
try: | ||
pilcfilename = str(dp.FileName) | ||
if pilcfilename.startswith(fpattern + "_") and \ | ||
pilcfilename.endswith(filepostfix): | ||
nblast = int(pilcfilename[ | ||
len(fpattern) + 1: - len(filepostfix)]) | ||
nbstart = max(0, nblast - nbfiles + 1) | ||
except Exception: | ||
pilcfilename = None | ||
nblist = [nb for nb in range(nbstart, nbstart + nbfiles)] | ||
|
||
if filename: | ||
path = (filename).split("/")[-1].split(".")[0] + "/" | ||
else: | ||
path = "" | ||
path += '%s/%s_' % (name, fpattern) | ||
result = triggermode | ||
|
||
spf = 0 | ||
cfid = 0 | ||
if "__root__" in commonblock.keys(): | ||
root = commonblock["__root__"] | ||
if hasattr(root, "currentfileid") and hasattr(root, "stepsperfile"): | ||
spf = root.stepsperfile | ||
cfid = root.currentfileid | ||
if root.h5object.__class__.__name__ == "File": | ||
import nxstools.h5pywriter as nxw | ||
else: | ||
import nxstools.h5cppwriter as nxw | ||
else: | ||
raise Exception("Writer cannot be found") | ||
|
||
en = root.open(entryname) | ||
dt = en.open("data") | ||
ins = en.open(insname) | ||
pilc = ins.open(name) | ||
pilcdata = pilc.open("data") | ||
col = pilc.open("collection") | ||
|
||
if timeid and pilcfilename and "filenames" in col.names(): | ||
try: | ||
filenames = list(col.open("filenames").read()) | ||
if filenames: | ||
filenames.append(str(pilcfilename)) | ||
nlist = [] | ||
for fname in filenames: | ||
fname = str(fname) | ||
if fname.startswith(fpattern + "_") and \ | ||
fname.endswith(filepostfix): | ||
nlist.append(int(fname[ | ||
len(fpattern) + 1: - len(filepostfix)])) | ||
nblist = nlist | ||
except Exception: | ||
pass | ||
for nbf in nblist: | ||
# nnbf = "%05i" % (nbf) | ||
for field in fields: | ||
fnbf = "%s_%05i" % (field, nbf) | ||
if spf > 0 and cfid > 0: | ||
if cfid == nbf: | ||
nxw.link( | ||
"%s_%05i%s://entry/data/%s" | ||
% (path, nbf, filepostfix, field), | ||
pilcdata, field) | ||
nxw.link("/%s/%s/%s/data/%s" | ||
% (entryname, insname, name, field), | ||
dt, "%s_%s" % (name, field)) | ||
nxw.link("%s_%05i%s://entry/data/%s" | ||
% (path, nbf, filepostfix, field), | ||
pilcdata, "%s" % (fnbf)) | ||
else: | ||
nxw.link("%s_%05i%s://entry/data/%s" | ||
% (path, nbf, filepostfix, field), | ||
pilcdata, "%s" % (fnbf)) | ||
nxw.link("/%s/%s/%s/data/%s" % | ||
(entryname, insname, name, fnbf), dt, | ||
"%s_%s" % (name, fnbf)) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ | |
""" NXS tools release version""" | ||
|
||
#: (:obj:`str`) package version | ||
__version__ = "4.5.1" | ||
__version__ = "4.6.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version='1.0'?> | ||
<definition> | ||
<group type="NXentry" name="$var.entryname#'$(__entryname__)'$var.serialno"> | ||
<group type="NXinstrument" name="$(__insname__)"> | ||
<group type="NXcollection" name="$(name)"> | ||
<group type="NXcollection" name="collection"> | ||
<field type="NX_FLOAT64" name="position_trigger_start"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_positiontriggerstart</field> | ||
<field type="NX_FLOAT64" name="position_trigger_step_size"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_positiontriggerstepsize</field> | ||
<field units="s" type="NX_FLOAT64" name="position_trigger_stop"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_positiontriggerstop</field> | ||
<field type="NX_INT32" name="nb_triggers"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_nbtriggers</field> | ||
<field units="s" type="NX_FLOAT64" name="trigger_pulse_length"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_triggerpulselength</field> | ||
<field type="NX_INT32" name="trigger_mode"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_triggermode_cb</field> | ||
<field units="s" type="NX_FLOAT64" name="time_trigger_start"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_timetriggerstart</field> | ||
<field units="s" type="NX_FLOAT64" name="time_trigger_step_size"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_timetriggerstepsize</field> | ||
<field type="NX_CHAR" name="file_prefix"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_fileprefix</field> | ||
<field type="NX_CHAR" name="file_dir"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_filedir</field> | ||
<field type="NX_CHAR" name="last_file_name"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_filename</field> | ||
<field type="NX_INT32" name="trigger_counter"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_triggercounter</field> | ||
<field type="NX_INT32" name="encoder_trigger"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_encodertrigger</field> | ||
<field type="NX_INT32" name="encoder_triggering"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_encodertriggering</field> | ||
<field type="NX_INT32" name="remaining_triggers"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_remainingtriggers</field> | ||
<field type="NX_INT32" name="buffer_load"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_bufferload</field> | ||
<field type="NX_INT32" name="software_inhibit"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_softwareinhibit</field> | ||
<field type="NX_FLOAT64" name="hardware_inhibit"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_hardwareinhibit</field> | ||
<field type="NX_FLOAT64" name="mask_data_to_write"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_maskdatatowrite</field> | ||
<field type="NX_INT32" name="triggers_per_file"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_triggersperfile</field> | ||
<field type="NX_INT32" name="counter_config"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_counterconfig</field> | ||
<field units="steps/unit" type="NX_FLOAT64" name="position1_conversion"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_position1conversion</field> | ||
<field units="steps/unit" type="NX_FLOAT64" name="position2_conversion"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_position2conversion</field> | ||
<field units="steps/unit" type="NX_FLOAT64" name="position3_conversion"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_position3conversion</field> | ||
<field units="steps/unit" type="NX_FLOAT64" name="position4_conversion"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_position4conversion</field> | ||
<field units="steps/unit" type="NX_FLOAT64" name="position5_conversion"> | ||
<strategy mode="FINAL"/>$datasources.$(name)_position5conversion</field> | ||
</group> | ||
<group type="NXdata" name="data"> | ||
</group> | ||
</group> | ||
</group> | ||
</group> | ||
</definition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version='1.0'?> | ||
<definition> | ||
<datasource type="PYEVAL" name="$(name)_triggermode_cb"> | ||
<result name="result"> | ||
from nxstools.pyeval import pilc | ||
ds.result = pilc.triggermode_cb(commonblock, "$(name)", ds.$(name)_triggermode, ds.$(name)_nbtriggers, ds.$(name)_triggersperfile, "$(hostname)", "$(device)", "$var.filename", "$var.entryname#'$(__entryname__)'$var.serialno", "$(__insname__)", ds.$(name)_fileprefix, ds.$(name)_filedir) | ||
</result> | ||
$datasources.$(name)_triggermode | ||
$datasources.$(name)_nbtriggers | ||
$datasources.$(name)_triggersperfile | ||
$datasources.$(name)_fileprefix | ||
$datasources.$(name)_filedir | ||
</datasource> | ||
</definition> |
Oops, something went wrong.