本文整理汇总了C++中report_error函数的典型用法代码示例。如果您正苦于以下问题:C++ report_error函数的具体用法?C++ report_error怎么用?C++ report_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了report_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idle_report_error
/**
* We need to report error in idle moment
* since we can't report_error before gtk_main is called.
* This function is attached via g_idle_add() in init_libnotify().
*
* @param data passed to the function,
* set when the source was created
* @return FALSE if the source should be removed,
* TRUE otherwise
*/
static gboolean idle_report_error(gpointer data) {
report_error("Unable to initialize libnotify. Notifications will not be sent");
return FALSE;
}
示例2: print_kmer_stats
static void print_kmer_stats()
{
char num_str[50];
if(num_of_all_zero_kmers > 1)
{
report_error("%s all-zero-kmers seen\n",
ulong_to_str(num_of_all_zero_kmers, num_str));
}
if(num_of_oversized_kmers > 0)
{
report_error("%s oversized kmers seen\n",
ulong_to_str(num_of_oversized_kmers, num_str));
}
if(num_of_zero_covg_kmers > 0)
{
report_warning("%s kmers have no coverage in any colour\n",
ulong_to_str(num_of_zero_covg_kmers, num_str));
}
if((print_kmers || parse_kmers) && print_info)
{
printf("kmers read: %s\n", ulong_to_str(num_of_kmers_read, num_str));
printf("covgs read: %s\n", ulong_to_str(sum_of_covgs_read, num_str));
printf("seq loaded: %s\n", ulong_to_str(sum_of_seq_loaded, num_str));
}
if(print_info)
{
// Memory calculations
// use expected number of kmers if we haven't read the whole file
unsigned long kmer_count
= (print_kmers || parse_kmers ? num_of_kmers_read : expected_num_of_kmers);
// Number of hash table entries is 2^mem_height * mem_width
// Aim for 80% occupancy once loaded
float extra_space = 10.0/8;
unsigned long hash_capacity = extra_space * kmer_count;
// mem_width must be within these boundaries
unsigned int min_mem_width = 5;
unsigned int max_mem_width = 50;
unsigned int min_mem_height = 12;
// min mem usage = 2^12 * 5 = 20,480 entries = 320.0 KB with k=31,cols=1
unsigned long mem_height = min_mem_height;
unsigned long mem_width = max_mem_width;
unsigned long hash_entries = (0x1UL << mem_height) * mem_width;
if(hash_capacity > hash_entries)
{
// Resize
mem_height = Log2((double)hash_capacity / (max_mem_width-1))+0.99;
mem_height = MIN2(mem_height, 32);
mem_height = MAX2(mem_height, min_mem_height);
mem_width = hash_capacity / (0x1UL << mem_height) + 1;
printf("mem_width: %lu; mem_height: %lu;\n", mem_width, mem_height);
if(mem_width < min_mem_width)
{
// re-calculate mem_height
mem_height = Log2((double)hash_capacity / min_mem_width)+0.99;
mem_height = MIN2(mem_height, 32);
mem_height = MAX2(mem_height, min_mem_height);
mem_width = hash_capacity / (0x1UL << mem_height) + 1;
mem_width = MAX2(mem_width, min_mem_width);
}
hash_entries = (0x1UL << mem_height) * mem_width;
}
char min_mem_required[50];
char rec_mem_required[50];
set_memory_required_str(kmer_count, min_mem_required);
set_memory_required_str(hash_entries, rec_mem_required);
printf("Memory required: %s\n", min_mem_required);
printf("Memory suggested: --mem_width %lu --mem_height %lu\n",
mem_width, mem_height);
char hash_entries_numstr[50];
ulong_to_str(hash_entries, hash_entries_numstr);
printf(" [%s entries; %s memory]\n", hash_entries_numstr, rec_mem_required);
}
}
示例3: main
main()
{
int sts, i, zro=0;
OM_S_OBJID a_objid[MAXA], b_objid[MAXB], c_objid;
OM_S_OBJID resa_objid[MAXA], resb_objid[MAXB], c2_objid;
OM_S_CHANNUM chan_a, chan_b;
OM_S_CHANNUM chan_resa, chan_resb;
uword count, siz;
char *chan_acany,*chan_acbc,*chan_acb,*chan_bca;
char *chan_sbca;
char *chan_resacany,*chan_resacbc,*chan_resacb,*chan_resbca;
char *chan_sca;
OM_S_CHANSELECT chansel;
int relindex=0, to=0, from=0;
OM_S_MESSAGE showb,showresb,connect_msg,move_chan_msg;
uword OSnum;
uword minorchan=0;
struct connect_struct
{
OM_S_CHANSELECT to_sel;
int to_idx;
OM_S_OBJID fr_objid;
uword fr_os;
OM_S_CHANSELECT fr_sel;
int fr_idx;
} connect_args;
struct move_chan_struct
{
OM_S_CHANSELECT to_sel;
OM_S_OBJID fr_objid;
OMuword fr_os;
OM_S_CHANSELECT fr_sel;
} move_chan_args;
sts = om$runtime_init();
if (!(sts&1))
{
printf (" error in om%runtine_init\n" );
om$report_error(sts = sts);
exit();
}
OSnum = OM_Gw_TransOSnum_0;
chan_acb = "A.acb";
chan_acany = "A.acany";
chan_acbc = "A.acbc";
chan_bca = "B.bca";
chan_sbca = "C.sbca";
for ( i=0; i<MAXA; i++ )
{
sts = om$construct(osname = "OM_TransOS_0",
classname = "A",
p_objid = &a_objid[i],
neighbor = OM_GS_NULL_NEIGHBOR);
if (!(sts&1))
{
printf (" error in om$construct for A\n" );
om$report_error(sts = sts);
printf (" iteration : %d \n", i );
exit();
}
}
sts = om$get_channel_number(channame = "A.acb",
p_channum = &chan_a );
if (!(sts&1))
{
printf (" error in om$get channel_number for acb\n" );
om$report_error(sts = sts);
exit();
}
sts = om$get_channel_number(channame = "B.bca",
p_channum = &chan_b );
if (!(sts&1))
{
printf (" error in om$get_channel_number for bca\n" );
om$report_error(sts = sts);
exit();
}
for ( i=0; i<MAXB; i++ )
{
sts = om$construct(osname = "OM_TransOS_0",
classname = "B",
p_objid = &b_objid[i],
neighbor = OM_GS_NULL_NEIGHBOR);
if (!(sts&1))
{
printf (" error in om$construct for B\n" );
om$report_error(sts = sts);
printf (" iteration : %d \n", i );
exit();
}
} /* for */
//.........这里部分代码省略.........
示例4: printf
bool SwapEnds::move(VRP *V, int a, int v)
{
///
/// This function takes the routes corresponding to nodes a and v
/// and swaps the ends of these routes following a and v respectively.
/// Example: VRPH_DEPOT-i-a-j-k-l-VRPH_DEPOT and VRPH_DEPOT-t-u-v-x-y-z-VRPH_DEPOT becomes
/// VRPH_DEPOT-i-a-x-y-z-VRPH_DEPOT and VRPH_DEPOT-t-u-v-j-k-l-VRPH_DEPOT.
/// If the proposed move is feasible, all solution modifications
/// are made, and the function returns true. Returns false if the move
/// is infeasible.
///
VRPMove M;
if(evaluate(V,a,v,&M)==false)
return false; // move is infeasible
int current_node, a_start, a_end, v_start, v_end;
int route_after_a, route_before_a, route_before_v, route_after_v;
int n, u, b;
#if SWAP_ENDS_DEBUG>0
printf("Calling swap ends(%d,%d)\n",a,v);
#endif
if(a==VRPH_DEPOT || v==VRPH_DEPOT)
report_error("%s: Swap ends called with depot; Move doesn't make sense\n",__FUNCTION__);
n = V->num_nodes;
if(V->route_num[a] == V->route_num[v])
report_error("%s: swap ends called with a and v in same route!\n",__FUNCTION__);
#if SWAP_VERIFY
V->verify_routes("SWAP_ENDS::prior to move\n");
#endif
V->update(&M);
a_end = V->route[V->route_num[a]].end;
a_start = V->route[V->route_num[a]].start;
route_after_a = V->route_num[-V->next_array[a_end]];
route_before_a = V->route_num[-V->pred_array[a_start]];
v_end = V->route[V->route_num[v]].end;
v_start = V->route[V->route_num[v]].start;
route_after_v = V->route_num[-V->next_array[v_end]];
route_before_v = V->route_num[-V->pred_array[v_start]];
u = V->next_array[v];
b = V->next_array[a];
if(u==VRPH_DEPOT || b==VRPH_DEPOT)
{
report_error("%s: u=0 or b=0 in swap_ends\n",__FUNCTION__);
}
if(u>0 && b>0)
{
V->next_array[a]=u;
V->pred_array[u]=a;
V->next_array[v]=b;
V->pred_array[b]=v;
}
else
{
if(u>0 && b<0)
{
V->next_array[a]=u;
V->pred_array[u]=a;
V->next_array[v]=b;
V->pred_array[-b]=-v;
}
else
{
if(u<0 && b>0)
{
V->next_array[a]=u;
V->pred_array[-u]=-a;
V->next_array[v]=-b;
V->pred_array[b]=v;
}
else
report_error("%s: Reached strange place...\n",__FUNCTION__);
}
}
// Now update the start, end, length, and load info for V->route_num[a] and V->route_num[v]
//.........这里部分代码省略.........
示例5: debug_status_message
std::pair<double, double> BinomialLogitPartialAugmentationDataImputer::impute(
RNG &rng, double number_of_trials, double number_of_successes,
double linear_predictor) const {
if (number_of_successes > number_of_trials) {
ostringstream err;
err << "The number of successes must not exceed the number of trials "
<< "in BinomialLogitPartialAugmentationDataImputer::impute()."
<< endl;
debug_status_message(err, number_of_trials, number_of_successes,
linear_predictor);
report_error(err.str());
}
if (number_of_successes < 0 || number_of_trials < 0) {
ostringstream err;
err << "The number of successes and the number of trials must both "
<< "be non-negative in "
<< "BinomialLogitPartialAugmentationDataImputer::impute()." << endl;
debug_status_message(err, number_of_trials, number_of_successes,
linear_predictor);
report_error(err.str());
}
double information_weighted_sum = 0;
double information = 0;
if (number_of_trials < clt_threshold_) {
for (int i = 0; i < number_of_trials; ++i) {
bool success = i < number_of_successes;
double latent_logit = rtrun_logit_mt(rng, linear_predictor, 0, success);
// mu is unused because the mixture is a scale-mixture only,
// but we need it for the API.
double mu, sigsq;
mixture_approximation.unmix(rng, latent_logit - linear_predictor, &mu,
&sigsq);
double current_weight = 1.0 / sigsq;
information += current_weight;
information_weighted_sum += latent_logit * current_weight;
}
} else {
// Large sample case. There are number_of_successes draws from
// the positive side, and number_of_trials - number_of_successes
// draws from the negative side.
double mean_of_logit_sum = 0;
double variance_of_logit_sum = 0;
if (number_of_successes > 0) {
mean_of_logit_sum +=
number_of_successes * trun_logit_mean(linear_predictor, 0, true);
variance_of_logit_sum += number_of_successes *
trun_logit_variance(linear_predictor, 0, true);
}
double number_of_failures = number_of_trials - number_of_successes;
if (number_of_failures > 0) {
mean_of_logit_sum +=
number_of_failures * trun_logit_mean(linear_predictor, 0, false);
variance_of_logit_sum +=
number_of_failures *
trun_logit_variance(linear_predictor, 0, false);
}
// The information_weighted_sum is the sum of the latent logits
// (approximated by a normal), divided by the weight that each
// term in the sum recieves (the variance of the logistic
// distribution, pi^2/3).
information_weighted_sum =
rnorm_mt(rng, mean_of_logit_sum, sqrt(variance_of_logit_sum));
information_weighted_sum /= Constants::pi_squared_over_3;
// Each latent logit carries the same amount of information:
// 1/pi_squared_over_3.
information = number_of_trials / Constants::pi_squared_over_3;
}
return std::make_pair(information_weighted_sum, information);
}
示例6: check_params
/*! \brief
* Checks the validity of parameters.
*
* \param[in] fp File handle to use for diagnostic messages
* (can be NULL).
* \param[in] name Name of the method (used for error messages).
* \param[in] nparams Number of parameters in \p param.
* \param[in,out] param Parameter array
* (only the \c flags field of boolean parameters may be modified).
* \param[in] symtab Symbol table (used for checking overlaps).
* \returns true if there are no problems with the parameters,
* false otherwise.
*
* This function performs some checks common to both check_method() and
* check_modifier().
* The purpose of these checks is to ensure that the selection parser does not
* need to check for the validity of the parameters at each turn, and to
* report programming errors as early as possible.
* If you remove a check, make sure that the parameter parser can handle the
* resulting parameters.
*/
static bool
check_params(FILE *fp, const char *name, int nparams, gmx_ana_selparam_t param[],
const gmx::SelectionParserSymbolTable &symtab)
{
bool bOk = true;
int i, j;
if (nparams > 0 && !param)
{
report_error(fp, name, "error: missing parameter data");
return false;
}
if (nparams == 0 && param)
{
report_error(fp, name, "warning: parameter data unused because nparams=0");
}
/* Check each parameter */
for (i = 0; i < nparams; ++i)
{
/* Check that there is at most one NULL name, in the beginning */
if (param[i].name == NULL && i > 0)
{
report_error(fp, name, "error: NULL parameter should be the first one");
bOk = false;
continue;
}
/* Check for duplicates */
for (j = 0; j < i; ++j)
{
if (param[j].name == NULL)
{
continue;
}
if (!gmx_strcasecmp(param[i].name, param[j].name))
{
report_error(fp, name, "error: duplicate parameter name '%s'", param[i].name);
bOk = false;
break;
}
}
/* Check flags */
if (param[i].flags & SPAR_SET)
{
report_param_error(fp, name, param[i].name, "warning: flag SPAR_SET is set");
param[i].flags &= ~SPAR_SET;
}
if (param[i].flags & SPAR_RANGES)
{
if (param[i].val.type != INT_VALUE && param[i].val.type != REAL_VALUE)
{
report_param_error(fp, name, param[i].name, "error: SPAR_RANGES cannot be set for a non-numeric parameter");
bOk = false;
}
if (param[i].flags & SPAR_DYNAMIC)
{
report_param_error(fp, name, param[i].name, "warning: SPAR_DYNAMIC does not have effect with SPAR_RANGES");
param[i].flags &= ~SPAR_DYNAMIC;
}
if (!(param[i].flags & SPAR_VARNUM) && param[i].val.nr != 1)
{
report_param_error(fp, name, param[i].name, "error: range should take either one or an arbitrary number of values");
bOk = false;
}
if (param[i].flags & SPAR_ATOMVAL)
{
report_param_error(fp, name, param[i].name, "error: SPAR_RANGES and SPAR_ATOMVAL both set");
bOk = false;
}
}
if ((param[i].flags & SPAR_VARNUM) && (param[i].flags & SPAR_ATOMVAL))
{
report_param_error(fp, name, param[i].name, "error: SPAR_VARNUM and SPAR_ATOMVAL both set");
bOk = false;
}
if (param[i].flags & SPAR_ENUMVAL)
{
if (param[i].val.type != STR_VALUE)
{
report_param_error(fp, name, param[i].name, "error: SPAR_ENUMVAL can only be set for string parameters");
//.........这里部分代码省略.........
示例7: __init_cobalt
static __libcobalt_ctor void __init_cobalt(void)
{
pthread_t ptid = pthread_self();
struct sched_param parm;
int policy, ret;
const char *p;
p = getenv("XENO_CONFIG_OUTPUT");
if (p && *p) {
dump_configuration();
_exit(0);
}
#ifndef CONFIG_SMP
ret = get_static_cpu_count();
if (ret > 0)
report_error("running non-SMP libraries on SMP kernel?");
#endif
__cobalt_main_ptid = ptid;
cobalt_default_mutexattr_init();
cobalt_default_condattr_init();
if (__cobalt_defer_init)
return;
__libcobalt_init();
if (__cobalt_no_shadow)
return;
p = getenv("XENO_NOSHADOW");
if (p && *p)
return;
ret = __STD(pthread_getschedparam(ptid, &policy, &parm));
if (ret) {
report_error("pthread_getschedparam: %s", strerror(ret));
exit(EXIT_FAILURE);
}
/*
* Switch the main thread to a Xenomai shadow.
* __cobalt_main_prio might have been overriden by
* some compilation unit which has been linked in, to force
* the scheduling parameters. Otherwise, the current policy
* and priority are reused, for declaring the thread to the
* Xenomai scheduler.
*
* SCHED_FIFO is assumed for __cobalt_main_prio > 0.
*/
if (__cobalt_main_prio > 0) {
policy = SCHED_FIFO;
parm.sched_priority = __cobalt_main_prio;
} else if (__cobalt_main_prio == 0) {
policy = SCHED_OTHER;
parm.sched_priority = 0;
}
ret = __RT(pthread_setschedparam(ptid, policy, &parm));
if (ret) {
report_error("pthread_setschedparam: %s", strerror(ret));
exit(EXIT_FAILURE);
}
}
示例8: report_error
double VRP::SA_solve(int heuristics, double start_temp, double cool_ratio,
int iters_per_loop, int num_loops, int nlist_size, bool verbose)
{
///
/// Uses the given parameters to generate a VRP solution using Simulated Annealing.
/// Assumes that data has already been imported into V and that we have
/// some existing solution. Returns the total route length of the best solution found.
///
this->temperature = start_temp;
this->cooling_ratio = cool_ratio;
int ctr, n, j, i, R, rules, random, fixed, neighbor_list, objective;
if(heuristics & VRPH_RANDOMIZED)
random=VRPH_RANDOMIZED;
else
random=0;
if(heuristics & VRPH_FIXED_EDGES)
fixed=VRPH_FIXED_EDGES;
else
fixed=0;
if(heuristics & VRPH_USE_NEIGHBOR_LIST)
neighbor_list=VRPH_USE_NEIGHBOR_LIST;
else
neighbor_list=0;
objective=VRPH_SAVINGS_ONLY;
// default strategy
if(heuristics & VRPH_MINIMIZE_NUM_ROUTES)
objective=VRPH_MINIMIZE_NUM_ROUTES;
n=num_nodes;
// The perm[] array will contain all the nodes in the current solution
int *perm;
perm=new int[this->num_nodes];
j=VRPH_ABS(this->next_array[VRPH_DEPOT]);
for(i=0;i<this->num_nodes;i++)
{
perm[i]=j;
if(!routed[j])
report_error("%s: Unrouted node in solution!!\n");
j=VRPH_ABS(this->next_array[j]);
}
if(j!=VRPH_DEPOT)
report_error("%s: VRPH_DEPOT is not last node in solution!!\n");
// Define the heuristics we may use
OnePointMove OPM;
TwoPointMove TPM;
TwoOpt TO;
OrOpt OR;
ThreeOpt ThreeO;
CrossExchange CE;
ThreePointMove ThreePM;
double start_val;
this->export_solution_buff(this->best_sol_buff);
// We are assuming we have an existing solution
// Set the neighbor list size used in the improvement search
this->neighbor_list_size=VRPH_MIN(nlist_size, num_nodes);
best_total_route_length=this->total_route_length;
normalize_route_numbers();
ctr=0;
// The idea is to perform num_loops loops of num_iters iterations each.
// For each iteration, run through the given heuristic operation at random
// and perform a Simulated Annealing search.
rules=VRPH_USE_NEIGHBOR_LIST+VRPH_FIRST_ACCEPT+VRPH_SIMULATED_ANNEALING+VRPH_SAVINGS_ONLY;
double worst_obj=0;
for(ctr=0;ctr<num_loops;ctr++)
{
if(verbose)
{
printf("\nctr=%d of %d, temp=%f, obj=%f (overall best=%f; worst=%f)\n",ctr,num_loops,
this->temperature,
this->total_route_length,this->best_total_route_length,worst_obj);
fflush(stdout);
}
// Reset worst_obj;
worst_obj=0;
// Cool it...
this->temperature = this->cooling_ratio * this->temperature;
for(int k=0; k < iters_per_loop; k++)
{
//.........这里部分代码省略.........
示例9: pnt
double pnt(double t, double df, double delta, int lower_tail, int log_p)
{
double a, albeta, b, del, errbd, geven, godd,
lambda, p, q, rxb, s, tnc, tt, x, xeven, xodd;
int it, negdel;
/* note - itrmax and errmax may be changed to suit one's needs. */
const int itrmax = 1000;
const double errmax = 1.e-12;
if (df <= 0.) ML_ERR_return_NAN;
if(!R_FINITE(t))
return (t < 0) ? R_DT_0 : R_DT_1;
if (t >= 0.) {
negdel = false; tt = t; del = delta;
}
else {
negdel = true; tt = -t; del = -delta;
}
if (df > 4e5 || del*del > 2*M_LN2*(-(numeric_limits<double>::min_exponent))) {
/*-- 2nd part: if del > 37.62, then p=0 below
FIXME: test should depend on `df', `tt' AND `del' ! */
/* Approx. from Abramowitz & Stegun 26.7.10 (p.949) */
s = 1./(4.*df);
return pnorm(tt*(1. - s), del, sqrt(1. + tt*tt*2.*s),
lower_tail != negdel, log_p);
}
/* initialize twin series */
/* Guenther, J. (1978). Statist. Computn. Simuln. vol.6, 199. */
x = t * t;
x = x / (x + df);/* in [0,1) */
if (x > 0.) {/* <==> t != 0 */
lambda = del * del;
p = .5 * exp(-.5 * lambda);
if(p == 0.) { /* underflow! */
/*========== really use an other algorithm for this case !!! */
ML_ERROR(ME_UNDERFLOW);
report_error("|delta| too large."); /* |delta| too large */
}
q = M_SQRT_2dPI * p * del;
s = .5 - p;
a = .5;
b = .5 * df;
rxb = pow(1. - x, b);
albeta = M_LN_SQRT_PI + lgammafn(b) - lgammafn(.5 + b);
xodd = pbeta(x, a, b, /*lower*/true, /*log_p*/false);
godd = 2. * rxb * exp(a * log(x) - albeta);
xeven = 1. - rxb;
geven = b * x * rxb;
tnc = p * xodd + q * xeven;
/* repeat until convergence or iteration limit */
for(it = 1; it <= itrmax; it++) {
a += 1.;
xodd -= godd;
xeven -= geven;
godd *= x * (a + b - 1.) / a;
geven *= x * (a + b - .5) / (a + .5);
p *= lambda / (2 * it);
q *= lambda / (2 * it + 1);
tnc += p * xodd + q * xeven;
s -= p;
if(s <= 0.) { /* happens e.g. for (t,df,delta)=(40,10,38.5), after 799 it.*/
ML_ERROR(ME_PRECISION);
goto finis;
}
errbd = 2. * s * (xodd - godd);
if(errbd < errmax) goto finis;/*convergence*/
}
/* non-convergence:*/
ML_ERROR(ME_PRECISION);
}
else { /* x = t = 0 */
tnc = 0.;
}
finis:
tnc += pnorm(- del, 0., 1., /*lower*/true, /*log_p*/false);
lower_tail = lower_tail != negdel; /* xor */
return R_DT_val(tnc);
}
示例10: plan
int plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer)
{
struct sample *sample;
int po2;
int transitiontime, gi;
int current_cylinder;
unsigned int stopidx;
int depth;
double tissue_tolerance = 0.0;
struct gaschanges *gaschanges = NULL;
int gaschangenr;
int *stoplevels = NULL;
char *trial_cache = NULL;
bool stopping = false;
bool clear_to_ascend;
int clock, previous_point_time;
int avg_depth, bottom_time = 0;
int last_ascend_rate;
int best_first_ascend_cylinder;
struct gasmix gas;
int o2time = 0;
int breaktime = -1;
int breakcylinder = 0;
int error = 0;
set_gf(diveplan->gflow, diveplan->gfhigh, prefs.gf_low_at_maxdepth);
if (!diveplan->surface_pressure)
diveplan->surface_pressure = SURFACE_PRESSURE;
create_dive_from_plan(diveplan, is_planner);
/* Let's start at the last 'sample', i.e. the last manually entered waypoint. */
sample = &displayed_dive.dc.sample[displayed_dive.dc.samples - 1];
get_gas_at_time(&displayed_dive, &displayed_dive.dc, sample->time, &gas);
po2 = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].po2.mbar;
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
current_cylinder = 0;
}
depth = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].depth.mm;
avg_depth = average_depth(diveplan);
last_ascend_rate = ascend_velocity(depth, avg_depth, bottom_time);
/* if all we wanted was the dive just get us back to the surface */
if (!is_planner) {
transitiontime = depth / 75; /* this still needs to be made configurable */
plan_add_segment(diveplan, transitiontime, 0, gas, po2, false);
create_dive_from_plan(diveplan, is_planner);
return(error);
}
tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap);
#if DEBUG_PLAN & 4
printf("gas %s\n", gasname(&gas));
printf("depth %5.2lfm \n", depth / 1000.0);
#endif
best_first_ascend_cylinder = current_cylinder;
/* Find the gases available for deco */
gaschanges = analyze_gaslist(diveplan, &gaschangenr, depth, &best_first_ascend_cylinder);
/* Find the first potential decostopdepth above current depth */
for (stopidx = 0; stopidx < sizeof(decostoplevels) / sizeof(int); stopidx++)
if (decostoplevels[stopidx] >= depth)
break;
if (stopidx > 0)
stopidx--;
/* Stoplevels are either depths of gas changes or potential deco stop depths. */
stoplevels = sort_stops(decostoplevels, stopidx + 1, gaschanges, gaschangenr);
stopidx += gaschangenr;
/* Keep time during the ascend */
bottom_time = clock = previous_point_time = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].time.seconds;
gi = gaschangenr - 1;
if (best_first_ascend_cylinder != current_cylinder) {
stopping = true;
current_cylinder = best_first_ascend_cylinder;
gas = displayed_dive.cylinder[current_cylinder].gasmix;
#if DEBUG_PLAN & 16
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", best_first_ascend_cylinder,
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[best_first_ascend_cylinder].depth / 1000.0);
#endif
}
while (1) {
/* We will break out when we hit the surface */
do {
/* Ascend to next stop depth */
int deltad = ascend_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
if (ascend_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
plan_add_segment(diveplan, clock - previous_point_time, depth, gas, po2, false);
previous_point_time = clock;
stopping = false;
last_ascend_rate = ascend_velocity(depth, avg_depth, bottom_time);
}
if (depth - deltad < stoplevels[stopidx])
deltad = depth - stoplevels[stopidx];
tissue_tolerance = add_segment(depth_to_mbar(depth, &displayed_dive) / 1000.0,
//.........这里部分代码省略.........
示例11: create_dive_from_plan
//.........这里部分代码省略.........
int lastdepth = 0;
if (!diveplan || !diveplan->dp)
return;
#if DEBUG_PLAN & 4
printf("in create_dive_from_plan\n");
dump_plan(diveplan);
#endif
// reset the cylinders and clear out the samples and events of the
// displayed dive so we can restart
reset_cylinders(&displayed_dive, track_gas);
dc = &displayed_dive.dc;
dc->when = displayed_dive.when = diveplan->when;
free(dc->sample);
dc->sample = NULL;
dc->samples = 0;
dc->alloc_samples = 0;
while ((ev = dc->events)) {
dc->events = dc->events->next;
free(ev);
}
dp = diveplan->dp;
cyl = &displayed_dive.cylinder[0];
oldgasmix = cyl->gasmix;
sample = prepare_sample(dc);
sample->po2.mbar = dp->po2;
if (track_gas && cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->end.mbar;
sample->manually_entered = true;
finish_sample(dc);
while (dp) {
struct gasmix gasmix = dp->gasmix;
int po2 = dp->po2;
int time = dp->time;
int depth = dp->depth;
if (time == 0) {
/* special entries that just inform the algorithm about
* additional gases that are available */
if (verify_gas_exists(gasmix) < 0)
goto gas_error_exit;
dp = dp->next;
continue;
}
/* Check for SetPoint change */
if (oldpo2 != po2) {
if (lasttime)
/* this is a bad idea - we should get a different SAMPLE_EVENT type
* reserved for this in libdivecomputer... overloading SMAPLE_EVENT_PO2
* with a different meaning will only cause confusion elsewhere in the code */
add_event(dc, lasttime, SAMPLE_EVENT_PO2, 0, po2, "SP change");
oldpo2 = po2;
}
/* Make sure we have the new gas, and create a gas change event */
if (gasmix_distance(&gasmix, &oldgasmix) > 0) {
int idx;
if ((idx = verify_gas_exists(gasmix)) < 0)
goto gas_error_exit;
/* need to insert a first sample for the new gas */
add_gas_switch_event(&displayed_dive, dc, lasttime + 1, idx);
cyl = &displayed_dive.cylinder[idx];
sample = prepare_sample(dc);
sample[-1].po2.mbar = po2;
sample->time.seconds = lasttime + 1;
sample->depth.mm = lastdepth;
sample->manually_entered = dp->entered;
if (track_gas && cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->sample_end.mbar;
finish_sample(dc);
oldgasmix = gasmix;
}
/* Create sample */
sample = prepare_sample(dc);
/* set po2 at beginning of this segment */
/* and keep it valid for last sample - where it likely doesn't matter */
sample[-1].po2.mbar = po2;
sample->po2.mbar = po2;
sample->time.seconds = lasttime = time;
sample->depth.mm = lastdepth = depth;
sample->manually_entered = dp->entered;
if (track_gas) {
update_cylinder_pressure(&displayed_dive, sample[-1].depth.mm, depth, time - sample[-1].time.seconds,
dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered);
if (cyl->type.workingpressure.mbar)
sample->cylinderpressure.mbar = cyl->end.mbar;
}
finish_sample(dc);
dp = dp->next;
}
#if DEBUG_PLAN & 32
save_dive(stdout, &displayed_dive);
#endif
return;
gas_error_exit:
report_error(translate("gettextFromC", "Too many gas mixes"));
return;
}
示例12: go
static void go(char *lang1, char *lang2,
char *lexfile1, char *dicfile1,
char *lexfile2, char *dicfile2,
char *outfile) {
Words *lex1, *lex2;
wchar_t *string1 = NULL;
wchar_t *string2 = NULL;
nat_uint32_t ptr1 = 0;
nat_uint32_t ptr2 = 0;
nat_uint32_t size1, size2;
NATCell *cells1 = NULL;
NATCell *cells2 = NULL;
nat_uint32_t cellptr1 = 0;
nat_uint32_t cellptr2 = 0;
nat_uint32_t *tab1 = NULL;
nat_uint32_t *tab2 = NULL;
/* ---- First ------------------------------- */
lex1 = words_quick_load(lexfile1);
if (!lex1) { fprintf(stderr, "Error loading lexicon 1\n"); exit(1); }
size1 = 11 * lex1->count;
string1 = g_new0(wchar_t, size1);
if (!string1) { fprintf(stderr, "Error allocating string1\n"); exit(1); }
cells1 = g_new0(NATCell, lex1->count + 1);
if (!cells1) { fprintf(stderr, "Error allocating cells1\n"); exit(1); }
tab1 = g_new0(nat_uint32_t, lex1->count + 1);
if (!tab1) { fprintf(stderr, "Error allocating tab1\n"); exit(1); }
tab1[0] = tab1[1] = lex1->count-1;
ptr1 = tree_to_array(lex1->count,string1, cells1, lex1->tree, ptr1, size1, &cellptr1, tab1);
cells1[cellptr1].offset = ptr1;
cells1[cellptr1].count = 0;
cells1[cellptr1].id = cellptr1;
cellptr1++;
g_message("** Preparing source Lexicon **");
g_message("\tPtr is at %u and original size was %u", ptr1, size1);
g_message("\tOffset on the array is %u", cellptr1);
g_message("\tNULL is pointing to %u", tab1[0]);
/* ---- Second ------------------------------ */
lex2 = words_quick_load(lexfile2);
if (!lex2) report_error("Error loading lexicon 2\n");
size2 = 11*lex2->count;
string2 = g_new0(wchar_t, size2);
if (!string2) report_error("Error allocating string2\n");
cells2 = g_new0(NATCell, lex2->count+1);
if (!cells2) report_error("Error allocating cells2\n");
tab2 = g_new0(nat_uint32_t, lex2->count+1);
if (!tab2) report_error("Error allocating tab2\n");
tab2[0] = tab2[1] = lex2->count-1;
ptr2 = tree_to_array(lex2->count,string2, cells2, lex2->tree, ptr2, size2, &cellptr2, tab2);
cells2[cellptr2].offset = ptr2;
cells2[cellptr2].count = 0;
cells2[cellptr2].id = cellptr2;
cellptr2++;
g_message("** Preparing target Lexicon **");
g_message("\tPtr is at %u and original size was %u", ptr2, size2);
g_message("\tOffset on the array is %u", cellptr2);
g_message("\tNULL is pointing to %u", tab2[0]);
save(outfile,
lang1, lang2,
dicfile1, tab1, dicfile2, tab2,
string1, ptr1, cells1, cellptr1,
string2, ptr2, cells2, cellptr2);
/* save(outfile, lang1, lang2,
dicfile1, tab1, dicfile2, tab2,
string1, ptr1, cells1, lex1->count,
string2, ptr2, cells2, lex2->count); */
words_free(lex1);
words_free(lex2);
}
示例13: report_error
void lr_parser::syntax_error(lr_symbol* cur_token)
{
report_error("Syntax error", cur_token);
}
示例14: solve
int solve(clingo_control_t *ctl) {
clingo_solve_result_t ret;
if (report_error(clingo_control_solve(ctl, 0, &on_model, 0, &ret))) { return 0; }
printf("the solve result is: %d\n", ret);
return 1;
}
示例15: reg
void PreferencesNetwork::syncSettings()
{
auto cloud = qPrefCloudStorage::instance();
auto proxy = qPrefProxy::instance();
proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
proxy->set_proxy_host(ui->proxyHost->text());
proxy->set_proxy_port(ui->proxyPort->value());
proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
proxy->set_proxy_user(ui->proxyUsername->text());
proxy->set_proxy_pass(ui->proxyPassword->text());
QString email = ui->cloud_storage_email->text();
QString password = ui->cloud_storage_password->text();
QString newpassword = ui->cloud_storage_new_passwd->text();
//TODO: Change this to the Cloud Storage Stuff, not preferences.
if (prefs.cloud_verification_status == qPref::CS_VERIFIED && !newpassword.isEmpty()) {
// deal with password change
if (!email.isEmpty() && !password.isEmpty()) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[[email protected]+_-]+$");
if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
report_error(qPrintable(tr("Change ignored. Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
return;
}
if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) {
report_error(qPrintable(tr("Change ignored. Cloud storage email and new password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
ui->cloud_storage_new_passwd->setText("");
return;
}
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful);
cloudAuth->backend(email, password, "", newpassword);
ui->cloud_storage_new_passwd->setText("");
}
} else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN ||
prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD ||
email != prefs.cloud_storage_email ||
password != prefs.cloud_storage_password) {
// different credentials - reset verification status
int oldVerificationStatus = cloud->cloud_verification_status();
cloud->set_cloud_verification_status(qPref::CS_UNKNOWN);
if (!email.isEmpty() && !password.isEmpty()) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[[email protected]+_-]+$");
if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
cloud->set_cloud_verification_status(oldVerificationStatus);
return;
}
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
cloudAuth->backend(email, password);
}
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY) {
QString pin = ui->cloud_storage_pin->text();
if (!pin.isEmpty()) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[[email protected]+_-]+$");
if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
return;
}
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(updateCloudAuthenticationState()));
cloudAuth->backend(email, password, pin);
}
}
cloud->set_cloud_storage_email(email);
cloud->set_save_password_local(ui->save_password_local->isChecked());
cloud->set_cloud_storage_password(password);
cloud->set_cloud_verification_status(prefs.cloud_verification_status);
cloud->set_cloud_base_url(prefs.cloud_base_url);
}