Ejemplo n.º 1
0
void
MooseEnumTest::withNamesFromTest()
{
  //
  // Construct MultiMooseEnum from MooseEnum
  //
  MooseEnum me1("one two three four");
  MultiMooseEnum mme1 = MultiMooseEnum::withNamesFrom(me1);

  // set in-range values
  mme1 = "one two";
  CPPUNIT_ASSERT( mme1.contains("one") == true );
  CPPUNIT_ASSERT( mme1.contains("two") == true );
  CPPUNIT_ASSERT( mme1.contains("three") == false );
  CPPUNIT_ASSERT( mme1.contains("four") == false );

  // set out-of-range values
  try
  {
    mme1 = "five";
  }
  catch(const std::exception & e)
  {
    std::string msg(e.what());
    CPPUNIT_ASSERT( msg.find("Invalid option") != std::string::npos );
  }

  // construct mme with out-of-range-allowed
  MooseEnum me2("one two three four", "", true);
  MultiMooseEnum mme2 = MultiMooseEnum::withNamesFrom(me2);
  mme2 = "six";
  CPPUNIT_ASSERT( mme2.contains("six") == true );

  //
  // Construct MooseEnum from MultiMooseEnum
  //
  MultiMooseEnum mme3("one two three four");
  MooseEnum me3 = MooseEnum::withNamesFrom(mme3);

  // set in-range values
  me3 = "one";
  CPPUNIT_ASSERT( me3 == "one" );

  // set out-of-range values
  try
  {
    me3 = "five";
  }
  catch(const std::exception & e)
  {
    std::string msg(e.what());
    CPPUNIT_ASSERT( msg.find("Invalid option") != std::string::npos );
  }

  // construct mme with out-of-range-allowed
  MultiMooseEnum mme4("one two three four", "", true);
  MooseEnum me4 = MooseEnum::withNamesFrom(mme4);
  me4 = "six";
  CPPUNIT_ASSERT( me4 == "six" );
}
Ejemplo n.º 2
0
void HM_LC_SWX_FM::handleStateChangeRemote(int32_t messageCounter, std::shared_ptr<BidCoSPacket> packet)
{
	try
	{
		if(packet->payload()->empty()) return;
		int32_t channel = packet->payload()->at(0) & 0x3F;
		if(channel > _channelCount) return;
		std::shared_ptr<HomeMaticCentral> central = getCentral();
		std::shared_ptr<BidCoSPeer> peer(central->getPeer(packet->senderAddress()));
		//Check if channel is paired to me
		std::shared_ptr<BasicPeer> me(peer->getPeer(channel, _address, channel));
		if(!me) return;
		int32_t channelGroupedWith = peer->getChannelGroupedWith(channel);
		if(channelGroupedWith > -1)
		{
			//Check if grouped channel is also paired to me
			std::shared_ptr<BasicPeer> me2(peer->getPeer(channelGroupedWith, _address, channelGroupedWith));
			if(!me2) channelGroupedWith = -1;
		}
		if(channelGroupedWith > -1)
		{
			if(channelGroupedWith < channel) _states[channel] = true;
			else _states[channel] = false;
		}
		else _states[channel] = !_states[channel];

		if(packet->controlByte() & 0x20) sendStateChangeResponse(packet, channel);
	}
	catch(const std::exception& ex)
    {
        Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(Exception& ex)
    {
        Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Ejemplo n.º 3
0
gslpp::complex AmpDS1::AmpDS1pp2(orders order) 
{
    if (mySM.getFlavour().getHDS1().getCoeffDS1PP().getOrder() < order){
        std::stringstream out;
        out << order;
        throw std::runtime_error("AmpDK1::computeThValue(): requires cofficient of "
                                 "order" + out.str() + "not computed");
    }
    
    gslpp::vector<gslpp::complex> ** allcoeff = mySM.getFlavour().ComputeCoeffDS1PP(
            mySM.getBKd3().getMu(),
            mySM.getBKd3().getScheme());
    
    gslpp::vector<double> me2(mySM.getBKd3().getBpars());
    
    double MK = mySM.getMesons(QCD::K_0).getMass();
    double MP = mySM.getMesons(QCD::P_0).getMass();
    double FK = mySM.getMesons(QCD::K_0).getDecayconst();
    double FP = mySM.getMesons(QCD::P_0).getDecayconst();
    double Ms = mySM.Mrun(mySM.getBKd3().getMu(),
                mySM.getQuarks(QCD::STRANGE).getMass_scale(),
                mySM.getQuarks(QCD::STRANGE).getMass(), FULLNNLO);
    double Md = mySM.Mrun(mySM.getBKd3().getMu(),
                mySM.getQuarks(QCD::DOWN).getMass_scale(),
                mySM.getQuarks(QCD::DOWN).getMass(), FULLNNLO);
    
    double X = sqrt(1.5)*FP*(MK*MK-MP*MP);
    double KK = FP/(FK-FP);
    double Q6b = -4.*sqrt(1.5)*(MK*MK/(Ms+Md))*(MK*MK/(Ms+Md))*FP/KK;
    
    me2(0) *= 4./9.*sqrt(2.)*X;
    me2(1) *= me2(0);
    me2(2) *= 0.;
    me2(3) *= 0.;
    me2(4) *= 0.;
    me2(5) *= 0.;
    me2(6) *= -(KK/6./sqrt(2.)*Q6b*(KK+1)-X/sqrt(2.));
    me2(7) *= -(KK/2./sqrt(2.)*Q6b*(KK+1)-sqrt(2.)/6.*X);
    me2(8) = 1.5*me2(0);
    me2(9) = 1.5*me2(0);
    me2(10) = 0.;
    me2(11) = 0.;
    
    switch(order) {
        case NLO:
           return((*(allcoeff[LO]) + *(allcoeff[NLO])) * me2);
        case LO:
            return((*(allcoeff[LO])) * me2);
        default:
            std::stringstream out;
            out << order;
            throw std::runtime_error("AmpDK1::AmpDK(): order " + out.str() + "not implemented");;
    }
}