wxmtxy_xml
index
/home/oxygen18/JEMIAN/Documents/eclipse/usaxs/wxmtxy/trunk/wxmtxy_xml.py

@note: support the XML settings file for the wxmtxy application
 
This Python file provides routines to read and write XML settings
files for the wxmtxy application.  An example of the XML file is 
shown below.  The routines manage the settings internally with a 
Python dictionary.  Interface routines are used to read and write 
the various components of the file.  *HOWEVER*, the EPICS configuration 
is communicated in a Python dictionary.  An example of the Python 
dictionary with the EPICS configuration is shown below.
 
@version: 
########### SVN repository information ###################
# $Date: 2010-06-03 16:04:15 -0500 (Thu, 03 Jun 2010) $
# $Author: jemian $
# $Revision: 184 $
# $URL: https://subversion.xor.aps.anl.gov/bcdaext/wxmtxy/trunk/wxmtxy_xml.py $
# $Id: wxmtxy_xml.py 184 2010-06-03 21:04:15Z jemian $
########### SVN repository information ###################
 
@note: for help with xml.dom, see http://docs.python.org/library/xml.dom.html
 
@note: Here is an example XML file:
<?xml version="1.0" ?>
<wxmtxy date="2009-04-09" time="10:27:00" version="1.0">
  <XYpair name="example" selected="True">
    <EPICS_configuration>
      <axis name="x">
        <flag isMotorRec="False" />
        <field name="VAL" pv="32idbLAX:float1" />
        <field name="RBV" pv="32idbLAX:float2" />
        <field name="DESC" pv="32idbLAX:string1" />
        <field name="EGU" pv="32idbLAX:string2" />
        <field name="DMOV" pv="32idbLAX:bit1" />
        <field name="STOP" pv="32idbLAX:bit2" />
      </axis>
      <axis name="y">
        <flag isMotorRec="True" />
        <field name="VAL" pv="32idbLAX:m58:c1:m1" /><!-- USAXS a1y -->
      </axis>
    </EPICS_configuration>
    <tab name="page 1">
      <row name="page 1, row 0" x="1.0" y="-1.0" selected="True"/>
      <row name="page 1, row 1" x="1.1" y="-1.1"/>
      <row/>
    </tab>
    <tab name="page 2" selected="True">
      <row name="page 2, row 0" x="2.0" y="-2.0"/>
      <row name="page 2, row 1" x="2.1" y="-2.1"/>
      <row name="page 2, row 2" x="2.2" y="-2.2" selected="True"/>
      <row name="page 2, row 3" x="2.3" y="-2.3"/>
      <row name="page 2, row 4" x="2.4" y="-2.4"/>
      <row name="page 2, row 5" x="2.5" y="-2.5"/>
      <row name="page 2, row 6" x="2.6" y="-2.6"/>
    </tab>
    <tab name="empty page"/>
    <tab name="page 3">
  </XYpair>
</wxmtxy>
 
@note: Here is an example Python dictionary of the EPICS configuration above:
    example_dictionary = {
        'x': {
            'isMotorRec': False,
            'VAL': '32idbLAX:float1',
            'RBV': '32idbLAX:float2',
            'DESC': '32idbLAX:string1',
            'EGU': '32idbLAX:string2',
            'DMOV': '32idbLAX:bit1',
            'STOP': '32idbLAX:bit2'
        },
        'y': {
            'isMotorRec': True,
            'VAL': '32idbLAX:m58:c1:m1.VAL'
        }
    }

 
Modules
       
copy
datetime
xml.dom.minidom
wxmtxy_axis

 
Classes
       
Settings

 
class Settings
    handle the XML settings file
 
  Methods defined here:
