Ejemplo n.º 1
0
void ZmpEKF::incorporateMeasurement(ZmpMeasurement z,
                                    StateMeasurementMatrix &H_k,
                                    MeasurementMatrix &R_k,
                                    MeasurementVector &V_k)
{
    static const float com_height  = 310; //TODO: Move this
	float zheight_div_G = com_height/GRAVITY_mss;
    static MeasurementVector last_measurement(
        ublas::scalar_vector<float>(measurementSize, 0.0f));

    MeasurementVector z_x(measurementSize);
    z_x(0) = z.comX + zheight_div_G * z.accX;
    z_x(1) = z.comY + zheight_div_G * z.accY;

    // The Jacobian is the identity because the observation space is the same
    // as the state space.
    H_k(0,0) = 1.0f;
    H_k(1,1) = 1.0f;

    V_k = z_x - xhat_k; // divergence

    //MeasurementVector deltaS = z_x - last_measurement;

    R_k(0,0) = getVariance(V_k(0));//variance;
    R_k(1,1) = getVariance(V_k(1));//variance;

    last_measurement = z_x;
}
Ejemplo n.º 2
0
/*
============
sdUICrosshairInfo::DrawBrackets
============
*/
void sdUICrosshairInfo::DrawBrackets( const sdBounds2D& bounds, const idVec4& color ) {
	const float screenWidth = SCREEN_WIDTH * 1.0f / deviceContext->GetAspectRatioCorrection();

	float left			= bounds.GetLeft();
	float right			= bounds.GetRight();
	float top			= bounds.GetTop();
	float bottom		= bounds.GetBottom();
	float width			= bounds.GetWidth();
	float height		= bounds.GetHeight();

	idVec2 center( left + width * 0.5f, top + height * 0.5f );

	float size = width * 0.25f;

	//
	// left half
	//
	idVec4 rect;
	rect.Set( left - crosshairParts[ CP_L_BRACKET_TOP ].width, top, crosshairParts[ CP_L_BRACKET_TOP ].width, height );

	DrawThreeVerticalParts( rect, color, vec2_one, crosshairParts[ CP_L_BRACKET_TOP ], crosshairParts[ CP_L_BRACKET_CENTER ], crosshairParts[ CP_L_BRACKET_BOTTOM ] );
	
	rect.Set( right, top, crosshairParts[ CP_L_BRACKET_TOP ].width, height );
	DrawThreeVerticalParts( rect, color, vec2_one, crosshairParts[ CP_R_BRACKET_TOP ], crosshairParts[ CP_R_BRACKET_CENTER ], crosshairParts[ CP_R_BRACKET_BOTTOM ] );	
	
}
void SplitSwitchPlugin::Execute() {
  int n;
  int NumChans = m_PluginInfo.NumOutputs - 1;
  for (n=1; n<m_PluginInfo.NumOutputs; n++) GetOutputBuf(n)->Zero();
  if (InputExists (2)) {
    for (n=0; n<m_HostInfo->BUFSIZE; n++) {
      if (InputExists (0)) {
        m_GUIArgs.Auto = true;
        // Check the Switch Pos CV Value
        m_SwitchPos = int (GetInput (0, n));
      }
      else if (InputExists (1)) {
        m_GUIArgs.Auto = true;
        // Check the trigger CV value
        if (GetInput (1, n) < 0.01) {
          m_Triggered = false;
        }
        else {
          if (!m_Triggered) {
            m_Triggered = true;
            m_SwitchPos = (m_SwitchPos+1);
          }
        }
      }
      else {
        m_GUIArgs.Auto = false;
        m_SwitchPos=(m_GUIArgs.Switch);
      }
      if (m_SwitchPos > NumChans) m_SwitchPos = 1;
      m_GUIArgs.Echo = m_SwitchPos;
      SetOutput (0, n, m_SwitchPos);
      SetOutput (m_SwitchPos, n, GetInput (2, n));
    }
  }
}
Ejemplo n.º 4
0
bool CLuaMain::LoadScript(const char* szLUAScript)
{
    if (m_luaVM && !IsLuaCompiledScript(szLUAScript, strlen(szLUAScript)))
    {
        // Run the script
        if (!CLuaMain::LuaLoadBuffer(m_luaVM, szLUAScript, strlen(szLUAScript), NULL))
        {
            ResetInstructionCount();
            int luaSavedTop = lua_gettop(m_luaVM);
            int iret = this->PCall(m_luaVM, 0, LUA_MULTRET, 0);
            if (iret == LUA_ERRRUN || iret == LUA_ERRMEM)
            {
                std::string strRes = ConformResourcePath(lua_tostring(m_luaVM, -1));
                g_pClientGame->GetScriptDebugging()->LogPCallError(m_luaVM, strRes);
            }
            // Cleanup any return values
            if (lua_gettop(m_luaVM) > luaSavedTop)
                lua_settop(m_luaVM, luaSavedTop);
        }
        else
        {
            std::string strRes = ConformResourcePath(lua_tostring(m_luaVM, -1));
            g_pClientGame->GetScriptDebugging()->LogError(m_luaVM, "Loading in-line script failed: %s", strRes.c_str());
        }
    }
    else
        return false;

    return true;
}
Ejemplo n.º 5
0
void nofCarrier::LookForWares()
{
    // Gibts an dieser Flagge etwas, das ich tragen muss?
    if(workplace->AreWareJobs(!rs_dir, ct, true))
    {
        // Dann soll das CARRS_FETCHWARE übernehmen
        FetchWare(false);
    }
    else if(workplace->AreWareJobs(rs_dir, ct, false))
    {
        // Oder evtl auf der anderen Seite?
        state = CARRS_FETCHWARE;
        rs_dir = !rs_dir;
        rs_pos = 0;
        StartWalking(cur_rs->GetDir(rs_dir, rs_pos));
    }
    else
    {
        // Wieder zurück in die Mitte gehen
        state = CARRS_GOTOMIDDLEOFROAD;
        rs_dir = !rs_dir;
        rs_pos = 0;
        StartWalking(cur_rs->GetDir(rs_dir, rs_pos));
    }
}
void HRP2DeviceTorqueCtrl::setState( const ml::Vector& q )
{
  assert(q.size()==N_JOINTS+6);
  if(!m_initSucceeded)
  {
    SEND_WARNING_STREAM_MSG("Cannot setState before initialization!");
    return;
  }
  Device::setState(q);
  COPY_VECTOR_TO_VECTOR(q, m_q_sot);
  config_sot_to_urdf(m_q_sot, m_q);

  m_robot->computeAllTerms(*m_data, m_q, m_v);
  se3::SE3 H_lf = m_robot->position(*m_data,
                                    m_robot->model().getJointId(LEFT_FOOT_FRAME_NAME));
  pininvdyn::trajectories::TrajectorySample s(12, 6);
  pininvdyn::math::se3ToVector(H_lf, s.pos);
  m_contactLF->setReference(s);
  SEND_MSG("Setting left foot reference to "+toString(H_lf), MSG_TYPE_DEBUG);

  se3::SE3 H_rf = m_robot->position(*m_data,
                                    m_robot->model().getJointId(RIGHT_FOOT_FRAME_NAME));
  pininvdyn::math::se3ToVector(H_rf, s.pos);
  m_contactRF->setReference(s);
  SEND_MSG("Setting right foot reference to "+toString(H_rf), MSG_TYPE_DEBUG);
}
Ejemplo n.º 7
0
bool
Feature::getWorldBound(const SpatialReference* srs,
                       osg::BoundingSphered&   out_bound) const
{
    if ( srs && getSRS() && getGeometry() )
    {
        out_bound.init();

        ConstGeometryIterator i( getGeometry(), false); 
        while( i.hasMore() )
        {
            const Geometry* g = i.next();
            for( Geometry::const_iterator p = g->begin(); p != g->end(); ++p )
            {
                GeoPoint point( getSRS(), *p, ALTMODE_ABSOLUTE );
                GeoPoint srs_point;
                if ( point.transform( srs, srs_point ) )
                {
                    osg::Vec3d world;
                    srs_point.toWorld(world);
                    out_bound.expandBy( world );
                }
            }
        }
        if ( out_bound.valid() && out_bound.radius() == 0.0 )
        {
            out_bound.radius() = 1.0;
        }
        return true;
    }
    return false;
}
Ejemplo n.º 8
0
int LibANNInterface::annCntNeighbours(std::vector<double>& query_point, double epsilon, double radius) {
    if (epsilon < 0)
        throw InvalidParameterValueException("epsilon must be >= 0");

    if (query_point.size() != dim)
        throw InvalidParameterValueException("query_point must have the same dimension as the current tree");

    ANNpoint query_pt  = annAllocPt(dim);

    int i = 0;
    std::vector<double>::iterator iter;

    for(iter = query_point.begin(); iter != query_point.end(); iter++) {
        query_pt[i] = *iter;
        i++;
    }

    int points_nearby = 0;

    if (is_bd_tree) {
        points_nearby = bd_tree->annkFRSearch(query_pt, radius * radius, 0, NULL, NULL, epsilon);
    }
    else {
        points_nearby = kd_tree->annkFRSearch(query_pt, radius * radius, 0, NULL, NULL, epsilon);
    }

    annDeallocPt(query_pt);

    return points_nearby;
}
 explicit LbmNormalizerExecStreamTest()
 {
     FENNEL_UNIT_TEST_CASE(LbmNormalizerExecStreamTest, testBitsInByte);
     FENNEL_UNIT_TEST_CASE(LbmNormalizerExecStreamTest, testScanFullKey);
     FENNEL_UNIT_TEST_CASE(LbmNormalizerExecStreamTest, testScanPartKey);
     FENNEL_UNIT_TEST_CASE(LbmNormalizerExecStreamTest, testCloseRepeats);
 }
