Exemplo n.º 1
0
def test_p201_hdf5():
    chain = AcquisitionChain()
    p201_device = P201()
    p201_device.request_exclusive_access()
    p201_device.disable_interrupts()
    p201_device.reset()
    p201_device.software_reset()
    p201_device.reset_FIFO_error_flags()
    p201_device.enable_interrupts(100)
    p201_device.set_clock(Clock.CLK_100_MHz)
    p201_master = P201AcquisitionMaster(p201_device,
                                        nb_points=10,
                                        acq_expo_time=50e-6)
    p201_counters = P201AcquisitionDevice(p201_device,
                                          nb_points=10,
                                          acq_expo_time=50e-6,
                                          channels={
                                              "c0": 1,
                                              "c1": 2,
                                              "timer": 11
                                          })
    chain.add(p201_master, p201_counters)
    hdf5_writer = hdf5.Writer(root_path='/tmp')
    toto = Container('toto')
    scan = Scan(chain, name='test_acq', parent=toto, writer=hdf5_writer)
    scan.run()
Exemplo n.º 2
0
def test_lima_basler():
    config = beacon_get_config()
    m0 = config.get("bcumot2")
    m0.velocity(360)
    m0.acceleration(720)

    chain = AcquisitionChain()
    nb_points = 4
    emotion_master = SoftwarePositionTriggerMaster(m0,
                                                   0,
                                                   360,
                                                   nb_points,
                                                   time=1)
    tango_host = "lid00limax:20000"
    lima_dev = DeviceProxy("//%s/id00/limaccds/basler_bcu" % tango_host)
    params = {
        "acq_nb_frames": nb_points,
        "acq_expo_time": 10e-3,
        "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI"
    }
    lima_acq_dev = LimaAcquisitionMaster(lima_dev, **params)
    chain.add(emotion_master, lima_acq_dev)

    hdf5_writer = hdf5.Writer(root_path='/tmp')
    toto = Container('test_lima_basler')
    scan = Scan(chain, name='test_acq', parent=toto, writer=hdf5_writer)

    scan.run()
Exemplo n.º 3
0
def test_p201():
    #import logging; logging.basicConfig(level=logging.DEBUG)

    chain = AcquisitionChain()
    p201_device = P201()
    p201_device.request_exclusive_access()
    p201_device.set_interrupts()
    p201_device.reset()
    p201_device.software_reset()
    p201_device.reset_FIFO_error_flags()
    p201_device.set_clock(Clock.CLK_100_MHz)
    p201_master = P201AcquisitionMaster(p201_device,
                                        nb_points=100000,
                                        acq_expo_time=50e-6)
    p201_counters = P201AcquisitionDevice(p201_device,
                                          nb_points=100000,
                                          acq_expo_time=50e-6,
                                          channels={
                                              "c0": 1,
                                              "c1": 2,
                                              "timer": 11
                                          })
    chain.add(p201_master, p201_counters)
    scan = Scan(chain)
    scan.run()
Exemplo n.º 4
0
def test_lima():
  config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

  emotion.load_cfg_fromstring(config_xml)
  m0 = emotion.get_axis("m0")

  def cb(*args, **kwargs):
    print args, kwargs

  chain = AcquisitionChain()
  emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 10, time=5)
  lima_dev = DeviceProxy("id30a3/limaccd/simulation")
  params = { "acq_nb_frames": 10,
             "acq_expo_time": 3/10.0,
             "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI" }
  lima_acq_dev = LimaAcquisitionDevice(lima_dev, **params)
  dispatcher.connect(cb, sender=lima_acq_dev) 
  chain.add(emotion_master, lima_acq_dev)
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
  m0.wait_move()
  print m0.velocity()==10 
Exemplo n.º 5
0
def test_lima():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    emotion.load_cfg_fromstring(config_xml)
    m0 = emotion.get_axis("m0")

    def cb(*args, **kwargs):
        print args, kwargs

    chain = AcquisitionChain()
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 10, time=5)
    lima_dev = DeviceProxy("id30a3/limaccd/simulation")
    params = {
        "acq_nb_frames": 10,
        "acq_expo_time": 3 / 10.0,
        "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI"
    }
    lima_acq_dev = LimaAcquisitionMaster(lima_dev, **params)
    dispatcher.connect(cb, sender=lima_acq_dev)
    chain.add(emotion_master, lima_acq_dev)
    scan = Scan(chain)
    scan.run()
    m0.wait_move()
    print m0.velocity() == 10
