int main(int argc, char * argv[]){ int k = 3; if(argc > 1){ int i = 0; k = 0; while(argv[1][i] != 0 ){ k = k*10 + argv[1][i] - '0'; ++i; } ++k; } //printf("begin\n"); size = k; filled = 0; inBuf = malloc(size); outBuf = malloc(size); Reading(); free(inBuf); free(outBuf); return 0; }
void* RunThread(void* threadArgument) { Reader* reader = (Reader*)threadArgument; int dataLength = 256; int readResult = 0; ofstream file; file.open(reader->GetFileName(), ios::app); while(reader->GetSerial()->IsConnected()) { system("cls"); char incomingData[dataLength]; readResult = reader->GetSerial()->ReadData(incomingData,dataLength); string s = incomingData; if (readResult > 0) { reader->SetReading(Reading(incomingData)); if(reader->GetReading().GetErrorMessage() == "") { file<<"XAccel = "<<reader->GetReading().GetAccelerationXAxis()<<'\t'<<"YAccel = "<<reader->GetReading().GetAccelerationYAxis()<<'\t'<<"ZAccel = "<<reader->GetReading().GetAccelerationZAxis()<<'\t'<<"XGyro = "<<reader->GetReading().GetGyroXAxis()<<'\t'<<"YGyro = "<<reader->GetReading().GetGyroYAxis()<<'\t'<<"ZGyro = "<<reader->GetReading().GetGyroZAxis()<<endl; reader->PrintReading(); } } char dataToWrite[1] = {'1'}; reader->GetSerial()->WriteData(dataToWrite, 1); Sleep(35); } }
int main() { cout << "Please enter input file name: "; string name; cin >> name; ifstream ist(name.c_str()); if (!ist) error("cannot open input file ", name); cout << "Please enter name of output file: "; cin >> name; ofstream ost(name.c_str()); if (!ost) error("cannot open outputfile ", name); vector<Reading> temps; int hour; double temperature; while (ist >> hour >> temperature) { if (hour < 0 || 23 < hour) error("hour out of range ", hour); temps.push_back(Reading(hour, temperature)); } for (int i=0; i<temps.size(); i++) { ost << "(" << temps[i].hour << ", " << temps[i].temperature << ")" << endl; } }
void Animal::send(Position position, int power) const { Reading reading = Reading(number,position,power); trackSystem->recieve(reading); }
void MainWindow::readResponse() { //qDebug() << "Data Ready"; // char c; // QString t; // while (serial.getChar(&c)) { // if (c == '\n') { //'&' is the terminating character of valid data // rx_data = string(response.constData()); // t = QString::fromStdString(rx_data); // double val = t.toDouble(); // qDebug() << "Data = " << t; // if (val < 100) // realtimeDataSlot(val,val,val); // else // realtimeDataSlot(0,0,0); // response.clear(); // } // else { // //if (c != '\n') // '&' is the starting character of valid data // response.append(c); // qDebug() << "Reading..." << c; // } // } //Below is the Code for IMU double ax,ay,az,gx,gy,gz; char a = '1',c; const char* ack = &a; serial.write(ack); string s = ""; while (serial.getChar(&c)) { if (c == '\r') { //'&' is the terminating character of valid data s = string(response.constData()); const char* rx_data_char = s.c_str(); // rx_data = s; rx_data.append(rx_data_char); // qDebug() << "Data = " << QString::fromStdString(s); // double val = rx_data.toDouble(); if (s[0] == '#' && s[1] == 'G') { qDebug() << "Total Data = " << QString::fromStdString(rx_data); Reading reading = Reading(rx_data); if (reading._validReading) { ax = reading.GetAccelerationXAxis(); ay = reading.GetAccelerationYAxis(); az = reading.GetAccelerationZAxis(); qDebug() << "Xacc = " << ax; qDebug() << "Yacc = " << ay; qDebug() << "Zacc = " << az; qDebug() << "Xgyro = " << reading.GetGyroXAxis(); qDebug() << "Ygyro = " << reading.GetGyroYAxis(); qDebug() << "Zgyro = " << reading.GetGyroZAxis(); realtimeDataSlot(ax,ay,az); } else qDebug() << "Current String = " << QString::fromStdString(reading._currentString) << " " << QString::fromStdString(reading.GetErrorMessage()); } else qDebug() << "Double Extraction Error"; response.clear(); if (s[0] == '#' && s[1] == 'G') rx_data = ""; serial.write(ack); break; } else { if (c != '\n') response.append(c); //qDebug() << "Reading..." << c; } } }
void MainLoop() { int a=0,b=0; while(1) { you.player_move = true; if(you.s_timestep) { turn_skip(); Sleep(16); continue; } int char_ = waitkeyinput(); you.prev_hp[1] = you.hp; you.prev_mp[1] = you.mp; switch(char_) { case 'j': Move(coord_def(you.position.x,you.position.y-1)); //위 break; case 'k': Move(coord_def(you.position.x,you.position.y+1)); //아래 break; case 'h': Move(coord_def(you.position.x-1,you.position.y)); //왼쪽 break; case 'l': Move(coord_def(you.position.x+1,you.position.y)); //오른쪽 break; case 'b': Move(coord_def(you.position.x-1,you.position.y+1)); break; case 'n': Move(coord_def(you.position.x+1,you.position.y+1)); break; case 'y': Move(coord_def(you.position.x-1,you.position.y-1)); break; case 'u': Move(coord_def(you.position.x+1,you.position.y-1)); break; case 'x': //주위탐색 Search(); break; case 's': //턴스킵 case '.': //턴스킵 turn_skip(); break; case 'g': case ',': //줍기 PickUp(); break; case 'i': //아이템확인 iteminfor(); break; case 'd': //아이템버리기 iteminfor_discard(); break; case 'D': //마지막에 먹은 아이템 버리기 fast_discard(); break; case 'w': //무기장착 Equip_Weapon(); break; case 'W': //방어구장착 Equip_Armor(); break; case 'T': //방어구해제 Unequip_Armor(); break; case 'C': //문닫기 Close_door(); break; case 'O': //문열기 Open_door(); break; case 'o': //자동이동 auto_Move(); break; case '5': //100턴넘기기 long_rest(); break; case 0x88: //컨트롤P - 로그 view_log(); break; case 15: //컨트롤o if(isNormalGame()) dungeonView(); break; case 'e': //먹기 Eatting(); break; case 'q': //마시기 Drinking(); break; case 'r': //읽기 Reading(); break; case 'm': //스킬정보창 skill_view(); break; case 'P': //장신구장착 Equip_Jewelry(); break; case 'R': //장신구해제 Unequip_Jewelry(); break; case 'S': //체크후 종료 saveandcheckexit(); break; case 0x89: //강제종료 nosaveandexit(); break; case 0x8A: //저장과 종료 saveandexit(); break; case 'X': //넓은탐색 Wide_Search(); break; case 'f': //던지기(빠른) Quick_Throw(you.GetThrowIter(),you.GetTargetIter()); break; case 'F': //던지기(선택) Select_Throw(); break; case '\\': //식별템 확인 Iden_Show(); break; case '>': Stair_move(true); break; case '<': Stair_move(false); break; case '%': stat_view(); break; case '}': Weapon_Show(); break; case '[': Armour_Show(); break; case ']': rune_Show(); break; case '\"': Amulet_Show(); break; case '@': Simple_State_Show(); break; case 'N': //sendScore(); break; case 'E': Experience_Show(); break; //case 'c': // Spelllcard_Declare(); // //Eat_Power(); // break; case 'v': case 'V': Spelllcard_Evoke(); break; case 'p': Pray(); break; case '#': if(isNormalGame() && Dump(0,NULL)) printlog("덤프에 성공했습니다.",true,false,false,CL_normal); break; case 'Z': case 'z': SpellUse(); break; case 'I': SpellView(); break; case 'a': SkillUse(); break; case 'A': PropertyView(); break; case 'M': run_spell(); break; case 't': shout(); break; case '^': God_show(); break; case '&': //위자드모드! //waitkeyinput(); wiz_mode(); break; case '_': save_mode(); break; case 0x8B: auto_pick_onoff(false); break; case '?'://도움말 Help_Show(); break; case VK_ESCAPE://esc escape(); break; case VK_TAB: auto_battle(); break; default: break; } } }