// Add AI execution timer to target Clonk func AddAI(object clonk) { var fx = GetEffect("S2AI", clonk); if (!fx) fx = AddEffect("S2AI", clonk, 1, 3, nil, S2AI); if (!fx || !clonk) return nil; fx.ai = S2AI; clonk.ExecuteS2AI = S2AI.Execute; if (clonk->GetProcedure() == "PUSH") fx.vehicle = clonk->GetActionTarget(); BindInventory(clonk); SetHome(clonk); SetGuardRange(clonk, fx.home_x-S2AI_DefGuardRangeX, fx.home_y-S2AI_DefGuardRangeY, S2AI_DefGuardRangeX*2, S2AI_DefGuardRangeY*2); SetMaxAggroDistance(clonk, S2AI_DefMaxAggroDistance); return fx; }
void Servo::run() { if(mode == Servo::JOG){ //ジョグモードの場合は単発で目的位置へ移動 CPhidgetAdvancedServo_setPosition (*servo, index, position); }else if(mode == Servo::PREDEFINED){ //プリディファインドモードの場合は制御ベクトルに従ってそれぞれ移動 if(to == 0){ SetReady(); }else if(to == 1){ SetContact(); }else if(to == 2){ SetHome(); } } //// エンゲージ /* if(mode == Servo::JOG){ std::cout << "[ サーボモーター制御スレッド ] モータID : " << index << " > エンゲージ(ジョグ)" << std::endl; Engage(true); }else if(mode == Servo::KNOCK){ std::cout << "[ サーボモーター制御スレッド ] モータID : " << index << " > エンゲージ(電磁弁)" << std::endl; CPhidgetAdvancedServo_setPosition (*servo, index, knockPosition); } */ //// ディスエンゲージ動作は行わない //電磁弁的動作処理時間(0.5秒) //Sleep(500); // //ディスエンゲージ //std::cout << "ディスエンゲージ" << std::endl; //CPhidgetAdvancedServo_setEngaged(*servo, index, 0); }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool XCSoarInterface::Startup(HINSTANCE hInstance, LPTSTR lpCmdLine) { // The title bar text TCHAR szTitle[MAX_LOADSTRING]; // Store instance handle in our global variable hInst = hInstance; // IDS_APP_TITLE = XCSoar (see XCSoar.rc) LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); //If it is already running, then focus on the window if (MainWindow::find(szTitle)) return false; // Send the SettingsMap to the DeviceBlackboard SendSettingsMap(); // Register window classes PaintWindow::register_class(hInst); MainWindow::register_class(hInst); MapWindow::register_class(hInst); // Fill the fast(co)sine table InitSineTable(); PreloadInitialisation(true); // Send the SettingsMap to the DeviceBlackboard SendSettingsMap(); // Creates the main window StartupStore(TEXT("Create main window\n")); RECT WindowSize = SystemWindowSize(); main_window.set(szTitle, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom); if (!main_window.defined()) { return false; } main_window.install_timer(); // Initialize DeviceBlackboard device_blackboard.Initialise(); // Initialize Marks marks = new Marks("xcsoar-marks"); topology = new TopologyStore(marks->GetTopology()); // Show the main and map windows StartupStore(TEXT("Create map window\n")); main_window.show(); main_window.map.show(); #ifdef HAVE_ACTIVATE_INFO SHSetAppKeyWndAssoc(VK_APP1, main_window); SHSetAppKeyWndAssoc(VK_APP2, main_window); SHSetAppKeyWndAssoc(VK_APP3, main_window); SHSetAppKeyWndAssoc(VK_APP4, main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems SHSetAppKeyWndAssoc(VK_APP5, main_window); SHSetAppKeyWndAssoc(VK_APP6, main_window); #endif // Initialize main blackboard data task.ClearTask(); glide_computer.Initialise(); logger.LinkGRecordDLL(); // try to link DLL if it exists // Load the EGM96 geoid data OpenGeoid(); PreloadInitialisation(false); Profile::LoadWindFromRegistry(); // TODO TB: seems to be out of date?! CalculateNewPolarCoef(); // Calculate polar-related data and saves it to the cache StartupStore(TEXT("GlidePolar::UpdatePolar\n")); GlidePolar::UpdatePolar(false, SettingsComputer()); // Show startup info depending on device StartupInfo(); // Read the topology file(s) topology->Open(); // Read the terrain file terrain.OpenTerrain(); // Read the waypoint files ReadWayPoints(way_points, terrain); // Read and parse the airfield info file ReadAirfieldFile(); // Set the home waypoint SetHome(way_points, terrain, SetSettingsComputer(), false, true); // ReSynchronise the blackboards here since SetHome touches them ReadBlackboardBasic(device_blackboard.Basic()); terrain.ServiceFullReload(Basic().Location); // Scan for weather forecast CreateProgressDialog(gettext(TEXT("Scanning weather forecast"))); StartupStore(TEXT("RASP load\n")); RASP.ScanAll(Basic().Location); // Reads the airspace files ReadAirspace(); // Sorts the airspaces by priority SortAirspace(); // Read the FLARM details file OpenFLARMDetails(); #ifndef DISABLEAUDIOVARIO /* VarioSound_Init(); VarioSound_EnableSound(EnableSoundVario); VarioSound_SetVdead(SoundDeadband); VarioSound_SetV(0); VarioSound_SetSoundVolume(SoundVolume); */ #endif // Start the device thread(s) CreateProgressDialog(gettext(TEXT("Starting devices"))); devStartup(lpCmdLine); // Reset polar in case devices need the data StartupStore(TEXT("GlidePolar::UpdatePolar\n")); GlidePolar::UpdatePolar(true, SettingsComputer()); CreateProgressDialog(gettext(TEXT("Initialising display"))); // Finally ready to go.. all structures must be present before this. // Create the drawing thread StartupStore(TEXT("CreateDrawingThread\n")); draw_thread = new DrawThread(main_window.map, main_window.flarm); draw_thread->start(); // Show the infoboxes StartupStore(TEXT("ShowInfoBoxes\n")); InfoBoxManager::Show(); // Create the calculation thread StartupStore(TEXT("CreateCalculationThread\n")); CreateCalculationThread(); #ifdef NEWTASK { // NEWTASK PeriodClock t; t.reset(); t.update(); CreateProgressDialog(gettext(TEXT("Running test 0"))); test_newtask(0); StartupStore(TEXT("test 0 %d\n"),t.elapsed()); /* t.update(); CreateProgressDialog(gettext(TEXT("Running test 1"))); test_newtask(1); StartupStore(TEXT("test 1 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 2"))); test_newtask(2); StartupStore(TEXT("test 2 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 3"))); test_newtask(3); StartupStore(TEXT("test 3 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 4"))); test_newtask(4); StartupStore(TEXT("test 4 %d\n"),t.elapsed()); */ CreateProgressDialog(gettext(TEXT("test complete"))); } #endif // Initialise the airspace warning dialog StartupStore(TEXT("dlgAirspaceWarningInit\n")); dlgAirspaceWarningInit(); // Find unique ID of this PDA ReadAssetNumber(); StartupStore(TEXT("ProgramStarted\n")); // Give focus to the map main_window.map.set_focus(); // Start calculation thread calculation_thread->start(); // Start instrument thread instrument_thread->start(); globalRunningEvent.trigger(); return true; }
void SettingsLeave() { if (!GlobalRunning) return; SwitchToMapWindow(); // Locking everything here prevents the calculation thread from running, // while shared data is potentially reloaded. LockFlightData(); LockTaskData(); MenuActive = false; // 101020 LKmaps contain only topology , so no need to force total reload! if(MAPFILECHANGED) { #if TESTBENCH StartupStore(_T(".... MAPFILECHANGED from configuration\n")); #endif if (LKTopo==0) { AIRSPACEFILECHANGED = TRUE; AIRFIELDFILECHANGED = TRUE; WAYPOINTFILECHANGED = TRUE; TERRAINFILECHANGED = TRUE; } TOPOLOGYFILECHANGED = TRUE; } if (TERRAINFILECHANGED) { #if TESTBENCH StartupStore(_T(".... TERRAINFILECHANGED from configuration\n")); #endif RasterTerrain::CloseTerrain(); RasterTerrain::OpenTerrain(); // NO! We dont reload waypoints on terrain change. // SetHome(WAYPOINTFILECHANGED==TRUE); MapWindow::ForceVisibilityScan = true; } if((WAYPOINTFILECHANGED) || (AIRFIELDFILECHANGED)) { #if TESTBENCH StartupStore(_T(".... WAYPOINT OR AIRFIELD CHANGED from configuration\n")); #endif SaveDefaultTask(); //@ 101020 BUGFIX ClearTask(); ReadWayPoints(); StartupStore(_T(". RELOADED %d WAYPOINTS + %d virtuals%s"),WayPointList.size()-NUMRESWP,NUMRESWP,NEWLINE); SetHome(true); // force home reload if (WAYPOINTFILECHANGED) { #if TESTBENCH StartupStore(_T(".... WAYPOINTFILECHANGED from configuration\n")); #endif SaveRecentList(); LoadRecentList(); RangeLandableNumber=0; RangeAirportNumber=0; RangeTurnpointNumber=0; CommonNumber=0; SortedNumber=0; // SortedTurnpointNumber=0; 101222 LastDoRangeWaypointListTime=0; LKForceDoCommon=true; LKForceDoNearest=true; LKForceDoRecent=true; // LKForceDoNearestTurnpoint=true; 101222 } InputEvents::eventTaskLoad(_T(LKF_DEFAULTASK)); //@ BUGFIX 101020 } if (TOPOLOGYFILECHANGED) { #if TESTBENCH StartupStore(_T(".... TOPOLOGYFILECHANGED from configuration\n")); #endif CloseTopology(); OpenTopology(); MapWindow::ForceVisibilityScan = true; } if(AIRSPACEFILECHANGED) { #if TESTBENCH StartupStore(_T(".... AIRSPACEFILECHANGED from configuration\n")); #endif CAirspaceManager::Instance().CloseAirspaces(); CAirspaceManager::Instance().ReadAirspaces(); CAirspaceManager::Instance().SortAirspaces(); MapWindow::ForceVisibilityScan = true; } if (POLARFILECHANGED) { #if TESTBENCH StartupStore(_T(".... POLARFILECHANGED from configuration\n")); #endif CalculateNewPolarCoef(); GlidePolar::SetBallast(); } if (AIRFIELDFILECHANGED || AIRSPACEFILECHANGED || WAYPOINTFILECHANGED || TERRAINFILECHANGED || TOPOLOGYFILECHANGED ) { CloseProgressDialog(); MainWindow.SetFocus(); } extern void ReinitScreen(void); if (FONTSCHANGED) { ReinitScreen(); } UnlockTaskData(); UnlockFlightData(); if(!SIMMODE && COMPORTCHANGED) { #if TESTBENCH StartupStore(_T(".... COMPORTCHANGED from configuration. ForceComPortReset @%s\n"),WhatTimeIsIt()); #endif LKForceComPortReset=true; // RestartCommPorts(); 110605 } MapWindow::ResumeDrawingThread(); // allow map and calculations threads to continue on their merry way }
// 初期化(デフォルト実装) void Init() { //デフォルト実装では可動子をホームポジションへ移動させる SetHome(); }
bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser &cl) { if (!wxApp::OnCmdLineParsed(cl)) return false; wxString s; if (cl.Found(wxT("save-xrc"), &s)) { // This was most likely done on a command line, so use // stderr instead of gui for messages wxLog::SetActiveTarget(new wxLogStderr); wxFileSystem fs; wxFSFile* f = fs.OpenFile(wxT("memory:wxvbam.xrs#zip:wxvbam.xrs$wxvbam.xrc")); if (!f) { wxLogError(_("Configuration/build error: can't find built-in xrc")); return false; } wxFileOutputStream os(s); os.Write(*f->GetStream()); delete f; wxString lm; lm.Printf(_("Wrote built-in configuration to %s.\n" "To override, remove all but changed root node(s). " "First found root node of correct name in any .xrc or " ".xrs files in following search path overrides built-in:"), s.c_str()); tack_full_path(lm); wxLogMessage(lm); return false; } if (cl.Found(wxT("print-cfg-path"))) { // This was most likely done on a command line, so use // stderr instead of gui for messages wxLog::SetActiveTarget(new wxLogStderr); wxString lm(_("Configuration is read from, in order:")); tack_full_path(lm); wxLogMessage(lm); return false; } if (cl.Found(wxT("save-over"), &s)) { // This was most likely done on a command line, so use // stderr instead of gui for messages wxLog::SetActiveTarget(new wxLogStderr); wxFileOutputStream os(s); os.Write(builtin_over, sizeof(builtin_over)); wxString lm; lm.Printf(_("Wrote built-in override file to %s\n" "To override, delete all but changed section. First found section is used from search path:"), s.c_str()); wxString oi = wxFileName::GetPathSeparator(); oi += wxT("vba-over.ini"); tack_full_path(lm, oi); lm.append(_("\n\tbuilt-in")); wxLogMessage(lm); return false; } if (cl.Found(wxT("f"))) { pending_fullscreen = true; } if (cl.Found(wxT("o"))) { wxPrintf(_("Options set from the command line are saved if any" " configuration changes are made in the user interface.\n\n" "For flag options, true and false are specified as 1 and 0, respectively.\n\n")); for (int i = 0; i < num_opts; i++) { wxPrintf(wxT("%s (%s"), opts[i].opt, opts[i].boolopt ? (const wxChar*)wxT("flag") : opts[i].stropt ? (const wxChar*)wxT("string") : opts[i].enumvals ? opts[i].enumvals : opts[i].intopt ? (const wxChar*)wxT("int") : (const wxChar*)wxT("string")); if (opts[i].enumvals) { const wxChar* evx = wxGetTranslation(opts[i].enumvals); if (wxStrcmp(evx, opts[i].enumvals)) wxPrintf(wxT(" = %s"), evx); } wxPrintf(wxT(")\n\t%s\n\n"), opts[i].desc); if (opts[i].enumvals) opts[i].enumvals = wxGetTranslation(opts[i].enumvals); } wxPrintf(_("The commands available for the Keyboard/* option are:\n\n")); for (int i = 0; i < ncmds; i++) wxPrintf(wxT("%s (%s)\n"), cmdtab[i].cmd, cmdtab[i].name); return false; } #if !defined(NO_LINK) && !defined(__WXMSW__) if (cl.Found(wxT("s"))) { CleanLocalLink(); } #endif int nparm = cl.GetParamCount(); bool complained = false, gotfile = false; for (int i = 0; i < nparm; i++) { wxString p = cl.GetParam(i); size_t eqat = p.find(wxT('=')); if (eqat != wxString::npos) { p[eqat] = 0; if (!opt_set(p.c_str(), p.c_str() + eqat + 1)) { p[eqat] = wxT('='); eqat = wxString::npos; } else p[eqat] = wxT('='); pending_optset.push_back(p); } if (eqat == wxString::npos) { if (!gotfile) { pending_load = p; gotfile = true; } else { if (!complained) { wxFprintf(stderr, _("Bad configuration option or multiple ROM files given:\n")); wxFprintf(stderr, wxT("%s\n"), pending_load.c_str()); complained = true; } wxFprintf(stderr, wxT("%s\n"), p.c_str()); } } } home = strdup((const char*)wxApp::argv[0]); SetHome(home); LoadConfig(); // Parse command line arguments (overrides ini) ReadOpts(argc, (char**)argv); return true; }