void Hint (void) { /* The next 4 lines must be there. */ while (gtk_events_pending ()) { gtk_main_iteration (); } if (ichangestuff == 0) { Play ("click.mp3", 0); } if ((((ifilestuff == 0) && ((biscomputer == 0) || (wiscomputer == 0)) && (iyesno == 0)) && (((((Modulo (imoves, 2) == 0) && (iiamblack == 1)) || ((Modulo (imoves, 2) != 0) && (iiamblack == 0))) && (inet == 1)) || (inet == 0))) && (imoving == 0)) { imoving = 1; if (Modulo (imoves, 2) == 0) { if (inet == 1) idohint = 1; Computer ('b'); idohint = 0; JudgeBoard ('w'); if (wiscomputer == 1) { Computer ('w'); JudgeBoard ('b'); } } else { if (inet == 1) idohint = 1; Computer ('w'); idohint = 0; JudgeBoard ('b'); if (biscomputer == 1) { Computer ('b'); JudgeBoard ('w'); } } imoving = 0; } else { if (inet == 1) { Message ("It is not your move.", 3, 0); } } }
void Can_Controller::write(Frame f) { uint8_t response = delegate.sendMsgBuf(f.id, 0, f.len, f.body); if (response != CAN_OK) { Computer().logTwo("CAN_write_error", canResponseToString(response)); Onboard().logTwo("CAN_write_error", canResponseToString(response)); } }
ComputerList ComputerManager::getComputersInRoom( const QString& roomName, const QModelIndex& parent ) { QAbstractItemModel* model = computerTreeModel(); int rows = model->rowCount( parent ); ComputerList computers; for( int i = 0; i < rows; ++i ) { QModelIndex entryIndex = model->index( i, 0, parent ); auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() ); switch( objectType ) { case NetworkObject::Group: if( model->data( entryIndex, NetworkObjectModel::NameRole ).toString() == roomName ) { computers += getComputersInRoom( roomName, entryIndex ); } break; case NetworkObject::Host: computers += Computer( model->data( entryIndex, NetworkObjectModel::UidRole ).toUuid(), model->data( entryIndex, NetworkObjectModel::NameRole ).toString(), model->data( entryIndex, NetworkObjectModel::HostAddressRole ).toString(), model->data( entryIndex, NetworkObjectModel::MacAddressRole ).toString() ); break; default: break; } } return computers; }
int printComputerTableINT(QSqlQuery &query, vector<Computer>& vect) { int width1 = 29; int width2 = 13; int width3 = 21; int width4 = 5; char sep = ' '; cout << " " << left << setw(width1) << setfill(sep) << "Name" << " | " << left << setw(width2) << setfill(sep) << "Creation Time" << " | " << left << setw(width3) << setfill(sep) << "Type" << " | " << left << setw(width4) << setfill(sep) << "Built" << endl; cout << left << setw(width1 + width2 + width3 + width4 + 10) <<setfill('-') << "" << endl; int i = 0; while(query.next()) { vect.push_back(Computer(query.value("name").toString().toStdString(), query.value("year_creation").toInt(), query.value("type").toString().toStdString(), query.value("was_built").toInt())); cout << " " << left << setw(width1) << setfill(sep) << vect.back().getnm() << " | " << right << setw(width2) << setfill(sep) << vect.back().getyc() << " | " << left << setw(width3) << setfill(sep) << vect.back().gettp() << " | "; if(vect.back().getwcb() == true) cout << left << setw(width4) << setfill(sep) << "Yes" << endl; else cout << left << setw(width4) << setfill(sep) << "No" << endl; i++; } return i; }
void solve() { MOUSEMSG m; long i,j,k,r,w,x,y; long nowx=-1,nowy=-1; while(1) { m = GetMouseMsg(); x = ( m.x - (BL-SIDE/2) ) / SIDE; y = ( m.y - (BH-SIDE/2) ) / SIDE; if( ok(x,y) ) { switch(m.uMsg) { case WM_MOUSEMOVE: //移动 if( nowx != x || nowy != y ) MoveMouse(x,y); break; case WM_LBUTTONDOWN: //按下 PressMouse(x,y); Computer(); break; } nowx = x; nowy = y; if( Pan() ) break; } } End(); }
void ConsoleUI::add_computer() { Computer c = Computer(); string name_, type_, yearBuilt_, wasBuilt_; clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "Name of Computer:" << endl; cout << endl << " -> "; cin >> name_; clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "Type of Computer:" << endl; cout << endl << " -> "; cin >> type_; clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "When was the computer built? [YYYY]" << endl; cout << endl << " -> "; cin >> yearBuilt_; while (!is_digits(yearBuilt_)) { clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "Invalid input! Please try again:" << endl; cout << "When was the computer built? [YYYY]" << endl; cin >> yearBuilt_; } clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "Was the computer built? [Y/N]" << endl; cout << endl << " -> "; cin >> wasBuilt_; while ((wasBuilt_ != "Y") && (wasBuilt_ != "N") && (wasBuilt_ != "y") && (wasBuilt_ != "n")) { clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "Invalid input! Please try again:" << endl; cout << "Was the computer built? [Y/N]" << endl; cout << endl << " -> "; cin >> wasBuilt_; } if ((wasBuilt_ == "Y") || (wasBuilt_ == "y")) { c.set_wasBuilt("Yes"); } else if ((wasBuilt_ == "N") || (wasBuilt_ == "n")) { c.set_wasBuilt("No"); } fix_string(name_); fix_string(type_); c.set_name(name_); c.set_type(type_); c.set_yearBuilt(yearBuilt_); dbService.addC(c); clear_screen(); cout << readFileToString("../templates/commands.txt") << endl; cout << "\t\t " << "Computer has been added to the list! \n\n\n\n\n\n\n" << endl; }
Frame Can_Controller::read() { Frame frame; uint8_t response = delegate.readMsgBuf(&frame.len, frame.body); if (response != CAN_OK) { Computer().logTwo("CAN_read_error", canResponseToString(response)); Onboard().logTwo("CAN_read_error", canResponseToString(response)); } frame.id = delegate.getCanId(); return frame; }
Computer setComputer() { string name, comptype; int yearCreate; bool built; legalComputer(name, yearCreate, comptype, built); return Computer(name, yearCreate, comptype, built); }
void ScientistComputerConnectionsRepository::populateComputerList(std::list<Computer> &computerList, QSqlQuery query){ while(query.next()){ Computer c = Computer(); c.setId(query.value("ID").toInt()); c.setName(query.value("Name").toString().toStdString()); c.setYearBuilt(query.value("YearBuilt").toString().toStdString()); c.setType(query.value("Type").toInt()); c.setWasBuilt(query.value("WasBuilt").toInt()); computerList.push_back(c); } }
void Move_chessman(void) { int row=35,column=35,count=0,key=0,flag=1; void far *image1=0,*image2=0; setcolor(WHITE); setfillstyle(SOLID_FILL,WHITE); sector(column,row,0,360,15,15); getimage(50,50,80,80,image); image_null=image; while(key!=27) { key=Getkey(); switch(key) { case 72 : row=Limit(72,row); UP(column,row); Trace(72,row); break; case 80 : row=Limit(80,row); DOWN(column,row); Trace(80,row); break; case 75 : column=Limit(75,column); LIFT(column,row); Trace(75,column); break; case 77 : column=Limit(77,column); RIGHT(column,row); Trace(77,column); break; case 13 : Computer(column,row); Move_chessman(); break; case 27 : END(); break; default : break; } } }
void Can_Controller::begin() { // Idempotent if (begun) { return; } begun = true; // Set interrupt pin. // DON'T set MCP_CS: mcp_can library does it for us pinMode(MCP_INT_PIN, INPUT); uint8_t response = delegate.begin(CAN_500KBPS); if (delegate.begin(CAN_500KBPS) != CAN_OK) { Computer().logTwo("CAN_begin_error", canResponseToString(response)); Onboard().logTwo("CAN_begin_error", canResponseToString(response)); } }
ComputerList ComputerManager::getCheckedComputers(const QModelIndex &parent) { QAbstractItemModel* model = computerTreeModel(); int rows = model->rowCount( parent ); ComputerList computers; for( int i = 0; i < rows; ++i ) { QModelIndex entryIndex = model->index( i, 0, parent ); if( model->data( entryIndex, NetworkObjectModel::CheckStateRole ).value<Qt::CheckState>() == Qt::Unchecked ) { continue; } auto objectType = static_cast<NetworkObject::Type>( model->data( entryIndex, NetworkObjectModel::TypeRole ).toInt() ); switch( objectType ) { case NetworkObject::Group: computers += getCheckedComputers( entryIndex ); break; case NetworkObject::Host: computers += Computer( model->data( entryIndex, NetworkObjectModel::UidRole ).value<NetworkObject::Uid>(), model->data( entryIndex, NetworkObjectModel::NameRole ).toString(), model->data( entryIndex, NetworkObjectModel::HostAddressRole ).toString(), model->data( entryIndex, NetworkObjectModel::MacAddressRole ).toString() ); break; default: break; } } return computers; }
Controler::Controler(){ in = Input(); com = Computer(); out = Output(); eh = ExceptionHandler(); }
void main() { int in ; clrscr(); net_delete_name("Database_Engin2"); int_5C_vector = getvect(0X5C); if(int_5C_vector ==(void far *) NULL) printf("Error"); else printf("Net Bios Installed\n"); // To get the Machine Name regs.x.dx =FP_OFF( (void far *)&machine); sregs.ds =FP_SEG( (void far *)&machine); regs.x.ax =0x5E00; int86x(0x21,®s,®s,&sregs); if (regs.h.ch ==0) printf("Error No Machine Name\n"); else { netbios_name_number =regs.h.cl; printf("The Machine Name is %s\n",machine.machine_name); } //To get the user Name regs.h.ah =0xDC; int86(0x21,®s,®s); connect_num =regs.h.al; printf("The Connection Number is %d\n ", connect_num); request_buffer.request_length =2; request_buffer.subfunction =0x16; request_buffer.buffer_connect_num =connect_num; reply_buffer.reply_length =61; regs.h.ah =0xE3; sregs.ds =FP_SEG( (void far *)&request_buffer); regs.x.si =FP_OFF( (void far *)&request_buffer); sregs.es =FP_SEG( (void far *)&reply_buffer); regs.x.di =FP_OFF( (void far *)&reply_buffer); int86x(0x21,®s,®s,&sregs); printf("The User Id is %s\n",reply_buffer.object_name); regs.h.ah =0xEA; regs.h.al =1; regs.x.bx =0; sregs.es =FP_SEG( (void far *)&reply_buffer2); regs.x.di =FP_OFF( (void far *)&reply_buffer2); int86x(0x21,®s,®s,&sregs); if (regs.x.bx ==0) printf("Not A Netware Lan\n"); else printf("This is a Netware Lan\n"); // To add a name to local name table strcpy(netbios_name,"Database_Engin2"); while (strlen(netbios_name) < 15) strcat(netbios_name," "); memset(&add_name_ncb,0,sizeof(NCB)); add_name_ncb.NCB_COMMAND =ADD_NAME; strcpy(add_name_ncb.NCB_NAME,netbios_name); sregs.es = FP_SEG((void far*)&add_name_ncb); regs.x.bx =FP_OFF((void far *)&add_name_ncb); int86x(0x5C,®s,®s,&sregs); while(add_name_ncb.NCB_CMD_CPLT == 0xFF) ; if(add_name_ncb.NCB_CMD_CPLT != 0) { printf("Error Could not add to name table\n"); } FrontScreen(); P = Menu(2,menu2); //outtextxy(maxx/2,maxy/2,itoa(P,str,10)); if (P==0) Computer(machine.machine_name); // PROCEDURE TO RECEIVE MACHINE NAME FROM THREE COMPUTERS for(i=1;i<=3;i++) //receiving the machine name from the // computers three { memset(&recv_ncb,0,sizeof(NCB)); recv_ncb.NCB_COMMAND =RECEIVE_DATAGRAM; recv_ncb.NCB_NUM = add_name_ncb.NCB_NUM; recv_ncb.NCB_BUFFER_PTR =(void far *)&machine; recv_ncb.NCB_LENGTH =sizeof(machine); sregs.es = FP_SEG((void far*)&recv_ncb); regs.x.bx =FP_OFF((void far *)&recv_ncb); int86x(0x5C,®s,®s,&sregs); while(recv_ncb.NCB_CMD_CPLT == 0Xff) ; switch(i) { case 1:Computer2(machine.machine_name); break; case 2:Computer1(machine.machine_name); break; case 3:Computer3(machine.machine_name); break; } // printf("%s\n" ,machine.machine_name); if (recv_ncb.NCB_CMD_CPLT != 0) { printf("Error,Could Not Receive Message\n"); exit(1); } } // PROCEDURE TO SEND FILE NAME TO THREE COMPUTERS P = Menu(3,menu1); //if(P==0) filename=Send(); strcpy(struct_send.msg,filename); strcpy(destination,"Bllot3 "); memset(&send_ncb,0,sizeof(NCB)); send_ncb.NCB_COMMAND =SEND_DATAGRAM; send_ncb.NCB_NUM = add_name_ncb.NCB_NUM; send_ncb.NCB_BUFFER_PTR =(void far *)&struct_send; send_ncb.NCB_LENGTH =sizeof(struct_send); strcpy(send_ncb.NCB_CALLNAME,destination); sregs.es = FP_SEG((void far*)&send_ncb); regs.x.bx =FP_OFF((void far *)&send_ncb); int86x(0x5C,®s,®s,&sregs); while(send_ncb.NCB_CMD_CPLT == 0Xff); if (send_ncb.NCB_CMD_CPLT != 0) { printf("Error,Could Not Send Message\n"); } closegraph(); delay(4000); // PROCEDURE TO RECEIVE ACK FROM THREE COMPUTERS /* for(i=1;i<=1;i++) //receiving the machine name from the // computers three { memset(&recv_ncb,0,sizeof(NCB)); recv_ncb.NCB_COMMAND =RECEIVE_DATAGRAM; recv_ncb.NCB_NUM = add_name_ncb.NCB_NUM; recv_ncb.NCB_BUFFER_PTR =(void far *)&machine; recv_ncb.NCB_LENGTH =sizeof(machine); sregs.es = FP_SEG((void far*)&recv_ncb); regs.x.bx =FP_OFF((void far *)&recv_ncb); int86x(0x5C,®s,®s,&sregs); while(recv_ncb.NCB_CMD_CPLT == 0Xff) ; switch(i) { case 1:Computer2(machine.machine_name); break; case 2:Computer1(machine.machine_name); break; case 3:Computer3(machine.machine_name); break; } if (recv_ncb.NCB_CMD_CPLT != 0) { printf("Error,Could Not Receive Message\n"); exit(1); } } */ net_delete_name("Database_Engin2"); exit(1); } //End of main
void Pass (void) { /* The next 4 lines must be there. */ while (gtk_events_pending ()) { gtk_main_iteration (); } if (ichangestuff == 0) { Play ("click.mp3", 0); } if ((((ifilestuff == 0) && ((biscomputer == 0) || (wiscomputer == 0)) && (iyesno == 0)) && (((((Modulo (imoves, 2) == 0) && (iiamblack == 1)) || ((Modulo (imoves, 2) != 0) && (iiamblack == 0))) && (inet == 1)) || (inet == 0))) && (imoving == 0)) { imoving = 1; if (inet == 1) { SendData (1, "pass"); } if (Modulo (imoves, 2) == 0) { JudgeBoard ('w'); } else { JudgeBoard ('b'); } pass[ihistory] = 1; iscorewhite = ScoreWhite (); iscoreblack = ScoreBlack (); if (Modulo (imoves, 2) != 0) { if ((iscorewhite > iscoreblack) || (pass[ihistory - 1] == 1)) { if (iscorewhite > iscoreblack) { iduh = 1; } EndGame (); } else { if (wiscomputer == 1) { Computer ('w'); JudgeBoard ('b'); } } } else { if ((iscoreblack > iscorewhite) || (pass[ihistory - 1] == 1)) { if (iscoreblack > iscorewhite) { iduh = 1; } EndGame (); } else { if (biscomputer == 1) { Computer ('b'); JudgeBoard ('w'); } } } imoving = 0; } else { if (inet == 1) { Message ("It is not your move.", 3, 0); } } }