示例#1
0
    void run() {
        for ( int i = 0; i < 3; ++i ) {
            BSONObj k = simpleKey( 'b' + 2 * i );
            insert( k );
        }

        locate( 1, 'a', 'b', dl() );
        locate( 1, 'c', 'd', dl() );
        locate( 1, 'e', 'f', dl() );
        locate( 1, 'g', 'g' + 1, DiskLoc() ); // of course, 'h' isn't in the index.

        // old behavior
        //       locate( -1, 'a', 'b', dl() );
        //       locate( -1, 'c', 'd', dl() );
        //       locate( -1, 'e', 'f', dl() );
        //       locate( -1, 'g', 'f', dl() );

        locate( -1, 'a', 'a' - 1, DiskLoc() ); // of course, 'a' - 1 isn't in the index
        locate( -1, 'c', 'b', dl() );
        locate( -1, 'e', 'd', dl() );
        locate( -1, 'g', 'f', dl() );
    }
示例#2
0
Cell* eval(Cell* const c)
{
	initialize(c);
	if (c == nil)
		throw RuntimeError("Empty list\n     : At Cell* eval()");
	string s;
	if (!listp(c) && symbolp(c) && fstack.empty())
		throw RuntimeError("Attempt to reference an unbound variable \"" + get_symbol(c) + "\"" + "\n     : At Cell* eval()");
	else if (!listp(c) && !fstack.empty() && symbolp(c)) {
		s = get_symbol(c);
		CellMap::iterator find_key;
		if (fstack.size() > 1) {
			find_key = fstack[1].find(s);
			if (find_key != fstack[1].end())
				return ceval(find_key->second);
		}
		find_key = fstack[0].find(s);
		if (find_key == fstack[0].end())
			throw RuntimeError("Attempt to reference an unbound variable \"" + s + "\"" + "\n     : At Cell* eval()");
		return ceval(find_key->second);
	}
	if (!listp(c) && !symbolp(c))
		return c;
	else if (listp(c) && !symbolp(car(c)) && !listp(car(c)))
		throw RuntimeError("Invalid operator\n     : At Cell* eval()");
	else if (listp(car(c))) {
		if (nullp(car(c)))
			throw RuntimeError("Cannot evaluate a null expression\n     : At Cell* eval()");
		return ceval(c); // pass it to ceval if it's a double list
	}
	s = get_symbol(car(c));
	vector<string>::iterator find_op = locate(op.begin(), op.end(), s);
	if (find_op != op.end())
		return ceval(c);
	else if (fstack.size() > 1) {
		CellMap::iterator find_key = fstack[1].find(s);
		if (find_key != fstack[1].end())
			return ceval(c);// return apply(ceval(find_key->second), cdr(c));
	}
	throw RuntimeError("Invalid operator \"" + s + "\"\n     : At Cell* eval()");
}
示例#3
0
void MB8877::cmd_readtrack(char cmd)
{
	uint	i;

#ifdef FDC_DEBUG
	fdcdisplay((char*)"III READ_TRACK");
#endif

	// type-3 read track
	 fdc.cmdtype = cmd;
//	status = FDC_ST_DRQ | FDC_ST_BUSY;
	reg[STATUS] = FDC_ST_BUSY | FDC_ST_RECNFND;

	// If side Compare flag is set, compare the current and desired sides
	// and exits if they differ.
	if ((reg[CMD] & FDC_FLAG_VERIFICATION) && (reg[CMD] & 0x08) != fdc.side) return;

	// Try to set file cursor at the desired position.
	if (! disk.seek(locate()) ) return;	// Exit with record not found status

	// Send ID RECORD
	for(i=0; i<80; i++) send_qx1(0x4e);	// 000-079: (G) GAP 0
	for(i=0; i<12; i++) send_qx1(0x00);	// 080-091: (G) SYNC
	for(i=0; i<3; i++) send_qx1(0xc2);	// 092-(G) Index address mark
	send_qx1(0xfc);				// (G) Index address mark
	for(i=0; i<50; i++) send_qx1(0x4e);	// (G) GAP 1
	for(i=0; i<12; i++) send_qx1(0x00);	// (G) SYNC
	// Send DATA
	if(reg[TRACK]<80)
	{
		reg[SECTOR]=0+fdc.side*5; cmd_readdata(FDC_CMD_RD_TRK);
		reg[SECTOR]=3+fdc.side*5; cmd_readdata(FDC_CMD_RD_TRK);
		reg[SECTOR]=1+fdc.side*5; cmd_readdata(FDC_CMD_RD_TRK);
		reg[SECTOR]=4+fdc.side*5; cmd_readdata(FDC_CMD_RD_TRK);
		reg[SECTOR]=2+fdc.side*5; cmd_readdata(FDC_CMD_RD_TRK);
	}
	else
		for(i=0; i<9; i++)
			reg[SECTOR]=0+fdc.side*10; cmd_readdata(FDC_CMD_RD_TRK);
	for(i=0; i<22; i++) send_qx1(0x4e);	// (G) GAP 2
}
示例#4
0
文件: hash.c 项目: ombt/ombt
int
retrieve(const HashTable &ht, DataItem *&d)
{
        // get bucket for data item
        int ib = (*ht.hasher)(d, ht.tableSize);

        // remove from hash table
        ListPosition p;
        if (ht.table[ib] == NULLLIST)
                return(NOMATCH);
        if (locate(*ht.table[ib], d, p) != OK)
                return(NOMATCH);
        if (retrieve(*ht.table[ib], d, p) != OK)
        {
                ERRORI("retrieve failed for bucket ...", ib);
                return(NOTOK);
        }

        // all done
        return(OK);
}
示例#5
0
void AlarmClient::startDaemon()
{
    if(kapp->dcopClient()->isApplicationRegistered("korgac"))
    {
        // Alarm daemon already runs
        return;
    }

    KGlobal::dirs()->addResourceType("autostart", "share/autostart");
    QString desktopFile = locate("autostart", "korgac.desktop");
    if(desktopFile.isEmpty())
    {
        kdWarning() << "Couldn't find autostart/korgac.desktop!" << endl;
    }
    else
    {
        QString error;
        if(kapp->startServiceByDesktopPath(desktopFile, QStringList(), &error) != 0)
            kdWarning() << "Failure starting korgac:" << error << endl;
    }
}
示例#6
0
void Wallpaper::paperSelected( int item )
{
    QMap<QString, int>::ConstIterator end = papers.end();
    for ( QMap<QString, int>::ConstIterator it = papers.begin();
          it != end;
          ++it )
    {
        if ( it.data() == item )
        {
            QImage wp;
            QString file = locate( "wallpaper", it.key() );
            wp.load( file );
            wp = wp.smoothScale( 140, 105 );
            QPixmap pix( wp );
            pix_wallpaper->setPixmap( pix );

            selectedPaper = it.key();
            break;
        }
    }
}
        boost::optional<IndexKeyEntry> seek(const BSONObj& key,
                                            bool inclusive,
                                            RequestedInfo parts) override {
            if (key.isEmpty()) {
                _it = inclusive ? _data.begin() : _data.end();
                _isEOF = (_it == _data.end());
                if (_isEOF) {
                    return {};
                }
            } else {
                const BSONObj query = stripFieldNames(key);
                locate(query, _forward == inclusive ? RecordId::min() : RecordId::max());
                _lastMoveWasRestore = false;
                if (_isEOF)
                    return {};
                dassert(inclusive ? compareKeys(_it->key, query) >= 0
                                  : compareKeys(_it->key, query) > 0);
            }

            return *_it;
        }
