void CMonitorPage::InvalidateMonitorData() { if (m_nJK == 0) { m_nJK = ::GetDbMgr()->GetOptInt(OPT_M_LASTJKZS); m_ServerMedicalTime = ::GetDbMgr()->GetOptInt(OPT_M_LASTTJTIME); if (m_nJK == 0 || m_ServerMedicalTime == 0) CalcJKZS(); } CString strServerMedicalTime; if (m_ServerMedicalTime) { tm *tm = ::_localtime32(&m_ServerMedicalTime); strServerMedicalTime.Format( "%04d/%02d/%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); } else { strServerMedicalTime = "尚未体检"; } UpdateJKZS(m_nJK, strServerMedicalTime); UpdateServer(m_Servers, m_nServer); UpdateClient(&m_ClientInfo); UpdateGameInfo(&m_GameInfo); }
void Phase::UndoCmd(CommitSession& session, Player& player) { LiveGame& game = GetGame(); VERIFY_MODEL_MSG(player.GetName(), &game == player.GetCurrentLiveGame()); const Colour colour = game.GetTeam(player).GetColour(); const Cmd* pCmd = GetCurrentCmd(colour); const Controller& controller = session.GetController(); if (Cmd* pUndo = RemoveCmd(session, colour)) { while (pUndo->GetRecordCount()) { // Update review games before record gets popped. for (auto& g : game.GetReviewGames()) g->OnPreRecordPop(controller); pUndo->PopRecord(session); } if (pUndo->IsAutoProcess()) // Also undo the command start. RemoveCmd(session, colour); } UpdateClient(controller, &player); }
void UpkeepPhase::FinishGraveyard(CommitSession& session, const Player& player) { LiveGame& game = GetGame(); const Colour c = game.GetTeam(player).GetColour(); VERIFY_MODEL(GetCurrentCmd(c) == nullptr); bool bOK = m_finished.insert(c).second; VERIFY_MODEL(bOK); const Controller& controller = session.GetController(); UpdateClient(controller, &player); if (m_finished.size() == game.GetTeams().size()) { session.DoAndPushRecord(RecordPtr(new StartRoundRecord)); if (game.HasFinished()) game.StartScorePhase(); // Deletes this. else game.StartActionPhase(); // Deletes this. game.GetPhase().UpdateClient(controller, nullptr); } session.GetController().SendMessage(Output::UpdateCurrentPlayers(session.GetGame()), session.GetGame()); }
void MainObject::UpdateClients() { std::vector<int> ids; lp_server->getIdList(&ids); for(unsigned i=0;i<ids.size();i++) { UpdateClient(ids[i]); } }
void ChooseTeamPhase::AssignTeam(CommitSession& session, Player& player, RaceType race, Colour colour) { LiveGame& game = GetGame(); game.GetTeam(player).Assign(race, colour, game); AdvanceTurn(); session.GetController().SendMessage(Output::ChooseTeam(game, false), player); bool allAssigned = true; for (auto& team : game.GetTeams()) allAssigned &= team->GetColour() != Colour::None; if (allAssigned) { session.DoAndPushRecord(RecordPtr(new StartGameRecord)); game.StartMainGamePhase(); // Deletes this. session.GetController().SendUpdateGame(game); } else UpdateClient(session.GetController(), nullptr); }
void KmxController::Poll() { //poll is called every at least every 100 ms but can be alot more often if(msPast(&tval_poll_callbacks,200)){ //debug("polling callbacks"); mq->PollCallbacks(); } //only perform poll when locked //Timeout must be short enough not to be reentering if multiple threads are calling poll if(msPast(&tval_status,200)){ if(km->WaitToken(false,100) == KMOTION_LOCKED){ if(!simulate){ // Note only service the console // after we have the token so we // are sure of no getting blocked if(km->ServiceConsole()){ //TODO not verified that this works. DoErrorMessage(">ServiceConsole Failed\n"); } if(readStatus()){ //return; } } km->ReleaseToken(); //TODO //if(!simulate){ //ServiceKFLOPCommands(); //} } UpdateClient(); } }
void CClientInfoMgr::AddClient ( char const* pszName, bool bIsAdmin, uint32 nID, uint8 nTeamID) { m_nLocalID = 0; g_pLTClient->GetLocalClientID (&m_nLocalID); // if we already have this client in the list, then it's an update, not an add. CLIENT_INFO* pDup = GetClientByID(nID, false); if (pDup) { UpdateClient( pszName, bIsAdmin, nID, nTeamID ); return; } if( g_pGameClientShell->ShouldUseRadar() ) { g_pRadar->UpdatePlayerName(nID, pszName, nTeamID ); } // create the new object CLIENT_INFO* pNew = debug_new(CLIENT_INFO); if (!pNew) return; pNew->nID = nID; pNew->sName = pszName; pNew->bIsAdmin = bIsAdmin; pNew->nTeamID = nTeamID; pNew->sScore.Init(nID); // if we don't have a list yet, set the list pointer to the new object if (!m_pClients) { m_pClients = pNew; return; } // we do have a list - insert the object CLIENT_INFO* ptr = m_pClients; //insert at head? if (ptr->sScore.GetScore() < pNew->sScore.GetScore()) { pNew->pNext = m_pClients; m_pClients = pNew; return; } CLIENT_INFO* pNext = ptr->pNext; while (pNext && pNext->sScore.GetScore() >= pNew->sScore.GetScore()) { ptr = pNext; pNext = ptr->pNext; } if (pNext) { pNext->pPrev = pNew; } ptr->pNext = pNew; pNew->pNext = pNext; pNew->pPrev = ptr; }
void MainObject::commandReceivedData(int id,int cmd,const QStringList &args) { QStringList oargs; unsigned codec_num; unsigned port_num; bool ok=false; int room_num=lp_server->source(id); switch((MainObject::PanelCommand)cmd) { case MainObject::DC: lp_server->closeConnection(id); break; case MainObject::GC: oargs.push_back("S"); oargs.push_back(QString().sprintf("%u",lp_codecs->codecQuantity())); oargs.push_back(QString().sprintf("%u",lp_rooms->portQuantity(room_num))); oargs.push_back(lp_rooms->name(room_num)); lp_server->sendCommand(id,(int)MainObject::GC,oargs); for(unsigned i=0;i<lp_codecs->codecQuantity();i++) { oargs.clear(); oargs.push_back("O"); oargs.push_back(QString().sprintf("%u",i+1)); oargs.push_back(lp_codecs->name(i)); lp_server->sendCommand(id,(int)MainObject::GC,oargs); oargs.clear(); oargs.push_back("C"); oargs.push_back(QString().sprintf("%u",i+1)); oargs.push_back(lp_codecs->configurationCommand(i)); lp_server->sendCommand(id,(int)MainObject::GC,oargs); oargs.clear(); oargs.push_back("B"); oargs.push_back(QString().sprintf("%u",i+1)); oargs.push_back(QString().sprintf("%u",lp_codecs->isBusy(i))); lp_server->sendCommand(id,(int)MainObject::GC,oargs); } for(unsigned i=0;i<lp_rooms->portQuantity(room_num);i++) { oargs.clear(); oargs.push_back("I"); oargs.push_back(QString().sprintf("%u",i+1)); oargs.push_back(lp_rooms->portName(room_num,i)); lp_server->sendCommand(id,(int)MainObject::GC,oargs); } oargs.clear(); lp_server->sendCommand(id,(int)MainObject::GC,oargs); UpdateClient(id); break; case MainObject::SX: codec_num=args[0].toUInt(&ok)-1; if(ok&&(codec_num<lp_codecs->codecQuantity())) { if(lp_codecs->isBusy(codec_num)) { oargs.clear(); oargs.push_back(tr("Codec")); oargs.push_back(lp_codecs->name(codec_num)); if((room_num=lp_codecs->connectedToRoom(codec_num))<0) { oargs.push_back(tr("is currently in use elsewhere.")); } else { oargs.push_back(tr("is currently in use in")); oargs.push_back(lp_rooms->name(room_num)+"."); } lp_server->sendCommand(id,(int)MainObject::MB,oargs); return; } port_num=args[1].toUInt(&ok)-1; if(ok&&(port_num<lp_rooms->portQuantity(room_num))) { lp_devices->inputSwitcher()-> setCrosspoint(lp_codecs->switcherOutput(codec_num), lp_rooms->switcherInput(room_num,port_num)); lp_devices->outputSwitcher()-> setCrosspoint(lp_rooms->switcherOutput(room_num,port_num), lp_codecs->switcherInput(codec_num)); lp_rooms->setCodec(room_num,port_num,codec_num); lp_codecs->setConnectedToRoom(codec_num,room_num); UpdateClients(); } } break; case MainObject::MB: break; } }
LRESULT CClientListCtrl::OnP4EndSpecEdit( WPARAM wParam, LPARAM lParam ) { CCmd_EditSpec *pCmd= (CCmd_EditSpec *) wParam; BOOL chainedCommand = FALSE; BOOL need2Refresh = FALSE; if (lParam != IDCANCEL && lParam != IDABORT) { // Get the Sync flag int syncAfter = SYNC_DONT; BOOL bHasChgs = TRUE; if (m_PrevNbrCli < 1) { int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; CCmd_Changes *pCmd2= new CCmd_Changes; pCmd2->Init( m_hWnd, RUN_SYNC, key ? HOLD_LOCK : LOSE_LOCK, key); if( pCmd2->Run(SUBMITTED_CHANGES, FALSE, NULL, 1) ) { if (!pCmd2->GetChanges()->GetCount()) bHasChgs = FALSE; } delete pCmd2; } if (m_isNew && !GET_P4REGPTR()->DontShowYouHaveCr8NewClient() && bHasChgs) { BOOL b; switch(MsgBox(IDS_YOU_HAVE_CREATED_NEW_CLIENT, MB_ICONEXCLAMATION | MB_DEFBUTTON1, 0, this, &b)) { case IDC_BUTTON1: syncAfter = SYNC_HEAD; break; case IDC_BUTTON2: syncAfter = SYNC_DONT; break; } GET_P4REGPTR()->SetDontShowYouHaveCr8NewClient(b); } else if ((pCmd->IsSyncAfter() || pCmd->IsAutoUpdateSpec()) && !GET_P4REGPTR()->DontShowYouHaveChgClientView() && bHasChgs) { BOOL b; switch(MsgBox(pCmd->IsAutoUpdateSpec() ? IDS_DOYOUWANTOTSYNCYOURNEWCLIENT : IDS_YOU_HAVE_CHANGED_CLIENTS_VIEW, MB_ICONQUESTION | MB_DEFBUTTON1, 0, this, pCmd->IsAutoUpdateSpec() ? NULL : &b)) { case IDC_BUTTON1: syncAfter = SYNC_HEAD; break; case IDC_BUTTON2: syncAfter = pCmd->IsAutoUpdateSpec() ? SYNC_DONT : SYNC_HAVE; break; case IDC_BUTTON3: syncAfter = SYNC_DONT; break; } if (!pCmd->IsAutoUpdateSpec()) GET_P4REGPTR()->SetDontShowYouHaveChgClientView(b); } BOOL bDeld = FALSE; if (m_UpdateState == LIST_UPDATED) { // we have to set 'index' again in case client's name got changed int index= FindInList(m_pNewSpec->GetClientName()); int ixAll= FindInListAll(m_pNewSpec->GetClientName()); if (ixAll == -1) // not in either list { ASSERT(index == -1); CString curclient = GET_P4REGPTR()->GetP4Client(); CString defclient = GET_P4REGPTR()->GetP4Client(TRUE); InsertClient(m_pNewSpec, GetItemCount(), &curclient, &defclient); } else if (index > -1) // in both lists { ASSERT(ixAll > -1); if (MainFrame()->IsClientFilteredOut(m_pNewSpec)) // should it no longer be shown? { need2Refresh = TRUE; delete m_pNewSpec; } else { UpdateClient(m_pNewSpec, index); UpdateClientAll(m_pNewSpec, ixAll); } } else // not in visible list; is in list of all { if (MainFrame()->IsClientFilteredOut(m_pNewSpec)) // should it now be shown? need2Refresh = TRUE; else UpdateClientAll(m_pNewSpec, ixAll); if (pCmd->IsAutoUpdateSpec()) m_OldClient = m_pNewSpec->GetClientName(); delete m_pNewSpec; bDeld = TRUE; } ReSort(); if (pCmd->IsAutoUpdateSpec() || pCmd->IsSpecForceSwitch()) { if (bDeld) need2Refresh = TRUE; else { int i = FindInList(m_OldClient = m_pNewSpec->GetClientName()); if (i < 0) i = 0; SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); EnsureVisible(i, FALSE); } m_Active = _T("@"); // force switch to new client } } else if ( m_pNewSpec ) delete m_pNewSpec; int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; if( m_Active == m_saveclientnew ) // active-client == saved new client name m_OldClient = m_saveclientnew; // means they decided to edit the current client if( m_Active != m_OldClient ) // If current client is not now the client when this { // all started, switch to the new current client if (GET_P4REGPTR()->GetExpandFlag() == 1) GET_P4REGPTR()->AddMRUPcuPath(MainFrame()->GetCurrentItemPath()); m_Active = m_OldClient; GET_P4REGPTR()->SetP4Client( m_Active, TRUE, FALSE, FALSE); MainFrame()->UpdateCaption( ); if (syncAfter) chainedCommand = SyncAfter(key, syncAfter); } else if( syncAfter || GET_P4REGPTR()->GetClearAndReload() || AfxMessageBox(IDS_YOU_HAVE_UPDATED_YOUR_CLIENT_WORKSPACE__CLEAR_AND_RELOAD, MB_YESNO |MB_ICONQUESTION ) == IDYES ) { if (syncAfter) chainedCommand = SyncAfter(key, syncAfter); else { int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; MainFrame()->UpdateDepotandChangeViews(REDRILL, key); chainedCommand=TRUE; } } if (GET_SERVERLEVEL() >= 22) TheApp()->Set_m_ClientSubOpts(TheApp()->GetClientSpecField( _T("SubmitOptions"), pCmd->GetSpecOut())); } else { if ( m_pNewSpec ) delete m_pNewSpec; if (lParam == IDCANCEL && pCmd->GetIsRequestingNew()) { m_Active = pCmd->GetOldClient(); // switch back to the previous client GET_P4REGPTR()->SetP4Client( m_Active, TRUE, FALSE, FALSE); MainFrame()->UpdateCaption( ); } } if (lParam != IDABORT) { MainFrame()->ClearStatus(); if (!chainedCommand && pCmd->HaveServerLock()) pCmd->ReleaseServerLock(); CDialog *dlg = (CDialog *)pCmd->GetSpecSheet(); dlg->DestroyWindow(); } delete pCmd; m_EditInProgress = FALSE; if (need2Refresh && !chainedCommand) OnViewUpdate(); if (TheApp()->m_RunClientWizOnly && !chainedCommand) ::PostMessage(MainFrame()->m_hWnd, WM_COMMAND, ID_APP_EXIT, 0); return 0; }