void GuiApp::run() { commander().registerAllCommandsForTarget (JUCEApplication::getInstance()); commander().registerAllCommandsForTarget (this); globals().session().open(); sessionDoc = new SessionDocument (globals().session()); content = new ContentComponent (*this); content->setSize (800, 600); mainWindow = new MainWindow (*this); mainWindow->setContentNonOwned (content.get(), true); PropertiesFile* pf = globals().settings().getUserSettings(); mainWindow->restoreWindowStateFromString (pf->getValue ("mainWindowState")); #if JUCE_IOS || JUCE_ANDROID Desktop& d = Desktop::getInstance(); d.setKioskModeComponent (mainWindow); #endif mainWindow->addToDesktop(); mainWindow->setVisible (true); dispatch->startTimer (250); openWindow (ELEMENT_PLUGIN_MANAGER); File sess (pf->getValue ("lastSession")); if (sess.existsAsFile()) { sessionDoc->loadFrom (sess, true); mainWindow->setName (sessionDoc->getDocumentTitle()); } }
StatisticsCollection load(const std::string& filename, std::vector<AntennaInfo>& antennae) { bool remote = aoRemote::ClusteredObservation::IsClusteredFilename(filename); StatisticsCollection statisticsCollection; HistogramCollection histogramCollection; if(remote) { std::unique_ptr<aoRemote::ClusteredObservation> observation = aoRemote::ClusteredObservation::Load(filename); aoRemote::ProcessCommander commander(*observation); commander.PushReadAntennaTablesTask(); commander.PushReadQualityTablesTask(&statisticsCollection, &histogramCollection); commander.Run(); antennae = commander.Antennas(); } else { MeasurementSet ms(filename); const unsigned polarizationCount = ms.PolarizationCount(); statisticsCollection.SetPolarizationCount(polarizationCount); QualityTablesFormatter qualityData(filename); statisticsCollection.Load(qualityData); unsigned antennaCount = ms.AntennaCount(); for(unsigned a=0;a<antennaCount;++a) antennae.push_back(ms.GetAntennaInfo(a)); } return statisticsCollection; }
void utils_send_cmd(const char *command, PASSWORD_ID enc_id) { if (enc_id == PASSWORD_NONE) { utils_decrypt_report(commander(command)); } else { int encrypt_len; char *enc = aes_cbc_b64_encrypt((const unsigned char *)command, strlens(command), &encrypt_len, enc_id); char cmd[COMMANDER_REPORT_SIZE] = {0}; assert(encrypt_len < COMMANDER_REPORT_SIZE); memcpy(cmd, enc, encrypt_len); free(enc); utils_decrypt_report(commander(cmd)); } }
void openGalaxy::exit() { syslog().info("Quit signal received"); // Unlock m_quit so everybody knows it is time to exit m_mutex.lock(); m_quit = true; m_mutex.unlock(); // Notify the worker threads and wait until they exit try { poll().notify(); poll().join(); } catch(...) { m_Poll_exptr = std::current_exception(); } try { receiver().notify(); receiver().join(); } catch(...) { m_Receiver_exptr = std::current_exception(); } try { commander().notify(); commander().join(); } catch(...) { m_Commander_exptr = std::current_exception(); } try { output().notify(); output().join(); } catch(...) { m_Output_exptr = std::current_exception(); } // notify our wait() method m_lock_cv.notify_one(); }
void actionSummarize(const std::string &filename) { bool remote = aoRemote::ClusteredObservation::IsClusteredFilename(filename); StatisticsCollection statisticsCollection; HistogramCollection histogramCollection; if(remote) { aoRemote::ClusteredObservation *observation = aoRemote::ClusteredObservation::Load(filename); aoRemote::ProcessCommander commander(*observation); commander.PushReadQualityTablesTask(&statisticsCollection, &histogramCollection); commander.Run(); delete observation; } else { MeasurementSet *ms = new MeasurementSet(filename); const unsigned polarizationCount = ms->PolarizationCount(); delete ms; statisticsCollection.SetPolarizationCount(polarizationCount); QualityTablesFormatter qualityData(filename); statisticsCollection.Load(qualityData); } DefaultStatistics statistics(statisticsCollection.PolarizationCount()); statisticsCollection.GetGlobalTimeStatistics(statistics); std::cout << "Time statistics: \n"; printStatistics(statistics); statisticsCollection.GetGlobalFrequencyStatistics(statistics); std::cout << "\nFrequency statistics: \n"; printStatistics(statistics); statisticsCollection.GetGlobalCrossBaselineStatistics(statistics); std::cout << "\nCross-correlated baseline statistics: \n"; printStatistics(statistics); DefaultStatistics singlePolStat = statistics.ToSinglePolarization(); std::cout << "RFIPercentange: " << StatisticsDerivator::GetStatisticAmplitude(QualityTablesFormatter::RFIPercentageStatistic, singlePolStat, 0) << '\n'; statisticsCollection.GetGlobalAutoBaselineStatistics(statistics); std::cout << "\nAuto-correlated baseline: \n"; printStatistics(statistics); }
static void main_menu_select(void *cookie, int key) { if (key > 0) commander(key); }
void g1_human_class::think() { i4_bool process_input = i4_T; if (playback_think()) { process_input=i4_F; } g1_player_piece_class * stank = commander(); if ((g1_current_controller->view.get_view_mode()!=G1_ACTION_MODE && g1_current_controller->view.get_view_mode()!=G1_FOLLOW_MODE)) { process_input=i4_F; } if (!process_input) //are we controlling the stank? { g1_input.deque_time(g1_input_class::LEFT); g1_input.deque_time(g1_input_class::RIGHT); g1_input.deque_time(g1_input_class::UP); g1_input.deque_time(g1_input_class::DOWN); g1_input.deque_time(g1_input_class::STRAFE_LEFT); g1_input.deque_time(g1_input_class::STRAFE_RIGHT); g1_input.deque_time(g1_input_class::STRAFE_UP); g1_input.deque_time(g1_input_class::STRAFE_DOWN); g1_input.deque_time(g1_input_class::ZOOM_IN); g1_input.deque_time(g1_input_class::ZOOM_OUT); g1_input.deque_time(g1_input_class::ZOOM_LEFT); g1_input.deque_time(g1_input_class::ZOOM_RIGHT); g1_input.deque_time(g1_input_class::ZOOM_UP); g1_input.deque_time(g1_input_class::ZOOM_DOWN); // if (g1_current_controller->view.get_view_mode()==G1_STRATEGY_MODE) // { // g1_resources.startegy_camera_dist+=(strategy_up-strategy_down)*G1_HZ/1000.0f; // if (g1_resources.startegy_camera_dist<=0.1f) g1_resources.startegy_camera_dist=0.1f; // g1_resources.startegy_camera_angle+=(strategy_out-strategy_in)*G1_HZ/1000.0f; // if (g1_resources.startegy_camera_angle<=0.1f) g1_resources.startegy_camera_angle=0.1f; // } } else { //keys are buffered in the order pressed, so do a reversed comparison if (memcmp(g1_input.grab_cheat_keys(),"DOG",3)==0) { g1_input.clear_cheat_keys(); if (stank) { stank->toggle_stank_flag(g1_player_piece_class::ST_GODMODE); } } //This would actually belong the receive_event() function of //the border frame class, but it needs to be executed regardless //of wheter an event is outstanding. if (g1_border.get()) { i4_float heh; i4_float cx=g1_border->last_mouse_x(); i4_float lx=g1_border->prev_mouse_x(); i4_float cy=g1_border->last_mouse_y(); i4_float ly=g1_border->prev_mouse_y(); if (cy<7) { heh=-0.2f; } else if (cy>(g1_border->height()-7)) { heh=0.2f; } else { heh = ((cy - ly)*0.01f); } mouse_look_increment_y += heh; //if (mev->x<5) // heh=-1.0f; //else if (mev->x>(width()-5)) // heh=1.0f; //else //if (mev->x>20&&mev->x<(width()-20)) // heh = (((sw32)mev->x - (sw32)mev->lx)*0.01f); //else // heh=0; if (cx<20) { heh=-0.1f; } else if (cx>(g1_border->width()-20)) { heh=0.1f; } else { heh = ((cx - lx)*0.01f); } mouse_look_increment_x += heh; g1_border->clear_mouse_move(); } g1_map_piece_class * whofor=controlled(); sw32 left_ms=g1_input.deque_time(g1_input_class::LEFT), right_ms=g1_input.deque_time(g1_input_class::RIGHT), up_ms=g1_input.deque_time(g1_input_class::UP), down_ms=g1_input.deque_time(g1_input_class::DOWN), sleft_ms=g1_input.deque_time(g1_input_class::STRAFE_LEFT), sright_ms=g1_input.deque_time(g1_input_class::STRAFE_RIGHT); sw32 sup_ms=g1_input.deque_time(g1_input_class::STRAFE_UP); sw32 sdown_ms=g1_input.deque_time(g1_input_class::STRAFE_DOWN); sw32 zoom_in=g1_input.deque_time(g1_input_class::ZOOM_IN), zoom_out=g1_input.deque_time(g1_input_class::ZOOM_OUT), zoom_left=g1_input.deque_time(g1_input_class::ZOOM_LEFT), zoom_right=g1_input.deque_time(g1_input_class::ZOOM_RIGHT), zoom_up=g1_input.deque_time(g1_input_class::ZOOM_UP), zoom_down=g1_input.deque_time(g1_input_class::ZOOM_DOWN); look(mouse_look_increment_x, mouse_look_increment_y,whofor); mouse_look_increment_y = mouse_look_increment_x = 0; turn( g1_resources.player_turn_speed*(left_ms-right_ms)*G1_HZ/1000.0f, whofor ); accelerate( (up_ms-down_ms)*G1_HZ/1000.0f,whofor); strafe( (sright_ms-sleft_ms)*G1_HZ/1000.0f, (sup_ms-sdown_ms)*G1_HZ/1000.0f,whofor); if (g1_current_controller->view.get_view_mode()==G1_FOLLOW_MODE) { g1_resources.follow_camera_dist+=(zoom_out-zoom_in)*G1_HZ/1000.0f; if (g1_resources.follow_camera_dist<=0.5f) { g1_resources.follow_camera_dist=0.5f; } g1_resources.follow_camera_height+=(zoom_up-zoom_down)*G1_HZ/1000.0f; g1_resources.follow_camera_rotation+=(zoom_right-zoom_left)*G1_HZ/1000.0f; } //if (sright_ms>0) // sright_ms=sright_ms+1; if (g1_input.button_1()) { fire0(whofor); } if (g1_input.button_2()) { fire1(whofor); } if (g1_input.button_3()) { fire2(whofor); } } if (g1_input.key_pressed) { continue_game(); } g1_input.key_pressed=i4_F; }
//for most cases, this takes world coordinates, but not always!!! void g1_human_class::player_clicked(g1_object_class * obj, float gx, float gy,w32 command) { g1_object_type convoy_type=g1_get_object_type(li_convoy.get()); switch (command) { case DEFAULT: { if (obj && obj->player_num==team() && obj->get_flag(g1_object_class::SELECTABLE)) { clear_selected(); if (obj == commander()) { selected_object = 0; } else { g1_convoy_class * c=(g1_convoy_class *)g1_object_type_array[convoy_type]->create_object(convoy_type,0); c->setup(obj); c->player_num=team(); selected_object=c; selected_object->mark_as_selected(); } } else if (selected_object.valid()) { send_selected_units(gx,gy); } else { select_path(gx,gy); } } break; case ATTACK: { if (selected_object.valid()&&selected_object->player_num==team()) { attack_unit(obj,gx,gy); } //remember: this only works if //target is in range break; } case GOTO: if (selected_object.valid()&&selected_object->player_num==team()) { send_selected_units(gx,gy); } break; case SELECT: { //single objects can be selected, even if they don't //belong to the local user if (!obj/*||obj->player_num!=team() ||!obj->get_flag(g1_object_class::SELECTABLE) */) { break; } clear_selected(); g1_convoy_class * c=(g1_convoy_class *)g1_create_object(convoy_type); c->player_num=obj->player_num; if (!obj->get_flag(g1_object_class::SELECTABLE)) { c->player_num=0; } //a slight hack to prevent the user //from actually sending commands //to this unit. c->setup(obj); selected_object=c; selected_object->mark_as_selected(); break; } case ADD_TO_LIST: { if ((selected_object.valid()&&selected_object->id!=g1_get_object_type(li_convoy.get())) || !obj || obj->player_num!=team() || !obj->get_flag(g1_object_class::SELECTABLE)) { break; } if (!selected_object.valid()) { g1_convoy_class * cn=(g1_convoy_class *) g1_create_object(convoy_type); cn->player_num=team(); cn->setup(obj); selected_object=cn; cn->mark_as_selected(); break; } ((g1_convoy_class *)selected_object.get())->add_object(obj); } break; case START_DRAG: { dragstartx=gx; //Screen coordinates!!! dragstarty=gy; break; } case DRAGGING: { dragdestx=gx; dragdesty=gy; //w16 mod; //if (i4_current_app->get_window_manager()->shift_pressed()) // mod=ADD_TO_OLD; //else if (i4_current_app->get_window_manager()->alt_pressed()) // mod=SUB_FROM_OLD; //else // mod=CLEAR_OLD; //select_objects_in_range(dragstartx,dragstarty,dragendx,dragendy,mod); } break; case END_DRAG: { dragstartx=dragstarty=dragdestx=dragdesty=-1; } break; case SELECT_PATH: { select_path(gx,gy); } break; default: break; } }