예제 #1
0
 public static extern int CR_query_prog_info(int ProgType, ref CareRayInterface.ExpProgress expProg);
예제 #2
0
        private void btnBuildGainSeq_Click(object sender, EventArgs e)
        {
            if (tbDoseRate_Image.Text.Trim() == "")
            {
                cls_MessageBox.Show("Please input dose rate.");
                return;
            }

            List <ImageObject> images = new List <ImageObject>();

            foreach (int i in userControlMutiDicomImages.SelectList)
            {
                images.Add(captureImagesNow[i]);
            }
            if (images.Count <= 0)
            {
                cls_MessageBox.Show("Please select images.");
                return;
            }



            if (this.ImgCapture is CaptureCareRay)
            {
                //string path = new string((this.ImgCapture as CaptureCareRay).cal_params.gain_image_dir);
                string path = @"D:\CareRayCalImgs\C12140510-003\GainImage\";
                //Console.WriteLine(path);
                //path = path.Replace("\\","\\\\");
                Console.WriteLine(path);
                if (!Directory.Exists(path))
                {
                    //Console.WriteLine("delete folder");
                    //Directory.Delete(path, true);
                    Console.WriteLine("create folder");
                    Directory.CreateDirectory(path);
                }

                for (int index = 0; index < images.Count; ++index)
                {
                    this.writeImageToDisk(path + (object)(index + 1) + ".raw", images[index].ImageData);
                }
                int index1 = CareRayInterface.CR_linatech_calibration();
                if (index1 != 0)
                {
                    Console.WriteLine("CR_linear_calibration error,  reason: " + CareRayErrors.CrErrStrList(index1));
                }
                else
                {
                    CareRayInterface.ExpProgress expProg = new CareRayInterface.ExpProgress();
                    do
                    {
                        int result = CareRayInterface.CR_query_prog_info((int)CareRayInterface.ProgType.CR_CAL_PROG, ref expProg);
                        if (0 == result)
                        {
                            if (1 == expProg.calComplete)
                            {
                                Console.WriteLine("gain cal successfully");
                                break;
                            }
                            if (0 != expProg.errorCode)
                            {
                                result = expProg.errorCode;
                                Console.WriteLine("fail to gain");
                                break;
                            }
                        }
                    } while (true);
                }
            }

            return;


            string sortgainfolder = CapturePub.SaveDFPath;// +DateTime.Now.ToString("yyyy.MM.dd.HHmmss");

            CapturePub.saveCaptrueValue(XmlField.SortGainFolder, sortgainfolder);
            string gainFolder = sortgainfolder + "\\gain";

            if (!Directory.Exists(gainFolder))
            {
                Directory.CreateDirectory(gainFolder);
            }
            if (!Directory.Exists(CapturePub.SaveDFPath + "\\offset"))
            {
                Directory.CreateDirectory(CapturePub.SaveDFPath + "\\offset");
            }
            images.Sort();
            List <ushort[, ]> dataList = new List <ushort[, ]>();

            foreach (ImageObject obj in images)
            {
                dataList.Add(obj.ImageData);
            }
            string doserate = tbDoseRate_Image.Text.Trim();
            string gainFile = "gain_" + DateTime.Now.ToString("yyyy.MM.dd.HHmmss")
                              + "_" + doserate + "cGy(min)_"
                              + getGainString((CapturePKI.ElectricCapacityMode)comboBoxGainMode_Image.SelectedIndex)
                              + "_" + dataList[0].GetLength(0) + "x" + dataList[0].GetLength(1) + ".his";
            string gain_fullPath = gainFolder + "\\" + gainFile;

            SaveasHisFile(gain_fullPath, dataList, 1000);
            CapturePub.saveCaptrueValue(XmlField.GainSeqFile_Image, gain_fullPath);

            if (ImgCapture is CapturePKI)
            {
                (ImgCapture as CapturePKI).SetLinkCorrection();
            }
            cls_MessageBox.Show("Create gain sequence successfully!");
        }