本文整理汇总了C++中InfoBoxData::UnsafeFormatValue方法的典型用法代码示例。如果您正苦于以下问题:C++ InfoBoxData::UnsafeFormatValue方法的具体用法?C++ InfoBoxData::UnsafeFormatValue怎么用?C++ InfoBoxData::UnsafeFormatValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InfoBoxData
的用法示例。
在下文中一共展示了InfoBoxData::UnsafeFormatValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
UpdateInfoBoxTaskAATimeDelta(InfoBoxData &data)
{
const auto &calculated = CommonInterface::Calculated();
const TaskStats &task_stats = calculated.ordered_task_stats;
const CommonStats &common_stats = calculated.common_stats;
if (!task_stats.has_targets ||
!task_stats.total.IsAchievable()) {
data.SetInvalid();
return;
}
assert(!negative(task_stats.total.time_remaining_start));
fixed diff = task_stats.total.time_remaining_start -
common_stats.aat_time_remaining;
TCHAR value[32];
TCHAR comment[32];
const int dd = abs((int)diff);
FormatTimeTwoLines(value, comment, dd);
data.UnsafeFormatValue(negative(diff) ? _T("-%s") : _T("%s"), value);
data.SetComment(comment);
// Set Color (red/blue/black)
data.SetValueColor(negative(diff) ? 1 :
task_stats.total.time_remaining_start >
common_stats.aat_time_remaining + fixed(5*60) ? 2 : 0);
}
示例2: assert
void
InfoBoxContentTaskAATimeDelta::Update(InfoBoxData &data)
{
const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats;
if (!common_stats.ordered_has_targets ||
!task_stats.task_valid || !task_stats.total.IsAchievable()) {
data.SetInvalid();
return;
}
assert(!negative(task_stats.total.time_remaining));
fixed diff = task_stats.total.time_remaining -
common_stats.aat_time_remaining;
TCHAR HHMMSSsmart[32];
TCHAR SSsmart[32];
const int dd = abs((int)diff);
Units::TimeToTextSmart(HHMMSSsmart, SSsmart, dd);
data.UnsafeFormatValue(negative(diff) ? _T("-%s") : _T("%s"), HHMMSSsmart);
data.SetComment(SSsmart);
// Set Color (red/blue/black)
data.SetValueColor(negative(diff) ? 1 :
task_stats.total.time_remaining >
common_stats.aat_time_remaining + fixed(5*60) ? 2 : 0);
}
示例3: arrival_s
void
UpdateInfoBoxStartOpenArrival(InfoBoxData &data)
{
const NMEAInfo &basic = CommonInterface::Basic();
const auto &calculated = CommonInterface::Calculated();
const TaskStats &task_stats = calculated.ordered_task_stats;
const GlideResult ¤t_remaining =
task_stats.current_leg.solution_remaining;
const CommonStats &common_stats = CommonInterface::Calculated().common_stats;
const RoughTimeSpan &open = common_stats.start_open_time_span;
/* reset color that may have been set by a previous call */
data.SetValueColor(0);
if (!basic.time_available || !task_stats.task_valid ||
common_stats.ordered_summary.active != 0 ||
!open.IsDefined() ||
!current_remaining.IsOk()) {
data.SetInvalid();
return;
}
const unsigned arrival_s(basic.time + current_remaining.time_elapsed);
const RoughTime arrival = RoughTime::FromSecondOfDayChecked(arrival_s);
if (open.HasEnded(arrival)) {
data.SetValueInvalid();
data.SetComment(_("Closed"));
} else if (open.HasBegun(arrival)) {
if (open.GetEnd().IsValid()) {
unsigned seconds = SecondsUntil(arrival_s, open.GetEnd());
data.UnsafeFormatValue(_T("%02u:%02u"), seconds / 60, seconds % 60);
data.SetValueColor(3);
} else
data.SetValueInvalid();
data.SetComment(_("Open"));
} else {
unsigned seconds = SecondsUntil(arrival_s, open.GetStart());
data.UnsafeFormatValue(_T("%02u:%02u"), seconds / 60, seconds % 60);
data.SetValueColor(2);
data.SetComment(_("Waiting"));
}
}
示例4: SystemLoadCPU
void
UpdateInfoBoxCPULoad(InfoBoxData &data)
{
unsigned percent_load = SystemLoadCPU();
if (percent_load <= 100) {
data.UnsafeFormatValue(_T("%d%%"), percent_load);
} else {
data.SetInvalid();
}
}
示例5: iround
void
InfoBoxContentFlightLevel::Update(InfoBoxData &data)
{
const NMEAInfo &basic = CommonInterface::Basic();
const ComputerSettings &settings_computer =
CommonInterface::GetComputerSettings();
if (basic.pressure_altitude_available) {
fixed Altitude = Units::ToUserUnit(basic.pressure_altitude, Unit::FEET);
// Title color black
data.SetTitleColor(0);
// Set Value
data.UnsafeFormatValue(_T("%03d"), iround(Altitude / 100));
// Set Comment
data.UnsafeFormatComment(_T("%dft"), iround(Altitude));
} else if (basic.gps_altitude_available &&
settings_computer.pressure_available) {
// Take gps altitude as baro altitude. This is inaccurate but still fits our needs.
const AtmosphericPressure &qnh = settings_computer.pressure;
fixed Altitude = Units::ToUserUnit(qnh.QNHAltitudeToPressureAltitude(basic.gps_altitude), Unit::FEET);
// Title color red
data.SetTitleColor(1);
// Set Value
data.UnsafeFormatValue(_T("%03d"), iround(Altitude / 100));
// Set Comment
data.UnsafeFormatComment(_T("%dft"), iround(Altitude));
} else if ((basic.baro_altitude_available || basic.gps_altitude_available) &&
!settings_computer.pressure_available) {
data.SetInvalid();
data.SetComment(_("no QNH"));
} else {
data.SetInvalid();
}
}
示例6:
void
UpdateInfoBoxCruiseEfficiency(InfoBoxData &data)
{
const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
if (!task_stats.task_valid || !task_stats.start.task_started) {
data.SetInvalid();
return;
}
data.UnsafeFormatValue(_T("%d"), (int) (task_stats.cruise_efficiency * 100));
data.SetCommentFromVerticalSpeed(task_stats.effective_mc, false);
}
示例7:
void
UpdateInfoBoxHumidity(InfoBoxData &data)
{
const NMEAInfo &basic = CommonInterface::Basic();
if (!basic.humidity_available) {
data.SetInvalid();
return;
}
// Set Value
data.UnsafeFormatValue( _T("%d"), (int)basic.humidity);
}
示例8:
void
InfoBoxContentHumidity::Update(InfoBoxData &data)
{
const NMEAInfo &basic = XCSoarInterface::Basic();
if (!basic.humidity_available) {
data.SetInvalid();
return;
}
// Set Value
data.UnsafeFormatValue( _T("%d"), (int)basic.humidity);
}
示例9:
void
UpdateInfoBoxTimeUTC(InfoBoxData &data)
{
const NMEAInfo &basic = CommonInterface::Basic();
if (!basic.time_available) {
data.SetInvalid();
return;
}
// Set Value
const BrokenDateTime t = basic.date_time_utc;
data.UnsafeFormatValue(_T("%02d:%02d"), t.hour, t.minute);
// Set Comment
data.UnsafeFormatComment(_T("%02d"), t.second);
}
示例10: DetectCurrentTime
void
InfoBoxContentFinalETA::Update(InfoBoxData &data)
{
const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
if (!task_stats.task_valid || !task_stats.total.IsAchievable()) {
data.SetInvalid();
return;
}
int dd = (int)task_stats.total.solution_remaining.time_elapsed +
DetectCurrentTime(XCSoarInterface::Basic());
const BrokenTime t = BrokenTime::FromSecondOfDayChecked(abs(dd));
// Set Value
data.UnsafeFormatValue(_T("%02u:%02u"), t.hour, t.minute);
// Set Comment
data.UnsafeFormatComment(_T("%02u"), t.second);
}
示例11: unsigned
void
UpdateInfoBoxFinalETA(InfoBoxData &data)
{
const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
const BrokenTime &now_local = CommonInterface::Calculated().date_time_local;
if (!task_stats.task_valid || !task_stats.total.IsAchievable() ||
!now_local.IsPlausible()) {
data.SetInvalid();
return;
}
const BrokenTime t = now_local +
unsigned(task_stats.total.solution_remaining.time_elapsed);
// Set Value
data.UnsafeFormatValue(_T("%02u:%02u"), t.hour, t.minute);
// Set Comment
data.UnsafeFormatComment(_T("%02u"), t.second);
}
示例12:
void
InfoBoxContentFinalGR::Update(InfoBoxData &data)
{
const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
if (!task_stats.task_valid) {
data.SetInvalid();
return;
}
fixed gradient = task_stats.total.gradient;
if (!positive(gradient)) {
data.SetValue(_T("+++"));
return;
}
if (::GradientValid(gradient)) {
data.UnsafeFormatValue(_T("%d"), (int)gradient);
} else {
data.SetInvalid();
}
}
示例13: FormatTimeTwoLines
void
InfoBoxContentTaskAATime::Update(InfoBoxData &data)
{
const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats;
if (!common_stats.ordered_has_targets ||
!task_stats.task_valid || !task_stats.total.IsAchievable()) {
data.SetInvalid();
return;
}
TCHAR value[32];
TCHAR comment[32];
FormatTimeTwoLines(value, comment,
abs((int) common_stats.aat_time_remaining));
data.UnsafeFormatValue(negative(common_stats.aat_time_remaining) ?
_T("-%s") : _T("%s"), value);
data.SetValueColor(negative(common_stats.aat_time_remaining) ? 1 : 0);
data.SetComment(comment);
}
示例14: FormatTimeTwoLines
void
UpdateInfoBoxTaskAATime(InfoBoxData &data)
{
const auto &calculated = CommonInterface::Calculated();
const TaskStats &task_stats = calculated.ordered_task_stats;
const CommonStats &common_stats = calculated.common_stats;
if (!task_stats.has_targets ||
!task_stats.total.IsAchievable()) {
data.SetInvalid();
return;
}
TCHAR value[32];
TCHAR comment[32];
FormatTimeTwoLines(value, comment,
abs((int) common_stats.aat_time_remaining));
data.UnsafeFormatValue(common_stats.aat_time_remaining < 0 ?
_T("-%s") : _T("%s"), value);
data.SetValueColor(common_stats.aat_time_remaining < 0 ? 1 : 0);
data.SetComment(comment);
}
示例15: switch
void
UpdateInfoBoxBattery(InfoBoxData &data)
{
#ifdef HAVE_BATTERY
bool DisplaySupplyVoltageAsValue=false;
switch (Power::External::Status) {
case Power::External::OFF:
if (CommonInterface::Basic().battery_level_available)
data.UnsafeFormatComment(_T("%s; %d%%"),
_("AC Off"),
(int)CommonInterface::Basic().battery_level);
else
data.SetComment(_("AC Off"));
break;
case Power::External::ON:
if (!CommonInterface::Basic().voltage_available)
data.SetComment(_("AC ON"));
else{
DisplaySupplyVoltageAsValue = true;
data.SetValue(_T("%2.1fV"),
CommonInterface::Basic().voltage);
}
break;
case Power::External::UNKNOWN:
default:
data.SetCommentInvalid();
}
#ifndef ANDROID
switch (Power::Battery::Status){
case Power::Battery::HIGH:
case Power::Battery::LOW:
case Power::Battery::CRITICAL:
case Power::Battery::CHARGING:
if (Power::Battery::RemainingPercentValid){
#endif
if (!DisplaySupplyVoltageAsValue)
data.UnsafeFormatValue(_T("%d%%"), Power::Battery::RemainingPercent);
else
data.UnsafeFormatComment(_T("%d%%"), Power::Battery::RemainingPercent);
#ifndef ANDROID
}
else
if (!DisplaySupplyVoltageAsValue)
data.SetValueInvalid();
else
data.SetCommentInvalid();
break;
case Power::Battery::NOBATTERY:
case Power::Battery::UNKNOWN:
if (!DisplaySupplyVoltageAsValue)
data.SetValueInvalid();
else
data.SetCommentInvalid();
}
#endif
return;
#endif
if (CommonInterface::Basic().voltage_available) {
data.SetValue(_T("%2.1fV"), CommonInterface::Basic().voltage);
return;
} else if (CommonInterface::Basic().battery_level_available) {
data.SetValue(_T("%.0f%%"), CommonInterface::Basic().battery_level);
return;
}
data.SetInvalid();
}