double OptimVars::getValue() { switch(fitness) { case SUM : { return (getGenQ() + getSendQ()) + (getGenR()+ getSendR() + getDecR()); } case MAX : { return std::max(getGenQ(), getSendQ()) + std::max(std::max(getGenR(), getSendR()), getDecR()); } case CLOUD : { return getGenR() * (kOneHourComputingCost / kSecondsInHour) + (getSendR() * std::min(fixedVars.Tups, fixedVars.Tdoc)) * kOneByteUploadCost; } case BANDWIDTH : { return getSendR() + getSendQ(); } default : { return std::max(getGenQ(), getSendQ()) + std::max(std::max(getGenR(), getSendR()), getDecR()); } } }
bool IRCDDBApp::findUser(const wxString& usrCall) { wxString srv = d->currentServer; IRCMessageQueue * q = getSendQ(); if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) { wxString usr = usrCall; usr.Replace(wxT(" "), wxT("_")); IRCMessage * m = new IRCMessage(srv, wxT("FIND ") + usr ); q->putMessage(m); } else { IRCMessage * m2 = new IRCMessage(wxT("IDRT_USER")); m2->addParam(usrCall); m2->addParam(wxT("")); m2->addParam(wxT("")); m2->addParam(wxT("")); m2->addParam(wxT("")); d->replyQ.putMessage(m2); } return true; }
void NetworkSocket::showInfo() const { qDebug() << "-------------------[ SOCKET ]---------------------"; qDebug() << " Protocol type . . : " << getProtocolType(); qDebug() << " ReceiveQ. . . . . : " << getReceiveQ()<< " bytes"; qDebug() << " SendQ . . . . . . : " << getSendQ() << " bytes"; qDebug() << " Local Address . . : " << getLocalAddress() << " bytes"; qDebug() << " Foreign Address . : " << getForeignAddress(); qDebug() << " State . . . . . . : " << getState(); qDebug() << " PID . . . . . . . : " << getPID(); qDebug() << " Program Name. . . : " << getProgramName(); qDebug() << "--------------------------------------------------"; }
bool IRCDDBApp::sendHeard(const wxString& myCall, const wxString& myCallExt, const wxString& yourCall, const wxString& rpt1, const wxString& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const wxString& destination, const wxString& tx_msg, const wxString& tx_stats ) { wxString my = myCall; wxString myext = myCallExt; wxString ur = yourCall; wxString r1 = rpt1; wxString r2 = rpt2; wxString dest = destination; wxRegEx nonValid(wxT("[^A-Z0-9/]")); wxString underScore = wxT("_"); nonValid.Replace(&my, underScore); nonValid.Replace(&myext, underScore); nonValid.Replace(&ur, underScore); nonValid.Replace(&r1, underScore); nonValid.Replace(&r2, underScore); nonValid.Replace(&dest, underScore); bool statsMsg = (tx_stats.Len() > 0); wxString srv = d->currentServer; IRCMessageQueue * q = getSendQ(); if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) { wxString cmd = wxT("UPDATE "); cmd.Append( getCurrentTime() ); cmd.Append(wxT(" ")); cmd.Append(my); cmd.Append(wxT(" ")); cmd.Append(r1); cmd.Append(wxT(" ")); if (!statsMsg) { cmd.Append(wxT("0 ")); } cmd.Append(r2); cmd.Append(wxT(" ")); cmd.Append(ur); cmd.Append(wxT(" ")); wxString flags = wxString::Format(wxT("%02X %02X %02X"), flag1, flag2, flag3); cmd.Append(flags); cmd.Append(wxT(" ")); cmd.Append(myext); if (statsMsg) { cmd.Append(wxT(" # ")); cmd.Append(tx_stats); } else { cmd.Append(wxT(" 00 ")); cmd.Append(dest); if (tx_msg.Len() == 20) { cmd.Append(wxT(" ")); cmd.Append(tx_msg); } } IRCMessage * m = new IRCMessage(srv, cmd); q->putMessage(m); return true; } else { return false; } }
wxThread::ExitCode IRCDDBApp::Entry() { int sendlistTableID = 0; while (!d->terminateThread) { if (d->timer > 0) { d->timer --; } switch(d->state) { case 0: // wait for network to start if (getSendQ() != NULL) { d->state = 1; } break; case 1: // connect to db d->state = 2; d->timer = 200; break; case 2: // choose server wxLogVerbose(wxT("IRCDDBApp: state=2 choose new 's-'-user")); if (getSendQ() == NULL) { d->state = 10; } else { if (findServerUser()) { sendlistTableID = numberOfTables; d->state = 3; // next: send "SENDLIST" } else if (d->timer == 0) { d->state = 10; IRCMessage * m = new IRCMessage(wxT("QUIT")); m->addParam(wxT("no op user with 's-' found.")); IRCMessageQueue * q = getSendQ(); if (q != NULL) { q->putMessage(m); } } } break; case 3: if (getSendQ() == NULL) { d->state = 10; // disconnect DB } else { sendlistTableID --; if (sendlistTableID < 0) { d->state = 6; // end of sendlist } else { wxLogVerbose(wxT("IRCDDBApp: state=3 tableID=%d"), sendlistTableID); d->state = 4; // send "SENDLIST" d->timer = 900; // 15 minutes max for update } } break; case 4: if (getSendQ() == NULL) { d->state = 10; // disconnect DB } else { if (needsDatabaseUpdate(sendlistTableID)) { IRCMessage * m = new IRCMessage(d->currentServer, wxT("SENDLIST") + getTableIDString(sendlistTableID, true) + wxT(" ") + getLastEntryTime(sendlistTableID) ); IRCMessageQueue * q = getSendQ(); if (q != NULL) { q->putMessage(m); } d->state = 5; // wait for answers } else { d->state = 3; // don't send SENDLIST for this table, go to next table } } break; case 5: // sendlist processing if (getSendQ() == NULL) { d->state = 10; // disconnect DB } else if (d->timer == 0) { d->state = 10; // disconnect DB IRCMessage * m = new IRCMessage(wxT("QUIT")); m->addParam(wxT("timeout SENDLIST")); IRCMessageQueue * q = getSendQ(); if (q != NULL) { q->putMessage(m); } } break; case 6: if (getSendQ() == NULL) { d->state = 10; // disconnect DB } else { wxLogVerbose(wxT( "IRCDDBApp: state=6 initialization completed")); d->infoTimer = 2; d->initReady = true; d->state = 7; } break; case 7: // standby state after initialization if (getSendQ() == NULL) { d->state = 10; // disconnect DB } if (d->infoTimer > 0) { d->infoTimer --; if (d->infoTimer == 0) { d->moduleQTHURLMutex.Lock(); for (IRCDDBAppModuleQTH::iterator it = d->moduleQTH.begin(); it != d->moduleQTH.end(); ++it) { wxString value = it->second; IRCMessage* m = new IRCMessage(d->currentServer, wxT("IRCDDB RPTRQTH: ") + value); IRCMessageQueue* q = getSendQ(); if (q != NULL) { q->putMessage(m); } } d->moduleQTH.clear(); for (IRCDDBAppModuleURL::iterator it = d->moduleURL.begin(); it != d->moduleURL.end(); ++it) { wxString value = it->second; IRCMessage* m = new IRCMessage(d->currentServer, wxT("IRCDDB RPTRURL: ") + value); IRCMessageQueue* q = getSendQ(); if (q != NULL) { q->putMessage(m); } } d->moduleURL.clear(); d->moduleQTHURLMutex.Unlock(); d->moduleQRGMutex.Lock(); for (IRCDDBAppModuleQRG::iterator it = d->moduleQRG.begin(); it != d->moduleQRG.end(); ++it) { wxString value = it->second; IRCMessage* m = new IRCMessage(d->currentServer, wxT("IRCDDB RPTRQRG: ") + value); IRCMessageQueue* q = getSendQ(); if (q != NULL) { q->putMessage(m); } } d->moduleQRG.clear(); d->moduleQRGMutex.Unlock(); } } if (d->wdTimer > 0) { d->wdTimer --; if (d->wdTimer == 0) { d->moduleWDMutex.Lock(); for (IRCDDBAppModuleWD::iterator it = d->moduleWD.begin(); it != d->moduleWD.end(); ++it) { wxString value = it->second; IRCMessage* m = new IRCMessage(d->currentServer, wxT("IRCDDB RPTRSW: ") + value); IRCMessageQueue* q = getSendQ(); if (q != NULL) { q->putMessage(m); } } d->moduleWD.clear(); d->moduleWDMutex.Unlock(); } } break; case 10: // disconnect db d->state = 0; d->timer = 0; d->initReady = false; break; } Sleep(1000); } return 0; }