void Texture::reset() { if( ! ok ) return; Ref ref = get_ref(); if( ref != -1u && --registery[ ref ].refCount <= 0 ) { glDeleteTextures( 1, ®istery[ ref ].glHandle ); } ok = false; }
SEXP R_handle_reset(SEXP ptr){ //reset all fields reference *ref = get_ref(ptr); set_form(ref, NULL); set_headers(ref, NULL); reset_errbuf(ref); curl_easy_reset(ref->handle); //restore default settings set_handle_defaults(ref); return ScalarLogical(1); }
d_binary Storage_Persons::FacesGetObject() { GEN_DECLARE_ARGS_AND_DB(); wchar_t __mtd_name[] = L"FacesGetObject"; d_binary __res; __args_mgr.set_next_as_res(&__res); Critical_section cs(__db->get_cs_handle()); __db->run_method(get_ref(), __srv_cl_name, __mtd_name, __args_mgr); return __res; }
Texture::Texture( const std::string& filename ) { key = filename; Ref ref = get_ref(); ok = true; if( ref != -1u ) registery[ ref ].refCount++; else load( filename ); }
d_string Storage_Faces::PhotoGetObjectId() { GEN_DECLARE_ARGS_AND_DB(); wchar_t __mtd_name[] = L"PhotoGetObjectId"; d_string __res; __args_mgr.set_next_as_res(&__res); Critical_section cs(__db->get_cs_handle()); __db->run_method(get_ref(), __srv_cl_name, __mtd_name, __args_mgr); return __res; }
JNIEXPORT void JNICALL Java_org_grammaticalframework_pgf_Parser_addLiteralCallback (JNIEnv* env, jclass clazz, jobject jconcr, jlong callbacksRef, jstring jcat, jobject jcallback, jobject jpool) { PgfConcr* concr = get_ref(env, jconcr); GuPool* pool = get_ref(env, jpool); JPgfLiteralCallback* callback = gu_new(JPgfLiteralCallback, pool); callback->callback.match = jpgf_literal_callback_match; callback->callback.predict = jpgf_literal_callback_predict; callback->jcallback = (*env)->NewGlobalRef(env, jcallback); callback->fin.fn = jpgf_literal_callback_fin; jclass callback_class = (*env)->GetObjectClass(env, jcallback); callback->match_methodId = (*env)->GetMethodID(env, callback_class, "match", "(ILjava/lang/String;I)Lorg/grammaticalframework/pgf/LiteralCallback$CallbackResult;"); callback->predict_methodId = (*env)->GetMethodID(env, callback_class, "predict", "(ILjava/lang/String;)Ljava/util/Iterator;"); gu_pool_finally(pool, &callback->fin); pgf_callbacks_map_add_literal(concr, l2p(callbacksRef), j2gu_string(env, jcat, pool), &callback->callback); }
JNIEXPORT jobject JNICALL Java_org_grammaticalframework_sg_SG_queryTriple(JNIEnv *env, jobject self, jobject jsubj, jobject jpred, jobject jobj) { SgSG *sg = get_ref(env, self); GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_exn(tmp_pool); SgTriple triple; triple[0] = (jsubj == NULL) ? gu_null_variant : gu_variant_from_ptr((void*) get_ref(env, jsubj)); triple[1] = (jpred == NULL) ? gu_null_variant : gu_variant_from_ptr((void*) get_ref(env, jpred)); triple[2] = (jobj == NULL) ? gu_null_variant : gu_variant_from_ptr((void*) get_ref(env, jobj)); SgTripleResult* res = sg_query_triple(sg, triple, err); if (!gu_ok(err)) { GuString msg; if (gu_exn_caught(err, SgError)) { msg = (GuString) gu_exn_caught_data(err); } else { msg = "The query failed"; } throw_string_exception(env, "org/grammaticalframework/sg/SGError", msg); gu_pool_free(tmp_pool); return NULL; } gu_pool_free(tmp_pool); jclass res_class = (*env)->FindClass(env, "org/grammaticalframework/sg/TripleResult"); jmethodID constrId = (*env)->GetMethodID(env, res_class, "<init>", "(JLorg/grammaticalframework/pgf/Expr;Lorg/grammaticalframework/pgf/Expr;Lorg/grammaticalframework/pgf/Expr;)V"); jobject jres = (*env)->NewObject(env, res_class, constrId, p2l(res), jsubj, jpred, jobj); return jres; }
/** Set a FP register to a value */ static void pass0_set_fpreg_value( struct brw_wm_compile *c, GLuint file, GLuint idx, GLuint component, struct brw_wm_value *value ) { struct brw_wm_ref *ref = get_ref(c); ref->value = value; ref->hw_reg = brw_vec8_grf(0, 0); ref->insn = 0; ref->prevuse = NULL; c->pass0_fp_reg[file][idx][component] = ref; }
d_string Storage_Faces::FischerWeightsGetObjectId(const d_int& force) { GEN_DECLARE_ARGS_AND_DB(); wchar_t __mtd_name[] = L"FischerWeightsGetObjectId"; __args_mgr.set_next(&force); d_string __res; __args_mgr.set_next_as_res(&__res); Critical_section cs(__db->get_cs_handle()); __db->run_method(get_ref(), __srv_cl_name, __mtd_name, __args_mgr); return __res; }
d_status Storage_Faces::PhotoSetObject(const d_binary& newvalue) { GEN_DECLARE_ARGS_AND_DB(); wchar_t __mtd_name[] = L"PhotoSetObject"; __args_mgr.set_next(&newvalue); d_status __res; __args_mgr.set_next_as_res(&__res); Critical_section cs(__db->get_cs_handle()); __db->run_method(get_ref(), __srv_cl_name, __mtd_name, __args_mgr); return __res; }
d_binary Storage_Faces::DetectorsGetObject(const d_int& force) { GEN_DECLARE_ARGS_AND_DB(); wchar_t __mtd_name[] = L"DetectorsGetObject"; __args_mgr.set_next(&force); d_binary __res; __args_mgr.set_next_as_res(&__res); Critical_section cs(__db->get_cs_handle()); __db->run_method(get_ref(), __srv_cl_name, __mtd_name, __args_mgr); return __res; }
JNIEXPORT jobject JNICALL Java_org_grammaticalframework_pgf_Parser_parseWithHeuristics (JNIEnv* env, jclass clazz, jobject jconcr, jstring jstartCat, jstring js, jdouble heuristics, jlong callbacksRef, jobject jpool) { GuPool* pool = get_ref(env, jpool); GuPool* out_pool = gu_new_pool(); GuString startCat = j2gu_string(env, jstartCat, pool); GuString s = j2gu_string(env, js, pool); GuExn* parse_err = gu_new_exn(pool); GuEnum* res = pgf_parse_with_heuristics(get_ref(env, jconcr), startCat, s, heuristics, l2p(callbacksRef), parse_err, pool, out_pool); if (!gu_ok(parse_err)) { if (gu_exn_caught(parse_err, PgfExn)) { GuString msg = (GuString) gu_exn_caught_data(parse_err); throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", msg); } else if (gu_exn_caught(parse_err, PgfParseError)) { GuString tok = (GuString) gu_exn_caught_data(parse_err); throw_string_exception(env, "org/grammaticalframework/pgf/ParseError", tok); } gu_pool_free(out_pool); return NULL; } jfieldID refId = (*env)->GetFieldID(env, (*env)->GetObjectClass(env, jconcr), "gr", "Lorg/grammaticalframework/pgf/PGF;"); jobject jpgf = (*env)->GetObjectField(env, jconcr, refId); jclass expiter_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/ExprIterator"); jmethodID constrId = (*env)->GetMethodID(env, expiter_class, "<init>", "(Lorg/grammaticalframework/pgf/PGF;Lorg/grammaticalframework/pgf/Pool;JJ)V"); jobject jexpiter = (*env)->NewObject(env, expiter_class, constrId, jpgf, jpool, p2l(out_pool), p2l(res)); return jexpiter; }
int cmd_notes(int argc, const char **argv, const char *prefix) { int result; const char *override_notes_ref = NULL; struct option options[] = { OPT_STRING(0, "ref", &override_notes_ref, N_("notes-ref"), N_("use notes from <notes-ref>")), OPT_END() }; git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_notes_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (override_notes_ref) { struct strbuf sb = STRBUF_INIT; strbuf_addstr(&sb, override_notes_ref); expand_notes_ref(&sb); setenv("GIT_NOTES_REF", sb.buf, 1); strbuf_release(&sb); } if (argc < 1 || !strcmp(argv[0], "list")) result = list(argc, argv, prefix); else if (!strcmp(argv[0], "add")) result = add(argc, argv, prefix); else if (!strcmp(argv[0], "copy")) result = copy(argc, argv, prefix); else if (!strcmp(argv[0], "append") || !strcmp(argv[0], "edit")) result = append_edit(argc, argv, prefix); else if (!strcmp(argv[0], "show")) result = show(argc, argv, prefix); else if (!strcmp(argv[0], "merge")) result = merge(argc, argv, prefix); else if (!strcmp(argv[0], "remove")) result = remove_cmd(argc, argv, prefix); else if (!strcmp(argv[0], "prune")) result = prune(argc, argv, prefix); else if (!strcmp(argv[0], "get-ref")) result = get_ref(argc, argv, prefix); else { result = error(_("Unknown subcommand: %s"), argv[0]); usage_with_options(git_notes_usage, options); } return result ? 1 : 0; }
/** * int event_loop() * * page all selected algorithms with input ref * * @param page_ref {int} page to ref * * @return 0 */ int event_loop() { counter = 0; while(counter < max_page_calls) { page(get_ref()); ++counter; } size_t i = 0; for (i = 0; i < num_algos; i++) { if(algos[i].selected==1) { print_summary(algos[i]); } } return 0; }
JNIEXPORT jobject JNICALL Java_org_grammaticalframework_pgf_PGF_getFunctionType(JNIEnv* env, jobject self, jstring jid) { PgfPGF* pgf = get_ref(env, self); GuPool* tmp_pool = gu_new_pool(); PgfCId id = j2gu_string(env, jid, tmp_pool); PgfType* tp = pgf_function_type(pgf, id); gu_pool_free(tmp_pool); if (tp == NULL) return NULL; jclass type_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/Type"); jmethodID constrId = (*env)->GetMethodID(env, type_class, "<init>", "(Lorg/grammaticalframework/pgf/PGF;J)V"); jobject jtype = (*env)->NewObject(env, type_class, constrId, self, p2l(tp)); return jtype; }
static bool return_frame (void *page) { struct frame_ref *ee = get_ref (); if (ee) { ee->data = page; list_push_back (&free_frames, &ee->elem); ++counter; } else if (initialized) return false; else { paging_identity_map (page, PT_P|PT_RW|PT_PWT|PT_NX); use_block (page); } return true; }
bool Texture::load( const std::string& filaname ) { Ref ref; // Reference to the Item we'll be working on. // We only need to reset if we're referencing a texture. if( key.size() ) { reset(); } key = filaname; ref = get_ref(); // If this Item already exists, and is loaded, we're all set. if( ref != -1u && ref < registery.size() && registery[ref].refCount++ != 0 ) return true; // Otherwise, make it. registery.push_back( Item(key,0,1) ); ref = registery.size() - 1; glGenTextures( 1, ®istery[ref].glHandle ); // Use SDL to lead the image for simplicity. SDL_Surface* sdlSurface = SDL_LoadBMP( filaname.c_str() ); if( sdlSurface ) { gen_texture( registery[ref].glHandle, sdlSurface ); SDL_FreeSurface( sdlSurface ); ok = true; } else { ok = false; } return ok; }
JNIEXPORT void JNICALL Java_org_grammaticalframework_sg_TripleResult_close(JNIEnv *env, jobject self) { SgTripleResult *res = get_ref(env, self); GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_exn(tmp_pool); sg_triple_result_close(res, err); if (!gu_ok(err)) { GuString msg; if (gu_exn_caught(err, SgError)) { msg = (GuString) gu_exn_caught_data(err); } else { msg = "Closing the result failed"; } throw_string_exception(env, "org/grammaticalframework/sg/SGError", msg); } gu_pool_free(tmp_pool); }
JNIEXPORT jobject JNICALL Java_org_grammaticalframework_pgf_Generator_generateAll(JNIEnv* env, jclass clazz, jobject jpgf, jstring jstartCat) { GuPool* pool = gu_new_pool(); GuPool* out_pool = gu_new_pool(); GuString startCat = j2gu_string(env, jstartCat, pool); GuExn* err = gu_exn(pool); GuEnum* res = pgf_generate_all(get_ref(env, jpgf), startCat, err, pool, out_pool); if (res == NULL) { throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", "The generation failed"); gu_pool_free(pool); return NULL; } jclass expiter_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/ExprIterator"); jmethodID constrId = (*env)->GetMethodID(env, expiter_class, "<init>", "(Lorg/grammaticalframework/pgf/PGF;JJJ)V"); jobject jexpiter = (*env)->NewObject(env, expiter_class, constrId, jpgf, p2l(pool), p2l(out_pool), p2l(res)); return jexpiter; }
JNIEXPORT void JNICALL Java_org_grammaticalframework_sg_SG_close(JNIEnv *env, jobject self) { GuPool* tmp_pool = gu_local_pool(); // Create an exception frame that catches all errors. GuExn* err = gu_exn(tmp_pool); sg_close(get_ref(env, self), err); if (!gu_ok(err)) { GuString msg; if (gu_exn_caught(err, SgError)) { msg = (GuString) gu_exn_caught_data(err); } else { msg = "The database cannot be closed"; } throw_string_exception(env, "org/grammaticalframework/sg/SGError", msg); gu_pool_free(tmp_pool); return; } gu_pool_free(tmp_pool); }
void MoveAbility::invoke(Unit &to_modify, const Command &cmd, bool play_sound) { to_modify.log(MSG(dbg) << "invoke move action"); if (play_sound && this->sound) { this->sound->play(); } if (cmd.has_position()) { auto target = cmd.position(); to_modify.push_action(std::make_unique<MoveAction>(&to_modify, target)); } else if (cmd.has_unit()) { auto target = cmd.unit(); // distance from the targets edge that is required to stop moving coord::phys_t radius = path::path_grid_size + (to_modify.location->min_axis() / 2); // add the range of the unit if cmd indicator is set if (cmd.has_flag(command_flag::use_range) && to_modify.has_attribute(attr_type::attack)) { auto &att = to_modify.get_attribute<attr_type::attack>(); radius += att.range; } to_modify.push_action(std::make_unique<MoveAction>(&to_modify, target->get_ref(), radius)); } }
JNIEXPORT jobjectArray JNICALL Java_org_grammaticalframework_pgf_Concr_bracketedLinearize(JNIEnv* env, jobject self, jobject jexpr) { jclass object_class = (*env)->FindClass(env, "java/lang/Object"); if (!object_class) return NULL; jclass bracket_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/Bracket"); if (!bracket_class) return NULL; jmethodID bracket_constrId = (*env)->GetMethodID(env, bracket_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;II[Ljava/lang/Object;)V"); if (!bracket_constrId) return NULL; GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_exn(tmp_pool); PgfConcr* concr = get_ref(env, self); GuEnum* cts = pgf_lzr_concretize(concr, gu_variant_from_ptr((void*) get_ref(env, jexpr)), err, tmp_pool); if (!gu_ok(err)) { if (gu_exn_caught(err, PgfExn)) { GuString msg = (GuString) gu_exn_caught_data(err); throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", msg); } else { throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", "The expression cannot be concretized"); } gu_pool_free(tmp_pool); return NULL; } PgfCncTree ctree = gu_next(cts, PgfCncTree, tmp_pool); if (gu_variant_is_null(ctree)) { throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", "The expression cannot be concretized"); gu_pool_free(tmp_pool); return NULL; } ctree = pgf_lzr_wrap_linref(ctree, tmp_pool); PgfBracketLznState state; state.funcs = &pgf_bracket_lin_funcs; state.env = env; state.tmp_pool = tmp_pool; state.stack = gu_new_buf(GuBuf*, tmp_pool); state.list = gu_new_buf(jobject, tmp_pool); state.object_class = object_class; state.bracket_class = bracket_class; state.bracket_constrId = bracket_constrId; pgf_lzr_linearize(concr, ctree, 0, &state.funcs, tmp_pool); size_t len = gu_buf_length(state.list); jobjectArray array = (*env)->NewObjectArray(env, len, object_class, NULL); for (int i = 0; i < len; i++) { jobject obj = gu_buf_get(state.list, jobject, i); (*env)->SetObjectArrayElement(env, array, i, obj); (*env)->DeleteLocalRef(env, obj); } gu_pool_free(tmp_pool); return array; }
JNIEXPORT jobject JNICALL Java_org_grammaticalframework_pgf_Concr_tabularLinearize(JNIEnv* env, jobject self, jobject jexpr) { jclass map_class = (*env)->FindClass(env, "java/util/HashMap"); if (!map_class) return NULL; jmethodID constrId = (*env)->GetMethodID(env, map_class, "<init>", "()V"); if (!constrId) return NULL; jobject table = (*env)->NewObject(env, map_class, constrId); if (!table) return NULL; jmethodID put_method = (*env)->GetMethodID(env, map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); if (!put_method) return NULL; PgfConcr* concr = get_ref(env, self); GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_exn(tmp_pool); GuEnum* cts = pgf_lzr_concretize(concr, gu_variant_from_ptr((void*) get_ref(env, jexpr)), err, tmp_pool); if (!gu_ok(err)) { if (gu_exn_caught(err, PgfExn)) { GuString msg = (GuString) gu_exn_caught_data(err); throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", msg); } else { throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", "The expression cannot be concretized"); } gu_pool_free(tmp_pool); return NULL; } PgfCncTree ctree = gu_next(cts, PgfCncTree, tmp_pool); if (gu_variant_is_null(ctree)) { gu_pool_free(tmp_pool); return NULL; } size_t n_lins; GuString* labels; pgf_lzr_get_table(concr, ctree, &n_lins, &labels); for (size_t lin_idx = 0; lin_idx < n_lins; lin_idx++) { GuStringBuf* sbuf = gu_string_buf(tmp_pool); GuOut* out = gu_string_buf_out(sbuf); pgf_lzr_linearize_simple(concr, ctree, lin_idx, out, err, tmp_pool); jstring jstr = NULL; if (gu_ok(err)) { GuString str = gu_string_buf_freeze(sbuf, tmp_pool); jstr = gu2j_string(env, str); } else { gu_exn_clear(err); } jstring jname = gu2j_string(env, labels[lin_idx]); (*env)->CallObjectMethod(env, table, put_method, jname, jstr); (*env)->DeleteLocalRef(env, jname); if (jstr != NULL) (*env)->DeleteLocalRef(env, jstr); } gu_pool_free(tmp_pool); return table; }
static PgfExprProb* jpgf_literal_callback_match(PgfLiteralCallback* self, PgfConcr* concr, size_t lin_idx, GuString sentence, size_t* poffset, GuPool *out_pool) { JPgfLiteralCallback* callback = gu_container(self, JPgfLiteralCallback, callback); JNIEnv *env; (*cachedJVM)->AttachCurrentThread(cachedJVM, &env, NULL); jstring jsentence = gu2j_string(env, sentence); size_t joffset = gu2j_string_offset(sentence, *poffset); jobject result = (*env)->CallObjectMethod(env, callback->jcallback, callback->match_methodId, lin_idx, jsentence, joffset); if (result == NULL) return NULL; jclass result_class = (*env)->GetObjectClass(env, result); jfieldID epId = (*env)->GetFieldID(env, result_class, "ep", "Lorg/grammaticalframework/pgf/ExprProb;"); jobject jep = (*env)->GetObjectField(env, result, epId); jclass ep_class = (*env)->GetObjectClass(env, jep); jfieldID exprId = (*env)->GetFieldID(env, ep_class, "expr", "Lorg/grammaticalframework/pgf/Expr;"); jobject jexpr = (*env)->GetObjectField(env, jep, exprId); jfieldID probId = (*env)->GetFieldID(env, ep_class, "prob", "D"); double prob = (*env)->GetDoubleField(env, jep, probId); jfieldID offsetId = (*env)->GetFieldID(env, result_class, "offset", "I"); *poffset = j2gu_string_offset(sentence, (*env)->GetIntField(env, result, offsetId)); PgfExprProb* ep = gu_new(PgfExprProb, out_pool); ep->expr = gu_variant_from_ptr(get_ref(env, jexpr)); ep->prob = prob; { // This is an uggly hack. We first show the expression ep->expr // and then we read it back but in out_pool. The whole purpose // of this is to copy the expression from the temporary pool // that was created in the Java binding to the parser pool. // There should be a real copying function or even better // there must be a way to avoid copying at all. GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_exn(tmp_pool); GuStringBuf* sbuf = gu_string_buf(tmp_pool); GuOut* out = gu_string_buf_out(sbuf); pgf_print_expr(ep->expr, NULL, 0, out, err); GuString str = gu_string_buf_freeze(sbuf, tmp_pool); GuIn* in = gu_data_in((uint8_t*) str, strlen(str), tmp_pool); ep->expr = pgf_read_expr(in, out_pool, err); if (!gu_ok(err) || gu_variant_is_null(ep->expr)) { throw_string_exception(env, "org/grammaticalframework/pgf/PGFError", "The expression cannot be parsed"); gu_pool_free(tmp_pool); return NULL; } gu_pool_free(tmp_pool); } return ep; }
JNIEXPORT jlong JNICALL Java_org_grammaticalframework_pgf_Parser_newCallbacksMap (JNIEnv* env, jclass clazz, jobject jconcr, jobject jpool) { return p2l(pgf_new_callbacks_map(get_ref(env, jconcr), get_ref(env, jpool))); }
JNIEXPORT jstring JNICALL Java_org_grammaticalframework_pgf_Concr_getName(JNIEnv* env, jobject self) { return gu2j_string(env, pgf_concrete_name(get_ref(env, self))); }
JNIEXPORT jstring JNICALL Java_org_grammaticalframework_pgf_PGF_getStartCat(JNIEnv* env, jobject self) { return gu2j_string(env, pgf_start_cat(get_ref(env, self))); }
void main() { float adc_a; float adc_data; int i = 0, k = 0; char send_flag = 0;//1 发送成功 0 重发 // Ds1302Init(); //ds1302初始化函数,更改时间需要用到此函数 inituart(); init_adc(); delayms(1); lcdinit(); charsend("AT+CLTS=1\r\n"); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); while (1) { while (clk_count_last != clk_count) { if (gprs_allow_flag == 1) { delayms(100); gprs_allow_flag = 0; rec_fin = 0; time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200);delayms(200); time_a();//时钟初始化 delayms(200);delayms(200);delayms(200);delayms(200); charsend("AT+CIPSEND=183\r\n"); delayms(100); charsend("POST /data HTTP/1.1\r\nHost:121.40.171.93\r\nContent-Length:87\r\nAuthorization:Basic dGVzdDp0ZXN0\r\n\r\n"); charsend(http_post); } if (gprs_fin_flag == 1&& gprs_fin_flag_2 == 1) { gprs_fin_flag = 0; e_gprs = 0; //互斥访问 charsend("ok2222222222222222"); } if (gprs_fin_flag == 1 && gprs_fin_flag_1 == 1) { gprs_fin_flag = 0; e_gprs = 0; //互斥访问 charsend("ok11111111"); } clk_count_last = clk_count + 1; } clk_count_last = clk_count + 1; clk_count_last = clk_count_last % 600; //datasend( get_ad()); // http_post[54] = (int)chao_data_avg_s % 10 + 48; //传感器数据存在http_post // http_post[53] = (int)chao_data_avg_s / 10 % 10 + 48; // http_post[51] = (int)chao_data_avg_s / 100 % 10 + 48; // http_post[50] = (int)chao_data_avg_s / 100 % 10 + 48; kDisplayListChar(1, 1, myitoa((int)get_ref(),4), 4); kDisplayListChar(1, 2, "13", 6); chao_data[data_count%12] = get_ad(); ///1024* 5 tan_data[data_count%12] = get_ref(); data_count++; data_count=data_count%12; temper = ReadTemperature(); kDisplayListChar(3, 4, strcat(myitoa(temper / 10, 2), "."), 3); kDisplayListChar(5, 4, myitoa(temper % 10, 1), 1); // Ds1302ReadTime(); //时间显示 // time_formchar(time_char); // /******************************************** // adc_data=get_ad(); //这两句是接压力传感器的处理函数 // range=(adc_data-0x00BD)*0.6; // //*********************************************/ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // if (clk_count % 600 % 60 == 0) //每分钟 // { // // split(chao_data, 0, 11); // split(tan_data, 0, 11); // chao_data_avg[data_count_avg%10] = average1(chao_data, 4, 7); // tan_data_avg[data_count_avg%10] = average1(tan_data, 4, 7); // data_count++; // data_count_avg=data_count_avg%10; // // datasend(chao_data_avg[data_count_avg%10]); // } } }
bool cLuaScript::load(std::string filename, Girl *a_girl) { int rc; m_file = filename; girl = a_girl; g_LogFile.ss() << "cLuaScript::load: " << filename; g_LogFile.ssend(); /* * We need to open the file to make sure it exists and can be read * * There doesn't seem to be a better, cross platform way * to do this */ std::ifstream ifs(m_file.c_str(), std::ifstream::in); bool ok = ifs.good(); ifs.close(); if(!ok) return false; /* * So: slurp the file */ std::string prog = slurp(m_file); /* * load the string */ rc = luaL_loadstring(l, prog.c_str()); /* * a non-zero return code means an error occured * log it, and then return false so the script manager * can recycle the script */ if(rc != 0) { log_error(); return false; } /* * call the chunk */ rc = lua_pcall(l, 0, 1, 0); /* * again, check for errors. */ if(rc != 0) { log_error(); return false; } /* * OK. the script should have defined two entry points: * init() and run() * * we need to find these, convert them into references, and store them */ init_ref = get_ref("init"); run_ref = get_ref("run"); g_LogFile.ss() << "init_ref = " << init_ref << "\n"; g_LogFile.ss() << "run_ref = " << run_ref; g_LogFile.ssend(); /* * check the return code */ rc = lua_toboolean(l, -1); g_LogFile.ss() << "script ready: return value " << rc; g_LogFile.ssend(); return (rc != 0); }
JNIEXPORT void JNICALL Java_org_grammaticalframework_pgf_Concr_unload(JNIEnv* env, jobject self) { pgf_concrete_unload(get_ref(env, self)); }