Exemple #1
0
    def EditNumFinished(self, Event):
        Widget = Event.widget
        Item = self.GetConfigDataItemFromWidget(Widget)
        if not Item:
            return
        Parts = Item['type'].split(',')
        if len(Parts) > 3:
            Min = Parts[2].lstrip()[1:]
            Max = Parts[3].rstrip()[:-1]
            MinVal = Array2Val(Min)
            MaxVal = Array2Val(Max)
            Text = Widget.get()
            if ',' in Text:
                Text = '{ %s }' % Text
            try:
                Value = Array2Val(Text)
                if Value < MinVal or Value > MaxVal:
                    raise Exception('Invalid input!')
                self.SetConfigItemValue(Item, Text)
            except Exception as e:
                pass

            Text = Item['value'].strip('{').strip('}').strip()
            Widget.delete(0, END)
            Widget.insert(0, Text)

        self.UpdateWidgetsVisibilityOnPage()
Exemple #2
0
    def GenerateDeltaFile(self, DeltaFile, Full=False):
        NewData = self.CfgDataObj.GenerateBinaryArray()
        Lines = []
        TagName = ''
        Level = 0
        PlatformId = None
        DefPlatformId = 0

        for Item in self.CfgDataObj._CfgItemList:
            if Level == 0 and Item['embed'].endswith(':START'):
                TagName = Item['embed'].split(':')[0]
                Level += 1

            Start = Item['offset']
            End = Start + Item['length']
            FullName = '%s.%s' % (TagName, Item['cname'])
            if 'PLATFORMID_CFG_DATA.PlatformId' == FullName:
                DefPlatformId = Bytes2Val(self.OrgCfgDataBin[Start:End])

            if NewData[Start:End] != self.OrgCfgDataBin[Start:End] or (
                    Full and Item['name'] and (Item['cname'] != 'Dummy')):
                if not Item['subreg']:
                    Text = '%-40s | %s' % (FullName, Item['value'])
                    if 'PLATFORMID_CFG_DATA.PlatformId' == FullName:
                        PlatformId = Array2Val(Item['value'])
                    else:
                        Lines.append(Text)
                else:
                    OldArray = self.OrgCfgDataBin[Start:End]
                    NewArray = NewData[Start:End]
                    for SubItem in Item['subreg']:
                        NewBitValue = self.CfgDataObj.GetBsfBitFields(
                            SubItem, NewArray)
                        OldBitValue = self.CfgDataObj.GetBsfBitFields(
                            SubItem, OldArray)
                        if OldBitValue != NewBitValue or (
                                Full and Item['name'] and
                            (Item['cname'] != 'Dummy')):
                            if SubItem['cname'].startswith(Item['cname']):
                                Offset = len(Item['cname']) + 1
                                FieldName = '%s.%s' % (
                                    FullName, SubItem['cname'][Offset:])
                            Text = '%-40s | %s' % (FieldName, SubItem['value'])
                            Lines.append(Text)

            if Item['embed'].endswith(':END'):
                EndTagName = Item['embed'].split(':')[0]
                if EndTagName == TagName:
                    Level -= 1

        if PlatformId is None or DefPlatformId == PlatformId:
            PlatformId = DefPlatformId
            print(
                "WARNING: 'PlatformId' configuration is same as default %d!" %
                PlatformId)

        Lines.insert(
            0, '%-40s | %s\n\n' %
            ('PLATFORMID_CFG_DATA.PlatformId', '0x%04X' % PlatformId))
        self.CfgDataObj.WriteDeltaFile(DeltaFile, PlatformId, Lines)
Exemple #3
0
    def SyncConfigDataFromSubRegion(self):
        if not len(self.PageList) or not self.PageId:
            return

        for Item in self.GetCurrentConfigData():
            if not Item['subreg']:
                continue
            ValArray = self.CfgDataObj.ValueToByteArray(
                Item['value'], Item['length'])
            for SubItem in Item['subreg']:
                Value = Array2Val(SubItem['value'])
                self.CfgDataObj.UpdateBsfBitFields(SubItem, Value, ValArray)
            if Item['value'].startswith('{'):
                NewValue = Bytes2Str(ValArray)
            else:
                BitsValue = ''.join('{0:08b}'.format(i)
                                    for i in ValArray[::-1])
                NewValue = '0x%X' % (int(BitsValue, 2))
                NewValue = self.NormalizeValueStr(Item, NewValue)
            if NewValue != Item['value']:
                if self.Debug:
                    print('Update Subregion %s from %s to %s' %
                          (Item['cname'], Item['value'], NewValue))
                Item['value'] = NewValue