Exemplo n.º 6
0
def test_dm_lima():
  config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

  emotion.load_cfg_fromstring(config_xml)
  m0 = emotion.get_axis("m0")

  chain = AcquisitionChain()
  emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 5, time=5)
  lima_dev = DeviceProxy("id30a3/limaccd/simulation")
  params = { "acq_nb_frames": 5,
             "acq_expo_time": 3/10.0,
             "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI" }
  lima_acq_dev = LimaAcquisitionDevice(lima_dev, **params)
  chain.add(emotion_master, lima_acq_dev)
  toto = Container('toto')
  dm = ScanRecorder('test_acq', toto)
  scan = Scan(chain, dm)
  scan.prepare()
  scan.start()
Exemplo n.º 7
0
def test_emotion_p201():
  config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

  emotion.load_cfg_fromstring(config_xml)
  m0 = emotion.get_axis("m0")
  emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 5, time=1)
  chain = AcquisitionChain()

  p201_device = P201()
  p201_device.request_exclusive_access()
  p201_device.disable_interrupts()
  p201_device.reset()
  p201_device.software_reset()
  p201_device.reset_FIFO_error_flags()
  p201_device.enable_interrupts(100)
  p201_device.set_clock(Clock.CLK_100_MHz)
  p201_master = P201AcquisitionMaster(p201_device,nb_points=10,acq_expo_time=1e-3)
  p201_counters = P201AcquisitionDevice(p201_device,nb_points=10,acq_expo_time=1e-3,
                                        channels={"c0":1,"c1":2})
  chain.add(emotion_master, p201_master)
  chain.add(p201_master,p201_counters)
  chain._tree.show()
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
Exemplo n.º 8
0
def test_dm_lima():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    emotion.load_cfg_fromstring(config_xml)
    m0 = emotion.get_axis("m0")

    chain = AcquisitionChain()
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 5, time=5)
    lima_dev = DeviceProxy("id30a3/limaccd/simulation")
    params = {
        "acq_nb_frames": 5,
        "acq_expo_time": 3 / 10.0,
        "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI"
    }
    lima_acq_dev = LimaAcquisitionMaster(lima_dev, **params)
    chain.add(emotion_master, lima_acq_dev)

    toto = Container('toto')
    scan = Scan(chain, name='test_acq', parent=toto)

    scan.run()
Exemplo n.º 9
0
def test2():
    chain = AcquisitionChain()
    musst_master = TestAcquisitionMaster("musst")
    p201_master = TestAcquisitionMaster("P201")
    p201_acq_dev = TestAcquisitionDevice("P201")
    chain.add(musst_master, p201_master)
    chain.add(p201_master, p201_acq_dev)
    chain._tree.show()

    scan = Scan(chain)
    scan.run()
Exemplo n.º 10
0
def test2():
  chain = AcquisitionChain()
  musst_master = TestAcquisitionMaster("musst")
  p201_master = TestAcquisitionMaster("P201")
  p201_acq_dev = TestAcquisitionDevice("P201")
  chain.add(musst_master, p201_master)
  chain.add(p201_master, p201_acq_dev)
  chain._tree.show()
  
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
Exemplo n.º 11
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--log-level', type=str, default='info',
                        help='log level (debug, info, warning, error) [default: info]')
    parser.add_argument('--nb-points', type=int,
                        help='number of points [default: 1000]', default=1000)
    parser.add_argument('--acq-time', type=float, default=1e-3,
                        help='acquisition time [default: 0.001]')
    parser.add_argument('--p201', type=str, default="p201",
                        help='P201 card configuration name [default: p201]')

    args = parser.parse_args()

    logging.basicConfig(level=getattr(logging, args.log_level.upper()),
                        format="%(asctime)s %(levelname)s %(name)s: %(message)s")

    nb_points = args.nb_points
    acq_time = args.acq_time

    config = static.get_config()

    p201 = config.get(args.p201)
    p201_config = config.get_config(args.p201)

    channels = {}
    for counter in p201_config.get("counters", []):
        addr = counter['address']
        enabled = counter.get('software enable', False)
        # skip internal masters and disabled channels
        if addr >= p201.COUNTERS[-2] or not enabled:
          continue
        name = counter.get('name', "c%d" % addr)
        channels[name] = addr

    print "The following counters (which have software enable=True) will be used: ",
    print ", ".join(sorted(channels.keys()))

    p201_master = P201AcquisitionMaster(p201, nb_points=nb_points,
                                        acq_expo_time=acq_time)
    p201_counters = P201AcquisitionDevice(p201, nb_points=nb_points,
                                          acq_expo_time=acq_time,
                                          channels=channels)
    chain = AcquisitionChain()
    chain.add(p201_master, p201_counters)
    scan = Scan(chain, ScanRecorder())
    chain._tree.show()
    print("Prepare")
    scan.prepare()
    print("Start!")
    t = time.time()
    scan.start()
    dt = time.time() - t
    print("Finished (took %fs)!" % dt)
