當前位置: 首頁>>代碼示例>>Python>>正文


Python Device.Device類代碼示例

本文整理匯總了Python中Device.Device的典型用法代碼示例。如果您正苦於以下問題:Python Device類的具體用法?Python Device怎麽用?Python Device使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Device類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, config, device_no=1, hot_start=False, print_logs=False):

        Device.__init__(self, config, device_no, hot_start, print_logs)

        # Basics
        self.CommandEndCharacter = '\r\n'
        self.ReadSleepTime = .1
        self.WriteSleepTime = .1
        self.AnswerTime = .1
        self.Config = config
        self.MaxVoltage = None

        self.Identifier = None
        self.Model = None

        # Serial
        self.bOpen = False
        self.SerialPortName = self.Config.get(self.SectionName, 'address')
        self.Serial = None
        self.open_serial_port()

        # Info
        self.Busy = False
        self.last_write = ''
        self.LastMeasurement = -1
        self.LastCurrents = []
        self.LastVoltages = []
        self.LastStatusUpdate = -1
        self.LastStatus = []
        self.lastVoltage = 0
        self.CanRamp = True

        self.init_device(hot_start)
        self.hot_start()
開發者ID:diamondIPP,項目名稱:keithleyClient,代碼行數:34,代碼來源:ISEG.py

示例2: __init__

    def __init__(self):

        Device.__init__(self)

        self.__pagein  = 0
        self.__pageout = 0
        self.__time    = time.time()
        self.__lock    = threading.Lock()
開發者ID:RaumZeit,項目名稱:gdesklets-core,代碼行數:8,代碼來源:Swap.py

示例3: unicalDev

	def unicalDev(self, dev):
		unicality = True
		d = Device(dev)
		for device in self.data_list :
			if d.device_name() == device.device_name() and \
			   d.device_type() == device.device_type() :
				unicality = False
				break
		return unicality
開發者ID:elemc,項目名稱:scod,代碼行數:9,代碼來源:DevicesListModel.py

示例4: __init__

    def __init__(self, dev):

        Device.__init__(self)

        self.__dev = dev
        buf = gtop.netload(dev)
        self.__in, self.__out = buf.bytes_in, buf.bytes_out
        self.__time = time.time()
        self.__lock = threading.Lock()
開發者ID:RaumZeit,項目名稱:gdesklets-core,代碼行數:9,代碼來源:Net.py

示例5: addComputer

 def addComputer(self, name):
     device = Device('computer.jpg', name, 'computer',  self)
     device.move(100, 65)
     device.show()
     self.deviceList.append(device)
     try:
         self.detailsWindow.updateDetails()
     except Exception as e:
         pass
開發者ID:kiadyrakotomalala,項目名稱:PythonNetworkSimulator,代碼行數:9,代碼來源:Simulator.py

示例6: enrollDevice

def enrollDevice(deviceOwner = "", deviceType = "", deviceName = ""):
    deviceId = generateId()
    device = Device()
    device.deviceID = deviceId
    device.deviceType = deviceType
    device.deviceName = deviceName
    device.deviceOwner = deviceOwner

    deviceDao = DeviceDAO()
    return deviceDao.createDevice(device)
開發者ID:CodeLankaHack,項目名稱:team---iAS,代碼行數:10,代碼來源:EnrollDevice.py

示例7: __init__

    def __init__(self):

        Device.__init__(self)

        self.__total = 0.0
        self.__user  = 0.0
        self.__sys   = 0.0
        self.__nice  = 0.0
        self.__idle  = 0.0
        self.__lock  = threading.Lock()
開發者ID:RaumZeit,項目名稱:gdesklets-core,代碼行數:10,代碼來源:CPU.py

示例8: build_device

 def build_device(self, the_json):
     d = Device()
     if "name" in the_json:
         d.name = the_json["name"]
     if "sensors" in the_json:
         for sensor in the_json["sensors"]:
             if '__type__' in sensor and sensor['__type__'] == 'Sensor':
                 self.build_sensor(d, sensor)
     if "actuator" in the_json:
         self.build_actuator(d, the_json["actuator"])
     return d
開發者ID:matthewhauer,項目名稱:dashboard,代碼行數:11,代碼來源:DeviceLoader.py

示例9: __init__

    def __init__(self, key, port, host=''):
        import socket
        from NetRenderer import NetRenderer

        Device.__init__(self, NetRenderer())

        self.host = host
        self.port = port

        import journal
        self._marshaller = journal.pickler()
        self._marshaller.key = key

        return
開發者ID:bmi-forum,項目名稱:bmi-pyre,代碼行數:14,代碼來源:TCPDevice.py

示例10: __init__

    def __init__(self, key, port, host=''):
        import socket
        from NetRenderer import NetRenderer

        Device.__init__(self, NetRenderer())

        import pyre.ipc
        self._connection = pyre.ipc.connection('udp')
        self._connection.connect((host, port))

        import journal
        self._marshaller = journal.pickler()
        self._marshaller.key = key

        return
開發者ID:Alex-Song,項目名稱:vmaf,代碼行數:15,代碼來源:UDPDevice.py

示例11: scan_response_handler

    def scan_response_handler(self, sender, args):
        '''
        Handles all of the scan response data and stores it in a list of device objects

        :param sender:
        :param args:
        :return:
        '''
        addr = args['sender']
        if not self.find_device(addr):
            d = Device(self.bglib, self.cmd_q, addr)
            self.devices.append(d)

            ad_data = parse_scan_response_data(args['data'])
            if 'name' in ad_data:
                d.name = ad_data['name']
