Exemplo n.º 1
0
void Cloth::calcForces() {
  double currentTime = getCounter();

  for (int i = 0; i < numStructural; i++) {
    structuralSprings[i].calcSpringForce();
  }
  for (int i = 0; i < numShear; i++) {
    shearSprings[i].calcSpringForce();
  }
  for (int i = 0; i < numFlexion; i++) {
    flexionSprings[i].calcSpringForce();
  }

  timeSpentCalculatingInternalForce += getCounter() - currentTime;

  currentTime = getCounter();

  for (int i = 0; i < rows; i++) {
    for (int j = 0; j < columns; j++) {
      particles[(i * columns) + j].addForce(XMVectorScale(GRAVITY, particles[(i * columns) + j].getMass()));

      if (currentScenario == FLAG) {
        if (i < rows - 1 && j < columns - 1) {
          addWindForce(particles[(i * columns) + j], particles[(i * columns) + j + 1], particles[((i + 1) * columns) + j]);
          addWindForce(particles[((i + 1) * columns) + j], particles[(i * columns) + j + 1], particles[((i + 1) * columns) + j + 1]);
        }
      }
    }
  }

  timeSpentCalculatingExternalForce += getCounter() - currentTime;
}
Exemplo n.º 2
0
	void Assembler::org()
	{
		static int orgd = 0, orgc = 0;
		U32 loc;

		g_nops = getCpu()->getOp()->get();
		loc = ((Operands6502 *)getCpu()->getOp())->op[0].val.value;
		if (CurrentArea == BSS_AREA)
			BSSCounter.set(loc);
		else {
			if (fSOut)
				gSOut.flush();
			if (orgd == pass)
			{
				if (fBinOut | bMemOut | fListing) {
					DoingDc = true;
					//printf("%x %x\r\n", getCounter().val, loc);
					//getchar();
					while (getCounter().val < loc) {
					//printf("%x %x\r\n", getCounter().val, loc);
						emit('B', 0xff);
					}
					DoingDc = false;
				}
				getCounter().set(loc);
			}
			else
			{
				getCounter().set(loc);
				orgd = pass;
			}
		}
	}
Exemplo n.º 3
0
void Gui::removeInstance() noexcept
{
    --getCounter();
    if(getCounter() == 0 && m_window)
    {
        m_window->removeFromDesktop();
        delete m_window;
        m_window = nullptr;
    }
}
Exemplo n.º 4
0
char *
expandTheorem(int i, char *option)
/**************************************************************************
     purpose: retrieves and expands a \newtheorem into a string
**************************************************************************/
{	
	char s[128], *num;
	int ithm;
	
	if (i<0 || i>=iNewTheoremCount)
		return strdup("");
	
	incrementCounter(NewTheorems[i].numbered_like);
	ithm = getCounter(NewTheorems[i].numbered_like);
	
	if (NewTheorems[i].within) {
		num = FormatUnitNumber(NewTheorems[i].within);
		if (option)
			snprintf(s,128,"%s %s.%d (%s)", NewTheorems[i].caption, num, ithm, option);
		else
			snprintf(s,128,"%s %s.%d", NewTheorems[i].caption, num, ithm);
		free(num);
	} else {
		if (option)
			snprintf(s,128,"%s %d (%s)", NewTheorems[i].caption, ithm, option);
		else
			snprintf(s,128,"%s %d", NewTheorems[i].caption, ithm);
	}
			
	return strdup(s);
}
Exemplo n.º 5
0
void		Action::UseWarp::_update()
{
  Player        &p = _data.player();
  World::Map    &m = _data.world()[p.getBank()][p.getMap()];
  int           tx = m.warps[_id].x;
  int           ty = m.warps[_id].y;
  int           px = p.getX();
  int           py = p.getY();
  EKey          key = (EKey) -1;

  if (!getCounter())
    {
      if (px == tx && py == ty)
        {
          std::map<uint16_t, EKey>::iterator    it = _behaviours.find(m.data[ty][tx].attr->behavior);
          if (it != _behaviours.end())
            key = (*it).second;
        }
      else
        key = (py < ty ? KEY_DOWN : py > ty ? KEY_UP : px > tx ? KEY_LEFT : KEY_RIGHT);
      if (key != (EKey) -1)
        {
          queue(new Action::PressButton(key));
          queue(new Action::PressButton(key));
          queue(new Action::Wait(100));
        }
    }
  else
    _state = Action::FINISHED;
}
Exemplo n.º 6
0
		void startProfile(ProfileEntry* entry)
		{


			g_callStack[g_callLevel++] = entry;

			entry->start = getCounter();
		}
