// Copy samples from archive with index_name // to new index copy_name. // Uses all samples in source archive or [start ... end[ . void copy(const stdString &index_name, const stdString ©_name, int RTreeM, const epicsTime *start, const epicsTime *end, const stdString &single_name) { IndexFile index(RTreeM), new_index(RTreeM); IndexFile::NameIterator names; size_t channel_count = 0, value_count = 0, back_count = 0; BenchTimer timer; stdString dir1, dir2; Filename::getDirname(index_name, dir1); Filename::getDirname(copy_name, dir2); if (dir1 == dir2) { printf("You have to assert that the new index (%s)\n" "is in a directory different from the old index\n" "(%s)\n", copy_name.c_str(), index_name.c_str()); return; } index.open(index_name, true); new_index.open(copy_name, false); if (verbose) printf("Copying values from '%s' to '%s'\n", index_name.c_str(), copy_name.c_str()); RawDataReader reader(index); if (single_name.empty()) { bool ok = index.getFirstChannel(names); while (ok) { copy_channel(names.getName(), start, end, index, reader, new_index, channel_count, value_count, back_count); ok = index.getNextChannel(names); } } else copy_channel(single_name, start, end, index, reader, new_index, channel_count, value_count, back_count); new_index.close(); index.close(); timer.stop(); if (verbose) { printf("Total: %lu channels, %lu values\n", (unsigned long) channel_count, (unsigned long) value_count); printf("Skipped %lu back-in-time values\n", (unsigned long) back_count); printf("Runtime: %s\n", timer.toString().c_str()); } }
void copy_channels_node_t::do_process( const render::context_t& context) { Imath::Box2i src1_area( ImathExt::intersect( input_as<image_node_t>(0)->defined(), defined())); image::const_image_view_t src1( input_as<image_node_t>(0)->const_subimage_view( src1_area)); Imath::Box2i src2_area( ImathExt::intersect( input_as<image_node_t>(1)->defined(), defined())); image::const_image_view_t src2( input_as<image_node_t>(1)->const_subimage_view( src2_area)); image::image_view_t dst1( subimage_view( src1_area)); image::image_view_t dst2( subimage_view( src2_area)); int ch = get_value<int>( param( "red")); if( ch == copy_source) copy_channel( src1, 0, dst1, 0); else copy_channel( src2, ch-1, dst2, 0); ch = get_value<int>( param( "green")); if( ch == copy_source) copy_channel( src1, 1, dst1, 1); else copy_channel( src2, ch-1, dst2, 1); ch = get_value<int>( param( "blue")); if( ch == copy_source) copy_channel( src1, 2, dst1, 2); else copy_channel( src2, ch-1, dst2, 2); ch = get_value<int>( param( "alpha")); switch( ch) { case copy_source: copy_channel( src1, 3, dst1, 3); break; case set_one: case set_zero: { Imath::Box2i area( ImathExt::intersect( defined(), format())); copy_channel( src1, ch-1, subimage_view( area), 3); } break; default: copy_channel( src2, ch-1, dst2, 3); } }