Пример #1
0
 private void AddCommonInfo2RunResult(RunResult runResult)
 {
     runResult.buffySlice = pipettingSetting.dstbuffySlice;//ResultReader.Instance.HasBuffyCoat() ? 1 : 0;
     runResult.buffyVolume = pipettingSetting.buffyVolume;
     runResult.plasmaVolume = pipettingSetting.plasmaGreedyVolume;
     runResult.plasmaTotalSlice = pipettingSetting.dstPlasmaSlice;
 }
Пример #2
0
 private void AddEachSampleInfo2RunResult(int srcRackIndex, int startSampleIndex,List<DetectedHeight> heightsThisTime, RunResult runResult)
 {
     double r = pipettingSetting.r_mm;
     double area = 3.14159265 * r * r;
     for (int i = 0; i < heightsThisTime.Count; i++)
     {
         double z1 = heightsThisTime[i].Z1;
         double z2 = heightsThisTime[i].Z2;
         double totalPlasmaVolume = (z1 - z2 - pipettingSetting.safeDelta) * area;
         int plasmaSlice = pipettingSetting.dstPlasmaSlice;
         if (pipettingSetting.plasmaGreedyVolume != 0)
         {
             int maxPlasmaSlice = (int)Math.Ceiling(totalPlasmaVolume / pipettingSetting.plasmaGreedyVolume);
             plasmaSlice = Math.Min(plasmaSlice, maxPlasmaSlice);
         }
         int startSampleID = srcRackIndex * labwareSettings.sourceWells + i + startSampleIndex + 1;
         
         runResult.plasmaRealSlices.Add(plasmaSlice);
         //sw.WriteLine(string.Format("{0};{1};{2};{3}{4}", startSampleID, plasmaSlice, pipettingSetting.dstPlasmaSlice, buffySlice, pipettingSetting));
     }
 }
Пример #3
0
 private void SaveRunResult(RunResult runResult)
 {
     string sRunResultPath = Utility.GetOutputFolder() + "runResult.xml";
     if (File.Exists(sRunResultPath))
         File.Delete(sRunResultPath);
     
     string sContent = Utility.Serialize(runResult) ;
     File.WriteAllText(sRunResultPath, sContent);
 }
Пример #4
0
        public bool DoJob()
        {
            SettingsHelper settingHelper = new SettingsHelper();
            log.Info("load settings");
            settingHelper.LoadSettings(ref pipettingSetting, ref labwareSettings);

            heights = ResultReader.Instance.Read();
            log.Info("read heights");

            //PreparePlasmaDestPositions();
            positionGenerator = new PositionGenerator(pipettingSetting, labwareSettings,heights.Count);
            string errMsg = "";
            
            bool bok = settingHelper.IsValidSetting(labwareSettings,pipettingSetting,ref errMsg);
            if (!bok)
            {
                throw new Exception("Invalid setting:" + errMsg);
            }

            int maxSampleAllowed = positionGenerator.AllowedSamples();
            if (maxSampleAllowed < heights.Count)
                throw new Exception(string.Format("max allowed sample is: {0}",maxSampleAllowed));
            
            string sOutput = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\output\\";
            //create folders
            if (!Directory.Exists(sOutput))
                Directory.CreateDirectory(sOutput);
            
            RunResult runResult = new RunResult();
            int sourceRackCount = (int)Math.Ceiling((double)heights.Count / labwareSettings.sourceWells);
            WriteRacksCount(sourceRackCount);
            string sOrgOutPut = sOutput;
            for (int srcRack = 0; srcRack < sourceRackCount; srcRack++)
            {
                sOutput = sOrgOutPut + "\\srcRack" + (srcRack + 1).ToString() + "\\";
                if (!Directory.Exists(sOutput))
                    Directory.CreateDirectory(sOutput);
               

                int thisRackSamples = srcRack == sourceRackCount - 1 ? (heights.Count - srcRack * labwareSettings.sourceWells) : labwareSettings.sourceWells;
                Utility.Write2File(sOutput + "totalSample.txt", thisRackSamples.ToString());
                int batchNum = (int)Math.Ceiling((double)thisRackSamples / labwareSettings.tipCount);
                Utility.Write2File(sOutput + "batchCount.txt", batchNum.ToString());
                for (int startSample = 0; startSample < thisRackSamples; startSample += labwareSettings.tipCount)
                {
                    List<DetectedHeight> heightsThisTime = new List<DetectedHeight>();
                    for (int tip = 0; tip < labwareSettings.tipCount; tip++)
                    {
                        if (tip + startSample >= thisRackSamples)
                            break;
                        heightsThisTime.Add(heights[srcRack*labwareSettings.sourceWells+ startSample + tip]);
                    }
                    GenerateForBatch(sOutput,srcRack, startSample, heightsThisTime);
                    AddEachSampleInfo2RunResult(srcRack, startSample,heightsThisTime, runResult);
                }
            }

            AddCommonInfo2RunResult(runResult);
            SaveRunResult(runResult);
            //runResultSw.Close();
            return true;
        }
