当前位置: 首页>>代码示例>>Python>>正文


Python parameter.Parameter类代码示例

本文整理汇总了Python中chipwhisperer.common.utils.parameter.Parameter的典型用法代码示例。如果您正苦于以下问题:Python Parameter类的具体用法?Python Parameter怎么用?Python Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateParams

    def updateParams(self, _=None):
        rng = self.findParam("range").getValue()

        # Force to be valid values
        curval = self.findParam("curval").getValue()
        curval = max(curval, rng[0])
        curval = min(curval, rng[1])
        self.findParam("curval").setLimits(rng)
        self.findParam("curval").setValue(curval)

        self.paramRange = rng
        self.paramValueItem = self.findParam("curval")
        self.paramStep = self.findParam("step").getValue()
        self.paramRepeat = self.findParam("repeat").getValue()
        self.paramType = self.findParam("datatype").getValue()
        try:
            self.paramScript = eval(self.findParam("parampath").getValue())
        except SyntaxError as e:
            logging.error("Syntax Error: %s" % str(e))

        try:
            Parameter.setParameter(self.paramScript + [curval])
        except:
            pass
        self.tracesrequired = (
            math.ceil(((self.paramRange[1] - self.paramRange[0]) / self.paramStep) * self.paramRepeat) + 1
        )
        self.tracesreqChanged.emit(self.paramNum, self.tracesrequired)
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: findNewValue

    def findNewValue(self, mode="linear"):
        """ Find new value for this parameter """

        if str.lower(mode) == "linear":
            self.cnt += 1
            if self.cnt == self.paramRepeat:
                # Done this one, next step
                self.cnt = 0
                newval = self.paramValueItem.getValue() + self.paramStep

                if newval > self.paramRange[1]:
                    newval = self.paramRange[0]
                    self.rangeComplete.emit(self.paramNum)

                # Cast type to required value
                newval = self.paramType(newval)

                self.paramValueItem.setValue(newval)

                parameter = self.paramScript + [newval]
                try:
                    Parameter.setParameter(parameter)
                except:
                    raise StopIteration("Choose a valid Parameter Path/Value combination. Got: " + str(parameter))
        else:
            raise ValueError("Unknown Increment Type %s" % mode)
开发者ID:,项目名称:,代码行数:26,代码来源:

示例3: setPreprocessing

    def setPreprocessing(self, num, module):
        """Insert the preprocessing module selected from the GUI into the list of active modules.

        This ensures that the options for that module are then displayed in the GUI, along with
        writing the auto-generated script.
        """

        #Walk backwards to find previous trace source
        last_trace_src = self.cwGUI.api.project().traceManager()
        for i in range(num, 0, -1):
            if self.preprocessingListGUI[i] is not None:
                last_trace_src = self.preprocessingListGUI[i]
                break

        if self.preprocessingListGUI[num] is not None:
            self.preprocessingListGUI[num].deregister()
            self.preprocessingParams.getChild('Pre-Processing Mod. #%d'% num).delete()
        if module:
            self.preprocessingListGUI[num] = module(traceSource=last_trace_src)
            self.preprocessingListGUI[num].scriptsUpdated.connect(self.reloadScripts)
            par = Parameter(name = 'Pre-Processing Mod. #%d'% num, type = "group")
            par.append(self.preprocessingListGUI[num].getParams())
            self.preprocessingParams.append(par)
        else:
            self.preprocessingListGUI[num] = None

        self.reloadScripts()
开发者ID:phonchi,项目名称:chipwhisperer,代码行数:27,代码来源:attackscriptgen.py

示例4: ChipWhispererExtra

