private void initialiseCache() { cache = new spectrumlet[cacheSize]; for (int i = 0; i < cache.Length; i++) { cache[i] = new spectrumlet(); } }
public void add(spectrumlet spec) { for (int i = cacheSize - 1; i > 0; i--) { cache[i] = cache[i - 1]; } cache[0] = spec; }
public object getSpectrum(int _scanNumber, ref int _cacheSize) { double[,] specFromCache = getSpectrumFromCache(_scanNumber); if (specFromCache != null) { return(specFromCache); } object myPeakFlags = null; int myArraySize = 0; object myMassList = null; double myCentroidPeakWidth = 0; #region GetMassListRangeFromScanNum usage // string bstrFiler = ""; // int nIntensityCutoffType = 0; // int intensityCutoffValue = 0; // int nMaxNumberOfPeaks = 0; // int bCentroidResult = 0; // double pdCentroidPeakWidth = 0; // object pvarMassList = 0; // object pvarPeakFlags = 0; // string szMassRange1 = ""; // int pnArraySize = 0; // rawFile.GetMassListRangeFromScanNum(ref _scanNumber, bstrFiler, nIntensityCutoffType, intensityCutoffValue, //nMaxNumberOfPeaks, bCentroidResult, ref pdCentroidPeakWidth, ref pvarMassList, ref pvarPeakFlags, //szMassRange1, ref pnArraySize); #endregion //long t1 = DateTime.Now.Ticks; try { rawFile.GetMassListFromScanNum(ref _scanNumber, "", 0, 0, 0, 0, ref myCentroidPeakWidth, ref myMassList, ref myPeakFlags, ref myArraySize); } catch (Exception ex) { if (ex.Message == "Exception of type 'System.OutOfMemoryException' was thrown.") { _cacheSize = sCache.lowerCacheSize(0.9); //MessageBox.Show("Memory is full, the spectrum cache will be lowered to " + // _cacheSize.ToString() + "."); //Application.DoEvents(); GC.Collect(); GC.WaitForPendingFinalizers(); rawFile.GetMassListFromScanNum(ref _scanNumber, "", 0, 0, 0, 0, ref myCentroidPeakWidth, ref myMassList, ref myPeakFlags, ref myArraySize); } else { MessageBox.Show("There was an error at " + System.Reflection.MethodInfo.GetCurrentMethod() + ".\n" + "Message was: " + ex.Message); Application.DoEvents(); } } //long t2 = DateTime.Now.Ticks; ////double milliseconds = (t2 - t1) / 10000.0; //StreamWriter w = new StreamWriter(@"D:\DATUMARO\trabajo\tareas en curso\tareas1 ug\pruebas QuiXtoQuiX\tiempos.txt", true); //w.WriteLine(string.Concat(t1, "\t", t2)); //w.Close(); spectrumlet speclet = new spectrumlet(); speclet.scanNumber = _scanNumber; speclet.spectrum = (double[, ])myMassList; sCache.add(speclet); return(myMassList); }