示例#1
0
def test_read_profile(jsonfile):
    classes = globals()
    XObject.set_classes(classes)
    parser = ProfileParser()
    parser.read_profile(jsonfile)

    boards = Profile.get_boards()
    boards[power_profile['id']] = power_profile

    assert len(Profile.get_extendio()) == 1
    assert len(Profile.get_busswitch()) == 9
    assert len(Profile.get_eeprom()) == 8
    assert len(Profile.get_boards()) == 5
    assert len(Profile.get_buses()) == 8
    assert len(Profile.get_chips()) == 12
示例#2
0
    def parse_board_profile(board):
        '''
        "DATALOGGER": {
            "id": "DATALOGGER",
            "partno": "Scope-002-001",
            "daq_channel":[
                {"ch": 0, "alias": "volt", "port": 7603},
                {"ch": 1, "alias": "current", "port": 7604}
            ],
            "adc": {"partno": "AD7175", "path": "/dev/AXI4_DATALOGGER_AD7177"},
            "eeprom": {"partno": "CAT24C08", "bus": "EEPROM_IIC", "switch_channel": "Datalogger-1", "addr": "0x53"}
        }
        '''
        board_name = board['id']

        boards = Profile.get_boards()
        boards[board_name] = dict()
        boards[board_name]['id'] = board_name
        boards[board_name]['partno'] = board['partno']
        boards[board_name]['adc'] = board['adc'].copy()
        boards[board_name]['adc']['path'] = Utility.get_dev_path(
        ) + '/' + board['adc']['path']
        boards[board_name]['daq_channel'] = copy.deepcopy(board['daq_channel'])
        boards[board_name]['frame_device_path'] = Utility.get_dev_path(
        ) + '/' + board['frame_device_path']
示例#3
0
def _create_board_object():
    ret_value = True
    for board_name, board_profile in Profile.get_boards().iteritems():
        try:
            class_name = board_profile['partno'].replace('-', '')
            if XObject.create_object(board_name, class_name, board_profile):
                logger.boot('create the %s board object %s' %
                            (board_name, class_name))
            else:
                logger.boot(
                    'warning: can not find the %s board class %s in this project code'
                    % (board_name, class_name))
                ret_value = False
        except Exception as e:
            logger.boot("error: create %s board object fail:\n%s" %
                        (board_name, traceback.format_exc()))
            ret_value = False
    return ret_value
示例#4
0
    def parse_board_profile(board_profile):
        '''
        Profile:
        {
            #public
            "id":string,
            "partno":"DemoBoard-001-001",

            #private
            "chip":{
                "partno":"DemoChip",
                "id":string
                "init_msg":string
            }
        }
        '''
        board_name = board_profile['id']

        boards = Profile.get_boards()
        boards[board_name] = dict()
        boards[board_name]['id'] = board_name
        boards[board_name]['partno'] = board_profile['partno']

        boards[board_name]['chip'] = board_profile['chip'].copy()
示例#5
0
    def parse_board_profile(board):
        board_name = board['id']
        boards = Profile.get_boards()
        boards[board_name] = dict()
        boards[board_name]['id'] = board_name
        boards[board_name]['partno'] = board['partno']
        boards[board_name]['switch_gpio_path'] = utility.get_dev_path(
        ) + '/' + board['switch_gpio']
        boards[board_name]['daq_channel'] = board['daq_channel']

        boards[board_name]['dacfunction'] = copy.deepcopy(board['dacfunction'])
        for key in board['dacfunction'].keys():
            #            boards[board_name]['dacfunction'][key]["vref"] = board['dacfunction'][key]['vref']
            boards[
                board_name]['dacfunction'][key]['path'] = utility.get_dev_path(
                ) + '/' + board['dacfunction'][key]['path']
            boards[board_name]['dacfunction'][key]['gpio'] = [
                (board['dacfunction'][key]['gpio1'],
                 board['dacfunction'][key]['gpio1_state']),
                (board['dacfunction'][key]['gpio0'],
                 board['dacfunction'][key]['gpio0_state'])
            ]

        boards[board_name]['adc7175_path'] = utility.get_dev_path(
        ) + '/' + board['adc7175function']['path']
        boards[board_name]['adc7175_vref'] = (board['adc7175function']['vref'],
                                              "mV")
        boards[board_name]['adc7175_samplerate'] = (
            board['adc7175function']['samplerate'], "Hz")
        boards[board_name]['adc7175_config'] = copy.deepcopy(
            board['adc7175function']['config'])

        for key in board['ina231funtion'].keys():
            boards[board_name][key] = dict()
            boards[board_name][key]['ina231_path'] = utility.get_dev_path(
            ) + '/' + board['ina231funtion'][key]['iic_path']
            boards[board_name][key]['ina231_addr'] = int(
                board['ina231funtion'][key]['addr'], 16)

#         boards[board_name]['adc_path']= utility.get_dev_path()  +'/' +board['adcfunction']['path']
#         boards[board_name]['adc_vref']=board['adcfunction']['vref']

#         boards[board_name]['iowidthfunction']= copy.deepcopy(board['iowidthfunction'])
#         for key in board['iowidthfunction'].keys():
#             boards[board_name]['iowidthfunction'][key]["path"]=utility.get_dev_path()  +'/' +board['iowidthfunction'][key]["path"]
#
        boards[board_name]['protectwavemeasure'] = copy.deepcopy(
            board['protectwavemeasure'])
        boards[board_name]['protectwavemeasure'][
            "path"] = utility.get_dev_path(
            ) + '/' + board['protectwavemeasure']["path"]

        boards[board_name]['wave_measure'] = copy.deepcopy(
            board['wave_measure'])
        boards[board_name]['wave_measure']["path"] = utility.get_dev_path(
        ) + '/' + board['wave_measure']['path']

        boards[board_name]['freq'] = utility.get_dev_path(
        ) + '/' + board['meterfunction']['freq']['path']
        boards[board_name]['ppulse'] = utility.get_dev_path(
        ) + '/' + board['meterfunction']['ppulse']['path']

        boards[board_name]['frame_dev_path'] = utility.get_dev_path(
        ) + '/' + board['audiofunction']['frame_dev_path']
        #        boards[board_name]['audio_dev_path']= utility.get_dev_path()  +'/' +board['audiofunction']['audio_dev_path']
        boards[board_name]['audio_reset'] = board['audiofunction'][
            'reset_gpio']
        boards[board_name]['audio_enable'] = board['audiofunction'][
            'enable_gpio']

        boards[board_name]['AID'] = copy.deepcopy(board['AID'])
        for key in board['AID'].keys():
            boards[board_name]['AID'][key]["path"] = utility.get_dev_path(
            ) + '/' + board['AID'][key]["path"]

#         boards[board_name]['audiofunction_path']= utility.get_dev_path()  +'/' +board['audiofunction']['path']
#         boards[board_name]['audio_reset']= board['audiofunction']['reset_gpio']
#         boards[board_name]['audio_enable']= board['audiofunction']['enable_gpio']
#
        if "temperature" in board:
            boards[board_name]['temperature'] = copy.deepcopy(
                board['temperature'])
            boards[board_name]['temperature']["path"] = utility.get_dev_path(
            ) + '/' + board['temperature']["path"]

        boards[board_name]['swdrstctrl'] = copy.deepcopy(board['swdrstctrl'])
        for key in board['swdrstctrl'].keys():
            boards[board_name]['swdrstctrl'][key] = utility.get_dev_path(
            ) + '/' + board['swdrstctrl'][key]

        boards[board_name]['gpio_control'] = copy.deepcopy(
            board['gpio_control'])