Clear(self)
reset the internal data representation (db) to empty
CountPairs(self)
@return: number of pairs
CountRows(self, pairnum, tabnum)
return the number of rows
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
CountTabs(self, pairnum)
return the number of tabs
@param pairnum: [int] index number of the XY_pair
GetDb(self)
@return: database
GetEpicsConfig(self, pairnum)
Get a deep copy Python dictionary of the current EPICS PV config.
@param pairnum: [int] index number of the XY_pair
@return: the current EPICS configuration
GetPairTitle(self, pairnum)
return the name of the XY_pair
@param pairnum: [int] index number of the XY_pair
GetRowTitle(self, pairnum, tabnum, rownum)
return the name of the row
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param rownum: [int] index number of the Row object
GetRowXY(self, pairnum, tabnum, rownum)
return the name of the row
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param rownum: [int] index number of the Row object
GetSelectedPair(self)
@return: index number of the "selected" pair (-1 if none selected)
GetSelectedRow(self, pairnum, tabnum)
return the index number of the selected row
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
GetSelectedTab(self, pairnum)
return the index number of the selected tab
@param pairnum: [int] index number of the XY_pair
GetSettingsFile(self)
@return: name of XML settings file
GetTabTitle(self, pairnum, tabnum)
return the name of the tab
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
NewEpicsConfig(self, pairnum)
Create internal space for a new EPICS configuration
@param pairnum: [int] index number of the XY_pair
NewPair(self, title='')
create space in the database (db) for a new pair
and sets defaults for fields
 
@param title: [string] the title of the XY_pair set (default="")
@return: the index number
NewRow(self, pairnum, tabnum, title='')
create space in the database (db) pair for a new tab
and sets defaults for fields
 
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param title: the title of the Tab object (default="")
@return the index number
NewTab(self, pairnum, title='')
create space in the database (db) pair for a new tab
and sets defaults for fields
 
@param pairnum: [int] index number of the XY_pair
@param title: the title of the pair set (default="")
@return the index number
ReadXmlFile(self)
read the settings from a file into an internal dictionary (self.db)
 
@note: this method uses xml.dom.minidom (built into all Pythons)
@see: http://docs.python.org/library/xml.dom.minidom.html
SaveXmlFile(self)
save the internal dictionary (self.db) to an XML file
@note: What about using/saving a default stylesheet?
@see: http://www.boddie.org.uk/python/XML_intro.html
SelectPair(self, pairnum)
set the "selected" attribute of the pair
@param pairnum: [int] index number of the XY_pair
SelectRow(self, pairnum, tabnum, rownum)
set the selected attribute of the pair
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param rownum: [int] index number of the Row object
SelectTab(self, pairnum, tabnum)
set the selected attribute of the pair
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
SetEpicsConfig(self, pairnum, config)
set the current EPICS configuration
@param pairnum: [int] index number of the XY_pair
@param config: Python dictionary of EPICS PV configuration
SetEpicsField(self, pairnum, axis, field, value)
Define the EPICS config for a specific field
@param pairnum: [int] index number of the XY_pair'
@param axis: [string] "x" or "y"'
@param field: [string] member of wxmtxy_axis.field_list'
@param value: [string] value of this field
SetPairTitle(self, pairnum, title)
set the name of the XY_pair
@param pairnum: [int] index number of the XY_pair'
@param title: [string] name of the XY_pair
SetRowTitle(self, pairnum, tabnum, rownum, title)
set the name attribute of the row
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param rownum: [int] index number of the Row object
@param title: [string] title the Tab object
SetRowXY(self, pairnum, tabnum, rownum, x, y)
set the name attribute of the row
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param x: [float] X axis position
@param y: [float] Y axis position
SetSettingsFile(self, thefile)
set the name of XML settings file
@param thefile: [string] name of XML file with settings
SetTabTitle(self, pairnum, tabnum, title)
set the name attribute of the tab
@param pairnum: [int] index number of the XY_pair
@param tabnum: [int] index number of the Tab object
@param title: [string] title the Tab object
__init__(self, settingsFile=None)
prepare the settings file
@param settingsFile: [string] name of XML file with settings
__repr__(self)
default representation of this structure is XML
@return: XML representation of internal database (db)
@note: What about a default stylesheet?