def verify_usage(self, options, tests): MarionetteTestOptions.verify_usage(self, options, tests) #options, tests = self.parse_args() if options.iterations is not None and options.iterations < 1: raise ValueError('iterations must be a positive integer') if options.checkpoint_interval is not None and options.checkpoint_interval < 1: raise ValueError('checkpoint interval must be a positive integer') if options.checkpoint_interval and not options.iterations: raise ValueError( 'you must specify iterations when using checkpoint intervals') if options.yocto: # need to verify that the yocto ammeter is attached errmsg = YRefParam() if YAPI.RegisterHub("usb", errmsg) != YAPI.SUCCESS: raise RuntimeError( 'could not register yocto usb connection: %s' % str(errmsg)) # rescan for yocto devices if YAPI.UpdateDeviceList(errmsg) != YAPI.SUCCESS: raise RuntimeError('could not detect yoctopuce modules: %s' % str(errmsg)) # check for ammeter ammeter = YCurrent.FirstCurrent() if ammeter is None: raise RuntimeError('could not find ammeter device') if ammeter.isOnline(): module = ammeter.get_module() dc_ammeter = YCurrent.FindCurrent(module.get_serialNumber() + '.current1') if (not module.isOnline()) or (dc_ammeter is None): raise RuntimeError('could not get ammeter device') else: raise RuntimeError('could not find yocto ammeter device') # check for data logger data_logger = YDataLogger.FirstDataLogger() if data_logger is None: raise RuntimeError('could not find data logger device') if data_logger.isOnline(): module = data_logger.get_module() data_logger = YDataLogger.FindDataLogger( module.get_serialNumber() + '.dataLogger') if not module.isOnline() or data_logger is None: raise RuntimeError('could not get data logger device') else: raise RuntimeError('could not find yocto ammeter device')
def data_logger(self): if hasattr(self, '_data_logger') and self._data_logger: return self._data_logger # get a handle to the data logger self._data_logger = YDataLogger.FindDataLogger(self.module.get_serialNumber() + '.dataLogger') if not self.module.isOnline() or self._data_logger is None: raise Exception('could not get data logger device') # fix up the data logger's internal clock self._data_logger.set_timeUTC(time.mktime(time.gmtime())) return self._data_logger
def gaia_verify_usage(self, options, tests): if options.yocto: # need to verify that the yocto ammeter is attached errmsg = YRefParam() if YAPI.RegisterHub("usb", errmsg) != YAPI.SUCCESS: raise RuntimeError( 'could not register yocto usb connection: %s' % str(errmsg)) # rescan for yocto devices if YAPI.UpdateDeviceList(errmsg) != YAPI.SUCCESS: raise RuntimeError('could not detect yoctopuce modules: %s' % str(errmsg)) # check for ammeter ammeter = YCurrent.FirstCurrent() if ammeter is None: raise RuntimeError('could not find ammeter device') if ammeter.isOnline(): module = ammeter.get_module() dc_ammeter = YCurrent.FindCurrent(module.get_serialNumber() + '.current1') if (not module.isOnline()) or (dc_ammeter is None): raise RuntimeError('could not get ammeter device') else: raise RuntimeError('could not find yocto ammeter device') # check for data logger data_logger = YDataLogger.FirstDataLogger() if data_logger is None: raise RuntimeError('could not find data logger device') if data_logger.isOnline(): module = data_logger.get_module() data_logger = YDataLogger.FindDataLogger( module.get_serialNumber() + '.dataLogger') if not module.isOnline() or data_logger is None: raise RuntimeError('could not get data logger device') else: raise RuntimeError('could not find yocto ammeter device')