dlgIRC::dlgIRC() { setupUi(this); session = new IrcSession(this); irc->setOpenExternalLinks ( true ); setUnifiedTitleAndToolBarOnMac( true ); connect( irc, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); connect( session, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(onMessageReceived(IrcMessage*))); connect( session, SIGNAL(connected()), this, SLOT(onConnected())); connect( lineEdit, SIGNAL(returnPressed()), this, SLOT(sendMsg())); QFile file( QDir::homePath()+"/.config/mudlet/irc_nick" ); file.open( QIODevice::ReadOnly ); QDataStream ifs( & file ); QString nick; ifs >> nick; file.close(); if( nick.isEmpty() ) { nick = tr("Mudlet%1").arg(QString::number(rand()%10000)); QFile file( QDir::homePath()+"/.config/mudlet/irc_nick" ); file.open( QIODevice::WriteOnly | QIODevice::Unbuffered ); QDataStream ofs( & file ); ofs << nick; file.close(); } session->setNickName(nick); mNick = nick; session->setUserName("mudlet"); session->setRealName(mudlet::self()->version); session->setHost("irc.freenode.net"); session->setPort(6667); session->open(); }
bool IServerApp::sendMsg( uint32_t nSessionID , const char* pBuffer , uint16_t nLen, bool bBroadcast ) { if ( isConnected() == false ) { LOGFMTE("target svr is not connect , send msg failed") ; return false ; } stMsgTransferData msgTransData ; msgTransData.nSenderPort = getLocalSvrMsgPortType() ; msgTransData.bBroadCast = bBroadcast ; msgTransData.nSessionID = nSessionID ; int nLne = sizeof(msgTransData) ; if ( nLne + nLen >= MAX_MSG_BUFFER_LEN ) { stMsg* pmsg = (stMsg*)pBuffer ; LOGFMTE("msg send to session id = %d , is too big , cannot send , msg id = %d ",nSessionID,pmsg->usMsgType) ; return false; } memcpy_s(m_pSendBuffer ,sizeof(m_pSendBuffer),&msgTransData,nLne); memcpy_s(m_pSendBuffer + nLne ,sizeof(m_pSendBuffer) - nLne, pBuffer,nLen ); nLne += nLen ; sendMsg(m_pSendBuffer,nLne); return true ; }
void TcpThread::opeatorData() { OperatorSql w; char ch = data[2].at(0).toAscii(); //将QChar 转换为标准C语言的ASCII,上网找了,switch在QT中只能支持整型对象 //操作数据库 if (!w.createConnection()) { sendMsg(tr("SQL_LINK_ERROR")); return; } /* if(!w.verifyUser(data[0],data[1]))//用户名密码错误 { sendMsg(tr("USER_PASSWORD_ERROR")); tcpSocket->disconnectFromHost();//断开连接 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); qDebug()<< tr("用户或者密码不正确!")<<"\n"; return; } */ QString sqlstr = data[3];//取出SQL语句 switch(ch) { case 'Q': { w.queryRecode(sqlstr); saveLog(); break;//保存日志 } case 'A': { if(w.addRecode(sqlstr)) { sendMsg(tr("ADD_SUCCESS")); saveLog(); break; } else { sendMsg(tr("ADD_FAILED")); break; } } case 'D': { if(w.deleteRecode(sqlstr)) { sendMsg(tr("DELETE_SUCCESS")) ; saveLog(); break; } else { sendMsg(tr("DELETE_FAILED")); break; } } case 'U': { if( w.updateRecode(sqlstr)) { sendMsg(tr("UPDATE_SUCCESS")); saveLog(); break; } else { sendMsg(tr("UPDATE_FAILED")); break; } } default: sendMsg(tr("UNKOWN_ERROR")); break; } }
bool Monitor::coach_move( const char * command ) { char obj[128]; double x = 0.0, y = 0.0, ang = 0.0, velx = 0.0, vely = 0.0; int n = std::sscanf( command, " ( move ( %127[^)] ) %lf %lf %lf %lf %lf ) ", obj, &x, &y, &ang, &velx, &vely ); if ( n < 3 || std::isnan( x ) != 0 || std::isnan( y ) != 0 || std::isnan( ang ) != 0 || std::isnan( velx ) != 0 || std::isnan( vely ) != 0 ) { sendMsg( MSG_BOARD, "(error illegal_object_form)" ); return false; } std::string obj_name = "("; obj_name += obj; obj_name += ')'; if ( obj_name == BALL_NAME ) { M_stadium.clearBallCatcher(); if ( n == 3 || n == 4 ) { M_stadium.moveBall( PVector( x, y ), PVector( 0.0, 0.0 ) ); } else if ( n == 6 ) { M_stadium.moveBall( PVector( x, y ), PVector( velx, vely ) ); } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } } else { char teamname[128]; int unum = 0; if ( std::sscanf( obj_name.c_str(), PLAYER_NAME_FORMAT, teamname, &unum ) != 2 || unum < 1 || MAX_PLAYER < unum ) { sendMsg( MSG_BOARD, "(error illegal_object_form)" ); return false; } Side side = ( M_stadium.teamLeft().name() == teamname ? LEFT : M_stadium.teamRight().name() == teamname ? RIGHT : NEUTRAL ); PVector pos( x, y ); PVector vel( velx, vely ); ang = Deg2Rad( rcss::bound( ServerParam::instance().minMoment(), ang, ServerParam::instance().maxMoment() ) ); if ( n == 3 ) { M_stadium.movePlayer( side, unum, pos, NULL, NULL ); } else if ( n == 4 ) { M_stadium.movePlayer( side, unum, pos, &ang, NULL ); } else if ( n == 6 ) { M_stadium.movePlayer( side, unum, pos, &ang, &vel ); } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } } sendMsg( MSG_BOARD, "(ok move)" ); return true; }
void elFlowPort::sendCmd( const std::string& cmd ) { sendMsg( cmd.c_str(), cmd.size(), false ); }
void IdDialog::IdListCustomPopupMenu( QPoint ) { QMenu contextMnu( this ); std::list<RsGxsId> own_identities ; rsIdentity->getOwnIds(own_identities) ; QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); if (item) { uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ; if(!(item_flags & RSID_FILTER_OWNED_BY_YOU)) { if(own_identities.size() <= 1) { QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); if(own_identities.empty()) action->setEnabled(false) ; else action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; } else { QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ; for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it) { RsIdentityDetails idd ; rsIdentity->getIdDetails(*it,idd) ; QPixmap pixmap ; if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG")) pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ; QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity())); action->setData(QString::fromStdString((*it).toStdString())) ; } } contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg())); } } contextMnu.addSeparator(); contextMnu.addAction(ui->editIdentity); contextMnu.addAction(ui->removeIdentity); contextMnu.addSeparator(); contextMnu.exec(QCursor::pos()); }
// // bool sendState(toID) // Last modified: 27Aug2006 // // Attempts to send the state of the cell // to the neighbor with the parameterized ID, // returning true if successful, false otherwise. // // Returns: true if successful, false otherwise // Parameters: // toID in the ID of the receiving neighbor // bool Cell::sendState(const GLint toID) { return sendMsg(new State(*this), toID, STATE); } // sendState(const GLint)
void obp_canraw(void *pvParameters) { //>>>> oobdtemple protocol initmain >>>> int keeprunning = 1; data_packet *dp; data_packet actDataPacket; UBaseType_t busToUse = *(UBaseType_t *) pvParameters; /* function pointers to the bus interface */ extern bus_init actBus_init; extern bus_send actBus_send; extern bus_flush actBus_flush; extern bus_param actBus_param; extern bus_close actBus_close; extern QueueHandle_t protocolQueue; extern QueueHandle_t outputQueue; extern QueueHandle_t inputQueue; MsgData *msg; MsgData *ownMsg; param_data *args; extern SemaphoreHandle_t protocollBinarySemaphore; UBaseType_t msgType; UBaseType_t timeout = 0; int i; //catch the "Protocoll is running" Semaphore xSemaphoreTake(protocollBinarySemaphore, portMAX_DELAY); /* activate the bus... */ odbarr[busToUse] (); actBus_init(); ODPBuffer *protocolBuffer; protocolBuffer = NULL; // start with the protocol specific initalisation //<<<< oobdtemple protocol initmain <<<< extern print_cbf printdata_CAN; UBaseType_t stateMachine_state = 0; UBaseType_t actBufferPos = 0; /* tell the Rx-ISR about the function to use for received data */ busControl(ODB_CMD_RECV, odp_canraw_recvdata); protocolBuffer = createODPBuffer(CANRAWBUFFERSIZE); if (protocolBuffer == NULL) { keeprunning = 0; } else { protocolBuffer->len = 0; } extern protocolConfigPtr actProtConfigPtr; struct CanRawConfig *protocolConfig; protocolConfig = pvPortMalloc(sizeof(struct CanRawConfig)); if (protocolConfig == NULL) { keeprunning = 0; } else { actProtConfigPtr = protocolConfig; protocolConfig->recvID = 0x7DF; protocolConfig->separationTime = 0; protocolConfig->showBusTransfer = 0; } //>>>> oobdtemple protocol mainloop_start >>>> for (; keeprunning;) { if (MSG_NONE != (msgType = waitMsg(protocolQueue, &msg, portMAX_DELAY))) // portMAX_DELAY /* handle message */ { switch (msgType) { //<<<< oobdtemple protocol mainloop_start <<<< //>>>> oobdtemple protocol MSG_BUS_RECV >>>> case MSG_BUS_RECV: dp = msg->addr; //<<<< oobdtemple protocol MSG_BUS_RECV <<<< if (protocolConfig->showBusTransfer > 0) { odp_canraw_dumpFrame(dp, printdata_CAN); } // no more action, Raw CAN does not manage any answers from the bus //>>>> oobdtemple protocol MSG_SERIAL_DATA >>>> break; case MSG_SERIAL_DATA: //<<<< oobdtemple protocol MSG_SERIAL_DATA <<<< if (stateMachine_state == SM_CANRAW_STANDBY) { /* only if just nothing to do */ dp = (data_packet *) msg->addr; // data block received from serial input which need to be handled now if (((protocolBuffer->len) + dp->len) <= CANRAWBUFFERSIZE) { /* copy the data into the uds- buffer */ for (i = 0; i < dp->len; i++) { protocolBuffer->data[protocolBuffer->len++] = dp->data[i]; } } else { createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_CANRAW_DATA_TOO_LONG_ERR, (protocolBuffer->len) + dp->len, ERR_CODE_CANRAW_DATA_TOO_LONG_ERR_TEXT); } } //>>>> oobdtemple protocol MSG_SERIAL_PARAM_1 >>>> break; case MSG_SERIAL_PARAM: args = (UBaseType_t *) msg->addr; /* * DEBUGPRINT("protocol parameter received %ld %ld %ld\n", args->args[ARG_RECV], args->args[ARG_CMD], args->args[ARG_VALUE_1]); */ switch (args->args[ARG_RECV]) { case FBID_PROTOCOL_GENERIC: /* * DEBUGPRINT ("generic protocol parameter received %ld %ld\n", args->args[ARG_CMD], args->args[ARG_VALUE_1]); */ switch (args->args[ARG_CMD]) { case PARAM_INFO: //<<<< oobdtemple protocol MSG_SERIAL_PARAM_1 <<<< CreateParamOutputMsg(args, odp_canraw_printParam); //>>>> oobdtemple protocol MSG_SERIAL_PARAM_2 >>>> break; // and here we proceed all command parameters case PARAM_LISTEN: xTickCurrent = 0; // set current Timestamp to "0" if Listen mode ist activated protocolConfig->showBusTransfer = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_GENERIC, ERR_CODE_NO_ERR, 0, NULL); break; default: createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } break; //<<<< oobdtemple protocol MSG_SERIAL_PARAM_2 <<<< case FBID_PROTOCOL_SPEC: //DEBUGPRINT ("can raw protocol parameter received %ld %ld\n", args->args[ARG_CMD], args->args[ARG_VALUE_1]); switch (args->args[ARG_CMD]) { // first we commend out all parameters which are not used to generate the right "unknown parameter" message in the default - area /* case PARAM_ECHO: break; case PARAM_TIMEOUT_PENDING: break; case PARAM_BLOCKSIZE: break; */ case PARAM_CANRAW_FRAME_DELAY: protocolConfig->separationTime = args->args[ARG_VALUE_1] + 1; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; case PARAM_CANRAW_SENDID: protocolConfig->recvID = args->args[ARG_VALUE_1]; createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_NO_ERR, 0, NULL); break; default: createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } break; //>>>> oobdtemple protocol MSG_OTHERS >>>> case FBID_BUS_GENERIC: case FBID_BUS_SPEC: actBus_param(args); /* forward the received params to the underlying bus. */ break; default: createCommandResultMsg(FBID_PROTOCOL_SPEC, ERR_CODE_OS_UNKNOWN_COMMAND, 0, ERR_CODE_OS_UNKNOWN_COMMAND_TEXT); break; } //<<<< oobdtemple protocol MSG_OTHERS <<<< //>>>> oobdtemple protocol MSG_INIT >>>> case MSG_INIT: if (protocolBuffer != NULL) { protocolBuffer->len = 0; } //<<<< oobdtemple protocol MSG_INIT <<<< //>>>> oobdtemple protocol MSG_PROTOCOL_STOP >>>> break; case MSG_PROTOCOL_STOP: keeprunning = 0; break; //<<<< oobdtemple protocol MSG_PROTOCOL_STOP <<<< //>>>> oobdtemple protocol MSG_SEND_BUFFER >>>> case MSG_SEND_BUFFER: /* let's Dance: Starting the transfer protocol */ //<<<< oobdtemple protocol MSG_SEND_BUFFER <<<< if (protocolBuffer->len > 0) { actBufferPos = 0; for (; sendMoreFrames(protocolBuffer, &actBufferPos, &protocolConfig->showBusTransfer, &stateMachine_state, &timeout, printdata_CAN, actBus_send);); // fire all in one shot. //>>>> oobdtemple protocol MSG_SEND_BUFFER_2 >>>> } else { /* no data to send? */ createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_NO_ERR, 0, NULL); /* just release the input again */ if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { printser_string("Input queue is full!"); DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } break; //<<<< oobdtemple protocol MSG_SEND_BUFFER_2 <<<< //>>>> oobdtemple protocol MSG_TICK >>>> case MSG_TICK: //<<<< oobdtemple protocol MSG_TICK <<<< if (timeout > 0) { /* we just waiting for the next frame to send */ if (timeout == 1) { /* time's gone... */ for (; sendMoreFrames(protocolBuffer, &actBufferPos, &protocolConfig->showBusTransfer, &stateMachine_state, &timeout, printdata_CAN, actBus_send);); // fire all in one shot. if (timeout < 2) { // protocolBuffer->len = 0; createCommandResultMsg (FBID_PROTOCOL_GENERIC, ERR_CODE_NO_ERR, 0, NULL); stateMachine_state = SM_CANRAW_STANDBY; if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) { printser_string("INPQUE_FULL"); DEBUGPRINT ("FATAL ERROR: input queue is full!\n", 'a'); } } } timeout--; } //>>>> oobdtemple protocol final >>>> break; } disposeMsg(msg); } /* vTaskDelay (5000 / portTICK_PERIOD_MS); */ } /* Do all cleanup here to finish task */ actBus_close(); vPortFree(protocolConfig); freeODPBuffer(protocolBuffer); xSemaphoreGive(protocollBinarySemaphore); vTaskDelete(NULL); }
void QMidiOut::sendEvent(const QMidiEvent& e) { sendMsg(e.message()); }
int main() { unsigned long nMsg = 0; char *cmnd, *uname1, *uname2; int k; user *users = NULL; freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); cmnd = (char*)malloc(sizeof(char)*10); while(scanf("%s", cmnd)!=EOF) { if(DEBUG) printf("cmnd read: %s\n", cmnd); if(!strcmp(cmnd, "ADD")) { uname1 = getUser(); if(users==NULL) init(uname1, &users); else addUser(uname1, users); } else if(!strcmp(cmnd, "FOLLOW")) { uname1 = getUser(), uname2 = getUser(); follow(uname1, uname2, users); } else if(!strcmp(cmnd, "SEND")) { uname1 = getUser(); sendMsg(uname1, ++nMsg, users); } else if(!strcmp(cmnd, "RESEND")) { uname1 = getUser(); scanf("%d", &k); resendMsg(uname1, k, users); } else if(!strcmp(cmnd, "INACTIVE")) { uname1 = getUser(); inactivate(uname1, users); } else if(!strcmp(cmnd, "ACTIVE")) { uname1 = getUser(); activate(uname1, users); } else //UNFOLLOW { uname1 = getUser(), uname2 = getUser(); unfollow(uname1, uname2, users); } } user *cur = users; do { print(*cur); cur = cur->next; } while(cur!=users); return 0; }
// Get the msg types for Destination and Position. void PathingController::receivePosMsg(const owr_messages::position &msg) { currLat = msg.latitude; currLong = msg.longitude; currHeading = msg.heading; sendMsg(); }
int ManagerFilter::handleNeedMore(AHData* msg) { int* iMsg = (int*)msg->getData(); int pId = iMsg[0]; int mId = iMsg[1]; pthread_mutex_lock(&mLog); // log << "Received work request from " << pId << " with mId: " << mId; // log << ", expected mId: " << lastId[pId]+1 << std::endl; pthread_mutex_unlock(&mLog); // Handle Work Request // Check if we should answer the request. if (mId <= lastId[pId] ) return 1; int* pMsg; size_t msgSize = 0; pthread_mutex_lock(&mWorkQueue); // If we have work if (!workQueue.empty()) { // Mark that he has work and update lastId hasWork[pId] = true; lastId[pId]++; // Build char message std::list<Candidate> workToSend; workToSend.push_front(workQueue.front()); workQueue.pop(); pMsg = list2Msg(workToSend, pId, msgSize); } // If we don't have work else { // Mark no work for this pId hasWork[pId] = false; // Loop through all known clients, to see if someone has work bool someWork = false; std::map<int,bool>::iterator it; for (it = hasWork.begin(); it != hasWork.end(); it++) { if (it->second) { someWork = true; break; } } // If none has work to do, we can stop if (!someWork) { pMsg = buildEowMsg(msgSize); closeEventList(this->sNeedMore); closeEventList(this->sNewWork); } // Otherwise, ask for work else { // Send msg pthread_mutex_lock(&mStatus); if (!this->hasRequest) { this->hasRequest = true; AHData* askForMore = new AHData(new int(msgId), sizeof(int), sWorkRequest); sendMsg(askForMore); } pthread_mutex_unlock(&mStatus); pMsg = 0; } } pthread_mutex_unlock(&mWorkQueue); if (msgSize != 0) { std::cout << ">>>>> MANAGER <<<<<<" << std::endl; std::cout << " >> MSG: " << pMsg << std::endl; AHData* d = new AHData(pMsg, msgSize, sOut); sendMsg(d); } delete msg; return 1; }
ssize_t CClient::sendWlcomeMsg(){ string ret = "220 SimpleFtpServer\r\n"; return sendMsg(ret); }
/** Constructor */ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags) : mBlogId(cId), QMainWindow (parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); setupFileActions(); setupEditActions(); setupViewActions(); setupInsertActions(); setupParagraphActions(); setAcceptDrops(true); setStartupText(); newBlogMsg(); ui.toolBar_2->addAction(ui.actionIncreasefontsize); ui.toolBar_2->addAction(ui.actionDecreasefontsize); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionOrderedlist); ui.toolBar_2->addAction(ui.actionUnorderedlist); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionCode); ui.toolBar_2->addAction(ui.actionsplitPost); setupTextActions(); connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg())); connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew())); connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease())); connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease())); connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote())); connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode())); connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter())); connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList())); connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList())); //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect( ui.msgEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QPalette palette = QApplication::palette(); codeBackground = palette.color( QPalette::Active, QPalette::Midlight ); fontChanged(ui.msgEdit->font()); colorChanged(ui.msgEdit->textColor()); alignmentChanged(ui.msgEdit->alignment()); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), ui.actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified( ui.msgEdit->document()->isModified()); actionSave->setEnabled( ui.msgEdit->document()->isModified()); actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste())); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //defaultCharFormat defaultCharFormat = ui.msgEdit->currentCharFormat(); const QFont defaultFont = ui.msgEdit->document()->defaultFont(); defaultCharFormat.setFont( defaultFont ); defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() ); defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); defaultCharFormat.setBackground( palette.color( QPalette::Active, QPalette::Base ) ); defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) ); //defaultBlockFormat defaultBlockFormat = ui.msgEdit->textCursor().blockFormat(); }
int solver(int *map, int x1, int y1, int x2, int y2, int *stones, int n) { int i; int x, y; /* printf("(%d, %d) ~ (%d, %d)\n\n", x1, y1, x2, y2); printf("Map\n"); for (y=0; y<32; y++) { printf("\t"); for (x=0; x<32; x++) printf("%d", MAP(x, y)); printf("\n"); } printf("\n"); printf("Stones\n"); for (i=0; i<n; i++) { printf("\tstone %d\n", i+1); for (y=0; y<8; y++) { printf("\t\t"); for (x=0; x<8; x++) printf("%d", STONE(i, x, y)); printf("\n"); } } printf("\n"); */ /* Solutions for light.txt */ char *solutions[] = { "H 0 2 2\n", "H 0 2 2\nT 0 -6 0\n", "H 0 2 2\nT 0 -6 0\n\nH 0 1 -1\n", NULL }; printf("Solutions\n"); for (i=0; (solutions[i] != NULL); i++) { sleep(5); printf("Solutin %d\n", i+1); // Padding int j, line = 0; for (j=0; (solutions[i][j] != '\0'); j++) { if (solutions[i][j] == '\n') line++; } // Like a START BIT sendMsg("S"); // Main sendMsg(solutions[i]); for (j=0; j<(n - line); j++) sendMsg(""); // Prepare for next problem if (sendMsg("E") == EXIT_FAILURE) return EXIT_SUCCESS; // transition to `Ready state` } // Forced termination return EXIT_FAILURE; }
void Marmote_StopStreaming(FT_HANDLE ftHandle) { uint8_t dummy; sendMsg(ftHandle, SDR, STOP_STREAMING, &dummy, 0); }
void odp_canraw_recvdata(data_packet * p, UBaseType_t callFromISR) { extern print_cbf printdata_CAN; extern printChar_cbf printChar; extern protocolConfigPtr actProtConfigPtr; struct CanRawConfig *protocolConfig; short ByteCnt; if (callFromISR) xTickNew = (uint16_t) xTaskGetTickCountFromISR(); else xTickNew = (uint16_t) xTaskGetTickCount(); if (xTickNew < xTickOld) // check for xTick overflow xTickOld = 0; if (xTickCurrent >= 59999) // limit timestamp to 0-59999 tick (ms) xTickCurrent = 0; xTickCurrent = xTickCurrent + (xTickNew - xTickOld); xTickOld = xTickNew; // set latest value to xTickOld for next duration p->timestamp = xTickCurrent; protocolConfig = actProtConfigPtr; if (protocolConfig != NULL) { if (protocolConfig->showBusTransfer == 1) { //normal output MsgData *msg; extern QueueHandle_t protocolQueue; if (NULL != (msg = createDataMsg(p))) { UBaseType_t res = 0; if (callFromISR) { res = sendMsgFromISR(MSG_BUS_RECV, protocolQueue, msg); } else { res = sendMsg(MSG_BUS_RECV, protocolQueue, msg); } if (res != pdPASS) { disposeMsg(msg); DEBUGPRINT("FATAL ERROR: protocol queue is full!\n", 'a'); } } else { DEBUGPRINT("FATAL ERROR: Out of Heap space!l\n", 'a'); } } if (protocolConfig->showBusTransfer == 2) { //normal output, but straight from the ISR printdata_CAN(MSG_BUS_RECV, p, printChar); } if (protocolConfig->showBusTransfer == 3) { // Lawicel format: Estimated out of http://lxr.free-electrons.com/source/drivers/net/can/slcan.c line 110 cc. if (p->recv & 0x80000000) { // Bit 32 set, so it's an extended CAN ID printser_string("T"); printser_uint32ToHex(p->recv & 0x1FFFFFFF); } else { printser_string("t"); printser_int((p->recv & 0x700) >> 8, 10); printser_uint8ToHex(p->recv & 0x00FF); } printser_int(p->len, 10); ByteCnt = 0; while (ByteCnt != p->len) { printser_uint8ToHex(p->data[ByteCnt]); ByteCnt++; } if (p->err == 0x01) printser_string("FFFF"); // if error occurs set timestamp to 0xFFFF else printser_uint16ToHex(p->timestamp * portTICK_PERIOD_MS & 0xFFFF); //reduce down to 16 bit = 65536 ms = ~ 1 min printLF(); } if (protocolConfig->showBusTransfer == 4) { printser_uint8ToRaw(255); //startbyte printser_uint8ToRaw((p->len & 0xF) | // bit 0-3: DLC ((p->err & 3) << 4) | //bit 4-5 : Error flag (((p->recv & 0x80000000) ? 1 : 0) << 5) //bit 6: Extended CAN ID ); //Status flag printser_uint16ToRawCoded(p->timestamp * portTICK_PERIOD_MS & 0xFFFF); //reduce down to 16 bit = 65536 ms = ~ 1 min if ((p->recv & 0x80000000)) { // Bit 32 set, so it's an exended CAN ID printser_uint32ToRawCoded(p->recv & 0x1FFFFFFF); } else { printser_uint16ToRawCoded(p->recv & 0x1FFFFFFF); } int i; for (i = 0; i < p->len; i++) { printser_uint8ToRawCoded(p->data[i]); } } } }
void QMidiOut::setInstrument(int voice, int instr) { qint32 msg = 0xC0 + voice; msg |= instr << 8; sendMsg(msg); }
/* * Handler for all the buttons * The actual keyboard message to send is passed through evt->extra. */ int handleButton (struct pgEvent * evt) { sendMsg (evt->extra); return 1; }
void QMidiOut::noteOff(int note, int voice) { qint32 msg = 0x80 + voice; msg |= note << 8; sendMsg(msg); }
/** Constructor */ IdDialog::IdDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsIdentity, parent), ui(new Ui::IdDialog) { ui->setupUi(this); mIdQueue = NULL; /* Setup UI helper */ mStateHelper = new UIStateHelper(this); // mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget); mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui->idTreeWidget, false); mStateHelper->addClear(IDDIALOG_IDLIST, ui->idTreeWidget); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId); // mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_GpgHash); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->toolButton_Reputation); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->line_RatingOverall); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->line_RatingImplicit); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->line_RatingOwn); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->line_RatingPeers); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repModButton); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_Accept); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_Ban); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_Negative); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_Positive); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_Custom); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->repMod_spinBox); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId); // mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_GpgHash); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->line_RatingOverall); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->line_RatingImplicit); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->line_RatingOwn); mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui->line_RatingPeers); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId); // mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_GpgHash); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_Type); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->line_RatingOverall); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->line_RatingImplicit); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->line_RatingOwn); mStateHelper->addClear(IDDIALOG_IDDETAILS, ui->line_RatingPeers); //mStateHelper->addWidget(IDDIALOG_REPLIST, ui->treeWidget_RepList); //mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui->treeWidget_RepList); //mStateHelper->addClear(IDDIALOG_REPLIST, ui->treeWidget_RepList); /* Connect signals */ connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity())); connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo())); connect(ui->removeIdentity, SIGNAL(triggered()), this, SLOT(removeIdentity())); connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity())); connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity())); connect(ui->idTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection())); connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); connect(ui->filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged())); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui->repModButton, SIGNAL(clicked()), this, SLOT(modifyReputation())); connect(ui->messageButton, SIGNAL(clicked()), this, SLOT(sendMsg())); ui->avlabel->setPixmap(QPixmap(":/images/user/friends64.png")); ui->headerTextLabel->setText(tr("People")); /* Initialize splitter */ ui->splitter->setStretchFactor(0, 1); ui->splitter->setStretchFactor(1, 0); QList<int> sizes; sizes << width() << 500; // Qt calculates the right sizes ui->splitter->setSizes(sizes); /* Add filter types */ ui->filterComboBox->addItem(tr("All"), RSID_FILTER_ALL); ui->filterComboBox->addItem(tr("Owned by you"), RSID_FILTER_OWNED_BY_YOU); ui->filterComboBox->addItem(tr("Linked to your node"), RSID_FILTER_YOURSELF); ui->filterComboBox->addItem(tr("Linked to neighbor nodes"), RSID_FILTER_FRIENDS); ui->filterComboBox->addItem(tr("Linked to distant nodes"), RSID_FILTER_OTHERS); ui->filterComboBox->addItem(tr("Anonymous"), RSID_FILTER_PSEUDONYMS); ui->filterComboBox->setCurrentIndex(0); /* Add filter actions */ QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem(); QString headerText = headerItem->text(RSID_COL_NICKNAME); ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText)); headerText = headerItem->text(RSID_COL_KEYID); ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText)); /* Setup tree */ ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder); ui->idTreeWidget->enableColumnCustomize(true); ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false); /* Set initial column width */ int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W"); ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 18 * fontWidth); ui->idTreeWidget->setColumnWidth(RSID_COL_KEYID, 25 * fontWidth); ui->idTreeWidget->setColumnWidth(RSID_COL_IDTYPE, 18 * fontWidth); mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this); mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->setActive(IDDIALOG_REPLIST, false); // Hiding RepList until that part is finished. //ui->treeWidget_RepList->setVisible(false); ui->toolButton_Reputation->setVisible(false); #ifndef UNFINISHED ui->todoPushButton->hide() ; #endif QString hlp_str = tr( " <h1><img width=\"32\" src=\":/icons/help_64.png\"> Identities</h1> \ <p>In this tab you can create/edit pseudo-anonymous identities. \ </p> \ <p>Identities are used to securely identify your data: sign forum and channel posts,\ and receive feedback using Retroshare built-in email system, post comments \ after channel posts, etc.</p> \ <p> \ Identities can optionally be signed by your Retroshare node's certificate. \ Signed identities are easier to trust but are easily linked to your node's IP address. \ </p> \ <p> \ Anonymous identities allow you to anonymously interact with other users. They cannot be \ spoofed, but noone can prove who really owns a given identity. \ </p> \ ") ; registerHelpButton(ui->helpButton, hlp_str) ; // load settings processSettings(true); // hide reputation sice it's currently unused ui->reputationGroupBox->hide(); ui->tweakGroupBox->hide(); }
void QMidiOut::stopAll(int voice) { sendMsg((0xB0 | voice) | (0x7B << 8)); }
double RobotController::onAction(ActionEvent &evt) { switch(m_state){ // 初期姿勢を設定 seting initial pose case 0: { //broadcastMsgToSrv("Let's start the clean up task\n"); sendMsg("VoiceReco_Service","Let's start the clean up task\n"); double angL1 =m_my->getJointAngle("LARM_JOINT1")*180.0/(PI); double angL4 =m_my->getJointAngle("LARM_JOINT4")*180.0/(PI); double angR1 =m_my->getJointAngle("RARM_JOINT1")*180.0/(PI); double angR4 =m_my->getJointAngle("RARM_JOINT4")*180.0/(PI); double thetaL1 = -20-angL1; double thetaL4 = -160-angL4; double thetaR1 = -20-angR1; double thetaR4 = -160-angR4; if(thetaL1<0) m_my->setJointVelocity("LARM_JOINT1", -m_jvel, 0.0); else m_my->setJointVelocity("LARM_JOINT1", m_jvel, 0.0); if(thetaL4<0) m_my->setJointVelocity("LARM_JOINT4", -m_jvel, 0.0); else m_my->setJointVelocity("LARM_JOINT4", m_jvel, 0.0); if(thetaR1<0) m_my->setJointVelocity("RARM_JOINT1", -m_jvel, 0.0); else m_my->setJointVelocity("RARM_JOINT1", m_jvel, 0.0); if(thetaR4<0) m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0); else m_my->setJointVelocity("RARM_JOINT4", m_jvel, 0.0); m_time_LA1 = DEG2RAD(abs(thetaL1))/ m_jvel + evt.time(); m_time_LA4 = DEG2RAD(abs(thetaL4))/ m_jvel + evt.time(); m_time_RA1 = DEG2RAD(abs(thetaR1))/ m_jvel + evt.time(); m_time_RA4 = DEG2RAD(abs(thetaR4))/ m_jvel + evt.time(); m_state = 1; break; } // 初期姿勢に移動 moving initial pose case 1: { if(evt.time() >= m_time_LA1) m_my->setJointVelocity("LARM_JOINT1", 0.0, 0.0); if(evt.time() >= m_time_LA4) m_my->setJointVelocity("LARM_JOINT4", 0.0, 0.0); if(evt.time() >= m_time_RA1) m_my->setJointVelocity("RARM_JOINT1", 0.0, 0.0); if(evt.time() >= m_time_RA4) m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0); if(evt.time() >= m_time_LA1 && evt.time() >= m_time_LA4 && evt.time() >= m_time_RA1 && evt.time() >= m_time_RA4){ // 位置Aの方向に回転を開始します setting position a for rotating //broadcastMsgToSrv("Moving to the table"); m_time = rotateTowardObj(pos_a, m_vel, evt.time()); m_state = 2; } break; } // 位置Aの方向に回転 rotating to position a case 2: { // 回転終了 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // 位置Aに移動します setting position a for moving m_time = goToObj(pos_a, m_vel*4, 0.0, evt.time()); m_state = 3; } break; } // 位置Aに移動 moving to position a case 3: { // 位置Aに到着 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // 位置Bの方向に回転を開始します setting position b for rotating m_time = rotateTowardObj(pos_b, m_vel, evt.time()); m_state = 4; } break; } // 位置Bの方向に回転 rotating to position b case 4: { // 回転終了 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // 位置Bに移動します setting position b for moving m_time = goToObj(pos_b, m_vel*4, 0.0, evt.time()); m_state = 5; } break; } // 位置Bに移動 moving to position b case 5: { // 位置Bに到着 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // テーブルの方向に回転を開始します setting table position for rotating SimObj *table = getObj("table_0"); Vector3d pos; table->getPosition(pos); m_time = rotateTowardObj(pos, m_vel, evt.time()); m_state = 6; } break; } // テーブルの方向に回転 rotating to table case 6: { // 回転終了 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // ゴミがある場所と名前を取得します // ゴミが見つからなかった if(!this->recognizeTrash(m_tpos,m_tname)){ //broadcastMsgToSrv("No trash detected"); //broadcastMsgToSrv("Task finished"); sleep(10); } // ゴミが見つかった trash detected else{ //broadcastMsgToSrv("Please show which trash to take\n"); sendMsg("VoiceReco_Service","Please show me which object to take"); m_state = 7; } } break; } // wating to point case 7: { break; } // 物体認識開始 starting object recognition case 8: { // m_tpos object direction on object SimObj *target = this->getObj(m_pointedObject.c_str()); target->getPosition(m_tpos); //broadcastMsgToSrv("Ok I will take it\n"); msg_ob = "I will take " + m_pointedObject ; sendMsg("VoiceReco_Service",msg_ob); // ゴミの方向に回転をはじめる m_time = rotateTowardObj(m_tpos, m_vel, evt.time()); m_state = 9; break; } // ゴミの方向に回転をはじめる setting trash position for rotating case 9: { m_time = rotateTowardObj(m_tpos, m_vel, evt.time()); m_state = 10; break; } // ゴミの方向に回転中 rotating to trash case 10: { // 回転終了 if(evt.time() >= m_time){ // 回転を止める m_my->setWheelVelocity(0.0, 0.0); //ゴミの位置まで移動をはじめる setting trash position for moving m_time = goToObj(m_tpos, m_vel*4, 25.0, evt.time()); m_state = 11; } break; } // ゴミの位置まで移動中 moving to trash case 11: { // 移動終了 if(evt.time() >= m_time){ // 移動を止める m_my->setWheelVelocity(0.0, 0.0); // 関節の回転を始める setting arm for grasping double angR1 =m_my->getJointAngle("RARM_JOINT1")*180.0/(PI); double angR4 =m_my->getJointAngle("RARM_JOINT4")*180.0/(PI); double thetaR1 = -30.0-angR1; double thetaR4 = 0.0-angR4; if(thetaR1<0) m_my->setJointVelocity("RARM_JOINT1", -m_jvel, 0.0); else m_my->setJointVelocity("RARM_JOINT1", m_jvel, 0.0); if(thetaR4<0) m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0); else m_my->setJointVelocity("RARM_JOINT4", m_jvel, 0.0); m_time_RA1 = DEG2RAD(abs(thetaR1) )/ m_jvel + evt.time(); m_time_RA4 = DEG2RAD(abs(thetaR4) )/ m_jvel + evt.time(); // ゴミを取りに関節を曲げる状態に移行します m_state = 12; } break; } // 関節を回転中 rotating arm for grasping case 12: { // 関節回転終了 if(evt.time() >= m_time_RA1) m_my->setJointVelocity("RARM_JOINT1", 0.0, 0.0); if(evt.time() >= m_time_RA4) m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0); if(evt.time() >= m_time_RA1 && evt.time() >= m_time_RA4){ if(m_grasp) { //broadcastMsgToSrv("grasping the trash"); // 関節の回転を始める setting arm for taking double angR4 =m_my->getJointAngle("RARM_JOINT4")*180.0/(PI); double thetaR4 = -90.0-angR4; if(thetaR4<0) m_my->setJointVelocity("RARM_JOINT4", -m_jvel, 0.0); else m_my->setJointVelocity("RARM_JOINT4", m_jvel, 0.0); m_time_RA4 = DEG2RAD(abs(thetaR4) )/ m_jvel + evt.time(); // 関節を戻す状態に移行します m_state = 13; } else{ // graspできない broadcastMsgToSrv("Unreachable"); } } break; } // 関節を回転中 rotating arm for taking case 13: { // 関節回転終了 if(evt.time() >= m_time_RA4){ m_my->setJointVelocity("RARM_JOINT4", 0.0, 0.0); // 位置Aの方向に回転を開始します setting position a for rotating //broadcastMsgToSrv("Moving to the trashbox"); sendMsg("VoiceReco_Service","Now I will go to the trash boxes"); m_time = rotateTowardObj(pos_a, m_vel, evt.time()); m_state = 14; } break; } // 位置Aの方向に回転 rotating to position a case 14: { // 回転終了 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // 位置Aに移動します setting position a for moving m_time = goToObj(pos_a, m_vel*4, 0.0, evt.time()); m_state = 15; } break; } // 位置Aの位置まで移動中 movig to position a case 15: { // 移動終了 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); //broadcastMsgToSrv("Please tell me which trash box \n"); sendMsg("VoiceReco_Service","Please show me which trash box to use"); m_state = 16; } break; } // watig to point4 case 16: { break; } // ゴミ箱認識 starting trash box recognitiong-g-0 case 17: { // m_tpos object direction on object SimObj *target_trash = this->getObj(m_pointedtrash.c_str()); target_trash->getPosition(m_tpos); //broadcastMsgToSrv("Ok I will throw the trash in trash box \n"); msg_trash = "Ok I will put "+ m_pointedObject+"in"+ m_pointedtrash + "\n"; sendMsg("VoiceReco_Service",msg_trash); // ゴミの方向に回転をはじめる setting position trash box for rotating m_time = rotateTowardObj(m_tpos, m_vel, evt.time()); m_state = 18; break; } // ゴミ箱の方向に回転中 rotating to trash box case 18: { if(evt.time() >= m_time){ // 回転を止める m_my->setWheelVelocity(0.0, 0.0); //ゴミの位置まで移動をはじめる setting trash position for moving m_time = goToObj(m_tpos, m_vel*4, 30.0, evt.time()); m_state = 19; } break; } // ゴミを持ってゴミ箱に向かっている状態 moving to trash box case 19: { // ゴミ箱に到着 if(evt.time() >= m_time){ m_my->setWheelVelocity(0.0, 0.0); // grasp中のパーツを取得します getting grasped tarts CParts *parts = m_my->getParts("RARM_LINK7"); // releaseします parts->releaseObj(); // ゴミが捨てられるまで少し待つ sleep(1); // 捨てたゴミをゴミ候補から削除 deleting grasped object from list std::vector<std::string>::iterator it; it = std::find(m_trashes.begin(), m_trashes.end(), m_pointedObject); m_trashes.erase(it); // grasp終了 m_grasp = false; m_state = 1; } break; } } return 0.01; }
bool SSMP1commands::sendStopTalkingCmd() { char stopmsg[4] = {SSMP1_CMD_STOP_READING, '\x0', '\x0', '\x0'}; return sendMsg(stopmsg, 4); }
bool Monitor::parseCommand( const char * message ) { if ( ! std::strcmp( message, "(dispbye)" ) ) { disable(); return true; } else if ( ! std::strcmp( message, "(dispstart)" ) ) { M_stadium.kickOff(); return true; } else if ( ! std::strncmp( message, "(dispplayer", 11 ) ) { return dispplayer( message ); } else if ( ! std::strncmp( message, "(dispdiscard", 12 ) ) { return dispdiscard( message ); } else if ( ! std::strncmp( message, "(compression", 12 ) ) { return compression( message ); } else if ( ! std::strncmp( message, "(dispfoul", 9 ) ) { return dispfoul( message ); } else if ( ! std::strncmp( message, "(dispcard", 9 ) ) { return dispcard( message ); } else if ( ServerParam::instance().coachMode() || ServerParam::instance().coachWithRefereeMode() ) { if ( ! std::strncmp( message, "(start)", 7 ) ) { M_stadium.kickOff(); sendMsg( MSG_BOARD, "(ok start)" ); return true; } else if ( ! std::strncmp( message, "(change_mode", 12 ) ) { return coach_change_mode( message ); } else if ( ! std::strncmp( message, "(move", 5 ) ) { return coach_move( message ); } else if ( ! std::strncmp( message, "(recover", 8 ) ) { return coach_recover(); } else if ( ! std::strcmp( message, "change_player_type" ) ) { return coach_change_player_type( message ); } else if ( ! std::strncmp( message, "(check_ball", 11 ) ) { return coach_check_ball(); } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } return true; }
bool SSMP1commands::sendQueryIdCmd(unsigned char extradatalen) { char querymsg[4] = {SSMP1_CMD_GET_ID, '\x80', '\x00', static_cast<char>(extradatalen)}; return sendMsg(querymsg, 4); }
bool Monitor::coach_change_player_type( const char * command ) { char teamname[128]; int unum, player_type; if ( std::sscanf( command, " ( change_player_type %127s %d %d ) ", teamname, &unum, &player_type ) != 3 ) { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } const Team * team = NULL; if ( M_stadium.teamLeft().name() == teamname ) { team = &( M_stadium.teamLeft() ); } else if ( M_stadium.teamRight().name() == teamname ) { team = &( M_stadium.teamRight() ); } if ( team == NULL ) { sendMsg( MSG_BOARD, "(warning no_team_found)" ); return false; } if ( player_type < 0 || player_type >= PlayerParam::instance().playerTypes() ) { sendMsg( MSG_BOARD, "(error out_of_range_player_type)" ); return false; } const Player * player = NULL; for ( int i = 0; i < team->size(); ++i ) { const Player * p = team->player( i ); if ( p && p->unum() == unum ) { player = p; break; } } if ( player == NULL ) { sendMsg( MSG_BOARD, "(warning no_such_player)" ); return false; } M_stadium.substitute( player, player_type ); char buf[64]; snprintf( buf, 64, "(ok change_player_type %s %d %d)", teamname, unum, player_type ); sendMsg( MSG_BOARD, buf ); return true; }
bool SSMP1commands::sendReadAddressCmd(SSM1_CUtype_dt cu, unsigned int dataaddr) { if (dataaddr > 0xffff) return false; char msg[4] = {0,}; unsigned char msglen = 0; if (cu == SSM1_CU_Engine) { msg[0] = SSMP1_CMD_READ_ENGINE; msglen = 4; } else if (cu == SSM1_CU_Transmission) { msg[0] = SSMP1_CMD_READ_TRANSMISSION; msglen = 4; } else if (cu == SSM1_CU_CruiseCtrl) { msg[0] = SSMP1_CMD_READ_CRUISECONTROL; msglen = 4; } else if (cu == SSM1_CU_AirCon) { msg[0] = SSMP1_CMD_READ_AIRCON; msglen = 3; } else if (cu == SSM1_CU_AirCon2) { msg[0] = SSMP1_CMD_READ_AIRCON2; msglen = 4; } else if (cu == SSM1_CU_FourWS) { msg[0] = SSMP1_CMD_READ_4WS; msglen = 3; } else if (cu == SSM1_CU_ABS) { msg[0] = SSMP1_CMD_READ_ABS; msglen = 4; } else if (cu == SSM1_CU_AirSusp) { msg[0] = SSMP1_CMD_READ_AIRSUSP; msglen = 4; } else if (cu == SSM1_CU_PwrSteer) { msg[0] = SSMP1_CMD_READ_POWERSTEERING; msglen = 4; } else return false; char highaddrbyte = (dataaddr & 0xffff) >> 8; char lowaddrbyte = dataaddr & 0xff; msg[1] = highaddrbyte; msg[2] = lowaddrbyte; msg[3] = '\x00'; return sendMsg(msg, msglen); /* TODO: add block read support for newer ECUs/TCUs => make nrofbytes a fcn parameter */ }
int main() { #ifdef WINDOWS_XP // Initialize the winsock library WSADATA wsaData; winLog << "system started ..." << endl; winLog << endl << "initialize the winsock library ... "; try { if (WSAStartup(0x101, &wsaData)) { myException* initializationException = new myException(0,"Error: calling WSAStartup()"); throw initializationException; } } catch(myException* excp) { excp->response(); delete excp; exit(1); } winLog << "successful" << endl; #endif // get local information if neither the name or the address is given winLog << endl; winLog << "Retrieve the local host name and address:" << endl; myHostInfo uHostAddress; string localHostName = uHostAddress.getHostName(); string localHostAddr = uHostAddress.getHostIPAddress(); cout << "------------------------------------------------------" << endl; cout << " My local host information:" << endl; cout << " Name: " << localHostName << endl; cout << " Address: " << localHostAddr << endl; cout << "------------------------------------------------------" << endl; winLog << " ==> Name: " << localHostName << endl; winLog << " ==> Address: " << localHostAddr << endl; // open socket on the local host myTcpSocket myServer(PORTNUM); cout << myServer; winLog << "server configuation: " << endl; winLog << myServer; myServer.bindSocket(); cout << endl << "server finishes binding process... " << endl; winLog << endl << "server finishes binding process... " << endl; myServer.listenToClient(); cout << "server is listening to the port ... " << endl; winLog << "server is listening to the port ... " << endl; // wait to accept a client connection. // processing is suspended until the client connects cout << "server is waiting for client connecction ... " << endl; winLog << "server is waiting for client connnection ... " << endl; myTcpSocket* client; // connection dedicated for client communication string clientHost; // client name etc. client = myServer.acceptClient(clientHost); cout << endl << "==> A client from [" << clientHost << "] is connected!" << endl << endl; winLog << endl << "==> A client from [" << clientHost << "] is connected!" << endl << endl; while(1) { string clientMessageIn = ""; // receive from the client int numBytes = client->recieveMessage(clientMessageIn); if ( numBytes == -99 ) break; cout << "[RECV:" << clientHost << "]: " << clientMessageIn << endl; winLog << "[RECV:" << clientHost << "]: " << clientMessageIn << endl; // send to the clien char sendmsg[MAX_MSG_LEN+1]; memset(sendmsg,0,sizeof(sendmsg)); cout << "[" << localHostName << ":SEND] "; cin.getline(sendmsg,MAX_MSG_LEN); if ( numBytes == -99 ) break; string sendMsg(sendmsg); if ( sendMsg.compare("Bye") == 0 || sendMsg.compare("bye") == 0 ) break; //cout << "[" << localHostName << ": SEND] " << sendMsg << endl; winLog << "[" << localHostName << ": SEND] " << sendMsg << endl; client->sendMessage(sendMsg); } #ifdef WINDOWS_XP // Close the winsock library winLog << endl << "system shut down ..."; try { if (WSACleanup()) { myException* cleanupException = new myException(0,"Error: calling WSACleanup()"); throw cleanupException; } } catch(myException* excp) { excp->response(); delete excp; exit(1); } winLog << "successful" << endl; #endif return 1; }
void Marmote_SetFrequency(FT_HANDLE ftHandle, uint32_t freq_hz) { uint8_t txBuffer[4]; memcpy(txBuffer, &freq_hz, sizeof(freq_hz)); sendMsg(ftHandle, SDR, SET_FREQUENCY, txBuffer, sizeof(freq_hz)); }