def setUp(self):
        self.p = Process('process1')
        self.context = Context(self.p)

        # Make a ticker_block block to act as our child
        for c in ticker_block(mri="childBlock", config_dir="/tmp"):
            self.p.add_controller(c)
        self.b_child = self.context.block_view("childBlock")

        # Make an empty part for our parent
        part1 = Part("part1")

        # Make a RunnableChildPart to control the ticker_block
        part2 = RunnableChildPart(mri='childBlock',
                                  name='part2',
                                  initial_visibility=True)

        # create a root block for the RunnableController block to reside in
        self.c = RunnableController(mri='mainBlock', config_dir="/tmp")
        self.c.add_part(part1)
        self.c.add_part(part2)
        self.p.add_controller(self.c)
        self.b = self.context.block_view("mainBlock")
        self.ss = self.c.state_set

        # start the process off
        self.checkState(self.ss.DISABLED)
        self.p.start()
        self.checkState(self.ss.READY)
Example #2
0
 def setUp(self):
     self.p = Process("process1")
     self.context = Context(self.p)
     self.c1 = RunnableController(mri="SYS", config_dir="/tmp")
     self.tmp_dir = f"/tmp/{now}-{os.getpid()}"
     os.mkdir(self.tmp_dir)
     os.mkdir(self.tmp_dir + "/configure")
Example #3
0
 def test_init(self):
     c = RunnableController("mri", "/tmp")
     c.add_part(self.o)
     self.process.add_controller(c)
     b = c.block_view()
     assert list(b.configure.takes.elements) == [
         'generator', 'fileDir', 'axesToMove', 'formatName', 'fileTemplate'
     ]
Example #4
0
 def setUp(self):
     self.o = SimultaneousAxesPart(value=["x", "y"])
     self.process = Process("proc")
     self.process.start()
     self.addCleanup(self.process.stop, 2)
     c = RunnableController("mri", "/tmp")
     c.add_part(self.o)
     self.process.add_controller(c)
     self.b = c.block_view()
Example #5
0
 def setUp(self):
     self.o = UnrollingPart(name="Unroll")
     self.process = Process("proc")
     self.process.start()
     self.addCleanup(self.process.stop, 2)
     c = RunnableController("mri", "/tmp")
     c.add_part(self.o)
     self.process.add_controller(c)
     self.b = c.block_view()
Example #6
0
 def setUp(self):
     self.p = Process("process1")
     self.context = Context(self.p)
     self.c1 = RunnableController(mri="SYS",
                                  config_dir="/tmp",
                                  use_git=False)
     self.tmp_dir = "/tmp/%s-%s" % (now, os.getpid())
     os.mkdir(self.tmp_dir)
     os.mkdir(self.tmp_dir + "/configure")
    def setUp(self):
        self.p = Process('process1')
        self.context = Context(self.p)

        # Make a fast child, this will load the wait of 0.01 from saved file
        c1 = RunnableController(mri="fast",
                                config_dir=DESIGN_PATH,
                                use_git=False,
                                initial_design="fast")
        c1.add_part(WaitingPart("wait"))
        self.p.add_controller(c1)

        # And a slow one, this has the same saved files as fast, but doesn't
        # load at startup
        c2 = RunnableController(mri="slow",
                                config_dir=DESIGN_PATH,
                                use_git=False)
        c2.add_part(WaitingPart("wait", 0.123))
        self.p.add_controller(c2)

        # And a top level one, this loads slow and fast designs for the
        # children on every configure (or load), but not at init
        c3 = RunnableController(mri="top",
                                config_dir=DESIGN_PATH,
                                use_git=False,
                                initial_design="default")
        c3.add_part(
            RunnableChildPart(name="FAST", mri="fast",
                              initial_visibility=True))
        c3.add_part(
            RunnableChildPart(name="SLOW", mri="slow",
                              initial_visibility=True))
        self.p.add_controller(c3)

        # Some blocks to interface to them
        self.b = self.context.block_view("top")
        self.bf = self.context.block_view("fast")
        self.bs = self.context.block_view("slow")

        # start the process off
        self.p.start()
