int MAINTYPE main ( int argc, char * argv[] ) { int ErrorNumber = 0; char * FileName = argv[1]; struct _stat StatBuffer; assert( FileName != NULL ); if ( _stat( FileName, &StatBuffer ) ) { ErrorNumber = errno; assert( ErrorNumber != 0 ); (void) printf( "stat func failed %d\n", ErrorNumber ); goto Cleanup; } ShowTime( "mod time", StatBuffer.st_mtime ); ShowTime( "chg time", StatBuffer.st_ctime ); Cleanup: if (ErrorNumber == 0) { return (EXIT_SUCCESS); } else { return (EXIT_FAILURE); } } // main
void CConfigRecord::ShowWindow(int nChannel) { m_ctlRedundancy.SetCheck(m_RecordCfg.vRecordConfigAll[nChannel].bRedundancy); SetDlgItemInt(IDC_EDIT_PRERECLEN,m_RecordCfg.vRecordConfigAll[nChannel].iPreRecord); SetDlgItemInt(IDC_EDIT_RECORDLEN,m_RecordCfg.vRecordConfigAll[nChannel].iPacketLength); if ((m_RecordCfg.vRecordConfigAll[nChannel].iRecordMode == 1) || (m_RecordCfg.vRecordConfigAll[nChannel].iRecordMode == 0)) { if (m_RecordCfg.vRecordConfigAll[nChannel].iRecordMode == 1) { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO1); }else { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO2); } ShowTime(FALSE); }else { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO0); ShowTime(TRUE); } //ShowTime(FALSE); CTime time = CTime::GetCurrentTime(); m_ctlRecordWeek.SetCurSel(time.GetDayOfWeek()-1); m_nLastWeek = 0; }
int main(int argc, char* argv[]) { if (argc != 2) { printf("usage: filetime.exe <file>\n"); return 0; } HANDLE hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); if (hFile == INVALID_HANDLE_VALUE) { fprintf(stderr, "open failed, ecode: %u\n", GetLastError()); return 1; } FILETIME create, lastAccess, lastWrite; BOOL success = GetFileTime(hFile, &create, &lastAccess, &lastWrite); ShowTime("Create Time: ", create); ShowTime("Last Access Time: ", lastAccess); ShowTime("Last Write Time: ", lastWrite); CloseHandle(hFile); return 0; }
void CSnapStorageDlg::ShowWindow(int nChannel) { // m_ctlRedundancy.SetCheck(m_SnapCfg.vSnapshotConfigAll[nChannel].bRedundancy); SetDlgItemInt(IDC_EDIT_LENGTH,m_SnapCfg.vSnapshotConfigAll[nChannel].iPreSnap); // SetDlgItemInt(IDC_EDIT_RECORDLEN,m_SnapCfg.vSnapshotConfigAll[nChannel].iPacketLength); if ((m_SnapCfg.vSnapshotConfigAll[nChannel].iSnapMode == 1) || (m_SnapCfg.vSnapshotConfigAll[nChannel].iSnapMode == 0)) { if (m_SnapCfg.vSnapshotConfigAll[nChannel].iSnapMode == 1) { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO1); }else { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO2); } ShowTime(FALSE); }else { CheckRadioButton(IDC_RADIO0,IDC_RADIO2,IDC_RADIO0); ShowTime(TRUE); } CTime time = CTime::GetCurrentTime(); m_ctlRecordWeek.SetCurSel(time.GetDayOfWeek()-1); m_nLastWeek = 0; UpdateData(TRUE); }
labelshowtime::labelshowtime(QWidget *parent): QLabel(parent) { QTimer *timer=new QTimer(this); timer->setInterval(1000); //new databasecomfiguretion(); connect(timer,SIGNAL(timeout()), this,SLOT(ShowTime())); timer->start(); ShowTime(); resize(500,100); //setStyleSheet("background: yellow"); setStyleSheet("font: 50pt;"); }
static void Show(uchar ibVal) { switch (ibVal) { case 0: ShowHi(szTimeGps); break; case 1: ShowHi(szDeltaTimeGps); break; case 2: ShowHi(szTimeDateGps); break; case 3: ShowHi(szVersionGps); break; } time2 tm2 = ReadTimeDateGps(); if (tm2.fValid == false) { Error(); DelayInf(); Clear(); } else { if (ShowStatusGps() == 1) { switch (ibVal) { case 0: ShowTime(tm2.tiValue); break; case 1: ShowDeltaTime(tm2.tiValue); break; case 2: ShowTimeDate(tm2.tiValue); break; case 3: sprintf(szLo+7,"%u.%u",bVersionMaxGps,bVersionMinGps); break; } } } }
void Manager::RefreshCommit() { _MANAGER(CleverSysLog clv(L"Manager::RefreshCommit()")); _MANAGER(SysLog(L"RefreshedFrame=%p",RefreshedFrame)); if (!RefreshedFrame) return; if (IndexOf(RefreshedFrame)==-1 && IndexOfStack(RefreshedFrame)==-1) return; if (!RefreshedFrame->Locked()) { if (!Global->IsRedrawFramesInProcess) RefreshedFrame->ShowConsoleTitle(); if (RefreshedFrame) RefreshedFrame->Refresh(); if (!RefreshedFrame) return; CtrlObject->Macro.SetMode(RefreshedFrame->GetMacroMode()); } if ((Global->Opt->ViewerEditorClock && (RefreshedFrame->GetType() == MODALTYPE_EDITOR || RefreshedFrame->GetType() == MODALTYPE_VIEWER)) || (Global->WaitInMainLoop && Global->Opt->Clock)) ShowTime(1); }
void WriteProgress(string Desc, int &Prog, int i, int N) { int Node = 0; #ifdef USE_MPI int MpiError = MPI_Comm_rank(MPI_COMM_WORLD, &Node); MPI_Status MpiStatus; #endif //if (Node != 0) // return; #pragma omp critical(output) { Prog++; #ifdef USE_MPI string Buffer = ShowTime() + " - " + Desc + " on node " + to_string(Node) + ": " + to_string(Prog) + " of " + to_string(N) + "\n"; //MpiError = MPI_File_write_shared(MpiLog, (void*)Buffer.c_str(), Buffer.length(), MPI_CHAR, &MpiStatus); //MpiError = MPI_File_sync(MpiLog); cerr << Buffer; #endif if (Node == 0) { cout << setprecision(5) << float(Prog)/float(N)*100.0 << "\r"; fflush(stdout); //cout << "\b\b\b\b\b\b"; cout << setprecision(18); // Restore original } else { cout << "\r" << endl; } } return; }
__task void CMDHandler(void) { uint8_t write_buf[128]={0}; uint8_t read_buf[128]={0}; uint8_t i=0; uint32_t err_count=0; uint32_t ok_count=0; unsigned short tmp=0; os_dly_wait(300); // // 10MS * 10 = 100 mS Serial_PutString("AT\r\n"); os_dly_wait(50); // // 10MS * 10 = 100 mS Serial_PutString("ATE1\r\n"); os_dly_wait(50); // // 10MS * 10 = 100 mS Serial_PutString("AT+CPIN?\r\n"); os_dly_wait(100); // // 10MS * 10 = 100 mS ds18b20_start(); while (1) { Serial_PutString("AT+CSQ\r\n"); ShowTime(); printf("ACC:%5.2f %5.2f %5.2f GYRO: %5.2f %5.2f %5.2f\r\n\r\n",Acc_Buffer[0],Acc_Buffer[1],Acc_Buffer[2], Gyro_Buffer[0],Gyro_Buffer[1],Gyro_Buffer[2]); printf("SLOAR: %d, CHARGE: %d, BAT: %d (ADC Value)\r\n",Adc1Result.Channel_8, Adc1Result.Channel_9, Adc1Result.Channel_15); for(i=0;i<128;i++) write_buf[i]=rand(); at25_write_page(0x00,128,write_buf); at25_read_page(0x00,128,read_buf); if(memcmp(read_buf,write_buf,128) == 0) { printf("> FRAM Write successed : %d\r\n" ,++ok_count); } else { printf("> FRAM Write failed: %d\r\n",++err_count); } tmp=ds18b20_read(); printf("> Tmp: %.1f (%d)\r\n",(tmp*0.0039),tmp); if(flag_usart3_rx==1) { flag_usart3_rx=0; printf("%s",UART3RecvBuf); printf("\r\n"); } printf("---------------------------------------------------------------------------\r\n\r\n"); os_dly_wait(100); // // 10MS * 10 = 100 mS } }
void LevelMgr::Load(int level) { mCurLevel = level; FishMgr::Instance()->Load(mLevelInfoList[mCurLevel].fishList,mLevelInfoList[mCurLevel].fishCount); BackGroundMgr::Instance()->Load(mCurLevel); CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(mLevelInfoList[mCurLevel].music,true); mTime = mLevelInfoList[mCurLevel].time; ShowTime(); }
std::string Song::getLength(unsigned idx) const { assert(m_song); if (idx > 0) return ""; unsigned len = getDuration(); if (len > 0) return ShowTime(len); else return "-:--"; }
U32 tcPersonWanted(U32 persId) { U32 hours, i = 0, caught = 0; Person john = dbGetObject(Person_John_Gludo); Person miles = dbGetObject(Person_Miles_Chickenwing); LIST *bubble; LIST *jobs = txtGoKey(OBJECTS_ENUM_TXT, "enum_JobE"); char line[TXT_KEY_LENGTH], name[TXT_KEY_LENGTH]; dbGetObjectName(persId, name); bubble = txtGoKey(BUSINESS_TXT, "BURGLAR_RECOG"); sprintf(line, "%s %s.", NODE_NAME(GetNthNode(bubble, 3)), name); RemoveNode(bubble, NODE_NAME(GetNthNode(bubble, 3))); CreateNode(bubble, 0L, line); SetPictID(john->PictID); Bubble(bubble, 0, 0L, 0L); RemoveList(bubble); Say(BUSINESS_TXT, 0, miles->PictID, "ARREST_HIM"); livesInUnSet(London_London_1, persId); tcMoveAPerson(persId, Location_Nirvana); hours = CalcRandomNr(4L, 7L); while ((i++) < hours) { AddVTime(60); inpDelay(35); ShowTime(2); } if (tcGuyCanEscape(dbGetObject(persId)) > CalcRandomNr(100, 255)) { /* Flucht gelingt */ Say(BUSINESS_TXT, 0, john->PictID, "ESCAPED"); livesInSet(London_Escape, persId); } else { /* nicht */ Say(BUSINESS_TXT, 0, john->PictID, "ARRESTED"); livesInSet(London_Jail, persId); caught = tcPersonQuestioning(dbGetObject(persId)); } RemoveList(jobs); return caught; }
void ShowTopFlag(void) { #define BTM_LIN_START (BTM_LINE_ROW * 20) struct wr_slines_t { unsigned short x; unsigned short len; unsigned char *buffer; }; unsigned int i; //struct wr_slines_t wrconf; for(i = 0;i < 20;i++) lcd_buffer[BTM_LIN_START+i] = 0xff; ScreenSetHeadFlag(SCRHEAD_FLAG_SIG, GprsSigQuality()); //ScreenSetHeadFlag(SCRHEAD_FLAG_BAT, BatCapacity()); ShowChannel(); ShowTime(); #if 0 /* if(AlarmFlagErc) ShowAlarmFlag(1); else ShowAlarmFlag(0); wrconf.x = 0; wrconf.len = 16*20; wrconf.buffer = lcd_buffer; ioctl(fd_lcd, 20, &wrconf); if(HaveAlarmInfo) { ShowAlarmInfo(); wrconf.x = BTM_LINE_ROW+1; wrconf.len = 16*20; wrconf.buffer = lcd_buffer + (BTM_LINE_ROW+1)*20; ioctl(fd_lcd, 20, &wrconf); AlarmInfoCount++; if(AlarmInfoCount > 666) { // 10 min AlarmInfoCount = 0; HaveAlarmInfo = 0; memset(lcd_buffer+(BTM_LINE_ROW+1)*20, 0, 16*20); } } */ //write(fd_lcd,lcd_buffer_tmp, LCD_BUFFER_SIZE); #endif DisplayLcdBuffer(); }
void mOutputCommandFlush( ) { // if (mTotalSims % mOutputCommandInterval == 0) // { if(mOutputCommandDetailLevel == 3) { cout<<" TotalSims = " <<mTotalSims <<" Time = " << (int)mTotalExeTime << "s Total error = "<<mTotalErrors <<" Avg # iteration = " << mTotalIterations/(double)(mTotalSims) <<" Undetected error = "<<mTotalUndetectedErrors <<" ML error = " <<mTotalMLErrors <<" Avg decode time = " <<(double)mTotalDecodingTime/CLOCKS_PER_SEC/ (double)(mTotalSims) <<"(s)" <<endl; } else if(mOutputCommandDetailLevel == 2) { cout<<" TotalSims = " << mTotalSims <<" Time = " <<(int)mTotalExeTime <<" Total error = " <<mTotalErrors <<" Undetected error = " << mTotalUndetectedErrors <<" ML error = " <<mTotalMLErrors <<" Avg # iteration = " <<mTotalIterations/(double)(mTotalSims) <<" Avg # iteration correct = " <<mTotalCorrectIterations/(double)(mTotalSims - mTotalErrors) <<" Avg # iteration wrong = " <<mTotalWrongIterations/(double)(mTotalErrors) <<" Avg decode time = " <<(double)mTotalDecodingTime/CLOCKS_PER_SEC/ (double)(mTotalSims) <<"(s)" <<" Avg decode time correct = " <<(double)mTotalCorrectDecodingTime/CLOCKS_PER_SEC/ (double)(mTotalSims - mTotalErrors) <<"(s)" <<" Avg decode time wrong = " <<(double)mTotalWrongDecodingTime/CLOCKS_PER_SEC/ (double)(mTotalErrors) <<"(s)" <<endl; } else if(mOutputCommandDetailLevel != -1) { double tBER = ((double)nbBitErrors) / (mBlocklength * (double)mTotalSims); double tFER = (double)mTotalErrors / (double)mTotalSims; double temps = (double)mTotalExeTime; double sec_par_trame = (temps/1000.f) / mTotalSims; double trame_par_sec = 1.0f / sec_par_trame; double bps = (trame_par_sec * mBlocklength) / 1000.0 / 1000.0; double avgIters = (double)mTotalIterations/(double)(mTotalSims); printf("SNR = %.2f | BER = %1.3e | FER = %1.3e | BPS = %2.2f | MATRICES = %8ld | FE = %3d | ERR = %d | MlErr = %d | Avg#Iter = %3.1f | ", EbN0, tBER, tFER, bps, mTotalSims, (int) mTotalErrors, (int) mTotalUndetectedErrors, (int)mTotalMLErrors, avgIters); printf("TpF = %1.3f ms | ", (temps) / (float)mTotalSims); printf(" | "); ShowTime( ((double)mTotalSimTime) ); printf("\n"); fflush(stdout); } }
static void ShowParamBuff(void) { if (GetParamDevice(iwPrm) == 0) ShowLo(szNoParam); else { if (mpboEnblParams[iwPrm] == false) ShowLo(szBlocked); else { switch (ibVal) { case 0: sprintf(szLo,"%12.3f", mpreParamsBuff[ibSoftTim][iwPrm]); break; case 1: ShowTime(mptiParamsBuff[iwPrm]); break; case 2: ShowDate(mptiParamsBuff[iwPrm]); break; } } } }
void FetchOneThumbnail( HWND hwnd, MPARAM mp1, MPARAM mp2) { CAMRecPtr pcr = (CAMRecPtr)mp1; if (pcr == (CAMRecPtr)-1) { ShowTime( "FetchThumb", TRUE); UpdateThumbWnd( hwnd); return; } if (pcr && pcr->bmp) { WinSendDlgItemMsg( hwnd, FID_CLIENT, CM_INVALIDATERECORD, (MP)&pcr, MPFROM2SHORT( 1, (CMA_NOREPOSITION | CMA_ERASE))); if (pcr->mrc.flRecordAttr & CRA_CURSORED) WinPostMsg( hwnd, CAMMSG_SHOWTHUMB, (MP)pcr, 0); } return; }
void FileViewer::ShowStatus() { string strName; string strStatus; if (!IsTitleBarVisible()) return; GetTitle(strName); int NameLength=ScrX-43; //???41 if (Opt.ViewerEditorClock && IsFullScreen()) NameLength-=6; if (NameLength<20) NameLength=20; TruncPathStr(strName, NameLength); const wchar_t *lpwszStatusFormat = L"%-*s %5u %13I64u %7.7s %-4I64d %s%3d%%"; strStatus.Format( lpwszStatusFormat, NameLength, strName.CPtr(), View.VM.CodePage, View.FileSize, MSG(MViewerStatusCol), View.LeftPos, Opt.ViewerEditorClock ? L"":L" ", (View.LastPage ? 100:ToPercent64(View.FilePos,View.FileSize)) ); SetColor(COL_VIEWERSTATUS); GotoXY(X1,Y1); FS<<fmt::LeftAlign()<<fmt::Width(View.Width+(View.ViOpt.ShowScrollbar?1:0))<<fmt::Precision(View.Width+(View.ViOpt.ShowScrollbar?1:0))<<strStatus; if (Opt.ViewerEditorClock && IsFullScreen()) ShowTime(FALSE); }
static ubyte tcCarFound(Car car, U32 time) { S32 i = 0, hours; Person john = dbGetObject(Person_John_Gludo); Person miles = dbGetObject(Person_Miles_Chickenwing); ubyte found = 0; /* Der Jaguar darf nicht gefunden werden - sonst k�nnte er ja */ /* nicht explodieren! */ if (car != dbGetObject(Car_Jaguar_XK_1950)) { if (tcIsCarRecognised(car, time)) { /* Wagen wird erkannt! */ Say(BUSINESS_TXT, 0, john->PictID, "CAR_RECOG"); hours = CalcRandomNr(2L, 5L); while ((i++) < hours) { AddVTime(60); inpDelay(35); ShowTime(2); } if (!tcIsCarRecognised(car, time)) { /* Wagen wird nicht gefunden */ Say(BUSINESS_TXT, 0, john->PictID, "CAR_NOT_FOUND"); car->Strike = CalcRandomNr(200, 255); } else { /* Wagen wird gefunden! */ found = 1; Say(BUSINESS_TXT, 0, john->PictID, "CAR_FOUND"); Say(BUSINESS_TXT, 0, miles->PictID, "GUTE_ARBEIT"); UnSet(dbGetObject(Person_Matt_Stuvysunt), Relation_has, car); } } } return found; }
void GetColor(int PaletteIndex) { FarColor NewColor = Global->Opt->Palette[PaletteIndex-COL_FIRSTPALETTECOLOR]; if (Console().GetColorDialog(NewColor)) { Global->Opt->Palette.Set(PaletteIndex-COL_FIRSTPALETTECOLOR, &NewColor, 1); Global->ScrBuf->Lock(); // отменяем всякую прорисовку Global->CtrlObject->Cp()->LeftPanel->Update(UPDATE_KEEP_SELECTION); Global->CtrlObject->Cp()->LeftPanel->Redraw(); Global->CtrlObject->Cp()->RightPanel->Update(UPDATE_KEEP_SELECTION); Global->CtrlObject->Cp()->RightPanel->Redraw(); Global->WindowManager->ResizeAllWindows(); // рефрешим Global->WindowManager->PluginCommit(); // коммитим. if (Global->Opt->Clock) ShowTime(1); Global->ScrBuf->Unlock(); // разрешаем прорисовку Global->WindowManager->PluginCommit(); // коммитим. } }
int FileViewer::ProcessKey(int Key) { if (RedrawTitle && (((unsigned int)Key & 0x00ffffff) < KEY_END_FKEY || IS_INTERNAL_KEY_REAL((unsigned int)Key & 0x00ffffff))) ShowConsoleTitle(); if (Key!=KEY_F3 && Key!=KEY_IDLE) F3KeyOnly=false; switch (Key) { #if 0 /* $ 30.05.2003 SVS Фича :-) Shift-F4 в редакторе/вьювере позволяет открывать другой редактор/вьювер Пока закомментим */ case KEY_SHIFTF4: { if (!Opt.OnlyEditorViewerUsed) CtrlObject->Cp()->ActivePanel->ProcessKey(Key); return TRUE; } #endif /* $ 22.07.2000 tran + выход по ctrl-f10 с установкой курсора на файл */ case KEY_CTRLF10: { if (View.isTemporary()) { return TRUE; } SaveScreen Sc; string strFileName; View.GetFileName(strFileName); CtrlObject->Cp()->GoToFile(strFileName); RedrawTitle = TRUE; return (TRUE); } // $ 15.07.2000 tran + CtrlB switch KeyBar case KEY_CTRLB: Opt.ViOpt.ShowKeyBar=!Opt.ViOpt.ShowKeyBar; if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); else ViewKeyBar.Hide0(); // 0 mean - Don't purge saved screen Show(); KeyBarVisible = Opt.ViOpt.ShowKeyBar; return (TRUE); case KEY_CTRLSHIFTB: { Opt.ViOpt.ShowTitleBar=!Opt.ViOpt.ShowTitleBar; TitleBarVisible = Opt.ViOpt.ShowTitleBar; Show(); return (TRUE); } case KEY_CTRLO: if (!Opt.OnlyEditorViewerUsed) { if (FrameManager->ShowBackground()) { SetCursorType(FALSE,0); WaitKey(); FrameManager->RefreshFrame(); } } return TRUE; case KEY_F3: case KEY_NUMPAD5: case KEY_SHIFTNUMPAD5: if (F3KeyOnly) return TRUE; case KEY_ESC: case KEY_F10: FrameManager->DeleteFrame(); return TRUE; case KEY_F6: if (!DisableEdit) { UINT cp=View.VM.CodePage; string strViewFileName; View.GetFileName(strViewFileName); File Edit; if(!Edit.Open(strViewFileName, GENERIC_READ, FILE_SHARE_READ|(Opt.EdOpt.EditOpenedForWrite?FILE_SHARE_WRITE:0), nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN)) { Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MEditTitle),MSG(MEditCannotOpen),strViewFileName,MSG(MOk)); return TRUE; } Edit.Close(); // Если переключаемся в редактор, то удалять файл уже не нужно SetTempViewName(L""); SetExitCode(0); __int64 FilePos=View.GetFilePos(); /* $ 07.07.2006 IS Тут косяк, замеченный при чтении warnings - FilePos теряет информацию при преобразовании __int64 -> int Надо бы поправить FileEditor на этот счет. */ FileEditor *ShellEditor = new FileEditor(strViewFileName, cp, (GetCanLoseFocus()?FFILEEDIT_ENABLEF6:0)|(SaveToSaveAs?FFILEEDIT_SAVETOSAVEAS:0)|(DisableHistory?FFILEEDIT_DISABLEHISTORY:0),-2, static_cast<int>(FilePos), nullptr); ShellEditor->SetEnableF6(TRUE); /* $ 07.05.2001 DJ сохраняем NamesList */ ShellEditor->SetNamesList(View.GetNamesList()); FrameManager->DeleteFrame(this); // Insert уже есть внутри конструктора ShowTime(2); } return TRUE; // Печать файла с использованием плагина PrintMan case KEY_ALTF5: { if (Opt.UsePrintManager && CtrlObject->Plugins.FindPlugin(SYSID_PRINTMANAGER)) CtrlObject->Plugins.CallPlugin(SYSID_PRINTMANAGER,OPEN_VIEWER,0); // printman return TRUE; } case KEY_ALTSHIFTF9: // Работа с локальной копией ViewerOptions ViewerOptions ViOpt; ViOpt.TabSize=View.GetTabSize(); ViOpt.AutoDetectCodePage=View.GetAutoDetectCodePage(); ViOpt.ShowScrollbar=View.GetShowScrollbar(); ViOpt.ShowArrows=View.GetShowArrows(); ViOpt.PersistentBlocks=View.GetPersistentBlocks(); ViewerConfig(ViOpt,true); View.SetTabSize(ViOpt.TabSize); View.SetAutoDetectCodePage(ViOpt.AutoDetectCodePage); View.SetShowScrollbar(ViOpt.ShowScrollbar); View.SetShowArrows(ViOpt.ShowArrows); View.SetPersistentBlocks(ViOpt.PersistentBlocks); if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); View.Show(); return TRUE; case KEY_ALTF11: if (GetCanLoseFocus()) CtrlObject->CmdLine->ShowViewEditHistory(); return TRUE; default: // Этот кусок - на будущее (по аналогии с редактором :-) // if (CtrlObject->Macro.IsExecuting() || !View.ProcessViewerInput(&ReadRec)) { /* $ 22.03.2001 SVS Это помогло от залипания :-) */ if (!CtrlObject->Macro.IsExecuting()) if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); if (!ViewKeyBar.ProcessKey(Key)) return(View.ProcessKey(Key)); } return TRUE; } }
void CConfigRecord::OnRadio2() { // TODO: Add your control notification handler code here ShowTime(FALSE); }
void CalcARowAndBVector(int Node, int NumTermsQi0, int NumTermsQiGt0, int Omega, vector <rPowers> &PowerTableQi0, vector <rPowers> &PowerTableQiGt0, vector <double> &AResultsQi0, vector <double> &AResultsQiGt0, vector <double> &ARow, vector <double> &BResultsQi0, vector <double> &BResultsQiGt0, vector <double> &B, double &SLS, double &SLC, int l, QuadPoints &q, double r2Cusp, double r3Cusp, double alpha, double beta, double gamma, double kappa, double mu, double lambda1, double lambda2, double lambda3, int shpower, int sf) { //int NumTermsSub = NodeEnd-NodeStart+1; vector <rPowers> PowerTableSub; #ifdef USE_MPI int MpiError; MPI_Status MpiStatus; string Buffer; #endif // Calculate CLC term separately (requires different integration than the PhiLS terms). if (Node == 0) { ARow[0] = 0.0; B[0] = 0.0; SLS = 0.0; if (Node == 0) cout << "Starting long-long calculations at " << ShowTime() << endl; GaussIntegrationPhi23_LongLong(l, q.LongLong_r1, q.LongLong_r2Leg, q.LongLong_r2Lag, q.LongLong_r3Leg, q.LongLong_r3Lag, q.LongLong_r12, q.LongLong_r13, q.LongLong_phi23, r2Cusp, r3Cusp, kappa, mu, shpower, sf, ARow[0], SLC, B[0], SLS); cout << "SLS w/o r23 term: " << SLS << endl; cout << "SLC w/o r23 term: " << SLC << endl; cout << "CLS w/o r23 term: " << B[0] << endl; cout << "CLC w/o r23 term: " << ARow[0] << endl; cout << endl; if (Node == 0) cout << endl << "Starting long-long r23 term calculations at " << ShowTime() << endl; double CLCTemp = 0.0, SLSTemp = 0.0, SLCTemp = 0.0, CLSTemp = 0.0; //GaussIntegrationPhi12_LongLong_R23Term(q.LongLongr23_r1, q.LongLongr23_r2Leg, q.LongLongr23_r2Lag, q.LongLongr23_r3Leg, q.LongLongr23_r3Lag, q.LongLongr23_phi12, q.LongLongr23_r13, q.LongLongr23_r23, r2Cusp, r3Cusp, kappa, mu, sf, CLCTemp, SLCTemp, CLSTemp, SLSTemp); GaussIntegrationPhi13_LongLong_R23Term(l, q.LongLongr23_r1, q.LongLongr23_r2Leg, q.LongLongr23_r2Lag, q.LongLongr23_r3Leg, q.LongLongr23_r3Lag, q.LongLongr23_phi12, q.LongLongr23_r13, q.LongLongr23_r23, r2Cusp, r3Cusp, kappa, mu, shpower, sf, CLCTemp, SLCTemp, CLSTemp, SLSTemp); cout << "SLS r23 term: " << SLSTemp << endl; cout << "SLC r23 term: " << SLCTemp << endl; cout << "CLS r23 term: " << CLSTemp << endl; cout << "CLC r23 term: " << CLCTemp << endl << endl; ARow[0] += CLCTemp; SLS += SLSTemp; SLC += SLCTemp; B[0] += CLSTemp; cout << "SLS Term: " << SLS << endl; cout << "SLC Term: " << SLC << endl; cout << "CLS Term: " << B[0] << endl; cout << "CLC Term: " << ARow[0] << endl << endl; cout << "SLC - CLS = " << SLC - B[0] << endl << endl; } if (NumTermsQi0 > 0) { // Skips when no terms with qi == 0 if (Node == 0) cout << "Starting short-long calculations at " << ShowTime() << endl; VecGaussIntegrationPhi23_PhiLCBar_PhiLSBar(AResultsQi0, BResultsQi0, l, q.ShortLong_r1, q.ShortLong_r2Leg, q.ShortLong_r2Lag, q.ShortLong_r3Leg, q.ShortLong_r3Lag, q.ShortLong_r12, q.ShortLong_r13, q.ShortLong_phi23, r2Cusp, r3Cusp, kappa, mu, shpower, sf, NumTermsQi0, PowerTableQi0, Omega, lambda1, lambda2, lambda3); #ifdef USE_MPI //MpiError = MPI_Barrier(MPI_COMM_WORLD); Buffer = "Finished short-long on node " + to_string(Node) + "\n"; //MpiError = MPI_File_write_shared(MpiLog, (void*)Buffer.c_str(), Buffer.length(), MPI_CHAR, &MpiStatus); #endif if (Node == 0) cout << "Starting short-long r23 term calculations at " << ShowTime() << endl; VecGaussIntegrationPhi13_PhiLCBar_PhiLSBar_R23Term(AResultsQi0, BResultsQi0, l, q.ShortLongr23_r1, q.ShortLongr23_r2Leg, q.ShortLongr23_r2Lag, q.ShortLongr23_r3Leg, q.ShortLongr23_r3Lag, q.ShortLongr23_r12, q.ShortLongr23_phi13, q.ShortLongr23_r23, r2Cusp, r3Cusp, kappa, mu, shpower, sf, NumTermsQi0, PowerTableQi0, Omega, lambda1, lambda2, lambda3); //VecGaussIntegrationPhi12_PhiLCBar_PhiLSBar_R23Term(AResultsQi0, BResultsQi0, q.ShortLongr23_r1, q.ShortLongr23_r2Leg, q.ShortLongr23_r2Lag, q.ShortLongr23_r3Leg, q.ShortLongr23_r3Lag, q.ShortLongr23_r12, q.ShortLongr23_phi13, q.ShortLongr23_r23, r2Cusp, r3Cusp, kappa, mu, sf, NumTermsQi0, PowerTableQi0, Omega, lambda1, lambda2, lambda3); #ifdef USE_MPI //MpiError = MPI_Barrier(MPI_COMM_WORLD); Buffer = "Finished short-long r23 term on node " + to_string(Node) + "\n"; //MpiError = MPI_File_write_shared(MpiLog, (void*)Buffer.c_str(), Buffer.length(), MPI_CHAR, &MpiStatus); #endif } if (NumTermsQiGt0 > 0) { // Skips when no terms with qi > 0 if (Node == 0) cout << "Starting short-long full calculations at " << ShowTime() << endl; VecGaussIntegrationPhi23_PhiLCBar_PhiLSBar_Full(AResultsQiGt0, BResultsQiGt0, l, q.ShortLongQiGt0_r1, q.ShortLongQiGt0_r2Leg, q.ShortLongQiGt0_r2Lag, q.ShortLongQiGt0_r3Leg, q.ShortLongQiGt0_r3Lag, q.ShortLongQiGt0_r12,q. ShortLongQiGt0_r13, q.ShortLongQiGt0_phi23, r2Cusp, r3Cusp, kappa, mu, shpower, sf, NumTermsQiGt0, PowerTableQiGt0, Omega, lambda1, lambda2, lambda3); #ifdef USE_MPI Buffer = "Finished short-long full on node " + to_string(Node) + "\n"; //MpiError = MPI_File_write_shared(MpiLog, (void*)Buffer.c_str(), Buffer.length(), MPI_CHAR, &MpiStatus); #endif } return; }
int main(int argc, char *argv[]) { //vector<rPowers> PowerTable; int Omega, NumShortTerms, Ordering, IsTriplet, ShPower; double Alpha, Beta, Gamma, Mu, Lambda1, Lambda2, Lambda3, Kappa; double **PhiHPhi, **PhiPhi; vector <double> B(1, 0.0), ARow(1, 0.0), ShortTerms; double SLS = 0.0, SLC = 0.0; QuadPoints q; int sf, l; double r2Cusp, r3Cusp; int Node = 0, TotalNodes = 1; ifstream ParameterFile, FileShortRange; ofstream OutFile; //int NodeStart, NodeEnd; time_t TimeStart, TimeEnd; #ifdef USE_MPI char ProcessorName[MPI_MAX_PROCESSOR_NAME]; MPI_Status MpiStatus; int MpiError, ProcNameLen; #endif //@TODO: Will MPI time be different? TimeStart = time(NULL); //omp_set_num_threads(1); // Initialize global constants. PI = 3.1415926535897932384626433832795029L; if (argc < 5) { cerr << "Not enough parameters on the command line." << endl; cerr << "Usage: Scattering kappa parameterfile.txt shortrangefile.psh results.txt" << endl; cout << endl; exit(1); } cout << setprecision(18); cout.setf(ios::showpoint); // MPI initialization //@TODO: Check MpiError. #ifdef USE_MPI MpiError = MPI_Init(&argc, &argv); // All MPI programs start with MPI_Init; all 'N' processes exist thereafter. MpiError = MPI_Comm_size(MPI_COMM_WORLD, &TotalNodes); // Find out how big the SPMD world is MpiError = MPI_Comm_rank(MPI_COMM_WORLD, &Node); // and what this process's rank is. MpiError = MPI_Get_processor_name(ProcessorName, &ProcNameLen); string LogName; if (argc > 5) LogName = argv[5]; else LogName = "test.log"; //MpiError = MPI_File_open(MPI_COMM_WORLD, (char*)LogName.c_str(), MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &MpiLog); //cout << "Node " << Node << " of " << TotalNodes << " on " << ProcessorName << endl; // The following code here just shows what the nodes are and how many threads each has. stringstream ThreadStringStream; int ThreadStrLen; int MaxThreads = omp_get_max_threads(); ThreadStringStream << MaxThreads << " threads on Node " << Node << " of " << TotalNodes << " on " << ProcessorName; if (Node == 0) { cout << endl << ThreadStringStream.str() << endl; for (int i = 1; i < TotalNodes; i++) { MpiError = MPI_Recv(&ThreadStrLen, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &MpiStatus); char *StringStream = new char[ThreadStrLen+1]; MpiError = MPI_Recv(StringStream, ThreadStrLen, MPI_CHAR, i, 0, MPI_COMM_WORLD, &MpiStatus); StringStream[ThreadStrLen] = NULL; cout << StringStream << endl; } cout << endl; } else { ThreadStrLen = ThreadStringStream.str().length(); const char *ThreadString = ThreadStringStream.str().c_str(); MpiError = MPI_Send(&ThreadStrLen, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send((void*)ThreadString, ThreadStrLen, MPI_CHAR, 0, 0, MPI_COMM_WORLD); } #else Node = 0; #endif if (Node == 0) { ParameterFile.open(argv[2]); OutFile.open(argv[4]); if (!ParameterFile.is_open()) { cout << "Could not open parameter file...exiting." << endl; FinishMPI(); exit(3); } if (!OutFile.is_open()) { cout << "Could not open output file...exiting." << endl; FinishMPI(); exit(4); } OutFile << setprecision(18); OutFile.setf(ios::showpoint); ShowDateTime(OutFile); ReadParamFile(ParameterFile, q, Mu, ShPower, Lambda1, Lambda2, Lambda3, r2Cusp, r3Cusp); // Read in short-range short-range elements. These have already been calculated by the PsHBound program. // We are reading in only the binary versions (they were originally text files). // FileShortRange.open(argv[3], ios::in | ios::binary); if (FileShortRange.fail()) { cerr << "Unable to open file " << argv[3] << " for reading." << endl; FinishMPI(); exit(2); } // Create short-range short-range terms // // Read in omega and nonlinear parameters. if (!ReadShortHeader(FileShortRange, Omega, IsTriplet, Ordering, NumShortTerms, Alpha, Beta, Gamma, l)) { cerr << argv[3] << " is not a valid Ps-H short-range file...exiting." << endl; FinishMPI(); exit(3); } // Calculate number of terms for a given omega. Do we need to compare to the one in the short-range file above? NumShortTerms = CalcPowerTableSize(Omega); Kappa = atof(argv[1]); if (IsTriplet == 0) sf = 1; else if (IsTriplet == 1) sf = -1; else { cout << "IsTriplet parameter incorrect in " << argv[3] << endl; exit(6); } WriteHeader(OutFile, l, IsTriplet); cout << "Omega: " << Omega << endl; cout << "Number of terms: " << NumShortTerms << endl; cout << "Alpha: " << Alpha << " Beta: " << Beta << " Gamma: " << Gamma << endl; cout << "Mu: " << Mu << endl; cout << "Shielding power: " << ShPower << endl; cout << "Kappa: " << Kappa << endl; cout << "Lambda: " << Lambda1 << " " << Lambda2 << " " << Lambda3 << endl; cout << endl << "Number of quadrature points" << endl; cout << "Long-long: " << q.LongLong_r1 << " " << q.LongLong_r2Leg << " " << q.LongLong_r2Lag << " " << q.LongLong_r3Leg << " " << q.LongLong_r3Lag << " " << q.LongLong_r12 << " " << q.LongLong_r13 << " " << q.LongLong_phi23 << endl; cout << "Long-long 2/r23 term: " << q.LongLongr23_r1 << " " << q.LongLongr23_r2Leg << " " << q.LongLongr23_r2Lag << " " << q.LongLongr23_r3Leg << " " << q.LongLongr23_r3Lag << " " << q.LongLongr23_phi12 << " " << q.LongLongr23_r13 << " " << q.LongLongr23_r23 << endl; cout << "Short-long with qi = 0: " << q.ShortLong_r1 << " " << q.ShortLong_r2Leg << " " << q.ShortLong_r2Lag << " " << q.ShortLong_r3Leg << " " << q.ShortLong_r3Lag << " " << q.ShortLong_r12 << " " << q.ShortLong_r13 << " " << q.ShortLong_phi23 << endl; cout << "Short-long 2/r23 with qi = 0: " << q.ShortLongr23_r1 << " " << q.ShortLongr23_r2Leg << " " << q.ShortLongr23_r2Lag << " " << q.ShortLongr23_r3Leg << " " << q.ShortLongr23_r3Lag << " " << q.ShortLongr23_r12 << " " << q.ShortLongr23_phi13 << " " << q.ShortLongr23_r23 << endl; cout << "Short-long (full) with qi > 0: " << q.ShortLongQiGt0_r1 << " " << q.ShortLongQiGt0_r2Leg << " " << q.ShortLongQiGt0_r2Lag << " " << q.ShortLongQiGt0_r3Leg << " " << q.ShortLongQiGt0_r3Lag << " " << q.ShortLongQiGt0_r12 << " " << q.ShortLongQiGt0_r13 << " " << q.ShortLongQiGt0_phi23 << endl; cout << endl; cout << "Cusp parameters" << endl; cout << r2Cusp << " " << r3Cusp << endl; cout << endl; if (NumShortTerms > 0) { // Allocate memory for the overlap matrix and point PhiPhiP to rows of PhiPhi so we // can access it like a 2D array but have it in contiguous memory for LAPACK. PhiPhi = new double*[NumShortTerms*2]; PhiPhi[0] = new double[NumShortTerms*NumShortTerms*4]; for (int i = 1; i < NumShortTerms*2; i++) { PhiPhi[i] = PhiPhi[i-1] + NumShortTerms*2; } // Read in the <phi|phi> matrix elements. FileShortRange.read((char*)PhiPhi[0], NumShortTerms*NumShortTerms*4*sizeof(double)); // Allocate memory for the <phi|H|phi> matrix and point PhiHPhiP to rows of PhiHPhi so we // can access it like a 2D array but have it in contiguous memory for LAPACK. PhiHPhi = new double*[NumShortTerms*2]; PhiHPhi[0] = new double[NumShortTerms*NumShortTerms*4]; for (int i = 1; i < NumShortTerms*2; i++) { PhiHPhi[i] = PhiHPhi[i-1] + NumShortTerms*2; } // Read in the <phi|H|phi> matrix elements. FileShortRange.read((char*)PhiHPhi[0], NumShortTerms*NumShortTerms*4*sizeof(double)); // Allocate matrix of short-range - short-range terms. ShortTerms.resize(NumShortTerms*NumShortTerms*4); //@TODO: Remove next line. //memset(ShortTerms, 0, NumShortTerms*NumShortTerms*4*sizeof(double)); // Initialize to all 0. } } //@TODO: Check results of MpiError. #ifdef USE_MPI MpiError = MPI_Bcast(&Omega, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&NumShortTerms, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Ordering, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&IsTriplet, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Mu, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&ShPower, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Kappa, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Lambda1, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Lambda2, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Lambda3, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Alpha, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Beta, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&Gamma, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&r2Cusp, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&r3Cusp, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&sf, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&l, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&ShPower, 1, MPI_INT, 0, MPI_COMM_WORLD); MpiError = MPI_Bcast(&q, sizeof(q), MPI_UNSIGNED_CHAR, 0, MPI_COMM_WORLD); #endif ARow.resize(NumShortTerms*2+1); B.resize(NumShortTerms*2+1); //@TODO: Remove next line. //memset(ARow, 0, (NumShortTerms+1)*sizeof(double)); // Initialize to all 0. //memset(B, 0, (NumShortTerms+1)*sizeof(double)); // Initialize to all 0. vector <rPowers> PowerTableQi0, PowerTableQiGt0; vector <vector <rPowers> > PowerTableQi0Array(TotalNodes), PowerTableQiGt0Array(TotalNodes); vector <double> AResultsQi0, BResultsQi0, AResultsQiGt0, BResultsQiGt0; vector <double> AResultsQi0Final, BResultsQi0Final, AResultsQiGt0Final, BResultsQiGt0Final; int NumTerms, NumTermsQi0, NumTermsQiGt0; NumTerms = CalcPowerTableSize(Omega); if (Node == 0) { NumTermsQi0 = CalcPowerTableSizeQi0(Omega, Ordering, 0, NumShortTerms); NumTermsQiGt0 = CalcPowerTableSizeQiGt0(Omega, Ordering, 0, NumShortTerms); // The *2 comes from the 2 types of symmetry AResultsQi0.resize(NumTermsQi0*2, 0.0); AResultsQiGt0.resize(NumTermsQiGt0*2, 0.0); BResultsQi0.resize(NumTermsQi0*2, 0.0); BResultsQiGt0.resize(NumTermsQiGt0*2, 0.0); AResultsQi0Final.resize(NumTermsQi0*2, 0.0); AResultsQiGt0Final.resize(NumTermsQiGt0*2, 0.0); BResultsQi0Final.resize(NumTermsQi0*2, 0.0); BResultsQiGt0Final.resize(NumTermsQiGt0*2, 0.0); PowerTableQi0.resize(NumTermsQi0*2, rPowers(Alpha, Beta, Gamma)); PowerTableQiGt0.resize(NumTermsQiGt0*2, rPowers(Alpha, Beta, Gamma)); GenOmegaPowerTableQi0(Omega, l, Ordering, PowerTableQi0, 0, NumShortTerms-1); GenOmegaPowerTableQiGt0(Omega, l, Ordering, PowerTableQiGt0, 0, NumShortTerms-1); } #ifdef USE_MPI double NumTermsQi0Proc, NumTermsQiGt0Proc; vector <int> NumTermsQi0Array(TotalNodes), NumTermsQiGt0Array(TotalNodes); MpiError = MPI_Barrier(MPI_COMM_WORLD); // Tell all processes what terms they should be evaluating. if (Node == 0) { NumTermsQi0Proc = (double)NumTermsQi0 / (double)TotalNodes; //@TODO: Need the typecast? NumTermsQiGt0Proc = (double)NumTermsQiGt0 / (double)TotalNodes; //@TODO: Need the typecast? int Qi0Pos = (int)NumTermsQi0Proc, QiGt0Pos = (int)NumTermsQiGt0Proc; for (int i = 1; i < TotalNodes; i++) { //@TODO: Do we need to save these values in an array? NumTermsQi0Array[i] = int(NumTermsQi0Proc * (i+1)) - int(NumTermsQi0Proc * i); NumTermsQiGt0Array[i] = int(NumTermsQiGt0Proc * (i+1)) - int(NumTermsQiGt0Proc * i); MpiError = MPI_Send(&NumTermsQi0Array[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&NumTermsQiGt0Array[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD); cout << "Node " << i << ": " << NumTermsQi0Array[i] << " " << NumTermsQiGt0Array[i] << endl; PowerTableQi0Array[i].resize(NumTermsQi0Array[i]); PowerTableQiGt0Array[i].resize(NumTermsQiGt0Array[i]); for (int j = 0; j < NumTermsQi0Array[i]; j++, Qi0Pos++) { PowerTableQi0Array[i][j] = PowerTableQi0[Qi0Pos]; //cout << i << ": " << PowerTableQi0[Qi0Pos].ki + PowerTableQi0[Qi0Pos].li + PowerTableQi0[Qi0Pos].mi + PowerTableQi0[Qi0Pos].ni + PowerTableQi0[Qi0Pos].pi + PowerTableQi0[Qi0Pos].qi << " - " << // PowerTableQi0[Qi0Pos].ki << " " << PowerTableQi0[Qi0Pos].li << " " << PowerTableQi0[Qi0Pos].mi << " " << PowerTableQi0[Qi0Pos].ni << " " << PowerTableQi0[Qi0Pos].pi << " " << PowerTableQi0[Qi0Pos].qi << endl; } #ifdef VERBOSE cout << endl; #endif for (int j = 0; j < NumTermsQiGt0Array[i]; j++, QiGt0Pos++) { PowerTableQiGt0Array[i][j] = PowerTableQiGt0[QiGt0Pos]; #ifdef VERBOSE cout << i << ": " << PowerTableQiGt0[QiGt0Pos].ki + PowerTableQiGt0[QiGt0Pos].li + PowerTableQiGt0[QiGt0Pos].mi + PowerTableQiGt0[QiGt0Pos].ni + PowerTableQiGt0[QiGt0Pos].pi + PowerTableQiGt0[QiGt0Pos].qi << " - " << PowerTableQiGt0[QiGt0Pos].ki << " " << PowerTableQiGt0[QiGt0Pos].li << " " << PowerTableQiGt0[QiGt0Pos].mi << " " << PowerTableQiGt0[QiGt0Pos].ni << " " << PowerTableQiGt0[QiGt0Pos].pi << " " << PowerTableQiGt0[QiGt0Pos].qi << endl; #endif//VERBOSE } //@TODO: How safe is this? MpiError = MPI_Send(&PowerTableQi0Array[i][0], sizeof(rPowers)*NumTermsQi0Array[i], MPI_BYTE, i, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&PowerTableQiGt0Array[i][0], sizeof(rPowers)*NumTermsQiGt0Array[i], MPI_BYTE, i, 0, MPI_COMM_WORLD); } NumTermsQi0Array[0] = int(NumTermsQi0Proc); NumTermsQiGt0Array[0] = int(NumTermsQiGt0Proc); NumTermsQi0 = NumTermsQi0Array[0]; NumTermsQiGt0 = NumTermsQiGt0Array[0]; //AResultsQi0.resize(NumTermsQi0*2, 0.0); //AResultsQiGt0.resize(NumTermsQiGt0*2, 0.0); //BResultsQi0.resize(NumTermsQi0*2, 0.0); //BResultsQiGt0.resize(NumTermsQiGt0*2, 0.0); //@TODO: Temporary? int NumTermsQi0Temp = CalcPowerTableSizeQi0(Omega, Ordering, 0, NumShortTerms); for (int i = 0; i < NumTermsQi0; i++) { PowerTableQi0[NumTermsQi0+i].ki = PowerTableQi0[NumTermsQi0Temp+i].ki; PowerTableQi0[NumTermsQi0+i].li = PowerTableQi0[NumTermsQi0Temp+i].li; PowerTableQi0[NumTermsQi0+i].mi = PowerTableQi0[NumTermsQi0Temp+i].mi; PowerTableQi0[NumTermsQi0+i].ni = PowerTableQi0[NumTermsQi0Temp+i].ni; PowerTableQi0[NumTermsQi0+i].pi = PowerTableQi0[NumTermsQi0Temp+i].pi; PowerTableQi0[NumTermsQi0+i].qi = PowerTableQi0[NumTermsQi0Temp+i].qi; PowerTableQi0[NumTermsQi0+i].alpha = PowerTableQi0[NumTermsQi0Temp+i].alpha; PowerTableQi0[NumTermsQi0+i].beta = PowerTableQi0[NumTermsQi0Temp+i].beta; PowerTableQi0[NumTermsQi0+i].gamma = PowerTableQi0[NumTermsQi0Temp+i].gamma; } int NumTermsQiGt0Temp = CalcPowerTableSizeQiGt0(Omega, Ordering, 0, NumShortTerms); for (int i = 0; i < NumTermsQiGt0; i++) { PowerTableQiGt0[NumTermsQiGt0+i].ki = PowerTableQiGt0[NumTermsQiGt0Temp+i].ki; PowerTableQiGt0[NumTermsQiGt0+i].li = PowerTableQiGt0[NumTermsQiGt0Temp+i].li; PowerTableQiGt0[NumTermsQiGt0+i].mi = PowerTableQiGt0[NumTermsQiGt0Temp+i].mi; PowerTableQiGt0[NumTermsQiGt0+i].ni = PowerTableQiGt0[NumTermsQiGt0Temp+i].ni; PowerTableQiGt0[NumTermsQiGt0+i].pi = PowerTableQiGt0[NumTermsQiGt0Temp+i].pi; PowerTableQiGt0[NumTermsQiGt0+i].qi = PowerTableQiGt0[NumTermsQiGt0Temp+i].qi; PowerTableQiGt0[NumTermsQiGt0+i].alpha = PowerTableQiGt0[NumTermsQiGt0Temp+i].alpha; PowerTableQiGt0[NumTermsQiGt0+i].beta = PowerTableQiGt0[NumTermsQiGt0Temp+i].beta; PowerTableQiGt0[NumTermsQiGt0+i].gamma = PowerTableQiGt0[NumTermsQiGt0Temp+i].gamma; } cout << "Node " << 0 << ": " << NumTermsQi0Array[0] << " " << NumTermsQiGt0Array[0] << endl; for (int i = 0; i < NumTermsQiGt0; i++) { //cout << 0 << ": " << PowerTableQi0[i].ki + PowerTableQi0[i].li + PowerTableQi0[i].mi + PowerTableQi0[i].ni + PowerTableQi0[i].pi + PowerTableQi0[i].qi << " - " << // PowerTableQi0[i].ki << " " << PowerTableQi0[i].li << " " << PowerTableQi0[i].mi << " " << PowerTableQi0[i].ni << " " << PowerTableQi0[i].pi << " " << PowerTableQi0[i].qi << endl; #ifdef VERBOSE cout << 0 << ": " << PowerTableQiGt0[i].ki + PowerTableQiGt0[i].li + PowerTableQiGt0[i].mi + PowerTableQiGt0[i].ni + PowerTableQiGt0[i].pi + PowerTableQiGt0[i].qi << " - " << PowerTableQiGt0[i].ki << " " << PowerTableQiGt0[i].li << " " << PowerTableQiGt0[i].mi << " " << PowerTableQiGt0[i].ni << " " << PowerTableQiGt0[i].pi << " " << PowerTableQiGt0[i].qi << endl; #endif//VERBOSE } cout << endl; } else { MpiError = MPI_Recv(&NumTermsQi0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&NumTermsQiGt0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); PowerTableQi0.resize(NumTermsQi0*2); PowerTableQiGt0.resize(NumTermsQiGt0*2); AResultsQi0.resize(NumTermsQi0*2); AResultsQiGt0.resize(NumTermsQiGt0*2); BResultsQi0.resize(NumTermsQi0*2); BResultsQiGt0.resize(NumTermsQiGt0*2); MpiError = MPI_Recv(&PowerTableQi0[0], sizeof(rPowers)*NumTermsQi0, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&PowerTableQiGt0[0], sizeof(rPowers)*NumTermsQiGt0, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); // Create phi2 terms for (int i = 0; i < NumTermsQi0; i++) { PowerTableQi0[NumTermsQi0+i].ki = PowerTableQi0[i].ki - l; PowerTableQi0[NumTermsQi0+i].li = PowerTableQi0[i].li + l; PowerTableQi0[NumTermsQi0+i].mi = PowerTableQi0[i].mi; PowerTableQi0[NumTermsQi0+i].ni = PowerTableQi0[i].ni; PowerTableQi0[NumTermsQi0+i].pi = PowerTableQi0[i].pi; PowerTableQi0[NumTermsQi0+i].qi = PowerTableQi0[i].qi; PowerTableQi0[NumTermsQi0+i].alpha = PowerTableQi0[i].alpha; PowerTableQi0[NumTermsQi0+i].beta = PowerTableQi0[i].beta; PowerTableQi0[NumTermsQi0+i].gamma = PowerTableQi0[i].gamma; } for (int i = 0; i < NumTermsQiGt0; i++) { PowerTableQiGt0[NumTermsQiGt0+i].ki = PowerTableQiGt0[i].ki - l; PowerTableQiGt0[NumTermsQiGt0+i].li = PowerTableQiGt0[i].li + l; PowerTableQiGt0[NumTermsQiGt0+i].mi = PowerTableQiGt0[i].mi; PowerTableQiGt0[NumTermsQiGt0+i].ni = PowerTableQiGt0[i].ni; PowerTableQiGt0[NumTermsQiGt0+i].pi = PowerTableQiGt0[i].pi; PowerTableQiGt0[NumTermsQiGt0+i].qi = PowerTableQiGt0[i].qi; PowerTableQiGt0[NumTermsQiGt0+i].alpha = PowerTableQiGt0[i].alpha; PowerTableQiGt0[NumTermsQiGt0+i].beta = PowerTableQiGt0[i].beta; PowerTableQiGt0[NumTermsQiGt0+i].gamma = PowerTableQiGt0[i].gamma; } } //cout << "Node " << Node << ": " << NodeStart << " " << NodeEnd << endl; MpiError = MPI_Barrier(MPI_COMM_WORLD); #endif //#ifdef USE_MPI // MpiError = MPI_Barrier(MPI_COMM_WORLD); // // // Tell all processes what terms they should be evaluating. // if (Node == 0) { // NumTermsProc = (double)(NumShortTerms+1) / (double)TotalNodes; //@TODO: Need the typecast? // for (int i = 1; i < TotalNodes; i++) { // NodeStart = NumTermsProc * i; // NodeEnd = NumTermsProc * (i+1) - 1; // MpiError = MPI_Send(&NodeStart, 1, MPI_INT, i, 0, MPI_COMM_WORLD); // MpiError = MPI_Send(&NodeEnd, 1, MPI_INT, i, 0, MPI_COMM_WORLD); // } // // This is the set of values for the root node to take. // NodeStart = 0; // NodeEnd = NumTermsProc * (Node+1) - 1; // } // else { // MpiError = MPI_Recv(&NodeStart, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); // MpiError = MPI_Recv(&NodeEnd, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &MpiStatus); // } // MpiError = MPI_Barrier(MPI_COMM_WORLD); // //@TODO: To clean this up some, we could just output this in the loop above for node 0. // cout << "Node " << Node << ": " << NodeStart << " " << NodeEnd << endl; //#else // NumTermsProc = (double)(NumShortTerms+1); // NodeStart = 0; // NodeEnd = NumTermsProc * (Node+1) - 1; //#endif//USE_MPI //TimeStart = time(NULL); //CalcARowAndBVector(Node, NumTerms, Omega, PowerTable, AResults, ARow, BResults, B, SLS, q, r2Cusp, r3Cusp, Alpha, Beta, Gamma, Kappa, Mu, sf); CalcARowAndBVector(Node, NumTermsQi0, NumTermsQiGt0, Omega, PowerTableQi0, PowerTableQiGt0, AResultsQi0, AResultsQiGt0, ARow, BResultsQi0, BResultsQiGt0, B, SLS, SLC, l, q, r2Cusp, r3Cusp, Alpha, Beta, Gamma, Kappa, Mu, Lambda1, Lambda2, Lambda3, ShPower, sf); //TimeEnd = time(NULL); //cout << "Time elapsed: " << difftime(TimeEnd, TimeStart) << endl; //OutFile << "Time elapsed: " << difftime(TimeEnd, TimeStart) << endl; #ifdef USE_MPI if (Node == 0) { //@TODO: Temporary int NumTermsQi0Temp = CalcPowerTableSizeQi0(Omega, Ordering, 0, NumShortTerms); int NumTermsQiGt0Temp = CalcPowerTableSizeQiGt0(Omega, Ordering, 0, NumShortTerms); for (int i = 0; i < NumTermsQi0; i++) { AResultsQi0Final[i] = AResultsQi0[i]; AResultsQi0Final[NumTermsQi0Temp+i] = AResultsQi0[NumTermsQi0+i]; BResultsQi0Final[i] = BResultsQi0[i]; BResultsQi0Final[NumTermsQi0Temp+i] = BResultsQi0[NumTermsQi0+i]; } for (int i = 0; i < NumTermsQiGt0; i++) { AResultsQiGt0Final[i] = AResultsQiGt0[i]; AResultsQiGt0Final[NumTermsQiGt0Temp+i] = AResultsQiGt0[NumTermsQiGt0+i]; BResultsQiGt0Final[i] = BResultsQiGt0[i]; BResultsQiGt0Final[NumTermsQiGt0Temp+i] = BResultsQiGt0[NumTermsQiGt0+i]; } cout << " Node " << Node << " (" << ProcessorName << ") finished computation at " << ShowTime() << endl; // ResultsQi0 and ResultsQiGt0 already have process 0's results. // Gather the results from the rest of the processes. int nQi0 = NumTermsQi0Array[0], nQiGt0 = NumTermsQiGt0Array[0]; // IMPORTANT NOTE! i++ must be at the end, or else it increments before nQi0 and nQiGt0. for (int i = 1; i < TotalNodes; nQi0 += NumTermsQi0Array[i], nQiGt0 += NumTermsQiGt0Array[i], i++) { // Phi1 terms MpiError = MPI_Recv(&AResultsQi0Final[nQi0], NumTermsQi0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&BResultsQi0Final[nQi0], NumTermsQi0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&AResultsQiGt0Final[nQiGt0], NumTermsQiGt0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&BResultsQiGt0Final[nQiGt0], NumTermsQiGt0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); // Phi2 terms MpiError = MPI_Recv(&AResultsQi0Final[NumTermsQi0Temp+nQi0], NumTermsQi0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&BResultsQi0Final[NumTermsQi0Temp+nQi0], NumTermsQi0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&AResultsQiGt0Final[NumTermsQiGt0Temp+nQiGt0], NumTermsQiGt0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); MpiError = MPI_Recv(&BResultsQiGt0Final[NumTermsQiGt0Temp+nQiGt0], NumTermsQiGt0Array[i], MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &MpiStatus); } } else { cout << " Node " << Node << " (" << ProcessorName << ") finished computation at " << ShowTime() << endl; // Phi1 terms MpiError = MPI_Send(&AResultsQi0[0], NumTermsQi0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&BResultsQi0[0], NumTermsQi0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&AResultsQiGt0[0], NumTermsQiGt0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&BResultsQiGt0[0], NumTermsQiGt0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); // Phi2 terms MpiError = MPI_Send(&AResultsQi0[NumTermsQi0], NumTermsQi0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&BResultsQi0[NumTermsQi0], NumTermsQi0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&AResultsQiGt0[NumTermsQiGt0], NumTermsQiGt0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MpiError = MPI_Send(&BResultsQiGt0[NumTermsQiGt0], NumTermsQiGt0, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); } #else AResultsQi0Final = AResultsQi0; BResultsQi0Final = BResultsQi0; AResultsQiGt0Final = AResultsQiGt0; BResultsQiGt0Final = BResultsQiGt0; #endif if (Node == 0) { //@TODO: Put directly into A and B vector <double> AResults(NumShortTerms*2), BResults(NumShortTerms*2); CombineResults(Omega, Ordering, AResultsQi0Final, AResultsQiGt0Final, AResults, 0, NumShortTerms); CombineResults(Omega, Ordering, BResultsQi0Final, BResultsQiGt0Final, BResults, 0, NumShortTerms); for (int i = 0; i < NumShortTerms*2; i++) { ARow[i+1] = AResults[i]; } for (int i = 0; i < NumShortTerms*2; i++) { B[i+1] = BResults[i]; } int Multiplier; if (l == 0) Multiplier = 1; // S-wave only has a single symmetry else Multiplier = 2; cout << endl << endl << "A matrix row" << endl; for (int i = 0; i < NumShortTerms*Multiplier+1; i++) { cout << i << " " << ARow[i] << endl; } cout << endl << "B vector" << endl; for (int i = 0; i < NumShortTerms*Multiplier+1; i++) { cout << i << " " << B[i] << endl; } cout << endl; // Construct the rest of the matrix A with the short-range - short-range terms. for (int i = 0; i < NumShortTerms*2; i++) { for (int j = 0; j < NumShortTerms*2; j++) { ShortTerms[i*NumShortTerms*2+j] = PhiHPhi[i][j] - 0.5*Kappa*Kappa * PhiPhi[i][j] + 1.5*PhiPhi[i][j]; } } } if (Node == 0) { //@TODO: Move further up. // Output results to file if (Ordering == 0) OutFile << "Using Denton's ordering" << endl; else OutFile << "Using Peter Van Reeth's ordering" << endl; OutFile << "Omega: " << Omega << endl; OutFile << "Number of terms: " << NumShortTerms << endl; OutFile << "Alpha: " << Alpha << " Beta: " << Beta << " Gamma: " << Gamma << endl; OutFile << "Mu: " << Mu << endl; OutFile << "Shielding power: " << ShPower << endl; OutFile << "Kappa: " << Kappa << endl; OutFile << "Lambda: " << Lambda1 << " " << Lambda2 << " " << Lambda3 << " " << endl; OutFile << endl << "Number of quadrature points" << endl; OutFile << "Long-long: " << q.LongLong_r1 << " " << q.LongLong_r2Leg << " " << q.LongLong_r2Lag << " " << q.LongLong_r3Leg << " " << q.LongLong_r3Lag << " " << q.LongLong_r12 << " " << q.LongLong_r13 << " " << q.LongLong_phi23 << endl; OutFile << "Long-long 2/r23 term: " << q.LongLongr23_r1 << " " << q.LongLongr23_r2Leg << " " << q.LongLongr23_r2Lag << " " << q.LongLongr23_r3Leg << " " << q.LongLongr23_r3Lag << " " << q.LongLongr23_phi12 << " " << q.LongLongr23_r13 << " " << q.LongLongr23_r23 << endl; OutFile << "Short-long with qi = 0: " << q.ShortLong_r1 << " " << q.ShortLong_r2Leg << " " << q.ShortLong_r2Lag << " " << q.ShortLong_r3Leg << " " << q.ShortLong_r3Lag << " " << q.ShortLong_r12 << " " << q.ShortLong_r13 << " " << q.ShortLong_phi23 << endl; OutFile << "Short-long 2/r23 with qi = 0: " << q.ShortLongr23_r1 << " " << q.ShortLongr23_r2Leg << " " << q.ShortLongr23_r2Lag << " " << q.ShortLongr23_r3Leg << " " << q.ShortLongr23_r3Lag << " " << q.ShortLongr23_r12 << " " << q.ShortLongr23_phi13 << " " << q.ShortLongr23_r23 << endl; OutFile << "Short-long (full) with qi > 0: " << q.ShortLongQiGt0_r1 << " " << q.ShortLongQiGt0_r2Leg << " " << q.ShortLongQiGt0_r2Lag << " " << q.ShortLongQiGt0_r3Leg << " " << q.ShortLongQiGt0_r3Lag << " " << q.ShortLongQiGt0_r12 << " " << q.ShortLongQiGt0_r13 << " " << q.ShortLongQiGt0_phi23 << endl; OutFile << endl; OutFile << "Cusp parameters" << endl; OutFile << r2Cusp << " " << r3Cusp << endl; OutFile << endl; int Multiplier; if (l == 0) Multiplier = 1; // S-wave only has a single symmetry else Multiplier = 2; OutFile << "A matrix row" << endl; for (int i = 0; i < NumShortTerms*Multiplier+1; i++) { OutFile << i << " " << ARow[i] << endl; } OutFile << endl << "B vector" << endl; for (int i = 0; i < NumShortTerms*Multiplier+1; i++) { OutFile << i << " " << B[i] << endl; } //cout << "SLS Term: " << SLS << endl; //cout << "SLC Term: " << SLC << endl; //cout << "SLC - CLS: " << SLC - B[0] << endl << endl; cout << endl << "SLS Term" << endl << SLS << endl; cout << endl << "SLC Term" << endl << SLC << endl; cout << "SLC - CLS: " << SLC - B[0] << endl << endl; OutFile << endl << "SLS Term" << endl << SLS << endl; OutFile << endl << "SLC Term" << endl << SLC << endl; OutFile << "SLC - CLS: " << SLC - B[0] << endl << endl; double KohnPhase, InvKohnPhase, ComplexKohnPhase; KohnPhase = Kohn(NumShortTerms, ARow, B, ShortTerms, SLS); InvKohnPhase = InverseKohn(NumShortTerms, ARow, B, ShortTerms, SLS); ComplexKohnPhase = ComplexKohnT(NumShortTerms, ARow, B, ShortTerms, SLS); cout << "Kohn phase shift: " << KohnPhase << endl; cout << "Inverse Kohn phase shift: " << InvKohnPhase << endl; cout << "Complex Kohn phase shift: " << ComplexKohnPhase << endl << endl; OutFile << "Kohn phase shift: " << KohnPhase << endl; OutFile << "Inverse Kohn phase shift: " << InvKohnPhase << endl; OutFile << "Complex (T-matrix) Kohn phase shift: " << ComplexKohnPhase << endl << endl; double CrossSection = 4.0 * PI * sin(KohnPhase) * sin(KohnPhase); // (2l+1) = 1 with l = 0 cout << "Kohn partial wave cross section: " << CrossSection << endl; OutFile << "Kohn Partial wave cross section: " << CrossSection << endl; CrossSection = 4.0 * PI * sin(InvKohnPhase) * sin(InvKohnPhase); cout << "Inverse Kohn partial wave cross section: " << CrossSection << endl; OutFile << "Inverse Kohn partial wave cross section: " << CrossSection << endl; CrossSection = 4.0 * PI * sin(ComplexKohnPhase) * sin(ComplexKohnPhase); cout << "Complex (T-matrix) Kohn partial wave cross section: " << CrossSection << endl << endl; OutFile << "Complex (T-matrix) Kohn partial wave cross section: " << CrossSection << endl << endl; } // Cleanup if (Node == 0) { TimeEnd = time(NULL); cout << "Time elapsed: " << difftime(TimeEnd, TimeStart) << endl; OutFile << "Time elapsed: " << difftime(TimeEnd, TimeStart) << endl; ParameterFile.close(); OutFile.close(); FileShortRange.close(); if (NumShortTerms > 0) { delete [] PhiHPhi[0]; delete [] PhiHPhi; delete [] PhiPhi[0]; delete [] PhiPhi; } } cout << endl; fflush(stdout); #ifdef USE_MPI //MpiError = MPI_File_close(&MpiLog); MpiError = MPI_Finalize(); #endif return 0; }
void CSnapStorageDlg::OnRadio2() { // TODO: Add your control notification handler code here ShowTime(FALSE); }
int FileViewer::ProcessKey(int Key) { if (RedrawTitle && (((unsigned int)Key & 0x00ffffff) < KEY_END_FKEY || IsInternalKeyReal((unsigned int)Key & 0x00ffffff))) ShowConsoleTitle(); if (Key!=KEY_F3 && Key!=KEY_IDLE) F3KeyOnly=false; switch (Key) { #if 0 /* $ 30.05.2003 SVS Фича :-) Shift-F4 в редакторе/вьювере позволяет открывать другой редактор/вьювер Пока закомментим */ case KEY_SHIFTF4: { if (!Opt.OnlyEditorViewerUsed) CtrlObject->Cp()->ActivePanel->ProcessKey(Key); return TRUE; } #endif /* $ 22.07.2000 tran + выход по ctrl-f10 с установкой курсора на файл */ case KEY_CTRLF10: case KEY_RCTRLF10: { if (View.isTemporary()) { return TRUE; } SaveScreen Sc; string strFileName; View.GetFileName(strFileName); CtrlObject->Cp()->GoToFile(strFileName); RedrawTitle = TRUE; return (TRUE); } // $ 15.07.2000 tran + CtrlB switch KeyBar case KEY_CTRLB: case KEY_RCTRLB: Opt.ViOpt.ShowKeyBar=!Opt.ViOpt.ShowKeyBar; if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); else ViewKeyBar.Hide0(); // 0 mean - Don't purge saved screen Show(); KeyBarVisible = Opt.ViOpt.ShowKeyBar; return (TRUE); case KEY_CTRLSHIFTB: case KEY_RCTRLSHIFTB: { Opt.ViOpt.ShowTitleBar=!Opt.ViOpt.ShowTitleBar; TitleBarVisible = Opt.ViOpt.ShowTitleBar; Show(); return (TRUE); } case KEY_CTRLO: case KEY_RCTRLO: if (!Opt.OnlyEditorViewerUsed) { if (FrameManager->ShowBackground()) { SetCursorType(FALSE,0); WaitKey(); FrameManager->RefreshFrame(); } } return TRUE; case KEY_F3: case KEY_NUMPAD5: case KEY_SHIFTNUMPAD5: if (F3KeyOnly) return TRUE; case KEY_ESC: case KEY_F10: FrameManager->DeleteFrame(); return TRUE; case KEY_F6: if (!DisableEdit) { UINT cp=View.VM.CodePage; string strViewFileName; View.GetFileName(strViewFileName); File Edit; while(!Edit.Open(strViewFileName, FILE_READ_DATA, FILE_SHARE_READ|(Opt.EdOpt.EditOpenedForWrite?FILE_SHARE_WRITE:0), nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN)) { if(!OperationFailed(strViewFileName, MEditTitle, MSG(MEditCannotOpen), false)) continue; else return TRUE; } Edit.Close(); __int64 FilePos=View.GetFilePos(); DWORD flags = (GetCanLoseFocus()?FFILEEDIT_ENABLEF6:0)|(SaveToSaveAs?FFILEEDIT_SAVETOSAVEAS:0)|(DisableHistory?FFILEEDIT_DISABLEHISTORY:0); FileEditor *ShellEditor = new FileEditor( strViewFileName, cp, flags, -2, static_cast<int>(FilePos), // TODO: Editor StartChar should be __int64 str_title.IsEmpty() ? nullptr: &str_title, -1,-1, -1, -1, delete_on_close ); ShellEditor->SetEnableF6(TRUE); /* $ 07.05.2001 DJ сохраняем NamesList */ ShellEditor->SetNamesList(View.GetNamesList()); // Если переключаемся в редактор, то удалять файл уже не нужно SetTempViewName(L""); SetExitCode(0); FrameManager->DeleteFrame(this); // Insert уже есть внутри конструктора ShowTime(2); } return TRUE; case KEY_ALTSHIFTF9: case KEY_RALTSHIFTF9: // Работа с локальной копией ViewerOptions ViewerConfig(View.ViOpt, true); if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); View.Show(); return TRUE; case KEY_ALTF11: case KEY_RALTF11: if (GetCanLoseFocus()) CtrlObject->CmdLine->ShowViewEditHistory(); return TRUE; default: // Этот кусок - на будущее (по аналогии с редактором :-) // if (CtrlObject->Macro.IsExecuting() || !View.ProcessViewerInput(&ReadRec)) { /* $ 22.03.2001 SVS Это помогло от залипания :-) */ if (!CtrlObject->Macro.IsExecuting()) if (Opt.ViOpt.ShowKeyBar) ViewKeyBar.Show(); if (!ViewKeyBar.ProcessKey(Key)) return(View.ProcessKey(Key)); } return TRUE; } }
void FetchAllThumbnails( HWND hwnd) { BOOL fRtn = FALSE; ULONG ctr; HWND hCnr; PFNCTHREAD pfn; CAMRecPtr pcr; CAMRecPtr * ppcr; CAMThumbPtr pct = 0; char * pErr = 0; CNRINFO ci; do { hCnr = WinWindowFromID( hwnd, FID_CLIENT); if (!WinSendMsg( hCnr, CM_QUERYCNRINFO, (MP)&ci, (MP)sizeof(CNRINFO))) { pErr = "CM_QUERYCNRINFO"; break; } ctr = ci.cRecords * sizeof(CAMRecPtr) + sizeof(CAMThumb); pct = (CAMThumbPtr)malloc( ctr); if (!pct) { pErr = "malloc"; break; } memset( pct, 0, ctr); // fill in useful info pct->hReply = hwnd; pct->thisCam = (CAMPtr)GetCamPtr(); pct->fRotate = (QueryRotateOpts() & CAM_ROTATEONLOAD); ctr = 0; ppcr = pct->pcr; pcr = (CAMRecPtr)WinSendMsg( hCnr, CM_QUERYRECORD, (MP)0, MPFROM2SHORT( CMA_FIRST, CMA_ITEMORDER)); while (pcr && pcr != (CAMRecPtr)-1 && ctr < ci.cRecords) { if (!pcr->bmp && pcr->tnsize) { *ppcr++ = pcr; ctr++; } pcr = (CAMRecPtr)WinSendMsg( hCnr, CM_QUERYRECORD, (MP)pcr, MPFROM2SHORT( CMA_NEXT, CMA_ITEMORDER)); } if (!ctr) break; if (pcr) { if (pcr == (CAMRecPtr)-1) pErr = "CM_QUERYRECORD"; else pErr = "record overflow"; break; } ShowTime( "FetchThumb", FALSE); // start the thread if (((CAMPtr)GetCamPtr())->camType == CAM_TYPE_MSD) pfn = MsdThumbnailThread; else pfn = PtpThumbnailThread; if (_beginthread( pfn, 0, 0xF000, pct) == -1) { pErr = "FetchAllThumbnails - _beginthread failed"; break; } fRtn = TRUE; } while (0); if (!fRtn) { if (pErr) printf( "FetchAllThumbnails - %s failed\n", pErr); if (pct) free( pct); UpdateThumbWnd( hwnd); } return; }
/* ______________________________________________________________________________________________ Main ______________________________________________________________________________________________ */ int main(int argc, char *argv[]) { // --- Init Cluster variable --------------------------------------------------------- // carmen 0 => local execution i.e. show time on screen // carmen 1 => cluster execution i.e. refresh Performance.dat (default) #if defined PARMPI // --- MPI Runtime system initialization // size - total number of processors // rnak - current CPU MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); #else size=1; rank=0; #endif if (argc == 2) Cluster = atoi(argv[1]); // --- Print messages on screen- ----------------------------------------------------- cout << "carmen: begin execution.\n\n"; printf("Carmen %4.2f \n",CarmenVersion); cout << "Copyright (C) 2000-2005 by Olivier Roussel.\n"; cout << "All rights reserved.\n\n"; #if defined PARMPI //Synchronize all parallel branches MPI_Barrier(MPI_COMM_WORLD); #endif CPUTime.start(); // --- Create first node of the tree structure --------------------------------------- Node *Mesh=0; FineMesh *FMesh=0; // --- Init global values (See Parameters.h and Parameters.cpp) ---------------------------- cout << "carmen: init computation ...\n"; InitParameters(); // --- Debug output information for parallel execution ------------------------------------- #if defined PARMPI if (Multiresolution) { printf("\nParallel Multiresolution solver not implemented yet!\n"); exit(0); } printf("My Rank=%d\n",rank); // --- Each CPU print his coordinates in the virtual processor cart ------------------------ printf("Cart_i = %d; Cart_j = %d; Cart_k = %d;\n",coords[0],coords[1],coords[2]); // --- Each CPU print his computation domain printf("Xmin = %lf; XMax = %lf;\n",XMin[1],XMax[1]); printf("Ymin = %lf; YMax = %lf;\n",XMin[2],XMax[2]); printf("Zmin = %lf; ZMax = %lf;\n",XMin[3],XMax[3]); // --- And the local scale number ---------------------------------------------------------- printf("ScaleNb = %d\n",ScaleNb); #endif // --- Allocate ---------------------------------------------------------------------------- if (Multiresolution) Mesh = new Node; else FMesh = new FineMesh; // --- Init tree structure ----------------------------------------------------------------- if (Multiresolution) { InitTree(Mesh); RefreshTree(Mesh); } // --- Compute initial integral values and init time step ---------------------------------- if (Multiresolution) Mesh->computeIntegral(); else FMesh->computeIntegral(); // -- Write integral values -- // -- Compute initial time step -- InitTimeStep(); if (rank==0) PrintIntegral("Integral.dat"); // --- Save initial values into files ------------------------------------------------------ if (PrintEvery == 0) { if (Multiresolution) View(Mesh, "Tree_0.dat", "Mesh_0.dat", "Average_0.dat"); else View(FMesh,"Average_0.dat"); } // --- When PrintEvery != 0, save initial values into specific name format --- if (PrintEvery != 0) { if (Multiresolution) ViewEvery(Mesh, 0); else ViewEvery(FMesh, 0); } // --- Parallel execution only -------------------------------------------- // --- Save to disk DX header for ouput files ----------------------------- // --- This file is needed for the external postprocessing (merging files from the different processors) #if defined PARMPI real tempXMin[4]; real tempXMax[4]; // --- Save original task parameters for the parallel execution int tempScaleNb=ScaleNb; // --- Simulate sequantial running ScaleNb=AllTaskScaleNb; for (int i=0;i<4;i++) { tempXMin[i]=XMin[i]; tempXMax[i]=XMax[i]; // --- Simulate sequantial running XMin[i]=AllXMin[i]; XMax[i]=AllXMax[i]; } // --- Write header with parameters, as we have run sequantial code if (rank==0) FMesh->writeHeader("header.txt"); // Restore variables for (int i=0;i<4;i++) { XMin[i]=tempXMin[i]; XMax[i]=tempXMax[i]; } ScaleNb=tempScaleNb; #endif // --- Done --- cout << "carmen: done.\n"; // --- Write solver type --- if (Multiresolution) cout << "carmen: multiresolution (MR) solver.\n"; else cout << "carmen: finite volume (FV) solver.\n"; // --- Write number of iterations --- if (IterationNb == 1) cout << "carmen: compute 1 iteration ...\n"; else cout << "carmen: compute " << IterationNb << " iterations ...\n"; printf("\n\n\n"); // --- Begin time iteration ---------------------------------------------------------------- for (IterationNo = 1; IterationNo <= IterationNb; IterationNo++) { // --- Time evolution procedure --- if (Multiresolution) TimeEvolution(Mesh); else TimeEvolution(FMesh); // --- Remesh --- if (Multiresolution) Remesh(Mesh); // --- Check CPU Time --- CPUTime.check(); // --- Write information every (Refresh) iteration --- if ((IterationNo-1)%Refresh == 0) { // - Write integral values - if (rank==0) PrintIntegral("Integral.dat"); if (Cluster == 0) ShowTime(CPUTime); // Show time on screen //else if (rank==0) Performance("carmen.prf"); // Refresh file "carmen.prf" } // --- Backup data every (10*Refresh) iteration --- if ((IterationNo-1)%(10*Refresh) == 0 && UseBackup) { if (Multiresolution) Backup(Mesh); else Backup(FMesh); } // --- Print solution if IterationNo = PrintIt1 to PrintIt6 --- if (Multiresolution) ViewIteration(Mesh); else ViewIteration(FMesh); // --- Print solution if IterationNo is a multiple of PrintEvery --- if (PrintEvery != 0) { if (IterationNo%PrintEvery == 0) { if (Multiresolution) ViewEvery(Mesh, IterationNo); else ViewEvery(FMesh, IterationNo); } } // --- End time iteration ------------------------------------------------------------------ } // --- Backup final data ------------------------------------------------------------------ IterationNo--; if (UseBackup) { if (Multiresolution) Backup(Mesh); else Backup(FMesh); } // --- Write integral values --------------------------------------------------------------- if (rank==0) PrintIntegral("Integral.dat"); IterationNo++; // --- Save values into file --------------------------------------------------------------- if (Multiresolution) View(Mesh, "Tree.dat", "Mesh.dat", "Average.dat"); else View(FMesh, "Average.dat"); cout << "\ncarmen: done.\n"; // --- Analyse performance and save it into file ------------------------------------------- if (rank==0) Performance("carmen.prf"); // --- End --------------------------------------------------------------------------------- if (Multiresolution) delete Mesh; else delete FMesh; #if defined PARMPI //free memory for the MPI runtime variables delete[] disp; delete[] blocklen; int sz; MPI_Buffer_detach(&MPIbuffer,&sz); // for (int i = 0; i < 4*Dimension; i++) MPI_Request_free(&req[i]); MPI_Finalize(); #endif cout <<"carmen: end execution.\n"; return EXIT_SUCCESS; }
U32 tcStartEvidence(void) { S32 MyEvidence[4][7], guarded, radio; U32 totalEvidence[7], i, j, shownEvidence[4], Recognition[4], caught = 0; ubyte guyReady, guyNr, evidenceNr, guyCount, shown = 0; char line[TXT_KEY_LENGTH]; Person p[4]; Evidence evidence = dbGetObject(Evidence_Evidence_1); /* just for presentation */ struct ObjectNode *n; LIST *guys, *spuren; if ((!(Search.EscapeBits & FAHN_ALARM)) && (!(Search.EscapeBits & FAHN_QUIET_ALARM))) Say(BUSINESS_TXT, 0, ((Person) dbGetObject(Person_John_Gludo))->PictID, "A_BURGLARY_SIR"); Say(BUSINESS_TXT, 0, ((Person) dbGetObject(Person_Miles_Chickenwing))->PictID, "START_EVIDENCE"); joined_byAll(Person_Matt_Stuvysunt, OLF_PRIVATE_LIST, Object_Person); guys = ObjectListPrivate; dbSortObjectList(&guys, dbStdCompareObjects); guyCount = (ubyte) GetNrOfNodes(guys); spuren = txtGoKey(BUSINESS_TXT, "SPUREN"); p[0] = p[1] = p[2] = p[3] = NULL; guarded = ChangeAbs(((Building) dbGetObject(Search.BuildingId))->GRate, ((Building) dbGetObject(Search.BuildingId))->Strike / 7, 0, 255); radio = (S32) ((Building) dbGetObject(Search.BuildingId))->RadioGuarding; for (n = (struct ObjectNode *) LIST_HEAD(guys), i = 0; NODE_SUCC(n); n = (struct ObjectNode *) NODE_SUCC(n), i++) { S32 div = 380; p[i] = OL_DATA(n); /* alle folgenden Werte sind zwischen 0 und 255 */ /* statt durch 765 zu dividieren wurde urspr�nglich durch 255 dividiert -> */ /* viel zu gro�e Werte */ if (Search.SpotTouchCount[i]) div = 1; MyEvidence[i][0] = (((tcGetTrail(p[i], 0) * (S32) Search.WalkTime[i] * (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary + 1))) / div; MyEvidence[i][1] = (((tcGetTrail(p[i], 1) * (S32) Search.WaitTime[i] * (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary + 1))) / div; MyEvidence[i][2] = (((tcGetTrail(p[i], 2) * (S32) Search.WorkTime[i] * (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary + 1))) / div; MyEvidence[i][3] = (((tcGetTrail(p[i], 3) * (S32) Search.KillTime[i] * (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary + 1))); MyEvidence[i][4] = ChangeAbs(0, (S32) Search.CallCount * (S32) radio / 5, 0, 255); MyEvidence[i][5] = (p[i]->KnownToPolice * (max(1, guarded))) / (div * 3); MyEvidence[i][6] = ChangeAbs(0, (S32) CalcRandomNr(200, 255) * (S32) Search.SpotTouchCount[i], 0, 255); for (j = 0; j < 7; j++) /* jeden Betrag != 0 AUFRUNDEN auf 1% ! */ if (MyEvidence[i][j]) MyEvidence[i][j] = max(MyEvidence[i][j], 5); if (has(Person_Matt_Stuvysunt, Tool_Maske)) MyEvidence[i][6] = (MyEvidence[i][6] * 2) / 3; /* im Fluchtfall viele Gehspuren! */ if (Search.EscapeBits & FAHN_ESCAPE) MyEvidence[i][0] = CalcValue(MyEvidence[i][0], CalcRandomNr(80, 120), 255, 255, 50); totalEvidence[i] = MyEvidence[i][0] + MyEvidence[i][1] + MyEvidence[i][2] + MyEvidence[i][3] + MyEvidence[i][4] + MyEvidence[i][5] + MyEvidence[i][6]; shownEvidence[i] = Recognition[i] = 0; tcPersonLearns(OL_NR(n)); } prSetBarPrefs(m_gc, 300, 12, 1, 3, 0); guyReady = 0; txtGetFirstLine(BUSINESS_TXT, "FAHNDUNG", line); while (guyReady != ((1 << guyCount) - 1)) { if (shown) { ShowTime(0); inpDelay(35L); AddVTime(CalcRandomNr(1, 11)); shown = 0; } guyNr = CalcRandomNr(0, guyCount); /* wer ist den noch nicht fertig? */ while ((1 << guyNr) & guyReady) guyNr = (guyNr + 1) % guyCount; /* bei folgendem CalcRandomNr darf nicht 4 - guyCount stehe, sonst * Division durch 0! */ /* zuf�llig eine Spurenart ausw�hlen */ evidenceNr = CalcRandomNr(0, 7); /* wenn diese Spurenart schon angzeigt wurde, eine freie * Spur suchen */ j = 0; while (((1 << evidenceNr) & shownEvidence[guyNr]) && (j++ < 7)) evidenceNr = (evidenceNr + 1) % 7; if (j < 8) { /* 8 stimmt! -> ober wird anschlie�end noch erh�ht */ shownEvidence[guyNr] |= (1 << evidenceNr); if (MyEvidence[guyNr][evidenceNr] > 0) { ShowMenuBackground(); PrintStatus(NODE_NAME(GetNthNode(spuren, evidenceNr))); Recognition[guyNr] += MyEvidence[guyNr][evidenceNr]; evidence->Recognition = Recognition[guyNr] / 3; /* change also: totalEvidence /= 3.... */ evidence->pers = (U32) OL_NR(GetNthNode(guys, (U32) guyNr)); /* f�r alle "Evidences" - stimmt so, da f�r alle */ /* Personen die selbe Evidence Struct benutzt wird -> */ /* bestimmte Werte sind von vorher gesetzt und m�ssen gel�scht */ /* werden */ evidence->WalkTrail = 0; evidence->WaitTrail = 0; evidence->WorkTrail = 0; evidence->KillTrail = 0; evidence->CallTrail = 0; evidence->PaperTrail = 0; evidence->FotoTrail = 0; if (shownEvidence[guyNr] & 1) evidence->WalkTrail = MyEvidence[guyNr][0]; if (shownEvidence[guyNr] & 2) evidence->WaitTrail = MyEvidence[guyNr][1]; if (shownEvidence[guyNr] & 4) evidence->WorkTrail = MyEvidence[guyNr][2]; if (shownEvidence[guyNr] & 8) evidence->KillTrail = MyEvidence[guyNr][3]; if (shownEvidence[guyNr] & 16) evidence->CallTrail = MyEvidence[guyNr][4]; if (shownEvidence[guyNr] & 32) evidence->PaperTrail = MyEvidence[guyNr][5]; if (shownEvidence[guyNr] & 64) evidence->FotoTrail = MyEvidence[guyNr][6]; Present(Evidence_Evidence_1, "Fahndung", InitEvidencePresent); ShowMenuBackground(); PrintStatus(line); shown = 1; } } if (shownEvidence[guyNr] == ((1 << 7) - 1)) guyReady |= (1 << guyNr); } guyReady = 0; /* ein gewisses Restwissen bleibt der Polizei ! */ for (i = 0; i < guyCount; i++) { totalEvidence[i] /= 3; /* change als in recognition = ... */ if (p[i] != 0) { if (totalEvidence[i] > 255) totalEvidence[i] = 255; p[i]->KnownToPolice = (ubyte) (totalEvidence[i]); if (p[i]->KnownToPolice > tcPERSON_IS_ARRESTED) caught |= tcPersonWanted(OL_NR(GetNthNode(guys, i))); if (!caught) if (p[i] == dbGetObject(Person_Robert_Bull)) caught |= tcATraitor(Person_Robert_Bull); if (!caught) if (p[i] == dbGetObject(Person_Marc_Smith)) caught |= tcATraitor(Person_Marc_Smith); if (setup.Profidisk) { if (!caught) if (p[i] == dbGetObject(Person_Phil_Ciggy)) caught |= tcATraitor(Person_Phil_Ciggy); } } } caught |= tcIsThereATraitor(); if (! (tcCarFound ((Car) dbGetObject(Organisation.CarID), Search.TimeOfBurglary - Search.TimeOfAlarm))) { S32 newStrike; Car car = dbGetObject(Organisation.CarID); newStrike = CalcValue((S32) car->Strike, 0, 255, 255, 15); if (newStrike < (car->Strike + 40)) newStrike = ChangeAbs((S32) car->Strike, 40, 0, 255); car->Strike = newStrike; } ((Player) dbGetObject(Player_Player_1))->MattsPart = (ubyte) tcCalcMattsPart(); tcForgetGuys(); RemoveList(spuren); RemoveList(guys); return caught; }
void DirectoryViewer::ShowEntry(const FileList::FileEntry& fileEntry, const ConfigFile& configFile, unsigned int columnNumber, unsigned int numColumns) { unsigned char color = static_cast<unsigned char>(configFile.GetColorByExtension(fileEntry.Extension())); color += color < 10 ? '0' : 'a' - 10; unsigned int columnWidth = m_console.Width() / numColumns; if (columnWidth > 89) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, false); // 11 ShowTime(fileEntry.m_time, false); // 9 ShowAttributes(fileEntry.m_attributes); // 6 m_console.Printf(" "); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, false); // 16 int remainingSpace = columnWidth - 1 - 11 - 9 - 6 - 1 - 16 - 1; m_console.Printf("^%c%-*s^7", color, remainingSpace, fileEntry.m_name.c_str()); } else if (columnWidth > 80) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, false); // 11 ShowTime(fileEntry.m_time, false); // 9 ShowAttributes(fileEntry.m_attributes); // 6 m_console.Printf(" "); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-44.44s^7", color, fileEntry.m_name.c_str()); // 44 } else if (columnWidth > 40) { m_console.Printf("^4³"); // 1 ShowDate(fileEntry.m_time, true); // 9 ShowTime(fileEntry.m_time, true); // 6 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-17.17s^7", color, fileEntry.m_name.c_str()); // 17 } else if (columnWidth > 26) { m_console.Printf("^4³"); // 1 ShowAttributes(fileEntry.m_attributes); // 6 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-12.12s", color, fileEntry.m_name.c_str()); // 12 if (columnNumber + 1 == numColumns) m_console.Printf("^4³"); // 1 } else if (columnWidth > 20) { m_console.Printf("^4³"); // 1 ShowSize(fileEntry.m_size, fileEntry.m_attributes, true); // 7 m_console.Printf("^%c%-12.12s", color, fileEntry.m_name.c_str()); // 12 } else if (columnWidth > 16) { m_console.Printf("^4³^%c%-15.15s", color, fileEntry.m_name.c_str()); } else if (columnWidth > 13) { m_console.Printf("^4³^%c%-12.12s^7", color, fileEntry.m_name.c_str()); if (columnNumber + 1 == numColumns) m_console.Printf("^4³"); } if (columnNumber + 1 == numColumns) m_console.Printf("\n"); }
/* "Сбросить" виртуальный буфер на консоль */ void ScreenBuf::Flush(bool SuppressIndicators) { SCOPED_ACTION(CriticalSectionLock)(CS); if (!LockCount) { if (!SuppressIndicators) { if(Global->CtrlObject && (Global->CtrlObject->Macro.IsRecording() || (Global->CtrlObject->Macro.IsExecuting() && Global->Opt->Macro.ShowPlayIndicator)) ) { MacroChar=Buf[0]; MacroCharUsed=true; if(Global->CtrlObject->Macro.IsRecording()) { Buf[0].Char=L'R'; Buf[0].Attributes = Colors::ConsoleColorToFarColor(B_LIGHTRED|F_WHITE); } else { Buf[0].Char=L'P'; Buf[0].Attributes = Colors::ConsoleColorToFarColor(B_GREEN|F_WHITE); } } if(Global->Elevation->Elevated()) { ElevationChar=Buf[BufX*BufY-1]; ElevationCharUsed=true; Buf[BufX*BufY-1].Char=L'A'; Buf[BufX*BufY-1].Attributes = Colors::ConsoleColorToFarColor(B_LIGHTRED|F_WHITE); } } if (!SBFlags.Check(SBFLAGS_FLUSHEDCURTYPE) && !CurVisible) { CONSOLE_CURSOR_INFO cci={CurSize,CurVisible}; Global->Console->SetCursorInfo(cci); SBFlags.Set(SBFLAGS_FLUSHEDCURTYPE); } if (!SBFlags.Check(SBFLAGS_FLUSHED)) { SBFlags.Set(SBFLAGS_FLUSHED); if (Global->WaitInMainLoop && Global->Opt->Clock && !Global->ProcessShowClock) { ShowTime(FALSE); } std::list<SMALL_RECT>WriteList; bool Changes=false; if (SBFlags.Check(SBFLAGS_USESHADOW)) { FAR_CHAR_INFO* PtrBuf = Buf.data(), *PtrShadow = Shadow.data(); if (Global->Opt->ClearType) { //Для полного избавления от артефактов ClearType будем перерисовывать на всю ширину. //Чревато тормозами/миганием в зависимости от конфигурации системы. SMALL_RECT WriteRegion={0,0,static_cast<SHORT>(BufX-1),0}; for (SHORT I=0; I<BufY; I++, PtrBuf+=BufX, PtrShadow+=BufX) { WriteRegion.Top=I; WriteRegion.Bottom=I-1; while (I<BufY && memcmp(PtrBuf,PtrShadow,BufX*sizeof(FAR_CHAR_INFO))!=0) { I++; PtrBuf+=BufX; PtrShadow+=BufX; WriteRegion.Bottom++; } if (WriteRegion.Bottom >= WriteRegion.Top) { WriteList.emplace_back(WriteRegion); Changes=true; } } } else { bool Started=false; SMALL_RECT WriteRegion={static_cast<SHORT>(BufX-1),static_cast<SHORT>(BufY-1),0,0}; for (SHORT I=0; I<BufY; I++) { for (SHORT J=0; J<BufX; J++,++PtrBuf,++PtrShadow) { if (memcmp(PtrBuf,PtrShadow,sizeof(FAR_CHAR_INFO))!=0) { WriteRegion.Left=std::min(WriteRegion.Left,J); WriteRegion.Top=std::min(WriteRegion.Top,I); WriteRegion.Right=std::max(WriteRegion.Right,J); WriteRegion.Bottom=std::max(WriteRegion.Bottom,I); Changes=true; Started=true; } else if (Started && I>WriteRegion.Bottom && J>=WriteRegion.Left) { //BUGBUG: при включенном СlearType-сглаживании на экране остаётся "мусор" - тонкие вертикальные полосы // кстати, и при выключенном тоже (но реже). // баг, конечно, не наш, но что делать. // расширяем область прорисовки влево-вправо на 1 символ: WriteRegion.Left=std::max(static_cast<SHORT>(0),static_cast<SHORT>(WriteRegion.Left-1)); WriteRegion.Right=std::min(static_cast<SHORT>(WriteRegion.Right+1),static_cast<SHORT>(BufX-1)); bool Merge=false; if (!WriteList.empty()) { SMALL_RECT& Last=WriteList.back(); const int MAX_DELTA = 5; if (WriteRegion.Top-1==Last.Bottom && ((WriteRegion.Left>=Last.Left && WriteRegion.Left-Last.Left<MAX_DELTA) || (Last.Right>=WriteRegion.Right && Last.Right-WriteRegion.Right<MAX_DELTA))) { Last.Bottom=WriteRegion.Bottom; Last.Left=std::min(Last.Left,WriteRegion.Left); Last.Right=std::max(Last.Right,WriteRegion.Right); Merge=true; } } if (!Merge) WriteList.emplace_back(WriteRegion); WriteRegion.Left=BufX-1; WriteRegion.Top=BufY-1; WriteRegion.Right=0; WriteRegion.Bottom=0; Started=false; } } } if (Started) { WriteList.emplace_back(WriteRegion); } } } else { Changes=true; SMALL_RECT WriteRegion={0,0,static_cast<SHORT>(BufX-1),static_cast<SHORT>(BufY-1)}; WriteList.emplace_back(WriteRegion); } if (Changes) { std::for_each(CONST_RANGE(WriteList, i) { COORD BufferSize={BufX, BufY}, BufferCoord={i.Left, i.Top}; SMALL_RECT WriteRegion = i; Global->Console->WriteOutput(Buf.data(), BufferSize, BufferCoord, WriteRegion); }); Global->Console->Commit(); std::copy(ALL_CONST_RANGE(Buf), Shadow.begin()); }