Beispiel #1
0
 void DrawContoursTest::testInPlace1()
 {
     m_operator->initialize();
     m_operator->activate();
     
     runtime::DataContainer img(new cvsupport::Image("lenna.jpg"));
     runtime::Data* contoursItem = 0;
     std::vector<runtime::Data*> contoursVector;
     contoursItem = new cvsupport::Matrix("contour_1.npy");
     contoursVector.push_back(contoursItem);
     contoursItem = new cvsupport::Matrix("contour_2.npy");
     contoursVector.push_back(contoursItem);
     runtime::DataContainer contours(new runtime::List(contoursVector));
     
     runtime::UInt8 ch1(255);
     runtime::UInt8 ch2(0);
     runtime::UInt8 ch3(0);
     runtime::Int32 thickness(-1);
     
     m_operator->setInputData(DrawContours::IMG, img);
     m_operator->setInputData(DrawContours::CONTOURS, contours);
     m_operator->setParameter(DrawContours::CH_1, ch1);
     m_operator->setParameter(DrawContours::CH_2, ch2);
     m_operator->setParameter(DrawContours::CH_3, ch3);
     m_operator->setParameter(DrawContours::THICKNESS, thickness);
     
     runtime::DataContainer imgResult = m_operator->getOutputData(DrawContours::IMG);
     
     runtime::ReadAccess imgAccess(imgResult);
     cvsupport::Image::save("DrawContoursTest_testInPlace1_img.png", imgAccess.get<runtime::Image>());
 }