Ejemplo n.º 10
0
void F06Parser::add_assertions(const ConfigurationParameters& configuration,
		shared_ptr<Model> model) {
	if (!configuration.resultFile.empty()) {
		ifstream istream(configuration.resultFile.c_str());
		string currentLine;
		int currentSubCase = NO_SUBCASE;
		double loadStep = -1;
		double frequency = -1;
		while (this->readLine(istream, currentLine)) {
			trim(currentLine);
			size_t subCasePosition = currentLine.find("SUBCASE");
			if (subCasePosition != string::npos) {
				string subcaseN = trim_copy(currentLine.substr(subCasePosition + 7));
				//cout << "SUBCASE "<<subcaseN<< "  " << currentLine <<endl;
				currentSubCase = parseSubcase(currentSubCase, currentLine);
				loadStep = -1;
			}
			size_t loadStepPosition = currentLine.find("LOAD STEP = ");
			if (loadStepPosition != string::npos) {
				string loadStepString = trim_copy(currentLine.substr(loadStepPosition + 12));
				istringstream istringLine(loadStepString);
				istringLine >> loadStep;
			}
			size_t frequencyPosition = currentLine.find("FREQUENCY = ");
			if (frequencyPosition != string::npos) {
				string frequencyString = trim_copy(currentLine.substr(frequencyPosition + 12));
				istringstream istringLine(frequencyString);
				istringLine >> frequency;
			}
Ejemplo n.º 11
0
CParticleEmitter::CParticleEmitter( CProperty* a_Property ) 
	: m_EmissionTime( 0.0f ), m_EmittedParticles( 0 ), m_EmissionRate( 0 ), m_MinRadius( 0.0f ), m_MaxRadius( 0.0f )
{
	CProperty* readProperty;
	//Common properties	
	PROPERTY_VALUE( HASHED_ID( position ), m_Position, CVector3, CVector3() );
	PROPERTY_STRINGVALUE( HASHED_ID( name ), m_Name, "" );
	PROPERTY_VALUE( HASHED_ID( rotation ), m_Rotation, CVector3, CVector3() );
	PROPERTY_VALUE( HASHED_ID( emissionrate ), m_EmissionRate, Float, 0.0f );
	//Shape specific properties
	std::string shapeName;
	PROPERTY_STRINGVALUE( HASHED_ID( shape_name ), shapeName, "Unknown" );	
	if ( shapeName == "Cube" )
	{		
		PROPERTY_VALUE( HASHED_ID( shape_size ), m_MaxSize, CVector3, CVector3() );
		m_MinSize = -m_MaxSize;		
		m_Shape = CParticleEmitter::EMITTERSHAPE_CUBE;
	}
	else if ( shapeName == "Sphere" )
	{
		PROPERTY_VALUE( HASHED_ID( shape_minradius ), m_MinRadius, Float, 1.0f );
		PROPERTY_VALUE( HASHED_ID( shape_maxradius ), m_MaxRadius, Float, 2.0f );
		m_Shape = CParticleEmitter::EMITTERSHAPE_SPHERE;
	}
	else if ( shapeName == "Cone" )
	{
		m_Shape = CParticleEmitter::EMITTERSHAPE_CONE;
	}	
	else if ( shapeName == "Unknown" )
	{
		CLog::GetInstance()->OutMessage( "Particle emitter with no shape (%s)", CLog::MESSAGETYPE_WARNING, m_Name.c_str() );
	}

	m_OneOverEmissionTime = 1.0f / m_EmissionRate;
}
Ejemplo n.º 12
0
void RingoPgSearchEngine::_prepareSubSearch(PG_OBJECT scan_desc_ptr) {
   IndexScanDesc scan_desc = (IndexScanDesc) scan_desc_ptr;
   QS_DEF(Array<char>, search_type);
   int bingo_res;
   Array<char> search_query;
   Array<char> search_options;
   BingoPgFpData& data = _queryFpData.ref();

   BingoPgCommon::getSearchTypeString(_searchType, search_type, false);

   _getScanQueries(scan_desc->keyData[0].sk_argument, search_query, search_options);

   /*
    * Set up matching parameters
    */
   bingo_res = ringoSetupMatch(search_type.ptr(), search_query.ptr(), search_options.ptr());
   CORE_HANDLE_ERROR(bingo_res, 1, "reaction search engine: can not set rsub search context", bingoGetError());

   const char* fingerprint_buf;
   int fp_len;

   bingo_res = ringoGetQueryFingerprint(&fingerprint_buf, &fp_len);
   CORE_HANDLE_ERROR(bingo_res, 1, "reaction search engine: can not get query fingerprint", bingoGetError());

   int size_bits = fp_len * 8;
   data.setFingerPrints(fingerprint_buf, size_bits);

}
Ejemplo n.º 13
0
	void CommonAPI::OnTerminated(TcpConnection * connection)
#endif
	{
		std::string host;
		HostMap_t::iterator iter;
		if ((iter = mHostMap[0].find(connection)) != mHostMap[0].end())
		{
			if (mActiveHosts[0].erase(connection) != 0)
			{
				OnConnectionClosed(iter->second.c_str(), "unknown");
			}
			else
			{
				OnConnectionFailed(iter->second.c_str());
			}
			iter->first->Release();
			mIdleHosts[0].push_back(iter->second);
			mHostMap[0].erase(iter);
		}
		else if ((iter = mHostMap[1].find(connection)) != mHostMap[1].end())
		{
			if (mActiveHosts[1].erase(connection) != 0)
			{
				OnConnectionClosed(iter->second.c_str(), "unknown");
			}
			else
			{
				OnConnectionFailed(iter->second.c_str());
			}
			iter->first->Release();
			mIdleHosts[1].push_back(iter->second);
			mHostMap[1].erase(iter);
		}
	}
Ejemplo n.º 14
0
soci::connection_pool&
Database::getPool()
{
    if (!mPool)
    {
        auto const& c = mApp.getConfig().DATABASE;
        if (!canUsePool())
        {
            std::string s("Can't create connection pool to ");
            s += removePasswordFromConnectionString(c.value);
            throw std::runtime_error(s);
        }
        size_t n = std::thread::hardware_concurrency();
        LOG(INFO) << "Establishing " << n << "-entry connection pool to: "
                  << removePasswordFromConnectionString(c.value);
        mPool = std::make_unique<soci::connection_pool>(n);
        for (size_t i = 0; i < n; ++i)
        {
            LOG(DEBUG) << "Opening pool entry " << i;
            soci::session& sess = mPool->at(i);
            sess.open(c.value);
            if (!isSqlite())
            {
                setSerializable(sess);
            }
        }
    }
    assert(mPool);
    return *mPool;
}
Ejemplo n.º 15
0
TVNamerService::TVNamerService(QObject *parent, const QVariantList &)
    : Nepomuk2::Service(parent)
{
    // set up the watcher for newly created nfo:Video resources
    Nepomuk2::ResourceWatcher* watcher = new Nepomuk2::ResourceWatcher(this);
    watcher->addType(NFO::Video());
    connect(watcher, SIGNAL(resourceCreated(Nepomuk2::Resource,QList<QUrl>)),
            this, SLOT(slotVideoResourceCreated(Nepomuk2::Resource,QList<QUrl>)));
    watcher->start();

    // set up the watcher for newly created TV Shows
    watcher = new Nepomuk2::ResourceWatcher(this);
    watcher->addType(NMM::TVShow());
    connect(watcher, SIGNAL(resourceCreated(Nepomuk2::Resource,QList<QUrl>)),
            this, SLOT(slotTVShowResourceCreated(Nepomuk2::Resource)));
    connect(watcher, SIGNAL(resourceTypeAdded(Nepomuk2::Resource,Nepomuk2::Types::Class)),
            this, SLOT(slotTVShowResourceCreated(Nepomuk2::Resource)));
    watcher->start();

    // set up the watcher for watched TV Shows
    watcher = new Nepomuk2::ResourceWatcher(this);
    watcher->addType(NMM::TVShow());
    watcher->addProperty(NUAO::usageCount());
    connect(watcher, SIGNAL(propertyAdded(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariant)),
            this, SLOT(slotTVShowUsageCountChanged(Nepomuk2::Resource)));
    watcher->start();
}
Ejemplo n.º 16
0
string getCurrentExeFolder()
{
#if defined(_WIN32) || defined(WIN32)
	char path[MAX_PATH];
	if(GetModuleFileNameA(NULL, path, ARRAYSIZE(path)) != 0)
    {
	    string aPath(ExtractFilePath(path));
		return aPath;
    }
    return "";
// (from Andy S.)  --- :
#elif defined(__APPLE__)
    char path[PATH_MAX+1];
    unsigned  bufsize = sizeof(path);
    if (_NSGetExecutablePath(path, &bufsize) == 0) {
	    string aPath(ExtractFilePath(path));
		return aPath;
    }
#elif defined __linux
        char arg1[20];
        char exepath[PATH_MAX + 1] = {0};

        sprintf( arg1, "/proc/%d/exe", getpid() );
        readlink( arg1, exepath, 1024 );
		string thePath = ExtractFilePath(exepath); 
		Log(lDebug1)<<"Current exe folder says:"<<thePath;
        return thePath;
#endif

}
Ejemplo n.º 17
0
//*************************************************************************************************
int main()
{
   std::cout << "   Running 'UDbSCb'..." << std::endl;

   using blazetest::mathtest::TypeB;

   try
   {
      // Matrix type definitions
      typedef blaze::UpperMatrix< blaze::DynamicMatrix<TypeB> >         UDb;
      typedef blaze::SymmetricMatrix< blaze::CompressedMatrix<TypeB> >  SCb;

      // Creator type definitions
      typedef blazetest::Creator<UDb>  CUDb;
      typedef blazetest::Creator<SCb>  CSCb;

      // Running tests with small matrices
      for( size_t i=0UL; i<=6UL; ++i ) {
         for( size_t j=0UL; j<=i*i; ++j ) {
            RUN_DMATSMATSUB_OPERATION_TEST( CUDb( i ), CSCb( i, j ) );
         }
      }

      // Running tests with large matrices
      RUN_DMATSMATSUB_OPERATION_TEST( CUDb(  67UL ), CSCb(  67UL,  7UL ) );
      RUN_DMATSMATSUB_OPERATION_TEST( CUDb( 128UL ), CSCb( 128UL, 16UL ) );
   }
   catch( std::exception& ex ) {
      std::cerr << "\n\n ERROR DETECTED during dense matrix/sparse matrix subtraction:\n"
                << ex.what() << "\n";
      return EXIT_FAILURE;
   }

   return EXIT_SUCCESS;
}
Ejemplo n.º 18
0
void CDB::Close()
{
    if (!pdb)
        return;
    if (activeTxn)
        activeTxn->abort();
    activeTxn = NULL;
    pdb = NULL;

    // Flush database activity from memory pool to disk log
    unsigned int nMinutes = 0;
    if (fReadOnly)
        nMinutes = 1;
    if (IsChainFile(strFile))
        nMinutes = 2;
    if (IsChainFile(strFile) && IsInitialBlockDownload())
        nMinutes = 5;

    bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0);

    {
        LOCK(bitdb.cs_db);
        --bitdb.mapFileUseCount[strFile];
    }
}
Ejemplo n.º 19
0
int
main(int argc,
     char *argv[])
{
    if (argc<2 || argc>3) {
        cerr << "test the Random.h random number generators by drawing from\n"
             << "uniform, Gaussian, binomial, and poisson deviates.\n"
             << "Usage: test_random <nTrials> [seed]\n"
             << " nTrials is number of trials to output\n"
             << " seed is optional long-int seed.  Time of day is used as seed if none given.\n"
             << " output: 1 line per trial, giving trial number, uniform deviate,\n"
             << "   Gaussian deviate (mean=0, sigma=1),\n"
             << "   binomial deviate (N=10, p=0.4), and Poisson deviate (mean=3.5)."
             << endl;
        exit(1);
    }
    galsim::UniformDeviate u(0);
    int nTrials = atoi(argv[1]);
    if (argc>2) u.seed(atoi(argv[2]));
    galsim::GaussianDeviate gd(u,0.,1.);
    galsim::BinomialDeviate bd(u,10,0.4);
    galsim::PoissonDeviate pd(u, 3.5);

    for (int i=0; i<nTrials; i++)
        cout << i << " " << u() << " " << gd() << " " << bd() << " " << pd() << endl;
}
void test_config_file()
{
    options_description desc;
    desc.add_options()
        ("gv1", new untyped_value)
        ("gv2", new untyped_value)
        ("plug*", new untyped_value)
        ("m1.v1", new untyped_value)
        ("m1.v2", new untyped_value)
        ("b", bool_switch())
    ;

    const char content1[] =
    " gv1 = 0#asd\n"
    "plug3 = 7\n"
    "b = true\n"
    "[m1]\n"
    "v1 = 1\n"
    "\n"
    "v2 = 2\n"    
    ;

    stringstream ss(content1);
    vector<option> a1 = parse_config_file(ss, desc).options;
    BOOST_REQUIRE(a1.size() == 5);
    check_value(a1[0], "gv1", "0");
    check_value(a1[1], "plug3", "7");
    check_value(a1[2], "b", "true");
    check_value(a1[3], "m1.v1", "1");
    check_value(a1[4], "m1.v2", "2");

}
Ejemplo n.º 21
0
void muRmuFvariations(TString lev){
  line2();
  cout << " ### muR/muF ME variations (hdamp = mtop), nominal + 8" << endl;
  line();
  cout << "                                      "; printchan();
  line();
  printi(1);  cout << " muR = 1  , muF = 1    || " ; print3(lev, 1 ,1);
  printi(2);  cout << " muR = 1  , muF = 2    || " ; print3(lev, 2 ,1);
  printi(3);  cout << " muR = 1  , muF = 0.5  || " ; print3(lev, 3 ,1);
  printi(4);  cout << " muR = 2  , muF = 1    || " ; print3(lev, 4 ,1);
  printi(5);  cout << " muR = 2  , muF = 2    || " ; print3(lev, 5 ,1);
  printi(6);  cout << " muR = 2  , muF = 0.5  || " ; print3(lev, 6 ,1);
  printi(7);  cout << " muR = 0.5, muF = 1    || " ; print3(lev, 7 ,1);
  printi(8);  cout << " muR = 0.5, muF = 2    || " ; print3(lev, 8 ,1);
  printi(9);  cout << " muR = 0.5, muF = 0.5  || " ; print3(lev, 9 ,1);
  line();
  float nom = 0; float y = 0; float vmax = 0;
  TString o = " Maximum variation                  ";
  for(int i = 0; i < nChannels; i++){
    nom = GetWeight(chan[i], lev, 1); vmax = nom;
    for(int k = 0; k<9; k++) {
       if (TMath::Abs(GetWeight(chan[i], lev, k+1)-nom) > TMath::Abs(vmax-nom)) vmax = GetWeight(chan[i], lev, k+1);
    }
    o += Form("||  %6.2f (%2.2f %)  ", TMath::Abs(vmax-nom), TMath::Abs(vmax-nom)/nom*100);
  }
  //cout << Form(" Maximum variation   %6.2f (%2.3f %)  ||  %6.2f (%2.3f %)  ||  %6.2f (%2.3f %)  ", v1, e1, v2, e2, v3, e3)" << endl;
  cout << o << endl;
  line2();
}
void PubSubEventSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
    if (level == 0) {
        if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) {
            getPayloadInternal()->setNode(*attributeValue);
        }
        if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) {
            if (boost::optional<JID> jid = JID::parse(*attributeValue)) {
                getPayloadInternal()->setJID(*jid);
            }
        }
        if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subscription")) {
            if (boost::optional<PubSubEventSubscription::SubscriptionType> value = EnumParser<PubSubEventSubscription::SubscriptionType>()(PubSubEventSubscription::None, "none")(PubSubEventSubscription::Pending, "pending")(PubSubEventSubscription::Subscribed, "subscribed")(PubSubEventSubscription::Unconfigured, "unconfigured").parse(*attributeValue)) {
                getPayloadInternal()->setSubscription(*value);
            }
        }
        if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subid")) {
            getPayloadInternal()->setSubscriptionID(*attributeValue);
        }
        if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("expiry")) {
                getPayloadInternal()->setExpiry(stringToDateTime(*attributeValue));
        }
    }



    if (level >= 1 && currentPayloadParser) {
        currentPayloadParser->handleStartElement(element, ns, attributes);
    }
    ++level;
}
Ejemplo n.º 23
0
/*
* Actual HL-Decomposition part
* Initially all entries of chainHead[] are set to -1.
* So when ever a new chain is started, chain head is correctly assigned.
* As we add a new node to chain, we will note its position in the baseArray.
* In the first for loop we find the child node which has maximum sub-tree size.
* The following if condition is failed for leaf nodes.
* When the if condition passes, we expand the chain to special child.
* In the second for loop we recursively call the function on all normal nodes.
* chainNo++ ensures that we are creating a new chain for each normal child.
*/
void HLD(int curNode, int cost, int prev) {
    if(chainHead[chainNo] == -1) {
        chainHead[chainNo] = curNode; // Assign chain head
    }
    
    chainInd[curNode] = chainNo;
    posInBase[curNode] = ptr; // Position of this node in baseArray which we will use in Segtree
    baseArray[ptr++] = cost;
    
    int sc = -1, ncost;
    // Loop to find special child
    for(int i=0; i<adj[curNode].size(); i++) if(adj[curNode][i] != prev) {
        if(sc == -1 || subsize[sc] < subsize[adj[curNode][i]]) {
            sc = adj[curNode][i];
            ncost = costs[curNode][i];
        }
    }
    
    if(sc != -1) {
        // Expand the chain
        HLD(sc, ncost, curNode);
    }
    
    for(int i=0; i<adj[curNode].size(); i++) if(adj[curNode][i] != prev) {
        if(sc != adj[curNode][i]) {
            // New chains at each normal node
            chainNo++;
            HLD(adj[curNode][i], costs[curNode][i], curNode);
        }
    }
}
Ejemplo n.º 24
0
static int tolua_sjasm_sj_insert_label00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isstring(tolua_S,1,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isboolean(tolua_S,3,1,&tolua_err) ||
     !tolua_isboolean(tolua_S,4,1,&tolua_err) ||
     !tolua_isnoobj(tolua_S,5,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  char* tolua_var_5 = ((char*)  tolua_tostring(tolua_S,1,0));
  unsigned int tolua_var_6 = ((unsigned int)  tolua_tonumber(tolua_S,2,0));
  bool tolua_var_7 = ((bool)  tolua_toboolean(tolua_S,3,false));
  bool tolua_var_8 = ((bool)  tolua_toboolean(tolua_S,4,false));
  {
   bool tolua_ret = (bool)  LabelTable.Insert(tolua_var_5,tolua_var_6,tolua_var_7,tolua_var_8);
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'insert_label'.",&tolua_err);
 return 0;
#endif
}
Ejemplo n.º 25
0
void nofCarrier::HandleDerivedEvent(const unsigned int id)
{
    switch(id)
    {
            // Produktivitätsevent
        case 1:
        {
            productivity_ev = 0;

            // Gucken, ob bis jetzt gearbeitet wurde/wird oder nicht, je nachdem noch was dazuzählen
            if(since_working_gf != 0xFFFFFFFF)
            {
                // Es wurde bis jetzt nicht mehr gearbeitet, das also noch dazuzählen
                worked_gf += static_cast<unsigned short>(GetEvMgr().GetCurrentGF() - since_working_gf);
                // Zähler zurücksetzen
                since_working_gf = GetEvMgr().GetCurrentGF();
            }

            // Produktivität ausrechnen
            productivity = worked_gf * 100 / PRODUCTIVITY_GF;

            // Zähler zurücksetzen
            worked_gf = 0;

            // Nächstes Event anmelden
            productivity_ev = GetEvMgr().AddEvent(this, PRODUCTIVITY_GF, 1);

            // Reif für einen Esel?
            if(productivity >= DONKEY_PRODUCTIVITY && ct == CT_NORMAL)
                workplace->UpgradeDonkeyRoad();

        } break;
    }
}
Ejemplo n.º 26
0
void Polygon::read(istream &stream) {
    flags = readString(stream);

    readWS(stream);
    int c = stream.get();
    if (c != ')')  THROW("missing ')' on Polygon");

    readWS(stream);
    c = stream.get();
    if (c != '(')  THROW("missing '(' on Polygon");

    do {
        readWS(stream);
        c = stream.get();
        if (c != '[') break;

        Point p;
        stream >> p;
        points.push_back(p);

        readWS(stream);
        c = stream.get();
        if (c != ']')  THROW("missing ']' on Polygon point");

    } while (true);

    stream.unget();
}
Ejemplo n.º 27
0
// Select the preferred successor for MBB.
const MachineBasicBlock*
MinInstrCountEnsemble::pickTraceSucc(const MachineBasicBlock *MBB) {
  if (MBB->pred_empty())
    return nullptr;
  const MachineLoop *CurLoop = getLoopFor(MBB);
  const MachineBasicBlock *Best = nullptr;
  unsigned BestHeight = 0;
  for (const MachineBasicBlock *Succ : MBB->successors()) {
    // Don't consider back-edges.
    if (CurLoop && Succ == CurLoop->getHeader())
      continue;
    // Don't consider successors exiting CurLoop.
    if (isExitingLoop(CurLoop, getLoopFor(Succ)))
      continue;
    const MachineTraceMetrics::TraceBlockInfo *SuccTBI =
      getHeightResources(Succ);
    // Ignore cycles that aren't natural loops.
    if (!SuccTBI)
      continue;
    // Pick the successor that would give this block the smallest InstrHeight.
    unsigned Height = SuccTBI->InstrHeight;
    if (!Best || Height < BestHeight) {
      Best = Succ;
      BestHeight = Height;
    }
  }
  return Best;
}
Ejemplo n.º 28
0
bool MipsMCInstLower::lowerLongBranch(const MachineInstr *MI,
                                      MCInst &OutMI) const {
  switch (MI->getOpcode()) {
  default:
    return false;
  case Mips::LONG_BRANCH_LUi:
    lowerLongBranchLUi(MI, OutMI);
    return true;
  case Mips::LONG_BRANCH_ADDiu:
    lowerLongBranchADDiu(MI, OutMI, Mips::ADDiu,
                         MCSymbolRefExpr::VK_Mips_ABS_LO);
    return true;
  case Mips::LONG_BRANCH_DADDiu:
    unsigned TargetFlags = MI->getOperand(2).getTargetFlags();
    if (TargetFlags == MipsII::MO_ABS_HI)
      lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu,
                           MCSymbolRefExpr::VK_Mips_ABS_HI);
    else if (TargetFlags == MipsII::MO_ABS_LO)
      lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu,
                           MCSymbolRefExpr::VK_Mips_ABS_LO);
    else
      report_fatal_error("Unexpected flags for LONG_BRANCH_DADDiu");
    return true;
  }
}
void displayFcn()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glPointSize(4);

    glViewport(0, 400, 400, 400);
	GeneralLineGeneration(10, 20, 60, 80);
    BresenhamLineGeneration(20, 20, 70, 80);

    glViewport(400, 400, 400, 400);
	GeneralLineGeneration(20, 80, 70, 10);
    BresenhamLineGeneration(30, 80, 80, 10);

    glViewport(0, 0, 400, 400);
	GeneralLineGeneration(10, 30, 80, 50);
    BresenhamLineGeneration(10, 40, 80, 60);

    glViewport(400, 0, 400, 400);
	GeneralLineGeneration(10, 40, 90, 40);
    BresenhamLineGeneration(10, 60, 90, 60);
	GeneralLineGeneration(40, 10, 40, 90);
    BresenhamLineGeneration(60, 10, 60, 90);

	glFlush();
}
Ejemplo n.º 30
0
void	CDspTaskHelper::reassignTask( SmartPtr<CDspClient>& pNewClient, const SmartPtr<IOPackage>& pNewPackage )
{
	PRL_ASSERT( pNewClient );
	PRL_ASSERT( pNewPackage );
	if ( ! pNewClient || ! pNewPackage )
		return;

	QMutexLocker lock( &m_assignMutex );

	IOPackage::Type old_cmd = getRequestPackage()->header.type;

	WRITE_TRACE(DBG_FATAL, "Task with uuid = %s would be reassigned: "
		"session[ %s => %s ]"
		", packet [%#x => %#x]  "
		, QSTR2UTF8( getJobUuid().toString() )
		, QSTR2UTF8( getClient()->getClientHandle() )
		, QSTR2UTF8( pNewClient->getClientHandle() )
		, getRequestPackage()->header.type
		, pNewPackage->header.type
		);

	if(!m_bTaskLostByClient)
	{
		m_bTaskLostByClient = true;
		m_pLostTaskUser = m_pUser;
	}
	m_pUser = pNewClient;
	m_requestPkg = IOPackage::duplicateInstance( pNewPackage );
	m_requestPkg->header.type = old_cmd;

	parseFlags();

}