void DFO_CreateXYArray:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusOK()) { outputDC.AllocAndSetSize(nSelected); nSelected = 0; int nbad = 0; for (int i = 0; i < maxXYDataDesc; i++) if (xyData[i].doXY) { DC_XYData& currXY = outputDC[nSelected++]; if (xyData[i].xyDataDC != 0) { currXY = *(xyData[i].xyDataDC); if (StringLength(xyData[i].newID)) currXY.SetID(xyData[i].newID); } else { // stick a single 0.0 in currXY.Alloc(1); currXY.xData += 0.0; currXY.yData += 0.0; currXY.SetID("InputBAD"); nbad++; } } // std::cout << "*** CreateXYArray " << GetID() << " nsel " << nSelected << " n bad << " << nbad << std::endl; } }
void DataCaptureOutput::CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; for (int i = 0; i < capturedDataXY.Size(); i++) capturedDataXY[i].CreateFrom(capturedData[0], capturedData[i + 1]); }
BOOL UploadGAR (void) { FILE *GAR; char filename[MAX_PATH]; int i; if (!PromptFile(topHWnd,"Game Action Replay RAM file (gar.bin)\0gar.bin\0\0",filename,NULL,Path_PLUG,"Please select a valid Game Action Replay data file...","gar.bin",FALSE)) return FALSE; if ((GAR = fopen(filename,"rb")) == NULL) { MessageBox(topHWnd,"Unable to open GAR data file!",MSGBOX_TITLE,MB_OK | MB_ICONERROR); return FALSE; } OpenStatus(topHWnd); InitPort(); StatusText("Resetting CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Loading initialization plugin..."); if (!LoadPlugin("garset.bin")) { fclose(GAR); CloseStatus(); return FALSE; } StatusText("Running initialization plugin..."); RunCode(); Sleep(SLEEP_LONG); StatusText("Loading upload plugin..."); if (!LoadPlugin("garup.bin")) { fclose(GAR); CloseStatus(); return FALSE; } StatusText("Running upload plugin..."); RunCode(); StatusText("Uploading from data file..."); BYTE a[256]; for (i = 0; i < 8; i++) { fread(&a,256,1,GAR); if (!WriteBlock(a, 256)) { fclose(GAR); CloseStatus(); return FALSE; } StatusPercent((i*100)/8); } StatusPercent(100); StatusText("...done!"); fclose(GAR); StatusText("Upload complete!"); StatusOK(); ResetNES(RESET_COPYMODE); return TRUE; }
BOOL CMD_NESINFO (void) { char Version[256]; int i; OpenStatus(topHWnd); InitPort(); if (HWVer == 1) { if (ParPort == -1) { StatusText("CopyNES did not return a version reply!"); StatusOK(); return FALSE; } else { StatusText("CopyNES did not return a version reply, assuming version 1"); StatusOK(); return TRUE; } } StatusText("Retrieving internal version string..."); if (!WriteByteEx(0xA1,3,FALSE)) { StatusText("Failed to request version string!"); StatusOK(); return FALSE; } for (i = 0; i < 256; i++) { if (!ReadByteEx(&Version[i],1,FALSE)) { StatusText("Error reading version string!"); StatusOK(); return FALSE; } if (!Version[i]) break; } StatusText(Version); StatusOK(); return TRUE; }
void DPO_SelectLabelArray::CalcOutput(FOcalcType calcType) { DFO_SelectLabelArray::CalcOutput(calcType); indexStrings.DeAlloc(); if (StatusOK()) indexStrings = labDataDO->dataLabels; UpdateUI(); }
void DFO_XYIntegrateFMom:: DoStatusChk() { outputXY.SetID("FM Analysis"); DFO_XYBase::DoStatusChk(); if (StatusOK() && (inputXY->Size() < 2)) SetObjErrMsg("insufficient data in input"); }
void DPO_SelectXYfromXYSimResults::CalcOutput(FOcalcType calcType) { DFO_SelectXYfromXYSimResults::CalcOutput(calcType); indexStrings.DeAlloc(); if (StatusOK()) xySimResultsDC->GetCaseIDs(indexStrings); UpdateUI(); }
BOOL DownloadGAR (void) { FILE *GAR; char filename[MAX_PATH]; int i; if (!PromptFile(topHWnd,"Game Action Replay RAM file (gar_d.bin)\0gar_d.bin\0\0",filename,NULL,Path_PLUG,"Please specify where to save Game Action Replay RAM data...","gar_d.bin",TRUE)) return FALSE; if ((GAR = fopen(filename,"wb")) == NULL) { MessageBox(topHWnd,"Unable to open file for output!",MSGBOX_TITLE,MB_OK | MB_ICONERROR); return FALSE; } OpenStatus(topHWnd); InitPort(); StatusText("Resetting CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Loading initialization plugin..."); if (!LoadPlugin("garset.bin")) { fclose(GAR); CloseStatus(); return FALSE; } StatusText("Running initialization plugin..."); RunCode(); Sleep(SLEEP_LONG); StatusText("Loading download plugin..."); if (!LoadPlugin("gardn.bin")) { fclose(GAR); CloseStatus(); return FALSE; } StatusText("Running download plugin..."); RunCode(); StatusText("Saving to file..."); for (i = 0; i < 0x800; i++) { BYTE n; if (!ReadByte(n)) { fclose(GAR); CloseStatus(); return FALSE; } fwrite(&n,1,1,GAR); if (!(i & 0x7)) StatusPercent((i*100)/2048); } fclose(GAR); StatusText("Download complete!"); StatusOK(); ResetNES(RESET_COPYMODE); return TRUE; }
void UFO_WriteXY:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusOK() && (calcType == foc_Apply)) { IO_XYData outFile; const DC_XYData& outXY = *(static_cast<DO_XYData*>(GetInPortData(xyObjRef)))->xyData; outFile.WriteXYFile(outFname, writeColHeaders, outXY); } }
void DFO_TableColumnCorrelation:: DoStatusChk() { FuncObjC::DoStatusChk(); DSC_TableColSel::DoCheck(*this); if (StatusOK()) { if ((inputData->dataTable.Size() <= selectedYCol) || (selectedYCol < 0)) SetObjErrMsg("Y column index out of range"); } }
void DFO_XYArrayToTable:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; outputTableDC.SetID("XYDataArray"); const DC_XYDataArray& inputXYArray = *static_cast<DO_XYDataArray*>(GetInPortData(inputXYArrayObjRef))->xyDataArray; int ncols = inputXYArray.Size(); int nrows = inputXYArray[0].Size(); const SC_DoubleArray* inputX; if (!interpolateToCommonX) { for (int i = 1; i < ncols; i++) if (inputXYArray[i].Size() != nrows) { SetObjErrMsg("All XY arrays must have the same # of rows"); return; } inputX = &inputXYArray[0].xData; } else { inputX = &static_cast<DO_XYData*>(GetInPortData(interpolateToCommonXObjRef))->GetXY().xData; nrows = inputX->Size(); } outputTableDC.Alloc(ncols + 1, nrows); outputTableDC.columnDesc += "X"; outputTableDC.dataTable += *inputX; SC_DoubleArray outputY; for (int i = 0; i < ncols; i++) { if (interpolateToCommonX) { DC_Curve curveDC; SC_SetupErr curvErr; if (!curveDC.CreateCurve(inputXYArray[i], curvErr)) { SetObjErrMsg("Error creating curve"); return; } curveDC.GetCurveY(*inputX, outputY); outputTableDC.dataTable += outputY; } else { outputTableDC.dataTable += inputXYArray[i].yData; } outputTableDC.columnDesc += inputXYArray[i].GetID(); } outputTableDC.SetRowDesc("X"); }
void UncertInput::CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusOK()) { calcWasPerformed = true; //lastMetricVal = static_cast<DO_Real*>(GetInPortData(inputMetrics[currSelectedMetric].metricObject))->realVal; lastMetricVal.SetEmpty(); for (int i = 0; i < maxMetricSel; i++) { if (inputMetrics[i].uncertOnMetric) lastMetricVal += static_cast<DO_Real*>(GetInPortData(inputMetrics[i].metricObject))->realVal; } } }
void DFO_TableTranspose:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; int nchar = inputTableDC->GetStringLen(); int noutputRows = ninputCols; if (skipXColumn) noutputRows--; int noutputCols = ninputRows; outputTableDC.Alloc(noutputCols, noutputRows, nchar); outputTableDC.columnDesc = inputTableDC->rowDesc; SetDesc(outputTableDC.columnDesc, "Column", noutputCols); SC_DoubleMatrix& outTable = outputTableDC.dataTable; const SC_DoubleMatrix& inTable = inputTableDC->dataTable; int nextOutRow = 0; for (int i = 0; i < ninputCols; i++) { if (skipXColumn && (xcolumnIndex == i)) continue; outputTableDC.rowDesc += inputTableDC->columnDesc[i]; for (int j = 0; j < ninputRows; j++) outTable[j][nextOutRow] = inTable[i][j]; nextOutRow++; } SetDesc(outputTableDC.rowDesc, "Row", noutputRows); outputTableDC.SetSize(noutputCols, noutputRows); }
BOOL CMD_DUMPCART (void) { int dtype = 2; int rbyte = 0, rcount = 0; PPlugin plugin; char *path, *ext; char filename[MAX_PATH]; char fnamebuf[MAX_PATH]; int cmode, battery, bytes, numk; int mapper,submapper=0; int nes2=0, wram=0, vram=0; BYTE ctype; WORD nblks; char Status[256]; FILE *CRC, *DATA; // select board name plugin = PromptPlugin(PLUG_STD); if (plugin == NULL) return FALSE; mapper = plugin->num; PromptTitle = "Choose a ROM filename (omit extension)"; if (!Prompt(topHWnd)) return FALSE; strcpy(filename,PromptResult); OpenStatus(topHWnd); StatusText("Resetting USB CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Unloading any existing plugin..."); if (!LoadPlugin("clear.bin")) { CloseStatus(); return FALSE; } RunCode(); Sleep(SLEEP_SHORT); StatusText("Resetting USB CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Loading plugin..."); if (!LoadPlugin(plugin->file)) { CloseStatus(); return FALSE; } StatusText("Running plugin..."); RunCode(); Sleep(SLEEP_LONG); if (SaveCRC) CRC = fopen(strjoin3(fnamebuf,Path_CRC,filename,".txt"),"wb"); cmode = 0; if (!ReadByte((BYTE *)&cmode)) // mirroring { CloseStatus(); return FALSE; } battery = 0; while (1) { // for the first 'header' byte, wait longer than usual // since the plugin might be busy doing size detection, which can take a while int s; if (!ReadByteEx((BYTE *)&nblks,10,TRUE) || !ReadByte((BYTE *)&nblks+1)) { CloseStatus(); return FALSE; } bytes = nblks << 8; numk = bytes / 1024; if (!ReadByte(&ctype)) { CloseStatus(); return FALSE; } if (ctype == 0) break; switch (ctype) { case 1: ext = ".prg"; if(numk >= 4096) nes2 = 1; path = Path_PRG; sprintf(Status,"Dumping %iK PRG ROM...",numk); break; case 2: ext = ".chr"; if(numk >= 2048) nes2 = 1; path = Path_CHR; sprintf(Status,"Dumping %iK CHR ROM...",numk); break; case 3: ext = ".sav"; path = Path_WRAM; sprintf(Status,"Dumping %iK WRAM/VRAM...",numk); battery = 1; break; case 4: rbyte = nblks / 4; continue; case 5: nes2 = 1; wram = nblks & 0xFF; vram = nblks >> 8; if(wram & 0xF0) battery = 1; if(vram & 0xF0) battery = 1; sprintf(Status,"Non battery WRAM size: %i Bytes...", ((wram & 0x0f)?64 << (wram & 0x0F):0)); StatusText(Status); sprintf(Status,"battery WRAM size: %i Bytes...", ((wram >> 4)?64 << (wram & 0x0F):0)); StatusText(Status); sprintf(Status,"Non battery VRAM size: %i Bytes...", ((vram & 0x0f)?64 << (vram & 0x0F):0)); StatusText(Status); sprintf(Status,"battery VRAM size: %i Bytes...", ((vram >> 4)?64 << (vram & 0x0F):0)); StatusText(Status); continue; case 6: //Mapper number override by plugin. mapper = nblks & 0xFFF; submapper = (nblks & 0xF000) >> 12; sprintf(Status,"Mapper number: %i, submapper: %i...",mapper,submapper); StatusText(Status); if((mapper > 255) || (submapper > 0)) nes2 = 1; continue; case 255: sprintf(Status,"."); continue; //Prevent timeout. default:StatusText("Unknown block type %i! Aborting...",ctype); StatusOK(); return FALSE; break; } StatusText(Status); DATA = fopen(strjoin3(fnamebuf,path,filename,ext),"w+b"); if (DATA == NULL) { StatusText("Unable to open output file!"); StatusOK(); return FALSE; } for (s = 0; s < numk; s++) { int a; BYTE n; for (a = 0; a < 1024; a++) { if (!ReadByte(&n)) { CloseStatus(); return FALSE; } fwrite(&n,1,1,DATA); } if (rbyte) { rcount++; if (rbyte <= rcount) { rcount = 0; StatusText("Resetting USB CopyNES as requested by plugin..."); ResetNES(RESET_COPYMODE); StatusText("Reloading plugin..."); LoadPlugin(plugin->file); StatusText("Rerunning plugin..."); RunCode(); rbyte = 0; if (!ReadByte((BYTE *)&rbyte) || !ReadByte((BYTE *)&rbyte+1)) { CloseStatus(); return FALSE; } rbyte /= 4; } } StatusPercent((s*100)/numk); DoEvents(); } StatusPercent(100); StatusText("...done!"); if (SaveCRC) fprintf(CRC,"%s%s %08X\n",filename,ext,GetCRC(DATA)); fclose(DATA); } if (SaveCRC) fclose(CRC); StatusText("Dump complete!"); StatusOK(); ResetNES(RESET_COPYMODE); { int scrn4 = (cmode & 0x2) >> 1; int mirror = (~cmode & 0x1); int mcon = (cmode & 0x4) >> 2; if (plugin->num == 9999) return TRUE; WriteNES(filename,mapper,battery,mirror,scrn4,nes2,wram,vram,submapper,0); if (MakeUnif == 1) WriteUNIF(filename,plugin->name,battery,mirror,scrn4,mcon); if (SaveFiles == 0) { unlink(strjoin3(fnamebuf,Path_CHR,filename,".chr")); unlink(strjoin3(fnamebuf,Path_PRG,filename,".prg")); } } return TRUE; }
void PFO_2DTableHistogram:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusOK()) cursorReport->ReportTitleSetup(GetID()); }
void DFO_TableHistogram:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusOK()) DoHistogram(*selectedColData); }
void DFO_TableColumnCorrelation:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; xcolumnIDDO.SetValueLabel(inputData->GetTitle(selectedCol)); ycolumnIDDO.SetValueLabel(inputData->GetTitle(selectedYCol)); const SC_DoubleArray& xIn = *selectedColData; const SC_DoubleArray& yIn = inputData->dataTable[selectedYCol]; SC_DoubleArray& xCorr = outputDataDC.xData; SC_DoubleArray& yCorr = outputDataDC.yData; xCorr.Alloc(xIn.Size()); yCorr.Alloc(xIn.Size()); int nOK = 0; int i; for (i = 0; i < xIn.Size(); i++) { double nextX = xIn[i]; double nextY = yIn[i]; if (RealIsNull(nextX) || RealIsNull(nextY)) continue; if (logX) { if (nextX < stdEps) continue; nextX = log10(nextX); } if (logY) { if (nextY < stdEps) continue; nextY = log10(nextY); } xCorr[nOK] = nextX; yCorr[nOK++] = nextY; } if (nOK < 2) { SetObjErrMsg("Less than two points to correlate"); return; } xCorr.SetSize(nOK); yCorr.SetSize(nOK); pearsonRDO.InitLabelAndValue(PearsonR(xCorr, yCorr)); spearmanRDO.InitLabelAndValue(SpearmanR(xCorr, yCorr)); // make correlation line DC_Curve corrLine; corrLine.curveType = Curve::ctPolynomial; corrLine.polyOrder = 1; SC_SetupErr crvErr; outputLineDC.CreateFrom(xCorr, yCorr); if (!corrLine.CreateCurve(outputLineDC, crvErr)) { SetObjErrMsg(crvErr.GetErrorText()); return; } outputLineDC.xData.Sort(true); corrLine.GetCurveY(outputLineDC.xData, outputLineDC.yData); // unlog data if (logX) { outputLineDC.xData.InvLog10(); outputDataDC.xData.InvLog10(); } if (logY) { outputLineDC.yData.InvLog10(); outputDataDC.yData.InvLog10(); } lineSlopeDO.InitLabelAndValue(corrLine.GetPolyCoefficients()[1]); lineYInterceptDO.InitLabelAndValue(corrLine.GetPolyCoefficients()[0]); }
void DFO_TableCalibrationStatistics:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; const SC_DoubleArray& xIn = *selectedColData; const SC_DoubleArray& yIn = inputData->dataTable[selectedYCol]; double sumRes = 0.0; double absRes = 0.0; double sumSqr = 0.0; double maxRes, minRes, maxY, minY; int numRes = 0; for (int i = 0; i < xIn.Size(); i++) { double nextX = xIn[i]; double nextY = yIn[i]; if (RealIsNull(nextX) || RealIsNull(nextY)) continue; double currRes = nextX - nextY; if (numRes == 0) { maxRes = currRes; minRes = currRes; maxY = nextY; minY = nextY; } else { maxRes = DMax(maxRes, currRes); minRes = DMin(minRes, currRes); maxY = DMax(maxY, nextY); minY = DMin(minY, nextY); } numRes++; absRes += fabs(currRes); sumRes += currRes; sumSqr += Sqr(currRes); } if (numRes < 2) { SetObjErrMsg("Less than two points to calculate statistics for"); return; } maxOverPredictionDO.InitLabelAndValue(maxRes); maxUnderPredictionDO.InitLabelAndValue(-minRes); averageResidualDO.InitLabelAndValue(sumRes/double(numRes)); averageAbsResidualDO.InitLabelAndValue(absRes/double(numRes)); numMeasurementsDO.InitLabelAndValue(double(numRes)); normalizedResidualRMSDO.InitLabelAndValue(0.0); if (sumSqr > 0.0) { double rms = sqrt(sumSqr/double(numRes)); residualRMSDO.InitLabelAndValue(rms); double dy = maxY - minY; if (dy > 0.0) normalizedResidualRMSDO.InitLabelAndValue(rms / dy * 100.0); } else { residualRMSDO.InitLabelAndValue(0.0); } correlationCoefficientDO.InitLabelAndValue(PearsonR(xIn, yIn)); }