Beispiel #2
0
void lc_tankdlg::frontview(double height, double leng, double x, double CH,double r,double breadth,Document_Interface *doc)
{

    QPointF Coord_a,Coord_e(0.0,breadth+x), Coord_f(0.0,height);//front view
    Coord_a.setX(startxedit->text().toDouble());
    Coord_a.setY(startyedit->text().toDouble());
    Coord_e += Coord_a, Coord_f+= Coord_e;
    QPointF Coord_g(leng,0.0), Coord_h(0.0,0.0-height);
    Coord_g += Coord_f,Coord_h += Coord_g;

    QPointF mid1_l(leng/2-r,0.0), mid2_l(leng/2+r,0.0); //tank  front view
    mid1_l += Coord_f, mid2_l += Coord_f;

    QPointF ch1(0.0,CH), ch2(0.0,CH);
    ch1 += mid1_l, ch2 +=mid2_l;

    doc->addLine(&Coord_e, &Coord_f);//coord_e to coor_h for Front view
    doc->addLine(&Coord_f, &Coord_g );
    doc->addLine(&Coord_g, &Coord_h);
    doc->addLine(&Coord_h, & Coord_e);

    doc->addLine(&mid1_l,&ch1); // tank of front view
    doc->addLine(&mid2_l,&ch2);
    doc->addLine(&ch1,&ch2);
}
Beispiel #3
0
int main () {
	A2D ch1(0);
	while (1) {
		ch1.getValue8();
		_delay_ms(100);
		ch1.getValue10();
		_delay_ms(100);
	}
	return 0;
}
Beispiel #4
0
TEST(ChunkTests, InterpolatesNoiseInputsCorrectly) {
  const unsigned VOXELS_PER_CHUNK = Units::chunkToVoxel(1);
  DummyChunk ch1(0, 0, 0);
  glm::vec3 v000(ch1.getNoiseModuleInput(glm::vec3(0, 0, 0)));
  glm::vec3 v100(ch1.getNoiseModuleInput(glm::vec3(1, 0, 0)));
  glm::vec3 v200(ch1.getNoiseModuleInput(glm::vec3(2, 0, 0)));
  
  EXPECT_EQ(glm::vec3(0.0, 0.0, 0.0), v000);
  EXPECT_EQ(glm::vec3(1.f / (float)VOXELS_PER_CHUNK, 0.0, 0.0), v100);
  EXPECT_EQ(glm::vec3((1.f / (float)VOXELS_PER_CHUNK) * 2, 0.0, 0.0), v200);
}
Beispiel #5
0
BOOST_FIXTURE_TEST_CASE(get_correct_payload, F)
{
  logsvc::prot::ClientHandle ch0(0x1234);
  logsvc::prot::Disconnect disconnect0(ch0);
  BOOST_CHECK_EQUAL(ch0.get_payload(),
                    disconnect0.get_payload());
  logsvc::prot::ClientHandle ch1(0x12345678);
  logsvc::prot::Disconnect disconnect1(ch1);
  BOOST_CHECK_EQUAL(ch1.get_payload(),
                    disconnect1.get_payload());
}
Beispiel #6
0
TEST(ChunkTests, HeightValuesMatchAcrossChunks) {
  const unsigned VOXELS_PER_CHUNK = Units::chunkToVoxel(1);
  DummyChunk ch1(0, 0, 0);
  DummyChunk ch2(1, 0, 0);
  DummyChunk ch3(0, 0, 1);
  
  ch1.generate();
  ch2.generate();
  ch3.generate();
  
  EXPECT_EQ(ch1.heightAt(VOXELS_PER_CHUNK, 0), ch2.heightAt(0, 0));
}
Beispiel #7
0
void setPWM(int channel, int value) //set "channel" in PWM mode with duty = "value"
{
    float duty = ((float) value)/100;
    switch(channel)
    {
        case 0  :  PwmOut ch0(LED1);  ch0 = 1 - duty; ch0.period(pwmPeriod);
                   break;
        case 1  :  PwmOut ch1(LED2);  ch1 = 1 - duty; ch1.period(pwmPeriod);
                   break;
        case 2  :  PwmOut ch2(LED3);  ch2 = 1 - duty; ch2.period(pwmPeriod);
                   break;
        case 3  :  PwmOut ch3(D5);    ch3 = duty;     ch3.period(pwmPeriod);
                   break;
        case 4  :  PwmOut ch4(PTE29); ch4 = duty;     ch4.period(pwmPeriod);
                   break;
        case 5  :  PwmOut ch5(PTE21); ch5 = duty;     ch5.period(pwmPeriod);
                   break;
        //Define more outputs here. No need to change UI code upon addition of outputs
        default :  break;
    }
}
Beispiel #8
0
TEST_F(test_core, transition_NNIS)
{
	// define additional node chains
	NodeChain<M1> ch1(4, 100), ch2(6, 200), ch3(2, 300);

	// define network
	entry. link(ch1[0], pass, atNegative, 1);		// N
	ch1. back(). link(term, digits, atSimple, -1);
	entry. link(ch2[0], pass, atNegative, 2);		// N
	ch2. back(). link(term, letters, atSimple, -2);
	entry. link(ch3[0], pass, atInvoke, 3);			// I
	ch3. back(). link(exit, alpha, atSimple, 4);
	ch3. back(). link(exit, _12345, atSimple, 5);
	ch3. back(). link(exit, pound, atSimple, 6);
	entry. link(exit, pass, atSimple, 7);			// S
	exit. link(term, end, atSimple, 8);

	// test parsing
	EXPECT_EQ( 0,	trace_count(entry, "alpha", 2048) );
	EXPECT_EQ( 0,	trace_count(entry, "12345", 2048) );
	EXPECT_EQ( 1,	trace_count(entry, "#", 2048) );
}
Beispiel #9
0
void switchIO(int channel, int value) //Turn "channel" ON/OFF
{
    int signal = value;
    
    switch(channel)
    {
        case 0  :  DigitalOut ch0(LED1);  ch0 = 1 - signal;
                   break;
        case 1  :  DigitalOut ch1(LED2);  ch1 = 1 - signal;
                   break;
        case 2  :  DigitalOut ch2(LED3);  ch2 = 1 - signal;
                   break;
        case 3  :  DigitalOut ch3(D5);    ch3 = signal;
                   break;
        case 4  :  DigitalOut ch4(PTE29); ch4 = signal;
                   break;
        case 5  :  DigitalOut ch5(PTE21); ch5 = signal;
                   break;
        //Define more outputs here
        default :  break;
    }
}
int testIndividual(){
	Context context = createTestContext();
	Individual Lili;
	Individual Igor(&context, 'C', 3, 40, 2.3, 4, std::tuple<int, int, int>(-1, -1, -1));

	double sumCh = 0.0;
	for(int i = 0; i < 10000; i++){
		sumCh += context.random.poisson(Igor.getLambda());
	}
	sumCh = sumCh / 10000;

	if(sumCh > 2.5 or sumCh < 2.1){
		std::cerr << "WARNING: unexpected behavior of generator of Chiasmas, " << std::endl;
		std::cerr << "Change seed for random number and rerun tests, if this message occurs again"
		<< " something is wrong, please do not ignore it and report the issue." << std::endl;
		return 2;
	}

	// to test all computing functions on semi-known system, one gamete for the tested individual Stuart
	// will be a product of recombination and the second will be pure 'A' gamete. Therefore heterozygocity
	// will be equivalent to proportion of B in the sirt set
	std::vector<Chromosome> gamete1;
	std::vector<Chiasmata> chiasma1, chiasma2;
	Igor.makeGamete(gamete1, chiasma1);

	std::vector<Chromosome> gamete2;
	for(unsigned int i = 0; i < gamete1.size(); i++){
		gamete2.push_back(Chromosome('A',gamete1[i].getResolution()));
		chiasma2.push_back(Chiasmata());
	}
	Individual Stuart(&context, gamete1, chiasma1, gamete2, chiasma2, 1.6, Igor.getNumberOfSelectedLoci(), std::tuple<int, int, int>(-1, -1, -1));

	if(Igor.getSelectedHybridIndex() != 0.5){
		std::cerr << "f1 hybrid has selected hybrid index != 0.5!" << std::endl;
		return 1;
	}

	int count = 0;
	for(int i=0;i<Stuart.getNumberOfChromosomes();i++){
		count += gamete1[i].countB();
		count += gamete2[i].countB();
	}

	if(count != Stuart.getBcount()){
		std::cerr << "Discrepancy between B count of all Chromosomes and Individual \n";
		return 1;
	}

	double total_number_of_loci = (Stuart.getNumberOfChromosomes() * Stuart.getNumberOfLoci(0));
	if((count / (total_number_of_loci * 2)) != Stuart.getBprop()){
		std::cerr << "Discrepancy between B prop of all Chromosomes and Individual \n";
		return 1;
	}

	if((double)count / total_number_of_loci != Stuart.getHetProp()){
		std::cerr << "Manually comuted heterozygocity: "
				<< count << " / " << total_number_of_loci << " = " << (double)count / total_number_of_loci
				<< " !=  heterozygocity from function: " << Stuart.getHetProp() << std::endl;
		return 1;
	}

	if( 0 != Stuart.isPureA()){
		std::cerr << "Error: isPureA have not passed \n";
		return 1;
	}

	if( 0 != Stuart.isPureB()){
		std::cerr << "Warning: isPureB have not passed. Very very unlikely scenario, rerun test. \n";
		return 1;
	}

	// number of junctions independently derived from every chromosome compared to number of juctions derived from the method of individual
	int number_junction = 0;
	for(int i=0;i<Stuart.getNumberOfChromosomes();i++){
		number_junction += gamete1[i].getNumberOfJunctions();
		number_junction += gamete2[i].getNumberOfJunctions();
	}

	if(Stuart.getNumberOfJunctions(0, 0) != gamete1[0].getNumberOfJunctions()){
		std::cerr << "Number of junctions of st chromosome and st haplotype does not match number of junction in first gamete." << std::endl;
		return 1;
	}

	if(Stuart.getNumberOfJunctions() != number_junction){
		std::cerr << "Total number of junctions does not match number of junction in first gamete." << std::endl;
		return 1;
	}

	// neutral loci test 2
	Chromosome ch1('B', 40);
	Chromosome ch2('A', 40);
	ch1.write(13,'A'); ch2.write(14,'B');
	gamete1.clear(); gamete1.push_back(ch1);
	gamete2.clear(); gamete2.push_back(ch2);
	Individual Anna(&context, gamete1, chiasma1, gamete2, chiasma2, 1.6, 4, std::tuple<int, int, int>(-1, -1, -1));
	if(Anna.getSelectedHybridIndex() != 0.375){
		std::cerr << "Folowing individual :" << std::endl;
		Anna.readGenotype();
		std::cerr << "has unexpected selected hybrid index: " << Anna.getSelectedHybridIndex() << std::endl;
		std::cerr << "4 selected loci / chromosome of total 40 loci" << std::endl;
		std::cerr << "means that selected loci have indices 0, 13, 26 and 39" << std::endl;
		std::cerr << "therefore we expected 0.375 given the genotype..." << std::endl;
		return 1;
	}

	return 0;
}
Beispiel #11
0
TEST(ChunkTests, ChunkReturnsCorrectMinVoxelCoords) {
  const unsigned VOXELS_PER_CHUNK = Units::chunkToVoxel(1);
  DummyChunk ch1(3, 3, -3);
  glm::ivec3 minvc = ch1.getMinimumAbsVoxelCoord();
  EXPECT_EQ(glm::ivec3(3 * VOXELS_PER_CHUNK, 3 * VOXELS_PER_CHUNK, -3 * VOXELS_PER_CHUNK), minvc);
}
// ---------------------------------------------------------
// CMailToHandler::HandleUrlEmbeddedL()
// ---------------------------------------------------------
//
void CMailToHandler::HandleUrlEmbeddedL()
	{
	CLOG_ENTERFN( "CMailToHandler::HandleUrlEmbeddedL()" );

    //TPtrC path = iParsedUrl->Des();

	iTelService = CBrowserTelService::NewL();
	iTelService->AddObserver( this );

	TPtrC recipient = GetField( KMailto );
	TPtrC subject = GetField( KSubject );
	TPtrC msgBody = GetField( KBody );
	TPtrC cC = GetField( KCc );
    TPtrC tO = GetField( KTo );
    TPtrC bCC = GetField( KBcc );

    HBufC* rec = ChangeSeparationLC( recipient );
    HBufC* ccrec = ChangeSeparationLC( cC );
    HBufC* torec = ChangeSeparationLC( tO );
    HBufC* bccrec = ChangeSeparationLC( bCC );

    HBufC* allrec = HBufC::NewLC( ccrec->Length() +
                                  torec->Length() +
                                  bccrec->Length() + 3*KComma().Length() );
    if( ccrec->Length() != 0 )
        {
        if( allrec->Length() != 0 )
            {
            allrec->Des().Append( KComma() );
            }
        allrec->Des().Append( ccrec->Des() );
        }
    if( torec->Length() != 0 )
        {
        if( allrec->Length() != 0 )
            {
            allrec->Des().Append( KComma() );
            }
        allrec->Des().Append( torec->Des() );
        }
    if( bccrec->Length() != 0 )
        {
        if( allrec->Length() != 0 )
            {
            allrec->Des().Append( KComma() );
            }
        allrec->Des().Append( bccrec->Des() );
        }

    if( rec->Length() > 0 )
        {
        TChar ch1('?');
        TChar ch2('&');
        TChar recchar((*rec)[ rec->Length() - 1]);
        if( recchar == ch1 )
            {
            rec->Des().SetLength(rec->Length() - 1);
            }
        TChar recchar2((*rec)[ rec->Length() - 1]);
        if( recchar2 == ch2 )
            {
            rec->Des().SetLength(rec->Length() - 1);
            }
        }

    if( allrec->Length() > 0 )
        {
        TChar ch1('?');
        TChar ch2('&');
        TChar allrecchar1( (*allrec)[ allrec->Length() - 1] );
        if( allrecchar1 == ch1 )
            {
            allrec->Des().SetLength(allrec->Length() - 1);
            }
        TChar allrecchar2( (*allrec)[ allrec->Length() - 1] );
        if( allrecchar2 == ch2 )
            {
            allrec->Des().SetLength(allrec->Length() - 1);
            }
        }

 	TRAPD( err, iTelService->SendEmailMessageL( rec->Des(), allrec->Des(), subject, msgBody, ETrue) );

    CleanupStack::PopAndDestroy( 5 ); // rec, ccrec, torec, bccrec, allrec

    NotifyClient();

    ErrorHandlerL( err );

	CLOG_LEAVEFN( "CMailToHandler::HandleUrlEmbeddedL()" );
	}