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


Golang ContactDB.Lookup方法代碼示例

本文整理匯總了Golang中carpcomm/db.ContactDB.Lookup方法的典型用法代碼示例。如果您正苦於以下問題:Golang ContactDB.Lookup方法的具體用法?Golang ContactDB.Lookup怎麽用?Golang ContactDB.Lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在carpcomm/db.ContactDB的用法示例。


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

示例1: processNewIQData

// Consider moving this to a completely different worker binary.
func processNewIQData(contact_id string, contactdb *db.ContactDB) {
	log.Printf("%s: Processing IQ data", contact_id)

	contact, err := contactdb.Lookup(contact_id)
	if err != nil {
		log.Printf("%s: Error looking up contact: %s",
			contact_id, err.Error())
		return
	}
	if contact == nil {
		log.Printf("%s: Contact not found.", contact_id)
		return
	}

	// Get IQParams from the contact.
	var iq_params *pb.IQParams
	for _, b := range contact.Blob {
		if b.Format != nil && *b.Format == pb.Contact_Blob_IQ {
			if b.IqParams != nil {
				iq_params = b.IqParams
			}
		}
	}
	if iq_params == nil {
		log.Printf("%s: IQ blob missing", contact_id)
		return
	}

	local_path := fmt.Sprintf("%s/%s", *stream_tmp_dir, contact_id)

	png_path := fmt.Sprintf("%s.png", local_path)
	demod.Spectrogram(local_path, *iq_params, png_path,
		demod.SpectrogramTitle(*contact, *iq_params))

	if contact.SatelliteId != nil {
		blobs := processIQDataForSatellite(
			*contact.SatelliteId,
			local_path,
			*iq_params,
			*contact.StartTimestamp)
		contact.Blob = append(contact.Blob, blobs...)
	}

	log.Printf("%s: Storing updated contact: %v", contact_id, contact.Blob)

	// TODO: Need to be careful about locking the ContactDB record.
	// Currently we are the only process that modifies an existing ContactDB
	// record. In the future we may need to be more careful.
	if err := contactdb.Store(contact); err != nil {
		log.Printf("%s: Error storing contact: %s",
			contact_id, err.Error())
		return
	}
	log.Printf("%s: Wrote updated contact to db.", contact_id)
}
開發者ID:tstranex,項目名稱:carpcomm,代碼行數:56,代碼來源:queue.go


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