Example #1
0
void DATFileUpdaterTest::WriteDatFile(const std::string& filename)
{
	DATData data(filename);
	data.SetPixelCount(10);
	data.SetStatsCount(10);
	data.SetPixelSize(.7F);
	data.SetScannerID(L"main");
	data.SetScannerType(L"M10");
	data.SetArrayType(L"Hg-small");
	data.SetRows(4);
	data.SetCols(5);
	DATFileWriter* writer = new DATFileWriter(data);
	u_int16_t s[] = { 16, 22, 14, 39, 26, 36 };
	Uint16Vector stats;
	for(int i = 0; i < 6; i++)
	{
		stats.push_back(s[i]);
	}
	writer->WriteStats(stats);

	u_int16_t p[] = { 36, 3, 7, 8, 11, 2 };
	Uint16Vector pixels;
	for(int i = 0; i < 6; i++)
	{
		pixels.push_back(p[i]);
	}
	writer->WritePixels(pixels);
	delete writer;
}
void DATFileWriterTest::WriteTest()
{
	DATData data("DAT_file");
	data.SetPixelCount(10);
	data.SetStatsCount(10);
	DATFileWriter* writer = new DATFileWriter(data);
	u_int16_t stat1 = 16;
	u_int16_t stat2 = 22;
	Uint16Vector stats;
	stats.push_back(stat1);
	stats.push_back(stat2);
	writer->WriteStats(stats);

	u_int16_t p1 = 36;
	u_int16_t p2 = 3;
	Uint16Vector pixels;
	pixels.push_back(p1);
	pixels.push_back(p2);
	writer->WritePixels(pixels);
	CPPUNIT_ASSERT(1);
	delete writer;
}
Example #3
0
void TestFileGenerator::WriteSmallDatFileWithReservedStringParameters()
{
	int32_t rows = 4;
	int32_t cols = 5;
	int32_t pixelCount = rows*cols;
	DATData data("small_dat_file_with_reserved_string_parameters");
	data.SetPixelCount(pixelCount);
	data.SetStatsCount(1);
	data.SetArrayType(L"Hg_small");
	data.SetPixelSize(0.71f);
	data.SetScannerType(L"M10");
	data.SetScannerID(L"main");
	DateTime dt = DateTime::Parse(L"2005-12-25T11:12:13Z");
	data.SetScanDate(dt);
	data.SetRows(rows);
	data.SetCols(cols);
	std::string arrayId = "smellsliketeenspirit";
	data.SetArrayId(arrayId);
	
	ParameterNameValueType nvt;
	nvt.SetName(L"fixedlen");
	nvt.SetValueText(L"twenty-five", 25);
	data.GetFileHeader()->GetGenericDataHdr()->AddNameValParam(nvt);

	DATFileWriter writer(data);

	Uint16Vector pixels;
	pixels.reserve(pixelCount);

	u_int16_t inten = 10;
	for (int32_t i=0; i<pixelCount; ++i, ++inten)
	{
		if (inten > 46000)
		{
			inten = 0;
		}
		pixels.push_back(inten);
	}

	Uint16Vector stats;
	stats.push_back(pixels[0]);	// min
	stats.push_back(pixels[19]);	// max

	writer.WriteStats(stats);
	writer.WritePixels(pixels);
}
Example #4
0
void TestFileGenerator::WriteDatFile(const std::string& name, const std::wstring& type, int32_t rows, int32_t cols, bool showProgress)
{
	cout << "Started writing " << name.c_str() << endl;

	int32_t pixelCount = rows*cols;
	DATData data(name);
	data.SetPixelCount(pixelCount);
	data.SetStatsCount(1);
	data.SetArrayType(type);
	data.SetPixelSize(0.71f);
	data.SetScannerType(L"M10");
	data.SetScannerID(L"main");
	DateTime dt = DateTime::Parse(L"2005-12-25T11:12:13Z");
	data.SetScanDate(dt);
	data.SetRows(rows);
	data.SetCols(cols);
	DATFileWriter writer(data);

	Uint16Vector pixels;
	pixels.reserve(pixelCount);

	u_int16_t inten = 10;
	for (int32_t i=0; i<pixelCount; ++i, ++inten)
	{
		if (inten > 46000)
		{
			inten = 0;
			if (showProgress)
				cout << "Written " << i << " pixels so far..." << endl;
		}
		pixels.push_back(inten);
	}

	Uint16Vector stats;
	stats.push_back(pixels[0]);	// min
	stats.push_back(pixels[19]);	// max

	writer.WriteStats(stats);
	writer.WritePixels(pixels);

	cout << "Completed writing " << name.c_str() << endl;
}