Пример #5
0
        public bool DoJob()
        {
            detectInfos  = ResultReader.Instance.Read();
            patientInfos = ResultReader.Instance.ReadPatientInfos();
            if (patientInfos != null)
            {
                patientInfos = patientInfos.Take(detectInfos.Count).ToList();
                Console.WriteLine(string.Format("{0} samples", patientInfos.Count));
            }

            if (GlobalVars.Instance.TrackBarcode)
            {
                barcodeTracker = new BarcodeTracker(pipettingSettings, labwareSettings, patientInfos);
            }
            log.Info("read heights");
            mappingCalculator = new MappingCalculator(Settings.Utility.GetExeFolder() + Settings.stringRes.calibFileName);
            //PreparePlasmaDestPositions();
            positionGenerator = new PositionGenerator(pipettingSettings, labwareSettings, detectInfos.Count);
            int maxSampleAllowed = positionGenerator.AllowedSamples();

            if (maxSampleAllowed < detectInfos.Count)
            {
                throw new Exception(string.Format("max allowed sample is: {0}", maxSampleAllowed));
            }

            string sOutput         = Utility.GetOutputFolder();
            int    sourceRackCount = (int)Math.Ceiling((double)detectInfos.Count / labwareSettings.sourceWells);

            WriteRacksCount(sourceRackCount);
            string    sOrgOutPut = sOutput;
            RunResult runResult  = new RunResult();

            for (int srcRack = 0; srcRack < sourceRackCount; srcRack++)
            {
                sOutput = sOrgOutPut + "\\srcRack" + (srcRack + 1).ToString() + "\\";
                if (!Directory.Exists(sOutput))
                {
                    Directory.CreateDirectory(sOutput);
                }

                int thisRackSamples = srcRack == sourceRackCount - 1 ? (detectInfos.Count - srcRack * labwareSettings.sourceWells) : labwareSettings.sourceWells;
                Utility.Write2File(sOutput + "totalSample.txt", thisRackSamples.ToString());
                int batchNum = (int)Math.Ceiling((double)thisRackSamples / labwareSettings.tipCount);
                Utility.Write2File(sOutput + "batchCount.txt", batchNum.ToString());
                for (int startSample = 0; startSample < thisRackSamples; startSample += labwareSettings.tipCount)
                {
                    List <DetectedInfo> heightsThisTime = new List <DetectedInfo>();
                    for (int tip = 0; tip < labwareSettings.tipCount; tip++)
                    {
                        if (tip + startSample >= thisRackSamples)
                        {
                            break;
                        }
                        heightsThisTime.Add(detectInfos[srcRack * labwareSettings.sourceWells + startSample + tip]);
                    }
                    GenerateForBatch(sOutput, srcRack, startSample, heightsThisTime);
                    AddEachSampleInfo2RunResult(srcRack, startSample, heightsThisTime, runResult);
                }
            }
            if (GlobalVars.Instance.TrackBarcode)
            {
                barcodeTracker.WriteResult();
            }

            AddCommonInfo2RunResult(runResult);
            SaveRunResult(runResult);
            Thread.Sleep(1000);
            return(true);
        }
