Ejemplo n.º 1
0
    def GetMetrics(self):
        # PROTECTED REGION ID(SKABaseDevice.GetMetrics) ENABLED START #
        ### TBD - read the value of each of the attributes in the MetricList
        with exception_manager(self):
            args_dict = {'with_value': True, 'with_commands': False,
                         'with_metrics': True, 'with_attributes': False}
            device_dict = self._get_device_json(args_dict)
            argout = json.dumps(device_dict)

        return argout
Ejemplo n.º 2
0
    def ToJson(self, argin):
        # PROTECTED REGION ID(SKABaseDevice.ToJson) ENABLED START #

        # TBD - see how to use fandango's export_device_to_dict
        with exception_manager(self):
            defaults = {'with_value': False, 'with_commands': True,
                        'with_metrics': True, 'with_attributes': False}
            args_dict = self._parse_argin(argin, defaults=defaults)
            device_dict = self._get_device_json(args_dict)
            argout = json.dumps(device_dict)
        return argout
 def RunGroupCommand(self, argin):
     # PROTECTED REGION ID(SKATestDevice.RunGroupCommand) ENABLED START #
     with exception_manager(self):
         defaults = {'arg_type': None, 'arg_value': None, 'forward': True}
         required = ('group', 'command', 'arg_type', 'arg_value', 'forward')
         args = self._parse_argin(argin,
                                  defaults=defaults,
                                  required=required)
         group_name = args['group']
         group = self.groups.get(group_name)
         if group:
             command = args['command']
             forward = args['forward']
             if args['arg_type']:
                 _, param = convert_api_value({
                     'type': args['arg_type'],
                     'value': args['arg_value']
                 })
                 replies = group.command_inout(command,
                                               param,
                                               forward=forward)
             else:
                 replies = group.command_inout(command, forward=forward)
             results = []
             for reply in replies:
                 result = {
                     'device_name': reply.dev_name(),
                     'argout': coerce_value(reply.get_data()),
                     'failed': reply.has_failed(),
                 }
                 results.append(result)
             argout = json.dumps(results, sort_keys=True)
         else:
             raise RuntimeError(
                 "Invalid group requested. '{}' not in '{}'".format(
                     group_name, sorted(self.groups.keys())))
     return argout