Example #8
0
 def setUp(self):
     self.o = UnrollingPart(name="Unroll",
                            mri="mri",
                            initial_visibility=True)
     self.process = Process("proc")
     self.process.start()
     self.addCleanup(self.process.stop, 2)
     self.config_dir = tmp_dir("config_dir")
     c = RunnableController("mri", self.config_dir.value)
     c.add_part(self.o)
     self.process.add_controller(c)
     self.b = c.block_view()
Example #9
0
    def setUp(self):
        self.process = Process("Process")
        self.context = Context(self.process)

        # Create a fake PandA with a pulse block
        self.panda = ManagerController("PANDA", "/tmp")
        controller = BasicController("PANDA:PULSE3")
        self.pulse_part = PulsePart("part")
        controller.add_part(self.pulse_part)
        self.process.add_controller(controller)
        self.panda.add_part(
            ChildPart("PULSE3",
                      "PANDA:PULSE3",
                      initial_visibility=True,
                      stateful=False))
        self.process.add_controller(self.panda)

        # And the detector
        self.config_dir = tmp_dir("config_dir")
        for c in detector_block("DET", config_dir=self.config_dir.value):
            self.process.add_controller(c)

        # Make the child block holding panda and pmac mri
        self.child = self.create_child_block(
            panda_pulse_trigger_block,
            self.process,
            mri="SCAN:PULSE",
            panda="PANDA",
            detector="DET",
        )

        # And our part under test
        self.o = PandAPulseTriggerPart("detTrigger", "SCAN:PULSE")

        # Add in a scan block
        self.scan = RunnableController("SCAN", "/tmp")
        self.scan.add_part(DetectorChildPart("det", "DET", True))
        self.scan.add_part(self.o)
        self.process.add_controller(self.scan)

        # Now start the process off and tell the panda which sequencer tables
        # to use
        self.process.start()
        exports = ExportTable.from_rows([
            ("PULSE3.width", "detTriggerWidth"),
            ("PULSE3.step", "detTriggerStep"),
            ("PULSE3.delay", "detTriggerDelay"),
            ("PULSE3.pulses", "detTriggerPulses"),
        ])
        self.panda.set_exports(exports)
        self.tmpdir = tempfile.mkdtemp()
    def setUp(self):
        self.process = Process("test_process")
        self.context = Context(self.process)

        # Create a raw motor mock to handle axis request
        self.child = self.create_child_block(
            raw_motor_block, self.process, mri="BS", pv_prefix="PV:PRE"
        )
        # Add Beam Selector object
        self.o = MotorPreMovePart(name="MotorPreMovePart", mri="BS", demand=50)

        controller = RunnableController("SCAN", "/tmp", use_git=False)
        controller.add_part(self.o)

        self.process.add_controller(controller)
        self.process.start()
 def test_init(self):
     self.o = HDFWriterPart(name="m", mri="BLOCK:HDF5")
     self.context.set_notify_dispatch_request(
         self.o.notify_dispatch_request)
     c = RunnableController("mri", self.config_dir.value)
     c.add_part(self.o)
     self.process.add_controller(c)
     b = c.block_view()
     assert list(b.configure.meta.takes.elements) == [
         "generator",
         "fileDir",
         "axesToMove",
         "breakpoints",
         "formatName",
         "fileTemplate",
     ]
Example #12
0
    def test_real(self):
        c = RunnableController(mri="top", config_dir="/tmp")
        c.add_part(self.o)

        class ValidatePart(Part):
            data = []

            def setup(self, registrar):
                super(ValidatePart, self).setup(registrar)
                self.register_hooked(ValidateHook, self.validate)

            @add_call_types
            def validate(self, part_info):
                # type: (APartInfo) -> None
                self.data.append(part_info)

        c.add_part(ValidatePart("validate"))
        self.process.add_controller(c)
        c.block_view().validate(CompoundGenerator([], [], []))
        assert len(ValidatePart.data) == 1
        assert list(ValidatePart.data[0]) == ["scan"]
        assert len(ValidatePart.data[0]["scan"]) == 1
