本文整理汇总了C++中OperationEnvironment::SetErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ OperationEnvironment::SetErrorMessage方法的具体用法?C++ OperationEnvironment::SetErrorMessage怎么用?C++ OperationEnvironment::SetErrorMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationEnvironment
的用法示例。
在下文中一共展示了OperationEnvironment::SetErrorMessage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
CAI302WaypointUploader::Run(OperationEnvironment &env)
{
Waypoints waypoints;
env.SetText(_("Loading Waypoints..."));
if (!reader.Parse(waypoints, env)) {
env.SetErrorMessage(_("Failed to load file."));
return;
}
if (waypoints.size() > 9999) {
env.SetErrorMessage(_("Too many waypoints."));
return;
}
env.SetText(_("Uploading Waypoints"));
env.SetProgressRange(waypoints.size() + 1);
env.SetProgressPosition(0);
if (!device.ClearPoints(env)) {
if (!env.IsCancelled())
env.SetErrorMessage(_("Failed to erase waypoints."));
return;
}
if (!device.EnableBulkMode(env)) {
if (!env.IsCancelled())
env.SetErrorMessage(_("Failed to switch baud rate."));
return;
}
unsigned id = 1;
for (auto i = waypoints.begin(), end = waypoints.end();
i != end; ++i, ++id) {
if (env.IsCancelled())
break;
env.SetProgressPosition(id);
if (!device.WriteNavpoint(id, *i, env)) {
if (!env.IsCancelled())
env.SetErrorMessage(_("Failed to write waypoint."));
break;
}
}
device.DisableBulkMode(env);
}
示例2:
static bool
ShowParseWarning(int line, const TCHAR *str, OperationEnvironment &operation)
{
StaticString<256> buffer;
buffer.Format(_T("%s: %d\r\n\"%s\""),
_("Parse Error at Line"), line, str);
operation.SetErrorMessage(buffer.c_str());
return false;
}
示例3: DetectFileType
bool
AirspaceParser::Parse(TLineReader &reader, OperationEnvironment &operation)
{
bool ignore = false;
// Create and init ProgressDialog
operation.SetProgressRange(1024);
const long file_size = reader.GetSize();
TempAirspaceType temp_area;
AirspaceFileType filetype = AFT_UNKNOWN;
TCHAR *line;
// Iterate through the lines
for (unsigned line_num = 1; (line = reader.ReadLine()) != NULL; line_num++) {
// Skip empty line
if (StringIsEmpty(line))
continue;
if (filetype == AFT_UNKNOWN) {
filetype = DetectFileType(line);
if (filetype == AFT_UNKNOWN)
continue;
}
// Parse the line
if (filetype == AFT_OPENAIR)
if (!ParseLine(airspaces, line, temp_area) &&
!ShowParseWarning(line_num, line, operation))
return false;
if (filetype == AFT_TNP)
if (!ParseLineTNP(airspaces, line, temp_area, ignore) &&
!ShowParseWarning(line_num, line, operation))
return false;
// Update the ProgressDialog
if ((line_num & 0xff) == 0)
operation.SetProgressPosition(reader.Tell() * 1024 / file_size);
}
if (filetype == AFT_UNKNOWN) {
operation.SetErrorMessage(_("Unknown airspace filetype"));
return false;
}
// Process final area (if any)
if (!temp_area.points.empty())
temp_area.AddPolygon(airspaces);
return true;
}
示例4: OpenInternalSensors
bool
DeviceDescriptor::Open(OperationEnvironment &env, bool show_error_messages)
{
TCHAR buffer[64];
LogStartUp(_T("Opening device %s"), config.GetPortName(buffer, 64));
if (config.port_type == DeviceConfig::PortType::INTERNAL)
return OpenInternalSensors();
const struct DeviceRegister *driver = FindDriverByName(config.driver_name);
if (driver == NULL) {
if (show_error_messages) {
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("No such driver"), config.driver_name.c_str());
env.SetErrorMessage(msg);
}
return false;
}
reopen_clock.Update();
Port *port = OpenPort(config, *this);
if (port == NULL) {
if (show_error_messages) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("Unable to open port"), name);
env.SetErrorMessage(msg);
}
return false;
}
if (!Open(*port, *driver, env)) {
delete port;
return false;
}
return true;
}
示例5: OpenInternalSensors
bool
DeviceDescriptor::DoOpen(OperationEnvironment &env)
{
assert(config.IsAvailable());
if (config.port_type == DeviceConfig::PortType::INTERNAL)
return OpenInternalSensors();
if (config.port_type == DeviceConfig::PortType::DROIDSOAR_V2)
return OpenDroidSoarV2();
if (config.port_type == DeviceConfig::PortType::I2CPRESSURESENSOR)
return OpenI2Cbaro();
if (config.port_type == DeviceConfig::PortType::NUNCHUCK)
return OpenNunchuck();
if (config.port_type == DeviceConfig::PortType::IOIOVOLTAGE)
return OpenVoltage();
if (config.port_type == DeviceConfig::PortType::ADCAIRSPEED)
return OpenAdcAirspeed();
reopen_clock.Update();
Port *port = OpenPort(config, *this);
if (port == NULL) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("Unable to open port"), name);
env.SetErrorMessage(msg);
return false;
}
while (port->GetState() == PortState::LIMBO) {
env.Sleep(200);
if (env.IsCancelled() || port->GetState() == PortState::FAILED) {
delete port;
return false;
}
}
if (!Open(*port, env)) {
delete port;
return false;
}
return true;
}
示例6: OpenInternalSensors
bool
DeviceDescriptor::DoOpen(OperationEnvironment &env)
{
assert(config.IsAvailable());
if (config.port_type == DeviceConfig::PortType::INTERNAL)
return OpenInternalSensors();
if (config.port_type == DeviceConfig::PortType::DROIDSOAR_V2)
return OpenDroidSoarV2();
if (config.port_type == DeviceConfig::PortType::I2CPRESSURESENSOR)
return OpenI2Cbaro();
if (config.port_type == DeviceConfig::PortType::NUNCHUCK)
return OpenNunchuck();
if (config.port_type == DeviceConfig::PortType::IOIOVOLTAGE)
return OpenVoltage();
reopen_clock.Update();
Port *port = OpenPort(config, port_listener, *this);
if (port == nullptr) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("Unable to open port"), name);
env.SetErrorMessage(msg);
return false;
}
DumpPort *dump_port = new DumpPort(port);
dump_port->Disable();
if (!port->WaitConnected(env) || !OpenOnPort(dump_port, env)) {
if (!env.IsCancelled())
++n_failures;
delete dump_port;
return false;
}
ResetFailureCounter();
return true;
}
示例7: protect
bool
DeviceDescriptor::DoOpen(OperationEnvironment &env)
{
assert(config.IsAvailable());
{
ScopeLock protect(mutex);
error_message.clear();
}
if (config.port_type == DeviceConfig::PortType::INTERNAL)
return OpenInternalSensors();
if (config.port_type == DeviceConfig::PortType::DROIDSOAR_V2)
return OpenDroidSoarV2();
if (config.port_type == DeviceConfig::PortType::I2CPRESSURESENSOR)
return OpenI2Cbaro();
if (config.port_type == DeviceConfig::PortType::NUNCHUCK)
return OpenNunchuck();
if (config.port_type == DeviceConfig::PortType::IOIOVOLTAGE)
return OpenVoltage();
reopen_clock.Update();
Port *port;
try {
port = OpenPort(io_service, config, this, *this);
} catch (const std::runtime_error &e) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
LogError(WideToUTF8Converter(name), e);
StaticString<256> msg;
const UTF8ToWideConverter what(e.what());
if (what.IsValid()) {
ScopeLock protect(mutex);
error_message = what;
}
msg.Format(_T("%s: %s (%s)"), _("Unable to open port"), name,
(const TCHAR *)what);
env.SetErrorMessage(msg);
return false;
}
if (port == nullptr) {
TCHAR name_buffer[64];
const TCHAR *name = config.GetPortName(name_buffer, 64);
StaticString<256> msg;
msg.Format(_T("%s: %s."), _("Unable to open port"), name);
env.SetErrorMessage(msg);
return false;
}
DumpPort *dump_port = new DumpPort(port);
dump_port->Disable();
if (!port->WaitConnected(env) || !OpenOnPort(dump_port, env)) {
if (!env.IsCancelled())
++n_failures;
delete dump_port;
return false;
}
ResetFailureCounter();
return true;
}