Ejemplo n.º 1
0
def toggle_prescaling():

    create = False
    dbname = 'configDB'
    instrument = 'TMO'
    mycdb = cdb.configdb('mcbrowne:psana@psdb-dev:9306', instrument, create,
                         dbname)
    my_dict = mycdb.get_configuration("BEAM", "tmotimetool")

    top = cdict()
    top.setInfo('timetool', 'tmotimetool', 'serial1234', 'No comment')
    top.setAlg('timetoolConfig', [0, 0, 1])

    #print()

    #################################################################
    cl = TimeToolDev.TimeToolDev(
        dev='/dev/datadev_0',
        dataDebug=False,
        version3=False,
        pollEn=False,
        initRead=False,
        enVcMask=0xD,
    )

    #################################################################

    if (cl.Hardware.PgpMon[0].RxRemLinkReady.get() != 1):
        raise ValueError(f'PGP Link is down')

    #################################################################

    #cl.StartRun()
    #time.sleep(x)
    #cl.StopRun()

    #prescaling = cl.Application.AppLane[0].Prescale.ScratchPad.get()
    prescaling = my_dict['cl']['Application']['AppLane1']['Prescale'][
        'ScratchPad']
    print("old database prescaler value = ", prescaling)
    if (prescaling == 2):
        prescaling = 6
    else:
        prescaling = 2

    cl.Application.AppLane[0].Prescale.ScratchPad.set(prescaling)

    print("new rogue prescaler value = ",
          cl.Application.AppLane[0].Prescale.ScratchPad.get())

    top.set("cl.Application.AppLane1.Prescale.ScratchPad", int(prescaling),
            'UINT32')
    mycdb.modify_device('BEAM', top)

    cl.stop()
Ejemplo n.º 2
0
def get_config_with_params(db_url, instrument, db_name, cfgtype, detname):
    create = False
    mycdb = cdb.configdb(db_url, instrument, create, db_name)
    cfg = mycdb.get_configuration(cfgtype, detname)

    if cfg is None:
        raise ValueError(
            'Config for instrument/detname %s/%s not found. dbase url: %s, db_name: %s, config_style: %s'
            % (instrument, detname, db_url, db_name, cfgtype))

    cfg_no_RO_names = remove_read_only(cfg)

    return cfg_no_RO_names
Ejemplo n.º 3
0
def write_to_daq_config_db(prescaling):

    #database contains collections which are sets of documents (aka json objects).
    #each type of device has a collection.  The elements of that collection are configurations of that type of device.
    #e.g. there will be OPAL, EVR, and YUNGFRAU will be collections.  How they are configured will be a document contained within that collection
    #Each hutch is also a collection.  Documents contained within these collection have an index, alias, and list of devices with configuration IDs
    #How is the configuration of a state is described by the hutch and the alias found.  E.g. TMO and BEAM.  TMO is a collection.  
    #BEAM is an alias of some of the documents in that collection. The document with the matching alias and largest index is the current 
    #configuration for that hutch and alias.  
    #When a device is configured, the device has a unique name OPAL7.  Need to search through document for one that has an NAME called OPAL7.  This will have
    #have two fields "collection" and ID field (note how collection here is a field. ID points to a unique document).  This collection field and 
    #ID point to the actuall Mongo DB collection and document

    create = True
    dbname = 'sioanDB'     #this is the name of the database running on the server.  Only client care about this name.
    instrument = 'TST'      #

    mycdb = cdb.configdb('mcbrowne:psana@psdb-dev:9306', instrument, create, dbname)    #mycdb.client.drop_database('configDB_szTest') will drop the configDB_szTest database
    #mycdb.client.drop_database('sioanDB')
    mycdb.add_alias("BEAM")
    mycdb.add_device_config('timetool')
    
    top = cdict()
    top.setInfo('timetool', 'tmotimetool', 'serial1234', 'No comment')
    top.setAlg('timetoolConfig', [0,0,1])

    #There are many rogue fields, but only a handful need to be configured.  what are they?
    #1)  the FIR coefficients.  after accounting for parabolic fitting detection
    #2)  start and stop?
    #3)  main by pass. (still isn't working with FEX in hardware, but does in simulation.)
    #4)  all prescalers.  This has potential to crash linux kernel during hi rate and low prescaling.  How to add protection?  Slow ramp?
    #5)  low pass on background
    #6)  op code (now called readout group). there's no rogue counter part of this yet.
    #7)  the load coefficients bit needs to set to one for the FIR coefficients to be written.
    #8)  camera rate and soft or hard trigger. The soft trigger is for offline testing.  For users or just for me?
    #9)  the batcher bypass so soft trigger doesn't halt.

    ######################################################################
    ####### Keeping it simple.  Just what Giaccomo will need #############
    ######################################################################

    ########################################
    #####        prescaling          #######
    ########################################
    top.set("cl.Application.AppLane[0].Prescale.ScratchPad",int(prescaling),'UINT32')                     # testing ability to write to database
    top.set("cl.Application.AppLane[0].Prescale.DialInPreScaling",2,'UINT32')                            # prescaled raw data 
    top.set("cl.Application.AppLane[0].Fex.background_prescaler.DialInPreScaling",3,'UINT32')            # prescaled raw backgrounds (may consider accumulated backgrounds instead)
    ########################################
    #####      initial fir filter    #######
    ########################################
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet0","7f7f7f7f",'CHARSTR')                      #high part of step 
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet1","7f7f7f7f",'CHARSTR')                      #high part of step 
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet2","7f7f7f7f",'CHARSTR')                      #high part of step 
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet3","7f7f7f7f",'CHARSTR')                      #high part of step 
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet4","81818181",'CHARSTR')                      #low  part of step
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet5","81818181",'CHARSTR')                      #low  part of step
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet6","81818181",'CHARSTR')                      #low  part of step
    top.set("cl.Application.AppLane[0].Fex.FIR.CoefficientSet7","81818181",'CHARSTR')                      #low  part of step

    top.set("cl.Application.AppLane[0].Fex.FIR.LoadCoefficients","1",'CHARSTR')                             #low  part of step.  Having a value of 1  causes a segfault in pgpread_timetool.cc.  But not in tt_config.py. 

    ########################################
    #####      time constants        #######
    ########################################
    top.set("cl.Application.AppLane[0].Fex.FrameIIR.TimeConstant",8,'UINT32')


    ########################################
    #####      subtraction enabled     #####
    ########################################
    top.set("cl.Application.AppLane[0].Fex.FrameSubtractor.SubtractionActive",0,'UINT32')                   #turn background subtract on


    #the object hierarchy paths (e.g. cl.Application.AppLane[0]... yadayadayada) for a device can be found by implementing
    #pr.generateAddressMap where pr comes from "import rogue as pr".  For this to work, one has to be logged onto the machine hosting the firmware   
    #that interacts with rogue.  This particular register map can be found in the lcls2-pcie-apps directory cloned from https://github.com/slaclab/lcls2-pcie-apps.

    mycdb.modify_device('BEAM', top)