示例#8
0
int ft_cli_socktcp(t_sockaddr_in *sin, char *login)
{
    int sock;
    char *ip;

    if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == -1)
        error("socket -> ");
    if (!(ip = locate(login)))
    {
        printf("login invalide\n");
        exit(-1);
    }
    printf("%s : %s\n", login, ip);
    if (!(sin->sin_addr.s_addr = ft_inet_addr(ip)))
        error("inet error ->");
    sin->sin_family = PF_INET;
    sin->sin_port = ft_htons(PORT);

    ft_putendl("connect");
    return (sock);
}
示例#9
0
void ConfFilters::load()
{
	TQFile	f(locate("data","tdeprintfax/faxfilters"));
	if (f.exists() && f.open(IO_ReadOnly))
	{
		TQTextStream	t(&f);
		TQString		line;
		int		p(-1);
		TQListViewItem	*item(0);
		while (!t.eof())
		{
			line = t.readLine().stripWhiteSpace();
			if ((p=line.find(TQRegExp("\\s"))) != -1)
			{
				TQString	mime(line.left(p)), cmd(line.right(line.length()-p-1).stripWhiteSpace());
				if (!mime.isEmpty() && !cmd.isEmpty())
					item = new TQListViewItem(m_filters, item, mime, cmd);
			}
		}
	}
}
示例#10
0
文件: pl_ini.c 项目: nworkers/smsplus
int pl_ini_get_string(const pl_ini_file *file, 
                      const char *section, 
                      const char *key,
                      const char *default_value,
                      char *copy_to,
                      int dest_len)
{
  pl_ini_pair *pair = locate(file, section, key);
  if (pair)
  {
    strncpy(copy_to, pair->value, dest_len);
    return 1;
  }
  else if (default_value)
  {
    strncpy(copy_to, default_value, dest_len);
    return 1;
  }

  return 0;
}
示例#11
0
文件: fifteen.c 项目: spitis/cs50
//calculate a modified manhattan distance
float manDistance() {
    float manDist = 0;
    for (int i = 1; i < d*d; i++) {
        locate(i);
        
        //basic manhattan distance + some modifier to slightly favor finishing first rows/cols first
        manDist += abs(x[0] - (i-1)/d);// + (float) ((i-1)/d - x[0])/d*2 ;
        manDist += abs(x[1] - (i-1)%d);// + (float) ((i-1)%d - x[1])/d*2 ;
        
        //modification for linear conflict
        for (int j = 1; j < d-1; j++) {
            if (x[0] - (i-1)/d == 0)
                if (board[x[0]][x[1]+j] == i-1 || board[x[0]][x[1]-j] == i+1)
                    manDist += 1;
            if (x[1] - (i-1)%d == 0)
                if (board[x[0]+j][x[1]] == i-d || board[x[0]-j][x[1]] == i+d)
                    manDist += 1;
        }
    }
    return manDist;
}
示例#12
0
void
tabfind (double temperature, double *rate, float *atomic_temp_tab)
{


  float cooling_tab[50] = {
    -22.97, -22.87, -22.77, -22.64, -22.52, -22.42, -22.31, -22.22, -22.14,
    -22.07, -22.02, -21.97, -21.91, -21.86, -21.81, -21.75, -21.69, -21.63,
    -21.58, -21.53, -21.49, -21.45, -21.41, -21.38, -21.37, -21.36, -21.37,
    -21.4, -21.45, -21.52, -21.61, -21.69, -21.75, -21.78, -21.81, -21.85,
    -21.91, -21.96, -21.98, -21.98, -21.98, -21.97, -21.95, -21.95, -21.99,
    -22.1, -22.23, -22.34, -22.41, -22.44
  };
  int j = 0;
  double temperature1, temperature2, L1, L2, del_temperature, delL;
  for (j = 0; j < 50; j++)
    {
      cooling_tab[j] = cooling_tab[j] + 22.0;	// removing 10^-22 factor
    }

  locate (temperature, atomic_temp_tab, &j, 50);	//  temperature is between j and j+1
//      write(*,*) 'tab j', j
  if (j == 50)
    {
      *rate = cooling_tab[j];
    }
  else
    {
      temperature1 = atomic_temp_tab[j];
      temperature2 = atomic_temp_tab[j + 1];
      del_temperature = temperature2 - temperature1;
      L1 = cooling_tab[j];
      L2 = cooling_tab[j + 1];
      delL = L2 - L1;
      *rate = L1 + (temperature - temperature1) * delL / del_temperature;
    }

  *rate = pow (10.0, *rate);	// Lambda_bar [10-22 already removed]
  *rate = 0.01 ** rate;		//absorb 10-2 factor to obtain LN
}
示例#13
0
/******************************************************************************
* Start the alarm daemon if necessary, and register this application with it.
* Reply = false if the daemon definitely couldn't be started or registered with.
*/
bool Daemon::start()
{
	kdDebug(5950) << "Daemon::start()\n";
	updateRegisteredStatus();
	switch (mStatus)
	{
		case STOPPED:
		{
			if (mStartTimer)
				return true;     // we're currently waiting for the daemon to start
			// Start the alarm daemon. It is a KUniqueApplication, which means that
			// there is automatically only one instance of the alarm daemon running.
			QString execStr = locate("exe", QString::fromLatin1(DAEMON_APP_NAME));
			if (execStr.isEmpty())
			{
				KMessageBox::error(0, i18n("Alarm daemon not found."));
				kdError() << "Daemon::startApp(): " DAEMON_APP_NAME " not found" << endl;
				return false;
			}
			KApplication::kdeinitExec(execStr);
			kdDebug(5950) << "Daemon::start(): Alarm daemon started" << endl;
			mStartTimeout = 5000/startCheckInterval + 1;    // check daemon status for 5 seconds before giving up
			mStartTimer = new QTimer(mInstance);
			connect(mStartTimer, SIGNAL(timeout()), mInstance, SLOT(checkIfStarted()));
			mStartTimer->start(startCheckInterval);
			mInstance->checkIfStarted();
			return true;
		}
		case RUNNING:
			return true;     // we're waiting for the daemon to be completely ready
		case READY:
			// Daemon is ready. Register this application with it.
			if (!registerWith(false))
				return false;
			break;
		case REGISTERED:
			break;
	}
	return true;
}
示例#14
0
Vector3f MT::fast_test(Warp warp)
{	
	//locate the searching area
	rect_t rect = window(warp.t);
	float fast_stride = sqrt(rectArea(rect) / fast_n);
	feature.set_cell(fast_stride);
	rect_t region = window(warp.t / (1.0f + padding));
	float minminx = -rect.width * 0.5f;
	float minminy = -rect.height * 0.5f;
	float maxmaxx = image_width + rect.width * 0.5f;
	float maxmaxy = image_height + rect.height * 0.5f;
	int minx = int(max(region.x, minminx) + 0.5f);
	int miny = int(max(region.y, minminy) + 0.5f);
	int maxx = int(min(region.x + region.width, maxmaxx) - rect.width + 0.5f);
	int maxy = int(min(region.y + region.height, maxmaxy) - rect.height + 0.5f);

	//use slide window to find the best match
	float best_score = 0.0f;
	Vector3f best_translate = warp.t;
	MatrixXf model(8, fast_samples.size());
	for (int y = miny; y <= maxy; y += fast_step)
	for (int x = minx; x <= maxx; x += fast_step) {
		for (int i = 0; i < fast_samples.size(); ++i) {
			int tx = x + fast_samples[i].x();
			int ty = y + fast_samples[i].y();
			memcpy(model.col(i).data(), feature.cell_hist(tx, ty), 8 * sizeof(float));
		}
		float S = model.squaredNorm();
		float score = S < 1.0f ? 0.0f : model.cwiseProduct(fast_model).sum() / sqrt(S);
		if (score > best_score) {
			rect_t best_rect = rect;
			best_rect.x = float(x);
			best_rect.y = float(y);
			best_translate = locate(best_rect);
			best_score = score;
		}
	}
	return best_translate;
}
示例#15
0
int MultiDataDistribution2D::locateInEnvelopes(int x, int y,
                                               std::vector<int>& foundId, int guess) const
{
    OLB_PRECONDITION( x>=0 && x < nx );
    OLB_PRECONDITION( y>=0 && y < ny );

    int found = locate(x,y, guess);
    if (found == -1) {
        found = 0;
    }
    else {
        foundId.push_back(found);
        for (int iNeighbor=0; iNeighbor < (int)neighbors[found].size(); ++iNeighbor) {
            int nextNeighbor = neighbors[found][iNeighbor];
            BlockCoordinates2D const& coord = blocks[nextNeighbor].getEnvelope();
            if (util::contained(x, y, coord.x0, coord.x1, coord.y0, coord.y1)) {
                foundId.push_back(nextNeighbor);
            }
        }
    }
    return found;
}
示例#16
0
文件: kgpg.cpp 项目: Fat-Zer/tdeutils
void MyView::busyMessage(TQString mssge,bool reset)
{
if (reset) openTasks=0;
if (!mssge.isEmpty())
{
openTasks++;
TQToolTip::remove(this);
TQToolTip::add(this, mssge);
setMovie(TQMovie(locate("appdata","pics/kgpg_docked.gif")));
}
else openTasks--;

//kdDebug(2100) << "Emit message: "<<openTasks<<endl;

if (openTasks<=0)
{
setPixmap( KSystemTray::loadIcon("kgpg_docked"));
TQToolTip::remove(this);
TQToolTip::add(this, i18n("KGpg - encryption tool"));
openTasks=0;
}
}
示例#17
0
ColorSchema::ColorSchema(const QString& pathname)
:m_fileRead(false)
,lastRead(new QDateTime())
{
  //start with a valid time, aleXXX
  *lastRead = QDateTime::currentDateTime();
  QString fPath = pathname.startsWith("/") ? pathname : locate("data", "konsole/"+pathname);
  if (fPath.isEmpty() || !QFile::exists(fPath))
  {
    fRelPath = QString::null;
    setDefaultSchema();
  }
  else
  {
    fRelPath = pathname;
    clearSchema();
/*  this is done on demand, see the headers, aleXXX
    (void) rereadSchemaFile(); */
  }

  m_numb = serial++;
}
示例#18
0
MT::MT(Mat img, Rect2f rect, ostream *os) :
log(os),
image_size(img.size()),
window_size(rect.size()),
feature(image_size),
warp(image_size)
{
	warp.set(locate(rect));
	float fine_stride = sqrt(window_size.area() / fine_n);
	int W = int(floor(window_size.width / (2.0f * fine_stride)));
	int H = int(floor(window_size.height / (2.0f * fine_stride)));
	for (int y = 0; y <= 2 * H; ++y)
	for (int x = 0; x <= 2 * W; ++x)
		fine_samples.push_back(Point3f((x - W) * fine_stride, (y - H) * fine_stride, 0.0f));

	feature.process(img, 0.0f);
	fine_train(warp);
	fast_train(warp);
	error = 0.0f;
	roll = yaw = pitch = 0.0f;
	count = N = 0;
}
示例#19
0
文件: watch.c 项目: mackstann/corn
gboolean handle_event_when_idle(G_GNUC_UNUSED gpointer data)
{
    GFile * file = g_queue_pop_head(&event_queue);
    gchar * uri = g_file_get_uri(file);
    g_object_unref(file);
    if(uri)
    {
        gint pos = locate(uri);
        GHashTable * meta = db_get_noadd(uri);
        gboolean has_meta = g_hash_table_size(meta);
        if(pos > -1)
        {
            if(!has_meta)
                playlist_remove(pos);
            db_schedule_update(uri);
            g_free(uri);
        }
        else if(has_meta)
            playlist_append(uri);
    }
    return !g_queue_is_empty(&event_queue);
}
示例#20
0
void TwoThreeTree::insert(int x) {
    // insert x into the 2-3 tree
    if (root == NULL) {
        root = createLeaf(x);
        return;
    }

    TNode *p = locate(x);
    // duplication is allowed, but a note will be generated
    if (p->key == x) {
        cout << "Note: duplication of " << x << " is inserted.\n";
    }

    TNode *q = createLeaf(x);
    // swap the old left most node with the new node if the new node
    // is smallest. Avoid the insertion pattern "X O O O"
    if (p->key > x) {
        swapNodes(p, q);
    }

    attach(p, q);
}
示例#21
0
bool dictionary_hash<K,V>::find_and_remove(const K &key, V &val) {
  const unsigned ndx = locate(key, false);
  // false: if removed, then it doesn't count

  if (ndx == UINT_MAX)
    return false;

  const unsigned oldsize = size();

  entry &e = all_elems[ndx];

  assert(!e.removed);
  e.removed = true;
  num_removed_elems++;
  assert(num_removed_elems <= all_elems.size());

  assert(size() + 1 == oldsize);

  val = e.val;

  return true;
}
示例#22
0
main()
{
       char inp[maxlen], searchstr[maxlen];
       int d, c, i;
       
       d=0;
       i=0;
       for(d=0; d<=maxlen && (c=getchar())!=EOF; ++d)
                inp[d] = c;
                
       printf("What would you like to search?");
       for(i=0; i<=maxlen && (c=getchar())!=EOF; ++i)
                searchstr[i] = c;
                
       for (i=0;i<strlen(inp);i++) 
           if(locate(inp,searchstr,i)) 
           {
             printf("\n%s", searchstr);
             getch();
             break;
           }
}
示例#23
0
void ServiceButton::loadServiceFromId(const QString &id)
{
    _id = id;
    /* this is a KService::Ptr
       don't need to delete it
    delete _service;
    */
    _service = 0;

    if (_id.startsWith(":"))
    {
       _id = locate("appdata", id.mid(1));
       if (!_id.isEmpty())
       {
          KDesktopFile df(_id, true);
          _service = new KService(&df);
       }
    }
    else
    {
       _service = KService::serviceByStorageId(_id);
       if (_service)
       {
          _id = _service->storageId();
       }
    }

    if (_service)
    {
        backedByFile(_service->desktopEntryPath());
    }

    if (_id.startsWith("/"))
    {
       QString tmp = KGlobal::dirs()->relativeLocation("appdata", _id);
       if (!tmp.startsWith("/"))
          _id = ":"+tmp;
    }
}
示例#24
0
/** write the settings for MacOS-like-behavior (called by saveCheckStatus) */
void KOSPage::writeMacOS()
{
    kdDebug() << "KOSPage::writeMacOS()" << endl;

    ckcmdisplay->setGroup("KDE");
    ckcmdisplay->writeEntry("macStyle", true, true, true);

    cglobal->setGroup("KDE");
    cglobal->writeEntry("SingleClick", true, true, true);

    claunch->setGroup("FeedbackStyle");
    claunch->writeEntry("BusyCursor", false);

    cwin->setGroup("Windows");
    cwin->writeEntry("TitlebarDoubleClickCommand", "Shade");
    cwin->writeEntry("FocusPolicy", "ClickToFocus");
    cwin->writeEntry("AltTabStyle", "KDE");
    cwin->setGroup("MouseBindings");
    cwin->writeEntry("CommandActiveTitlebar2", "Lower");
    cwin->writeEntry("CommandActiveTitlebar3", "Operations menu");

    cdesktop->setGroup("Menubar");
    cdesktop->writeEntry("ShowMenubar", true);
    cdesktop->setGroup("Mouse Buttons");
    cdesktop->writeEntry("Middle", "WindowListMenu");
    cdesktop->setGroup("FMSettings");
    cdesktop->writeEntry("UnderlineLinks", false);

    ckonqueror->setGroup("FMSettings");
    ckonqueror->writeEntry("UnderlineLinks", false);

    ckcminput->setGroup("KDE");
    ckcminput->writeEntry("ChangeCursor", true, true, true);

    cklipper->setGroup("General");
    cklipper->writeEntry("Synchronize", false);

    writeKeyEntrys(locate("keys", "mac4.kksrc"));
}
示例#25
0
void Domain1D::resize(size_t nv, size_t np)
{
    // if the number of components is being changed, then a
    // new grid refiner is required.
    if (nv != m_nv || !m_refiner) {
        m_nv = nv;
        m_refiner.reset(new Refiner(*this));
    }
    m_nv = nv;
    m_name.resize(m_nv,"");
    m_max.resize(m_nv, 0.0);
    m_min.resize(m_nv, 0.0);
    // Default error tolerances for all domains
    m_rtol_ss.resize(m_nv, 1.0e-4);
    m_atol_ss.resize(m_nv, 1.0e-9);
    m_rtol_ts.resize(m_nv, 1.0e-4);
    m_atol_ts.resize(m_nv, 1.0e-11);
    m_points = np;
    m_z.resize(np, 0.0);
    m_slast.resize(m_nv * m_points, 0.0);
    locate();
}
QString LauncherApplet::newDesktopFile(const KURL& url)
{
   QString base = url.fileName();
   if (base.endsWith(".desktop"))
      base.truncate(base.length()-8);
   QRegExp r("(.*)(?=-\\d+)");
   if (r.search(base) > -1)
      base = r.cap(1);

   QString file = base + ".desktop";

   for(int n = 1; ++n; )
   {
      QString path = locate("appdata", file);
      if (path.isEmpty())
         break;

      file = QString("%2-%1.desktop").arg(n).arg(base);
   }
   file = locateLocal("appdata", file);
   return file;
}
示例#27
0
Profile::Profile(Profile *parent, const QString &name)
    :m_parent(parent), m_name(name)
{
    if (m_parent)
        m_parent->addChildProfile(this);

    QString profileConfig = locate("data", "kdevelop/profiles" + dirName() + "/profile.config");
    KConfig config(profileConfig);

    config.setGroup("Information");
    m_genericName = config.readEntry("GenericName");
    m_description = config.readEntry("Description");

    config.setGroup("Properties");
    m_properties = config.readListEntry("List");

    config.setGroup("Enable");
    m_explicitEnable = config.readListEntry("List");

    config.setGroup("Disable");
    m_explicitDisable = config.readListEntry("List");
}
示例#28
0
void DrawAnalogPort(int x, int y)
{

      color(CF_ANALOG,CB_ANALOG);
      DrawBox(x,y,x+57,y+10);	    /* draw the main status box */
      color(CF_TITLE,CB_ANALOG);
      locate(y,x+2 );
      cprintf("Analog Inputs");
      color(CF_ANALOG,CB_ANALOG);
      locate(y+1,x+1);	cprintf(" Port Value   Min   Max   Range");
      locate(y+3,x+1);	cprintf("   0    0     x   x ");
      locate(y+5,x+1);	cprintf("   1    0     x   x ");
      locate(y+7,x+1);	cprintf("   2    0     x   x ");
      locate(y+9,x+1);	cprintf("   3    0     x   x ");


}
示例#29
0
void OutputBit(int bit,int val)
{
   // calculate mask return
   int mask = 0;
   for(int i=0; i<=bit; i++)
   {
	mask = mask * 2+1;    //almost works
   }
   mask++;
   mask=mask/2;

   locate(25,1);
   cprintf("bit=%d mask=%d val=%d",bit,mask,val);
   switch (val)
   {
	case 2:	// toggle output bit
	{
	   valueOutput[0] = valueOutput[0] ^ mask;
	}
	break;
	case 1:	// turn BIT ON
	{
	   valueOutput[0] = valueOutput[0] ^ mask;

	}
	break;

	case 0: // turn BIT OFF
	{
	   mask = ~mask;
	   valueOutput[0] = valueOutput[0] ^ mask;

	}
	break;
   }
   WritePort(valueOutput[0]);

}
示例#30
0
AlarmDaemon::AlarmDaemon(bool autostart, QObject *parent, const char *name)
    : DCOPObject(name),
      QObject(parent, name),
      mAlarmTimer(0)
{
    kdDebug(5900) << "AlarmDaemon::AlarmDaemon()" << endl;
    ADConfigData::readConfig();

    ADConfigData::enableAutoStart(true);    // switch autostart on whenever the program is run

    readKAlarmConfig();       // read time-related KAlarm config items

#ifdef AUTOSTART_KALARM
    if(autostart)
    {
        /* The alarm daemon is being autostarted.
         * Check if KAlarm needs to be autostarted in the system tray.
         * This should ideally be handled internally by KAlarm, but is done by kalarmd
         * for the following reason:
         * KAlarm needs to be both session restored and autostarted, but KDE doesn't
         * currently cater properly for this - there is no guarantee that the session
         * restoration activation will come before the autostart activation. If they
         * come in the wrong order, KAlarm won't know that it is supposed to restore
         * itself and instead will simply open a new window.
         */
        KConfig kaconfig(locate("config", "kalarmrc"));
        kaconfig.setGroup(QString::fromLatin1("General"));
        autostart = kaconfig.readBoolEntry(AUTOSTART_TRAY, false);
        if(autostart)
        {
            kdDebug(5900) << "AlarmDaemon::AlarmDaemon(): wait to autostart KAlarm\n";
            QTimer::singleShot(KALARM_AUTOSTART_TIMEOUT * 1000, this, SLOT(autostartKAlarm()));
        }
    }
    if(!autostart)
#endif
        startMonitoring();    // otherwise, start monitoring alarms now
}