EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to cs-studio Scan System
From: Heinz Junkes <[email protected]>
To: Patard Charles-Henri <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Tue, 23 Feb 2016 16:37:06 +0100
HI,

on our FEL we support a “shutdown-opi” for our users (the last must turn off the lights).

A action button action writes a 1 to a local PV. The local PV is LED connected to a python-script:
 

The script assembles the scan commands (depends of the machine state) and submit them to the scan server.

ShutdownSubmit.py (we are still working on it):

from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from org.csstudio.opibuilder.scriptUtil import FileUtil
from org.eclipse.jface.dialogs import MessageDialog

import org.csstudio.scan.command.CommandSequence as CommandSequence
import org.csstudio.scan.command.CommentCommand as CommentCommand
import org.csstudio.scan.command.IncludeCommand as IncludeCommand
import org.csstudio.scan.command.LoopCommand as LoopCommand
import org.csstudio.scan.command.Comparison as Comparison
import org.csstudio.scan.command.ScanCommand as ScanCommand
import org.csstudio.scan.command.WaitCommand as WaitCommand
import org.csstudio.scan.command.DelayCommand as DelayCommand
import org.csstudio.scan.command.LogCommand as LogCommand
import org.csstudio.scan.command.SetCommand as SetCommand
import org.csstudio.scan.command.ScriptCommand as ScriptCommand
import org.csstudio.scan.data.ScanDataIterator as ScanDataIterator
import org.csstudio.scan.client.ScanClient as ScanClient
import org.csstudio.scan.server.ScanServerInfo as ScanServerInfo
import org.csstudio.scan.server.ScanState as ScanState

import sys, os

from java.lang import Thread, Runnable
from java.util import Timer, TimerTask

#scan id
scid = -1

#pvs[0] ==
#pvs[1] == loc://shutdownRunning

endless ='n'

class Delay(Runnable):
    def run(self):
        while endless == 'y':
            Thread.sleep(1000)
            scInfo = client.getScanInfo(scid)
            ConsoleUtil.writeInfo("scan state = " + scInfo.getState().toString())
            if PVUtil.getDouble(pvs[1]) == 1:
                pvs[1].setValue(0)
            else:
                pvs[1].setValue(1)
            if scInfo.getState().isDone():
                pvs[1].setValue(0)
                pvs[0].setValue(0)
                break;


def scanHeader(cmds, name):
    cmds.append( CommentCommand("FEL Scan " + name + " starts") )
    
def scanBody(cmds):
    # Assemble list of commands
    
    # disable BeamlineUser access
    cmds.append(SetCommand("FHIFEL:USER:ExpAccess", 0, False))
    # halt PG9520
    cmds.append(SetCommand("FHIFEL:PG9520:State", 0, False))
    #cmds.append(DelayCommand(2.0))
    # switch off HeNe
    cmds.append(SetCommand("FHIFEL:HELPER:GUNRELAY:actHeNe", 0, False))
    
    #ConsoleUtil.writeInfo(" MOD01:M_State = " + PVUtil.getString(pvs[2]))
    #ConsoleUtil.writeInfo(" MOD02:M_State = " + PVUtil.getString(pvs[3]))
    
    #put modulators into standby if not already off
    if PVUtil.getString(pvs[2]) != 'Off':
       cmds.append(SetCommand("MOD01:S_State", 1))
       
    if PVUtil.getString(pvs[3]) != 'Off':
       cmds.append(SetCommand("MOD02:S_State",1))
    
    #set gap to 142mm  
    cmds.append(SetCommand("FHIFEL:Undulator:SetGap", 142.0, False)) #, "FHIFEL:Undulator:SetGap")
    #tune down GUN HV 1
    cmds.append(SetCommand("FHIFEL:GUN:HV_1:S_Volt", 0.0, False))
    # wait if low
    cmds.append(WaitCommand("FHIFEL:GUN:HV_1:M_Volt", Comparison.valueOf("BELOW"), 200, 5.0, 0))
    # switch off GUN HV
    cmds.append(SetCommand("FHIFEL:GUN:HV_1:S_OutputSw", 0, "FHIFEL:GUN:HV_1:R_OutputSw"))
    #switch off Dipole magnets
    # !!! der geht nicht ???
    cmds.append(SetCommand("DA0102LP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DB01LP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DA0304MP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DD01MP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DB02MP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DA01TP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DA03TP:S_OutputSw", 0, False))
    cmds.append(SetCommand("DD03DP:S_OutputSw", 0, False))
    # switch of Solonoide magnets
    cmds.append(SetCommand("SA01GP:S_OutputSw", 0, False))
    cmds.append(SetCommand("SB01GP:S_OutputSw", 0, False))
    cmds.append(SetCommand("SC01GP:S_OutputSw", 0, False))
    cmds.append(SetCommand("SD01GP:S_OutputSw", 0, False))
    cmds.append(SetCommand("SD02GP:S_OutputSw", 0, False))
    
    #Tune Gun Filament to 6.2 Amp / actual!!! 5.353
    cmds.append(SetCommand("FHIFEL:GUN:Filament:S_Curr", 6.2, "FHIFEL:GUN:Filament:M_Curr"))
    
    #Here we could wait for modulator going to standby
    cmds.append(DelayCommand(300))
    #switch off modulators
    cmds.append(SetCommand("MOD01:S_State",0))
    cmds.append(SetCommand("MOD02:S_State",0))
    #switch off chillers
    cmds.append(SetCommand("FHIFEL:HELPER:GUNRELAY:ChillerL1", 0, False))
    cmds.append(SetCommand("FHIFEL:HELPER:GUNRELAY:ChillerL2", 0, False))
    
    cmds.append( CommentCommand("End") )
    

