# Given a channel mask for the upper 23 output channels, the Start mask and stop mask is written. # Here, only changes on the F connector are applied. # The PVs number 4 is a local variable, is the trigger. Is asociated to a boolean button and could be changed for the data base status variable. That's the reason why the "if" statment is performed. # There is no logical loop because in the worst case this script will be executed 2 times, this was done to allow communication of the changes on all GUIs opened. Inorder to make it more clean, a data base variable should be created. # If the channels are off and the start button is pressed, the status is changed then the script will be executed again, but this time no changes will be noticed by the status variable stopping the loop. # Orlando Soto, March 2014 from org.csstudio.opibuilder.scriptUtil import PVUtil, ConsoleUtil oldStartMask = int(PVUtil.getDouble(pvs[0])) # Getting the old start mask oldStopMask = int(PVUtil.getDouble(pvs[2])) # Getting the old stop mask chann_mask = int(widget.getParent().getMacroValue("chmask"),16) # Getting the channel mask from the macro value "chmask", the value is read on base 16 (hex). apply_changes = 0x00780000 # This variable define where the changes must be performed and by definition the complementary channels. if int(PVUtil.getDouble(pvs[4])): # If the corresponding start button was pressed, the stop mask bits are unset and the start mask bits are set, then a low and a high level is written on start_stop register. mask = (oldStopMask | apply_changes) & ~chann_mask # Stop mask changes applied on the four upper channels of the F connector. pvs[3].setValue(mask) # Updating the stop mask mask = (oldStartMask & ~apply_changes) | chann_mask # Start mask changes applied on the four upper channels of the F connector. pvs[1].setValue(mask) # Updating the start mask #ConsoleUtil.writeInfo("oldStartMask: %x, chann: %s, mask: %x" % (oldStartMask, widget.getParent().getMacroValue("chann"), mask)) pvs[5].setValue(0) # Stop all other channels except the ones on the channel mask. pvs[5].setValue(1) # Start the channels on the channel mask. else: # If the script was excecuted because an status changed was done and the start button wasn't pressed, # the corresponding channels are stopped. This part should be deleted because is contempled in the "if" part through the "apply_changes" variable. # Waiting for deletion until I get a time window to be sure that this change doesn't affect the performance. mask = oldStartMask & ~int(widget.getParent().getMacroValue("chmask"),16) # The start mask for the channel mask is unset. pvs[1].setValue(mask) # Updating the start mask mask = oldStopMask | int(widget.getParent().getMacroValue("chmask"),16) # The stop mask for the channel mask is set. pvs[3].setValue(mask) # Updating the stop mask #ConsoleUtil.writeInfo("oldStopMask: %x, chann: %s, mask: %x" % (oldStopMask , widget.getParent().getMacroValue("chann"), mask) ) pvs[5].setValue(0)# Stop all other channels except the ones on the channel mask.