void BWBranchPartialResultsForward(char *W, vector *C, vector *C1, comp_matrix *O, results_list *rl_prev, results_list *rl_next) { BWiterationVariables(); size_t k, l, k_aux, l_aux; int pos, end; result *r_iterator; for (size_t ii=0; ii < rl_prev->num_results; ii++) { r_iterator = &rl_prev->list[ii]; pos = r_iterator->pos; end = r_iterator->end; if (pos > end) { add_result(r_iterator, rl_next); continue; } k = r_iterator->k; l = r_iterator->l; //Deletion change_result(r_iterator, k, l, pos+1); add_mismatch(r_iterator, DELETION, XXX, pos); add_result(r_iterator, rl_next); for (unsigned int b=0;b<nA;b++) { BWiteration(k, l, k_aux, l_aux, b, C, C1, O); if (k_aux > l_aux) continue; //Insertion //TODO: Añadir soporte para multiples insertions seguidas change_result(r_iterator, k_aux, l_aux, pos); modify_last_mismatch_2(r_iterator, INSERTION, b); add_result(r_iterator, rl_next); //Mismatch if (b!=(unsigned int)W[pos]) { change_result(r_iterator, k_aux, l_aux, pos+1); modify_last_mismatch_1(r_iterator, MISMATCH); add_result(r_iterator, rl_next); } } } rl_prev->num_results = 0; }
void Checker::whitespace_sequence_check() { if(token->start + token->line.size() == lines[token->line_index].size) { if(settings.ext_bool_options["forbid_trailing_whitespaces"] != EB_IGNORE) add_result("trailing whitespaces"); } else if(token->start != 0) { if(token->line.size() > 1 && settings.ext_bool_options["forbid_vertical_alignment"] != EB_IGNORE) add_result("more than one whitespace"); } }
void Checker::spaces_in_unibrackets_check(int offset) { ExtendedBoolean* opt_ptr = NULL; char c = token->line[0]; char opposite; switch(c) { case '(': case ')': opt_ptr = &settings.ext_bool_options["spaces_inside_braces"]; opposite = c == '(' ? ')' : '('; break; case '[': case ']': opt_ptr = &settings.ext_bool_options["spaces_inside_brackets"]; opposite = c == '[' ? ']' : '['; break; case '{': case '}': opt_ptr = &settings.ext_bool_options["spaces_inside_curly_braces"]; opposite = c == '{' ? '}' : '{'; break; default: throw UnilintException("Not a bracket symbol"); } ExtendedBoolean& spaces_inside(*opt_ptr); char next_symbol = lines[token->line_index].line[token->start + offset]; //empty brackets are exception if(next_symbol == opposite) return; if(spaces_inside == EB_CONSISTENT) { spaces_inside = next_symbol == ' ' ? EB_TRUE : EB_FALSE; } else if(spaces_inside == EB_TRUE && next_symbol != ' ') { add_result( token->start + offset, std::string("no space ") + (offset > 0 ? "after " : "before ") + c); } else if(spaces_inside == EB_FALSE && next_symbol == ' ') { add_result( token->start + offset, std::string("unexpected space ") + (offset > 0 ? "after " : "before ") + c); } }
void BWExactPartialResultsForward(char *W, vector *C, vector *C1, comp_matrix *O, results_list *rl_prev, results_list *rl_next) { //TODO: No añadir resultados nuevos si el numero de errores máximo se alcanza BWiterationVariables(); size_t k, l, k_next, l_next; int pos, end; result *r_iterator; size_t results, results_next; for (size_t ii=0; ii < rl_prev->num_results; ii++) { r_iterator = &rl_prev->list[ii]; pos = r_iterator->pos; end = r_iterator->end; k_next = r_iterator->k; l_next = r_iterator->l; results_next = l_next - k_next; for(int i=pos; i<=end; i++) { //TODO: Pos que no entran en el bucle k = k_next; l = l_next; if (k > l) break; BWiteration(k, l, k_next, l_next, (size_t)W[i], C, C1, O); results = results_next; results_next = l_next - k_next; if (results == results_next) continue; change_result(r_iterator, k, l, i); add_result(r_iterator, rl_next); } if (k_next <= l_next) { change_result(r_iterator, k_next, l_next, end+1); add_result(r_iterator, rl_next); } } //r_prev rl_prev->num_results = 0; }
void BWExactFinalResultsForward(char *W, vector *C, vector *C1, comp_matrix *O, results_list *rl_prev, results_list *rl_next) { BWiterationVariables(); size_t k, l; int pos, end; result *r_iterator; for (size_t ii=0; ii < rl_prev->num_results; ii++) { r_iterator = &rl_prev->list[ii]; pos = r_iterator->pos; end = r_iterator->end; k = r_iterator->k; l = r_iterator->l; for(int i=pos; i<=end; i--) { //TODO: Pos que no entran en el bucle BWiteration(k, l, k, l, (size_t)W[i], C, C1, O); if (k > l) break; } if (k <= l) { change_result(r_iterator, k, l, end+1); add_result(r_iterator, rl_next); } } //r_prev rl_prev->num_results = 0; }
void Analyzer_Sensor_Health::end_of_log(uint32_t packet_count UNUSED) { std::map<const std::string, bool> sensors_health = _vehicle->sensors_health(); bool have = false; for (std::map<const std::string, bool>::const_iterator it = sensors_health.begin(); it != sensors_health.end(); ++it) { // ::fprintf(stderr, "would evaluate (%s)\n", (*it).first.c_str()); std::string name = (*it).first; if (_results[name] != NULL) { close_result(name); } have = true; } if (!have) { Analyzer_Result_Summary *summary = new Analyzer_Result_Summary(); summary->set_status(analyzer_status_warn); summary->set_reason("Sensor health never updated"); summary->add_source(_data_sources.get("SENSORS_HEALTH")); add_result(summary); } }
t_result *algo_result(t_result *r, t_tetrim *t, t_result *res) { int x; int y; t_result *tmp; x = -1; y = -1; while (++x < r->size) { while (++y < r->size) { if (is_exist(r, t, x, y)) { tmp = place_tetrim(r, t, x, y); if (t->next) res = algo_result(tmp, t->next, res); else if (!t->next) return (add_result(res, tmp, r->size)); if (res) return (res); } } y = -1; } return (new_result(r, t, res)); }
void Analyzer_Ever_Flew::end_of_log(const uint32_t packet_count UNUSED) { if (_vehicle->is_flying()) { _total_flight_time += _vehicle->T() - _fly_start_time; } if (_result.status() == analyzer_status_fail) { if (!_result.ever_armed()) { _result.add_evidence("Never Armed"); } switch (_vehicle->vehicletype()) { case AnalyzerVehicle::Base::vehicletype_t::copter: if (!_result.servos_past_threshold()) { _result.add_evidence("Servos never passed takeoff threshold"); } break; case AnalyzerVehicle::Base::vehicletype_t::plane: break; case AnalyzerVehicle::Base::vehicletype_t::rover: break; case AnalyzerVehicle::Base::vehicletype_t::invalid: _result.add_evidence("Vehicle type was never defined"); break; } } add_result(&_result); }
void Analyzer_Parameters::open_result_trivial(const std::string name, const double value, const Param_Constraint_Trivial &constraints) { Analyzer_Parameters_Result *result = new Analyzer_Parameters_Result(); _open_results[name] = result; result->set_T_start(_vehicle->T()); result->add_source(_data_sources.get("PARAM")); result->set_value(value); result->set_status(analyzer_status_fail); result->set_reason(constraints.description()); result->add_evidence(string_format("name=%s", name.c_str())); result->add_evidence(string_format("value=%f", value)); if (!constraints.min_ok(value)) { result->add_evidence("Parameter below minimum value"); result->add_evidence(string_format("min=%f", constraints.min())); } if (!constraints.max_ok(value)) { result->add_evidence("Parameter above maximum value"); result->add_evidence(string_format("max=%f", constraints.max())); } if (!constraints.default_ok(value)) { result->add_evidence("Parameter set to (bad) default value"); result->add_evidence(string_format("default=%f", constraints.bad_default())); } add_result(result); }
static int run_tests(int argc, char **argv) { struct result_info sum; int count = 0; int i; decoder = quirc_new(); if (!decoder) { perror("quirc_new"); return -1; } printf(" %-30s %17s %11s\n", "", "Time (ms)", "Count"); printf(" %-30s %5s %5s %5s %5s %5s\n", "Filename", "Load", "ID", "Total", "ID", "Dec"); puts("----------------------------------------" "---------------------------------------"); memset(&sum, 0, sizeof(sum)); for (i = 0; i < argc; i++) { struct result_info info; if (test_scan(argv[i], &info) > 0) { add_result(&sum, &info); count++; } } if (count > 1) print_result("TOTAL", &sum); quirc_destroy(decoder); return 0; }
// make sure someone running a PixHawk hasn't just copied parameters // from an APM: void Analyzer_Parameters::evaluate_log_bitmask() { float log_bitmask; const AnalyzerVehicle::AutoPilot::AutoPilotHardware hw = _vehicle->autopilot().hardware(); if (_vehicle->param("LOG_BITMASK", log_bitmask) && hw != AnalyzerVehicle::AutoPilot::AutoPilotHardware::UNKNOWN) { bool bad = (hw == AnalyzerVehicle::AutoPilot::AutoPilotHardware::PX4V2 && is_equal(log_bitmask, log_bitmask_apm_default)); if (bad) { if (_log_bitmask_bad_apm == nullptr) { _log_bitmask_bad_apm = new Analyzer_Parameters_Result(); _log_bitmask_bad_apm->set_T_start(_vehicle->T()); _log_bitmask_bad_apm->add_source(_data_sources.get("PARAM")); _log_bitmask_bad_apm->set_status(analyzer_status_fail); _log_bitmask_bad_apm->set_reason("AutoPilot is PixHawk hardware, log bitmask is APM default"); _log_bitmask_bad_apm->add_evidence("autopilot=PX4v2"); _log_bitmask_bad_apm->add_evidence(string_format("LOG_BITMASK=%f", log_bitmask)); add_result(_log_bitmask_bad_apm); } } else { if (_log_bitmask_bad_apm != nullptr) { _log_bitmask_bad_apm->set_T_stop(_vehicle->T()); _log_bitmask_bad_apm = nullptr; } } } }
void BWExactPartialResultsBackward(char *W, vector *C, vector *C1, comp_matrix *O, results_list *rl_prev, results_list *rl_next) { BWiterationVariables(); size_t k, l, k_next, l_next; int start, pos; result *r_iterator; size_t results, results_next; for (size_t ii=0; ii < rl_prev->num_results; ii++) { r_iterator = &rl_prev->list[ii]; start = r_iterator->start; pos = r_iterator->pos; k_next = r_iterator->k; l_next = r_iterator->l; results_next = l_next - k_next; for(int i=pos; i>=start; i--) { //TODO: Pos que no entran en el bucle k = k_next; l = l_next; if (k > l) break; BWiteration(k, l, k_next, l_next, (size_t)W[i], C, C1, O); results = results_next; results_next = l_next - k_next; if (results == results_next) continue; change_result(r_iterator, k, l, i); add_result(r_iterator, rl_next); } if (k_next <= l_next) { change_result(r_iterator, k_next, l_next, start-1); add_result(r_iterator, rl_next); } } //r_prev rl_prev->num_results = 0; }
void Checker::else_check() { ExtendedBoolean& at_newline(settings.ext_bool_options["else_at_newline"]); int depth_by_fact = lines[token->line_index].depth_by_fact; if(at_newline == EB_CONSISTENT) { at_newline = token->start == depth_by_fact ? EB_TRUE : EB_FALSE; } else if(at_newline == EB_TRUE && token->start != depth_by_fact) { add_result("else is not at new line"); } else if(at_newline == EB_FALSE && token->start == depth_by_fact) { add_result("else is at new line"); } }
void plt_emit(simulation_result *self,DATA *data, threadData_t *threadData) { plt_data *pltData = (plt_data*) self->storage; rt_tick(SIM_TIMER_OUTPUT); if(pltData->actualPoints < pltData->maxPoints) { add_result(self,data,pltData->simulationResultData,&pltData->actualPoints); /*used for non-interactive simulation */ } else { pltData->maxPoints = (long)(1.4*pltData->maxPoints + (pltData->maxPoints-pltData->actualPoints) + 2000); /* cerr << "realloc simulationResultData to a size of " << maxPoints * dataSize * sizeof(double) << endl; */ pltData->simulationResultData = (double*)realloc(pltData->simulationResultData, pltData->maxPoints * pltData->dataSize * sizeof(double)); if(!pltData->simulationResultData) { throwStreamPrint(threadData, "Error allocating simulation result data of size %ld",pltData->maxPoints * pltData->dataSize); } add_result(self,data,pltData->simulationResultData,&pltData->actualPoints); } rt_accumulate(SIM_TIMER_OUTPUT); }
void get_results (FILE * fp, const char *query_string, const char *misc_field, const int all_emails, int *searched, query_result * results, int *rc) { vc_component *v = NULL; char *s_result = NULL; char *email = NULL; char *name = NULL; char *misc = NULL; vc_component *fn = NULL; query_result * r = NULL; r = results; *rc = 0; *searched = 0; for (v = parse_vcard_file (fp); NULL != v; v = parse_vcard_file (fp)) { (*searched)++; fn = vc_get_next_by_name (v, VC_FORMATTED_NAME); name = vc_get_value (fn); misc = get_misc_value (v, misc_field); if (all_emails) { for (fn = vc_get_next_by_name (v, VC_EMAIL); NULL != fn; fn = vc_get_next_by_name(fn, VC_EMAIL)) { email = vc_get_value (fn); r = add_result(query_string, name, misc, email, r, rc); } } else { email = vc_get_preferred_email (v); r = add_result(query_string, name, misc, email, r, rc); } free (misc); vc_delete_deep (v); v = NULL; } }
//-------- Begin of function SeekPathReuse::move_outside_map ---------// // location (preX, preY) is inside the map while location (curX, curY) // is outside the map // // add one/two points // void SeekPathReuse::move_outside_map(int preX, int preY, int curX, int curY) { err_when(preX<0 || preX>=MAX_WORLD_X_LOC || preY<0 || preY>=MAX_WORLD_Y_LOC); err_when(curX>=0 && curX<MAX_WORLD_X_LOC && curY>=0 && curY<MAX_WORLD_Y_LOC); int vecX = curX-preX; int vecY = curY-preY; if(vecX!=0) vecX /= abs(vecX); if(vecY!=0) vecY /= abs(vecY); int vertical=0; // 1 for upper edge, 2 for lower edge int horizontal=0; // 1 for left edge, 2 for right edge int xStep, yStep; if(curX<0) { xStep = preX; horizontal = 1; } else if(curX>=MAX_WORLD_X_LOC) { xStep = MAX_WORLD_X_LOC-preX-1; horizontal = 2; } else err_here(); if(curY<0) { yStep = preY; vertical = 1; } else if(curY>=MAX_WORLD_Y_LOC) { yStep = MAX_WORLD_Y_LOC-preY-1; vertical = 2; } else err_here(); err_when(xStep!=yStep); int addXLoc = preX+xStep*vecX; int addYLoc = preY+yStep*vecY; add_result(addXLoc, addYLoc); // add the first point //-*************** codes here ***************-// //---------------------------------------------------------------// // may add the second point if exit at the edge of the map //---------------------------------------------------------------// /*if((addXLoc==0 && addYLoc==0) || (addXLoc==0 && addYLoc==MAX_WORLD_Y_LOC-1) || (addXLoc==MAX_WORLD_X_LOC-1 && addYLoc==0) || (addXLoc==MAX_WORLD_X_LOC-1 && addYLoc==MAX_WORLD_Y_LOC-1)) { err_when(!vertical || !horizontal); return; // exit at corner }*/ }
void Analyzer_Sensor_Health::close_result(const std::string name) { Analyzer_Sensor_Health_Result *result = _results[name]; result->set_T_stop(_vehicle->T()); // result->add_source(_data_sources.get(string_format("EKF_VARIANCES_%s", name.c_str()))); // result->add_evidence(string_format("max-variance=%f", result->max())); add_result(result); _results[name] = NULL; }
void Checker::blockbracket_check() { if(!is_pascal_functional_begin()) { ExtendedBoolean& block_at_newline(settings.ext_bool_options["start_block_at_newline"]); int indentation_end = lines[token->line_index].depth_by_fact; if(block_at_newline == EB_CONSISTENT) { block_at_newline = token->start == indentation_end ? EB_TRUE : EB_FALSE; } else if(block_at_newline == EB_TRUE && token->start != indentation_end) { add_result(token->line + " is not at new line"); } else if(block_at_newline == EB_FALSE && token->start == indentation_end) { add_result(token->line + " is at new line"); } } }
void Checker::nesting_depth_check() { int maximal_nesting_depth = settings.int_options["maximal_nesting_depth"]; if( lines[token->line_index].expected_depth != previous_depth && maximal_nesting_depth != IGNORE_OPTION && lines[token->line_index].expected_depth > maximal_nesting_depth) { add_result("maximal nesting depth exceeded"); } previous_depth = lines[token->line_index].expected_depth; }
void Analyzer_Arming_Checks::evaluate() { if (!_vehicle->param_seen("ARMING_CHECK")) { return; } if (_armed == _vehicle->is_armed()) { // we have not changed state since last we checked return; } _armed = _vehicle->is_armed(); if (! _vehicle->is_armed()) { // not interested in armed -> disarmed transitions return; } // we have armed since last we checked _armed = true; uint32_t arming_check = (uint32_t)_vehicle->param("ARMING_CHECK"); if (arming_check & ARMING_CHECK_ALL) { // all is right with the world return; } for (std::map<uint32_t, const char *>::const_iterator it = _bit_to_name.begin(); it != _bit_to_name.end(); ++it) { if ((*it).first == ARMING_CHECK_ALL || (*it).first == ARMING_CHECK_NONE) { continue; } if (!(arming_check & (*it).first)) { Analyzer_Arming_Checks_Result *result = new Analyzer_Arming_Checks_Result(); result->set_status(analyzer_status_fail); result->set_reason("Some of the arming checks were disabled when the craft was armed"); result->add_evidence(string_format("Arming flags: %u", arming_check)); result->add_source(_data_sources.get("PARAM")); result->add_source(_data_sources.get("ARMING")); result->set_T(_vehicle->T()); result->set_arming_check(arming_check); result->increase_severity_score(10); for (std::map<uint32_t, const char *>::const_iterator it = _bit_to_name.begin(); it != _bit_to_name.end(); ++it) { if (!(result->arming_check() & (*it).first)) { result->add_evidence(string_format("%s check disabled", (*it).second)); result->increase_severity_score(1); } } add_result(result); break; } } }
void Checker::keyword_and_brace_check() { ExtendedBoolean& space(settings.ext_bool_options["space_between_keyword_and_brace"]); int keyword_end = token->start + token->line.size(); if(keyword_end == lines[token->line_index].size) return; char next_symbol = lines[token->line_index].line[keyword_end]; if(space == EB_CONSISTENT) { space = next_symbol == ' ' ? EB_TRUE : EB_FALSE; } else if(space == EB_TRUE && next_symbol != ' ') { add_result(keyword_end, "no space after " + token->line); } else if(space == EB_FALSE && next_symbol == ' ') { add_result(keyword_end, "space after " + token->line); } }
void Analyzer_Estimate_Divergence::close_result(std::string name) { _result[name]->set_T_stop(_vehicle->T()); if (_result[name]->duration() < delta_time_threshold()) { delete _result[name]; _result[name] = NULL; return; } close_result_add_evidence(_result[name]); add_result(_result[name]); _result[name] = NULL; }
void Analyzer_Position_Estimate_Divergence::close_result(const std::string name) { _result[name]->set_T_stop(_vehicle->T()); if (_result[name]->duration() < delta_time_threshold()) { delete _result[name]; _result[name] = NULL; return; } _result[name]->add_evidence(string_format("max-delta=%f metres", _result[name]->max_delta())); _result[name]->add_evidence(string_format("delta-threshold=%f metres", _result[name]->delta_threshold())); _result[name]->add_evidence(string_format("delta-time-threshold=%f seconds", delta_time_threshold() / 1000000.0f)); add_result(_result[name]); _result[name] = NULL; }
bool BWSearch1CPU(uint8_t *W, vector *C, vector *C1, comp_matrix *O, comp_matrix *Oi, result *res, results_list *r_list) { int16_t start, end, half, n;; SA_TYPE _k, _l; _k = res->k; _l = res->l; start = res->start; end = res->end; n = end - start + 1; half = n / 2; result r; init_result(&r, 0); bound_result(&r, half, end); change_result(&r, _k, _l, end); BWExactSearchBackward(W, C, C1, O, &r); if (r.k <= r.l) { r.start = start; r.pos = half-1; BWSimpleSearch1Backward(W, C, C1, O, &r, r_list); if (r.k <= r.l) add_result(&r, r_list); //Match } half--; init_result(&r, 1); bound_result(&r, start, half); change_result(&r, _k, _l, start); BWExactSearchForward(W, C, C1, Oi, &r); if (r.k <= r.l) { r.pos = half+1; r.end = end; BWSimpleSearch1Forward(W, C, C1, Oi, &r, r_list); } return false; }
void BWSearch1CPU(char *W, vector *C, vector *C1, comp_matrix *O, comp_matrix *Oi, result *res, results_list *r_list) { unsigned int half, n; int start, end; unsigned int _k, _l; _k = res->k; _l = res->l; start = res->start; end = res->end; n = end - start + 1; half = n / 2; result r; init_result(&r, 0); bound_result(&r, half, end); change_result(&r, _k, _l, end); BWExactSearchBackward(W, C, C1, O, &r); if (r.k <= r.l) { r.start = start; r.pos = half-1; BWSimpleSearch1Backward(W, C, C1, O, &r, r_list); if (r.k <= r.l) add_result(&r, r_list); //Match } half--; init_result(&r, 1); bound_result(&r, start, half); change_result(&r, _k, _l, start); BWExactSearchForward(W, C, C1, Oi, &r); if (r.k <= r.l) { r.pos = half+1; r.end = end; BWSimpleSearch1Forward(W, C, C1, Oi, &r, r_list); } }
void Checker::name_style_check(NameType type) { std::string option_name = ( type == NT_CLASS ? "class_naming_style" : type == NT_FUNCTION ? "function_naming_style" : "variable_naming_style"); NamingStyle ns = settings.naming_styles[option_name]; bool style_error = false; if(ns == NS_CAMEL || ns == NS_PASCAL) { style_error = ns == NS_CAMEL && !std::islower(token->line[0]) || ns == NS_PASCAL && !std::isupper(token->line[0]); for(int i = 1; !style_error && i < token->line.size(); ++i) { style_error = !std::isalpha(token->line[i]) && !std::isdigit(token->line[i]); } } if(ns == NS_UNDERSCORE || ns == NS_CAPS_UNDERSCORE) { for(int i = 0; !style_error && i < token->line.size(); ++i) { style_error = token->line[i] != '_' && !std::isdigit(token->line[i]) && ( ns == NS_UNDERSCORE && !islower(token->line[i]) || ns == NS_CAPS_UNDERSCORE && !isupper(token->line[i])); } } if(style_error) { std::string ns_string( ns == NS_CAMEL ? "camel" : ns == NS_PASCAL ? "pascal" : ns == NS_UNDERSCORE ? "underscore" : "caps_underscore"); add_result("name " + token->line + " is not of style " + ns_string); } }
void BWSearchCPU(char *W, vector *C, vector *C1, comp_matrix *O, result *res, results_list *rl_prev, results_list *rl_next, int num_errors) { res->pos = res->end; add_result(res, rl_prev); while (num_errors > 0) { BWExactPartialResultsBackward(W, C, C1, O, rl_prev, rl_next); //printf("next -> %u\n", rl_next->num_results); BWBranchPartialResultsBackward(W, C, C1, O, rl_next, rl_prev); //printf("prev -> %u\n", rl_prev->num_results); num_errors--; } BWExactFinalResultsBackward(W, C, C1, O, rl_prev, rl_next); //printf("next -> %u\n", rl_next->num_results); }
void Analyzer_Brownout::end_of_log(const uint32_t packet_count UNUSED) { double last_altitude = _vehicle->altitude(); _result.set_last_altitude(last_altitude); if (_vehicle->alt_modtime() > 0) { _result.add_evidence(string_format("Final altitude %f metres", _result.last_altitude())); if (_vehicle->is_flying()) { _result.add_evidence(string_format("Takeoff altitude %f metres", _result.takeoff_altitude())); double last_relative_altitude = _result.last_altitude() - _result.takeoff_altitude(); _result.add_evidence(string_format("Final relative altitude %f metres", last_relative_altitude)); _result.set_status(analyzer_status_fail); _result.increase_severity_score(10); if (last_relative_altitude > max_last_relative_altitude) { _result.increase_severity_score(10); } _result.add_source(_data_sources.get("SERVO_OUTPUT")); _result.add_source(_data_sources.get("ALTITUDE")); _result.set_reason("Log ended while craft still flying"); _result.add_evidence("Vehicle still flying"); } else { _result.set_status(analyzer_status_ok); _result.add_source(_data_sources.get("SERVO_OUTPUT")); _result.add_source(_data_sources.get("ALTITUDE")); _result.set_reason("No brownout detected"); } } else { _result.set_status(analyzer_status_warn); _result.increase_severity_score(5); _result.set_reason("Altitude never changed"); _result.add_source(_data_sources.get("ALTITUDE")); } add_result(&_result); }
static int scan_dir(const char *path, const char *filename, struct result_info *info) { DIR *d = opendir(path); struct dirent *ent; int count = 0; if (!d) { fprintf(stderr, "%s: opendir: %s\n", path, strerror(errno)); return -1; } printf("%s:\n", path); while ((ent = readdir(d))) { if (ent->d_name[0] != '.') { char fullpath[1024]; struct result_info sub; snprintf(fullpath, sizeof(fullpath), "%s/%s", path, ent->d_name); if (test_scan(fullpath, &sub) > 0) { add_result(info, &sub); count++; } } } closedir(d); if (count > 1) { print_result(filename, info); puts(""); } return count > 0; }
//-------- Begin of function SeekPathReuse::seek_path_offset ---------// void SeekPathReuse::seek_path_offset() { if(!is_leader_path_valid()) return; if(is_node_avail_empty()) { copy_leader_path_offset(); return; } //------------ construct data structure to store result node ----------------// result_node_array_def_size += result_node_array_reset_amount; path_reuse_result_node_ptr = (ResultNode*) mem_add(sizeof(ResultNode)* result_node_array_def_size); memset(path_reuse_result_node_ptr, 0, sizeof(ResultNode)* result_node_array_def_size); cur_result_node_ptr = path_reuse_result_node_ptr; num_of_result_node = 0; //---------------- set starting point ----------------------// add_result(start_x, start_y); //-----------------initialize offset path reuse ------------// cur_leader_node_ptr = reuse_leader_path_backup+1; cur_leader_node_num = 2; use_offset_method(reuse_leader_path_backup[0].node_x, reuse_leader_path_backup[0].node_y); // using offset path method directly //----------------------------------------------------------------------// // checking for incomplete searching //----------------------------------------------------------------------// ResultNode *lastNode = path_reuse_result_node_ptr + num_of_result_node - 1; if((lastNode->node_x!=vir_dest_x || lastNode->node_y!=vir_dest_y) && is_node_avail_empty()) { incomplete_search++; reuse_path_status = REUSE_PATH_INCOMPLETE_SEARCH; } }