Skip to content

Commit

Permalink
refs #19
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Sep 7, 2016
1 parent 7dc857d commit 1d567c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/pvWebMonitor/pvlist.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ XML Schema to validate the pvlist.xml file
# See LICENSE file for details.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xs:element name="pvwatch">
<xs:complexType>
<xs:sequence>
Expand All @@ -22,14 +22,15 @@ XML Schema to validate the pvlist.xml file
<!-- used to tell humans what the terms mean in a pvlist.xml file -->
<xs:attribute name="name" use="required" type="xs:NCName" />
</xs:complexType>

<xs:complexType name="pv_type">
<!-- defines the declaration of one PV to be monitored -->
<xs:attribute name="PV" type="xs:NMTOKEN" use="required" />
<xs:attribute name="description" type="xs:string" use="required" />
<xs:attribute name="display_format" type="xs:string" use="optional" default="%s" />
<xs:attribute name="mne" type="xs:NCName" use="required" />
<xs:attribute name="_ignore_" type="xs:boolean" use="optional" default="false" />
<xs:attribute name="as_string" type="xs:boolean" use="optional" default="false" />
</xs:complexType>

<xs:attributeGroup name="version_type">
Expand All @@ -43,5 +44,5 @@ XML Schema to validate the pvlist.xml file
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>

</xs:schema>
27 changes: 15 additions & 12 deletions src/pvWebMonitor/pvwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,33 @@ def get_pvlist(self):
pv = key.get("PV")
desc = key.get("description")
fmt = key.get("display_format", "%s") # default format
as_string = key.get("as_string", False) # default format
# :see: http://cars9.uchicago.edu/software/python/pyepics3/pv.html?highlight=as_string#pv.get
try:
self.add_pv(mne, pv, desc, fmt)
self.add_pv(mne, pv, desc, fmt, as_string)
except:
msg = "%s: problem connecting: %s" % (pvlist_file, etree.tostring(key))
utils.logException(msg)

def add_pv(self, mne, pv, desc, fmt):
def add_pv(self, mne, pv, desc, fmt, as_string):
'''Connect to a EPICS (PyEpics) process variable'''
if pv in self.pvdb:
msg = "key '%s' already defined by id=%s" % (pv, self.pvdb[pv]['id'])
raise KeyError(msg)

ch = epics.PV(pv)
entry = {
'name': pv, # EPICS PV name
'id': mne, # symbolic name used in the python code
'description': desc, # text description for humans
'timestamp': None, # client time last monitor was received
'counter': 0, # number of monitor events received
'units': "", # engineering units
'ch': ch, # EPICS PV channel
'format': fmt, # format for display
'value': None, # formatted value
'raw_value': None # unformatted value
'name': pv, # EPICS PV name
'id': mne, # symbolic name used in the python code
'description': desc, # text description for humans
'timestamp': None, # client time last monitor was received
'counter': 0, # number of monitor events received
'units': "", # engineering units
'ch': ch, # EPICS PV channel
'format': fmt, # format for display
'value': None, # formatted value
'raw_value': None, # unformatted value
'as_string': as_string, # whether to return the string representation of the value
}
self.pvdb[pv] = entry
self.xref[mne] = pv # mne is local mnemonic, define actual PV in pvlist.xml
Expand Down

0 comments on commit 1d567c1

Please sign in to comment.