示例#1
0
def validateAllModuleRouteEnablesAndModes(portio):
    '''
    Check that the routes used by modules are enabled on the portio
    :type portio: Studio._private.StudioClasses.com_silabs_ide_halconf_core_client_accessors_IPortIOAccessor
    '''
    if SNIPPET_PROFILE:
        start = time.time()

    # ensure that this is always in a known mapping group
    RuntimeModel.new_problem_group(None, portio, 'validateAllModuleRouteEnablesAndModes')

    for signal in portio.signals:
        signalNameComponents = signal.name.split('|')
        if len(signalNameComponents) == 3:
            module = signalNameComponents[0]
            route = signalNameComponents[1]
            signalType = signalNameComponents[2]
            if signalType == 'EN':
                # If the validation enable signal is True, validate the route enable property
                if signal.get() == True:
                    validateModuleRouteEnable(portio, module, route)



    if SNIPPET_PROFILE:
        stop = time.time()
        print("validateAllModuleRouteEnablesAndModes() completed in {:.3f} ms".format((stop - start) * 1000))
示例#2
0
def validateRouting(portio, state):
    '''
    :type portio: Studio._private.StudioClasses.com_silabs_ide_halconf_core_client_accessors_IPortIOAccessor
    '''

    if SNIPPET_PROFILE:
        start = time.time()

    # ensure that this is always in a known mapping group
    RuntimeModel.new_problem_group(None, portio, state, 'validateRouting')

    """
    A map that stores the pin assignment(s) for each physical pin:
    { pin ID : PinRoutes }
    """
    pinAssignments = collections.OrderedDict()

    """
    Generate a PinLabelsRoutes structures for each pin.
    Add the pin accessor and create an empty label list to track the assigned pin labels
    """
    for portbank in portio.portBanks:
        for pin in portbank.pins:
            pinAssignments[pin.id] = PinRoutes(pin, [])

    for route in activePinRoutes(portio):
        pinAssignments[route.getPinId()].pin = route.getPin()
        pinAssignments[route.getPinId()].routes.append(route)

    signalSettings = []

    # for module in portio.mode.getPeripherals():
    #     if 'APORT' in module.name:
    #         for attribute in dir(APORT_EFR.SIGNALS):
    #             if 'STAT' in attribute:
    #                 print(attribute + " : " + str(module.signal(getattr(APORT_EFR.SIGNALS, attribute)).get()))

    for pinRoute in pinAssignments.values():
        label = pinRoute.getLabel()
        color = pinRoute.getColor()

        # This is the place to override pin labels for APORT
        labels = label.split(' / ')
        newlabels = []
        for partiallabel in labels:
            newlabel = partiallabel
            # if 'APORT' in partiallabel:
            #     # get reference to aport through mode
            #     modules = portio.mode.getPeripherals()
            #
            #     for module in modules:
            #         if 'APORT' in module.name:
            #             chan = partiallabel.replace('APORT_', '').replace("P", "X").replace("N", "Y")
            #             newlabel = str(module.signal(getattr(APORT_EFR.SIGNALS, chan + "_STAT")).get())
            #             print(chan + " : " + newlabel)
            #
            #     newlabels.append(newlabel)
            # else:
            newlabels.append(newlabel)

        label = ' / '.join(newlabels)

        # Set pin signal assignment
        signalSettings.append((pinRoute.getPin().assignmentSignal, [label, color]))

        for (prop, msg) in pinRoute.errors():
            RuntimeModel.new_warning(prop, msg, state)

    # Filtering out non-aport pinRoutes
    aportPinAssignments = {}
    for pinID in pinAssignments.keys():
        if pinAssignments[pinID].isAportConnected():
            aportPinAssignments[pinID] = pinAssignments[pinID]
            for route in pinAssignments[pinID].getRoutes():
                if not route.getAportName():
                    aportPinAssignments[pinID].getRoutes().remove(route)

    # Generating warnings and infos
    for (prop, msg) in aportWarnings(aportPinAssignments):
        RuntimeModel.new_warning(prop, msg, state)
    for (prop, msg) in aportInfos(aportPinAssignments):
        RuntimeModel.new_info(prop, msg, state)

    # Only apply a signal setting if it isn't the same as the previous value
    for (signal, setting) in signalSettings:
        if not inLastSignalSettings(portio.mode.name, (signal, setting)):
            RuntimeModel.set_signal_value(signal, setting, state)

    # Keep track of settings for next time
    LastSignalSettings[portio.mode.name] = signalSettings

    # Validate that all module routes in use are enabled on the portio
    # validateAllModuleRouteEnablesAndModes(portio)

    if SNIPPET_PROFILE:
        stop = time.time()
        print("validateRouting() completed in {:.3f} ms".format((stop - start) * 1000))