Exemplo n.º 7
0
void Gui::addInstance() noexcept
{
    ++getCounter();
    if(m_window == nullptr)
    {
        m_window = new GuiWindow();
    }
}
void Timer::update()
{
	IComponent::update();
	if (getCounter() == maxCounter)
	{
		kill(); // timer kills itself
		pushMsg(msg);
	}
}
Exemplo n.º 9
0
void ProfilerThread::responseReceived()
{
  if (m_query->getErrno() == SUCCESS) incCounter();
  qDebug() << getCounter() << m_sendTime.msecsTo(QDateTime::currentDateTime()) <<  (int)(m_query->getErrno()!=SUCCESS) << m_requests_per_second;
  //QString a=QString("echo \"%1 %2 %3 %4 `ps -e -o rss,comm | grep fcgi | grep -o \\\"^[0-9 ]*\\\"`\"").arg(getCounter()).arg(m_sendTime.msecsTo(QDateTime::currentDateTime())).arg((int)(m_query->getErrno()!=SUCCESS)).arg(m_requests_per_second);
  //system(a.toStdString().c_str());
  if (m_counter == m_number_of_requests ) exit();
  emit doRequest();
}
Exemplo n.º 10
0
	// write a address to the output listing
	int Assembler::listAddr()
	{
		int n;
		int xx;

		n = fprintf(fpList, "%7d ", InputLine);
		xx = getCpu()->awidth;
		switch (xx)
		{
			case 16:
				n += fprintf(fpList, "%04.4lX ", getCounter().val);
				break;
			case 24:
				n += fprintf(fpList, "%06.6lX ", getCounter().val);
				break;
			default:
				n += fprintf(fpList, "%09.9I64X ", (__int64)getCounter().val);
		}
		return n;
	}
Exemplo n.º 11
0
		void endProfile(ProfileEntry* entry)
		{
			assert(g_callStack[g_callLevel - 1] == entry);

			int64 end = getCounter();

			entry->numSamples++;
			entry->profileSum += end - entry->start;

			--g_callLevel;
		}
