本文整理汇总了C++中HANDLE_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ HANDLE_ERROR函数的具体用法?C++ HANDLE_ERROR怎么用?C++ HANDLE_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HANDLE_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkTriggerReady
FlyCaptureError
checkTriggerReady(
FlyCaptureContext context )
{
FlyCaptureError error;
unsigned long ulValue;
//
// Do our check to make sure the camera is ready to be triggered
// by looking at bits 30-31. Any value other than 1 indicates
// the camera is not ready to be triggered.
//
error = flycaptureGetCameraRegister(
context, SOFT_ASYNC_TRIGGER, &ulValue );
HANDLE_ERROR( "flycaptureGetCameraRegister()", error );
while( ulValue != 0x80000001 )
{
error = flycaptureGetCameraRegister(
context, SOFT_ASYNC_TRIGGER, &ulValue );
HANDLE_ERROR( "flycaptureGetCameraRegister()", error );
}
return FLYCAPTURE_OK;
}
示例2: assert
double HackRFSource::set_sample_rate( double rate )
{
assert(this->m_dev != nullptr);
int status = HACKRF_SUCCESS;
double _sample_rates[] = {
8e6,
10e6,
12.5e6,
16e6,
20e6};
bool found_supported_rate = false;
for( unsigned int i = 0; i < sizeof(_sample_rates)/sizeof(double); i++ ) {
if(_sample_rates[i] == rate) {
found_supported_rate = true;
break;
}
}
if (!found_supported_rate) {
status = HACKRF_ERROR_OTHER;
HANDLE_ERROR("Unsupported samplerate: %gMsps", rate/1e6);
}
status = hackrf_set_sample_rate( this->m_dev, rate);
HANDLE_ERROR("Error setting sample rate to %gMsps: %%s\n", rate/1e6);
}
示例3: raise_message
void raise_message(ErrorMode mode,
bool skipTop,
const std::string &msg) {
if (mode == ErrorMode::ERROR) {
HANDLE_ERROR(false, Always, "\nFatal error: ", skipTop);
not_reached();
}
if (mode == ErrorMode::RECOVERABLE_ERROR) {
HANDLE_ERROR(true, IfUnhandled, "\nCatchable fatal error: ", skipTop);
return;
}
if (!g_context->errorNeedsHandling(static_cast<int>(mode), true,
ExecutionContext::ErrorThrowMode::Never)) {
return;
}
if (mode == ErrorMode::WARNING) {
if (RuntimeOption::WarningFrequency <= 0 ||
(g_warning_counter++) % RuntimeOption::WarningFrequency != 0) {
return;
}
HANDLE_ERROR(true, Never, "\nWarning: ", skipTop);
return;
}
if (RuntimeOption::NoticeFrequency <= 0 ||
(g_notice_counter++) % RuntimeOption::NoticeFrequency != 0) {
return;
}
raise_notice_helper(mode, skipTop, msg);
}
示例4: hackrf_start_rx
bool HackRFSource::Start()
{
if (this->m_streamingState != Streaming) {
this->m_streamingState = Streaming;
int status = hackrf_start_rx(this->m_dev,
_hackRF_rx_callback,
(void *)this);
HANDLE_ERROR("Failed to start RX streaming: %%s\n");
uint16_t frequencies[2];
frequencies[0] = this->m_scanStartFrequency;
frequencies[1] = this->m_scanStopFrequency;
status = hackrf_init_sweep(this->m_dev,
frequencies,
1, // num_ranges
this->m_scanNumBytes,
this->m_scanStepWidth, // TUNE_STEP * FREQ_ONE_MHZ,
this->m_scanOffset, // OFFSET,
LINEAR);
HANDLE_ERROR("Failed to set sweep parameters: %%s\n");
}
return true;
}
示例5: HANDLE_ERROR
void glcu::init_cuda()
{
cudaDeviceProp prop = {0};
int dev;
prop.major = 1;
prop.minor = 0;
HANDLE_ERROR(cudaChooseDevice(&dev, &prop));
HANDLE_ERROR(cudaGLSetGLDevice(dev));
}
示例6: HANDLE_ERROR
float gpuNUFFT::GpuNUFFTOperator::stopTiming()
{
float time;
HANDLE_ERROR( cudaEventRecord(stop, 0) );
HANDLE_ERROR( cudaEventSynchronize(stop) );
HANDLE_ERROR( cudaEventElapsedTime(&time, start, stop) );
return time;
}
示例7: get_o_param
void get_o_param(int argc, char **argv, const char *module_getopt_string, const struct option *long_options)
{
/* backup global variables */
int bck_optind = optind, bck_optopt = optopt, bck_opterr = opterr;
char *bck_optarg = optarg;
signed char opt;
// Add "i:" to getopt_string
/* This is necessary because getopt rearragnes arguments in such a way that
all positional agruments (i.e. not options) are put at the end of argv.
If it wouldn't know about "-i" and that it requires argument, it would
move the argument (ifc specifier) to the end of argv (but doesn't move
the "-i").
trap_parse_params (within TRAP_DEFAULT_INITIALIZATION) would than fail.
*/
char *getopt_string_with_i = malloc(strlen(module_getopt_string) + 3);
sprintf(getopt_string_with_i, "%s%s", module_getopt_string, "i:");
opterr = 0; /* disable getopt error output */
while ((opt = TRAP_GETOPT(argc, argv, getopt_string_with_i, long_options)) != -1) {
switch (opt) {
case 'o':
{
char *endptr;
long int tmp_interval;
errno = 0;
tmp_interval = strtol(optarg, &endptr, 0);
if (errno) {
HANDLE_PERROR("-o");
} else if (*optarg == '\0') {
HANDLE_ERROR("-o: missing argument");
} else if (*endptr != '\0') {
HANDLE_ERROR("-o: bad argument");
} else if (tmp_interval <= 0 || tmp_interval >= INTERVAL_LIMIT) {
HANDLE_ERROR("-o: bad interval range");
}
send_interval = tmp_interval;
break;
}
default:
if (optopt == 'o') {
HANDLE_ERROR("-o: missing argument");
}
break;
}
}
free(getopt_string_with_i);
/* restore global variables */
optind = bck_optind;
optopt = bck_optopt;
opterr = bck_opterr;
optarg = bck_optarg;
}
示例8: hackrf_stop_rx
HackRFSource::~HackRFSource()
{
if (this->m_dev != nullptr) {
int status = hackrf_stop_rx(this->m_dev);
double centerFrequency = this->GetCurrentFrequency();
HANDLE_ERROR("Failed to stop RX streaming at %u: %%s\n", centerFrequency);
status = hackrf_close(this->m_dev);
HANDLE_ERROR("Error closing hackrf: %%s\n");
}
}
示例9: HANDLE_ERROR
/*
* Initialize an OS timer. The initialization steps are:
*
* create priority queue
* install signal handler
*
* We also initialize the timer_block_mask if it has not been initialized yet.
*/
ostimer_s *__ostimer_init(timer_s *tp, enum timer_types type)
{
#ifndef NO_POSIX_SIGS
struct sigaction sa ;
#else
struct sigvec sv ;
#endif
ostimer_s *otp ;
struct timer_q *tqp ;
/*
* Find the corresponding ostimer
*/
if ( ( otp = ostimer_find( type ) ) == OSTIMER_NULL )
HANDLE_ERROR( tp->t_flags, OSTIMER_NULL,
tp->t_errnop, TIMER_ENOTAVAILABLE,
"TIMER __ostimer_init: requested timer type not available\n" ) ;
/*
* We use the value of ost_timerq to determine if the os_timer
* has been initialized.
*/
tqp = &otp->ost_timerq ;
if ( tqp->tq_handle )
return( otp ) ;
tqp->tq_handle = pq_create( time_compare,
tp->t_flags & TIMER_RETURN_ERROR ? PQ_RETURN_ERROR : PQ_NOFLAGS,
&tqp->tq_errno ) ;
if ( tqp->tq_handle == NULL )
{
*tp->t_errnop = TIMER_ENOMEM ;
return( OSTIMER_NULL ) ;
}
if ( ! timer_block_mask_set )
set_timer_block_mask() ;
#ifndef NO_POSIX_SIGS
sa.sa_handler = otp->ost_handler ;
sa.sa_mask = timer_block_mask ;
sa.sa_flags = 0 ;
if ( sigaction( otp->ost_signal, &sa, SIGACTION_NULL ) == -1 )
#else
sv.sv_handler = otp->ost_handler ;
sv.sv_mask = timer_block_mask ;
sv.sv_flags = 0 ;
if ( sigvec( otp->ost_signal, &sv, SIGVEC_NULL ) == -1 )
#endif
HANDLE_ERROR( tp->t_flags, OSTIMER_NULL, tp->t_errnop, TIMER_ESIGPROBLEM,
"TIMER __ostimer_init: signal handler installation failed\n" ) ;
return( otp ) ;
}
示例10: while
void SwiftReader::readResults(QTextStream& stream)
{
QString line;
int lineNum = 0;
while (!stream.atEnd())
{
line = stream.readLine();
++lineNum;
if (lineParser.exactMatch(line))
{
QStringList decimals = lineParser.capturedTexts();
Orbit d;
bool ok = true;
#define HANDLE_ERROR(index) \
if (!ok) { \
std::ostringstream os; \
os << "Could not decode decimal " << decimals.at(index).toAscii().data(); \
throw std::runtime_error(os.str()); \
}
d.time = decimals.at(1).toDouble(&ok); HANDLE_ERROR(1);
d.particleID = decimals.at(2).toDouble(&ok); HANDLE_ERROR(2);
d.axis = decimals.at(3).toDouble(&ok) * 25559; HANDLE_ERROR(3);
d.e = decimals.at(4).toDouble(&ok); HANDLE_ERROR(4);
d.i = decimals.at(5).toDouble(&ok); HANDLE_ERROR(5);
d.Omega = decimals.at(6).toDouble(&ok); HANDLE_ERROR(6);
d.w = decimals.at(7).toDouble(&ok); HANDLE_ERROR(7);
d.f = decimals.at(8).toDouble(&ok); HANDLE_ERROR(8);
d.hasOrbEls = true;
data[d.particleID].push_back(d);
}
}
}
示例11: checkSoftwareTriggerPresence
//=============================================================================
// Function Definitions
//=============================================================================
FlyCaptureError
checkSoftwareTriggerPresence(
FlyCaptureContext context,
unsigned int uiRegister )
{
FlyCaptureError error;
unsigned long ulValue;
switch( uiRegister )
{
case SOFT_ASYNC_TRIGGER:
error = flycaptureGetCameraRegister(
context, SOFT_ASYNC_TRIGGER, &ulValue );
HANDLE_ERROR( "flycaptureGetCameraRegister()", error );
//
// Check the Presence_Inq field of the register; bit 0 == 1 indicates
// presence of this feature.
//
if( ( ulValue & 0x80000000 ) == 0x80000000 )
{
return FLYCAPTURE_OK;
}
else
{
return FLYCAPTURE_NOT_IMPLEMENTED;
}
case SOFTWARE_TRIGGER:
error = flycaptureGetCameraRegister(
context, TRIGGER_INQ, &ulValue );
HANDLE_ERROR( "flycaptureGetCameraRegister()", error );
//
// Check the Software_Trigger_Inq field of the register; bit 15 == 1
// indicates presence of this feature.
//
if( ( ulValue & 0x10000 ) == 0x10000 )
{
return FLYCAPTURE_OK;
}
else
{
return FLYCAPTURE_NOT_IMPLEMENTED;
}
default:
return FLYCAPTURE_INVALID_ARGUMENT;
}
}
示例12: while
void HackRFSource::ThreadWorker()
{
while (true) {
StreamingState state = this->m_streamingState;
switch (state) {
case Streaming:
case Done:
break;
case DoRetune:
{
double nextFrequency = this->GetNextFrequency();
this->Retune(nextFrequency);
this->m_didRetune = true;
//struct timeval increment = {0, 5000}, currentTime;
//gettimeofday(¤tTime, nullptr);
//timeradd(¤tTime, &increment, &this->m_nextValidStreamTime);
this->m_dropPacketCount = ceil(this->m_sampleRate * this->m_retuneTime / 131072);
StreamingState expected = DoRetune;
while (!this->m_streamingState.compare_exchange_strong(expected, Streaming)) {
}
}
break;
}
if (state == Done) {
break;
}
}
int status = hackrf_stop_rx(this->m_dev);
HANDLE_ERROR("Failed to stop RX streaming: %%s\n");
}
示例13: main
int main(int argc, char** argv)
{
if (Device::isCuda())
{
gpu::GLUTImageViewers::init(argc, argv);
// Device::printAll();
Device::printAllSimple();
// Server Cuda1: in [0,5]
// Server Cuda2: in [0,2]
int deviceId = 0;
initCuda(deviceId);
int isOk = start();
//cudaDeviceReset causes the driver to clean up all state.
// While not mandatory in normal operation, it is good practice.
HANDLE_ERROR(cudaDeviceReset());
return isOk;
}
else
{
return EXIT_FAILURE;
}
}
示例14: testConnection
int64_t PDOPgSqlConnection::doer(const String& sql){
testConnection();
const char* query = sql.data();
PQ::Result res = m_server->exec(query);
if(!res){
// I think this error should be handled in a different way perhaps?
handleError(nullptr, "XX000", "Invalid result data");
return -1;
}
ExecStatusType status = m_lastExec = res.status();
int64_t ret;
if(status == PGRES_COMMAND_OK){
ret = (int64_t)res.cmdTuples();
} else if(status == PGRES_TUPLES_OK) {
ret = 0L;
} else {
HANDLE_ERROR(nullptr, res);
return -1L;
}
this->pgoid = res.oidValue();
return ret;
}
示例15: obs_register_encoder_s
void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
{
if (find_encoder(info->id)) {
encoder_warn("Encoder id '%s' already exists! "
"Duplicate library?", info->id);
goto error;
}
#define CHECK_REQUIRED_VAL_(info, val, func) \
CHECK_REQUIRED_VAL(struct obs_encoder_info, info, val, func)
CHECK_REQUIRED_VAL_(info, get_name, obs_register_encoder);
CHECK_REQUIRED_VAL_(info, create, obs_register_encoder);
CHECK_REQUIRED_VAL_(info, destroy, obs_register_encoder);
CHECK_REQUIRED_VAL_(info, encode, obs_register_encoder);
if (info->type == OBS_ENCODER_AUDIO)
CHECK_REQUIRED_VAL_(info, get_frame_size, obs_register_encoder);
#undef CHECK_REQUIRED_VAL_
REGISTER_OBS_DEF(size, obs_encoder_info, obs->encoder_types, info);
return;
error:
HANDLE_ERROR(size, obs_encoder_info, info);
}