class ChipWhispererExtra(Parameterized):
    _name = 'CW Extra'

    def __init__(self, parentParam, cwtype, scope, oa):
        #self.cwADV = CWAdvTrigger()

        if cwtype == "cwrev2":
            self.cwEXTRA = CWExtraSettings(self, oa)
        elif cwtype == "cwlite":
            self.cwEXTRA = CWExtraSettings(self, oa, hasFPAFPB=False, hasGlitchOut=True, hasPLL=False)
        else:
            raise ValueError("Unknown ChipWhisperer: %s" % cwtype)

        self.enableGlitch = True

        if self.enableGlitch:
            self.glitch = ChipWhispererGlitch.ChipWhispererGlitch(self, cwtype, scope, oa)

        self.params = Parameter(name=self.getName(), type='group')
        self.params.append(self.cwEXTRA.getParams())
        self.params.append(self.glitch.getParams())

    def armPreScope(self):
        if self.enableGlitch:
            self.glitch.armPreScope()

    def armPostScope(self):
        if self.enableGlitch:
            self.glitch.armPostScope()
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:29,代码来源:ChipWhispererExtra.py

示例5: dcmTimeout

 def dcmTimeout(self):
     try:
         self.qtadc.sc.getStatus()
         # The following happen with signals, so a failure will likely occur outside of the try...except
         # For this reason we do the call to .getStatus() to verify USB connection first
         Parameter.setParameter(['OpenADC', 'Clock Setup', 'Refresh Status', None], blockSignal=True)
         Parameter.setParameter(['OpenADC', 'Trigger Setup', 'Refresh Status', None], blockSignal=True)
     except Exception as e:
         self.dis()
         raise e
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:10,代码来源:OpenADC.py

示例6: OpenADCInterface_FTDI

class OpenADCInterface_FTDI(Parameterized, Plugin):
    _name = "FTDI (SASEBO-W/SAKURA-G)"

    def __init__(self, oadcInstance):
        self.serialNumber = ''
        self._serialnumbers = ['']

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh Device List', 'type':'action', 'action':self.serialRefresh},
            {'name':'Device Serial Number', 'key':'snum', 'type':'list', 'values':[''], 'get':self.getSerialNumber, 'set':self.setSelectedDevice},
        ])
        self.ser = None

        if (openadc_qt is None) or (ft is None):
            raise ImportError("Needed imports for FTDI missing")
        else:
            self.scope = oadcInstance

    def getSerialNumber(self):
        return self.serialNumber

    @setupSetParam("Device Serial Number")
    def setSelectedDevice(self, snum):
        self.serialNumber = snum

    def __del__(self):
        if self.ser != None:
            self.ser.close()

    def con(self):
        if self.ser == None:
            try:
                self.dev = ft.openEx(str(self.serialNumber), ft.ftd2xx.OPEN_BY_SERIAL_NUMBER)
                self.dev.setBitMode(0x00, 0x40)
                self.dev.setTimeouts(500, 500)
                self.dev.setLatencyTimer(2)
                self.ser = self
            except ft.ftd2xx.DeviceError, e:
                self.ser = None
                raise IOError("Could not open %s: %s" % (self.serialNumber, e))

        try:
            self.scope.con(self.ser)
            print("OpenADC Found, Connecting")
        except IOError,e:
            exctype, value = sys.exc_info()[:2]
            raise IOError("OpenADC Error: %s"%(str(exctype) + str(value)) + " - " + e.message)
开发者ID:phonchi,项目名称:chipwhisperer,代码行数:48,代码来源:ftdi.py

示例7: __init__

    def __init__(self, oa):

        self.oldlow = None
        self.oldhigh = None
        self.oa = oa
        self.sadref = [0]

        try:
            # Update SAD calculation when data changes
            ResultsBase.registeredObjects["Trace Output Plot"].dataChanged.connect(self.dataChanged)
            outwid = ResultsBase.registeredObjects["Trace Output Plot"]
            rangewidget = {'name':'Point Range', 'key':'pointrng', 'type':'rangegraph', 'limits':(0, 0), 'value':(0, 0), 'default':(0, 0),
                                       'graphwidget':outwid, 'action':self.updateSADTraceRef, 'fixedsize':128}
        except KeyError:
            rangewidget = {'name':'Point Range', 'key':'pointrng', 'type':'range', 'limits':(0, 0), 'value':(0, 0), 'default':(0, 0),
                                       'action':self.updateSADTraceRef, 'fixedsize':128}

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            # {'name':'Open SAD Viewer', 'type':'action'},
            {'name':'SAD Ref From Captured', 'key':'sad', 'type':'group', 'children':[
                rangewidget,
                {'name':'Set SAD Reference from Current Trace', 'key':'docopyfromcapture', 'type':'action', 'action':self.copyFromCaptureTrace},
                {'name':'SAD Reference vs. Cursor', 'key':'sadrefcur', 'type':'int', 'value':0, 'limits':(-1, 100E6), 'readonly':True},
            ]},
            {'name':'SAD Threshold', 'type':'int', 'limits':(0, 100000), 'default':0, 'set':self.setThreshold, 'get':self.getThreshold}
        ])
