void software_sensor::on_pose_frame(rs2_software_pose_frame software_frame) { if (!_is_streaming) return; frame_additional_data data; data.timestamp = software_frame.timestamp; data.timestamp_domain = software_frame.domain; data.frame_number = software_frame.frame_number; data.metadata_size = 0; for (auto i : _metadata_map) { auto size_of_enum = sizeof(rs2_frame_metadata_value); auto size_of_data = sizeof(rs2_metadata_type); memcpy(data.metadata_blob.data() + data.metadata_size, &i.first, size_of_enum); data.metadata_size += static_cast<uint32_t>(size_of_enum); memcpy(data.metadata_blob.data() + data.metadata_size, &i.second, size_of_data); data.metadata_size += static_cast<uint32_t>(size_of_data); } auto frame = _source.alloc_frame(RS2_EXTENSION_POSE_FRAME, 0, data, false); if (!frame) { LOG_WARNING("Dropped pose frame. alloc_frame(...) returned nullptr"); return; } frame->set_stream(std::dynamic_pointer_cast<stream_profile_interface>(software_frame.profile->profile->shared_from_this())); frame->attach_continuation(frame_continuation{ [=]() { software_frame.deleter(software_frame.data); }, software_frame.data }); _source.invoke_callback(frame); }
void putv_tnc (int c) //************************************************************************** // // //************************************************************************** { int port = t->port; static unsigned int bytes = 0; #ifdef _AX25K if (t->processkind & P_AX25K) { ax25k_putv(c); return; } #endif wasput[port] = 1; if (l2vorhanden) { if (! txfbuf[port]) { while (! putfree_tnc()) wdelay(268); txfbuf[port] = 900; } if (! (bytes & 2047)) while (freeblocks_tnc () < 20) wdelay(367); else bytes = 0; set_stream(port); tnc_put(c); txfbuf[port]--; bytes++; } }
void putbeacon_tnc (char *adressfeld, char *bakentext) //************************************************************************** // // //************************************************************************** { if (l2vorhanden) { #ifdef _AX25K CRegEx reg; if (ax25k_isdefault() || reg.regex_match("ax.*:", adressfeld)) { for (unsigned int i = 0; bakentext[i]; i++) if (bakentext[i] == LF) bakentext[i] = CR; ax25k_putbeacon(adressfeld, bakentext); return; } #endif set_stream(0); tnc_connect(NULL, adressfeld); for (unsigned int i = 0; bakentext[i]; i++) { if (bakentext[i] == LF) bakentext[i] = CR; tnc_put(bakentext[i]); } tnc_flush(); } }
frame_interface* synthetic_source::allocate_composite_frame(std::vector<frame_holder> holders) { frame_additional_data d {}; auto req_size = 0; for (auto&& f : holders) req_size += get_embeded_frames_size(f.frame); auto res = _actual_source.alloc_frame(RS2_EXTENSION_COMPOSITE_FRAME, req_size * sizeof(rs2_frame*), d, true); if (!res) return nullptr; auto cf = static_cast<composite_frame*>(res); auto frames = cf->get_frames(); for (auto&& f : holders) copy_frames(std::move(f), frames); frames -= req_size; auto releaser = [frames, req_size]() { for (auto i = 0; i < req_size; i++) { frames[i]->release(); frames[i] = nullptr; } }; frame_continuation release_frames(releaser, nullptr); cf->attach_continuation(std::move(release_frames)); cf->set_stream(cf->first()->get_stream()); return res; }
void software_sensor::on_video_frame(rs2_software_video_frame software_frame) { frame_additional_data data; data.timestamp = software_frame.timestamp; data.timestamp_domain = software_frame.domain; data.frame_number = software_frame.frame_number; rs2_extension extension = software_frame.profile->profile->get_stream_type() == RS2_STREAM_DEPTH ? RS2_EXTENSION_DEPTH_FRAME : RS2_EXTENSION_VIDEO_FRAME; auto frame = _source.alloc_frame(extension, 0, data, false); if (!frame) { return; } auto vid_profile = dynamic_cast<video_stream_profile_interface*>(software_frame.profile->profile); auto vid_frame = dynamic_cast<video_frame*>(frame); vid_frame->assign(vid_profile->get_width(), vid_profile->get_height(), software_frame.stride, software_frame.bpp * 8); frame->set_stream(std::dynamic_pointer_cast<stream_profile_interface>(software_frame.profile->profile->shared_from_this())); frame->attach_continuation(frame_continuation{ [=]() { software_frame.deleter(software_frame.pixels); }, software_frame.pixels }); _source.invoke_callback(frame); }
void drive(opcode* stream, int size, int start = 0) { set_stream(stream, size); int ip = start; while(ip < size) { ip = dispatch(ip); } }
void GDLWXStream::Init() { this->plstream::init(); set_stream(); // private // plgpls( &thePls); // in GDLGStream }
static void near openport_tnc (int port) //************************************************************************** // // //************************************************************************** { set_stream(port); set_conok(1); }
static void near discport_tnc (int port) //************************************************************************** // // //************************************************************************** { set_stream(port); tnc_disconnect(2); }
static void near closeport_tnc (int port) //************************************************************************** // // //************************************************************************** { set_stream(port); set_conok(0); }
static int near linkstate_tnc (int port) //************************************************************************** // // //************************************************************************** { set_stream(port); return get_lstate(); }
int putfree_tnc (void) //************************************************************************** // // //************************************************************************** { #ifdef _AX25K if (t->processkind & P_AX25K) return ax25k_putfree(); #endif set_stream(t->port); return tnc_putfree(); }
static void near connport_tnc (int port, char *mycall, char *conncall) //************************************************************************** // // //************************************************************************** { set_stream(port); if (mycall) tnc_connect(mycall, conncall); else tnc_connect(NULL, conncall); }
void set_paclen_tnc (unsigned short paclen) //************************************************************************** // // //************************************************************************** { if (l2vorhanden) { set_stream(t->port); set_paclen(paclen); } }
static int near holtnc (void) //************************************************************************** // // //************************************************************************** { if (l2vorhanden) { set_stream(t->port); return tnc_get(); } else { wdelay(341); return CR; } }
void putflush_tnc (void) //************************************************************************** // // //************************************************************************** { b->pacbytes = 0; #ifdef _AX25K if (t->processkind & P_AX25K) { ax25k_flush(); return; } #endif set_stream(t->port); tnc_flush(); }
void software_sensor::on_video_frame(rs2_software_video_frame software_frame) { if (!_is_streaming) return; frame_additional_data data; data.timestamp = software_frame.timestamp; data.timestamp_domain = software_frame.domain; data.frame_number = software_frame.frame_number; data.metadata_size = 0; for (auto i : _metadata_map) { auto size_of_enum = sizeof(rs2_frame_metadata_value); auto size_of_data = sizeof(rs2_metadata_type); if (data.metadata_size + size_of_enum + size_of_data > 255) { continue; //stop adding metadata to frame } memcpy(data.metadata_blob.data() + data.metadata_size, &i.first, size_of_enum); data.metadata_size += static_cast<uint32_t>(size_of_enum); memcpy(data.metadata_blob.data() + data.metadata_size, &i.second, size_of_data); data.metadata_size += static_cast<uint32_t>(size_of_data); } rs2_extension extension = software_frame.profile->profile->get_stream_type() == RS2_STREAM_DEPTH ? RS2_EXTENSION_DEPTH_FRAME : RS2_EXTENSION_VIDEO_FRAME; auto frame = _source.alloc_frame(extension, 0, data, false); if (!frame) { LOG_WARNING("Dropped video frame. alloc_frame(...) returned nullptr"); return; } auto vid_profile = dynamic_cast<video_stream_profile_interface*>(software_frame.profile->profile); auto vid_frame = dynamic_cast<video_frame*>(frame); vid_frame->assign(vid_profile->get_width(), vid_profile->get_height(), software_frame.stride, software_frame.bpp * 8); frame->set_stream(std::dynamic_pointer_cast<stream_profile_interface>(software_frame.profile->profile->shared_from_this())); frame->attach_continuation(frame_continuation{ [=]() { software_frame.deleter(software_frame.pixels); }, software_frame.pixels }); auto sd = dynamic_cast<software_device*>(_owner); sd->register_extrinsic(*vid_profile, _unique_id); _source.invoke_callback(frame); }
frame_interface* synthetic_source::allocate_points(std::shared_ptr<stream_profile_interface> stream, frame_interface* original) { auto vid_stream = dynamic_cast<video_stream_profile_interface*>(stream.get()); if (vid_stream) { frame_additional_data data{}; data.frame_number = original->get_frame_number(); data.timestamp = original->get_frame_timestamp(); data.timestamp_domain = original->get_frame_timestamp_domain(); data.metadata_size = 0; data.system_time = _actual_source.get_time(); auto res = _actual_source.alloc_frame(RS2_EXTENSION_POINTS, vid_stream->get_width() * vid_stream->get_height() * sizeof(float) * 5, data, true); if (!res) throw wrong_api_call_sequence_exception("Out of frame resources!"); res->set_sensor(original->get_sensor()); res->set_stream(stream); return res; } return nullptr; }
void getmycall_tnc (char *outcall) //************************************************************************** // // //************************************************************************** { if (l2vorhanden) { #ifdef _AX25K if (t->processkind & P_AX25K) { ax25k_getmycall(outcall); return; } #endif set_stream(t->port); char *mycall = get_mycall(); if (mycall) strcpy(outcall, mycall); } else *outcall = 0; }
static void near linkcall_tnc (int port, char *buf) //************************************************************************** // // //************************************************************************** { char callbuf[80]; unsigned int i = 0; set_stream(port); strcpy(callbuf, get_concall()); strupr(callbuf); while (callbuf[i] > ' ') *buf++ = callbuf[i++]; *buf = 0; if (! callbuf[i]) return; i = strlen (callbuf); while (i && callbuf[i - 1] > ' ') i--; if (i) { *buf++ = ' '; while (callbuf[i] > ' ') *buf++ = callbuf[i++]; *buf = 0; } }
void set_stream(VMMethod* vmm) { set_stream(vmm->opcodes, vmm->total); }
/** @brief clears the stream. Further output will be ignored */ void clear() { set_stream(nullptr); }
frame_interface* synthetic_source::allocate_video_frame(std::shared_ptr<stream_profile_interface> stream, frame_interface* original, int new_bpp, int new_width, int new_height, int new_stride, rs2_extension frame_type) { video_frame* vf = nullptr; if (new_bpp == 0 || (new_width == 0 && new_stride == 0) || new_height == 0) { // If the user wants to delegate width, height and etc to original frame, it must be a video frame if (!rs2_is_frame_extendable_to((rs2_frame*)original, RS2_EXTENSION_VIDEO_FRAME, nullptr)) { throw std::runtime_error("If original frame is not video frame, you must specify new bpp, width/stide and height!"); } vf = static_cast<video_frame*>(original); } frame_additional_data data{}; data.frame_number = original->get_frame_number(); data.timestamp = original->get_frame_timestamp(); data.timestamp_domain = original->get_frame_timestamp_domain(); data.metadata_size = 0; data.system_time = _actual_source.get_time(); auto width = new_width; auto height = new_height; auto bpp = new_bpp * 8; auto stride = new_stride; if (bpp == 0) { bpp = vf->get_bpp(); } if (width == 0 && stride == 0) { width = vf->get_width(); stride = width * bpp / 8; } else if (width == 0) { width = stride * 8 / bpp; } else if (stride == 0) { stride = width * bpp / 8; } if (height == 0) { height = vf->get_height(); } auto res = _actual_source.alloc_frame(frame_type, stride * height, data, true); if (!res) throw wrong_api_call_sequence_exception("Out of frame resources!"); vf = static_cast<video_frame*>(res); vf->assign(width, height, stride, bpp); vf->set_sensor(original->get_sensor()); res->set_stream(stream); if (frame_type == RS2_EXTENSION_DEPTH_FRAME) { original->acquire(); (dynamic_cast<depth_frame*>(res))->set_original(original); } return res; }
bg_nle_file_handle_t * bg_nle_file_cache_load(bg_nle_file_cache_t * c, bg_nle_id_t id, bg_nle_track_type_t type, int stream) { const bg_plugin_info_t * info; bg_nle_file_handle_t * exact = NULL; bg_nle_file_handle_t * inexact = NULL; bg_nle_file_handle_t * h = c->cache; int i; /* 1. Try to find an open file */ while(h) { if(h->file->id == id) { inexact = h; if((h->type == type) && (h->stream == stream)) { exact = h; break; } } h = h->next; } if(exact) { c->cache = remove_from_list(c->cache, exact); c->cache_size--; return exact; } else if(inexact && inexact->plugin->set_track) { c->cache = remove_from_list(c->cache, inexact); c->cache_size--; inexact->plugin->set_track(inexact->h->priv, inexact->file->track); set_stream(inexact, type, stream); return inexact; } /* Find the file in the media list */ h = calloc(1, sizeof(*h)); for(i = 0; i < c->p->media_list->num_files; i++) { if(c->p->media_list->files[i]->id == id) h->file = c->p->media_list->files[i]; } if(!h->file) { free(h); return NULL; } info = bg_plugin_find_by_name(c->p->plugin_reg, h->file->plugin); h->h = bg_plugin_load(c->p->plugin_reg, info); h->plugin = (bg_input_plugin_t*)h->h->plugin; if(h->file->section && h->h->info->parameters) { bg_cfg_section_apply(h->file->section, h->h->info->parameters, h->plugin->common.set_parameter, h->h->priv); } if(!h->plugin->open(h->h->priv, h->file->filename)) goto fail; if(h->plugin->set_track) h->plugin->set_track(h->h->priv, h->file->track); h->ti = h->plugin->get_track_info(h->h->priv, h->file->track); set_stream(h, type, stream); return h; fail: free(h); return NULL; }
int main(int argc, char *argv[]) { Parameters *parameters; // user defined parameters Geometry *geometry; // homogenous cube geometry Material *material; // problem material Bank *source_bank; // array for particle source sites Bank *fission_bank; // array for particle fission sites Tally *tally; // scalar flux tally double *keff; // effective multiplication factor double t1, t2; // timers // Get inputs: set parameters to default values, parse parameter file, // override with any command line inputs, and print parameters parameters = init_parameters(); parse_parameters(parameters); read_CLI(argc, argv, parameters); print_parameters(parameters); // Set initial RNG seed set_initial_seed(parameters->seed); set_stream(STREAM_OTHER); // Create files for writing results to init_output(parameters); // Set up geometry geometry = init_geometry(parameters); // Set up material material = init_material(parameters); // Set up tallies tally = init_tally(parameters); // Create source bank and initial source distribution source_bank = init_source_bank(parameters, geometry); // Create fission bank fission_bank = init_fission_bank(parameters); // Set up array for k effective keff = calloc(parameters->n_active, sizeof(double)); center_print("SIMULATION", 79); border_print(); printf("%-15s %-15s %-15s %-15s\n", "BATCH", "ENTROPY", "KEFF", "MEAN KEFF"); // Start time t1 = timer(); run_eigenvalue(parameters, geometry, material, source_bank, fission_bank, tally, keff); // Stop time t2 = timer(); printf("Simulation time: %f secs\n", t2-t1); // Free memory free(keff); free_tally(tally); free_bank(fission_bank); free_bank(source_bank); free_material(material); free(geometry); free(parameters); return 0; }
void Tag61::actual_read(const std::string & data, std::string::size_type & pos, const std::string::size_type & length) { set_stream(data.substr(pos, length)); pos += length; }
int main(int argc, char *argv[]) { Parameters *parameters; // user defined parameters Geometry *geometry; // homogenous cube geometry Material *material; // problem material Bank *source_bank; // array for particle source sites Tally *tally; // scalar flux tally double *keff; // effective multiplication factor double t1, t2; // timers #ifdef _OPENMP unsigned long counter = 0; //counter to decide the start pos of master bank copy from sub banks Bank *g_fission_bank; //global fission bank #endif // Get inputs: set parameters to default values, parse parameter file, // override with any command line inputs, and print parameters parameters = init_parameters(); parse_parameters(parameters); read_CLI(argc, argv, parameters); print_parameters(parameters); // Set initial RNG seed set_initial_seed(parameters->seed); set_stream(STREAM_INIT); // Create files for writing results to init_output(parameters); // Set up geometry geometry = init_geometry(parameters); // Set up material material = init_material(parameters); // Set up tallies tally = init_tally(parameters); // Create source bank and initial source distribution source_bank = init_source_bank(parameters, geometry); // Create fission bank #ifdef _OPENMP omp_set_num_threads(parameters->n_threads); // Set number of openmp threads printf("threads num: %d\n", parameters->n_threads); // Allocate one master fission bank g_fission_bank = init_bank(2*parameters->n_particles); #endif // Set up array for k effective keff = calloc(parameters->n_active, sizeof(double)); center_print("SIMULATION", 79); border_print(); printf("%-15s %-15s %-15s\n", "BATCH", "KEFF", "MEAN KEFF"); #ifdef _OPENMP // Start time t1 = omp_get_wtime(); run_eigenvalue(counter, g_fission_bank, parameters, geometry, material, source_bank, fission_bank, tally, keff); // Stop time t2 = omp_get_wtime(); #endif printf("Simulation time: %f secs\n", t2-t1); // Free memory #ifdef _OPENMP free_bank(g_fission_bank); #endif free(keff); free_tally(tally); free_bank(source_bank); free_material(material); free(geometry); free(parameters); return 0; }