Exemplo n.º 12
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_CounterJNI
 * Method:    getCounter
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CounterJNI_getCounter
  (JNIEnv * env, jclass, jlong id)
{
	//COUNTERJNI_LOG(logDEBUG) << "Calling COUNTERJNI getCounter";
	//COUNTERJNI_LOG(logDEBUG) << "Counter Ptr = " << (void*)id;
	int32_t status = 0;
	jint returnValue = getCounter((void*)id, &status);
	//COUNTERJNI_LOG(logDEBUG) << "Status = " << status;
	//COUNTERJNI_LOG(logDEBUG) << "getCounterResult = " << returnValue;
	CheckStatus(env, status);
	return returnValue;
}
Exemplo n.º 13
0
/*FGROUP SSM
Start recording. 
mode: 2    ->After            3 ->Before 
      0x102->After+TTCrxreset
      0x12 ->Afterr/FP2ssm 0x13 ->Before/FP2ssm 
! in FP2ssm wait for a change of L0_COUNTER or PP_COUNTER */
void SSMstartrec(w32 mode) {
/* w32 localmode;
if(mode==0x102) {
  localmode=2;
} else {
  localmode=mode;
}; */
if(SSMsetom(mode)) {
  return;
};
if((mode&0x10)==0x10) { /* FP2ssm mode, wait for counter change */
  w32 cntr1, cntr2;
  printf("Entering loop for waiting L0 or PP counters change.\n");
  printf("Press Kill button to get out of the loop.\n");
  cntr1= getCounter(L0_COUNTERrp);
  cntr2= getCounter(PP_COUNTERrp);
  while(1) {
    w32 cntr;
    if(quit !=0) {quit=0; 
      printf("interrupt received: %d\n",quit);
      break;};
    cntr= getCounter(L0_COUNTERrp);
    if(cntr != cntr1) {
      printf("L0 counter change detected, starting SSM for front panel\n");
      break;};
    cntr= getCounter(PP_COUNTERrp);
    if(cntr != cntr2) {
      printf("PP counter change detected, starting SSM for front panel\n");
      break;};
  };
};
  vmew32(SSMaddress,0);
  vmew32(SSMstart,DUMMYVAL);
  if(mode==0x102) {
    TTCrxreset();
    printf("SSM recording (26ms) + TTCrx reset started\n");
  };
}
Exemplo n.º 14
0
static char *
SaveEquationAsFile(char *pre, char *eq, char *post)
{	
	FILE * f;
	char name[15];
	char *tmp_dir, *fullname, *texname;
	static int file_number = 0;
	
	/* create needed file names */
	file_number++;
	tmp_dir = getTmpPath();
#ifdef INLINE_EQ_ALIGN
        if(g_inline_eq_align&&!strcmp(pre,"$"))
       	   sprintf(name, "l2r-%04d", file_number);
        else 
#endif
	sprintf(name, "l2r_%04d", file_number);
	fullname = strdup_together(tmp_dir, name);	
	texname = strdup_together(fullname,".tex");

	diagnostics(4, "SaveEquationAsFile =%s", texname);
	
	f = fopen(texname,"w");
	while (eq && (*eq == '\n' || *eq == ' ')) eq++;  /* skip whitespace */
	if (f) {
		fprintf(f, "%s", g_preamble);
		fprintf(f, "\\thispagestyle{empty}\n");
		fprintf(f, "\\begin{document}\n");
		fprintf(f, "\\setcounter{equation}{%d}\n",getCounter("equation"));
		if (strstr(pre, "equation"))
			fprintf(f, "$$%s$$", eq);
#ifdef INLINE_EQ_ALIGN
                else if(g_inline_eq_align&&!strcmp(pre,"$"))
			fprintf(f, "%s.\\quad %s%s", pre, eq, post);
#endif
		else
			fprintf(f, "%s%s%s", pre, eq, post);
		fprintf(f, "\n\\end{document}");
		fclose(f);
	} else {
		free(fullname);
		fullname = NULL;
	}
	
	free(tmp_dir);
	free(texname);
	return(fullname);
}
Exemplo n.º 15
0
/**
 * Save the key data in a JSON like format. The filename is specified in
 * constructor YubikoOtpKeyConfig::YubikoOtpKeyConfig(const string& )
 */
void YubikoOtpKeyConfig::save() {
	BOOST_LOG_NAMED_SCOPE("YubikoOtpKeyConfig::save");
	const string myOutFile = checkFileName(true);
	ptree myTree;
	myTree.put(K_NM_DOC_PRIV_ID /*--->*/, getPrivateId());
	myTree.put(K_NM_DOC_PUB_ID /*---->*/, getPublicId());
	myTree.put(K_NM_DOC_SEC_KEY /*--->*/, getSecretKey());
	myTree.put(K_NM_DOC_TIMESTAMP /*->*/, getTimestamp().tstp_int);
	myTree.put(K_NM_DOC_SES_CNTR /*-->*/, getCounter());
	myTree.put(K_NM_DOC_CRC /*------->*/, getCrc());
	myTree.put(K_NM_DOC_RANDOM /*---->*/, getRandom());
	myTree.put(K_NM_DOC_USE_CNTR /*-->*/, getUseCounter());
	myTree.put(K_NM_DOC_DESC /*------>*/, getDescription());
	myTree.put(K_NM_DOC_SYS_USER /*-->*/, getSysUser());
	myTree.put(K_NM_DOC_VERS /*------>*/, K_VL_VERS);
	write_json(myOutFile, myTree);
	itsChangedFlag = false;
}
Exemplo n.º 16
0
    ~LeakedObjectDetector() noexcept
    {
        if (--(getCounter().numObjects) < 0)
        {
            /** If you hit this, then you've managed to delete more instances of this class than you've
                created.. That indicates that you're deleting some dangling pointers.

                Note that although this assertion will have been triggered during a destructor, it might
                not be this particular deletion that's at fault - the incorrect one may have happened
                at an earlier point in the program, and simply not been detected until now.

                Most errors like this are caused by using old-fashioned, non-RAII techniques for
                your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays,
                ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
            */
            d_stderr2("*** Dangling pointer deletion! Class: '%s', Count: %i", getLeakedObjectClassName(), getCounter().numObjects);
        }
    }
