#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
import fbcktemplate
from fbcktemplate import FbckTemplate

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.2.1'
__CHEETAH_versionTuple__ = (2, 4, 2, 'final', 1)
__CHEETAH_genTime__ = 1301337132.7043381
__CHEETAH_genTimestamp__ = 'Mon Mar 28 11:32:12 2011'
__CHEETAH_src__ = 'fbckplots.tmpl'
__CHEETAH_srcLastModified__ = 'Mon Jan 24 18:48:35 2011'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class fbckplots(FbckTemplate):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(fbckplots, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def histpv_param(self, type, **KWS):



        ## CHEETAH: generated from #def histpv_param(type) at line 4, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        if int(VFFSL(SL,"POI_INDEX",True)) == 0: # generated from line 5, col 1
            return '$%s{0}HST_S_PV' % type
        return '$%s{0}P%sHST_S_PV' % (type, VFFSL(SL,"POI_INDEX",True))
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def s_deshistpv_param(self, **KWS):



        ## CHEETAH: generated from #def s_deshistpv_param() at line 10, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        if int(VFFSL(SL,"POI_INDEX",True)) == 0: # generated from line 11, col 1
            return '$S{0}DESHST_S_PV'
        return '$S{0}DES%sHST_S_PV' % (VFFSL(SL,"POI_INDEX",True))
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def fill_graph(self, pvs, colors, **KWS):



        ## CHEETAH: generated from #def fill_graph($pvs, $colors) at line 16, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''numTraces ''')
        _v = len(VFFSL(SL,"pvs",True))
        if _v is not None: write(_filter(_v))
        write(u'''
yPv {
''')
        i = 0
        for pv in VFFSL(SL,"pvs",True): # generated from line 20, col 1
            _v = VFFSL(SL,"i",True) # u'$i' on line 21, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$i')) # from line 21, col 1.
            write(u''' "''')
            _v = VFFSL(SL,"pv",True) # u'$pv' on line 21, col 5
            if _v is not None: write(_filter(_v, rawExpr=u'$pv')) # from line 21, col 5.
            write(u'''"
''')
            i = VFFSL(SL,"i",True) + 1
        write(u'''}
plotColor {
''')
        i = 0
        for color in VFFSL(SL,"colors",True): # generated from line 27, col 1
            _v = VFFSL(SL,"i",True) # u'$i' on line 28, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$i')) # from line 28, col 1.
            write(u''' "''')
            _v = VFFSL(SL,"color",True) # u'$color' on line 28, col 5
            if _v is not None: write(_filter(_v, rawExpr=u'$color')) # from line 28, col 5.
            write(u'''"
''')
            i = VFFSL(SL,"i",True) + 1
        write(u'''}
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def writeBody(self, **KWS):



        ## CHEETAH: main method generated for this template
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        # 
        write(u'''4 0 1
beginScreenProperties
major 4
minor 0
release 1
x 211
y 43
w 1000
h 995
font "helvetica-medium-r-12.0"
ctlFont "helvetica-medium-r-12.0"
btnFont "helvetica-medium-r-12.0"
fgColor index 14
bgColor index 5
textColor index 14
ctlFgColor1 index 14
ctlFgColor2 index 0
ctlBgColor1 index 0
ctlBgColor2 index 14
topShadowColor index 1
botShadowColor index 11
showGrid
snapToGrid
gridSize 8
endScreenProperties

''')
        self._handleCheetahInclude(VFFSL(SL,"TEMPLATES_DIR",True) + "plots_master.edl", trans=trans, includeFrom="file", raw=True)
        write(u'''
''')
        # ############## Actuators
        top = 88
        h = 12
        vmargin = 193
        row = 0
        for i in VFFSL(SL,"used_indices",False)('A', size=4): # generated from line 67, col 1
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 870
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 76, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 76, col 3.
            write(u'''
w 110
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 78, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 78, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
''')
            color = VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()
            write(u'''fgColor ''')
            _v = VFFSL(SL,"color",True) # u'$color' on line 81, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$color')) # from line 81, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
  "''')
            _v = VFFSL(SL,"indexed_var",False)('$A{0}DEVNAME', VFFSL(SL,"i",True)) # u"$indexed_var('$A{0}DEVNAME', $i)" on line 85, col 4
            if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('$A{0}DEVNAME', $i)")) # from line 85, col 4.
            write(u'''"
}
autoSize
endObjectProperties
# (X-Y Graph) Actuators
object xyGraphClass
beginObjectProperties
major 4
minor 6
release 0
# Geometry
x 512
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 97, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 97, col 3.
            write(u'''
w 352
h 192
# Appearance
border
plotAreaBorder
autoScaleBothDirections
xLabel "Pulses"
yLabel "kG-m"
fgColor index 14
bgColor index 3
gridColor index 14
font "helvetica-medium-r-8.0"
# Operating Modes
nPts 2
# X axis properties
showXAxis
xAxisSrc "fromUser"
xMin 0
xMax 200
xAxisSmoothing 1
# Y axis properties
showYAxis
yAxisSrc "AutoScale"
yMax 1
# Y2 axis properties
y2AxisSrc "AutoScale"
y2Min 0
y2Max 1
y2MajorsPerLabel 3
# Trace Properties
''')
            pv = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"histpv_param",False)('A'), VFFSL(SL,"i",True))
            _v = VFFSL(SL,"fill_graph",False)([VFFSL(SL,"pv",True)], [VFFSL(SL,"color",True)]) # u'$fill_graph([$pv], [$color])' on line 129, col 1
            if _v is not None: write(_filter(_v, rawExpr=u'$fill_graph([$pv], [$color])')) # from line 129, col 1.
            write(u'''
endObjectProperties

''')
            row = VFFSL(SL,"row",True) + 1
        write(u'''
''')
        # ############## Position States
        top = 88
        h = 12
        vmargin = 5
        row = 0
        pvs = []
        colors = []
        for i in VFFSL(SL,"used_indices",False)('S'): # generated from line 142, col 1
            STATE_NAME = VFFSL(SL,"indexed_var",False)('$S{0}NAME', VFFSL(SL,"i",True))
            if "p" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)() or ("y" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)() and "x" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)()): # generated from line 144, col 1
                continue
            STATE_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"histpv_param",False)('S'), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"STATE_PV",True)) # u'$pvs.append($STATE_PV)' on line 148, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($STATE_PV)')) # from line 148, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 149, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 149, col 2.
            write(u'''
''')
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 158, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 158, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 160, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 160, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 162, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 162, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
  "''')
            _v = VFFSL(SL,"STATE_NAME",True) # u'$STATE_NAME' on line 166, col 4
            if _v is not None: write(_filter(_v, rawExpr=u'$STATE_NAME')) # from line 166, col 4.
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            STATE_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"s_deshistpv_param",False)(), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"STATE_PV",True)) # u'$pvs.append($STATE_PV)' on line 173, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($STATE_PV)')) # from line 173, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 174, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 174, col 2.
            write(u'''
# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 182, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 182, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 184, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 184, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 186, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 186, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
"
''')
            _v = VFFSL(SL,"STATE_NAME",True) + ' SP'
            if _v is not None: write(_filter(_v))
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
        write(u'''
# (X-Y Graph) Position States
object xyGraphClass
beginObjectProperties
major 4
minor 6
release 0
# Geometry
x 16
y 88
w 384
h 192
# Appearance
border
plotAreaBorder
autoScaleBothDirections
xLabel "Pulses"
yLabel "mm"
fgColor index 14
bgColor index 3
gridColor index 14
font "helvetica-medium-r-8.0"
# Operating Modes
nPts 2
# X axis properties
showXAxis
xAxisSrc "fromUser"
xMin 0
xMax 200
xAxisSmoothing 1
# Y axis properties
showYAxis
yAxisSrc "AutoScale"
yMax 1
# Y2 axis properties
y2AxisSrc "AutoScale"
y2Min 0
y2Max 1
y2MajorsPerLabel 3
# Trace Properties
''')
        _v = VFFSL(SL,"fill_graph",False)(VFFSL(SL,"pvs",True), VFFSL(SL,"colors",True)) # u'$fill_graph($pvs, $colors)' on line 238, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'$fill_graph($pvs, $colors)')) # from line 238, col 1.
        write(u'''
''')
        pvs = []
        colors = []
        write(u'''endObjectProperties

''')
        # ############## Angle States
        top = 288
        h = 12
        vmargin = 5
        row = 0
        for i in VFFSL(SL,"used_indices",False)('S'): # generated from line 248, col 1
            STATE_NAME = VFFSL(SL,"indexed_var",False)('S{0}NAME', VFFSL(SL,"i",True))
            if "a" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)() or ("y" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)() and "x" not in VFN(VFFSL(SL,"STATE_NAME",True),"lower",False)()): # generated from line 250, col 1
                continue
            STATE_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"histpv_param",False)('S'), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"STATE_PV",True)) # u'$pvs.append($STATE_PV)' on line 254, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($STATE_PV)')) # from line 254, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 255, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 255, col 2.
            write(u'''
''')
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 264, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 264, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 266, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 266, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 268, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 268, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
  "''')
            _v = VFFSL(SL,"STATE_NAME",True) # u'$STATE_NAME' on line 272, col 4
            if _v is not None: write(_filter(_v, rawExpr=u'$STATE_NAME')) # from line 272, col 4.
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
            STATE_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"s_deshistpv_param",False)(), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"STATE_PV",True)) # u'$pvs.append($STATE_PV)' on line 278, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($STATE_PV)')) # from line 278, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 279, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 279, col 2.
            write(u'''
''')
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 288, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 288, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 290, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 290, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 292, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 292, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
"
''')
            _v = VFFSL(SL,"STATE_NAME",True) + ' SP'
            if _v is not None: write(_filter(_v))
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
        write(u'''