Example #13
0
    def setUp(self):
        self.p = Process("process1")
        self.context = Context(self.p)

        self.p2 = Process("process2")
        self.context2 = Context(self.p2)

        # Make a motion block to act as our child
        for c in motion_block(mri="childBlock", config_dir="/tmp"):
            self.p.add_controller(c)
        self.b_child = self.context.block_view("childBlock")

        # create a root block for the RunnableController block to reside in
        self.c = RunnableController(mri="mainBlock", config_dir="/tmp")
        self.p.add_controller(self.c)
        self.b = self.context.block_view("mainBlock")
        self.ss = self.c.state_set

        # start the process off
        self.checkState(self.ss.DISABLED)
        self.p.start()
        self.checkState(self.ss.READY)
Example #14
0
    def setUp(self):
        self.p = Process("process")
        self.context = Context(self.p)

        # Make a motion block to act as our child
        for c in motion_block(mri="childBlock", config_dir="/tmp"):
            self.p.add_controller(c)
        self.b_child = self.context.block_view("childBlock")

        part = MisbehavingPart(mri="childBlock",
                               name="part",
                               initial_visibility=True)

        # create a root block for the RunnableController block to reside in
        self.c = RunnableController(mri="mainBlock", config_dir="/tmp")
        self.c.add_part(part)
        self.p.add_controller(self.c)
        self.b = self.context.block_view("mainBlock")
        self.ss = self.c.state_set

        # start the process off
        self.checkState(self.ss.DISABLED)
        self.p.start()
        self.checkState(self.ss.READY)
Example #15
0
    def setUp(self):
        self.p = Process("process1")
        self.context = Context(self.p)

        # Make a fast child, this will load the wait of 0.01 from saved file
        c1 = RunnableController(
            mri="fast", config_dir=DESIGN_PATH, use_git=False, initial_design="fast"
        )
        c1.add_part(WaitingPart("wait"))
        c1.add_part(ExposureDeadtimePart("dt", 0.001))
        c1.add_part(DatasetTablePart("dset"))
        self.p.add_controller(c1)

        # And a slow one, this has the same saved files as fast, but doesn't
        # load at startup
        c2 = RunnableController(mri="slow", config_dir=DESIGN_PATH, use_git=False)
        c2.add_part(WaitingPart("wait", 0.123))
        c2.add_part(DatasetTablePart("dset"))
        self.p.add_controller(c2)

        # And a faulty one, this is hidden at startup by default
        c3 = RunnableController(mri="faulty", config_dir=DESIGN_PATH, use_git=False)
        c3.add_part(FaultyPart("bad"))
        c3.add_part(DatasetTablePart("dset"))
        self.p.add_controller(c3)

        # And a top level one, this loads slow and fast designs for the
        # children on every configure (or load), but not at init
        self.ct = RunnableController(
            mri="top", config_dir=DESIGN_PATH, use_git=False, initial_design="default"
        )
        self.ct.add_part(
            DetectorChildPart(name="FAST", mri="fast", initial_visibility=True)
        )
        self.ct.add_part(
            DetectorChildPart(name="SLOW", mri="slow", initial_visibility=True)
        )
        self.ct.add_part(
            DetectorChildPart(name="BAD", mri="faulty", initial_visibility=False)
        )
        self.ct.add_part(
            DetectorChildPart(
                name="BAD2",
                mri="faulty",
                initial_visibility=False,
                initial_frames_per_step=0,
            )
        )
        self.fast_multi = MaybeMultiPart("fast")
        self.slow_multi = MaybeMultiPart("slow")
        self.ct.add_part(self.fast_multi)
        self.ct.add_part(self.slow_multi)
        self.p.add_controller(self.ct)

        # Some blocks to interface to them
        self.b = self.context.block_view("top")
        self.bf = self.context.block_view("fast")
        self.bs = self.context.block_view("slow")

        # start the process off
        self.p.start()
        self.tmpdir = tempfile.mkdtemp()
Example #16
0
 def setUp(self):
     self.p = Process("process1")
     self.context = Context(self.p)
     self.c1 = RunnableController(mri="SYS", config_dir="/tmp")