Exemplo n.º 17
0
void dispatcher(){	
	int i;
	setGuestPreviousShadowSet(curr_vcpu->gprshadowset);
		
	//Check if needs to save GP registers context
	if(vcpu_sgpr[curr_vcpu->gprshadowset] != NULL && vcpu_sgpr[curr_vcpu->gprshadowset] != curr_vcpu){
		save_sgpr_ctx(vcpu_sgpr[curr_vcpu->gprshadowset]->gp_registers);			   
		restore_sgpr_ctx(curr_vcpu->gp_registers);
		vcpu_sgpr[curr_vcpu->gprshadowset]=curr_vcpu;
	}else{
		if(curr_vcpu->init){
                    //FIXME: This line results in critical fault. Must be debugged. 
                    //restore_sgpr_ctx(curr_vcpu->gp_registers);
		}
		vcpu_sgpr[curr_vcpu->gprshadowset]=curr_vcpu;		
	}
	/* First scheduling of a VM */
#ifdef STATICTLB	
	if(curr_vm->init){
		/* Write entries to TLB*/
		for(i=0;i<curr_vm->ntlbent;i++){
			tlbEntryWrite(&curr_vm->tlbentries[i]);
			curr_vm->tlbentries[i].onhardware = 1;
		}
		curr_vm->init=0;		
	}
#endif	
	setGLowestGShadow(curr_vcpu->gprshadowset);	
	setGuestID(curr_vm->id);
	
	/* Avoid to enter in guest mode for hypervisor tasks. */
	if(curr_vm->id!=0){
		setGuestMode();
	}
	//Initialize vcpu
	if(curr_vcpu->init){
		curr_vcpu->gp_registers[REG_SP]=curr_vcpu->sp;
		curr_vcpu->gp_registers[REG_A0]=curr_vcpu->arg;
		curr_vcpu->cp0_registers[9][0]=getCounter();
		curr_vcpu->init = 0;
	}	
}
/*
 * Rozpoczêcie liczenia cykli.
 */
