"""
:filename: TrendPlugin.py
:author: roar@tordivel.no
:requirements: Scorpion 9.0.0.493 or higher
TrendPlugin - multiple curves plugin
::
1.0.0.3, 11nov2015, RL: modified for autodoc
1.0.0.2. 22sep2011, RL: hides caption, enabled=System.Service
1.0.0.1, 30may2011, RL: created
"""
__version__ = '1.0.0.3'
from Scorpion import GetBoolValue,RegisterCallback,PluginChanged,SelectTagname,GetControlByHandle
[docs]class TrendPlugin(object):
"""
TrendPlugin - multiple curves plugin
"""
def __init__(self,cntr,name):
self.name=name
cntr.deleteControls() #delete previous added controls if any
self.curve=cntr.addControl('TrendView',0,0)
self.curve.align=5 #client
self.curve.showCaption=False
self.curve.enableSetup=GetBoolValue('System.Service')
self.curve.onChange=self.controlChange
RegisterCallback('System.AccessControlChanged',self.systemAccessControlChanged)
[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.setText('config',self.curve.config)
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.config=spb.getText('config')
[docs] def controlChange(self,sender,args):
'''
notify container plugin has changed
'''
#print self,'ControlChange',sender.name,args
if sender==self.curve:
PluginChanged(self)
[docs] def systemAccessControlChanged(self,settings,service):
'''
callback when accesscontrol changes
'''
self.curve.enableSetup=service
[docs]def CreatePlugin(hWnd, name=''):
'''
Scorpion Plugin Stub - Required
'''
cntr=GetControlByHandle(hWnd)
return TrendPlugin(cntr,name)