void process(Servo *servo, Instruction b) { enum opcode operation = OPCODE(b); int parameter = PARAM(b); switch(operation) { case MOV: mov(servo, parameter); break; case WAIT: wait(servo, parameter); break; case LOOP_START: loop_start(servo, parameter); execute(servo, servo->recipe[servo->pc]); break; case END_LOOP: end_loop(servo); execute(servo, servo->recipe[servo->pc]); break; case RECIPE_END: recipe_end(servo); break; default: /* Opcode not defined */ break; } }
void BusConnect (void) { _logger->log("Subscription " + _name + " initiating MQTT bus connection."); connect(global_config.mqtt_broker_ip.c_str(), global_config.mqtt_broker_port); loop_start(); }
void Client::connect() { configuration->configure(*this); throwIfError("connect", mosqpp::mosquittopp::connect(configuration->address().c_str(), configuration->port())); throwIfError("loop_start", loop_start()); }
Controller::Controller(const char* id, const char* host, int port) : mosquittopp(id) { printf("Initializing MQTT connections...\n"); mosqpp::lib_init(); // Mandatory initialization for mosquitto library loop_start(); connect_async(host, port, 60); //keepalive interval faceDetector = new FaceDetector(); faceDetector->start_detector(-1, *new Size(240,180)); // faceDetector->start_detector(-1, *new Size(120,90)); };
myMosq(const char * _id,const char * _topic, const char * _host, int _port) : mosquittopp(_id) { mosqpp::lib_init(); // Mandatory initialization for mosquitto library this->keepalive = 60; // Basic configuration setup for myMosq class this->id = _id; this->port = _port; this->host = _host; this->topic = _topic; connect_async(host, // non blocking connection to broker request port, keepalive); loop_start(); // Start thread managing connection / publish / subscribe };
bool analyze(float * spectrum, bool initialized) { #ifdef DETECT_PRINT printf("\n"); #endif ++_iteration_; loop_start(spectrum); if (!initialized) { NBL_WARN("Channel::analyze() not calling _analyze()") } bool ret = initialized ? _analyze() : false; loop_end(); return ret; }
jit_function_t bf_compile(jit_context_t cx, FILE *fp) { jit_type_t params[1], putchar_params[1], signature, putchar_sig, getchar_sig; jit_value_t ptr, uptr, ubyte, tmp; bf_loop_t loop = NULL; ubyte_ptr = jit_type_create_pointer(jit_type_ubyte, 1); params[0] = ubyte_ptr; putchar_params[0] = jit_type_ubyte; signature = jit_type_create_signature(jit_abi_cdecl, jit_type_void, params, 1, 1); putchar_sig = jit_type_create_signature(jit_abi_cdecl, jit_type_ubyte, putchar_params, 1, 1); getchar_sig = jit_type_create_signature(jit_abi_cdecl, jit_type_ubyte, NULL, 0, 1); jit_function_t function = jit_function_create(cx, signature); ptr = jit_value_get_param(function, 0); uptr = jit_value_create_nint_constant(function, ubyte_ptr, 1); ubyte = jit_value_create_nint_constant(function, jit_type_ubyte, 1); ops *unit = (ops*)malloc(sizeof(ops)); unit->count = 0; int first = 1; while(!feof(fp)) { char c = fgetc(fp); if (first) { unit->token = c; first = 0; } switch(c) { case '>': OPTIMIZE_TOKEN('>') case '<': OPTIMIZE_TOKEN('<') case '+': OPTIMIZE_TOKEN('+') case '-': OPTIMIZE_TOKEN('-') case '.': emitOpcodes(function, ptr, unit); unit->token = '.'; tmp = jit_insn_load_relative(function, ptr, 0, jit_type_ubyte); jit_insn_call_native(function, "putchar", putchar, putchar_sig, &tmp, 1, JIT_CALL_NOTHROW); break; case ',': emitOpcodes(function, ptr, unit); unit->token = ','; jit_insn_call_native(function, "getchar", getchar, getchar_sig, NULL, 0, JIT_CALL_NOTHROW); jit_insn_store_relative(function, ptr, 0, tmp); break; case '[': emitOpcodes(function, ptr, unit); unit->token = '['; loop_start(function, &loop); tmp = jit_insn_load_relative(function, ptr, 0, jit_type_ubyte); jit_insn_branch_if_not(function, tmp, &loop->stop); break; case ']': emitOpcodes(function, ptr, unit); unit->token = ']'; loop_stop(function, &loop); break; } } jit_insn_return(function, NULL); jit_function_compile(function); return function; }