Changeset 79


Ignore:
Timestamp:
Nov 6, 2009 10:35:02 AM (14 years ago)
Author:
jemian
Message:

Refs #2: progress ...

Location:
epics2xml
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • epics2xml/config.xml

    r78 r79  
    2323        <description>APS Storage ring current, mA</description>
    2424    </pv>
     25    <pv name="APS:BarometricPressure:MBR" rate="monitor">
     26        <description>ANL barometric pressure, mbar</description>
     27    </pv>
    2528</epics2xml>
  • epics2xml/display.xsl

    r75 r79  
    2525        </xsl:element>
    2626        <xsl:element name="body">
    27             <xsl:attribute name="bgcolor">#f0f0f8</xsl:attribute>
     27<!--            <xsl:attribute name="bgcolor">#f0f0f8</xsl:attribute>-->
    2828            <xsl:element name="h1"><xsl:value-of select="title"/></xsl:element>
    2929            <xsl:element name="h2">EPICS data</xsl:element>
     30            <xsl:element name="p">
     31                file written:
     32                <xsl:value-of select="@timeStamp"/>
     33            </xsl:element>
    3034            <xsl:element name="table">
    3135                <xsl:attribute name="bd">2</xsl:attribute>
  • epics2xml/epics2xml.py

    r78 r79  
    2727from xml.dom import minidom
    2828import datetime
    29 import copy
    30 import pvConnect
     29#import copy
     30#import pvConnect
    3131
    3232
     
    4646
    4747    def GetConfigFile(self):
    48         '''@return: name of XML settings file'''
    49         return self.settingsFile
     48        '''@return: name of XML configuration file'''
     49        return self.configFile
    5050
    5151    def SetConfigFile(self, thefile):
    5252        '''set the name of XML configuration file
    5353            @param thefile: [string] name of XML file with the configuration'''
    54         self.settingsFile = thefile
     54        self.configFile = thefile
    5555
    5656    def Clear(self):
     
    5858        self.db = {}
    5959
     60    def ReadConfigFile(self):
     61        '''read the configuration from a file into an internal dictionary (self.db)
     62
     63            @note: this method uses xml.dom.minidom (built into all Pythons)
     64            @see: http://docs.python.org/library/xml.dom.minidom.html
     65        '''
     66        try:
     67            doc = minidom.parse(self.configFile) # parse an XML file by name
     68            assert doc.documentElement.tagName == self.rootElement
     69        except IOError:
     70            return 'Could not read the XML file: ' + self.configFile
     71        except AssertionError:
     72            return 'XML root element is not ' + self.rootElement
     73        #... read all attributes from the root element
     74        docElem = doc.documentElement
     75        self.Clear()
     76        version = self._get_attribute(docElem, "version", "not-specified")
     77        try:
     78            # only handle v1.0 resource configuration files
     79            assert version == u'1.0'
     80        except AssertionError:
     81            doc.unlink()
     82            return 'Cannot handle file version:', version
     83        # file verified now
     84
    6085    def ReadXmlFile(self):
    6186        '''read the settings from a file into an internal dictionary (self.db)
     
    6590        '''
    6691        try:
    67             doc = minidom.parse(self.settingsFile) # parse an XML file by name
     92            doc = minidom.parse(self.configFile) # parse an XML file by name
    6893            assert doc.documentElement.tagName == self.rootElement
    6994        except IOError:
    70             return 'Could not read the XML file: ' + self.settingsFile
     95            return 'Could not read the XML file: ' + self.configFile
    7196        except AssertionError:
    7297            return 'XML root element is not ' + self.rootElement
     
    134159           @see: http://www.boddie.org.uk/python/XML_intro.html
    135160        '''
    136         out = open(self.settingsFile, 'w')
     161        out = open(self.configFile, 'w')
    137162        out.write(repr(self))
    138163        out.close()
     
    141166        #
    142167       
    143         return 'Saved settings to ' + self.settingsFile
     168        return 'Saved settings to ' + self.configFile
    144169
    145170    def _SetAttr(self, node, attribute, value):
     
    227252
    228253if __name__ == '__main__':
     254    cf = Epics2Xml("config.xml")
     255    cf.ReadConfigFile()
    229256#    rc = Settings("examples/test-settings.xml")
    230257#    rc.ReadXmlFile()
  • epics2xml/pvdata.xml

    r78 r79  
    22<?xml-stylesheet type="text/xsl" href="display.xsl" ?>
    33
    4 <pvdata version="1.0">
     4<pvdata version="1.0" timeStamp="2009-11-06 10:32:00">
    55    <title>epics2xml: demonstration of function</title>
    66    <pv name="S:SRcurrentAI" rate="monitor" timeStamp="2009-11-06 09:26:00">
     
    88        <value>99.9853</value>
    99    </pv>
     10    <pv name="APS:BarometricPressure:MBR" rate="monitor" timeStamp="2009-11-06 10:28:00">
     11        <description>ANL barometric pressure, mbar</description>
     12        <value>992.083</value>
     13    </pv>
    1014</pvdata>
Note: See TracChangeset for help on using the changeset viewer.