SCAN_NAME = "FEL Shutdown"    
   
ledStat = PVUtil.getLong(pvs[0])
if ledStat == 1:
    #tStr = PVUtil.getTimeString(pvs[0])
    #ConsoleUtil.writeInfo("The LED status = " + str(ledStat) + " at " + tStr)
    
    scanCmds = [ ] 
    
    scanHeader(scanCmds, SCAN_NAME)
    scanBody(scanCmds)
    #ConsoleUtil.writeInfo( str(cmds) )
    client = ScanClient()
    xml = CommandSequence(scanCmds).getXML()
    #xml = cmds.getXML()
    ConsoleUtil.writeInfo( xml )
    scid = client.submitScan(SCAN_NAME,xml)
    endless = 'y'
    Thread(Delay()).start() # blinking LED ... scan data output live?
    #waitForDone(scid)
    
        
    # warten bis Done ...
    #thread killen
    #endless = 'n'
    #pvs[0].setValue(0)

    #xml = FileUtil.readTextFile("/FHIFEL_CSS/scans/FHIFEL_shutdown.scn")

#
#MessageDialog.openInformation(None, "Dialog from python script", "Are you sure you want to shutdown the FEL?")

#scid = client.submitScan("shutdown",xml)

# waitUntilDone ...


HTH,
Heinz


On 23 Feb 2016, at 14:58, Patard Charles-Henri <[email protected]> wrote:

Hello,
I need to use cs-studio Scan System for scanning output beams from accelerator sources. We need to create two independents scans one for each sources. End users start scan by clicking on BOY action button. Output data from scan need to integrated to a xml file which is used a java program in charge of draw the spectrum plot. I’ve some questions :
 
·         Do I need to create two scan servers ?
·         How to create server ? By copying org.csstudio.scan.server plugin two times rename it like this org.csstudio.scan.server.source1 and   org.csstudio.scan.server.source2. After that configure each server and export it as eclipse product.
·         Is it possible to create scan commands by code and ask to scan server to execute commands ?
·         How to call scans by end user BOY interface ? Python script which call java program created with java scan system API or Jython script ?
Thank you.
 
<image001.jpg>
 

Préservons notre environnement, n’imprimez ce mail que si nécessaire.
Preserve our environment, print this email only if necessary.

<Charles-Henry PATARD.vcf>

Attachment: smime.p7s
Description: S/MIME cryptographic signature


References:
How to cs-studio Scan System Patard Charles-Henri

Navigate by Date:
Prev: RE: How to cs-studio Scan System Patard Charles-Henri
Next: RE: How to cs-studio Scan System Crisp, Daniel
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: How to cs-studio Scan System Patard Charles-Henri
Next: RE: How to cs-studio Scan System Crisp, Daniel
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·