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


Python FormatUtils.formatMacString方法代码示例

本文整理汇总了Python中SmartMeshSDK.utils.FormatUtils.formatMacString方法的典型用法代码示例。如果您正苦于以下问题:Python FormatUtils.formatMacString方法的具体用法?Python FormatUtils.formatMacString怎么用?Python FormatUtils.formatMacString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmartMeshSDK.utils.FormatUtils的用法示例。


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

示例1: _manager_raw_notif_handler

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _manager_raw_notif_handler(self,manager,notifName,notif):
     
     # parse further
     if   notifName==IpMgrSubscribe.IpMgrSubscribe.NOTIFDATA:
         # try to parse data notifications as OAP (fails if not OAP payload, no problem)
         self.oapDispatch.dispatch_pkt(notifName,notif)
     elif notifName==IpMgrSubscribe.IpMgrSubscribe.NOTIFHEALTHREPORT:
         hr  = self.hrParser.parseHr(notif.payload)
         # POST HR to some URL
         self.notifCb(
             notifName    = 'hr',
             notifJson    = {
                 'name':    'hr',
                 'mac':     u.formatMacString(notif.macAddress),
                 'hr':      hr,
             },
         )
     
     # POST raw notification to some URL
     if notifName.startswith('event'):
         nm           = 'event'
     else:
         nm           = notifName
     fields = stringifyMacIpAddresses(notif._asdict())
     self.notifCb(
         notifName    = nm,
         notifJson    = {
             'manager': manager,
             'name':    notifName,
             'fields':  fields,
         },
     )
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:34,代码来源:JsonManager.py

示例2: log

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def log(self,event_type,mac=None,temperature='',generationTime=None):
     assert event_type in self.EVENT_ALL
     
     if mac:
         macString   = FormatUtils.formatMacString(mac)
     else:
         macString   = ''
     
     if generationTime!=None and self.timeOffset!=None:
         timestamp   = self.timeOffset+generationTime
     else:
         timestamp   = time.time()
     
     timestampString = '{0}.{1:03d}'.format(
         time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(timestamp)),
         int(1000*(timestamp-int(timestamp))),
     )
     
     logline = '{TIMESTAMP},{EVENT_TYPE},{MAC},{TEMPERATURE}\n'.format(
         TIMESTAMP   = timestampString,
         EVENT_TYPE  = event_type,
         MAC         = macString,
         TEMPERATURE = temperature,
     )
     
     print logline,
     self.datalogfile.write(logline)
     self.datalogfile.flush()
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:30,代码来源:SyncTemp.py

示例3: _print_allMoteInfo

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _print_allMoteInfo(self):
     
     columnNames = []
     for (mac,v) in self.allMoteInfo.items():
         for n in v:
             if n in ['macAddress','RC','reserved']:
                 continue
             columnNames += [n]
     columnNames = sorted(list(set(columnNames)))
     
     data_matrix     = []
     data_matrix    += [['mac']+columnNames]
     for (mac,v) in self.allMoteInfo.items():
         thisline    = []
         thisline   += [FormatUtils.formatMacString(mac)]
         for n in columnNames:
             if n in v:
                 thisline += [v[n]]
             else:
                 thisline += ['']
         data_matrix += [thisline]
     
     table = plotly.tools.FigureFactory.create_table(data_matrix)
     
     plotly.offline.plot(table,filename='allMoteInfo.html',)
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:27,代码来源:Timelapse2Analyze.py

示例4: oapinfo_response

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
def oapinfo_response(mac, oap_resp):
    output  = []
    output += ["GET /info response from {0}:".format(FormatUtils.formatMacString(mac))]
    output  = '\n'.join(output)
    
    print output
    print (mac, oap_resp)
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:9,代码来源:OapClient.py

示例5: _moteListFrameCb_toggleLed

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
    def _moteListFrameCb_toggleLed(self, mac, button):

        if isinstance(self.apiDef, IpMgrDefinition.IpMgrDefinition):
            # find out whether to switch LED on of off
            if button.cget("text") == "ON":
                val = 1
                button.configure(text="OFF")
            else:
                val = 0
                button.configure(text="ON")

            # send the OAP message
            try:
                self.oap_clients[mac].send(
                    OAPMessage.CmdType.PUT,  # command
                    [3, 2],  # address
                    data_tags=[OAPMessage.TLVByte(t=0, v=val)],  # parameters
                    cb=None,  # callback
                )
            except APIError as err:
                self.statusFrame.write("[WARNING] {0}".format(err))
            else:
                # update status
                self.statusFrame.write(
                    "Toggle LED command sent successfully to mote {0}.".format(FormatUtils.formatMacString(mac))
                )
        else:
            button.configure(text="N.A.")
            # update status
            self.statusFrame.write("This feature is only present in SmartMesh IP")
开发者ID:realms-team,项目名称:sol,代码行数:32,代码来源:MeshOfMeshes.py

示例6: stringifyMacIpAddresses

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
def stringifyMacIpAddresses(indict):
    '''
    in: {
        'field1':     123,
        'macAddress': [0,1,2,3,4,5,6,7],
    }
    out: {
        'field1':     123,
        'macAddress': '00-01-02-03-04-05-06-07',
    }
    '''
    outdict = indict
    for name in ['macAddress','source','dest']:
        try:
            assert len(outdict[name])==8
            outdict[name] = u.formatMacString(outdict[name])
        except KeyError:
            pass
    for name in ['ipv6Address']:
        try:
            assert len(outdict[name])==16
            outdict[name] = u.formatIpString(outdict[name])
        except KeyError:
            pass
    return outdict
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:27,代码来源:JsonManager.py