开发者ID:phonchi,项目名称:chipwhisperer,代码行数:27,代码来源:ChipWhispererSAD.py

示例8: __init__

    def __init__(self, cwGUI):
        self.cwGUI = cwGUI

        self.locked = False
        self.utilList = []
        self.scriptList = []
        self.scriptList.append({'widget':MainScriptEditor(self.cwGUI)})
        self.scriptList[0]['filename'] = self.scriptList[0]['widget'].filename
        self.scriptList[0]['dockname'] = 'Auto-Generated'
        self.defaultEditor = self.scriptList[0]
        autogen = (self.defaultEditor['dockname'], self.defaultEditor['filename'])
        self.preprocessingListGUI = [None, None, None, None]
        self.setAttack(self.cwGUI.api.valid_attacks.get("CPA", None), blockSignal=True)

        self.getParams().addChildren([
            {'name':'Attack Script', 'type':'group', 'children':[
                {'name':'Filename', 'key':'attackfilelist', 'type':'filelist', 'values':{autogen:0}, 'value':0, 'editor':self.editorControl,},
            ]},
            {'name':'Pre-Processing', 'type':'group', 'children':[
                {'name':'Module #%d' % step, 'type':'list', 'values':self.cwGUI.api.valid_preprocessingModules, 'get':partial(self.getPreprocessing, step), 'set':partial(self.setPreprocessing, step)} for step in range(0, len(self.preprocessingListGUI))
            ]},
            {'name':'Attack', 'type':'group', 'children':[
                {'name':'Module', 'type':'list', 'values':self.cwGUI.api.valid_attacks, 'get':self.getAttack, 'set':self.setAttack},
            ]},
        ])
        self.params.init()
        self.preprocessingParams = Parameter(name="Preprocessing", type='group')

        self.attackParams = Parameter(name="Attack", type='group')
        self.params.getChild(['Attack','Module']).stealDynamicParameters(self.attackParams)

        self.cwGUI.api.sigTracesChanged.connect(self.updateAttackTraceLimits)
开发者ID:phonchi,项目名称:chipwhisperer,代码行数:32,代码来源:attackscriptgen.py

示例9: __init__

    def __init__(self, standalone=False):
        self.standalone = standalone
        self.serialnum = None

        self.params = Parameter(name=self.getName(), type='group')

        if standalone:
            self.setSerial = self._setSerial
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:8,代码来源:SAKURAG.py

示例10: __init__

 def __init__(self, parentParam=None, configfile=None):
     self.configfile = configfile
     self.fmt = None
     self.params = Parameter(name=self._name, type='group').register()
     self.params.addChildren([
             {'name':'Config File', 'key':'cfgfile', 'type':'str', 'readonly':True, 'value':''},
             {'name':'Format', 'key':'format', 'type':'str', 'readonly':True, 'value':''},
     ])
     self.clear()
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:9,代码来源:_base.py

