Esempio n. 1
0
def main():
    logger = start_logger()

    # rcl = redis.Redis(host='redis')
    rcl = redis.Redis()
    logger.info("Redis connection opened.")

    japc = pyjapc.PyJapc(incaAcceleratorName=None)
    logger.info("PyJAPC initialised.")


    def broker_psus(name, values):
        psus = PSU_GUN if CRIO_GUN in name else PSU_HV
        timestamp = datetime.datetime.now(TZ).isoformat()
        with rcl.pipeline(transaction=True) as pipe:
            for psu in psus:
                name = psu["name"]
                val = values[psu["id"]]
                pipe.lpush(f"psu:{name}:iread:val", val)
                pipe.lpush(f"psu:{name}:iread:t", timestamp)
                pipe.ltrim(f"psu:{name}:iread:val", 0, BUFFERLEN-1)
                pipe.ltrim(f"psu:{name}:iread:t", 0, BUFFERLEN-1)
                logger.info(f"Queued push to psu:{name}:*")
            pipe.execute()
            logger.info(f"Push to psu:{name}:* executed.")

    def broker_gauges(name, values):
        if CRIO_HV in name:
            gauges = GAUGES_HV
        else:
            raise NotImplementedError
        timestamp = datetime.datetime.now(TZ).isoformat()
        with rcl.pipeline(transaction=True) as pipe:
            for gauge in gauges:
                name = gauge["name"]
                val = values[gauge["channel"]]
                pipe.lpush(f"gauge:{name}:val", val)
                pipe.lpush(f"gauge:{name}:t", timestamp)
                pipe.ltrim(f"gauge:{name}:val", 0, BUFFERLEN-1)
                pipe.ltrim(f"gauge:{name}:t", 0, BUFFERLEN-1)
                logger.info(f"Queued push to gauge:{name}:*")
            pipe.execute()
            logger.info(f"Push to gauge:{name}:* executed.")

    japc.subscribeParam(f"{CRIO_HV}/PSU_all_values#I_read", broker_psus)
    logger.info(f"Subscribed to {CRIO_HV}/PSU_all_values#I_read")

    japc.subscribeParam(f"{CRIO_GUN}/PSU_all_values#I_read", broker_psus)
    logger.info(f"Subscribed to {CRIO_GUN}/PSU_all_values#I_read")

    japc.subscribeParam(f"{CRIO_HV}/Gauge_Levels", broker_gauges)
    logger.info(f"Subscribed to {CRIO_HV}/Gauge_Levels")

    japc.startSubscriptions()
    logger.info("Subscriptions started.")

    while True:
        input()
Esempio n. 2
0
    def initiate_JAPC(self,log=50):
            """

            Initialisation of the pyJAPC module. 

            Input:

            log : (default 50): The log level of the pyjapc module.


            """

            
            japc=pyjapc.PyJapc(selector=self.japc_selector,
                               incaAcceleratorName=self.INCA_ACCEL,noSet=self.simulate_SET,logLevel=log) 
        
            self.japc=japc
Esempio n. 3
0
import vxi11
import pyjapc
import numpy as np
import datetime

######### general settings and I/O
folder_name = "x_scan_y=0"  # must not exist in the scope !!!
samples_per_acqusition = 15
mode = "HIRES"

x_steps = [3000, 10000, 20000, 25000, 30000, 40000, 50000]
y_steps = 0 * np.ones(len(x_steps))  #25700
assert len(x_steps) == len(y_steps)

######### JAPC init
japc = pyjapc.PyJapc(noSet=False)
japc.setSelector(" ")

######### setup setings
x_motor = "CA.TEST.MPHYTRON2"
y_motor = "CA.TEST.MPHYTRON1"


def motor_goto(motor_name, step_position, motion_mode='Absolute'):
    '''
	Send the motor to the destination:
	mode = Absolute, Relative
	units=1 means motor steps
	'''
    mode = int(2)  #default
    units = int(2)
Esempio n. 4
0
    def initJAPC(self):

        self.japc = pyjapc.PyJapc("SPS.USER.AWAKE1")
# -*- coding: utf-8 -*-
"""
spectrometer_quadrupole.py

This script controls the quadrupole magnets that is part of the electron spectrometer in the AWAKE experiment 
at CERN. Developed by James Chappell: [email protected]
"""

import pyjapc
import numpy as np
import matplotlib.pyplot as plt
from time import sleep
import argparse
import pylogbook

japc = pyjapc.PyJapc('SPS.USER.ALL')
japc.rbacLogin(username='******', password='******')
japc.rbacGetToken()


def quadrupole_turn_on(current):
    """ 
    This function turns on the UCL AWAKE Spectrometer dipole to the settings 
    given by the input arguments.
    
    Arguments:
        
        - current           This is the value of the current that the quadrupole 
                            should be set to. It is measured in Amps [A].
                    
                            
Esempio n. 6
0
to an AWAKE Virtual Variable device.

In this example, we get our data from the BCTF and republish in the 
AWAKE-GUI-SUPPORT device

@author: sgess
"""
#%% Import PyJapc and declare devices
import pyjapc
import numpy as np

my_data_source = 'TT41.BCTF.412340/Acquisition#totalIntensityPreferred'
my_virtual_device = 'TSG41.AWAKE-GUI-SUPPORT'

#%% Initialize PyJapc
japc = pyjapc.PyJapc('SPS.USER.AWAKE1')

#%% Set variable names (you only have to do this once)
nameList = [''] * 100
nameList[0] = 'Timestamp'
nameList[1] = 'BCTF Data'
japc.setParam(my_virtual_device + '/NameSettings#nameValue', nameList)


#%% Declare call back function
def myCallbackFunction(paramName, paramValue, header):

    timeStamp = header['acqStamp']

    print(paramName + ' = ' + '{:0.2f}'.format(paramValue))
    print('Timestamp = ' + str(timeStamp))