"""
:filename: TrendClientPlugin.py
:author: roar@tordivel.no
:requirements: Scorpion 9.2.0.513 or higher
TrendClientPlugin - TrendView single curve viewer
::
1.0.0.2, 11nov2015, RL: modified for autodoc
1.0.0.1, 16mar2012, RL: created
"""
__version__ = '1.0.0.2'
from Scorpion import GetBoolValue,RegisterCallback,PluginChanged,SelectTagname,GetControlByHandle
[docs]class TrendClientPlugin(object):
"""
TrendClientPlugin - TrendView single curve viewer
"""
def __init__(self,cntr,name):
self.name=name
cntr.deleteControls() #delete previous added controls if any
self.curve=cntr.addControl('TrendViewClient',0,0)
self.curve.align=5 #client
self.curve.showCaption=False #no caption
self.curve.onChange=self.controlChange #hook up for changes
[docs] def __str__(self):
'''
return a unique persistance name for host application storage
'''
return '%s_%s'%(self.__class__.__name__,self.name)
[docs] def getConfig(self):
'''
returns plugin configuration as string
'''
from SPB import CreateSpb
spb=CreateSpb()
#create a spb instance, populate with the plugin configuration
#and return the xml string
spb.setInt('version',1)
spb.setBool('showCaption',self.curve.showCaption)
spb.setBool('showStatusbar',self.curve.showStatusbar)
if self.curve.selCurve<>None:
spb.setText('selCurve',self.curve.selCurve.parameter)
return spb.xml
[docs] def setConfig(self,value):
'''
set plugin configuration from the string 'value'
'''
from SPB import CreateSpb
spb=CreateSpb(value)
# TODO: extract plugin configuration from the spb object
if spb.getInt('version')>0:
self.curve.showCaption=spb.getBool('showCaption')
self.curve.showStatusbar=spb.getBool('showStatusbar')
if spb.getText('selCurve')<>None:
self.curve.selCurve=spb.getText('selCurve')
[docs] def controlChange(self,sender,args):
'''
notify container plugin has changed
'''
if sender==self.curve:
PluginChanged(self)
[docs]def CreatePlugin(hWnd, name=''):
'''
Scorpion Plugin Stub - Required
'''
cntr=GetControlByHandle(hWnd)
return TrendClientPlugin(cntr,name)