예제 #1
0
void MonitorBar::calculate_VM_stats() {
  calculateVMRegion(int32(start1()), used1(), in_core_percentage_1, old_len_1);
  assert(in_core_percentage_1 >= 0 && in_core_percentage_1 <= 100,
         "wrong percentage");
  if (start2() != NULL) {
    calculateVMRegion(int32(start2()), used2(), in_core_percentage_2, old_len_2);
    assert(in_core_percentage_2 >= 0 && in_core_percentage_2 <= 100,
           "wrong percentage");
  }
}
예제 #2
0
bool ConvexPolygon::isConvex() const
// Algorithme
// effectue le produit vectoriel de tous les cotes
// adjacents
// si ils ont tous le meme signe retourner true
// sinon retourner false
{
    Vect start1(pointList[size-1]);
    start1 -= pointList[0];

    Vect start2(pointList[1]);
    start2 -= pointList[0];

    double firstProd = start1.x*start2.y - start1.y*start2.x;

    for(int i(1); i<size; i++)
    {
        Vect vect1(pointList[i-1]);
        vect1 -= pointList[i];

        Vect vect2(pointList[i+1]);
        vect2 -= pointList[i];

        double prod = vect1.x*vect2.y - vect1.y*vect2.x;

        if(prod*firstProd < 0)
        {
            return false;
        }
    }

    return true;
}
예제 #3
0
void doit(void)
{
	virt_time_init();

	start("TLS1.3 sanity", "NORMAL:-VERS-ALL:+VERS-TLS1.3", 64, 0);
	start("TLS1.3 ticket extension", "NORMAL:-VERS-ALL:+VERS-TLS1.3", 5, 3);
	start2("TLS1.3 ticket extension - expires at handshake", "NORMAL:-VERS-ALL:+VERS-TLS1.3", 2, 3);
}
예제 #4
0
roundprogress::roundprogress(QWidget *parent)
    : QWidget(parent), task(MyInternalTask(true)), task2(MyInternalTask(false))
{
    ui.setupUi(this);
    ui.progressButton->setIcon(QIcon("find.png"));
    connect(ui.startButton, SIGNAL(clicked()), this, SLOT(start()));
    connect(ui.startButton2, SIGNAL(clicked()), this, SLOT(start2()));
    connect(ui.startBothButton, SIGNAL(clicked()), this, SLOT(start3()));
    ui.startButton->setFocus();
}
예제 #5
0
void TestChainElement::TestNoShortMoves()
{
	ComparisonContext cContext;
	MockStringWithKnownWeighting start1(&cContext, Original, 0.8);
	start1.Append(new MockStringWithKnownWeighting(&cContext, Original, 3.0));

	MockStringWithKnownWeighting start2(&cContext, Modified, 3.0);
	start2.Append(new MockStringWithKnownWeighting(&cContext, Modified, 0.8));

	start1.Bridge(start2.GetNext());
	start2.Bridge(start1.GetNext());

	start1.FindMoves(&start2);

	assertTest(!start1.IsMoved());
	assertTest(!start2.IsMoved());
	assertTest(start2.GetBridge());
	assertTest(!start1.GetBridge());
}
예제 #6
0
파일: start.c 프로젝트: pciavald/42
void			start(t_data *data)
{
	t_ant		*ant;
	t_around	*around;

	if (data->start->ants)
	{
		ant = data->ants;
		while (ant)
		{
			if (ant->path)
				ant = ant->next;
			else
				break ;
		}
		if (ant == NULL)
			return ;
		around = data->start->around;
		start2(data, around, ant);
	}
}
예제 #7
0
파일: walk.cpp 프로젝트: AcYut/segway-lite
Walk::Walk(AcYut* bot)
{
	this->bot = bot;
	legYin=-1.773347;
	supLegYin=1.773347;
	veloYin=10;
	veloYfi=10;
	legZin=25.155276;
	supLegZin=25.155276;
	veloZin=-170;
	veloZfi=170;
	zMax=60;
	lift=30;
	legRotin=0;
	legRotfi=0;
	supLegRotin=0;
	supLegRotfi=0;
	
	start2();
	printf("START completed\n\n\n");
};
예제 #8
0
파일: Polygon.cpp 프로젝트: gitrider/wxsj2
    bool CPolygon::intersert(const CPolygon& polygon, Point2DList& pointList) const
    {
        bool intersected = false;
        for (EdgeIterator p1ei = mCGALPolygon.edges_begin(); p1ei != mCGALPolygon.edges_end(); ++p1ei)
            for (EdgeIterator p2ei = polygon.mCGALPolygon.edges_begin(); p2ei != polygon.mCGALPolygon.edges_end(); ++p2ei)
            {
                Vector2 start1((*p1ei).source().x(), (*p1ei).source().y());
                Vector2 end1((*p1ei).target().x(), (*p1ei).target().y());
                Vector2 start2((*p2ei).source().x(), (*p2ei).source().y());
                Vector2 end2((*p2ei).target().x(), (*p2ei).target().y());

                float crossx, crossy;

                if ( intersectWith(start1, end1, start2, end2, crossx, crossy) )
                {
                    pointList.push_back(Vector2(crossx,crossy));

                    intersected = true;
                }
            }

        return intersected;
    }