示例11: __init__

    def __init__(self, oaiface, hwinfo=None):
        self.oa = oaiface
        self._hwinfo = hwinfo
        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh Status', 'type':'action', 'linked':[('ADC Clock', 'DCM Locked'), ('ADC Clock', 'ADC Freq'), ('CLKGEN Settings', 'DCM Locked'), 'Freq Counter'],
                     'help':'%namehdr%' +
                            'Update if the Digital Clock Manager (DCM) are "locked" and their operating frequency.'},
            {'name':'Reset DCMs', 'type':'action', 'action':self.resetDcms, 'linked':[('CLKGEN Settings', 'Multiply'), ('CLKGEN Settings', 'Divide')],
                      'help':'%namehdr%' +
                            'When the input frequency to the DCM blocks changes, it can cause them to become "unlocked". When they are "unlocked" they are NOT ' +
                            'generating a reliable output frequency. You must press the "Reset" button to cause them to re-lock. This is currently not automatically ' +
                            'done as during regular operation they shouldn\'t become unlocked.\n\nHowever every time you change the DCM block source, it will cause ' +
                            'the blocks to lose lock.'},

            {'name': 'ADC Clock', 'type':'group', 'children': [
                {'name': 'Source', 'type':'list', 'values':{"EXTCLK Direct":("extclk", 4, "clkgen"),
                                                            "EXTCLK x4 via DCM":("dcm", 4, "extclk"),
                                                            "EXTCLK x1 via DCM":("dcm", 1, "extclk"),
                                                            "CLKGEN x4 via DCM":("dcm", 4, "clkgen"),
                                                            "CLKGEN x1 via DCM":("dcm", 1, "clkgen")},
                          'set':self.setAdcSource, 'get':self.adcSource,
                          'help':'%namehdr%' +
                                'The ADC sample clock is generated from this source. Options are either an external input (which input set elsewhere) or an internal clock generator. Details of each option:\n\n' +
                                '=================== ====================== =================== ===============\n' +
                                ' Name                Description            Input Freq Range   Fine Phase Adj.\n' +
                                '=================== ====================== =================== ===============\n' +
                                ' EXCLK Direct       Connects sample clock     1-105 MHz            NO\n' +
                                '                    external pin directly.\n' +
                                ' EXTCLK xN via DCM  Takes external pin,       5-105 MHz (x1)       YES\n\n' +
                                '                    multiplies frequency      5-26.25 MHz (x4)        \n\n' +
                                '                    xN and feeds to ADC.  \n' + 
                                ' CLKGEN xN via DCM  Multiples CLKGEN by       5-105 MHz (x1)       YES\n\n' +
                                '                    xN and feeds to ADC.      5-26.25 MHz (x4)        \n\n' +
                                '=================== ====================== =================== ===============\n'},
                {'name': 'Phase Adjust', 'type':'int', 'limits':(-255, 255), 'set':self.setPhase, 'get':self.phase, 'help':'%namehdr%' +
                         'Makes small amount of adjustment to sampling point compared to the clock source. This can be used to improve the stability ' +
                         'of the measurement. Total phase adjustment range is < 5nS regardless of input frequency.'},
                {'name': 'ADC Freq', 'type': 'int', 'siPrefix':True, 'suffix': 'Hz', 'readonly':True, 'get':self.adcFrequency},
                {'name': 'DCM Locked', 'type':'bool', 'get':self.dcmADCLocked, 'readonly':True},
                {'name':'Reset ADC DCM', 'type':'action', 'action':lambda _ : self.resetDcms(True, False), 'linked':['Phase Adjust']},
            ]},
            {'name': 'Freq Counter', 'type': 'str', 'readonly':True, 'get':lambda: str(self.extFrequency()) + " Hz"},
            {'name': 'Freq Counter Src', 'type':'list', 'values':{'EXTCLK Input':0, 'CLKGEN Output':1}, 'set':self.setFreqSrc, 'get':self.freqSrc},
            {'name': 'CLKGEN Settings', 'type':'group', 'children': [
                {'name':'Input Source', 'type':'list', 'values':["system", "extclk"], 'set':self.setClkgenSrc, 'get':self.clkgenSrc},
                {'name':'Multiply', 'type':'int', 'limits':(2, 256), "default":2, 'set':self.setClkgenMul, 'get':self.clkgenMul, 'linked':['Current Frequency']},
                {'name':'Divide', 'type':'int', 'limits':(1, 256), 'set':self.setClkgenDiv, 'get':self.clkgenDiv, 'linked':['Current Frequency']},
                {'name':'Desired Frequency', 'type':'float', 'limits':(3.3E6, 200E6), 'default':0, 'step':1E6, 'siPrefix':True, 'suffix':'Hz',
                                            'set':self.autoMulDiv, 'get':self.getClkgen, 'linked':['Multiply', 'Divide']},
                {'name':'Current Frequency', 'type':'str', 'default':0, 'readonly':True,
                                            'get':lambda: str(self.getClkgen()) + " Hz"},
                {'name':'DCM Locked', 'type':'bool', 'default':False, 'get':self.clkgenLocked, 'readonly':True},
                {'name':'Reset CLKGEN DCM', 'type':'action', 'action':lambda _ : self.resetDcms(False, True), 'linked':['Multiply', 'Divide']},
            ]}
        ])
        self.params.refreshAllParameters()
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:57,代码来源:_OpenADCInterface.py

