#' run the tag finder on all files from a Lotek receiver
#'
#' Called by \code{\link{processServer}}. After running the tag
#' finder, queues a new subjob that exports data.
#'
#' @param j, the job. It has these properties:
#' \enumerate{
#' \item serno: serial number of receiver; "Lotek-NNN"
#' \item tsStart: earliest timestamp of a detection in a file
#' with new data. Not used at present, but might
#' allow for pause/resume later.
#' }
#'
#' @return
#'
#' @note if topJob(j) contains fields motusUserID and motusProjectID, these are
#' recorded in the receiver database for the batch generated by this call.
#'
#' @note if topJob(j) contains the field "paramOverrides", then it is treated
#' as a string of parameter overrides for the tag finder.
#'
#' @seealso \link{\code{processServer}}
#'
#' @export
#'
#' @author John Brzustowski \email{jbrzusto@@REMOVE_THIS_PART_fastmail.fm}
handleLtFindtags = function(j) {
serno = j$serno
jobLog(j, paste0("Running tag finder on receiver ", serno))
if (updateTagDeployments())
jobLog(j, "Some tag deployment metadata were updated from motus.org")
## lock this receiver's database
lockSymbol(serno)
## make sure we unlock the receiver DB when this function exits, even on error
## NB: the runMotusProcessServer script also drops any locks held by a given
## processServer after the latter exits.
on.exit(lockSymbol(serno, lock=FALSE))
tj = topJob(j)
src = getRecvSrc(serno)
## get parameter overrides
por = getParamOverrides(serno, tsStart=Sys.time(), motusProjectID = tj$motusProjectID)
## get job-specific parameter overrides
por2 = tj$paramOverrides
if (isTRUE(nchar(por2) > 0)) {
por = paste(por, por2)
}
if (por != "")
jobLog(j, paste0("Got parameter overrides: ", por))
rv = ltFindTags(src, MOTUS_METADB_CACHE, par=paste(ltDefaultFindTagsParams, por))
if (! is.null(rv)) {
## record motus user and project IDs for this batch, which may
## be present in the top job (typically an "uploadFile" job)
muid = tj$motusUserID
mpid = tj$motusProjectID
if (!isTRUE(muid > 0))
muid = "null"
if (!isTRUE(mpid > 0))
mpid = "null"
dbGetQuery(src$con, sprintf("update batches set motusUserID=%s, motusProjectID=%s, motusJobID=%d where batchID in (%s)", muid, mpid, as.integer(j), paste(rv$batchID, collapse=",")))
}
closeRecvSrc(src)
jobLog(j, paste0("Got ", sum(rv$numHits), " tag detections."))
return(TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.