void MountCommand::buildBackend(Cmdline const& cl) { Backend backend; Key mpk(mp, KEY_CASCADING_NAME, KEY_END); if (!mpk.isValid()) { throw invalid_argument(mp + " is not a valid mountpoint"); } backend.setMountpoint(mpk, mountConf); backend.setBackendConfig(cl.getPluginsConfig("system/")); if (cl.debug) { cout << "Trying to load the resolver plugin " << cl.resolver << endl; } backend.addPlugin (cl.resolver); if (cl.interactive) { cout << endl; cout << "Enter a path to a file in the filesystem." << endl; cout << "The path must either not exist or be a file." << endl; cout << "For user or cascading mountpoints it must be a relative path." << endl; cout << "Then, the path will be resolved dynamically." << endl; cout << "Path: "; cin >> path; }
void Pulsar::WAPPArchive::load_extensions() { // Telescope extension Telescope *t = getadd<Telescope>(); Telescopes::Arecibo(t); // Backend extension Backend *b = getadd<Backend>(); b->set_name("WAPP"); // ObsExtension ObsExtension *o = getadd<ObsExtension>(); o->observer = hdr->observers; o->project_ID = hdr->project_id; // Receiver Receiver *r = getadd<Receiver>(); // Use codes to init recvr string rcode = hdr->frontend; if (rcode=="lbw") Arecibo::L_wide(r); else if (rcode=="sbw") Arecibo::S_wide(r); else if (rcode=="430") Arecibo::Greg_430(r); else if (rcode=="327") Arecibo::Greg_327(r); else if (rcode=="cb") Arecibo::C_band(r); else r->set_name(rcode); // TODO : figure out hybrid field in hdr // FITSUBHdr FITSSUBHdrExtension *fs = getadd<FITSSUBHdrExtension>(); fs->set_tsamp(hdr->samp_time*1e-6); }
int main(int argc, char ** argv) { std::cout<<"Compiling "<<argv[1]<<std::endl; { bf_chars.insert('+'); bf_chars.insert('-'); bf_chars.insert('<'); bf_chars.insert('>'); bf_chars.insert(','); bf_chars.insert('.'); bf_chars.insert('['); bf_chars.insert(']'); } std::string bf_filname(argv[1]); std::string c_filename(argv[2]); lexer = new First_Lexer(bf_filname); Parser * parser = new BF_Parser; Backend * backend = new C_Backend; root = parser->program(); if(parser->is_error) { std::cout<<"Compiling failed!"<<std::endl; } backend->output(c_filename); return 0; }
void UploadQueue::processEvent(const SyncEvent* _event) { Backend *backend = BackendManager::getActiveBackend(); if(backend == nullptr) { LOG(DEBUG)<<"No active backend"; return; } //accessing _event->node is dangerous it may be deleted from main thread! switch (_event->type) { case SyncEventType::DELETE: if(!checkEventValidity(*_event)) break; LOG(DEBUG)<<"Event:DELETE fullpath:"<<_event->fullPathBuffer; backend->remove(_event); break; case SyncEventType::RENAME: if(!checkEventValidity(*_event)) break; //LOG(DEBUG)<<"Event:RENAME from:"<<_event->fullPathBuffer<<" to:"<<_event->node->getFullPath(); backend->move(_event); break; case SyncEventType::UPDATE_CONTENT: if(!checkEventValidity(*_event)) break; //log_msg("Event:UPDATE_CONTENT file:%s\n",_event->node->getFullPath().c_str()); backend->put(_event); break; case SyncEventType::UPDATE_METADATA: if(!checkEventValidity(*_event)) break; //log_msg("Event:UPDATE_METADATA file:%s\n",_event->node->getFullPath().c_str()); backend->put_metadata(_event); break; default: LOG(ERROR)<<"INVALID Event: file:"<<_event->fullPathBuffer<<" TYPE:"<< SyncEvent::getEnumString(_event->type); } }
void Quilt::download( Backend &backend ) { if( getDimension() == 2 ) { REAL *ps = cpts; ps += qspec[0].offset; ps += qspec[1].offset; ps += qspec[0].index * qspec[0].order * qspec[0].stride; ps += qspec[1].index * qspec[1].order * qspec[1].stride; backend.surfpts( mapdesc->getType(), ps, qspec[0].stride, qspec[1].stride, qspec[0].order, qspec[1].order, qspec[0].breakpoints[qspec[0].index], qspec[0].breakpoints[qspec[0].index+1], qspec[1].breakpoints[qspec[1].index], qspec[1].breakpoints[qspec[1].index+1] ); } else { REAL *ps = cpts; ps += qspec[0].offset; ps += qspec[0].index * qspec[0].order * qspec[0].stride; backend.curvpts( mapdesc->getType(), ps, qspec[0].stride, qspec[0].order, qspec[0].breakpoints[qspec[0].index], qspec[0].breakpoints[qspec[0].index+1] ); } }
void SearchTab::searchButtonClicked() { QString search = ui->searchQuery->text(); if (search.isEmpty()) return; SqlUtilities::clearSearch(); ui->searchWidget->hide(); ui->searchSpinnerWidget->show(); pSpinnerMovie->start(); mSearchCount = 0; int index = ui->trackerCombo->currentIndex(); QString selected = ui->trackerCombo->currentText(); QSettings settings("Entomologist"); settings.setValue("last-search-query", search); QMapIterator<QString, Backend*> i(mIdMap); while (i.hasNext()) { i.next(); Backend *b = i.value(); if ((index == 0) || (b->name() == selected)) { mSearchCount++; b->search(search); } } }
TEST(Backend, backendName) { using namespace kdb; using namespace kdb::tools; Backend b; b.setMountpoint(Key("user/a", KEY_CASCADING_NAME, KEY_END), KeySet(0, KS_END)); EXPECT_EQ(b.getMountpoint(), "user/a"); }
void PostEntry::submitPost(int blogId, const BilboPost &postData) { setCurrentPostFromEditor(); if (d->mCurrentPost.content().isEmpty() || d->mCurrentPost.title().isEmpty()) { if (KMessageBox::warningContinueCancel(this, i18n("Your post title or body is empty.\nAre you sure you want to submit this post?") ) == KMessageBox::Cancel) { return; } } bool isNew = false; if (d->mCurrentPost.status() == BilboPost::New) { isNew = true; } QPointer<SendToBlogDialog> dia = new SendToBlogDialog(isNew, d->mCurrentPost.isPrivate(), this); dia->setAttribute(Qt::WA_DeleteOnClose, false); if (dia->exec() == QDialog::Accepted) { this->setCursor(Qt::BusyCursor); d->mCurrentPost.setProperties(postData); d->mCurrentPostBlogId = blogId; QString msgType; if (dia->isPrivate()) { msgType = i18nc("Post status, e.g Draft or Published Post", "draft"); d->mCurrentPost.setPrivate(true); } else { msgType = i18nc("Post status, e.g Draft or Published Post", "post"); d->mCurrentPost.setPrivate(false); } QString statusMsg; if (dia->isNew()) { statusMsg = i18n("Submitting new %1...", msgType); d->isNewPost = true; } else { statusMsg = i18n("Modifying %1...", msgType); d->isNewPost = false; } Q_EMIT showStatusMessage(statusMsg, true); Backend *b = new Backend(d->mCurrentPostBlogId, this); connect(b, &Backend::sigError, this, &PostEntry::slotError); if (uploadMediaFiles(b)) { qCDebug(BLOGILO_LOG) << "Uploading"; showProgressBar(); connect(b, &Backend::sigPostPublished, this, &PostEntry::slotPostPublished); if (d->isNewPost) { b->publishPost(&d->mCurrentPost); } else { b->modifyPost(&d->mCurrentPost); } } else { deleteProgressBar(); } } delete dia; }
int run_main (int, ACE_TCHAR *[]) { // Set up the backend prior to ACE_START_TEST so the initialization can // call the back end's reset(). Backend b; ACE_Log_Msg_Backend *old_b = ACE_Log_Msg::msg_backend (&b); ACE_START_TEST (ACE_TEXT ("Log_Msg_Backend_Test")); int status = 0; if (old_b != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Old backend (%@) not 0 at start\n"), old_b)); ++status; } // Reopen to get the backend established. u_long flags = ACE_LOG_MSG->flags (); flags |= ACE_Log_Msg::CUSTOM; if (-1 == ACE_LOG_MSG->open (ACE_TEXT ("Log_Msg_Backend_Test"), flags)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Reopening log"))); ++status; } // Make sure messages are getting routed correctly. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Message 1\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Message 2\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Message 3\n"))); unsigned int count = b.log_count (); if (count != 3) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Backend counted %u; expected 3\n"), count)); ++status; } // Should have seen the hooks other than close() so far. Note that // hooks_ok() logs a message so check counts before checking hooks. if (!b.hooks_ok ()) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Hooks not called correctly\n"))); ++status; } ACE_END_TEST; // Reset the backend to avoid references to our soon-to-be-destroyed one. ACE_Log_Msg::msg_backend (old_b); return status; }
void FailOverCacheAcceptor::remove(Backend& w) { LOCK(); const auto res(map_.erase(w.getNamespace())); if (res != 1) { LOG_WARN("Request to remove namespace " << w.getNamespace() << " which is not registered here"); } }
void Worker::closeClient(Connection *client) { ClientData *pData = (ClientData*)client->getData(); std::string sid = pData->session.getId(); LOG("close client, fd=%d, sid=%s", client->getSocket().getFd(), sid.c_str()); //router通知 sendToRouter(ROUTER_MSG_CLOSE, SID_LENGTH, pData->session.getId(), 0, NULL); //后端通知 Config *pConfig = Config::getInstance(); if(pConfig->bEventClose){ Backend *backend = new Backend(pEventLoop, NULL, NULL); backend->copyParam(pData->params); backend->addParam("EVENT", sizeof("EVENT") - 1, "2", 1); backend->setCloseHandler(EV_CB(this, Worker::onBackendClose)); backend->setResponseHandler(EV_CB(this, Worker::onBackendResponse)); if(!backend->run()){ delete backend; } } //释放后端请求 for(BackendList::const_iterator it = pData->backends.begin(); it != pData->backends.end(); ++it){ Backend *backend = it->first; backend->setClient(NULL); backend->shutdown(); } //取消频道订阅 for(ChannelSet::const_iterator it2 = pData->channels.begin(); it2 != pData->channels.end(); ++it2){ const std::string &chname = it2->first; ChannelList::iterator cit = arrChannels.find(chname); if(cit != arrChannels.end()){ cit->second.erase(client); if(cit->second.empty()){ sendToRouter(ROUTER_MSG_CH_UNSUB, chname.size(), chname.c_str(), 0, NULL); arrChannels.erase(cit); } } } //计数更新 pMaster->delClient(nId); //客户端列表更新 arrClients.erase(sid); //lua更新 if(pMaster->pScript && pMaster->pScript->hasCloseProc()){ pMaster->pScript->procClose(client); } delete pData; delete client; }
void MainWindow::openSearchedBug(const QString &trackerName, const QString &bugId) { for (int i = 0; i < mBackendList.size(); ++i) { Backend *b = mBackendList.at(i); if (b->name() == trackerName) { qDebug() << "openSearchedBug: mSyncRequests is now " << mSyncRequests; b->displayWidget()->loadSearchResult(bugId); } } }
TEST(Backend, SimpleBackend) { using namespace kdb; using namespace kdb::tools; Backend b; b.setMountpoint(Key("/", KEY_CASCADING_NAME, KEY_END), KeySet(0, KS_END)); EXPECT_EQ(b.getMountpoint(), "/"); b.addPlugin("resolver"); b.addPlugin("dump"); b.useConfigFile("abc"); EXPECT_TRUE(b.validated()); KeySet mountConfig; b.serialize(mountConfig); // outputGTest(mountConfig, "mountConfig"); mountConfig.rewind(); mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\/") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "This is a configuration for a backend, see subkeys for more information") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//config") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//config/path") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "abc") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//errorplugins") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//errorplugins/#5#resolver#resolver#") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//getplugins") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//getplugins/#0#resolver") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//getplugins/#5#dump#dump#") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//mountpoint") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "/") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//setplugins") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//setplugins/#0#resolver") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//setplugins/#5#dump") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; mountConfig.next(); EXPECT_EQ(mountConfig.current().getName(), "system/elektra/mountpoints/\\//setplugins/#7#resolver") << "name of element in keyset wrong"; EXPECT_EQ(mountConfig.current().getString(), "") << "string of element in keyset wrong"; }
std::string str(std::streamsize digits, std::ios_base::fmtflags f)const { log_prefix_event(m_value, "Conversion to string"); std::string s = m_value.str(digits, f); log_postfix_event(m_value, s, "Conversion to string"); return s; }
int compare(const T& i)const { log_prefix_event(m_value, i, "compare"); int r = m_value.compare(i); log_postfix_event(m_value, r, "compare"); return r; }
int compare(const logged_adaptor& o)const { log_prefix_event(m_value, o.value(), "compare"); int r = m_value.compare(o.value()); log_postfix_event(m_value, r, "compare"); return r; }
void MainWindow::syncNextTracker() { if (mBackendList.empty()) return; Backend *b = mBackendList.at(mSyncPosition); mSyncPosition++; if (mUploading) { mSyncRequests++; ui->syncingLabel->setText(QString("Uploading changes to %1").arg(b->name())); b->uploadAll(); } else { syncTracker(b); } }
void MainWindow::showEditMonitoredComponents() { MonitorDialog d; QMap<QString, QString> componentMap; // First get the list of monitored components for each tracker, so // we can compare later. QMapIterator<QString, Backend *> i(mBackendMap); while (i.hasNext()) { i.next(); componentMap[i.key()] = SqlUtilities::getMonitoredComponents(i.key()); } // When the user modifies the monitored components, // we want to update the affected trackers, and then // we need to set the last sync time to 1970 in order // to fetch the appropriate components. if (d.exec() == QDialog::Accepted) { i.toFront(); while (i.hasNext()) { i.next(); QString components = SqlUtilities::getMonitoredComponents(i.key()); qDebug() << "Components for " << i.key() << " are now " << components; if (componentMap[i.key()] != components) { Backend *b = i.value(); // Remove all of the bugs for this tracker, and resync SqlUtilities::clearBugs(b->type(), i.key()); if (components.isEmpty()) b->setMonitorComponents(QStringList()); else b->setMonitorComponents(components.split(",")); b->setLastSync("1970-01-01T12:13:14"); mSyncPosition = mBackendList.size(); syncTracker(b); } } } }
/** Register the backend 'backend' with the cluster */ void Cluster::registerBackend(const Backend &backend) { if (backend.isNull()) return; QMutexLocker lkr( &(globalCluster()->datamutex) ); if (not globalCluster()->local_backends.contains(backend.UID())) { globalCluster()->local_backends.insert( backend.UID(), backend ); #ifdef SIRE_USE_MPI //now inform the MPI connected nodes that a backend with this //UID is available on this node if (::usingMPI()) { SireCluster::MPI::MPICluster::registerBackend(backend); } #endif } }
void DirectorPlugin::pass(HttpRequest* r, const std::string& directorName, const std::string& backendName) { auto i = directors_.find(directorName); if (i == directors_.end()) { r->log(Severity::error, "director.pass(): No director with name '%s' configured.", directorName.c_str()); internalServerError(r); return; } Director* director = i->second.get(); // custom backend route Backend* backend = nullptr; if (!backendName.empty()) { backend = director->findBackend(backendName); if (!backend) { // explicit backend specified, but not found -> do not serve. r->log(Severity::error, "director: Requested backend '%s' not found.", backendName.c_str()); internalServerError(r); return; } } #if !defined(NDEBUG) server().log(Severity::trace, "director: passing request to %s [backend %s].", director->name().c_str(), backend->name().c_str()); #endif auto rn = requestNotes(r); rn->manager = director; r->onPostProcess.connect(std::bind(&DirectorPlugin::addVia, this, r)); director->schedule(rn, backend); return; }
void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const mpl::false_& tag) { unsigned limb = bit_location / (sizeof(limb_type) * CHAR_BIT); unsigned shift = bit_location % (sizeof(limb_type) * CHAR_BIT); limb_type mask = chunk_bits >= sizeof(limb_type) * CHAR_BIT ? ~static_cast<limb_type>(0u) : (static_cast<limb_type>(1u) << chunk_bits) - 1; limb_type value = static_cast<limb_type>(bits & mask) << shift; if(value) { if(val.size() == limb) { val.resize(limb + 1, limb + 1); if(val.size() > limb) val.limbs()[limb] = value; } else if(val.size() > limb) val.limbs()[limb] |= value; } if(chunk_bits > sizeof(limb_type) * CHAR_BIT - shift) { shift = sizeof(limb_type) * CHAR_BIT - shift; chunk_bits -= shift; bit_location += shift; bits >>= shift; if(bits) assign_bits(val, bits, bit_location, chunk_bits, tag); }
void update_view() { try { debug_value = m_value.str(0, static_cast<std::ios_base::fmtflags>(0)); } catch(const std::exception& e) { debug_value = "String conversion failed with message: \""; debug_value += e.what(); debug_value += "\""; } }
void Pulsar::TimerArchive::unpack_extensions () try { if (verbose == 3) cerr << "Pulsar::TimerArchive::unpack_extensions" << endl; Receiver* receiver = getadd<Receiver>(); unpack (receiver); Telescope* telescope = getadd<Telescope>(); try { telescope->set_coordinates (get_telescope()); Telescopes::set_telescope_info (telescope, this); } catch (Error& error) { if (verbose > 2) warning << "Pulsar::TimerArchive::unpack_extensions " << error.get_message().c_str() << endl; } TapeInfo* tape = getadd<TapeInfo>(); unpack (tape); if (verbose == 3) cerr << "Pulsar::TimerArchive::unpack_extensions set Backend" << endl; Backend* backend = get<Backend>(); if (!backend) { Backend* ben = getadd<Backend>(); ben->set_name (hdr.machine_id); ben->set_corrected (hdr.corrected & BE_PHS_CORRECTED); ben->set_downconversion_corrected (hdr.corrected & BE_DCC_CORRECTED); backend = ben; } if (verbose == 3) cerr << "Pulsar::TimerArchive::unpack_extensions " << backend->get_extension_name() << " name=" << backend->get_name() << endl; } catch (Error& error) { throw error += "Pulsar::TimerArchive::unpack_extensions"; }
void MainWindow::deleteTracker(const QString &id) { Backend *b = mBackendMap[id]; mBackendMap.remove(id); for (int i = 0; i < mBackendList.size(); ++i) { if (mBackendList.at(i) == b) { mBackendList.removeAt(i); break; } } QString name = b->name(); SqlUtilities::removeTracker(b->id(), name); pSearchTab->removeTracker(b); delete b; // This removes the tab as well, as the widget is destroyed QSettings settings("Entomologist"); settings.remove(QString("%1-sort-column").arg(name)); settings.remove(QString("%1-sort-order").arg(name)); settings.remove(QString("%1-header-geometry").arg(name)); }
void Worker::createClient(int fd, const char *host, int port) { //创建session对像 Session sess(nPid, fd); LOG("new client, fd=%d, host=%s, port=%d, sid=%s", fd, host, port, sess.getId()); //环镜变量 ClientData *pData = new ClientData(); char szPort[8]; int nPort = sprintf(szPort, "%d", port); pData->session = sess; pData->nrequest = 0; Backend::makeParam(pData->params, "REMOTE_ADDR", sizeof("REMOTE_ADDR") - 1, host, strlen(host)); Backend::makeParam(pData->params, "REMOTE_PORT", sizeof("REMOTE_PORT") - 1, szPort, nPort); Backend::makeParam(pData->params, "SESSIONID", sizeof("SESSIONID") - 1, sess.getId(), SID_LENGTH); //创建连接对像 Connection *client = new Connection(pEventLoop, fd); client->setHostAndPort(host, port); client->setData(pData); client->setMessageHandler(EV_CB(this, Worker::onMessage)); client->setCloseHandler(EV_CB(this, Worker::onClose)); //client->setWriteCompleteHandler(EL_CB(this, Worker::onWriteComplete)); arrClients[sess.getId()] = client; //计数更新 pMaster->addClient(nId); //Router通知 sendToRouter(ROUTER_MSG_CONN, SID_LENGTH, sess.getId(), 0, NULL); //backend通知 Config *pConfig = Config::getInstance(); if(pConfig->bEventConnect){ Backend *backend = new Backend(pEventLoop, client, NULL); backend->copyParam(pData->params); backend->addParam("EVENT", sizeof("EVENT") - 1, "1", 1); backend->setCloseHandler(EV_CB(this, Worker::onBackendClose)); backend->setResponseHandler(EV_CB(this, Worker::onBackendResponse)); if(backend->run()){ pData->backends[backend] = 1; }else{ delete backend; } } //lua通知 if(pMaster->pScript && pMaster->pScript->hasConnectProc()){ pMaster->pScript->procConnect(client); } }
/*---------------------------------------------------------------------- * getNextPts - make arrays of pointers to trim points on left and right * hulls of trim strip. *---------------------------------------------------------------------- */ void Trimline::getNextPts( REAL vval, Backend& backend ) { reset(); swap(); append( tinterp ); assert( tinterp->param[1] >= vval ); register TrimVertex *p; for( p=jarcl.getnextpt() ; p->param[1] >= vval; p=jarcl.getnextpt() ) { append( p ); } /* compute and copy pointer to final point on left hull */ if( interpvert( last(), p, binterp, vval ) ) { binterp->nuid = p->nuid; backend.triangle( p, binterp, last() ); append( binterp ); } jarcl.reverse(); (void) jarcl.getprevpt(); /* reset jarcl to proper position */ jarcl.reverse(); }
void Trimline::getPrevPts( REAL vval, Backend& backend ) { reset(); swap(); append( tinterp ); assert( tinterp->param[1] >= vval ); register TrimVertex *q; for( q=jarcl.getprevpt(); q->param[1] >= vval; q=jarcl.getprevpt() ) { append( q ); } /* compute and copy pointer to final point on right hull */ if( interpvert( q, last(), binterp, vval ) ) { binterp->nuid = q->nuid; backend.triangle( last(), binterp, q ); append( binterp ); } jarcl.reverse(); (void) jarcl.getnextpt(); /* reset jarcl to proper position */ jarcl.reverse(); }
void Pulsar::FITSArchive::load_header (const char* filename) try { int status = 0; fitsfile* fptr = 0; // Open the data file if (verbose > 2) cerr << "FITSArchive::load_header fits_open_file ("<< filename <<")"<<endl; fits_open_file (&fptr, filename, READONLY, &status); if (status != 0) throw FITSError (status, "FITSArchive::load_header", "fits_open_file(%s)", filename); // These Extensions must exist in order to load ObsExtension* obs_ext = getadd<ObsExtension>(); FITSHdrExtension* hdr_ext = getadd<FITSHdrExtension>(); // Pulsar FITS header definiton version if (verbose > 2) cerr << "FITSArchive::load_header reading FITS header version" << endl; string tempstr; string dfault; dfault = hdr_ext->hdrver; psrfits_read_key (fptr, "HDRVER", &tempstr, dfault, verbose > 2); hdr_ext->hdrver = tempstr; psrfits_version = fromstring<float>( tempstr ); if (sscanf (hdr_ext->hdrver.c_str(), "%d.%d", &hdr_ext->major_version, &hdr_ext->minor_version) != 2) throw Error (InvalidParam, "FITSARchive::load_header", "could not parse header version from " + hdr_ext->hdrver); if (verbose > 2) cerr << "Got: Version " << tempstr << endl; // File creation date if (verbose > 2) cerr << "FITSArchive::load_header reading file creation date" << endl; dfault = hdr_ext->creation_date; psrfits_read_key (fptr, "DATE", &tempstr, dfault, verbose > 2); hdr_ext->creation_date = tempstr; // Name of observer if (verbose > 2) cerr << "FITSArchive::load_header reading observer name" << endl; dfault = obs_ext->observer; psrfits_read_key (fptr, "OBSERVER", &tempstr, dfault, verbose > 2); obs_ext->observer = tempstr; if (verbose > 2) cerr << "Got observer: " << tempstr << endl; // Project ID if (verbose > 2) cerr << "FITSArchive::load_header reading project ID" << endl; dfault = obs_ext->project_ID; psrfits_read_key (fptr, "PROJID", &tempstr, dfault, verbose > 2); obs_ext->project_ID = tempstr; if (verbose > 2) cerr << "Got PID: " << tempstr << endl; // Telescope name if (verbose > 2) cerr << "FITSArchive::load_header reading telescope name" << endl; dfault = get_telescope(); psrfits_read_key (fptr, "TELESCOP", &tempstr, dfault, verbose > 2); tempstr = stringtok (tempstr, " "); if (verbose > 2) cerr << "FITSArchive::load_header TELESCOP=" << tempstr << endl; set_telescope ( tempstr ); Telescope* telescope = getadd<Telescope>(); try { Telescopes::set_telescope_info (telescope, this); } catch (Error& error) { if (verbose > 2) cerr << "FITSArchive::load_header WARNING" " could not set telescope info for " << get_telescope() << "\n\t" << error.get_message() << endl; } // RA psrfits_read_key( fptr, "RA", &tempstr, dfault, verbose > 2 ); hdr_ext->set_ra( tempstr ); // DEC psrfits_read_key( fptr, "DEC", &tempstr, dfault, verbose > 2 ); hdr_ext->set_dec( tempstr ); // Antenna ITRF coordinates load_ITRFExtension (fptr); // Receiver parameters load_Receiver (fptr); // WidebandCorrelator parameters load_WidebandCorrelator (fptr); Backend* backend = get<Backend>(); if (backend && strstr (backend->get_name().c_str(), "BPP")) { if (verbose > 3) cerr << "FITSArchive::load_header using BPP matching policy" << endl; ThresholdMatch::set_BPP (this); } // // // Figure out what kind of observation it was // // if (verbose > 2) cerr << "FITSArchive::load_header reading OBS_MODE" << endl; psrfits_read_key (fptr, "OBS_MODE", &tempstr); string obs_mode = tempstr; if (verbose > 2) cerr << "FITSArchive::load_header OBS_MODE='" << obs_mode << "'" << endl; hdr_ext->set_obs_mode( obs_mode ); if (obs_mode == "PSR" || obs_mode == "LEVPSR") { set_type ( Signal::Pulsar ); if (verbose > 2) cerr << "FITSArchive::load_header using Signal::Pulsar" << endl; } else if (obs_mode == "CAL" || obs_mode == "LEVCAL") set_type ( Signal::PolnCal ); else if (obs_mode == "FOF") set_type ( Signal::FluxCalOff ); else if (obs_mode == "FON") set_type ( Signal::FluxCalOn ); else if (obs_mode == "PCM") set_type ( Signal::Calibrator ); else if (obs_mode == "SEARCH" || obs_mode == "SRCH") { search_mode = true; set_type ( Signal::Unknown ); if (verbose > 2) cerr << "FITSArchive::load_header search mode file" << endl; } else { if (verbose > 2) cerr << "FITSArchive::load_header WARNING unknown OBSTYPE = " << tempstr <<endl; set_type ( Signal::Unknown ); } // // // Read the centre frequency of the observation // // { double dfault = 0.0; double centre_frequency; psrfits_read_key (fptr, "OBSFREQ", ¢re_frequency, dfault, verbose > 2); set_centre_frequency( centre_frequency ); hdr_ext->set_obsfreq( centre_frequency ); } // Read the bandwidth of the observation { double dfault = 0.0; double bandwidth; psrfits_read_key (fptr, "OBSBW", &bandwidth, dfault, verbose > 2); set_bandwidth( bandwidth ); hdr_ext->set_obsbw( bandwidth ); } // Read the number of channels of the observation { int obsnchan; psrfits_read_key (fptr, "OBSNCHAN", &obsnchan, 0, verbose > 2); hdr_ext->set_obsnchan( obsnchan ); } // Read the name of the source if (verbose > 2) cerr << "FITSArchive::load_header reading source name" << endl; psrfits_read_key (fptr, "SRC_NAME", &tempstr); set_source ( tempstr ); // Read where the telescope was pointing if (verbose > 2) cerr << "FITSArchive::load_header reading coordinates" << endl; dfault = hdr_ext->coordmode; psrfits_read_key (fptr, "COORD_MD", &tempstr, dfault, verbose > 2); hdr_ext->coordmode = tempstr; if (verbose > 2) cerr << "Got coordinate type: " << tempstr << endl; if (verbose > 2) cerr << "FITSArchive::load_header reading equinox" << endl; dfault = "pre version 2.8"; psrfits_read_key (fptr, "EQUINOX", &tempstr, dfault, verbose > 2); if ((tempstr == dfault) || (tempstr.empty())) { // // The file was created before the EQUINOX attribute was added, // or was mistakenly created with a null equinox. // hdr_ext->equinox = "2000.0"; } else { hdr_ext->equinox = tempstr; if (verbose > 2) cerr << "Got equinox: " << tempstr << endl; } // // PSRFITS definitons versions before 2.8 have // COORD_MD = J2000 // and no EQUINOX attribute // // PSRFITS definition versions 2.8 to 2.10 have // COORD_MD = EQUAT // EQUINOX = J2000 // // PSRFITS definition version 2.11 has // COORD_MD = J2000 (again) // EQUINOX = 2000.0 // if (hdr_ext->coordmode == "EQUAT") hdr_ext->coordmode = "J2000"; if (hdr_ext->equinox == "J2000") hdr_ext->equinox = "2000.0"; // // ... also, since PSRFITS definition version 2.8, "Gal" is "GAL" // if (hdr_ext->coordmode == "Gal" || hdr_ext->coordmode == "GALACTIC") hdr_ext->coordmode = "GAL"; // // ... also, if unset assume J2000 // if (hdr_ext->coordmode == "UNSET") { warning << "FITSArchive::load_header WARNING" " assuming J2000 coordinates" << endl; hdr_ext->coordmode = "J2000"; } sky_coord coord; if (hdr_ext->coordmode == "J2000") { dfault = ""; psrfits_read_key (fptr, "RA", &tempstr, dfault, verbose > 2); string stt_crd1 = ""; psrfits_read_key (fptr, "STT_CRD1", &stt_crd1, dfault, verbose > 2); hdr_ext->set_stt_crd1(stt_crd1); // If RA exists, set the ra from the value of RA. // Otherwise, set the ra to the value of STT_CRD1 const string hms = !tempstr.empty() ? tempstr : stt_crd1; psrfits_read_key (fptr, "DEC", &tempstr, dfault, verbose > 2); string stt_crd2 = ""; psrfits_read_key (fptr, "STT_CRD2", &stt_crd2, dfault, verbose > 2); hdr_ext->set_stt_crd2(stt_crd2); // If DEC exists, set the dec from the value of DEC. // Otherwise, set the dec to the value of STT_CRD2 const string dec = !tempstr.empty() ? tempstr : stt_crd2; coord.setHMSDMS (hms.c_str(), dec.c_str()); psrfits_read_key (fptr, "STP_CRD1", &tempstr, dfault, verbose > 2); if (!tempstr.empty()) hdr_ext->set_stp_crd1(tempstr); psrfits_read_key (fptr, "STP_CRD2", &tempstr, dfault, verbose > 2); if (!tempstr.empty()) hdr_ext->set_stp_crd2(tempstr); } else if (hdr_ext->coordmode == "GAL") { double dfault = 0.0; double co_ord1, co_ord2; psrfits_read_key (fptr, "STT_CRD1", &co_ord1, dfault, verbose > 2); psrfits_read_key (fptr, "STT_CRD2", &co_ord2, dfault, verbose > 2); AnglePair temp; temp.setDegrees(co_ord1,co_ord2); coord.setGalactic(temp); } else if (verbose > 2) cerr << "FITSArchive::load_header WARNING COORD_MD=" << hdr_ext->coordmode << " not implemented" << endl; set_coordinates (coord); if (get_type() != Signal::Pulsar && get_type() != Signal::Unknown) load_CalInfoExtension (fptr); // Track mode if (verbose > 2) cerr << "FITSArchive::load_header reading track mode" << endl; dfault = hdr_ext->trk_mode; psrfits_read_key (fptr, "TRK_MODE", &tempstr, dfault, verbose > 2); hdr_ext->trk_mode = tempstr; // // Since PSRFITS version 2.8, the UTC date and time are stored in one string // if (verbose > 2) cerr << "FITSArchive::load_header reading observation date" << endl; dfault = "pre version 2.8"; psrfits_read_key (fptr, "DATE-OBS", &tempstr, dfault, verbose > 2); if ((tempstr == dfault) || (tempstr.empty())) { // // Before version 2.8, the UTC date and time were stored separately // // Read the start UT date if (verbose > 2) cerr << "FITSArchive::load_header reading start date" << endl; dfault = hdr_ext->stt_date; psrfits_read_key (fptr, "STT_DATE", &tempstr, dfault, verbose > 2); hdr_ext->stt_date = tempstr; // Read the start UT if (verbose > 2) cerr << "FITSArchive::load_header reading start UT" << endl; dfault = hdr_ext->stt_time; psrfits_read_key (fptr, "STT_TIME", &tempstr, dfault, verbose > 2); // strip off any fractional seconds, if present size_t decimal = tempstr.find('.'); if (decimal != string::npos) tempstr = tempstr.substr (0, decimal); hdr_ext->stt_time = tempstr; } else { // // Since version 2.8, the UTC date and time are stored as one string // // // Separate the date and time at the expected point in the string // const unsigned date_length = strlen ("YYYY-MM-DD"); if (tempstr.length() >= date_length) hdr_ext->stt_date = tempstr.substr(0,date_length); if (tempstr.length() > date_length) hdr_ext->stt_time = tempstr.substr(date_length+1); if (verbose > 2) cerr << "FITSArchive::load_header DATE-0BS parsed into\n" " date='" << hdr_ext->stt_date << "'\n" " time='" << hdr_ext->stt_time << "'\n"; } // Read the bpa if (verbose > 2) cerr << "FITSArchive::load_header reading BPA" << endl; dfault = "0.0"; psrfits_read_key( fptr, "BPA", &tempstr, dfault, verbose > 2 ); if( tempstr == "*" ) hdr_ext->set_bpa( 0 ); else hdr_ext->set_bpa( fromstring<double>(tempstr) ); // Read the bmaj if (verbose > 2) cerr << "FITSArchive::load_header reading BMAJ" << endl; dfault = "0.0"; psrfits_read_key( fptr, "BMAJ", &tempstr, dfault, verbose > 2 ); if( tempstr == "*" ) hdr_ext->set_bpa( 0 ); else hdr_ext->set_bmaj( fromstring<double>(tempstr) ); // Read the bmin if(verbose > 2 ) cerr << "FITSArchive::load_header reading BMIN" << endl; dfault = "0.0"; psrfits_read_key( fptr, "BMIN", &tempstr, dfault, verbose > 2 ); if( tempstr == "*" ) hdr_ext->set_bpa( 0 ); else hdr_ext->set_bmin( fromstring<double>(tempstr) ); // ///////////////////////////////////////////////////////////////// // Read start MJD long day; long sec; double frac; if (verbose > 2) cerr << "FITSArchive::load_header reading MJDs" << endl; psrfits_read_key (fptr, "STT_IMJD", &day, (long)0, verbose > 2); psrfits_read_key (fptr, "STT_SMJD", &sec, (long)0, verbose > 2); psrfits_read_key (fptr, "STT_OFFS", &frac, 0.0, verbose > 2); hdr_ext->set_start_time( MJD ((int)day, (int)sec, frac) ); if (verbose > 2) cerr << "FITSArchive::load_header" " MJD=" << hdr_ext->get_start_time().printall() << endl; // Read the start LST (in seconds) if (verbose > 2) cerr << "FITSArchive::load_header reading start LST" << endl; psrfits_read_key (fptr, "STT_LST", &(hdr_ext->stt_lst), 0.0, verbose > 2); // Read the IBEAM value (for multibeam data) if (verbose > 2) cerr << "FITSArchive::load_header reading IBEAM" << endl; // If the keyword does not exist, set ibeam value to a blank string dfault = ""; psrfits_read_key (fptr, "IBEAM", &tempstr, dfault, verbose > 2); hdr_ext->ibeam = tempstr; if (verbose > 2) cerr << "FITSArchive::load_header IBEAM='" << hdr_ext->ibeam << "'" << endl; // Read the PNT_ID (for multibeam data) if (verbose > 2) cerr << "FITSArchive::load_header reading PNT_ID" << endl; // If PNT_ID does not exist, set pnt_id to "" string default_pnt_id_value = ""; psrfits_read_key (fptr, "PNT_ID", &(hdr_ext->pnt_id), default_pnt_id_value, verbose > 2); if (verbose > 2) cerr << "FITSArchive::load_header PNT_ID='" << hdr_ext->pnt_id << "'" << endl; // //////////////////////////////////////////////////////////////// // Finished with primary header information // //////////////////////////////////////////////////////////////// if (verbose > 2) cerr << "FITSArchive::load_header finished with primary HDU" << endl; // Load the processing history load_ProcHistory (fptr); // Load the digitiser statistics load_DigitiserStatistics (fptr); // Load the digitiser counts load_DigitiserCounts(fptr ); // Load the original bandpass data load_Passband (fptr); // Load the coherent dedispersion extension load_CoherentDedispersion (fptr); // Load the flux calibrator extension load_FluxCalibratorExtension (fptr); // Load the calibrator stokes parameters load_CalibratorStokes (fptr); // Load the calibration model description load_PolnCalibratorExtension (fptr); // Load the parameters from the SUBINT HDU load_FITSSUBHdrExtension( fptr ); // Load the pulsar parameters if (get_type() == Signal::Pulsar) load_Parameters (fptr); // Load the pulse phase predictor load_Predictor (fptr); hdr_model = model; if (correct_P236_reference_epoch) P236_reference_epoch_correction (); load_integration_state (fptr); status = 0; // Finished with the file for now fits_close_file (fptr, &status); if (status) throw FITSError (status, "Pulsar::FITSArchive::load_header", "fits_close_file"); loaded_from_fits = true; if (verbose > 2) cerr << "FITSArchive::load_header exit" << endl; } catch (Error& error) { throw error += "FITSArchive::load_header"; }
void negate() { log_prefix_event(m_value, "negate"); m_value.negate(); log_postfix_event(m_value, "negate"); }
// Called from the tracker tab to display the context menu void MainWindow::showMenu(int tabIndex) { QMenu contextMenu(tr("Context menu"), this); QAction *a; // Show a different context menu for the search tab int searchIndex = ui->trackerTab->indexOf(pSearchTab); if (tabIndex == searchIndex) { QAction *searchAction = contextMenu.addAction(tr("Clear Results")); a = contextMenu.exec(QCursor::pos()); if (a == searchAction) { SqlUtilities::clearSearch(); QSettings settings("Entomologist"); settings.setValue("last-search-query", ""); pSearchTab->refreshResults(); } return; } QString trackerName = ui->trackerTab->tabText(tabIndex); Backend *b = NULL; for (int i = 0; i < mBackendList.size(); ++i) { b = mBackendList.at(i); if (trackerName == b->name()) break; } if (b == NULL) return; QString id = b->id(); QAction *editAction = contextMenu.addAction(tr("Edit")); QAction *deleteAction = contextMenu.addAction(tr("Delete")); QAction *resyncAction = contextMenu.addAction(tr("Resync")); a = contextMenu.exec(QCursor::pos()); if (a == editAction) { NewTracker t(this, true); QString tmpName = b->name(); t.setName(b->name()); t.setHost(b->url()); t.setUsername(b->username()); t.setPassword(b->password()); t.setTrackerType(b->type()); if (t.exec() == QDialog::Accepted) { bool updateName = false; if (t.data().value("name") != tmpName) updateName = true; updateTracker(id, t.data(), updateName); } } else if (a == deleteAction) { QMessageBox box; box.setText(QString("Are you sure you want to delete %1?").arg(b->name())); box.setStandardButtons(QMessageBox::Yes|QMessageBox::No); if (box.exec() == QMessageBox::Yes) { deleteTracker(id); } } else if (a == resyncAction) { mSyncPosition = mBackendList.size(); syncTracker(b); } }