示例#1
0
def main(args):
    """Simple command-line interface for Monsoon."""
    if args.avg and args.avg < 0:
        print('--avg must be greater than 0')
        return

    mon = monsoon_controller.create([int(args.serialno[0])])[0]

    if args.voltage is not None:
        mon.set_voltage(args.voltage)

    if args.current is not None:
        mon.set_max_current(args.current)

    if args.status:
        items = sorted(mon.status.items())
        print('\n'.join(['%s: %s' % item for item in items]))

    if args.usbpassthrough:
        mon.usb(args.usbpassthrough)

    if args.startcurrent is not None:
        mon.set_max_initial_current(args.startcurrent)

    if args.samples:
        result = mon.measure_power(args.samples / args.hz,
                                   measure_after_seconds=args.offset,
                                   hz=args.hz,
                                   output_path='monsoon_output.txt')
        print(repr(result))
示例#2
0
 def test_raises_error_if_monsoon_serial_not_provided(self, *_):
     with self.assertRaises(ValueError):
         monsoon.create([{'type': 'LvpmStockMonsoon'}])
示例#3
0
 def test_raises_error_if_monsoon_type_is_unknown(self, *_):
     with self.assertRaises(ValueError):
         monsoon.create([{'type': 'UNKNOWN', 'serial': 10}])
示例#4
0
 def test_create_can_create_hvpm_from_dict(self, *_):
     monsoons = monsoon.create([{'type': 'HvpmMonsoon', 'serial': 10}])
     self.assertIsInstance(monsoons[0], HvpmMonsoon)
     self.assertEqual(monsoons[0].serial, 10)
示例#5
0
 def test_create_can_create_hvpm_from_id_only(self, *_):
     monsoons = monsoon.create([23456])
     self.assertIsInstance(monsoons[0], HvpmMonsoon)
示例#6
0
 def test_create_can_create_lvpm_from_id_only(self, *_):
     monsoons = monsoon.create([12345])
     self.assertIsInstance(monsoons[0], LvpmStockMonsoon)