Example #1
0
    def test_save_config(self):
        controller.subscribe('DEFAULT.PV', SubscriptionMode.Monitor(delta=0.01))
        controller.subscribe('FOO.PV',  SubscriptionMode.Monitor(0.123))
        controller.subscribe('BAR.PV', SubscriptionMode.Scan(123.1)) 

        cfg = controller.save_config()
        logger.info("Saved config looks like:\n%s", cfg)
Example #2
0
    def test_load_config(self):
        pvnames = ('DEFAULT.PV', 'FOO.PV', 'BAR.PV')
        
        futures = []
        futures.append(controller.subscribe('DEFAULT.PV', SubscriptionMode.Monitor(delta=0.01)))
        futures.append(controller.subscribe('FOO.PV',  SubscriptionMode.Monitor(0.123)))
        futures.append(controller.subscribe('BAR.PV', SubscriptionMode.Scan(123.1)))

        [ fut.wait() for fut in futures ]

        cfg = controller.save_config()

        futures = controller.munsubscribe([pvname for pvname, _ in controller.list_subscribed()])
        [ fut.wait() for fut in futures ]

        logger.info("Trying to load:\n%s", cfg)

        futures = controller.load_config(cfg)
        results = [ fut.get() for fut in futures ]

        pvnames = [pvname for pvname, _ in controller.list_subscribed()]

        self.assertIn('DEFAULT.PV', pvnames)
        self.assertIn('FOO.PV', pvnames)
        self.assertIn('BAR.PV', pvnames)

        av = controller.get_apv('DEFAULT.PV')
        self.assertEqual( av.name, 'DEFAULT.PV' )
        self.assertEqual( av.mode.name, SubscriptionMode.Monitor.name )
        self.assertEqual( av.mode.delta, 0.01 )

        av = controller.get_apv('FOO.PV')
        self.assertEqual( av.name, 'FOO.PV' )
        self.assertEqual( av.mode.name, SubscriptionMode.Monitor.name )
        self.assertEqual( av.mode.delta, 0.123 )

        av = controller.get_apv('BAR.PV')
        self.assertEqual( av.name, 'BAR.PV' )
        self.assertEqual( av.mode.name, SubscriptionMode.Scan.name )
        self.assertEqual( av.mode.period, 123.1 )
Example #3
0
 def get(self):
     cfg = controller.save_config()
     self.set_header("Content-Type", "application/json")
     self.write(cfg)