public static void MyClassInitialize(TestContext testContext)
 {
     string sFile = Utility.GetExeFolder() + "calibrations.xml";
     mappingCalculator = new MappingCalculator(sFile);
 }
Esempio n. 2
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);
        }
        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;
        }