#the initial node, and the maximum depth. Eg. defaults TOP="B" P="B", NTOT=6.

#When a choice is made in one of the menus,
#loc://$(LCID)_MOUT  (pv[1]) is changed, tiggering nodeMenuAction.py for ChoiceButton_N, which makes
#loc://$(LCID)_NODE  (pv[0]) change, triggering nodeMenuUpdate.py for all buttons.
#Warning - some danger of infinite recursion here. Careful"

#The $(LCID) macro is used to make local PVs per instance. So several instances could be run from the same CSS
#without interfering.

#For example loc://$(LCID)_NODE pv is like this:         B_SYS_HV_ECAL_SEC1_.....
#split into list with elements                           0 1   2  3    4    5
#eg - with N for the menu N = 3                                   *
#

nodeLoader.readTree()  #Read in the node tree

n = int(widget.getMacroValue("N"))  #Get N,B and NODE
topnode = widget.getMacroValue("TOP")
node = PVUtil.getString(pvArray[0])

if not node in nodeLoader.NodeIndex:  # check node defined, or force to top node
    node = topnode

nlist = node.split(
    "_")  #make a list of the parts of node   nlist = (B,SYS,HV,ECAL,SEC1,....)

#widget.setPropertyValue("height",24 )            #and size
#widget.setPropertyValue("visible","false")       #assume invisible until other decision made
widget.setPropertyValue("enabled",
                        "false")  #assume invisible until other decision made
#import the nodes dictionary describing the Hall-B tree
#from NodesDict import SubNodeNames
import nodeLoader
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil
from java.util import Arrays
import os.path

#Read in the node tree
nodeLoader.readTree()


#The macro P is like this:      B_SYS_HV_ECAL_SEC1_.....
#split into list with elements  0 1   2  3    4    5
#                                             *

#This script relates to choice button with number n (taken from macro N) - let's say 4 in this case (* above).
#If the macro has 5 (n+1) or more elements we want to draw the button, make the choices the siblings of element n,
#and mark the correct one as selected.



#Get the macro(s) associated with the widget
#The standard EPICS marco P=prefix is always passed. It is the name of the node or element.
node = widget.getMacroValue("P")     #main node for the GUI
n = int(widget.getMacroValue("N"))   #index of this menu

widget.setPropertyValue("visible","false")
drawing=0

if not node in nodeLoader.NodeIndex:                      # check node defined, or print error and ret  
        #ConsoleUtil.write("Error: There is no Key for \""+str(node)+"\" in NodeIndex[]") 
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil
import nodeLoader
from java.util import Arrays

#This is the code to update the list of items in combo widget to chose a node
#in the CLAS EPICS tree. 
#It is triggered by selection of a new node using the local PV loc://$(DID)_NODE
#It makes the item list of all the ancestors, the node, and the subnodes

nodeLoader.readTree()                        #make sure the node tree is made

topnode  = widget.getMacroValue("TOP")       #Name of the top node  Eg. B_SYS_HV
ntop     = len(topnode.split("_"))           #Work out the no of levels in the top node (eg. 3 here)

node     = topnode                           #Start off the node that this combo will display
       
index    =  int(nodeLoader.NodeIndex[node])     #get subnodes
subnodes = nodeLoader.SubNodeNames[index].rstrip("'").lstrip("'").split(",")
          
row = 0
rowlen = 6
col = 0
if len(subnodes[0]):                         #if there are subnodes
    for i in range(len(subnodes)):           #make a list, sort it and start it with this node
        # Fill the subnodes group container with relevant .opi files
        # header first
        index    =  int(nodeLoader.NodeIndex[node+"_"+subnodes[i]])
        erange = nodeLoader.ElementRange[index].strip("'")
        low  = erange.split(",")[0]
        high = erange.split(",")[1]
        
Example #4
0
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil
import nodeLoader
from java.util import Arrays

#This is the code to update the list of items in combo widget to chose a node
#in the CLAS EPICS tree.
#It is triggered by selection of a new node using the local PV loc://$(DID)_NODE
#It makes the item list of all the ancestors, the node, and the subnodes

nodeLoader.readTree()  #make sure the node tree is made

topnode = widget.getMacroValue("TOP")  #Name of the top node  Eg. B_SYS_HV
ntop = len(topnode.split(
    "_"))  #Work out the no of levels in the top node (eg. 3 here)

node = topnode  #Start off the node that this combo will display

index = int(nodeLoader.NodeIndex[node])  #get subnodes
subnodes = nodeLoader.SubNodeNames[index].rstrip("'").lstrip("'").split(",")

row = 0
rowlen = 6
col = 0
if len(subnodes[0]):  #if there are subnodes
    for i in range(
            len(subnodes)):  #make a list, sort it and start it with this node
        # Fill the subnodes group container with relevant .opi files
        # header first
        index = int(nodeLoader.NodeIndex[node + "_" + subnodes[i]])
        erange = nodeLoader.ElementRange[index].strip("'")
        low = erange.split(",")[0]
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil
import fnmatch
import nodeLoader
import array
import math

nodeLoader.readTree()                              #Read in the node tree
views=["B_SYS_HV"]                                 #list of possible views

topnode    = str(widget.getMacroValue("TOP"))      #Get the top node
rangemode  = str(widget.getMacroValue("SCALE"))    #Get the scale for the (= Whole or Part)
title      = str(widget.getMacroValue("TITLE"))    #Get the title
node       = PVUtil.getString(pvArray[0])          #Get the current node from local pv
rangepv    = PVUtil.getDoubleArray(pvArray[1])

if node.find(topnode) <0:                    #if the node doesn't contain topnode
	node = topnode                             #force to top
#ConsoleUtil.writeInfo("Node = "+node+"  Top = "+topnode)
view=-1                                            #init index of view
for n in range(len(views)):                        #find the vew for this node
        if node.find(views[n]) > -1:
                view=n
                
if view > -1:                                      #if it's a valid view 

 
        widget.setPropertyValue("axis_1_auto_scale","true")
        if node in nodeLoader.NodeIndex:           #check for node and get index
                #ConsoleUtil.writeInfo("Node = "+node+"  Top = "+topnode)
                index  =  int(nodeLoader.NodeIndex[node])
                erange = nodeLoader.ElementRange[index].strip("'")