Exemplo n.º 12
0
def energyscan(start, end, npoints):
    mstart = energy.controller.calc_to_real(start)
    mend = energy.controller.calc_to_real(end)
    delta = abs(mend - mstart) / float(npoints) * mono.encoder.steps_per_unit
    mdelta = int(delta / mono.encoder.steps_per_unit)
    npoints = (delta * npoints / int(delta)) - 1

    chain = AcquisitionChain()

    musst_acq_dev = MusstAcquisitionDevice(
        musst,
        program="monoscan.mprg",
        store_list=["timer", "ch2", "ch3"],
        vars={
            "e1": mstart * mono.encoder.steps_per_unit,
            "e2": mend * mono.encoder.steps_per_unit,
            "de": mdelta,
            "monoangle": mono.position() * mono.encoder.steps_per_unit,
            "npoints": npoints
        })

    master = MotorMaster(mono, start, end)
    # in this case, prepare can be done in parallel, is it always the case?
    # if yes, the code can be optimized
    chain.add(master, musst_acq_dev)

    cscan = Scan(DataManager())
    cscan.set_acquisition_chain(chain)
    cscan.prepare()

    return cscan.start()
Exemplo n.º 13
0
def test():
    chain = AcquisitionChain()
    mono_master = TestAcquisitionMaster("mono")
    cam1_dev = TestAcquisitionDevice("cam1")
    cam1_master = TestAcquisitionMaster("cam1")
    cam2_dev = TestAcquisitionDevice("cam2")
    timer_master = TestAcquisitionMaster("timer")
    c0_dev = TestAcquisitionDevice("c0")
    c1_dev = TestAcquisitionDevice("c1")
    chain.add(mono_master, cam1_dev)
    chain.add(mono_master, cam1_master)
    chain.add(cam1_master, cam2_dev)
    chain.add(timer_master, c0_dev)
    chain.add(timer_master, c1_dev)
    chain._tree.show()

    scan = Scan(chain)
    scan.run()
Exemplo n.º 14
0
def test():
  chain = AcquisitionChain()
  mono_master = TestAcquisitionMaster("mono")
  cam1_dev = TestAcquisitionDevice("cam1")
  cam1_master = TestAcquisitionMaster("cam1")
  cam2_dev = TestAcquisitionDevice("cam2")
  timer_master = TestAcquisitionMaster("timer")
  c0_dev = TestAcquisitionDevice("c0")
  c1_dev = TestAcquisitionDevice("c1")
  chain.add(mono_master, cam1_dev)
  chain.add(mono_master,cam1_master)
  chain.add(cam1_master, cam2_dev)
  chain.add(timer_master, c0_dev)
  chain.add(timer_master, c1_dev)
  chain._tree.show()
  
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
Exemplo n.º 15
0
def test_p201():
  #import logging; logging.basicConfig(level=logging.DEBUG)

  chain = AcquisitionChain()
  p201_device = P201()
  p201_device.request_exclusive_access()
  p201_device.disable_interrupts()
  p201_device.reset()
  p201_device.software_reset()
  p201_device.reset_FIFO_error_flags()
  p201_device.enable_interrupts(100)
  p201_device.set_clock(Clock.CLK_100_MHz)
  p201_master = P201AcquisitionMaster(p201_device,nb_points=100000,acq_expo_time=50e-6)
  p201_counters = P201AcquisitionDevice(p201_device,nb_points=100000,acq_expo_time=50e-6,
                                        channels={"c0":1,"c1":2,"timer":11})
  chain.add(p201_master,p201_counters)
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
Exemplo n.º 16
0
def test_emotion_p201():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    emotion.load_cfg_fromstring(config_xml)
    m0 = emotion.get_axis("m0")
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 5, time=1)
    chain = AcquisitionChain()

    p201_device = P201()
    p201_device.request_exclusive_access()
    p201_device.set_interrupts()
    p201_device.reset()
    p201_device.software_reset()
    p201_device.reset_FIFO_error_flags()
    p201_device.set_clock(Clock.CLK_100_MHz)
    p201_master = P201AcquisitionMaster(p201_device,
                                        nb_points=10,
                                        acq_expo_time=1e-3)
    p201_counters = P201AcquisitionDevice(p201_device,
                                          nb_points=10,
                                          acq_expo_time=1e-3,
                                          channels={
                                              "c0": 1,
                                              "c1": 2
                                          })
    chain.add(emotion_master, p201_master)
    chain.add(p201_master, p201_counters)
    chain._tree.show()
    scan = Scan(chain)
    scan.run()