Пример #6
0
        private void AddEachSampleInfo2RunResult(int srcRackIndex, int startSampleIndex, List <DetectedInfo> heightsThisTime, RunResult runResult)
        {
            double area = mappingCalculator.GetArea();

            for (int i = 0; i < heightsThisTime.Count; i++)
            {
                double z1 = heightsThisTime[i].Z1;
                double z2 = heightsThisTime[i].Z2;

                double totalPlasmaVolume = mappingCalculator.GetVolumeFromHeight(z1) -
                                           mappingCalculator.GetVolumeFromHeight(z2) - pipettingSettings.safeDelta * area;

                int plasmaSlice = pipettingSettings.dstPlasmaSlice;
                if (pipettingSettings.plasmaGreedyVolume != 0)
                {
                    int maxPlasmaSlice = (int)Math.Ceiling(totalPlasmaVolume / pipettingSettings.plasmaGreedyVolume);
                    plasmaSlice = Math.Min(plasmaSlice, maxPlasmaSlice);
                }
                int startSampleID = srcRackIndex * labwareSettings.sourceWells + i + startSampleIndex + 1;

                runResult.plasmaRealSlices.Add(plasmaSlice);
                //sw.WriteLine(string.Format("{0};{1};{2};{3}{4}", startSampleID, plasmaSlice, pipettingSetting.dstPlasmaSlice, buffySlice, pipettingSetting));
            }
        }
Пример #7
0
        public bool DoJob()
        {
            detectInfos = ResultReader.Instance.Read();
            patientInfos = ResultReader.Instance.ReadPatientInfos();
            if(GlobalVars.Instance.TrackBarcode)
                barcodeTracker = new BarcodeTracker(pipettingSetting, labwareSettings, patientInfos);
            log.Info("read heights");
            mappingCalculator = new MappingCalculator(Settings.Utility.GetExeFolder() + Settings.stringRes.calibFileName);
            //PreparePlasmaDestPositions();
            positionGenerator = new PositionGenerator(pipettingSetting, labwareSettings,detectInfos.Count);
            int maxSampleAllowed = positionGenerator.AllowedSamples();
            if (maxSampleAllowed < detectInfos.Count)
                throw new Exception(string.Format("max allowed sample is: {0}",maxSampleAllowed));

            string sOutput = Utility.GetOutputFolder();
            int sourceRackCount = (int)Math.Ceiling((double)detectInfos.Count / labwareSettings.sourceWells);
            WriteRacksCount(sourceRackCount);
            string sOrgOutPut = sOutput;
            RunResult runResult = new RunResult();
            for (int srcRack = 0; srcRack < sourceRackCount; srcRack++)
            {
                sOutput = sOrgOutPut + "\\srcRack" + (srcRack + 1).ToString() + "\\";
                if (!Directory.Exists(sOutput))
                    Directory.CreateDirectory(sOutput);

                int thisRackSamples = srcRack == sourceRackCount - 1 ? (detectInfos.Count - srcRack * labwareSettings.sourceWells) : labwareSettings.sourceWells;
                Utility.Write2File(sOutput + "totalSample.txt", thisRackSamples.ToString());
                int batchNum = (int)Math.Ceiling((double)thisRackSamples / labwareSettings.tipCount);
                Utility.Write2File(sOutput + "batchCount.txt", batchNum.ToString());
                for (int startSample = 0; startSample < thisRackSamples; startSample += labwareSettings.tipCount)
                {
                    List<DetectedInfo> heightsThisTime = new List<DetectedInfo>();
                    for (int tip = 0; tip < labwareSettings.tipCount; tip++)
                    {
                        if (tip + startSample >= thisRackSamples)
                            break;
                        heightsThisTime.Add(detectInfos[srcRack*labwareSettings.sourceWells+ startSample + tip]);
                    }
                    GenerateForBatch(sOutput,srcRack, startSample, heightsThisTime);
                    AddEachSampleInfo2RunResult(srcRack, startSample, heightsThisTime, runResult);
                }
            }
            if(GlobalVars.Instance.TrackBarcode)
                barcodeTracker.WriteResult();

            AddCommonInfo2RunResult(runResult);
            SaveRunResult(runResult);
            return true;
        }