bool DeviceDescriptor::OpenDroidSoarV2() { #ifdef ANDROID if (is_simulator()) return true; if (ioio_helper == nullptr) return false; if (i2cbaro[0] == nullptr) { i2cbaro[0] = new I2CbaroDevice(GetIndex(), Java::GetEnv(), ioio_helper->GetHolder(), DeviceConfig::PressureUse::STATIC_WITH_VARIO, config.sensor_offset, 2 + (0x77 << 8) + (27 << 16), 0, // bus, address 5, // update freq. 0); // flags i2cbaro[1] = new I2CbaroDevice(GetIndex(), Java::GetEnv(), ioio_helper->GetHolder(), // needs calibration ? (config.sensor_factor == fixed(0)) ? DeviceConfig::PressureUse::PITOT_ZERO : DeviceConfig::PressureUse::PITOT, config.sensor_offset, 1 + (0x77 << 8) + (46 << 16), 0 , 5, 0); return true; } #endif return false; }
void snmp_bc_close(void *hnd) { struct oh_handler_state *handle = (struct oh_handler_state *)hnd; oh_sel_close(handle->selcache); if (is_simulator()) { sim_close(); } else { struct snmp_bc_hnd *custom_handle = (struct snmp_bc_hnd *)handle->data; /* Should we free handle->config? */ /* windows32 specific net-snmp cleanup (is a noop on unix) */ snmp_close(custom_handle->ss); SOCK_CLEANUP; } /* Cleanup event2hpi hash table */ event2hpi_hash_free(handle); /* Cleanup str2event hash table */ str2event_use_count--; if (str2event_use_count == 0) str2event_hash_free(); }
bool DeviceDescriptor::OpenI2Cbaro() { #ifdef ANDROID if (is_simulator()) return true; if (ioio_helper == nullptr) return false; for (unsigned i=0; i<sizeof i2cbaro/sizeof i2cbaro[0]; i++) { if (i2cbaro[i] == nullptr) { i2cbaro[i] = new I2CbaroDevice(GetIndex(), Java::GetEnv(), ioio_helper->GetHolder(), // needs calibration ? (config.sensor_factor == fixed(0) && config.press_use == DeviceConfig::PressureUse::PITOT) ? DeviceConfig::PressureUse::PITOT_ZERO : config.press_use, config.sensor_offset, config.i2c_bus, config.i2c_addr, config.press_use == DeviceConfig::PressureUse::TEK_PRESSURE ? 20 : 5, 0); // called flags, actually reserved for future use. return true; } } #endif return false; }
/** * snmp_bc_close: * @hnd: Pointer to handler structure. * * Close an SNMP BladeCenter/RSA plugin handler instance. * * Returns: * Void **/ void snmp_bc_close(void *hnd) { struct oh_handler_state *handle = (struct oh_handler_state *)hnd; oh_el_close(handle->elcache); if (is_simulator()) { sim_close(); } else { struct snmp_bc_hnd *custom_handle = (struct snmp_bc_hnd *)handle->data; /* FIXME:: Should we free handle->config - same question on A.1.1 code? */ snmp_close(custom_handle->ss); /* Windows32 specific net-snmp cleanup (noop on unix) */ SOCK_CLEANUP; } /* Cleanup event2hpi hash table */ event2hpi_hash_free(handle); /* Cleanup str2event hash table */ /* FIXME:: Add RSA free here */ bc_xml2event_hash_use_count--; if (bc_xml2event_hash_use_count == 0) { xml2event_hash_free(&bc_xml2event_hash); } }
void DeviceListWidget::UpdateButtons() { const unsigned current = GetList().GetCursorIndex(); if (current < NUMDEV) { const auto &config = CommonInterface::GetSystemSettings().devices[current]; if (config.port_type != DeviceConfig::PortType::DISABLED) { disable_button->SetEnabled(true); disable_button->SetCaption(config.enabled ? _("Disable") : _("Enable")); } else disable_button->SetEnabled(false); } else disable_button->SetEnabled(false); if (is_simulator() || current >= NUMDEV) { reconnect_button->SetEnabled(false); flight_button->SetEnabled(false); manage_button->SetEnabled(false); monitor_button->SetEnabled(false); debug_button->SetEnabled(false); } else { const DeviceDescriptor &device = (*devices)[current]; reconnect_button->SetEnabled(!device.GetConfig().IsDisabled()); flight_button->SetEnabled(device.IsLogger()); manage_button->SetEnabled(device.IsManageable()); monitor_button->SetEnabled(device.GetConfig().UsesPort()); debug_button->SetEnabled(device.GetConfig().UsesPort() && device.GetState() == PortState::READY); } edit_button->SetEnabled(current < NUMDEV); }
static bool devInitOne(DeviceDescriptor &device, const DeviceConfig &config, DeviceDescriptor *&nmeaout) { if (config.port_type == DeviceConfig::INTERNAL) { #ifdef ANDROID if (is_simulator()) return true; device.internal_gps = InternalGPS::create(Java::GetEnv(), native_view, device.GetIndex()); return device.internal_gps != NULL; #else return false; #endif } const struct DeviceRegister *Driver = devGetDriver(config.driver_name); if (Driver == NULL) return false; Port *Com = OpenPort(config, device); if (Com == NULL) return false; if (!device.Open(Com, Driver)) { delete Com; return false; } if (nmeaout == NULL && (Driver->Flags & (1l << dfNmeaOut))) nmeaout = &device; return true; }
bool InfoBoxContentTrack::HandleKey(const InfoBoxKeyCodes keycode) { if (!is_simulator()) return false; if (!XCSoarInterface::Basic().gps.simulator) return false; const Angle a5 = Angle::Degrees(fixed(5)); switch (keycode) { case ibkUp: case ibkRight: device_blackboard->SetTrack( XCSoarInterface::Basic().track + a5); return true; case ibkDown: case ibkLeft: device_blackboard->SetTrack( XCSoarInterface::Basic().track - a5); return true; case ibkEnter: break; } return false; }
void devRestart() { if (is_simulator()) return; /* #ifdef WINDOWSPC static bool first = true; if (!first) { NMEAParser::Reset(); return; } first = false; #endif */ StartupStore(TEXT("RestartCommPorts\n")); mutexComm.Lock(); devShutdown(); NMEAParser::Reset(); devInit(TEXT("")); mutexComm.Unlock(); }
bool InfoBoxContentAltitudeGPS::HandleKey(const InfoBoxKeyCodes keycode) { const NMEAInfo &basic = CommonInterface::Basic(); if (!is_simulator()) return false; if (!basic.gps.simulator) return false; const Angle a5 = Angle::Degrees(5); switch (keycode) { case ibkUp: ChangeAltitude(fixed(+100)); return true; case ibkDown: ChangeAltitude(fixed(-100)); return true; case ibkLeft: device_blackboard->SetTrack( basic.track - a5); return true; case ibkRight: device_blackboard->SetTrack( basic.track + a5); return true; } return false; }
bool InfoBoxContentSpeedGround::HandleKey(const InfoBoxKeyCodes keycode) { if (!is_simulator()) return false; if (!CommonInterface::Basic().gps.simulator) return false; fixed fixed_step = (fixed)Units::ToSysSpeed(fixed(10)); const Angle a5 = Angle::Degrees(5); switch (keycode) { case ibkUp: device_blackboard->SetSpeed( CommonInterface::Basic().ground_speed + fixed_step); return true; case ibkDown: device_blackboard->SetSpeed(std::max(fixed(0), CommonInterface::Basic().ground_speed - fixed_step)); return true; case ibkLeft: device_blackboard->SetTrack(CommonInterface::Basic().track - a5); return true; case ibkRight: device_blackboard->SetTrack(CommonInterface::Basic().track + a5); return true; } return false; }
void XCSoarInterface::AfterStartup() { LogStartUp(_T("ProgramStarted = 3")); StartupLogFreeRamAndStorage(); status_messages.Startup(true); if (is_simulator()) { LogStartUp(_T("GCE_STARTUP_SIMULATOR")); InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { LogStartUp(_T("GCE_STARTUP_REAL")); InputEvents::processGlideComputer(GCE_STARTUP_REAL); } protected_task_manager->task_load_default(&way_points); task_manager->resume(); LogStartUp(_T("CloseProgressDialog")); ProgressGlue::Close(); main_window.full_screen(); InfoBoxManager::SetDirty(); TriggerGPSUpdate(); status_messages.Startup(false); }
static void AfterStartup() { StartupLogFreeRamAndStorage(); if (is_simulator()) { InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { InputEvents::processGlideComputer(GCE_STARTUP_REAL); } OrderedTask *defaultTask = LoadDefaultTask(CommonInterface::GetComputerSettings().task, &way_points); if (defaultTask) { { ScopeSuspendAllThreads suspend; defaultTask->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*defaultTask); delete defaultTask; } task_manager->Resume(); #ifdef USE_GDI CommonInterface::main_window->Fullscreen(); #endif InfoBoxManager::SetDirty(); ForceCalculation(); }
bool InfoBoxContentTrack::HandleKey(const InfoBoxKeyCodes keycode) { if (!is_simulator()) return false; const Angle a5 = Angle::degrees(fixed(5)); switch (keycode) { case ibkUp: device_blackboard.SetTrackBearing( XCSoarInterface::Basic().TrackBearing + a5); return true; case ibkDown: device_blackboard.SetTrackBearing( XCSoarInterface::Basic().TrackBearing - a5); return true; case ibkLeft: case ibkRight: case ibkEnter: break; } return false; }
/** * snmp_bc_check_selcache: * @handle: Pointer to handler's data. * @id: Resource ID that owns Event Log. * @entryId: Event Log entry ID. * * Sync Event Log's cache. If this is first entry, then create the * event log cache. * * Return values: * SA_OK - normal operation. * SA_ERR_HPI_INVALID_PARAMS - @handler is NULL. **/ SaErrorT snmp_bc_check_selcache(struct oh_handler_state *handle, SaHpiResourceIdT id, SaHpiEventLogEntryIdT entryId) { SaErrorT err = SA_OK; if (!handle) { dbg("Invalid parameter."); return(SA_ERR_HPI_INVALID_PARAMS); } if ((g_list_length(handle->elcache->elentries) == 0) && !(is_simulator())) { /* err = snmp_bc_build_selcache(handle, id); */ trace("elcache sync called before discovery?\n"); } else { err = snmp_bc_selcache_sync(handle, id, entryId); } if (err) { dbg("Event Log cache build/sync failed. Error=%s", oh_lookup_error(err)); return(err); } return(SA_OK); }
/** * snmp_bc_check_selcache: * @handle: Pointer to handler's data. * @id: Resource ID that owns Event Log. * @entryId: Event Log entry ID. * * Sync Event Log's cache. If this is first entry, then create the * event log cache. * * Return values: * SA_OK - normal operation. * SA_ERR_HPI_INVALID_PARAMS - @handler is NULL. **/ SaErrorT snmp_bc_check_selcache(struct oh_handler_state *handle, SaHpiResourceIdT id, SaHpiEventLogEntryIdT entryId) { SaErrorT err; SaHpiEventLogInfoT elinfo; if (!handle) { err("Invalid parameter."); return(SA_ERR_HPI_INVALID_PARAMS); } err = SA_OK; oh_el_info(handle->elcache, &elinfo); if (elinfo.Entries == 0 && !(is_simulator())) { /* err = snmp_bc_build_selcache(handle, id); */ dbg("elcache sync called before discovery?\n"); } else { err = snmp_bc_selcache_sync(handle, id, entryId); } if (err) { err("Event Log cache build/sync failed. Error=%s", oh_lookup_error(err)); return(err); } return(SA_OK); }
/** * Create special startup message for some devices */ void XCSoarInterface::StartupInfo() { // TODO speed: TB: this slows down the bootup process because of sleep() #ifdef CREDITS_FIVV CreateProgressDialog(gettext(TEXT("Special ITA version"))); Sleep(1000); #endif #ifdef PNA // VENTA-ADDON TCHAR sTmp[MAX_PATH]; _stprintf(sTmp, TEXT("PNA MODEL=%s (%d)"), GlobalModelName, GlobalModelType); CreateProgressDialog(sTmp); Sleep(3000); #endif // non PNA if (is_simulator()) { CreateProgressDialog(TEXT("SIMULATION")); Sleep(2000); } #ifdef PNA if ( SetBacklight() == true ) CreateProgressDialog(TEXT("AUTOMATIC BACKLIGHT CONTROL")); else CreateProgressDialog(TEXT("NO BACKLIGHT CONTROL")); Sleep(3000); // this should work ok for all pdas as well if ( SetSoundVolume() == true ) CreateProgressDialog(TEXT("AUTOMATIC SOUND LEVEL CONTROL")); else CreateProgressDialog(TEXT("NO SOUND LEVEL CONTROL")); Sleep(3000); #endif }
bool InfoBoxContentAltitudeGPS::HandleKey(const InfoBoxKeyCodes keycode) { if (!is_simulator()) return false; fixed fixed_step = (fixed)Units::ToSysUnit(fixed(100), Units::AltitudeUnit); const Angle a5 = Angle::degrees(fixed(5)); switch (keycode) { case ibkUp: device_blackboard.SetAltitude( XCSoarInterface::Basic().GPSAltitude + fixed_step); return true; case ibkDown: device_blackboard.SetAltitude( max(fixed_zero, XCSoarInterface::Basic().GPSAltitude - fixed_step)); return true; case ibkLeft: device_blackboard.SetTrackBearing( XCSoarInterface::Basic().TrackBearing - a5); return true; case ibkRight: device_blackboard.SetTrackBearing( XCSoarInterface::Basic().TrackBearing + a5); return true; } return false; }
/** * snmp_bc_close: * @hnd: Pointer to handler structure. * * Close an SNMP BladeCenter/RSA plugin handler instance. * * Returns: * Void **/ void snmp_bc_close(void *hnd) { struct oh_handler_state *handle = (struct oh_handler_state *)hnd; oh_el_close(handle->elcache); if (is_simulator()) { sim_close(); } else { struct snmp_bc_hnd *custom_handle = (struct snmp_bc_hnd *)handle->data; snmp_sess_close(custom_handle->sessp); /* Windows32 specific net-snmp cleanup (noop on unix) */ SOCK_CLEANUP; } /* Cleanup event2hpi hash table */ event2hpi_hash_free(handle); /* Cleanup errlog2event_hash table */ errlog2event_hash_use_count--; if (errlog2event_hash_use_count == 0) { errlog2event_hash_free(); } }
void TaskListPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) { LoadWindow(task_list_callbacks, parent, Layout::landscape ? _T("IDR_XML_TASKLIST_L") : _T("IDR_XML_TASKLIST")); instance = this; task_store = new TaskStore(); lazy_loaded = false; browse_tabbed = ((TabbedControl *)form.FindByName(_T("tabbedManage"))); assert(browse_tabbed != NULL); if (is_simulator()) /* cannot communicate with real devices in simulator mode */ form.FindByName(_T("cmdDeclare"))->set_enabled(false); // Save important control pointers wTaskView = (WndOwnerDrawFrame*)form.FindByName(_T("frmTaskView1")); assert(wTaskView != NULL); TaskViewRect = wTaskView->get_position(); wTaskView->SetOnMouseDownNotify(::OnTaskViewClick); fullscreen = false; wTasks = (WndListFrame*)form.FindByName(_T("frmTasks")); assert(wTasks != NULL); // Set callbacks wTasks->SetActivateCallback(OnTaskListEnter); wTasks->SetPaintItemCallback(::OnTaskPaintListItem); wTasks->SetCursorCallback(OnTaskCursorCallback); }
void InfoBoxContentAltitude::PnlSimulatorOnMinusBig(gcc_unused WndButton &Sender) { if (!is_simulator()) return; ChangeAltitude(fixed(-100)); }
void InfoBoxContentAltitude::PnlSimulatorOnPlusSmall(gcc_unused WndButton &Sender) { if (!is_simulator()) return; ChangeAltitude(fixed(+10)); }
static void PnlSimulatorOnMinusBig(gcc_unused WndButton &Sender) { if (!is_simulator()) return; ChangeAltitude(fixed(-100)); }
static void PnlSimulatorOnPlusSmall(gcc_unused WndButton &Sender) { if (!is_simulator()) return; ChangeAltitude(fixed(+10)); }
void AllDevicesPutVoice(const TCHAR *sentence) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutVoice(sentence); }
void AllDevicesPutStandbyFrequency(double frequency) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutStandbyFrequency(frequency); }
void AllDevicesLinkTimeout() { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].LinkTimeout(); }
void AllDevicesPutMacCready(fixed MacCready) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutMacCready(MacCready); }
void AllDevicesPutBugs(fixed bugs) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutBugs(bugs); }
void AllDevicesPutBallast(fixed ballast) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutBallast(ballast); }
void AllDevicesPutVolume(int volume) { if (is_simulator()) return; for (unsigned i = 0; i < NUMDEV; ++i) DeviceList[i].PutVolume(volume); }