예제 #9
0
//------------------------------------------------------------------------
int notmain ( void )
{
    unsigned int ra;
    unsigned int rb;

    uart_init();
    hexstring(0x12345678);

    PUT32(0x40,0);
    ra=GET32(0x40);
    start1();
    start2();
    start3();
    while(1)
    {
        rb=GET32(0x40);
        if(rb!=ra)
        {
            ra=rb;
            hexstring(ra);
        }
    }
    return(0);
}
예제 #10
0
void MobileSimulator::MouseMotionEvent(Vec2i screenCoordinates)
{
	Vector2 pos = MathUtil::ScreenToWorld(screenCoordinates);
	_fingerGhost1->SetPosition(pos);
	_fingerGhost2->SetPosition(-pos);

	if (_mouseDown)
	{
		//move touch(es)
		TouchList *tl = &TouchListener::GetTouchList();
		if (tl->size() > 0)
		{
			(*tl)[0]->CurrentPoint = screenCoordinates;
			if ( (*tl)[0]->MotionStartTime < 0.0f )
			{
				(*tl)[0]->MotionStartTime = theWorld.GetCurrentTimeSeconds();
			}
		}
		if (tl->size() > 1)
		{
			Vector2 negCoordsVec = MathUtil::WorldToScreen(-pos);
			Vec2i negCoords(negCoordsVec.X, negCoordsVec.Y);
			(*tl)[1]->CurrentPoint = negCoords;
			if ( (*tl)[1]->MotionStartTime < 0.0f )
			{
				(*tl)[1]->MotionStartTime = theWorld.GetCurrentTimeSeconds();
			}

			Touch* t1 = (*tl)[0];
			Touch* t2 = (*tl)[1];

			Vector2 start1(t1->StartingPoint);
			Vector2 current1(t1->CurrentPoint);
			Vector2 start2(t2->StartingPoint);
			Vector2 current2(t2->CurrentPoint);

			Vector2 initialVector = start2 - start1;
			Vector2 currentVector = current2 - current1;

			Vector2 initNorm = Vector2::Normalize(initialVector);
			Vector2 currentNorm = Vector2::Normalize(currentVector);
			float radiansRotated = acos(Vector2::Dot(initNorm, currentNorm));

			if (!_multiGestureOngoing)
			{					
				Vector2 motion = current1 - start1;

				if (motion.LengthSquared() >= (MULTI_MIN_DISTANCE * MULTI_MIN_DISTANCE) )
				{
					_multiGestureOngoing = true;
					
					// figure out if it's a rotate or a pinch
					if (radiansRotated > MULTI_ROTATE_ANGLE)
					{
						_gestureType = ROTATE;
					}
					else
					{
						_gestureType = PINCH;
					}
				}
			}

			if (_multiGestureOngoing)
			{
				GestureData gd;
				gd.Velocity = 0.0f; // don't want to store all the extra datums
									//  needed to actually calculate this

				if      (_gestureType == ROTATE)
				{
					float cross = Vector2::Cross(initNorm, currentNorm);
					if (cross > 0.0f)
					{
						radiansRotated = -radiansRotated;
					}
					gd.GestureMagnitude = radiansRotated;
					theSwitchboard.Broadcast(new TypedMessage<GestureData>("MultiTouchRotate", gd));
				}
				else if (_gestureType == PINCH)
				{
					gd.GestureMagnitude = currentVector.Length() / initialVector.Length();
					theSwitchboard.Broadcast(new TypedMessage<GestureData>("MultiTouchPinch", gd));	
				}
			}
		}
	}
}
예제 #11
0
void test_regex_token_iterator(boost::basic_regex<charT, traits>& r)
{
   typedef typename std::basic_string<charT>::const_iterator const_iterator;
   typedef boost::regex_token_iterator<const_iterator, charT, traits> test_iterator;
   const std::basic_string<charT>& search_text = test_info<charT>::search_text();
   boost::regex_constants::match_flag_type opts = test_info<charT>::match_options();
   const int* answer_table = test_info<charT>::answer_table();
   //
   // we start by testing sub-expression 0:
   //
   test_iterator start(search_text.begin(), search_text.end(), r, 0, opts), end;
   test_iterator copy(start);
   while(start != end)
   {
      if(start != copy)
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator != comparison.", charT);
      }
      if(!(start == copy))
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator == comparison.", charT);
      }
      test_sub_match(*start, search_text.begin(), answer_table, 0);
      ++start;
      ++copy;
      // move on the answer table to next set of answers;
      if(*answer_table != -2)
         while(*answer_table++ != -2){}
   }
   if(answer_table[0] >= 0)
   {
      // we should have had a match but didn't:
      BOOST_REGEX_TEST_ERROR("Expected match was not found.", charT);
   }
   //
   // and now field spitting:
   //
   test_iterator start2(search_text.begin(), search_text.end(), r, -1, opts), end2;
   test_iterator copy2(start2);
   int last_end2 = 0;
   answer_table = test_info<charT>::answer_table();
   while(start2 != end2)
   {
      if(start2 != copy2)
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator != comparison.", charT);
      }
      if(!(start2 == copy2))
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator == comparison.", charT);
      }
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4244)
#endif
      if(boost::re_detail::distance(search_text.begin(), start2->first) != last_end2)
      {
         BOOST_REGEX_TEST_ERROR(
            "Error in location of start of field split, found: " 
            << boost::re_detail::distance(search_text.begin(), start2->first)
            << ", expected: "
            << last_end2
            << ".", charT);
      }
      int expected_end = static_cast<int>(answer_table[0] < 0 ? search_text.size() : answer_table[0]);
      if(boost::re_detail::distance(search_text.begin(), start2->second) != expected_end)
      {
         BOOST_REGEX_TEST_ERROR(
            "Error in location of end2 of field split, found: "
            << boost::re_detail::distance(search_text.begin(), start2->second)
            << ", expected: "
            << expected_end
            << ".", charT);
      }
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
      last_end2 = answer_table[1];
      ++start2;
      ++copy2;
      // move on the answer table to next set of answers;
      if(*answer_table != -2)
         while(*answer_table++ != -2){}
   }
   if(answer_table[0] >= 0)
   {
      // we should have had a match but didn't:
      BOOST_REGEX_TEST_ERROR("Expected match was not found.", charT);
   }
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
   //
   // and now both field splitting and $0:
   //
   std::vector<int> subs;
   subs.push_back(-1);
   subs.push_back(0);
   start2 = test_iterator(search_text.begin(), search_text.end(), r, subs, opts);
   copy2 = start2;
   last_end2 = 0;
   answer_table = test_info<charT>::answer_table();
   while(start2 != end2)
   {
      if(start2 != copy2)
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator != comparison.", charT);
      }
      if(!(start2 == copy2))
      {
         BOOST_REGEX_TEST_ERROR("Failed iterator == comparison.", charT);
      }
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4244)
#endif
      if(boost::re_detail::distance(search_text.begin(), start2->first) != last_end2)
      {
         BOOST_REGEX_TEST_ERROR(
            "Error in location of start of field split, found: " 
            << boost::re_detail::distance(search_text.begin(), start2->first)
            << ", expected: "
            << last_end2
            << ".", charT);
      }
      int expected_end = static_cast<int>(answer_table[0] < 0 ? search_text.size() : answer_table[0]);
      if(boost::re_detail::distance(search_text.begin(), start2->second) != expected_end)
      {
         BOOST_REGEX_TEST_ERROR(
            "Error in location of end2 of field split, found: "
            << boost::re_detail::distance(search_text.begin(), start2->second)
            << ", expected: "
            << expected_end
            << ".", charT);
      }
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
      last_end2 = answer_table[1];
      ++start2;
      ++copy2;
      if((start2 == end2) && (answer_table[0] >= 0))
      {
         BOOST_REGEX_TEST_ERROR(
            "Expected $0 match not found", charT);
      }
      if(start2 != end2)
      {
         test_sub_match(*start2, search_text.begin(), answer_table, 0);
         ++start2;
         ++copy2;
      }
      // move on the answer table to next set of answers;
      if(*answer_table != -2)
         while(*answer_table++ != -2){}
   }
   if(answer_table[0] >= 0)
   {
      // we should have had a match but didn't:
      BOOST_REGEX_TEST_ERROR("Expected match was not found.", charT);
   }