示例12: __init__

    def __init__(self, oadcInstance):
        self.portName = ''
        self.ser = None

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh List', 'type':'action', 'action':self.serialRefresh},
            {'name':'Selected Port', 'type':'list', 'values':[''], 'get':self.getPortName, 'set':self.setPortName},
        ])
        self.scope = oadcInstance
开发者ID:phonchi,项目名称:chipwhisperer,代码行数:10,代码来源:oadc_serial.py

示例13: setupTraceParam

    def setupTraceParam(self):
        self.traceParams = Parameter(self, name='Trace Setup', type='group', children=[
            {'name':'Starting Trace', 'key':'strace', 'type':'int', 'value':0, 'action':lambda _:self.updateGenericScript()},
            {'name':'Traces per Attack', 'key':'atraces', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':lambda _:self.updateGenericScript()},
            {'name':'Attack Runs', 'key':'runs', 'type':'int', 'limits':(1, 1E6), 'value':1, 'action':lambda _:self.updateGenericScript()},
            {'name':'Reporting Interval', 'key':'reportinterval', 'type':'int', 'value':10, 'action':lambda _:self.updateGenericScript()},
        ])

        self.addFunction("init", "setTraceStart", "0")
        self.addFunction("init", "setTracesPerAttack", "1")
        self.addFunction("init", "setIterations", "1")
        self.addFunction("init", "setReportingInterval", "10")
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:12,代码来源:_generic_parameters.py

示例14: reloadGuiActions

    def reloadGuiActions(self):
        # Remove all old actions that don't apply for new selection
        if hasattr(self,"_ToolMenuItems"):
            for act in self._ToolMenuItems:
                self.toolMenu.removeAction(act)

        self._ToolMenuItems = []
        self._ToolMenuItems.append(self.toolMenu.addSeparator())
        for act in Parameter.getAllParameters("menu"):
            self._ToolMenuItems.append(QAction(act.getName(), self, statusTip=act.getTip(), triggered=act.callAction))

        for act in self._ToolMenuItems:
            self.toolMenu.addAction(act)
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:13,代码来源:CWMainGUI.py

示例15: __init__

    def __init__(self, parentParam, oadcInstance):
        self.portName = ''
        self.ser = None

        self.params = Parameter(name=self.getName(), type='group')
        self.params.addChildren([
            {'name':'Refresh List', 'type':'action', 'action':lambda _: self.serialRefresh()},
            {'name':'Selected Port', 'type':'list', 'values':[''], 'get':self.getPortName, 'set':self.setPortName},
        ])

        if (openadc_qt is None) or (serial is None):
            raise ImportError("Needed imports for serial missing")
        else:
            self.scope = oadcInstance
开发者ID:FrankMuenzner,项目名称:chipwhisperer,代码行数:14,代码来源:oadc_serial.py


注:本文中的chipwhisperer.common.utils.parameter.Parameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。