Ejemplo n.º 4
0
from psalg.configdb.typed_json import cdict
import psalg.configdb.configdb as cdb
import os
import io

# these are the current default values, but I put them here to be explicit
create = False
dbname = 'configDB'
instrument = 'TST'

mycdb = cdb.configdb('mcbrowne:psana@psdb-dev:9306', instrument, create,
                     dbname)
print('Configs:')
mycdb.print_configs()
print(70 * '-')
# this needs to be called once per detType at the
# "beginning of time" to create the collection name (same as detType
# in top.setInfo).  It doesn't hurt to call it again if the collection
# already exists, however.
mycdb.add_device_config('hsd')

top = cdict()

top.setInfo('hsd', 'xpphsd', 'serial1234', 'No comment')
top.setAlg('hsdConfig', [0, 0, 1])

# this should be an array of enums, but not yet supported
top.set('enable', 1 * [1], 'UINT32')

top.set('raw.start', 1 * [4], 'UINT32')
top.set('raw.gate', 1 * [20], 'UINT32')
Ejemplo n.º 5
0
def get_configdb(uri_suffix="mcbrowne:psana@psdb-dev:9306", inst='TMO'):
    return configdb(uri_suffix, inst)
Ejemplo n.º 6
0
def get_configdb(uri_suffix="mcbrowne:psana@psdb-dev:9306", inst='TMO'):
    return configdb(uri_suffix, inst)


#--------------------

#confdb = get_configdb()

#--------------------

if __name__ == "__main__":

    # Access the configuration database using:
    #from psalg.configdb.configdb import configdb
    confdb = configdb("mcbrowne:psana@psdb-dev:9306", 'TMO')
    # <psalg.configdb.configdb.configdb at 0x7fab765ebf98>

    # Find the hutches in the database:
    list_of_hutch_names = confdb.get_hutches()  # ['TMO', 'CXI']
    print('list_of_hutch_names:', list_of_hutch_names)

    # Find the aliases in a hutch:
    list_of_alias_names = confdb.get_aliases(hutch='TMO')  # ['NOBEAM', 'BEAM']
    print('list_of_alias_names:', list_of_alias_names)

    # Find the device configurations available for all hutches:
    list_of_device_configuration_names = confdb.get_device_configs()  #['test']
    print('list_of_device_configuration_names:',
          list_of_device_configuration_names)