#endif
}
예제 #12
0
int main(int argc, char* argv[])
{
	ExplorationShared shared;
	EBehavior behavior(&shared);
	EBWaitIdle waitStart("Start");
	EBWaitIdle waitMotion1("ArmPositioning");
	EBWaitIdle waitMotion2("Turn1");
	EBWaitIdle waitMotion3("Turn2");
	EBWaitIdle waitMotion4("Turn3");
	EBWaitIdle waitMotion5("Turn4");
	EBWaitIdle waitMotion6("Turn5");
	EBWaitIdle waitMotion7("Final pos");
	EBWaitIdle waitMotion8("Going back to rest");
	EBWaitIdle endState1("end1");
	EBWaitIdle endState2("end2");

	EBWaitIdle stateInhibitHandTracking("Inhibit hand tracking");
	EBWaitIdle stateEnableHandTracking("Enable hand tracking");

	EBWaitIdle position1Wait("Position1 done");
	EBWaitIdle position2Wait("Position2 done");
	EBWaitIdle position3Wait("Position3 done");
	
	EBWaitDeltaT position2Train(6);
	EBWaitDeltaT position3Train(6);
	EBWaitDeltaT position4Train(6);

	EBWaitIdle position2("Waiting arm done");
	EBWaitIdle position3("Waiting arm done");
	EBWaitIdle position4("Waiting arm done");

	EBWaitIdle waitArmAck("Wait armAck");

	EBWaitDeltaT dT1(6);
	EBWaitDeltaT dT2(0.2);
	EBWaitDeltaT dT3OneSecond(3);

	EBWaitDeltaT dTHandClosing(0.1);
	EBWaitDeltaT waitArmSeemsToRest(5);
	EBBehaviorOutput	startTrain(YBVKFTrainStart);
	EBBehaviorOutput	startSequence(YBVKFStart);
	EBBehaviorOutput    stopTrain(YBVKFTrainStop);
	EBBehaviorOutput    stop(YBVKFStop);
	EBSimpleOutput	forceOpen(YBVGraspRflxForceOpen);
	EBSimpleOutput  parkArm(YBVArmForceRestingTrue);
	
	// output: enable and disable hand tracking system
	EBEnableTracker		enableHandTracking;
	EBInhibitTracker	inhibitHandTracking;
		
	EBOutputCommand cmd1(YBVArmForceNewCmd, YVector(_nJoints, pos1));
	EBOutputCommand cmd2(YBVArmForceNewCmd, YVector(_nJoints, pos2));
	EBOutputCommand cmd3(YBVArmForceNewCmd, YVector(_nJoints, pos3));
	// EBOutputCommand cmd4(YBVArmForceNewCmd, YVector(_nJoints, pos4));
	// EBOutputCommand cmd5(YBVArmForceNewCmd, YVector(_nJoints, pos5));
//	EBOutputCommand cmd6(YBVArmForceNewCmd, YVector(_nJoints, pos6));
	EBOutputCommand cmd7(YBVArmForceNewCmd, YVector(_nJoints, pos7));
	EBOutputCommand cmd8(YBVArmForceNewCmd, YVector(_nJoints, pos8));
	EBOutputCommand cmd9(YBVArmForceNewCmd, YVector(_nJoints, pos9));
	EBOutputCommand cmd10(YBVArmForceNewCmd, YVector(_nJoints, pos10));

	EBSimpleInput armDone(YBVArmDone);
	EBSimpleInput handDone(YBVHandDone);
	EBSimpleInput start(YBVKFExplorationStart);
	EBSimpleInput start2(YBVGraspRflxClutch);
	EBSimpleInput armAck(YBVArmIssuedCmd);
	EBSimpleInput armNAck(YBVArmIsBusy);

	behavior.setInitialState(&waitStart);
	behavior.add(&start, &waitStart, &waitMotion1, &cmd1);
	behavior.add(&start2, &waitStart, &dTHandClosing, &enableHandTracking);
	behavior.add(NULL, &dTHandClosing, &waitArmAck, &cmd1);

	behavior.add(&armAck, &waitArmAck, &stateEnableHandTracking, &startSequence);
	behavior.add(&armNAck, &waitArmAck, &waitArmSeemsToRest, &inhibitHandTracking);
	behavior.add(NULL, &waitArmSeemsToRest, &waitStart, &forceOpen);
	behavior.add(NULL, &stateEnableHandTracking, &waitMotion1, &enableHandTracking);

	behavior.add(&armDone, &waitMotion1, &dT3OneSecond);
	// wait some extra time before issueing the startKF signal
	behavior.add(NULL, &dT3OneSecond, &dT1, &startTrain);
	
	// july 21/04
	behavior.add(NULL, &dT1, &waitMotion6);
	behavior.add(NULL, &waitMotion6, &position1Wait, &stopTrain);
	// position2
	behavior.add(NULL, &position1Wait, &position2, &cmd7);
	behavior.add(&armDone, &position2, &position2Train, &startTrain);
	behavior.add(NULL, &position2Train, &position2Wait, &stopTrain);
	//position3
	behavior.add(NULL, &position2Wait, &position3, &cmd8);
	behavior.add(&armDone, &position3, &position3Train, &startTrain);
	behavior.add(NULL, &position3Train, &position3Wait, &stopTrain);
	//position 4
	behavior.add(NULL, &position3Wait, &position4, &cmd9);
	behavior.add(&armDone, &position4, &position4Train, &startTrain);
	behavior.add(NULL, &position4Train, &stateInhibitHandTracking, &stopTrain);

	behavior.add(NULL, &stateInhibitHandTracking, &dT2);

	/*
	behavior.add(NULL, &dT1, &waitMotion2, &cmd2);
	// behavior.add(&armDone, &waitMotion1, &waitMotion2, &cmd2);
	behavior.add(&armDone, &waitMotion2, &waitMotion3, &cmd3);
	behavior.add(&armDone, &waitMotion3, &waitMotion4, &cmd4);
	behavior.add(&armDone, &waitMotion4, &waitMotion5, &cmd5);
	behavior.add(&armDone, &waitMotion5, &waitMotion6, &cmd6);

	behavior.add(&armDone, &waitMotion6, &dT2, &stopKF);
	*/
	behavior.add(NULL, &dT2, &waitMotion7, &cmd10);
	behavior.add(&armDone, &waitMotion7, &waitMotion8, &forceOpen);
	behavior.add(&handDone, &waitMotion8, &endState1, &parkArm);
	behavior.add(NULL, &endState1, &endState2, &inhibitHandTracking);
	behavior.add(NULL, &endState2, &waitStart, &stop);

	behavior.Begin();
	behavior.loop();

	return 0;
}