Exemplo n.º 17
0
def energyscan(start,end,npoints):
  mstart = energy.controller.calc_to_real(start)
  mend = energy.controller.calc_to_real(end)
  delta = abs(mend - mstart)/float(npoints)*mono.encoder.steps_per_unit
  mdelta = int(delta/mono.encoder.steps_per_unit)
  npoints = (delta*npoints/int(delta)) - 1 

  chain = AcquisitionChain()
 
  musst_acq_dev = MusstAcquisitionDevice(musst, 
                                         program = "monoscan.mprg", 
                                         store_list = ["timer","ch2","ch3"],
                                         vars = {"e1": mstart * mono.encoder.steps_per_unit, 
                                                 "e2": mend * mono.encoder.steps_per_unit, 
                                                 "de": mdelta, 
                                                 "monoangle": mono.position() * mono.encoder.steps_per_unit,
                                                 "npoints": npoints})

  master = MotorMaster(mono, start, end)
  # in this case, prepare can be done in parallel, is it always the case?
  # if yes, the code can be optimized
  chain.add(master, musst_acq_dev)

  cscan = Scan(DataManager())
  cscan.set_acquisition_chain(chain)
  cscan.prepare()
  
  return cscan.start()
Exemplo n.º 18
0
def test_emotion_master():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    emotion.load_cfg_fromstring(config_xml)
    m0 = emotion.get_axis("m0")

    chain = AcquisitionChain()
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7)
    test_acq_dev = TestAcquisitionDevice("c0", 0)
    chain.add(emotion_master, test_acq_dev)
    scan = Scan(chain)
    scan.run()
Exemplo n.º 19
0
def test_emotion_master():
  config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

  emotion.load_cfg_fromstring(config_xml)
  m0 = emotion.get_axis("m0")
 
  chain = AcquisitionChain()
  emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7)
  test_acq_dev = TestAcquisitionDevice("c0", 0)
  chain.add(emotion_master, test_acq_dev)
  scan = Scan(chain, ScanRecorder())
  scan.prepare()
  scan.start()
Exemplo n.º 20
0
def test_sps():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
    <axis name="m1">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="1"/>
      <acceleration value="10"/>
    </axis>
    <axis name="m2">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    load_cfg_fromstring(config_xml)
    m0 = get_axis("m0")

    chain = AcquisitionChain()
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7, time=1)
    c0_dev = TestAcquisitionDevice("c0")
    c1_dev = TestAcquisitionDevice("c1")
    chain.add(emotion_master, c0_dev)
    chain.add(emotion_master, c1_dev)
    chain._tree.show()

    session_cnt = Container('sps_test')
    recorder = ScanRecorder('test_scan', session_cnt)
    scan = Scan(chain, recorder)
    scan.prepare()
    scan.start()