示例7: publish

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def publish(self,mac,datastream,value):
     
     # log
     if log.isEnabledFor(logging.DEBUG):
         output      = []
         output     += ['publish() called with:']
         output     += ['- mac          {0}'.format(FormatUtils.formatMacString(mac))]
         output     += ['- datastream   {0}'.format(datastream)]
         output     += ['- value        {0}'.format(value)]
         output      = '\n'.join(output)
         log.debug(output)
     
     # verify subscriber alive, if exists
     if self.subscriber:
         if not self.subscriber.isAlive():
             self.subscriber = None
             raise SystemError("subscriber is not alive during publish()")
     
     # create the datastream (or retrieve feed_id if exists)
     feed_id = self.createDatastream(mac,datastream)
     
     # publish to datastream
     self.client.put(
         url         = 'feeds/{0}.json'.format(
             feed_id,
         ),
         body        = {
         'version':         '1.0.0',
             'datastreams': [
                 {
                     'id' :              datastream,
                     'current_value':    value,
                 },
             ]
         },
     )
     
     # log
     if log.isEnabledFor(logging.DEBUG):
         output      = []
         output     += ['published to Xively:']
         output     += ['- mac          {0}'.format(FormatUtils.formatMacString(mac))]
         output     += ['- datastream   {0}'.format(datastream)]
         output     += ['- value        {0}'.format(value)]
         output      = '\n'.join(output)
         log.debug(output)
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:48,代码来源:xivelyConnector.py

示例8: _printExpectedOAPResp

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _printExpectedOAPResp(self):
     with self.dataLock:
         print '   expectedOAPResp ({0} items):'.format(len(self.expectedOAPResp))
         if self.expectedOAPResp:
             for mac in self.expectedOAPResp:
                 print '     - {0}'.format(u.formatMacString(mac))
         else:
             print '     (empty)'
开发者ID:kjones200,项目名称:smartmeshsdk,代码行数:10,代码来源:BroadcastLeds.py

示例9: handle_oap_data

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
def handle_oap_data(mac,notif):
    
    if isinstance(notif,OAPNotif.OAPTempSample):
        
        print 't={TEMP:.2f}C at {MAC}'.format(
            TEMP = float(notif.samples[0])/100,
            MAC  = FormatUtils.formatMacString(mac),
        )
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:10,代码来源:TempLogger.py

示例10: printOperationalMotes

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
def printOperationalMotes():
    
    output  = []
    output += ["{0} operational motes:".format(len(AppData().get('operationalmotes')))]
    for (i,m) in enumerate(AppData().get('operationalmotes')):
        output += ['{0}: {1}'.format(i,FormatUtils.formatMacString(m))]
    output  = '\n'.join(output)
    
    print output
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:11,代码来源:OapClient.py

示例11: _moteListFrameCb_clearTemp

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _moteListFrameCb_clearTemp(self,mac,button):
     # clear the temperature data
     self.notifClientHandler.clearTemp(mac)
     
     # update status
     self.statusFrame.write(
             "Temperature data for mote {0} cleared successfully.".format(
                 FormatUtils.formatMacString(mac),
             )
         )
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:12,代码来源:TempMonitor.py

示例12: _moteListFrameCb_clearCtrs

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _moteListFrameCb_clearCtrs(self,mac,button):
     # clear the counters
     self.notifClientHandler.clearNotifCounters(mac)
     
     # update status
     self.statusFrame.write(
             "Counters for mote {0} cleared successfully.".format(
                 FormatUtils.formatMacString(mac),
             )
         )
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:12,代码来源:TempMonitor.py

示例13: _handle_oap_notif

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
    def _handle_oap_notif(self,mac,notif):

        receive_time = float(time.time()) - self.mapmgrtime.pctomgr_time_offset
        output  = "OAP notification from {0} (receive time {1}):\n{2}".format(
            FormatUtils.formatMacString(mac),
            receive_time,
            notif
        )
        
        if AppData().get('printNotifs'):
            print output
        if AppData().get('logNotifs'):
            self.log_file.write('{0}\n'.format(output))
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:15,代码来源:OapClient.py

示例14: mac2feedId

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def mac2feedId(self,mac):
     if type(mac) in [tuple,list]:
         mac = FormatUtils.formatMacString(mac)
     
     returnVal = None
     
     with self.dataLock:
         for d in self.xivelyDevices:
             if d['serial']==mac:
                 returnVal = d['feed_id']
                 break
     
     return returnVal
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:15,代码来源:xivelyConnector.py

示例15: _moteListFrameCb_clearPkGen

# 需要导入模块: from SmartMeshSDK.utils import FormatUtils [as 别名]
# 或者: from SmartMeshSDK.utils.FormatUtils import formatMacString [as 别名]
 def _moteListFrameCb_clearPkGen(self,mac,button):
     
     # log
     log.debug("_moteListFrameCb_clearPkGen")
     
     # clear the PkGen counters
     self.notifClientHandler.clearPkGenCounters(mac)
     
     # update status
     self.statusFrame.write(
             "pkGen counters for mote {0} cleared successfully.".format(
                 FormatUtils.formatMacString(mac),
             )
         )
开发者ID:dustcloud,项目名称:smartmeshsdk,代码行数:16,代码来源:PkGen.py


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