int __cdecl main() { HRESULT hr = S_OK; hr = DebugPlotInit(); if (FAILED(hr)) return -1; int count = 0; while(1) { WaitForViewer(INFINITE); for (int i = 0; i < BUF_SIZE; i++) { double phase = PI_2 * (count++) / PERIOD; double re = AMP * sin(phase); double im = AMP * cos(phase); dataBuf[i].re = reBuf[i] = short(re); dataBuf[i].im = imBuf[i] = short(im); } PlotLine("real", reBuf, BUF_SIZE); PlotLine("imaginary", imBuf, BUF_SIZE); PlotDots("constellation", dataBuf, BUF_SIZE); PlotText("sample count", "%d\n", count); } DebugPlotDeinit(); return 0; }
// === FUNCTION ============================================================ // Name: PlotLines // Description: // =========================================================================== bool PlotLines(TCanvas* c1, TLegend* leg) { c1->cd(); std::vector<std::string> vLegend; vLegend.push_back("PhaseI_0PU"); vLegend.push_back("PhaseI_140PU"); vLegend.push_back("PhaseII3_140PU"); vLegend.push_back("PhaseII4_140PU"); std::map<std::string, TGraph*> vMap; vMap["PhaseI_0PU"] = PlotLine(plateu, "NoPileUp", "PhaseI"); vMap["PhaseI_140PU"] = PlotLine(plateu, "140PileUp", "PhaseI"); vMap["PhaseII3_140PU"] = PlotLine(plateu, "140PileUp", "PhaseII3"); //vMap["PhaseII4_140PU"] = PlotLine(plateu, "140PileUp", "PhaseII4"); vMap["PhaseII4_140PU"] = PlotLine(plateu, "140PileUp", "PhaseII4v2"); for (int i = 0; i < vLegend.size(); ++i) { vMap[vLegend.at(i)]->SetLineColor(VColor[i+1]); leg->AddEntry( vMap[vLegend.at(i)], vLegend.at(i).c_str(), "l"); vMap[vLegend.at(i)]->Draw("sameLP"); } leg->Draw("same"); return true; } // ----- end of function PlotLines -----
int TestTut1(bool bBlock, bool bPrint) { HRESULT hr = S_OK; const int PRINT_COUNT = 64*1024; hr = DebugPlotInit(); if (FAILED(hr)) return -1; int count = 0; while(1) { bPrint = count % PRINT_COUNT == 0; if (bPrint) printf("Running %d\n", count); if (bBlock) { WaitForViewer(INFINITE); if (bPrint) printf("After WaitForViewer\n"); } for (int i = 0; i < BUF_SIZE; i++) { double phase = PI_2 * (count++) / PERIOD; double re = AMP * sin(phase); double im = AMP * cos(phase); dataBuf[i].re = reBuf[i] = short(re); dataBuf[i].im = imBuf[i] = short(im); } PlotLine("real", reBuf, BUF_SIZE); PlotLine("imaginary", imBuf, BUF_SIZE); PlotDots("constellation", dataBuf, BUF_SIZE); PlotText("sample count", "%d\n", count); if (bPrint) printf("After plot\n"); } DebugPlotDeinit(); return 0; }
void QRPlot::plotLine(QString propertyName, QString dataTitle) { qDebug() << "Plotting " << propertyName; Summary summary = getSummaryWithTitle(dataTitle); Property xProp = summary.getProperties().getProperty("TIME"); Property yProp = summary.getProperties().getProperty(propertyName); PlotLine newLine = PlotLine(xProp.getValues(), yProp.getValues(), propertyName, yProp.getUnit(), dataTitle); this->graph.addLine(newLine); this->updatePlottedPropertiesList(); }
void NCursesFrontend::PrintTopHeader(char* header, int lineNr, bool upTime) { BString<1024> buffer("%-*s", m_screenWidth, header); int headerLen = strlen(header); int charsLeft = m_screenWidth - headerLen - 2; int time = upTime ? m_upTimeSec : m_dnTimeSec; int d = time / 3600 / 24; int h = (time % (3600 * 24)) / 3600; int m = (time % 3600) / 60; int s = time % 60; BString<100> timeStr; if (d == 0) { timeStr.Format("%.2d:%.2d:%.2d", h, m, s); if ((int)strlen(timeStr) > charsLeft) { timeStr.Format("%.2d:%.2d", h, m); } } else { timeStr.Format("%i %s %.2d:%.2d:%.2d", d, (d == 1 ? "day" : "days"), h, m, s); if ((int)strlen(timeStr) > charsLeft) { timeStr.Format("%id %.2d:%.2d:%.2d", d, h, m, s); } if ((int)strlen(timeStr) > charsLeft) { timeStr.Format("%id %.2d:%.2d", d, h, m); } } const char* shortCap = upTime ? " Up " : "Dn "; const char* longCap = upTime ? " Uptime " : " Download-time "; int timeLen = strlen(timeStr); int shortCapLen = strlen(shortCap); int longCapLen = strlen(longCap); if (charsLeft - timeLen - longCapLen >= 0) { snprintf(buffer + m_screenWidth - timeLen - longCapLen, MAX_SCREEN_WIDTH - (m_screenWidth - timeLen - longCapLen), "%s%s", longCap, *timeStr); } else if (charsLeft - timeLen - shortCapLen >= 0) { snprintf(buffer + m_screenWidth - timeLen - shortCapLen, MAX_SCREEN_WIDTH - (m_screenWidth - timeLen - shortCapLen), "%s%s", shortCap, *timeStr); } else if (charsLeft - timeLen >= 0) { snprintf(buffer + m_screenWidth - timeLen, MAX_SCREEN_WIDTH - (m_screenWidth - timeLen), "%s", *timeStr); } PlotLine(buffer, lineNr, 0, NCURSES_COLORPAIR_INFOLINE); }
int NCursesFrontend::PrintMessage(Message& msg, int row, int maxLines) { const char* messageType[] = { "INFO ", "WARNING ", "ERROR ", "DEBUG ", "DETAIL "}; const int messageTypeColor[] = { NCURSES_COLORPAIR_INFO, NCURSES_COLORPAIR_WARNING, NCURSES_COLORPAIR_ERROR, NCURSES_COLORPAIR_DEBUG, NCURSES_COLORPAIR_DETAIL }; CString text; if (m_showTimestamp) { time_t rawtime = msg.GetTime() + g_Options->GetTimeCorrection(); text.Format("%s - %s", *Util::FormatTime(rawtime), msg.GetText()); } else { text = msg.GetText(); } // replace some special characters with spaces for (char* p = (char*)text; *p; p++) { if (*p == '\n' || *p == '\r' || *p == '\b') { *p = ' '; } } int len = strlen(text); int winWidth = m_screenWidth - 8; int msgLines = len / winWidth; if (len % winWidth > 0) { msgLines++; } int lines = 0; for (int i = msgLines - 1; i >= 0 && lines < maxLines; i--) { int r = row - msgLines + i + 1; PlotLine(text + winWidth * i, r, 8, NCURSES_COLORPAIR_TEXT); if (i == 0) { PlotText(messageType[msg.GetKind()], r, 0, messageTypeColor[msg.GetKind()], false); } else { PlotText(" ", r, 0, messageTypeColor[msg.GetKind()], false); } lines++; } return lines; }
void NCursesFrontend::PrintFilename(FileInfo * fileInfo, int row, bool selected) { int color = 0; const char* Brace1 = "["; const char* Brace2 = "]"; if (m_inputMode == editQueue && selected) { color = NCURSES_COLORPAIR_TEXTHIGHL; if (!m_useColor) { Brace1 = "<"; Brace2 = ">"; } } else { color = NCURSES_COLORPAIR_TEXT; } const char* downloading = ""; if (fileInfo->GetActiveDownloads() > 0) { downloading = " *"; } BString<100> priority; if (fileInfo->GetNzbInfo()->GetPriority() != 0) { priority.Format(" [%+i]", fileInfo->GetNzbInfo()->GetPriority()); } BString<100> completed; if (fileInfo->GetRemainingSize() < fileInfo->GetSize()) { completed.Format(", %i%%", (int)(100 - fileInfo->GetRemainingSize() * 100 / fileInfo->GetSize())); } BString<1024> nzbNiceName; if (m_showNzbname) { nzbNiceName.Format("%s%c", fileInfo->GetNzbInfo()->GetName(), PATH_SEPARATOR); } BString<1024> text("%s%i%s%s%s %s%s (%s%s)%s", Brace1, fileInfo->GetId(), Brace2, *priority, downloading, *nzbNiceName, fileInfo->GetFilename(), *Util::FormatSize(fileInfo->GetSize()), *completed, fileInfo->GetPaused() ? " (paused)" : ""); PlotLine(text, row, 0, color); }
void NCursesFrontend::PrintMessages() { int lineNr = m_messagesWinTop; BString<1024> buffer("%s Messages", m_useColor ? "" : "*** "); PlotLine(buffer, lineNr++, 0, NCURSES_COLORPAIR_INFOLINE); int line = lineNr + m_messagesWinClientHeight - 1; int linesToPrint = m_messagesWinClientHeight; GuardedMessageList messages = GuardMessages(); // print messages from bottom for (int i = (int)messages->size() - 1; i >= 0 && linesToPrint > 0; i--) { int printedLines = PrintMessage(messages->at(i), line, linesToPrint); line -= printedLines; linesToPrint -= printedLines; } if (linesToPrint > 0) { // too few messages, print them again from top line = lineNr + m_messagesWinClientHeight - 1; while (linesToPrint-- > 0) { PlotLine("", line--, 0, NCURSES_COLORPAIR_TEXT); } int linesToPrint2 = m_messagesWinClientHeight; for (int i = (int)messages->size() - 1; i >= 0 && linesToPrint2 > 0; i--) { int printedLines = PrintMessage(messages->at(i), line, linesToPrint2); line -= printedLines; linesToPrint2 -= printedLines; } } }
void NCursesFrontend::PrintGroupQueue() { GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); int lineNr = m_queueWinTop; if (downloadQueue->GetQueue()->empty()) { BString<1024> buffer("%s NZBs for downloading", m_useColor ? "" : "*** "); PrintTopHeader(buffer, lineNr++, false); PlotLine("Ready to receive nzb-job", lineNr++, 0, NCURSES_COLORPAIR_TEXT); } else { lineNr++; ResetColWidths(); int calcLineNr = lineNr; int i = 0; for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (i >= m_queueScrollOffset && i < m_queueScrollOffset + m_queueWinHeight -1) { PrintGroupname(nzbInfo, calcLineNr++, false, true); } i++; } int64 remaining = 0; int64 paused = 0; i = 0; for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { if (i >= m_queueScrollOffset && i < m_queueScrollOffset + m_queueWinHeight -1) { PrintGroupname(nzbInfo, lineNr++, i == m_selectedQueueEntry, false); } i++; remaining += nzbInfo->GetRemainingSize(); paused += nzbInfo->GetPausedSize(); } BString<1024> buffer(" %sNZBs for downloading - %i NZBs in queue - %s / %s", m_useColor ? "" : "*** ", (int)downloadQueue->GetQueue()->size(), *Util::FormatSize(remaining), *Util::FormatSize(remaining - paused)); PrintTopHeader(buffer, m_queueWinTop, false); } }
void NCursesFrontend::PrintFileQueue() { int lineNr = m_queueWinTop + 1; int64 remaining = 0; int64 paused = 0; int pausedFiles = 0; int fileNum = 0; GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { for (FileInfo* fileInfo : nzbInfo->GetFileList()) { if (fileNum >= m_queueScrollOffset && fileNum < m_queueScrollOffset + m_queueWinHeight -1) { PrintFilename(fileInfo, lineNr++, fileNum == m_selectedQueueEntry); } fileNum++; if (fileInfo->GetPaused()) { pausedFiles++; paused += fileInfo->GetRemainingSize(); } remaining += fileInfo->GetRemainingSize(); } } if (fileNum > 0) { BString<1024> header(" %sFiles for downloading - %i / %i files in queue - %s / %s", m_useColor ? "" : "*** ", fileNum, fileNum - pausedFiles, *Util::FormatSize(remaining), *Util::FormatSize(remaining - paused)); PrintTopHeader(header, m_queueWinTop, true); } else { lineNr--; BString<1024> header("%s Files for downloading", m_useColor ? "" : "*** "); PrintTopHeader(header, lineNr++, true); PlotLine("Ready to receive nzb-job", lineNr++, 0, NCURSES_COLORPAIR_TEXT); } }
void NCursesFrontend::PrintStatus() { int statusRow = m_screenHeight - 2; BString<100> timeString; int currentDownloadSpeed = m_standBy ? 0 : m_currentDownloadSpeed; if (currentDownloadSpeed > 0 && !m_pauseDownload) { int64 remain_sec = (int64)(m_remainingSize / currentDownloadSpeed); int h = (int)(remain_sec / 3600); int m = (int)((remain_sec % 3600) / 60); int s = (int)(remain_sec % 60); timeString.Format(" (~ %.2d:%.2d:%.2d)", h, m, s); } BString<100> downloadLimit; if (m_downloadLimit > 0) { downloadLimit.Format(", Limit %i KB/s", m_downloadLimit / 1024); } BString<100> postStatus; if (m_postJobCount > 0) { postStatus.Format(", %i post-job%s", m_postJobCount, m_postJobCount > 1 ? "s" : ""); } int averageSpeed = (int)(m_dnTimeSec > 0 ? m_allBytes / m_dnTimeSec : 0); BString<1024> status(" %d threads, %s, %s remaining%s%s%s%s, Avg. %s", m_threadCount, *Util::FormatSpeed(currentDownloadSpeed), *Util::FormatSize(m_remainingSize), *timeString, *postStatus, m_pauseDownload ? (m_standBy ? ", Paused" : ", Pausing") : "", *downloadLimit, *Util::FormatSpeed(averageSpeed)); PlotLine(status, statusRow, 0, NCURSES_COLORPAIR_STATUS); }
Bool wxTextPrintout::OnPrintPage(int page) { if (page>Pages) { return FALSE; } int i; // first get Pagesize float x,y,w,h; int w0,h0; GetPageSizePixels(&w0,&h0); // Set sizes x=0.f;y=0.f; w=float(w0); h=float(h0); // now work out the borders x=x+BorderSize; y=y+GetBorderSize()+(GetHeaderSize()+GetHeaderRuleOff())*GetScale(); w=w-GetBorderSize()-x; h=h-GetBorderSize()-y-(GetFooterSize()+GetFooterRuleOff())*GetScale(); // get the Device Context wxDC *dc=GetDC(); // now create the font if necessary wxFont *myFont=wxTheFontList->FindOrCreateFont(int(GetFontSize()*GetScale()), FontFamily, FontStyle, FontWeight); dc->SetFont(myFont); // now start drawing // protect rest of the page dc->SetClippingRegion(x,y,w,h); // print the text char * StillToPrint=TextToPrint; float yplot; for (i=1;i<=page;i++) { yplot=y; while ( (StillToPrint=PlotLine(dc,x,y,w,h,&yplot,StillToPrint,(i==page))) && (yplot!=-1) ) { // Do nothing - We are still printing... } if (StillToPrint==0) { Pages=i; if ((i!=page)) { return FALSE; } } } dc->DestroyClippingRegion(); // Print Header if (GetHeaderSize()) { dc->SetClippingRegion(x, y-(GetHeaderSize()+GetHeaderRuleOff())*GetScale(), w, GetHeaderSize()*GetScale() ); PlotHeader(dc, x,y-(GetHeaderSize()+GetHeaderRuleOff())*GetScale(), w,GetHeaderSize()*GetScale(), page); dc->DestroyClippingRegion(); } // Print footer if (GetFooterSize()) { dc->SetClippingRegion(x, y+h+GetFooterRuleOff()*GetScale(), w, GetFooterSize()*GetScale() ); PlotFooter(dc, x,y+h+GetFooterRuleOff()*GetScale(), w,GetFooterSize()*GetScale(), page); dc->DestroyClippingRegion(); } // return TRUE, as the page has been printed return TRUE; }
void NCursesFrontend::PrintGroupname(NzbInfo* nzbInfo, int row, bool selected, bool calcColWidth) { int color = NCURSES_COLORPAIR_TEXT; char chBrace1 = '['; char chBrace2 = ']'; if (m_inputMode == editQueue && selected) { color = NCURSES_COLORPAIR_TEXTHIGHL; if (!m_useColor) { chBrace1 = '<'; chBrace2 = '>'; } } const char* downloading = ""; if (nzbInfo->GetActiveDownloads() > 0) { downloading = " *"; } BString<100> priority; if (nzbInfo->GetPriority() != 0) { priority.Format(" [%+i]", nzbInfo->GetPriority()); } // Format: // [id - id] Name Left-Files/Paused Total Left Time // [1-2] Nzb-name 999/999 999.99 MB 999.99 MB 00:00:00 int nameLen = 0; if (calcColWidth) { nameLen = m_screenWidth - 1 - 9 - 11 - 11 - 9; } else { nameLen = m_screenWidth - 1 - m_colWidthFiles - 2 - m_colWidthTotal - 2 - m_colWidthLeft - 2 - 9; } BString<1024> buffer; bool printFormatted = nameLen > 20; if (printFormatted) { BString<100> files("%i/%i", (int)nzbInfo->GetFileList()->size(), nzbInfo->GetPausedFileCount()); BString<1024> nameWithIds("%c%i%c%s%s %s", chBrace1, nzbInfo->GetId(), chBrace2, *priority, downloading, nzbInfo->GetName()); int64 unpausedRemainingSize = nzbInfo->GetRemainingSize() - nzbInfo->GetPausedSize(); CString remaining = Util::FormatSize(unpausedRemainingSize); CString total = Util::FormatSize(nzbInfo->GetSize()); BString<100> time; int currentDownloadSpeed = m_standBy ? 0 : m_currentDownloadSpeed; if (nzbInfo->GetPausedSize() > 0 && unpausedRemainingSize == 0) { time = "[paused]"; remaining = Util::FormatSize(nzbInfo->GetRemainingSize()); } else if (currentDownloadSpeed > 0 && !m_pauseDownload) { int64 remain_sec = (int64)(unpausedRemainingSize / currentDownloadSpeed); int h = (int)(remain_sec / 3600); int m = (int)((remain_sec % 3600) / 60); int s = (int)(remain_sec % 60); if (h < 100) { time.Format("%.2d:%.2d:%.2d", h, m, s); } else { time.Format("99:99:99"); } } if (calcColWidth) { int colWidthFiles = strlen(files); m_colWidthFiles = colWidthFiles > m_colWidthFiles ? colWidthFiles : m_colWidthFiles; int colWidthTotal = strlen(total); m_colWidthTotal = colWidthTotal > m_colWidthTotal ? colWidthTotal : m_colWidthTotal; int colWidthLeft = strlen(remaining); m_colWidthLeft = colWidthLeft > m_colWidthLeft ? colWidthLeft : m_colWidthLeft; } else { buffer.Format("%-*s %*s %*s %*s %8s", nameLen, *nameWithIds, m_colWidthFiles, *files, m_colWidthTotal, *total, m_colWidthLeft, *remaining, *time); } } else { buffer.Format("%c%i%c%s %s", chBrace1, nzbInfo->GetId(), chBrace2, downloading, nzbInfo->GetName()); } if (!calcColWidth) { PlotLine(buffer, row, 0, color); } }
void NCursesFrontend::PrintKeyInputBar() { int queueSize = CalcQueueSize(); int inputBarRow = m_screenHeight - 1; if (!m_hint.Empty()) { time_t time = Util::CurrentTime(); if (time - m_startHint < 5) { PlotLine(m_hint, inputBarRow, 0, NCURSES_COLORPAIR_HINT); return; } else { SetHint(nullptr); } } switch (m_inputMode) { case normal: if (m_groupFiles) { PlotLine("(Q)uit | (E)dit | (P)ause | (R)ate | (W)indow | (G)roup | (T)ime", inputBarRow, 0, NCURSES_COLORPAIR_KEYBAR); } else { PlotLine("(Q)uit | (E)dit | (P)ause | (R)ate | (W)indow | (G)roup | (T)ime | n(Z)b", inputBarRow, 0, NCURSES_COLORPAIR_KEYBAR); } break; case editQueue: { const char* status = nullptr; if (m_selectedQueueEntry > 0 && queueSize > 1 && m_selectedQueueEntry == queueSize - 1) { status = "(Q)uit | (E)xit | (P)ause | (D)elete | (U)p/(T)op"; } else if (queueSize > 1 && m_selectedQueueEntry == 0) { status = "(Q)uit | (E)xit | (P)ause | (D)elete | dow(N)/(B)ottom"; } else if (queueSize > 1) { status = "(Q)uit | (E)xit | (P)ause | (D)elete | (U)p/dow(N)/(T)op/(B)ottom"; } else { status = "(Q)uit | (E)xit | (P)ause | (D)elete"; } PlotLine(status, inputBarRow, 0, NCURSES_COLORPAIR_KEYBAR); break; } case downloadRate: BString<100> hint("Download rate: %i", m_inputValue); PlotLine(hint, inputBarRow, 0, NCURSES_COLORPAIR_KEYBAR); // Print the cursor PlotText(" ", inputBarRow, 15 + m_inputNumberIndex, NCURSES_COLORPAIR_CURSOR, true); break; } }
void plot_pos(struct Grplot *grplot,int p, struct posdata *pos,double stime,double etime,int mode, unsigned int color,float width,char *fontname, float fontsize) { float *P; int i; int flg; float ylim=0; double ymajor=100; double yminor=100/5; double y; int km=0; float mult=1; float ox=0,oy=0,px=0,py=0; float tx,ty; unsigned int gry; unsigned int red; unsigned int blue; struct PlotDash *dashA; struct PlotDash *dashB; dashA=PlotMakeDashString("4 4"); dashB=PlotMakeDashString("4 2 1 2"); gry=PlotColor(128,128,128,255); red=PlotColor(255,0,0,255); blue=PlotColor(0,0,255,255); GrplotYzero(grplot,p,-1,1,gry,0x0f,width,NULL); for (i=0;i<pos->cnt;i++) { if (mode==0) P=&pos->PGSM[3*i]; else P=&pos->PGSE[3*i]; if (fabs(P[0])>500) continue; if (fabs(P[1])>500) continue; if (fabs(P[2])>500) continue; if (fabs(P[0])>ylim) ylim=fabs(P[0]); if (fabs(P[1])>ylim) ylim=fabs(P[1]); if (fabs(P[2])>ylim) ylim=fabs(P[2]); } if (ylim<2) { /* plot in km */ km=1; mult=6370.0; ylim=ylim*6370; y=0; while (y<ylim) y+=1000; ylim=y; ymajor=1000; yminor=1000/5; } else if (ylim<60) { y=0; while (y<ylim) y=y+20; ylim=y; ymajor=20; yminor=20/4; } else { y=0; while (y<ylim) y=y+50; ylim=y; ymajor=100; yminor=100/5; } GrplotYaxis(grplot,p,-ylim,ylim,ymajor,yminor,0x03,color,0x0f,width); if (km==0) { GrplotYaxisLabel(grplot,p,-ylim,ylim,ymajor,0x03,label_val,NULL,fontname, fontsize,color,0x0f); GrplotYaxisTitle(grplot,p,0x03,strlen("Pos (RE)"),"Pos (RE)", fontname,fontsize,color,0x0f); } else { GrplotYaxisLabel(grplot,p,-ylim,ylim,ymajor,0x03,label_km,NULL,fontname, fontsize,color,0x0f); GrplotYaxisTitle(grplot,p,0x03,strlen("Pos (km)"),"Pos (km)", fontname,fontsize,color,0x0f); } GrplotGetPoint(grplot,p,0,1,0,1,0,1,&tx,&ty); PlotLine(grplot->plot,tx+5,ty+5,tx+20,ty+5,color,0x0f,width,NULL); PlotLine(grplot->plot,tx+35,ty+5,tx+50,ty+5,red,0x0f,width,dashA); PlotLine(grplot->plot,tx+65,ty+5,tx+80,ty+5,blue,0x0f,width,dashB); PlotText(grplot->plot,NULL,fontname,fontsize, tx+22,ty+10,strlen("X"),"X",blue,0x0f,1); PlotText(grplot->plot,NULL,fontname,fontsize, tx+52,ty+10,strlen("Y"),"Y",blue,0x0f,1); PlotText(grplot->plot,NULL,fontname,fontsize, tx+82,ty+10,strlen("Z"),"Z",blue,0x0f,1); flg=0; for (i=0;i<pos->cnt;i++) { if (mode==0) P=&pos->PGSM[3*i]; else P=&pos->PGSE[3*i]; if (fabs(P[0])<500) { px=pos->time[i]-stime; py=P[0]*mult; if (flg==1) GrplotLine(grplot,p,ox,oy,px,py, 0,etime-stime,-ylim,ylim, color,0x0f,width,NULL); ox=px; oy=py; flg=1; } else flg=0; } flg=0; for (i=0;i<pos->cnt;i++) { if (mode==0) P=&pos->PGSM[3*i]; else P=&pos->PGSE[3*i]; if (fabs(P[1])<500) { px=pos->time[i]-stime; py=P[1]*mult; if (flg==1) GrplotLine(grplot,p,ox,oy,px,py, 0,etime-stime,-ylim,ylim, red,0x0f,width,dashA); ox=px; oy=py; flg=1; } else flg=0; } flg=0; for (i=0;i<pos->cnt;i++) { if (mode==0) P=&pos->PGSM[3*i]; else P=&pos->PGSE[3*i]; if (fabs(P[2])<500) { px=pos->time[i]-stime; py=P[2]*mult; if (flg==1) GrplotLine(grplot,p,ox,oy,px,py, 0,etime-stime,-ylim,ylim, blue,0x0f,width,dashB); ox=px; oy=py; flg=1; } else flg=0; } PlotFreeDash(dashA); PlotFreeDash(dashB); }
bool Sample() { HRESULT hr = S_OK; hr = ::DebugPlotInit(); if (FAILED(hr)) return false; const int COMPLEX_16M_BYTES = 16*1024*1024/sizeof(COMPLEX16); COMPLEX16 * dataToProcess = new COMPLEX16[COMPLEX_16M_BYTES]; PrepareData(dataToProcess, COMPLEX_16M_BYTES, 4*1024); // generate a sine wave data and write to a 4k buffer // add a special *interesting data* at index 256k int interestDataIdx = 32*1024; dataToProcess[interestDataIdx].re = 30000; dataToProcess[interestDataIdx].im = 30000; __int64 counter = 0; DWORD timer = 0; DWORD lastTimer = 0; do { while(1) // Periodically write data in 4k buffer to source trace buffer util the buffer is full (16M bytes) { int numWritten; hr = ::TracebufferWriteData(dataToProcess, COMPLEX_16M_BYTES, &numWritten); if (hr == E_END_OF_BUF) { assert(numWritten <= COMPLEX_16M_BYTES); break; } } bool endOfSourceBuf = false; while(!endOfSourceBuf) { int numRead; // syncronize with viewer, if the plotter plot too much data, wait for viewer will block until viewer read the data //::WaitForViewer(INFINITE); // process PROCESS_SIZE COMPLEX16 every time hr = ::TracebufferReadData(readBuf, PROCESS_SIZE, &numRead); if (hr == E_END_OF_BUF) // source trace buffer is empty { endOfSourceBuf = true; assert(numRead <= PROCESS_SIZE); } if (numRead == 0) continue; // process each COMPLEX double avgEnergy = 0.0; for (int i = 0; i < numRead; i++) { int re = readBuf[i].re; int im = readBuf[i].im; if (re > 20000) // find our interesting data!!! { //PauseViewer(); //::OutputDebugString(L"Pause viewer"); } // calculate energy double energyF = log(double(re*re + im*im)) - 10; energyF = max(energyF, 0.0); avgEnergy += energyF; energyBuf[i] = (int)energyF; // set re & im value reBuf[i] = re; imBuf[i] = im; } avgEnergy /= numRead; // generate a fake spectrum using rand() GenSpectrum(); // plot PlotLine("re part", reBuf, numRead); PlotLine("im part", imBuf, numRead); PlotLine("energy", energyBuf, numRead); PlotDots("dots", readBuf, numRead); PlotText("text", "%f\n", avgEnergy); Log("log", "%I64d\n", counter++); if (1) { static int lowFrequencyData = 0; //::PlotLine("low frequency", &lowFrequencyData, 1); lowFrequencyData = (lowFrequencyData+1)%100; lastTimer = timer; ::PlotSpectrum("spectrum 63", spectrumBuf, SPECTRUM_SIZE); ::PlotSpectrum("spectrum 32", spectrumBuf, 32); } ::Sleep(15); } ::TracebufferClear(); } while(1); delete [] dataToProcess; DebugPlotDeinit(); return true; }
void plot_maxmin(struct Plot *plot, struct CnvGrid *ptr,int magflg, float xoff,float yoff,float wdt,float hgt,float sze, int (*trnf)(int,void *,int,void *,void *data),void *data, unsigned int color,char mask,float width, struct PlotDash *dash) { int i,s; double min=1e10; double max=-1e10; float max_lon=0,max_lat=0; float min_lon=0,min_lat=0; float map[2],pnt[2]; float px,py; for (i=0;i<ptr->num;i++) { if (ptr->mag[i]>max) { max_lon=ptr->lon[i]; max_lat=ptr->lat[i]; max=ptr->mag[i]; } if (ptr->mag[i]<min) { min_lon=ptr->lon[i]; min_lat=ptr->lat[i]; min=ptr->mag[i]; } } if (!magflg) { double mlat,mlon,glat,glon,r; int s; mlat=max_lat; mlon=max_lon; s=AACGMConvert(mlat,mlon,150,&glat,&glon,&r,1); max_lat=glat; max_lon=glon; mlat=min_lat; mlon=min_lon; s=AACGMConvert(mlat,mlon,150,&glat,&glon,&r,1); min_lat=glat; min_lon=glon; } map[0]=max_lat; map[1]=max_lon; s=(*trnf)(2*sizeof(float),map,2*sizeof(float),pnt,data); if (s==0) { px=xoff+pnt[0]*wdt; py=yoff+pnt[1]*hgt; PlotLine(plot,px-sze,py,px+sze,py,color,mask,width,dash); PlotLine(plot,px,py-sze,px,py+sze,color,mask,width,dash); } map[0]=min_lat; map[1]=min_lon; s=(*trnf)(2*sizeof(float),map,2*sizeof(float),pnt,data); if (s==0) { px=xoff+pnt[0]*wdt; py=yoff+pnt[1]*hgt; PlotLine(plot,px-sze,py+sze,px+sze,py-sze,color,mask,width,dash); PlotLine(plot,px-sze,py-sze,px+sze,py+sze,color,mask,width,dash); } }