# (X-Y Graph) Angle States
object xyGraphClass
beginObjectProperties
major 4
minor 6
release 0
# Geometry
x 16
y 288
w 384
h 192
# Appearance
border
plotAreaBorder
autoScaleBothDirections
xLabel "Pulses"
yLabel "mrad"
fgColor index 14
bgColor index 3
gridColor index 14
font "helvetica-medium-r-8.0"
# Operating Modes
nPts 2
# X axis properties
showXAxis
xAxisSrc "fromUser"
xMin 0
xMax 200
xAxisSmoothing 1
# Y axis properties
showYAxis
yAxisSrc "AutoScale"
yMax 1
# Y2 axis properties
y2AxisSrc "AutoScale"
y2Min 0
y2Max 1
y2MajorsPerLabel 3
# Trace Properties
''')
        _v = VFFSL(SL,"fill_graph",False)(VFFSL(SL,"pvs",True), VFFSL(SL,"colors",True)) # u'$fill_graph($pvs, $colors)' on line 344, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'$fill_graph($pvs, $colors)')) # from line 344, col 1.
        write(u'''
''')
        pvs = []
        colors = []
        write(u'''endObjectProperties


''')
        # ############## X Measurements
        _v = VFFSL(SL,"paginate",False)((1 + VFFSL(SL,"NR_MEASUREMENT_PAGES",True)) / 2, 290, 486, 'm') # u"$paginate((1 + $NR_MEASUREMENT_PAGES) / 2, 290, 486, 'm')" on line 351, col 1
        if _v is not None: write(_filter(_v, rawExpr=u"$paginate((1 + $NR_MEASUREMENT_PAGES) / 2, 290, 486, 'm')")) # from line 351, col 1.
        write(u'''
