Example #1
0
        ['', 2, 'Seconds', 1],
        ['', 3, 'Seconds', 1],
        [4, 1, 'Seconds', 1],
        ['', 2, 'Seconds', 1],
        ['', 3, 'Seconds', 1],
        [5, 1, 'Seconds', 1],
        ['', 2, 'Seconds', 1],
        ['', 3, 'Seconds', 1],
    ],
                      pre=Set('motor_x', 1, completion=True),
                      post=[
                          Set('motor_x', orig_motor_x, completion=True),
                          Set('motor_y', orig_motor_y, completion=True),
                      ],
                      log_always=('neutrons', 'setpoint'))
    cmds = table.createScan()
    try:
        client = ScanClient('localhost', 4810)
        scid = client.submit(cmds, name="2D table scan example")
        client.waitUntilDone(scid)
        print "Number of log calls: %d" % client.lastSerial(scid)

        # get raw data back as a Python dict
        data = client.getData(scid)
        print data

        # Create table for motor_x, motor_y and neutrons
        table = createTable(data, 'motor_x', 'motor_y', 'neutrons', 'setpoint')
        print "Position X: ", table[0]
        print "Position Y: ", table[1]
        print "Counts   : ", table[2]
Example #2
0
    # Custom settings configure the TableScan
    setScanSettings(LocalScanSettings())
    # Create table scan command
    # use function to generate scan range
    table = TableScan(['Comment',     'motor_x',       'motor_y',     'Wait For',   'Value'],
                      [['Example',        '',               '',         '',         ''], 
                       ['',        'range(1, 6, 1)', 'range(1, 4, 1)', 'Seconds',    1],
                       ['',               1,                1,          '',         '']],
                      pre=Set('motor_x', 1, completion=True),
                      post=[Set('motor_x', orig_motor_x, completion=True),
                            Set('motor_y', orig_motor_y, completion=True),],
                      start=Set("neutrons", 0, completion=True, timeout=10),
                      log_always=('neutrons', 'setpoint')
                      )

    cmds = table.createScan()
    try:
        client = ScanClient('localhost', 4810)
        scid = client.submit(cmds, name="2D table scan example")
        client.waitUntilDone(scid)
        print "Number of log calls: %d" % client.lastSerial(scid)
         
        # get raw data back as a Python dict 
        data = client.getData(scid)
        print data
         
        # Create table for motor_x, motor_y and neutrons
        table = createTable(data, 'motor_x', 'motor_y', 'neutrons', 'setpoint')
        print "Position X: ", table[0]
        print "Position Y: ", table[1]
        print "Counts   : ",  table[2]
Example #3
0
# and to treat 'position' as a motor with readback check via *.RBV 
setScanSettings(MyScanSettings())

# Table scan with these settings,
# definition of column headers,
# and rows
table = TableScan(
      ['temperature', 'position'],
    [ [      50,           1],
      [      '',           2],
      [      '',           3],
      [     100,           1],
      [      '',           2],
      [      '',           3],
    ])

# Create scan, print each command
scan = table.createScan()
for cmd in scan:
    print cmd
"""
Result:
Set('temperature', 50.0, completion=True, timeOut=300)
Set('position', 1.0, completion=True, readback='position.RBV', timeOut=100)
Set('position', 2.0, completion=True, readback='position.RBV', timeOut=100)
Set('position', 3.0, completion=True, readback='position.RBV', timeOut=100)
Set('temperature', 100.0, completion=True, timeOut=300)
Set('position', 1.0, completion=True, readback='position.RBV', timeOut=100)
Set('position', 2.0, completion=True, readback='position.RBV', timeOut=100)
Set('position', 3.0, completion=True, readback='position.RBV', timeOut=100)
"""
    def testBadInput(self):
        print("\n=== Bad Input ===")

        # No list of rows, just single row
        with self.assertRaises(Exception) as context:
            table_scan = TableScan(
                (
                    "+p X",
                    "+p Y",
                    "Z",
                    "Wait For",
                    "Value",
                ),
                ["Loop(3)", "", "", "time", "00:01:00"],
            )
        print("Caught: " + str(context.exception))
        self.assertTrue("Table needs list of rows" in str(context.exception))

        # Missing column in rows
        with self.assertRaises(Exception) as context:
            table_scan = TableScan((
                "+p X",
                "+p Y",
                "Z",
                "Wait For",
                "Value",
            ), [
                ["Loop(3)", "", "", "time", "00:01:00"],
                [
                    "Loop(3)",
                    "",
                    "",
                    "time",
                ],
            ])
        print("Caught: " + str(context.exception))
        self.assertTrue("Table has 5 columns but row 1 has only 4" in str(
            context.exception))

        # Missing 'Value' column (either nothing or the wrong column)
        with self.assertRaises(Exception) as context:
            table_scan = TableScan(("+p X", "+p Y", "Z", "Wait For"), [
                [
                    "Loop(3)",
                    "",
                    "",
                    "time",
                ],
            ])
            table_scan.createScan()
        print("Caught: " + str(context.exception))
        self.assertTrue("Wait For column must be followed by Value" in str(
            context.exception))

        with self.assertRaises(Exception) as context:
            table_scan = TableScan((
                "+p X",
                "+p Y",
                "Z",
                "Wait For",
                "ShouldBeValue",
            ), [
                ["Loop(3)", "", "", "time", "00:01:00"],
            ])
            table_scan.createScan()
        print("Caught: " + str(context.exception))
        self.assertTrue("Wait For column must be followed by Value" in str(
            context.exception))
Example #5
0
# and to treat 'position' as a motor with readback check via *.RBV
setScanSettings(MyScanSettings())

# Table scan with these settings,
# definition of column headers,
# and rows
table = TableScan(['temperature', 'position'], [
    [50, 1],
    ['', 2],
    ['', 3],
    [100, 1],
    ['', 2],
    ['', 3],
])

# Create scan, print each command
scan = table.createScan()
for cmd in scan:
    print cmd
"""
Result:
Set('temperature', 50.0, completion=True, timeout=300)
Set('position', 1.0, completion=True, readback='position.RBV', timeout=100)
Set('position', 2.0, completion=True, readback='position.RBV', timeout=100)
Set('position', 3.0, completion=True, readback='position.RBV', timeout=100)
Set('temperature', 100.0, completion=True, timeout=300)
Set('position', 1.0, completion=True, readback='position.RBV', timeout=100)
Set('position', 2.0, completion=True, readback='position.RBV', timeout=100)
Set('position', 3.0, completion=True, readback='position.RBV', timeout=100)
"""