int main(int argc, char *argv[]) { uint8_t dev_addr; char *err_char; if (argc != 2) { fprintf(stderr, "USAGE: %s DEV_ADDR\n", argv[0]); exit(EXIT_FAILURE); } dev_addr = strtol(argv[1], &err_char, 0); if (adt7410_init(dev_addr, ADT7410_RES_16BIT) != 0) { return EXIT_FAILURE; } while (1) { if (sense(dev_addr) !=0) { return EXIT_FAILURE; } sleep(1); } return EXIT_SUCCESS; }
void TankAI::brainTick(float seconds) { //listen closely and watch out for enemies. sense(); //take a decision if (_currentTarget == NULL && _strategy != EXPLORE) { switchStrategy(EXPLORE, NULL); } else if (_currentTarget != NULL && _strategy != HUNT) { switchStrategy(HUNT, _currentTarget); delete _path; _path = NULL; } //do what you decided to do switch (_strategy) { case HUNT: { hunt(); break; } case EXPLORE: { explore(); break; } case ESCAPE: { escape(); break; } } }
void DHTSensor::print(OLEDDisplay* display, int x, int y) { sense(); display->drawString(x, y, "DHT Sensor"); display->drawString(x, y+10, "Temp: " + String(temperature)); display->drawString(x, y+20, "Hum: " + String(humidity)); }
bool Player::init() { if (!Agent::init()) return false; // get the respond (first message) from the server shared_ptr<Perception> p = sense(); if (0 == p.get()) { return false; } if (!WM.update(p)) return false; // scened the init message shared_ptr<Action> iAct(new InitAction(OPTS.arg<string > ("teamname"), OPTS.arg<unsigned int>("unum"))); perform(iAct); //Allen, for GUI under new server sense(); shared_ptr<Action> bAct = shared_ptr<Action > (new BeamAction(FM.getMy().beforeKickOffBeam)); perform(bAct); return true; }
void nscsi_full_device::scsi_unknown_command() { logerror("%s: Unknown command", tag()); for(int i=0; i != scsi_cmdsize; i++) logerror(" %02x", scsi_cmdbuf[i]); logerror("\n"); scsi_status_complete(SS_CHECK_CONDITION); sense(false, 5); }
void ReplacementHT::get_generic_description_string(char* str) const { sprintf(str, "%" PRId8 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId8 " %" PRId16 " %" PRId16 " %" PRId32 " %" PRId32 " ", get_mut_type(), donor_pos1(), donor_pos2(), receiver_pos1(), receiver_pos2(), sense(), align1_.get_score(), align2_.get_score(), length_, replaced_seq_length_); }
void DHTSensor::report() { sense(); if (!error) { publish("temperature", temperature); publish("humidity", humidity); } else publish("log", "Error reading out sensor"); }
// // Sense Test Task // void senseTask(CThread *p_thread, xHandle p_param) { SENSE_PARAM_T *p_sense = (SENSE_PARAM_T *) p_param; gpioSense sense(p_sense->sense_pin, p_sense->trigger); gpioSense::enable(); CPin led(p_sense->led_pin); led.output(); while( p_thread->isAlive() ) { if ( gpioSense::wait() ) { if ( sense.isActived() ) { led.toggle(); } } } }
int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; //Initialize the movement parameters P10OUT &= ~(BIT4+BIT5+BIT6+BIT7); // P10.0-3 low P10SEL = 0x00; // All of port 10 set up for digital I/O P10DIR |= BIT4+BIT5+BIT6+BIT7; // configure P10.0 as output //set up LEDs P1SEL &= ~(BIT1 + BIT0); // configure P1.0 & P1.1 for digital IO P1DIR |= BIT0 + BIT1; ledSetup(1); P6OUT |= BIT7; P6DIR &= ~BIT7; P6REN |= BIT7; P7OUT |= BIT4+BIT5+BIT6; P7DIR &= ~BIT4+BIT5+BIT6; P7REN |= BIT4+BIT5+BIT6; //setup the button P2OUT = BIT6; P2DIR = ~BIT6; P2REN = BIT6; while( P2IN & BIT6 ); ledSetup(0); accelforward(); while( P2IN & BIT6 ) { sense(); } stop(); return 0; }
static gboolean button_press_event( GtkWidget *widget, GdkEventButton *event ) { if(page == 2) { if (event->button == 1) { sense( (int)event->x, (int)event->y); } } else if(page == 1) { if(((int)event->x > 715 && (int)event->x < 942) && ((int)event->y > 628 && (int)event->y < 693)) { hidePageOne(); showPageTwo(); Tempo = (int)gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(TempoEntry)); SongName = (char*)gtk_entry_get_text(GTK_ENTRY(NameEntry)); strcat(SongName,".rra"); PlaySong = (char*)malloc(strlen("rplay ")+1+strlen(SongName)); PlaySong[0]='\0'; strcat(PlaySong,"rplay "); strcat(PlaySong,SongName); page = 2; } } else if(page == 0) { showPageOne(); page = 1; } printf( "%d %d \n",(int)event->x, (int)event->y); return TRUE; }
/* args: * * 1: Port to listen on * 2: Device name of sound card * */ int main(int argc, char** argv) { char* dev_name; int aud_fd; struct spsv_commobj sc; if (argc != 2) { printf("Usage: specserver <devname>\n"); exit(-1); } dev_name = argv[1]; aud_fd = open_auddev(dev_name); printf("Audio device opened, waiting for contact\n"); build_commobj(&sc); wait_for_request_transmission(&sc); sense(aud_fd, &sc); return 1; }
void nscsi_full_device::bad_lun() { scsi_status_complete(SS_CHECK_CONDITION); sense(false, 2); }
void loop() { // listen for incoming clients EthernetClient client = server.available(); if (client) { Serial.println("new client"); // an http request ends with a blank line while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); if(c == '?'){ startRequest = true; noReq = false; }else if(c == ' '){ startRequest = false; } if(startRequest){ httpReq += c; } if(light){ button = "Turn the system off."; action = "/?OFF"; sense(); }else{ button = "Arm the system."; action = "/?ON"; motionStart = ""; measurement = ""; } // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response if(noReq){ client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.println("<head>"); client.println("<link rel='stylesheet' href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'><script type='text/javascript' src='http://code.jquery.com/jquery-2.1.1.min.js'></script><script type='text/javascript'>$.ajax({url: 'http://107.170.57.28/return.php', type: 'get', success: function (response){$('body').html(response)}});</script></head><body></body>"); client.println("</head>"); client.println("</html>"); }else{ client.println(); client.print("{\"sensorLog\": \""); client.print(sensorLog); client.print(motionStart); client.print(measurement); client.print("\",\"action\": \"" + action + "\"}"); } break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } if(httpReq == "?ON"){ digitalWrite(7, HIGH); digitalWrite(3, LOW); sensorLog = ("Calibrating sensor <br /> Done <br /> SENSOR ACTIVE <br /> Motion Detected at: "); measurement = " sec"; light = true; }else if(httpReq == "?OFF"){ // digitalWrite(7, LOW); sensorLog = ("System turned off"); light = false; }else if(httpReq == "?PLAY"){ play(); } noReq = true; Serial.print("HTTPReq: "); Serial.print(httpReq); httpReq = ""; // give the web browser time to receive the data delay(1); // close the connection: client.stop(); Serial.println("client disonnected"); } }
Eigen::VectorXd SensorModel::sense(const Eigen::VectorXd &state) const { return sense(state, Eigen::VectorXd::Zero(noiseDim)); }