Exemplo n.º 21
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        '--log-level',
        type=str,
        default='info',
        help='log level (debug, info, warning, error) [default: info]')

    parser.add_argument('--axis',
                        type=str,
                        default="m0",
                        help='emotion axis configuration name [default: m0]')
    parser.add_argument('--axis-nb-points',
                        type=int,
                        default=5,
                        help='number of points to trigger [default: 5]')
    parser.add_argument('--axis-time', type=float, default=0,
                        help='motion time (s) (excluding acceleration and ' \
                             'deceleration) [default: use currently ' \
                             ' configured velocity]')
    parser.add_argument('--axis-start-pos',
                        type=float,
                        default=0,
                        help='axis start position [default: 0]')
    parser.add_argument('--axis-stop-pos',
                        type=float,
                        default=100,
                        help='axis stop position [default: 100]')

    parser.add_argument('--p201',
                        type=str,
                        default="p201",
                        help='P201 card configuration name [default: p201]')
    parser.add_argument('--p201-nb-points',
                        type=int,
                        help='number of points [default: 10]',
                        default=10)
    parser.add_argument('--p201-acq-time',
                        type=float,
                        default=1e-3,
                        help='acquisition time (s) [default: 0.001]')

    args = parser.parse_args()

    logging.basicConfig(
        level=getattr(logging, args.log_level.upper()),
        format="%(asctime)s %(levelname)s %(name)s: %(message)s")

    config = static.get_config()

    axis = config.get(args.axis)
    p201 = config.get(args.p201)
    p201_config = config.get_config(args.p201)

    channels = {}
    for counter in p201_config.get("counters", []):
        addr = counter['address']
        enabled = counter.get('software enable', False)
        # skip internal masters and disabled channels
        if addr >= p201.COUNTERS[-2] or not enabled:
            continue
        name = counter.get('name', "c%d" % addr)
        channels[name] = addr

    emotion_master = SoftwarePositionTriggerMaster(axis,
                                                   args.axis_start_pos,
                                                   args.axis_stop_pos,
                                                   args.axis_nb_points,
                                                   time=args.axis_time)
    chain = AcquisitionChain()

    p201_master = P201AcquisitionMaster(p201,
                                        nb_points=args.p201_nb_points,
                                        acq_expo_time=args.p201_acq_time)
    p201_counters = P201AcquisitionDevice(p201,
                                          nb_points=args.p201_nb_points,
                                          acq_expo_time=args.p201_acq_time,
                                          channels=channels)

    chain.add(emotion_master, p201_master)
    chain.add(p201_master, p201_counters)
    chain._tree.show()
    scan = Scan(chain, ScanRecorder())
    print("Prepare")
    scan.prepare()
    print("Start!")
    t = time.time()
    scan.start()
    dt = time.time() - t
    print("Finished (took %fs)!" % dt)
Exemplo n.º 22
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "--log-level", type=str, default="info", help="log level (debug, info, warning, error) [default: info]"
    )

    parser.add_argument("--axis", type=str, default="m0", help="emotion axis configuration name [default: m0]")
    parser.add_argument("--axis-nb-points", type=int, default=5, help="number of points to trigger [default: 5]")
    parser.add_argument(
        "--axis-time",
        type=float,
        default=0,
        help="motion time (s) (excluding acceleration and "
        "deceleration) [default: use currently "
        " configured velocity]",
    )
    parser.add_argument("--axis-start-pos", type=float, default=0, help="axis start position [default: 0]")
    parser.add_argument("--axis-stop-pos", type=float, default=100, help="axis stop position [default: 100]")

    parser.add_argument("--p201", type=str, default="p201", help="P201 card configuration name [default: p201]")
    parser.add_argument("--p201-nb-points", type=int, help="number of points [default: 10]", default=10)
    parser.add_argument("--p201-acq-time", type=float, default=1e-3, help="acquisition time (s) [default: 0.001]")

    args = parser.parse_args()

    logging.basicConfig(
        level=getattr(logging, args.log_level.upper()), format="%(asctime)s %(levelname)s %(name)s: %(message)s"
    )

    config = static.get_config()

    axis = config.get(args.axis)
    p201 = config.get(args.p201)
    p201_config = config.get_config(args.p201)

    channels = {}
    for counter in p201_config.get("counters", []):
        addr = counter["address"]
        enabled = counter.get("software enable", False)
        # skip internal masters and disabled channels
        if addr >= p201.COUNTERS[-2] or not enabled:
            continue
        name = counter.get("name", "c%d" % addr)
        channels[name] = addr

    emotion_master = SoftwarePositionTriggerMaster(
        axis, args.axis_start_pos, args.axis_stop_pos, args.axis_nb_points, time=args.axis_time
    )
    chain = AcquisitionChain()

    p201_master = P201AcquisitionMaster(p201, nb_points=args.p201_nb_points, acq_expo_time=args.p201_acq_time)
    p201_counters = P201AcquisitionDevice(
        p201, nb_points=args.p201_nb_points, acq_expo_time=args.p201_acq_time, channels=channels
    )

    chain.add(emotion_master, p201_master)
    chain.add(p201_master, p201_counters)
    chain._tree.show()
    scan = Scan(chain, ScanRecorder())
    print("Prepare")
    scan.prepare()
    print("Start!")
    t = time.time()
    scan.start()
    dt = time.time() - t
    print("Finished (took %fs)!" % dt)
