Exemplo n.º 1
0
 def test_reload_config(self):
     cfg="""
         <config>
           <controller class='mockup'>
             <axis name="m0">
               <velocity value="1000"/>
               <acceleration value="100"/>
               <low_limit value="-5"/>
               <high_limit value="5"/>
             </axis>
           </controller>
         </config>
     """
     f = tempfile.NamedTemporaryFile()
     filename = f.name
     try:
         f.write(cfg) 
         f.flush()
         emotion.load_cfg(f.name)
         m = emotion.get_axis("m0")
         self.assertEquals(m.config.config_dict.config_file, f.name)
     finally:
         f.close()
     self.assertEquals(m.limits(), (-5,5))
     self.assertEquals(m.backlash, 0)
     self.assertEquals(m.steps_per_unit, 1)
     cfg2 = """
         <config>
           <controller class='mockup'>
             <axis name="m0">
               <steps_per_unit value="5"/>
               <velocity value="1000"/>
               <acceleration value="100"/>
               <low_limit value="-5"/>
               <high_limit value="10"/>
               <backlash value="4"/>
             </axis>
           </controller>
         </config>
     """
     with open(filename, "w") as f:
         f.write(cfg2)
     try:
         m.config.reload()
     
         self.assertEquals(m.config.config_dict['high_limit']['value'], '10')
         self.assertEquals(m.backlash, 4)
         self.assertEquals(m.steps_per_unit, 5)
         m.apply_config()
         self.assertEquals(m.limits(), (-5,10))
     finally:
         os.unlink(filename)
Exemplo n.º 2
0
 def load_config(config_file):
     emotion.load_cfg(config_file,clear=False)    
Exemplo n.º 3
0
 def load_config(config_file):
     emotion.load_cfg(config_file, clear=False)
Exemplo n.º 4
0
 def setUp(self):
     self.cfg_file = tempfile.NamedTemporaryFile(delete=False)
     self.cfg_file.write(config_xml)
     self.cfg_file.close()
     emotion.load_cfg(self.cfg_file.name)