void CycleCounter::startCounting()
{
	startTime = getCounter( ) / 100000;
}
Exemplo n.º 19
0
void
CmdEquation(int code)
/******************************************************************************
 purpose   : Handle everything associated with equations
 ******************************************************************************/
{
	char *pre, *eq, *post;
	int inline_equation, number, true_code;

	true_code = code & ~ON;	
			
	if (!(code & ON)) return ;

	SlurpEquation(code,&pre,&eq,&post);
	
	diagnostics(4, "Entering CmdEquation --------%x\n<%s>\n<%s>\n<%s>",code,pre,eq,post);

	inline_equation = (true_code == EQN_MATH) || (true_code == EQN_DOLLAR) || (true_code == EQN_RND_OPEN);
	
	number=getCounter("equation");
	
	if (g_equation_comment)
		WriteEquationAsComment(pre,eq,post);
	
	diagnostics(4,"inline=%d  inline_bitmap=%d",inline_equation,g_equation_inline_bitmap);
	diagnostics(4,"inline=%d display_bitmap=%d",inline_equation,g_equation_display_bitmap);
	diagnostics(4,"inline=%d  inline_rtf   =%d",inline_equation,g_equation_inline_rtf);
	diagnostics(4,"inline=%d display_rtf   =%d",inline_equation,g_equation_display_rtf);

	if ((inline_equation && g_equation_inline_bitmap)  || 
		(!inline_equation && g_equation_display_bitmap) ) {
			if (true_code != EQN_ARRAY) {
				PrepareRtfEquation(true_code,FALSE);
				WriteLatexAsBitmap(pre,eq,post);
				FinishRtfEquation(true_code,FALSE);
			} else {
				char *s, *t;
				s=eq;
				diagnostics(4,"eqnarray whole = <%s>",s);
				do {
					t=strstr(s,"\\\\");
					if (t) *t = '\0';
					diagnostics(4,"eqnarray piece = <%s>",s);
					if (strstr(s,"\\nonumber"))
						g_suppress_equation_number = TRUE;
					else
						g_suppress_equation_number = FALSE;

					PrepareRtfEquation(true_code,FALSE);
					WriteLatexAsBitmap("\\begin{eqnarray*}",s,"\\end{eqnarray*}");
					FinishRtfEquation(true_code,FALSE);
					if (t) s = t+2;
				} while (t);
			}
	}

	if ((inline_equation && g_equation_inline_rtf)  || 
		(!inline_equation && g_equation_display_rtf) ) {
		setCounter("equation",number);
		WriteEquationAsRTF(true_code,&eq);	
	}

/* balance \begin{xxx} with \end{xxx} call */	
	if (true_code == EQN_MATH     || true_code == EQN_DISPLAYMATH   ||
		true_code == EQN_EQUATION || true_code == EQN_EQUATION_STAR ||
		true_code == EQN_ARRAY    || true_code == EQN_ARRAY_STAR      )
			ConvertString(post);
	
	free(pre);
	free(eq);
	free(post);
	
}
Exemplo n.º 20
0
//--------------------------------------------------------------------------
// Function:    IdComponent::getCounter
///\brief       Returns the reference counter for the id of this object.
///\return      Reference count
// Programmer   Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int IdComponent::getCounter() const
{
    return (getCounter(getId()));
}
Exemplo n.º 21
0
void main()
{
   char s[40];
	int encoder_state;
   word count;

   // Initialize the controller
	brdInit();

   // Configure digital outputs to simulate quadrature encoder output
	setDigOut(LED1, 1);
   setDigOut(LED2, 1);

	// Configure quadrature encoder input
   setDecoder(QUAD_I, QUAD_Q, -1, 0);

   // Configure digital inputs for switches
   setDigIn(SW1);
   setDigIn(SW2);
   setDigIn(SW3);

   // initialize outputs to low
   encoder_state = 0;
	simulate_encoder(encoder_state);

   // reset quadrature decoder counter
   resetCounter(QUAD_I);

	DispStr(2, 1, "<<< Simulating a Quadrature Encoder with button presses >>>");
   DispStr(1, 3, "Press Button SW1 to decrement counter");
   DispStr(1, 4, "Press Button SW2 to increment counter");
   DispStr(1, 5, "Press Button SW3 to reset counter");

	while (1)
	{
   	costate
      {
       	// Display the counter value
         getCounter(QUAD_I, &count);
         sprintf(s, "Quadrature Decoder Count = %6u", count);
         DispStr(1, 7, s);
      }

      costate
      {
      	// decrement counter
			waitfor(!digIn(SW1)); 			// wait for switch 1 to be pressed
			waitfor(DelayMs(50));			// debounce
			if (!digIn(SW1)) {
	         --encoder_state;
	         if (encoder_state < 0)
	         {
	            encoder_state = 3;
	         }
	         simulate_encoder(encoder_state);
				waitfor(DelayMs(150));         // repeat when switch held down
         }
      }

      costate
      {
      	// increment counter
			waitfor(!digIn(SW2)); 			// wait for switch 2 to be pressed
			waitfor(DelayMs(50));			// debounce
			if (!digIn(SW2)) {
	         ++encoder_state;
	         if (encoder_state > 3)
	         {
	            encoder_state = 0;
	         }
	         simulate_encoder(encoder_state);
				waitfor(DelayMs(150));         // repeat when switch held down
         }
      }

      costate
      {
      	// reset counter
			waitfor(!digIn(SW3)); 			// wait for switch 3 to be pressed
			waitfor(DelayMs(50));			// debounce
         if (!digIn(SW3)) {
	         resetCounter(QUAD_I);      // reset quadrature decoder counter
	         waitfor(digIn(SW3));       // wait for switch 3 to be released
         }
      }
	}
}
Exemplo n.º 22
0
static void 
FinishRtfEquation(int code, int EQ_Needed)
{	
	if (EQ_Needed && g_processing_fields==1) {
		fprintRTF("}}{\\fldrslt }}");
		g_processing_fields--;	
	}
	
	switch (code) {
	
		case EQN_MATH:
			diagnostics(4,"FinishRtfEquation -- \\end{math}");
			CmdIndent(INDENT_INHIBIT);
			SetTexMode(MODE_HORIZONTAL);
			break;
	
		case EQN_DOLLAR:
			diagnostics(4,"FinishRtfEquation -- $");
			fprintRTF("}");
			SetTexMode(MODE_HORIZONTAL);
			break;
	
		case EQN_RND_OPEN:	
			diagnostics(4,"FinishRtfEquation -- \\)");
			fprintRTF("}");
			SetTexMode(MODE_HORIZONTAL);
			break;
	
		case EQN_DOLLAR_DOLLAR:
			diagnostics(4,"FinishRtfEquation -- $$");
			CmdEndParagraph(0);
			CmdIndent(INDENT_INHIBIT);
			fprintRTF("}");
			break;
	
		case EQN_BRACKET_OPEN:
			diagnostics(4,"FinishRtfEquation -- \\[");
			SetTexMode(MODE_VERTICAL);
			fprintRTF("\\par\\par\n}");
			break;

		case EQN_DISPLAYMATH:
			diagnostics(4,"FinishRtfEquation -- displaymath");
			CmdEndParagraph(0);
			CmdIndent(INDENT_INHIBIT);
			break;

		case EQN_EQUATION_STAR:
			diagnostics(4,"FinishRtfEquation -- equation*");
			CmdEndParagraph(0);
			CmdIndent(INDENT_INHIBIT);
			break;

		case EQN_ARRAY_STAR:
			diagnostics(4,"FinishRtfEquation -- eqnarray* ");
			CmdEndParagraph(0);
			CmdIndent(INDENT_INHIBIT);
			g_processing_eqnarray = FALSE;
			g_processing_tabular = FALSE;
			break;

		case EQN_EQUATION:
		case EQN_ARRAY:
		    diagnostics(4,"FinishRtfEquation --- equation or eqnarray");
			if (g_show_equation_number && !g_suppress_equation_number) {
				char number[20];
				incrementCounter("equation");
				for (; g_equation_column < 3; g_equation_column++)
						fprintRTF("\\tab ");
				fprintRTF("\\tab{\\b0 (");
				sprintf(number,"%d",getCounter("equation"));
				InsertBookmark(g_equation_label,number);
				if (g_equation_label) {
					free(g_equation_label);
					g_equation_label = NULL;
				}
				fprintRTF(")}");
			}
			g_processing_eqnarray = FALSE;
			g_processing_tabular = FALSE;
			CmdEndParagraph(0);
			CmdIndent(INDENT_INHIBIT);
			break;
			
		default:
			diagnostics(ERROR, "calling FinishRtfEquation with OFF code");
			break;
		}
}
Exemplo n.º 23
0
int Encoder::readRotations() {
    return getCounter() / (resolution * 2);
}
Exemplo n.º 24
0
 LeakedObjectDetector(const LeakedObjectDetector&) noexcept { ++(getCounter().numObjects); }
/*
 * Zakonczenie liczenia cykli.
 */
void CycleCounter::stopCounting()
{
	stopTime = getCounter( ) / 100000;
}