Exemplo n.º 23
0
def test_step_cont():
    config_xml = """
<config>
  <controller class="mockup">
    <axis name="m0">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
    <axis name="m1">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="1"/>
      <acceleration value="10"/>
    </axis>
    <axis name="m2">
      <steps_per_unit value="10000"/>
      <!-- degrees per second -->
      <velocity value="10"/>
      <acceleration value="100"/>
    </axis>
  </controller>
</config>"""

    load_cfg_fromstring(config_xml)
    m0 = get_axis("m0")
    m1 = get_axis("m1")
    m2 = get_axis("m2")

    ascan = AcquisitionChain(parallel_prepare=True)
    ascan_mot = LinearStepTriggerMaster(11, m0, 10, 20)
    timer = SoftwareTimerMaster(0.1)
    ascan.add(ascan_mot, timer)
    test_acq_dev = TestAcquisitionDevice("timer_test",
                                         2,
                                         prepare_once=True,
                                         start_once=True)
    ascan.add(timer, test_acq_dev)
    test2_acq_dev = TestAcquisitionDevice("timer_test2",
                                          2,
                                          prepare_once=True,
                                          start_once=True)
    ascan.add(timer, test2_acq_dev)
    step_scan = Container('step_scan')
    scan = Scan(chain)
    scan.run()

    chain = AcquisitionChain(parallel_prepare=True)

    step_master = MeshStepTriggerMaster(m1,
                                        -2,
                                        2,
                                        5,
                                        m2,
                                        -5,
                                        5,
                                        3,
                                        backnforth=True)
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7, time=1)
    chain.add(step_master, emotion_master)
    chain.add(emotion_master, test_acq_dev)
    scan = Scan(chain, name='super_zap_image', parent=step_scan)
    scan.run()

    print "next scan"
    chain = AcquisitionChain()
    emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7)
    test_acq_dev = TestAcquisitionDevice("super_mario", 0)
    chain.add(emotion_master, test_acq_dev)
    scan = Scan(chain, name='soft_zapline', parent=step_scan)
    scan.run()
Exemplo n.º 24
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        '--log-level',
        type=str,
        default='info',
        help='log level (debug, info, warning, error) [default: info]')
    parser.add_argument('--nb-points',
                        type=int,
                        help='number of points [default: 1000]',
                        default=1000)
    parser.add_argument('--acq-time',
                        type=float,
                        default=1e-3,
                        help='acquisition time [default: 0.001]')
    parser.add_argument('--p201',
                        type=str,
                        default="p201",
                        help='P201 card configuration name [default: p201]')

    args = parser.parse_args()

    logging.basicConfig(
        level=getattr(logging, args.log_level.upper()),
        format="%(asctime)s %(levelname)s %(name)s: %(message)s")

    nb_points = args.nb_points
    acq_time = args.acq_time

    config = static.get_config()

    p201 = config.get(args.p201)
    p201_config = config.get_config(args.p201)

    channels = {}
    for counter in p201_config.get("counters", []):
        addr = counter['address']
        enabled = counter.get('software enable', False)
        # skip internal masters and disabled channels
        if addr >= p201.COUNTERS[-2] or not enabled:
            continue
        name = counter.get('name', "c%d" % addr)
        channels[name] = addr

    print "The following counters (which have software enable=True) will be used: ",
    print ", ".join(sorted(channels.keys()))

    p201_master = P201AcquisitionMaster(p201,
                                        nb_points=nb_points,
                                        acq_expo_time=acq_time)
    p201_counters = P201AcquisitionDevice(p201,
                                          nb_points=nb_points,
                                          acq_expo_time=acq_time,
                                          channels=channels)
    chain = AcquisitionChain()
    chain.add(p201_master, p201_counters)
    scan = Scan(chain, ScanRecorder())
    chain._tree.show()
    print("Prepare")
    scan.prepare()
    print("Start!")
    t = time.time()
    scan.start()
    dt = time.time() - t
    print("Finished (took %fs)!" % dt)