#!/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__ = 1289270921.534977
__CHEETAH_genTimestamp__ = 'Mon Nov  8 18:48:41 2010'
__CHEETAH_src__ = 'fbcktemplate/fbckoffsets.tmpl'
__CHEETAH_srcLastModified__ = 'Mon Nov  8 16:25:57 2010'
__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 fbckoffsets(FbckTemplate):

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


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

        super(fbckoffsets, 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 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 346
y 104
w 335
h 290
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
gridSize 8
endScreenProperties

# (Rectangle)
object activeRectangleClass
beginObjectProperties
major 4
minor 0
release 0
x 7
y 5
w 321
h 60
lineColor index 3
fill
fillColor index 3
endObjectProperties

# (Rectangle)
object activeRectangleClass
beginObjectProperties
major 4
minor 0
release 0
x 7
y 75
w 321
h 205
lineColor index 3
fill
fillColor index 3
endObjectProperties


# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 17
y 19
w 150
h 14
font "helvetica-bold-r-12.0"
fontAlign "right"
fgColor index 14
bgColor index 0
useDisplayBg
value {
  "''')
        _v = VFFSL(SL,"indexed_var",False)('S{0}NAME', VFFSL(SL,"OFFSETS_INDEX",True)) # u"$indexed_var('S{0}NAME', $OFFSETS_INDEX)" on line 76, col 4
        if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('S{0}NAME', $OFFSETS_INDEX)")) # from line 76, col 4.
        write(u''' - Desired"
}
autoSize
endObjectProperties

# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 17
y 41
w 150
h 14
font "helvetica-bold-r-10.0"
fontAlign "center"
fgColor index 14
bgColor index 0
useDisplayBg
value {
  "(''')
        _v = VFFSL(SL,"indexed_var",False)('S{0}DES_PV', VFFSL(SL,"OFFSETS_INDEX",True)) # u"$indexed_var('S{0}DES_PV', $OFFSETS_INDEX)" on line 97, col 5
        if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('S{0}DES_PV', $OFFSETS_INDEX)")) # from line 97, col 5.
        write(u''')"
}
autoSize
endObjectProperties

# (Text Control)
object activeXTextDspClass
beginObjectProperties
major 4
minor 5
release 0
x 200
y 19
w 43
h 37
controlPv "''')
        _v = VFFSL(SL,"indexed_var",False)('S{0}DES_PV', VFFSL(SL,"OFFSETS_INDEX",True)) # u"$indexed_var('S{0}DES_PV', $OFFSETS_INDEX)" on line 112, col 12
        if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('S{0}DES_PV', $OFFSETS_INDEX)")) # from line 112, col 12.
        write(u'''"
font "helvetica-medium-r-12.0"
fgColor index 14
bgColor index 0
useDisplayBg
autoHeight
limitsFromDb
nullColor index 0
useHexPrefix
newPos
objType "controls"
endObjectProperties

# (Text Control)
object activeXTextDspClass
beginObjectProperties
major 4
minor 5
release 0
x 245
y 19
w 43
h 37
controlPv "''')
        _v = VFFSL(SL,"indexed_var",False)('S{0}dotEGU_PV', VFFSL(SL,"OFFSETS_INDEX",True)) # u"$indexed_var('S{0}dotEGU_PV', $OFFSETS_INDEX)" on line 135, col 12
        if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('S{0}dotEGU_PV', $OFFSETS_INDEX)")) # from line 135, col 12.
        write(u'''"
font "helvetica-medium-r-12.0"
fgColor index 14
bgColor index 0
useDisplayBg
autoHeight
limitsFromDb
nullColor index 0
useHexPrefix
newPos
objType "controls"
endObjectProperties

# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 70
y 90
w 43
h 14
font "helvetica-medium-r-12.0"
fontAlign "right"
fgColor index 14
bgColor index 0
useDisplayBg
value {
  "Offset 1"
}
autoSize
endObjectProperties

# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 200
y 90
w 17
h 14
font "helvetica-medium-r-12.0"
fgColor index 14
bgColor index 0
useDisplayBg
value {
  "0.0"
}
autoSize
endObjectProperties

# (Text Control)
object activeXTextDspClass
beginObjectProperties
major 4
minor 5
release 0
x 244
y 90
w 40
h 14
controlPv "''')
        _v = VFFSL(SL,"indexed_var",False)('S{0}dotEGU_PV', VFFSL(SL,"OFFSETS_INDEX",True)) # u"$indexed_var('S{0}dotEGU_PV', $OFFSETS_INDEX)" on line 199, col 12
        if _v is not None: write(_filter(_v, rawExpr=u"$indexed_var('S{0}dotEGU_PV', $OFFSETS_INDEX)")) # from line 199, col 12.
        write(u'''"
font "helvetica-medium-r-12.0"
fgColor index 14
bgColor index 0
useDisplayBg
autoHeight
limitsFromDb
nullColor index 0
useHexPrefix
newPos
objType "controls"
endObjectProperties

''')
        nr_pois = int(VFFSL(SL,"TOTALPOI",True))
        top = 135
        h = 15
        vmargin = 40
        for i in range(2, VFFSL(SL,"nr_pois",True) + 1): # generated from line 216, col 1
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * (VFFSL(SL,"i",True) - 2)
            write(u'''# (Static Text)
object activeXTextClass
beginObjectProperties
major 4
minor 1
release 0
x 70
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 225, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 225, col 3.
            write(u'''
w 43
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 227, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 227, col 3.
            write(u'''
font "helvetica-medium-r-12.0"
fontAlign "right"
fgColor index 14
bgColor index 0
useDisplayBg
value {
  "Offset ''')
            _v = VFFSL(SL,"i",True) # u'$i' on line 234, col 11
            if _v is not None: write(_filter(_v, rawExpr=u'$i')) # from line 234, col 11.
            write(u'''"
}
autoSize
endObjectProperties
''')
        write(u'''
''')
        top = 120
        h = 40
        vmargin = 15
        for i in range(2, VFFSL(SL,"nr_pois",True) + 1): # generated from line 243, col 1
            y = VFFSL(SL,"top",True) + (VFFSL(SL,"h",True) + VFFSL(SL,"vmargin",True)) * (VFFSL(SL,"i",True) - 2)
            write(u'''# (Text Entry)
object TextentryClass
beginObjectProperties
major 10
minor 0
release 0
x 200
y ''')
            _v = VFFSL(SL,"y",True) # u'$y' on line 252, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$y')) # from line 252, col 3.
            write(u'''
w 100
h ''')
            _v = VFFSL(SL,"h",True) # u'$h' on line 254, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$h')) # from line 254, col 3.
            write(u'''
''')
            offsetpv = VFFSL(SL,"indexed_var",False)('$S{0}OFFSET%d_PV' % i, VFFSL(SL,"OFFSETS_INDEX",True))
            write(u'''controlPv "''')
            _v = VFFSL(SL,"offsetpv",True) # u'$offsetpv' on line 256, col 12
            if _v is not None: write(_filter(_v, rawExpr=u'$offsetpv')) # from line 256, col 12.
            write(u'''"
fgColor index 14
fgAlarm
bgColor index 0
fill
font "helvetica-medium-r-12.0"
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_fbckoffsets= 'writeBody'

## END CLASS DEFINITION

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


# 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=fbckoffsets()).run()


