Example #1
0
int test_store_restore(TestData* testdata){
	MotionDetect md;
	test_bool(initMotionDetect(&md, &testdata->fi, "test") == VS_OK);
	test_bool(configureMotionDetect(&md)== VS_OK);

	LocalMotions lms;
	int i;
	for(i=0; i<2; i++){
		test_bool(motionDetection(&md, &lms,&testdata->frames[i])== VS_OK);
		if (i==0) vs_vector_del(&lms);
	}

	FILE* f = fopen("lmtest","w");
	storeLocalmotions(f,&lms);
	fclose(f);
	f = fopen("lmtest","r");
	LocalMotions test = restoreLocalmotions(f);
	fclose(f);
	storeLocalmotions(stderr,&test);
	compare_localmotions(&lms,&test);
	fprintf(stderr,"\n** LM and LMS OKAY\n");

	f = fopen("lmstest","w");
	md.frameNum=1;
	prepareFile(&md,f);
	writeToFile(&md,f,&lms);
	md.frameNum=2;
	writeToFile(&md,f,&test);
	fclose(f);

	f = fopen("lmstest","r");
	test_bool(readFileVersion(f)==1);
	LocalMotions read1;
	test_bool(readFromFile(f,&read1)==1);
	compare_localmotions(&lms,&read1);
	LocalMotions read2;
	test_bool(readFromFile(f,&read2)==2);
	compare_localmotions(&test,&read2);
	fclose(f);
	fprintf(stderr,"** Reading file stepwise OKAY\n");
	vs_vector_del(&read1);
	vs_vector_del(&read2);
	vs_vector_del(&test);
	vs_vector_del(&lms);

	f = fopen("lmstest","r");
	ManyLocalMotions mlms;
	test_bool(readLocalMotionsFile(f,&mlms)==VS_OK);
	test_bool(vs_vector_size(&mlms)==2);
	fprintf(stderr,"** Entire file routine OKAY\n\n");

	for(i=0; i< vs_vector_size(&mlms); i++){
		if(MLMGet(&mlms,i))
			vs_vector_del(MLMGet(&mlms,i));
	}
	vs_vector_del(&mlms);

	return 1;
}
Example #2
0
bool CxFlowParse::setFileName(const string &strFileName)
{
	m_strFileName = strFileName;
	m_xMainNode = XMLNode::openFileHelper(m_strFileName.c_str(), "Knowledge");
	if (m_xMainNode.isEmpty())
		return false;
	m_knowlegdeDescription.m_strFileName = strFileName;
	m_knowlegdeDescription.m_strName = m_xMainNode.getAttribute("name");
	m_knowlegdeDescription.m_strID = m_xMainNode.getAttribute("id");
	m_knowlegdeDescription.m_strDescription = m_xMainNode.getAttribute("description");
	m_knowlegdeDescription.m_strVersion = m_xMainNode.getAttribute("version");
	m_knowlegdeDescription.m_strPixFilename = m_xMainNode.getAttribute("pixfilename");
	readFileVersion(m_knowlegdeDescription.m_strFileVersion);
	
	return true;
}