void cTumkwsaSink::ATKresultThread()
{
  Boolean term;
  smileMutexLock(terminatedMtx);
  term = terminated;
  smileMutexUnlock(terminatedMtx);

  while (term==FALSE) {
    APacket p = ansChan->GetPacket();
    if (p.GetKind() == StringPacket){
      AStringData * sd = (AStringData *)p.GetData();
      if (sd->data.find("TERMINATED") != string::npos) {
        smileMutexLock(terminatedMtx);
        terminated = TRUE;
        smileMutexUnlock(terminatedMtx);
      }
    }

    // TODO: string output:  (call printResult function...)
    processResult(0, 0, 0.0, &p);

    smileMutexLock(terminatedMtx);
    term = terminated;
    smileMutexUnlock(terminatedMtx);
  }
}
Beispiel #2
0
ScopeProfiler::~ScopeProfiler()
{
	__int64 finish = 0;
	QueryPerformanceCounter((LARGE_INTEGER*)&finish);

	float dt = (finish - _start) * _secondsPerCount;
	processResult(dt);
}
Beispiel #3
0
void buildAndCheckSentence(unsigned char characterIn, char *sentence, unsigned char *sentenceIndex, unsigned char *sentenceState, unsigned char *checksum, void (*processResult)(char *)) {
	// Full specification for NMEA0138 specifies a maximum sentence length
	// of 255 characters. We're going to ignore this for half the length as
	// we shouldn't get anything that big.

	// This contains the function's state of whether
	// it is currently building a sentence.
	// 0 - Awaiting start character ($)
	// 1 - Building sentence
	// 2 - Building first checksum character
	// 3 - Building second checksum character
	
	// We start recording a new sentence if we see a dollarsign.
	// The sentenceIndex is hard-set to 1 so that multiple dollar-signs
	// keep you at the beginning.
	if ((*sentenceState) == 0) {
		if (characterIn == '$') {
			(*sentenceIndex) = 0;
			(*sentenceState) = 1;
		}
	} else if ((*sentenceState) == 1) {
		// Record every character that comes in now that we're building a sentence.
		// Only stop if we run out of room or an asterisk is found.
		if (characterIn == '*') {
			(*sentenceState) = 2;
		} else if ((*sentenceIndex) > 127) {
			// If we've filled up the buffer, ignore the entire message as we can't store it all
			(*sentenceState) = 0;
		} else {
			sentence[(*sentenceIndex)++] = characterIn;
		}
	} else if ((*sentenceState) == 2) {
		// Record the first ASCII-hex character of the checksum byte.
		(*checksum) = hex2char(characterIn) << 4;
		(*sentenceState) = 3;
	} else if ((*sentenceState) == 3) {
		// Record the second ASCII-hex character of the checksum byte.
		(*checksum) |= hex2char(characterIn);

		// Now that we've compiled a complete GPS sentence, let's check the checksum and parse it.
		// This code currently only supports RMC and GGA messages.
		unsigned char test = getChecksum(sentence, (*sentenceIndex));
		if ((*checksum) == test) {
			processResult(sentence);
		}

		// We clear all state variables here regardless of success.
		(*sentenceState) = 0;
	}
}
Beispiel #4
0
bool Client::connectToServer(const QString &serverName)
{
  if (!m_jsonRpcClient) {
    m_jsonRpcClient = new JsonRpcClient(this);
    connect(m_jsonRpcClient, SIGNAL(resultReceived(QJsonObject)),
            SLOT(processResult(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(notificationReceived(QJsonObject)),
            SLOT(processNotification(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(errorReceived(QJsonObject)),
            SLOT(processError(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(connectionStateChanged()),
            SIGNAL(connectionStateChanged()));
  }

  return m_jsonRpcClient->connectToServer(serverName);
}
Beispiel #5
0
void NewObjDialog::init(
    Panel panel,
    const std::function<void(const std::string&)>& okCallback)
{
    m_panel = panel;
    m_ok = panel.child<Button>("ok");
    m_cancel = panel.child<Button>("cancel");
    m_panel.hide();
	m_ok.setCallback([this, okCallback]() { processResult(okCallback); });
	m_cancel.setCallback([this]() { m_panel.hide(); });

    m_selector = loadObj<Selector>("ui\\Selector.json");
    m_panel.child<Layout>("main").add(m_selector);
	m_mainGroup.setCallback([this]() { selectGroup(); });

    addGroup("layout", "Layout");
    if (settings::isComplexLayerMode())
        addGroup("game", "GameExt");
    else
        addGroup("game", "Game");
    addGroup("primitive", "SimpleElement");
    addGroup("ui", "UIElement");
    addGroup("other", "Additional");

    auto presentation = presentationForDesignView();
    auto allObjects = presentation->derivedTypesByBaseTypeName("IObject");
    std::map<std::string, std::string> types;
    for (auto it = allObjects.begin(); it != allObjects.end(); ++it) {
        if (!impl::SerializableRegister::instance().isRegistered((*it)->name))
            continue;
        types[(*it)->nameInUI] = (*it)->name;
    }
    for (auto it = types.begin(); it != types.end(); ++it)
        addClass(it->second, it->first);
    m_selector.update();

	m_mainGroup.select(m_nameToGroupID["Layout"]);
}
Beispiel #6
0
// main method
void MPlayerManager::run()
	throw()
{
	__BEGIN_TRY

	string host     = g_pConfig->getProperty("DB_HOST");
	string db       = g_pConfig->getProperty("DB_DB");
	string user     = g_pConfig->getProperty("DB_USER");
	string password = g_pConfig->getProperty("DB_PASSWORD");
	uint port		= 0;
	if (g_pConfig->hasKey("DB_PORT") )
		port = g_pConfig->getPropertyInt("DB_PORT");

	Connection* pConnection = new Connection(host, db, user, password, port);
    g_pDatabaseManager->addConnection(Thread::self(), pConnection);
	//cout << "******************************************************" << endl;
	//cout << " Mofus THREAD CONNECT DB " << endl;
	//cout << "******************************************************" << endl;

	Timeval dummyQueryTime;
	getCurrentTime(dummyQueryTime);

	while (1 )
	{
		usleep(100);

		// 현재 진행중인 Job 확인
		if (m_pCurrentJob == NULL )
		{
			m_pCurrentJob = popJob();
		}

		// 현재 진행중인 Job 이 있다면
		if (m_pCurrentJob != NULL )
		{
			// Mofus 와 연결해서 작업을 할 새 Player를 생성
			MPlayer* pPlayer = new MPlayer(m_pCurrentJob);

			// 파워포인트 가져오기 작업 진행
			pPlayer->process();

			// 결과처리
			processResult();

			// Player/Job 삭제
			SAFE_DELETE(pPlayer);
			SAFE_DELETE(m_pCurrentJob);
		}

		Timeval currentTime;
		getCurrentTime(currentTime);

		if (dummyQueryTime < currentTime )
		{
			g_pDatabaseManager->executeDummyQuery(pConnection);

			dummyQueryTime.tv_sec += (60 + rand() % 30 ) * 60;
		}
	}

	__END_CATCH
}
int cLibsvmLiveSink::myTick(long long t)
{
  if (model == NULL) return 0;

  SMILE_DBG(4,"tick # %i, classifiy value vector using LibSVM (lag=%i):",t,lag);
  cVector *vec= reader->getFrameRel(lag);  //new cVector(nValues+1);
  if (vec == NULL) return 0;
//  else reader->nextFrame();

  struct svm_node *x = NULL;
  int i = 0;
  double v;
                                          // need one more for index = -1
  long Nft = Nsel;
  if (Nft <= 0) Nft = vec->N;

  if (fselType) {
    if ((outputSelIdx.enabled == NULL)&&(outputSelStr.names != NULL)) {
      buildEnabledSelFromNames(vec->N, vec->fmeta);
    } else if (outputSelIdx.enabled == NULL) Nft = vec->N;
  }
    
  // TODO: fselection by names... 
  // TODO: compute Nsel in loadSelection

  x = (struct svm_node *) malloc( (Nft + 1) * sizeof(struct svm_node));
  int j = 0;
  for (i=0; i<vec->N; i++) {
    if ((outputSelIdx.enabled == NULL)||(Nsel<=0)) {
      x[i].index = i+1; // FIXME!!! +1 is ok??? (no!?)
      x[i].value = vec->dataF[i];
    } else {
      if (outputSelIdx.enabled[i]) {
        x[j].index = j+1; // FIXME!!! +1 is ok??? (no!?)
        x[j].value = vec->dataF[i];
        j++;
      }
    }
  }
  if ((outputSelIdx.enabled == NULL)||(Nsel<=0)) {
    x[i].index = -1;
    x[i].value = 0.0;
  } else {
    x[j].index = -1;
    x[j].value = 0.0;
  }

  svm_apply_scale(scale,x);

     /*
        for (i=0; i<vec->n; i++) {
          printf("%i:%f ",i,x[i].value);
        }
        printf("\n");
     */
  long vi = vec->tmeta->vIdx;
  double tm = vec->tmeta->smileTime;
  double dur = vec->tmeta->lengthSec;

  if ( (predictProbability) && (svmType==C_SVC || svmType==NU_SVC) ) {
    v = svm_predict_probability(model,x,probEstimates);
    processResult(t, vi, tm, v, probEstimates, nClasses, dur);
//    printf("%g",v);
//    for(j=0;j<nr_class;j++)
//      printf(" %g",prob_estimates[j]);
//    printf("\n");
  } else {
    v = svm_predict(model,x);
    processResult(t, vi, tm, v, NULL, nClasses, dur);
//    result = v;
//    printf("%g\n",v);
  }
  free(x);

/*
	if (svm_type==NU_SVR || svm_type==EPSILON_SVR)
	{
		printf("Mean squared error = %g (regression)\n",error/total);
		printf("Squared correlation coefficient = %g (regression)\n",
		       ((total*sumvy-sumv*sumy)*(total*sumvy-sumv*sumy))/
		       ((total*sumvv-sumv*sumv)*(total*sumyy-sumy*sumy))
		       );
	}
	else
		printf("Accuracy = %g%% (%d/%d) (classification)\n",
		       (double)correct/total*100,correct,total);
  */
  
  


  // tick success
  return 1;
}
Beispiel #8
0
static void clusterClone(int argc, char *argv[])
{
int i;

for (i=1; i < argc; ++i)
    {
    struct lineFile *lf;
    struct psl *psl;
    unsigned tSize;
    char *prevAccPart = (char *)NULL;
    char *prevAccName = (char *)NULL;
    char *prevTargetName = (char *)NULL;
    struct hashEl *el;
    struct hash *chrHash = newHash(0);
    struct hash *coordHash = newHash(0);
    struct coordEl *coord;
    struct coordEl **coordListPt = (struct coordEl **) NULL;
    unsigned querySize = 0;
    int partCount = 0;
    int partsConsidered = 0;

    verbose(2,"#\tprocess: %s\n", argv[i]);
    lf=pslFileOpen(argv[i]);
    while ((struct psl *)NULL != (psl = pslNext(lf)) )
	{
	char *accName = (char *)NULL;
	char *targetName = (char *)NULL;
	int chrCount = 0;
	double percentCoverage;

	accName = cloneString(psl->qName);
	if ((char *)NULL == prevAccPart)
	    {
	    prevAccPart = cloneString(psl->qName);  /* first time */
	    querySize = psl->qSize;
	    ++partsConsidered;
	    }
	chopSuffixAt(accName,'_');

	if ((char *)NULL == prevAccName)
		prevAccName = cloneString(accName);  /* first time */
	if ((char *)NULL == prevTargetName)
		prevTargetName = cloneString(psl->tName);  /* first time */

	/*	encountered a new accession name, process the one we
 	 *	were working on
	 */
	if (differentWord(accName, prevAccName))
	    {
	    if (partCount > 0)
		processResult(chrHash, coordHash, prevAccName, querySize,
		    partsConsidered);
	    else
		verbose(1,"# ERROR %s %s - no coordinates found in %d parts considered\n",
		    prevTargetName, prevAccName, partsConsidered);
	    freeMem(prevAccName);
	    prevAccName = cloneString(accName);
	    freeHash(&chrHash);
	    freeHash(&coordHash);
	    chrHash = newHash(0);
	    coordHash = newHash(0);
	    querySize = 0;
	    partCount = 0;
	    partsConsidered = 0;
	    }

	tSize = psl->tEnd - psl->tStart;
	percentCoverage = 100.0*((double)(tSize+1)/(psl->qSize + 1));
	if (differentWord(psl->qName, prevAccPart))
	    {
	    ++partsConsidered;
	    querySize += psl->qSize;
	    freeMem(prevAccPart);
	    prevAccPart = cloneString(psl->qName);
	    }

	targetName = cloneString(psl->tName);
	if (differentWord(targetName, prevTargetName))
	    {
	    freeMem(prevTargetName);
	    prevTargetName = cloneString(targetName);
	    }
	/*	keep a hash of chrom names encountered	*/
	el = hashLookup(chrHash, targetName);
	if (el == NULL)
	    {
	    if (percentCoverage > minCover)
		{
		hashAddInt(chrHash, targetName, 1);
		chrCount = 1;
		}
	    else
		{
		hashAddInt(chrHash, targetName, 0);
		chrCount = 0;
		}
	    }
	else
	    {
	    if (percentCoverage > minCover)
		{
		chrCount = ptToInt(el->val) + 1;
		el->val=intToPt(chrCount);
		}
	    }

	AllocVar(coord);
	coord->start = psl->tStart;
	coord->end = psl->tEnd;
	coord->qSize = psl->qSize;
	coord->strand = sameWord(psl->strand,"+") ? 1 : 0;
	/*	when coverage is sufficient	*/
	if (percentCoverage > minCover)
	    {
	    ++partCount;
	    coord->name = cloneString(psl->qName);
	    /*	for each chrom name, accumulate a list of coordinates */
	    el = hashLookup(coordHash, targetName);
	    if (el == NULL)
		{
		AllocVar(coordListPt);
		hashAdd(coordHash, targetName, coordListPt);
		}
	    else
		{
		coordListPt = el->val;
		}
	    slAddHead(coordListPt,coord);
	verbose(2,"# %s\t%u\t%u\t%u\t%.4f\t%d %s:%d-%d %s\n",
	    psl->qName, psl->qSize, tSize, tSize - psl->qSize,
	    percentCoverage, chrCount, psl->tName, psl->tStart, psl->tEnd,
	    psl->strand);
	    }
	else
	    {
	verbose(3,"# %s\t%u\t%u\t%u\t%.4f\t%d %s:%d-%d %s\n",
	    psl->qName, psl->qSize, tSize, tSize - psl->qSize,
	    percentCoverage, chrCount, psl->tName, psl->tStart, psl->tEnd,
	    psl->strand);
	    }


	freeMem(accName);
	freeMem(targetName);
	pslFree(&psl);
	}
    if (partCount > 0)
	processResult(chrHash, coordHash, prevAccName, querySize,
	    partsConsidered);
    else
	verbose(1,"# ERROR %s %s - no coordinates found\n",
	    prevTargetName, prevAccName);
    freeMem(prevAccName);
    freeHash(&chrHash);
    freeHash(&coordHash);
    lineFileClose(&lf);
    }
}	/*	static void clusterClone()	*/
void CalculatorDialog::minus() {
    getop();
    processResult(lastResult - operand, "-");
}
Beispiel #10
0
 std::pair<v8::Local<v8::Object>, bool> eatObject(void) 
 {
     return processResult(_method.checkedArgObject(_pos));  
 }
Beispiel #11
0
 std::pair<v8::Local<v8::Function>, bool> eatCallback(void) 
 {
     return processResult(_method.checkedArgCallback(_pos));  
 }
Beispiel #12
0
 std::pair<v8::Local<v8::String>, bool> eatString(void) 
 {
     return processResult(_method.checkedArgString(_pos));            
 }
Beispiel #13
0
 std::pair<double, bool> eatNumber(void) 
 {
     return processResult(_method.checkedArgNumber(_pos));
 }
Beispiel #14
0
void CalculatorDialog::divide() {
    getop();
    if(operand==0) return;
    processResult(lastResult / operand, "/");
}
Beispiel #15
0
void CalculatorDialog::multiply() {
    getop();
    processResult(lastResult * operand, "*");
}
Beispiel #16
0
 std::pair<v8::Local<v8::Date>, bool> eatDate(void)
 {
     return processResult(_method.checkedArgDate(_pos));  
 }
Beispiel #17
0
void CalculatorDialog::plus() {
    getop();
    processResult(lastResult + operand, "+");
}