''')
        top = 520
        h = 12
        vmargin = 5
        row = 0
        first = (int(VFFSL(SL,"M_PAGE_NR",True)) - 1) * VFFSL(SL,"NR_MEASUREMENTS_PER_PAGE",True) * 2  + 1
        for i in VFFSL(SL,"used_indices",False)('M', VFFSL(SL,"first",True), VFFSL(SL,"NR_MEASUREMENTS_PER_PAGE",True) * 2): # generated from line 357, col 1
            MEASUREMENT_NAME = VFFSL(SL,"indexed_var",False)('M{0}DEVNAME', VFFSL(SL,"i",True))
            if ("x" in VFN(VFFSL(SL,"MEASUREMENT_NAME",True),"lower",False)()) == 0: # generated from line 359, col 1
                continue
            MEASUREMENT_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"histpv_param",False)('M'), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"MEASUREMENT_PV",True)) # u'$pvs.append($MEASUREMENT_PV)' on line 363, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($MEASUREMENT_PV)')) # from line 363, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 364, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 364, col 2.
            write(u'''
''')
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 373, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 373, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 375, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 375, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 377, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 377, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
  "''')
            _v = VFFSL(SL,"MEASUREMENT_NAME",True) # u'$MEASUREMENT_NAME' on line 381, col 4
            if _v is not None: write(_filter(_v, rawExpr=u'$MEASUREMENT_NAME')) # from line 381, col 4.
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
        write(u'''
# (X-Y Graph) X Measurements
object xyGraphClass
beginObjectProperties
major 4
minor 6
release 0
# Geometry
x 16
y 520
w 384
h 192
# Appearance
border
plotAreaBorder
autoScaleBothDirections
xLabel "Pulses"
yLabel "mm"
fgColor index 14
bgColor index 3
gridColor index 14
font "helvetica-medium-r-8.0"
# Operating Modes
nPts 2
# X axis properties
showXAxis
xAxisSrc "fromUser"
xMin 0
xMax 200
xAxisSmoothing 1
# Y axis properties
showYAxis
yAxisSrc "AutoScale"
yMax 1
# Y2 axis properties
y2AxisSrc "AutoScale"
y2Min 0
y2Max 1
y2MajorsPerLabel 3
# Trace Properties
''')
        _v = VFFSL(SL,"fill_graph",False)(VFFSL(SL,"pvs",True), VFFSL(SL,"colors",True)) # u'$fill_graph($pvs, $colors)' on line 427, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'$fill_graph($pvs, $colors)')) # from line 427, col 1.
        write(u'''
''')
        pvs = []
        colors = []
        write(u'''endObjectProperties

''')
        # ############## Y Measurements
        top = 720
        h = 12
        vmargin = 5
        row = 0
        for i in VFFSL(SL,"used_indices",False)('M', VFFSL(SL,"first",True), VFFSL(SL,"NR_MEASUREMENTS_PER_PAGE",True) * 2): # generated from line 437, col 1
            MEASUREMENT_NAME = VFFSL(SL,"indexed_var",False)('M{0}DEVNAME', VFFSL(SL,"i",True))
            if ("y" in VFN(VFFSL(SL,"MEASUREMENT_NAME",True),"lower",False)()) == 0: # generated from line 439, col 1
                continue
            MEASUREMENT_PV = VFFSL(SL,"indexed_var",False)(VFFSL(SL,"histpv_param",False)('M'), VFFSL(SL,"i",True))
            write(u'''#''')
            _v = VFN(VFFSL(SL,"pvs",True),"append",False)(VFFSL(SL,"MEASUREMENT_PV",True)) # u'$pvs.append($MEASUREMENT_PV)' on line 443, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$pvs.append($MEASUREMENT_PV)')) # from line 443, col 2.
            write(u'''
#''')
            _v = VFN(VFFSL(SL,"colors",True),"append",False)(VFN(VFFSL(SL,"fbcktemplate",True),"next_edm_color",False)()) # u'$colors.append($fbcktemplate.next_edm_color())' on line 444, col 2
            if _v is not None: write(_filter(_v, rawExpr=u'$colors.append($fbcktemplate.next_edm_color())')) # from line 444, col 2.
            write(u'''
''')
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * VFFSL(SL,"row",True)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 410
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 453, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 453, col 3.
            write(u'''
w 52
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 455, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 455, col 3.
            write(u'''
font "helvetica-bold-r-10.0"
fgColor ''')
            _v = VFFSL(SL,"colors",True)[-1] # u'$colors[-1]' on line 457, col 9
            if _v is not None: write(_filter(_v, rawExpr=u'$colors[-1]')) # from line 457, col 9.
            write(u'''
bgColor index 3
useDisplayBg
value {
  "''')
            _v = VFFSL(SL,"MEASUREMENT_NAME",True) # u'$MEASUREMENT_NAME' on line 461, col 4
            if _v is not None: write(_filter(_v, rawExpr=u'$MEASUREMENT_NAME')) # from line 461, col 4.
            write(u'''"
}
autoSize
endObjectProperties
''')
            row = VFFSL(SL,"row",True) + 1
        write(u'''
# (X-Y Graph) Y Measurements
object xyGraphClass
beginObjectProperties
major 4
minor 6
release 0
# Geometry
x 16
y 720
w 384
h 192
# Appearance
border
plotAreaBorder
autoScaleBothDirections
xLabel "Pulses"
yLabel "mm"
fgColor index 14
bgColor index 3
gridColor index 14
font "helvetica-medium-r-8.0"
# Operating Modes
nPts 2
# X axis properties
showXAxis
xAxisSrc "fromUser"
xMin 0
xMax 200
xAxisSmoothing 1
# Y axis properties
showYAxis
yAxisSrc "AutoScale"
yMax 1
# Y2 axis properties
y2AxisSrc "AutoScale"
y2Min 0
y2Max 1
y2MajorsPerLabel 3
# Trace Properties
''')
        _v = VFFSL(SL,"fill_graph",False)(VFFSL(SL,"pvs",True), VFFSL(SL,"colors",True)) # u'$fill_graph($pvs, $colors)' on line 507, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'$fill_graph($pvs, $colors)')) # from line 507, col 1.
        write(u'''
''')
        pvs = []
        colors = []
        write(u'''endObjectProperties

# (Freeze Button)
object activeFreezeButtonClass
beginObjectProperties
major 4
minor 0
release 0
x 16
y 936
w 100
h 24
fgColor index 14
bgColor index 4
frozenBgColor index 77
topShadowColor index 1
botShadowColor index 11
label "Freeze Plots"
frozenLabel "Unfreeze Plots"
font "helvetica-bold-r-12.0"
3d
endObjectProperties

# (Shell Command)
object shellCmdClass
beginObjectProperties
major 4
minor 2
release 0
x 432
y 936
w 116
h 24
fgColor index 14
bgColor index 4
topShadowColor index 1
botShadowColor index 11
font "helvetica-bold-r-12.0"
buttonLabel "Data Snapshot..."
multipleInstances
numCmds 1
command {
  0 "''')
        _v = VFFSL(SL,"DATA_SNAPSHOT_COMMAND",True) # u'$DATA_SNAPSHOT_COMMAND' on line 552, col 6
        if _v is not None: write(_filter(_v, rawExpr=u'$DATA_SNAPSHOT_COMMAND')) # from line 552, col 6.
        write(u'''"
}
endObjectProperties

# (Shell Command)
object shellCmdClass
beginObjectProperties
major 4
minor 2
release 0
x 864
y 936
w 120
h 24
fgColor index 14
bgColor index 4
topShadowColor index 1
botShadowColor index 11
font "helvetica-bold-r-12.0"
buttonLabel "ArchiveViewer..."
numCmds 1
command {
  0 "''')
        _v = VFFSL(SL,"AV_COMMAND",True) # u'$AV_COMMAND' on line 574, col 6
        if _v is not None: write(_filter(_v, rawExpr=u'$AV_COMMAND')) # from line 574, col 6.
        write(u'''"
}
endObjectProperties

# (Text Control)
object activeXTextDspClass
beginObjectProperties
major 4
minor 3
release 0
x 16
y 10
w 193
h 21
controlPv "''')
        _v = VFFSL(SL,"NAME_PV",True) # u'$NAME_PV' on line 588, col 12
        if _v is not None: write(_filter(_v, rawExpr=u'$NAME_PV')) # from line 588, col 12.
        write(u'''"
format "string"
font "helvetica-bold-r-18.0"
fgColor index 76
bgColor index 4
useDisplayBg
autoHeight
limitsFromDb
nullColor index 14
useHexPrefix
newPos
objType "monitors"
endObjectProperties

# (Related Display)
object relatedDisplayClass
beginObjectProperties
major 4
minor 2
release 0
x 880
y 8
w 48
h 24
fgColor index 14
bgColor index 4
topShadowColor index 1
botShadowColor index 11
font "helvetica-medium-r-12.0"
buttonLabel "Help..."
numPvs 4
numDsps 1
displayFileName {
  0 "fbck_l3l_plot_help.edl"
}
endObjectProperties

''')
        # ############## POI Plots
        nr_pois = int(VFFSL(SL,"TOTALPOI",True))
        if VFFSL(SL,"nr_pois",True) < 2: # generated from line 627, col 1
            return _dummyTrans and trans.response().getvalue() or ""
        w = 100
        hmargin = 3
        left = 870 - (VFFSL(SL,"w",True) + VFFSL(SL,"hmargin",True)) * (VFFSL(SL,"nr_pois",True) + 1)
        for i in range(VFFSL(SL,"nr_pois",True) + 1): # generated from line 633, col 1
            x = VFFSL(SL,"left",True) + (VFFSL(SL,"w",True) + VFFSL(SL,"hmargin",True)) * VFFSL(SL,"i",True)
            if VFFSL(SL,"i",True) == 0: # generated from line 635, col 1
                label = "Main..."
            else: # generated from line 637, col 1
                label = "PATTERN %d..." % VFFSL(SL,"i",True)
            if VFFSL(SL,"i",True) == int(VFFSL(SL,"POI_INDEX",True)): # generated from line 640, col 1
                write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x ''')
                _v = VFFSL(SL,"x",True) # u'$x' on line 647, col 3
                if _v is not None: write(_filter(_v, rawExpr=u'$x')) # from line 647, col 3.
                write(u'''
y 8
w ''')
                _v = VFFSL(SL,"w",True) # u'$w' on line 649, col 3
                if _v is not None: write(_filter(_v, rawExpr=u'$w')) # from line 649, col 3.
                write(u'''
h 24
font "helvetica-bold-r-14.0"
fontAlign "center"
fgColor index 14
bgColor index 3
value {
  "''')
                _v = VFFSL(SL,"label",True) # u'$label' on line 656, col 4
                if _v is not None: write(_filter(_v, rawExpr=u'$label')) # from line 656, col 4.
                write(u'''"
}
border
endObjectProperties
''')
            else: # generated from line 660, col 1
                write(u'''# (Shell Command) or (Related Display)
''')
                if VFFSL(SL,"GENERATE_ALL",True): # generated from line 662, col 1
                    write(u'''object relatedDisplayClass
''')
                else: # generated from line 664, col 1
                    write(u'''object shellCmdClass
''')
                write(u'''beginObjectProperties
major 4
minor 2
release 0
x ''')
                _v = VFFSL(SL,"x",True) # u'$x' on line 671, col 3
                if _v is not None: write(_filter(_v, rawExpr=u'$x')) # from line 671, col 3.
                write(u'''
y 8
w ''')
                _v = VFFSL(SL,"w",True) # u'$w' on line 673, col 3
                if _v is not None: write(_filter(_v, rawExpr=u'$w')) # from line 673, col 3.
                write(u'''
h 24
fgColor index 14
bgColor index 4
topShadowColor index 1
botShadowColor index 11
font "helvetica-bold-r-14.0"
buttonLabel "''')
                _v = VFFSL(SL,"label",True) # u'$label' on line 680, col 14
                if _v is not None: write(_filter(_v, rawExpr=u'$label')) # from line 680, col 14.
                write(u'''"
''')
                if VFFSL(SL,"GENERATE_ALL",True): # generated from line 681, col 1
                    write(u'''numDsps 1
''')
                    s = VFN(VFFSL(SL,"PLOTS_DISPLAY_FORMAT",True),"format",False)(VFFSL(SL,"M_PAGE_NR",True), i)
                    write(u'''displayFileName {
    0 "''')
                    _v = VFFSL(SL,"s",True) # u'$s' on line 685, col 8
                    if _v is not None: write(_filter(_v, rawExpr=u'$s')) # from line 685, col 8.
                    write(u'''"
}
''')
                else: # generated from line 687, col 1
                    write(u'''numCmds 1
''')
                    s = VFN(VFFSL(SL,"PLOTS_COMMAND_FORMAT",True),"format",False)(VFFSL(SL,"M_PAGE_NR",True), i)
                    write(u'''command {
  0 "''')
                    _v = VFFSL(SL,"s",True) # u'$s' on line 691, col 6
                    if _v is not None: write(_filter(_v, rawExpr=u'$s')) # from line 691, col 6.
                    write(u'''"
}
''')
                write(u'''endObjectProperties
''')
        write(u'''
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_fbckplots= 'writeBody'

## END CLASS DEFINITION

if not hasattr(fbckplots, '_initCheetahAttributes'):
    templateAPIClass = getattr(fbckplots, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(fbckplots)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=fbckplots()).run()