開發者ID:AshtonInstruments,項目名稱:BLEPython,代碼行數:16,代碼來源:Adapter.py

示例12: __init__

    def __init__(self, config, device_no=1, hot_start=False):

        Device.__init__(self, config, device_no, hot_start)

        # Serial
        self.bOpen = False
        self.bOpenInformed = False
        self.serialPortName = config.get(self.SectionName, 'address')
        self.baudrate = config.getint(self.SectionName, 'baudrate')
        self.serial = None
        self.commandEndCharacter = chr(13) + chr(10)

        self.writeSleepTime = 0.1
        self.readSleepTime = 0.2
        self.measurements = deque()
        self.last_voltage = 0
        self.identifier = None
        self.Model = None
        self.MaxVoltage = None
        self.manual = False
        self.open_serial_port()
開發者ID:diamondIPP,項目名稱:keithleyClient,代碼行數:21,代碼來源:KeithleyHead.py

示例13: parseDevice

    def parseDevice(jsonData):
        decoded = json.loads(jsonData)
#         for a in decoded.keys():
#             print decoded[a]
#             for b in decoded[a].keys():
#                 print decoded[a][b]
        device = Device()
        device.DeviceType = decoded['device']['DeviceType']
        device.Name = decoded['device']['Name']
        device.Battery = decoded['device']['Battery']
        device.UnReadMessages = decoded['device']['UnReadMessages']
        device.PhoneCall = decoded['device']['PhoneCall']
        device.Mac = decoded['device']['Mac']
        return device
開發者ID:liushiwei,項目名稱:PTPC,代碼行數:14,代碼來源:jsonParse.py

示例14: evaluate

    def evaluate(self, batchess, results, result_format, num_frames):
      """
      :param list[list[EngineBatch.Batch]] batchess: batches per device
      :param list[list[numpy.ndarray]] results: results per device
      :param list[str]|None result_format: describes what we have in a result list
      :type num_frames: NumbersDict
      :returns some score or None
      :rtype: dict[str] | None
      """
      assert results
      assert result_format  # train should always have the format
      assert num_frames["data"] > 0

      # We can get info such as "cost:..." and more info such as gradient_norm.
      # See Device.initialize().
      # We might also get gparams or ctc_priors or so. We will filter them out below when not needed.
      results = [Device.make_result_dict(res, result_format) for res in results]

      batch_norm_fact = 1 if not self.share_batches else 1.0 / len(self.devices)
      summed_results = {}
      for key in results[0].keys():
        summed_results[key] = sum([res[key] for res in results]) * batch_norm_fact

      # Accumulate for epoch stats.
      for key, value in summed_results.items():
        if key.startswith("gparam:"): continue
        if key not in self.results:
          self.results[key] = value # / float(num_frames[target])
        else:
          self.results[key] += value # / float(num_frames[target])

      # Prepare eval info stats for this (multiple-)batch run.
      eval_info = {}
      for key, value in summed_results.items():
        if key.startswith("gparam:"): continue
        if key == "ctc_priors": continue
        target = self._get_target_for_key(key)
        eval_info[key] = value / float(num_frames[target])

      #if numpy.isinf(score) or numpy.isnan(score):
      #  for i, res in enumerate(results):
      #    if numpy.isinf(res["cost"]) or numpy.isnan(res["cost"]):
      #      raise ModelBrokenError("Model is broken, got %s score." % score, batchess[i])
      #  assert False  # Should not get here.
      return eval_info
開發者ID:atuxhe,項目名稱:returnn,代碼行數:45,代碼來源:EngineTask.py

示例15: finish

      def finish(self):
        """
        :returns whether everything is fine.
        """
        device_results, outputs_format = self.device_collect_results()
        if device_results is None:
          if not getattr(sys, "exited", False):
            print("device crashed on batch", self.run_start_batch_idx, file=log.v3)
          self.parent.device_crash_batch = self.run_start_batch_idx
          self.crashed = True
          return False
        assert len(device_results) == len(self.alloc_devices) == len(self.running_devices_batches)

        if outputs_format and any([k.startswith("gparam:") for k in outputs_format]):
          # WARNING: this code is untested and likely broken!
          for i in range(len(self.alloc_devices)):
            res = Device.make_result_dict(device_results[i], outputs_format)
            self.alloc_devices[i].sync_net_train_params()
            devnet = self.alloc_devices[i].get_net_train_params(self.parent.network)
            vars = self.parent.network.get_all_params_vars()
            for p, q in zip(vars, devnet):
              p.set_value(q)
            gparams = {}
            for p in vars:
              gparams[p] = numpy.zeros(p.get_value(borrow=True, return_internal_type=True).shape, dtype=theano.config.floatX)
            for p in vars:
              q = res["gparam:%s" % p.name]
              if q.shape == p.get_value().shape:
                gparams[p] = q
              elif q.shape:
                print("warning: shape for gradient does not match:", p.get_value().shape, q.shape, file=log.v2)
            self.parent.updater.setNetParamDeltas(gparams)
            self.parent.updater.update()
            self.alloc_devices[i].set_net_params(self.parent.network)

        self.result = { 'batchess': self.running_devices_batches,
                        'results': device_results,
                        'result_format': outputs_format,
                        'num_frames': self.num_frames }
        self.eval_info = self.parent.evaluate(**self.result)
        self.parent.lock.acquire()
        self.print_process()
        self.parent.lock.release()
        return True
開發者ID:rwth-i6,項目名稱:returnn,代碼行數:44,代碼來源:EngineTask.py


注:本文中的Device.Device類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。