//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : Load
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override bool HLLoadRecipe(string strRecipePath, string strRecipeName)
        {
            bool bReturn = false;

            do
            {
                string strFileName = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("PMAlign{0}.VPP", m_iIndex);

                try {
                    m_objPMAlignTool = CogSerializer.LoadObjectFromFile(strFileName) as CogPMAlignTool;
                    // 처음이 느려서 한번찍어줌
                    //m_objPMAlignTool.Run();
                    //m_objFixtureTool.Run();
                    //                     m_objROI = ( CogRectangleAffine )m_objPMAlignTool.SearchRegion;
                    //                     m_objTrainRegion = ( CogRectangleAffine )m_objPMAlignTool.Pattern.TrainRegion;
                    //                     m_objTrainedImage = ( CogImage8Grey )m_objPMAlignTool.Pattern.TrainImage;
                    //
                    //                     m_objROI.Color = CogColorConstants.Blue;
                    //                     m_objTrainRegion.Color = CogColorConstants.Red; m_objTrainRegion.LineStyle = CogGraphicLineStyleConstants.Dot;
                } catch (System.Exception ex) {
                    Trace.WriteLine(ex.Message + " -> " + ex.StackTrace);
                    MakeErrorMessage("HLLoadRecipe", 5203, ex.Message);
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Beispiel #2
0
 public bool init(int amountOfVpps, List <string> vpppath, List <CogRecordDisplay> cogRecordDisplayin = null)
 {
     if (null == vpppath)
     {
         return(false);
     }
     try
     {
         for (int i = 0; i < amountOfVpps; i++)
         {
             if (null == vpppath[i])
             {
                 return(false);
             }
             else
             {
                 myJobManager[i]     = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath[i]);
                 myJob[i]            = myJobManager[i].Job(0);
                 myJobIndependent[i] = myJob[i].OwnedIndependent;
                 myJobManager[i].UserQueueFlush();
                 myJobManager[i].FailureQueueFlush();
                 myJobIndependent[i].RealTimeQueueFlush();
             }
         }
     }
     catch {}
     return(true);
 }
Beispiel #3
0
        private void InitializeJobManager()
        {
            SampleTextBox.Text =
                "This sample demonstrates how to load a persisted QuickBuild application and access " +
                "the results provided in the posted items (a.k.a. as user result queue)." +
                System.Environment.NewLine + System.Environment.NewLine +

                "The sample uses mySavedQB.vpp, which consists of a single Job that executes a " +
                "Blob tool with default parameters using a frame grabber provided image.  " +
                @"The provided .vpp file is configured to use ""VPRO_ROOT\images\pmSample.idb"" as the " +
                "source of images." +
                System.Environment.NewLine + System.Environment.NewLine +
                "To use:  Click the Run button or the Run Continuous button.  " +
                "The number of blobs will be displayed in the count text box " +
                "and the Blob tool input image will be displayed in the image display control.";

            //Depersist the QuickBuild session
            myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(
                Environment.GetEnvironmentVariable("VPRO_ROOT") +
                "\\Samples\\Programming\\QuickBuild\\mySavedQB.vpp");
            myJob            = myJobManager.Job(0);
            myIndependentJob = myJob.OwnedIndependent;

            //flush queues
            myJobManager.UserQueueFlush();
            myJobManager.FailureQueueFlush();
            myJob.ImageQueueFlush();
            myIndependentJob.RealTimeQueueFlush();

            // setup event handlers.  These are called when a result packet is available on
            // the User Result Queue or the Real-Time Queue, respectively.
            myJobManager.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(myJobManager_UserResultAvailable);
        }
        public void InitObject(MyDefine Common)
        {
            Common.Print_Infor();
            numPass    = Common.numOK;
            numFail    = Common.numNG;
            bUseCamera = Common.use_camera;


            mToolBlockProcess = CogSerializer.LoadObjectFromFile(Common.file_toolblock_process) as CogToolBlock;
            ToolBlock_PrintInfor(mToolBlockProcess);

            if (bUseCamera)
            {
                try
                {
                    mToolBlockAcq          = CogSerializer.LoadObjectFromFile(Common.file_toolblock_acq) as CogToolBlock;
                    mToolBlockAcq.Ran     += MToolBlockAcq_Ran;
                    mToolBlockAcq.Changed += MToolBlockAcq_Changed;
                    mToolBlockAcq.Running += MToolBlockAcq_Running;
                    ToolBlock_PrintInfor(mToolBlockAcq);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception {0}", e.ToString());
                }
            }
            else
            {
                //init mIFTool to get Image from database
                mIFTool.Operator.Open(Common.file_image_database, CogImageFileModeConstants.Read);
            }
        }
        /// <summary>
        /// Reload the vision tool
        /// </summary>
        public override void LoadVisionFile()
        {
            DisposeToolGroup();

            if (string.IsNullOrEmpty(VisionFile))
            {
                VisionFile = this.UniqueNames[1];
            }

            if (!VisionFile.Contains('\\'))
            {
                VisionFile = String.Format(@"{0}{1}.vpp", VisionFilesRootPath, VisionFile);
            }


            if (File.Exists(VisionFile))
            {
                // Load it
                try
                {
                    CogToolGroup = CogSerializer.LoadObjectFromFile(VisionFile) as CogToolGroup;
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Vision File load error");
                }
            }
            else
            {
                CogToolGroup = new CogToolGroup();
            }

            //_cogToolGroup.Ran += new EventHandler(OnRunComplete);
        }
Beispiel #6
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : Save
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override bool HLSaveRecipe(string strRecipePath, string strRecipeName)
        {
            bool bReturn = false;

            do
            {
                string[] strFileName = new string[( int )CResultData.enumLine.LINE_FINAL];
                strFileName[( int )CResultData.enumLine.LINE_VERTICAL] = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineVertical{0}.VPP", m_iIndex);
                strFileName[( int )CResultData.enumLine.LINE_HORIZON]  = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineHorizon{0}.VPP", m_iIndex);

                try {
                    for (int iLoopCount = 0; iLoopCount < ( int )CResultData.enumLine.LINE_FINAL; iLoopCount++)
                    {
                        CogSerializer.SaveObjectToFile(m_objFindLineTool[iLoopCount], strFileName[iLoopCount], typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.All);
                    }
                } catch (System.Exception ex) {
                    Trace.WriteLine(ex.Message + " -> " + ex.StackTrace);
                    MakeErrorMessage("HLLoadRecipe", 5404, ex.Message);
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Beispiel #7
0
        private void ImportToolsFromVppFile(string filePath)
        {
            CogToolGroup newToolGroup = CogSerializer.LoadObjectFromFile(filePath) as CogToolGroup;

            if (newToolGroup != null)
            {
                // It is a tool group
                foreach (ICogTool cogTool in newToolGroup.Tools)
                {
                    _cognexJob.CogToolGroup.Tools.Add(cogTool);
                }
            }
            else
            {
                ICogTool cogTool = CogSerializer.LoadObjectFromFile(filePath) as ICogTool;
                if (cogTool != null)
                {
                    // It is a tool
                    _cognexJob.CogToolGroup.Tools.Add(cogTool);
                }
                else
                {
                    // It is even not a tool group, probably a job
                    //throw new VisionSystemException("Unknown file format. Currently we accept only toolgroup and tool file");
                }
            }
            _toolGroupEdit.Refresh();
        }
Beispiel #8
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : Load
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override bool HLLoadRecipe(string strRecipePath, string strRecipeName)
        {
            bool bReturn = false;

            do
            {
                string[] strFileName = new string[( int )CResultData.enumLine.LINE_FINAL];
                strFileName[( int )CResultData.enumLine.LINE_VERTICAL] = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineVertical{0}.VPP", m_iIndex);
                strFileName[( int )CResultData.enumLine.LINE_HORIZON]  = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineHorizon{0}.VPP", m_iIndex);

                try {
                    for (int iLoopCount = 0; iLoopCount < ( int )CResultData.enumLine.LINE_FINAL; iLoopCount++)
                    {
                        m_objFindLineTool[iLoopCount] = CogSerializer.LoadObjectFromFile(strFileName[iLoopCount]) as CogFindLineTool;
                    }
                } catch (System.Exception ex) {
                    Trace.WriteLine(ex.Message + " -> " + ex.StackTrace);
                    MakeErrorMessage("HLLoadRecipe", 5403, ex.Message);
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Beispiel #9
0
        static bool loadManager(string vppPath)
        {
            if (manager != null)
            {
                unload();
            }

            if (!File.Exists(vppPath))
            {
                Console.WriteLine("file does not exist");
                return(false);
            }
            Console.WriteLine("loading...");
            try
            {
                manager = (CogJobManager)CogSerializer.LoadObjectFromFile(vppPath);
            }
            catch (Exception e)
            {
                Console.WriteLine("can not load: " + e.Message);
                return(false);
            }
            Console.WriteLine("loaded");
            listJobs();
            return(true);
        }
Beispiel #10
0
 // Load the vpp file of a CogBlockTool
 public static void load_vpp(string vppPath)
 {
     // Resources.ToolGroup == null if not load successfully
     Resources.ToolGroup = CogSerializer.LoadObjectFromFile(vppPath) as CogToolGroup;
     // If load vpp file successful
     if (Resources.ToolGroup != null)
     {
         // If a CogToolBlock is already defined in Resources.ToolGroup
         if (Resources.ToolGroup.Tools.Count > 0)
         {
             Resources.ToolBlock = Resources.ToolGroup.Tools[0] as CogToolBlock;
         }
         // else create a new toolBlock and let Resources.ToolBlock refer to it
         else
         {
             Resources.ToolGroup.Tools.Add(new CogToolBlock());
             Resources.ToolBlock = Resources.ToolGroup.Tools[0] as CogToolBlock;
         }
     }
     // If load vpp file fails, create a new CogToolGroup as well as the CogBlockTool within
     else
     {
         Resources.ToolGroup = new CogToolGroup();
         Resources.ToolGroup.Tools.Add(new CogToolBlock());
         Resources.ToolBlock = Resources.ToolGroup.Tools[0] as CogToolBlock;
     }
 }
Beispiel #11
0
        public Boolean LoadFromVPPFile(string FileName, CogRecordDisplay mCogRecordDisplay)//檔案參數載入
        {
            string ProcID       = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();
            string TempFileName = (string)FileName;

            try
            {
                //從CogTool裡面讀出來
                string       strFolderPath = @"D:\VPS_File\Product\PMA_Tool\" + @FileName + @"\";
                CogToolBlock ToolBlock1    = new CogToolBlock();

                FileName = strFolderPath + FileName + "_PMA.vpp";

                ToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(FileName);//開啟ToolBlock vpp檔案

                //依序載入
                mPMA_Tool = (CogPMAlignTool)ToolBlock1.Tools[TempFileName + "_PMA_Tool_"];
                this.ROI_Create(mCogRecordDisplay);

                SaveLog.Msg_("Data of PMA_Tool Loaded : " + @FileName);
                ToolBlock1 = null;

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("Load PMA_Tool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #12
0
        private async void Window_Initialized(object sender, EventArgs e)
        {
            _toolBlock = await Task.Run(() =>
                                        (CogToolBlock)CogSerializer.LoadObjectFromFile(_vppPath, typeof(BinaryFormatter)));

            _btnRunManually.IsEnabled = true;
        }
Beispiel #13
0
        /// <summary>
        /// This function is responsible for the initial setup of the app.
        /// It loads and prepares the saved QuickBuild app into a CogJobManager
        /// object, attaches event handlers to to interesting CogJobManager
        /// events, and sets up the CogDisplayStatusBar to reflect the status
        /// of the CogDisplay we are using.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            // Depersist the CogJobManager saved via QuickBuild
            myJobManager = CogSerializer.LoadObjectFromFile(
                Environment.GetEnvironmentVariable("VPRO_ROOT") +
                "\\Samples\\Programming\\QuickBuild\\advancedAppOne.vpp") as CogJobManager;

            // Initialize Variables
            myJob            = myJobManager.Job(0);
            myIndependentJob = myJob.OwnedIndependent;

            // Flush queues
            myJobManager.UserQueueFlush();
            myJobManager.FailureQueueFlush();
            myJob.ImageQueueFlush();
            myIndependentJob.RealTimeQueueFlush();

            // Register handler for Stopped event
            myJobManager.Stopped +=
                new CogJobManager.CogJobManagerStoppedEventHandler(
                    myJobManager_Stopped);

            // Register handler for UserResultAvailable event
            myJobManager.UserResultAvailable +=
                new CogJobManager.CogUserResultAvailableEventHandler(
                    myJobManager_UserResultAvailable);

            // Connect the status bar
            this.cogDisplayStatusBar1.Display = this.cogRecordDisplay1;
        }
Beispiel #14
0
        public bool SaveVpp(string strVppName)
        {
            try
            {
                // 2011.04.13
                //CogSerializer.SaveObjectToFile(m_cogtgType, strVppName, typeof(System.Runtime.Serialization.Formatters.Soap.SoapFormatter), CogSerializationOptionsConstants.Minimum);
                CogSerializer.SaveObjectToFile(m_cogtgType, strVppName, typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
// 2016.06.20
//#if !_USE_1Camera
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL && !_USE_FLIR && !_USE_1Camera)
                //** 2015.10.02 by kdi
                string strFolderName   = Path.GetDirectoryName(strVppName);
                string strOnlyFileName = Path.GetFileNameWithoutExtension(strVppName);
                string strExtName      = Path.GetExtension(strVppName);
                string strAcqVppName   = strFolderName + "\\" + strOnlyFileName + "_CAM" + strExtName;
                CogSerializer.SaveObjectToFile(m_cogtgType_Acq, strAcqVppName, typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
                //*/
#endif
                ReLoad();

                return(true);
            }
            catch
            {
                MessageBox.Show(strVppName + " File Save Error!");
                return(false);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Load the list of Project Files for Recipe
        /// </summary>

        public void LoadRecipe(string fileName, CameraLocation cameraLocation)
        {
            ToolBlockFileName = fileName;

            if (System.IO.File.Exists(ToolBlockFileName))
            {
                // upper as index 0
                this.cogToolRun      = CogSerializer.LoadObjectFromFile(fileName) as CogToolBlock;
                this.cogToolRun.Name = Path.GetFileNameWithoutExtension(fileName);
            }
            else
            {
                switch (cameraLocation)
                {
                case CameraLocation.InputStation:
                    Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for input station camera: [{0}]", fileName));
                    break;

                case CameraLocation.PrecisorStation:
                    Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for precisor station camera: [{0}]", fileName));
                    break;

                case CameraLocation.OutputStation:
                    Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for output station camera: [{0}]", fileName));
                    break;
                }
            }
        }
Beispiel #16
0
 /// <summary>
 /// Save CameraJob to Url
 /// </summary>
 /// <param name="url"></param>
 public void SaveJob(string url)
 {
     CogSerializer.SaveObjectToFile(AcqFifoTool.Subject as CogAcqFifoTool, url + "\\AqcTool.vpp");
     CogSerializer.SaveObjectToFile(CalibGridCBTool.Subject as CogCalibCheckerboardTool, url + "\\CalibTool.vpp");
     CogSerializer.SaveObjectToFile(PMAlignTool.Subject as CogPMAlignTool, url + "\\PMAlignTool.vpp");
     MessageBox.Show("Save Job Done! :)");
 }
Beispiel #17
0
        public bool LoadVpp(string strVppName) // load vpp file
        {
            try
            {
                m_cogtgType = CogSerializer.LoadObjectFromFile(strVppName) as Cognex.VisionPro.ToolGroup.CogToolGroup;
// 2016.06.20
//#if !_USE_1Camera
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL && !_USE_FLIR && !_USE_1Camera)
                //** 2015.10.02 by kdi
                string strFolderName   = Path.GetDirectoryName(strVppName);
                string strOnlyFileName = Path.GetFileNameWithoutExtension(strVppName);
                string strExtName      = Path.GetExtension(strVppName);
                string strAcqVppName   = strFolderName + "\\" + strOnlyFileName + "_CAM" + strExtName;
                m_cogtgType_Acq = CogSerializer.LoadObjectFromFile(strAcqVppName) as Cognex.VisionPro.ToolGroup.CogToolGroup;
                //*/
#endif
                return(true);
            }
            catch
            {
                // 2014.07.15
                AUtil.TopMostMessageBox.Show(strVppName + " File Load Error!");
                return(false);
            }
        }
Beispiel #18
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\tool.vpp"))
     {
         blob = CogSerializer.LoadObjectFromFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\tool.vpp") as CogBlobTool;
     }
 }
Beispiel #19
0
        public Boolean LoadFromVPPFile(string FileName)//檔案參數載入
        {
            string ProcID       = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();
            string TempFileName = (string)FileName;

            try
            {
                //從CogTool裡面讀出來
                string       strFolderPath = @"D:\VPS_File\Product\FindCircleTool\" + @FileName + @"\";
                CogToolBlock ToolBlock1    = new CogToolBlock();

                FileName = strFolderPath + FileName + "_FCT.vpp";

                ToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(FileName);//開啟ToolBlock vpp檔案

                //依序載入
                mFindCircleTool = (CogFindCircleTool)ToolBlock1.Tools[TempFileName + "_FindCircleTool_"];
                mFindCircleTool.Run();

                SaveLog.Msg_("Data of Find Circle Tool Loaded : " + @FileName);
                ToolBlock1 = null;

                FindCircleTool_Status = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("Save FindCircleTool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                FindCircleTool_Status = false;
                return(false);
            }
        }
Beispiel #20
0
 private void FrmToolBlock_ToolBlockSave(int toolBlockId, CogToolBlock editTool, CogToolBlock backupTool, bool save)
 {
     if (save)
     {
         processToolBlock = editTool;
         CogSerializer.SaveObjectToFile(processToolBlock, GetValue("ProcessVppPath"));
     }
 }
Beispiel #21
0
 private void LoadCameraJobFromUrl()
 {
     cogAcqFifoEdit.Subject     = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\AcqTool.vpp") as CogAcqFifoTool;
     cogImageFileTool.Subject   = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\ImageFileTool.vpp") as CogImageFileTool;
     pmAlignToolEdit.Subject    = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\AlignTool.vpp") as CogPMAlignTool;
     cogFixtureTool.Subject     = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\FixtureTool.vpp") as CogFixtureTool;
     sharpnessToolEdit1.Subject = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\SharpnessTool1.vpp") as CogImageSharpnessTool;
     sharpnessToolEdit2.Subject = CogSerializer.LoadObjectFromFile(urlCameraJob + "\\SharpnessTool2.vpp") as CogImageSharpnessTool;
 }
Beispiel #22
0
 public void SaveCameraJobToUrl()
 {
     CogSerializer.SaveObjectToFile(cogAcqFifoEdit.Subject, urlCameraJob + "\\AcqTool.vpp");
     CogSerializer.SaveObjectToFile(cogImageFileTool.Subject, urlCameraJob + "\\ImageFileTool.vpp");
     CogSerializer.SaveObjectToFile(pmAlignToolEdit.Subject, urlCameraJob + "\\AlignTool.vpp");
     CogSerializer.SaveObjectToFile(cogFixtureTool.Subject, urlCameraJob + "\\FixtureTool.vpp");
     CogSerializer.SaveObjectToFile(sharpnessToolEdit1.Subject, urlCameraJob + "\\SharpnessTool1.vpp");
     CogSerializer.SaveObjectToFile(sharpnessToolEdit2.Subject, urlCameraJob + "\\SharpnessTool2.vpp");
     SaveSharpnessSettings();
 }
Beispiel #23
0
 private void button2_Click(object sender, EventArgs e)
 {
     // CogSerializer.SaveObjectToFile(toolBlock,@"C:\PROJECTS\Stahli.Net\Bin\Debug\CognexStahli\Camera1.vpp");
     CogSerializer.SaveObjectToFile(toolBlock, System.IO.Directory.GetCurrentDirectory() + "\\CognexStahli\\Camera1.vpp");
     cogAcqTool                = cogToolBlockEditV21.Subject.Tools["CogAcqFifoTool1"] as CogAcqFifoTool;
     calbCheckerBoard          = cogToolBlockEditV21.Subject.Tools["CogCalibCheckerboardTool1"] as CogCalibCheckerboardTool;
     CalibNPointTool           = cogToolBlockEditV21.Subject.Tools["CogCalibNPointToNPointTool1"] as CogCalibNPointToNPointTool;
     cogPMAlignTool            = cogToolBlockEditV21.Subject.Tools["CogPMAlignTool1"] as CogPMAlignTool;
     cogPMAlignTool.InputImage = CalibNPointTool.OutputImage as CogImage8Grey;
 }
Beispiel #24
0
        /*
         * public void Save_Json(string jCategory, string jVarName, object jObj)
         * {
         *  System.Type type = jObj.GetType();
         *  string TypeName = type.FullName;
         *
         *
         *  // Main Recipe File
         *  var jsonFile = new JObject();
         *
         *  // Recipe File 내에서 구분
         *  var jPart = new JObject();
         *
         *  if (TypeName.Contains("Int16"))
         *      jPart.Add(jVarName, (Int16) jObj);
         *  else if (TypeName.Contains("Int32"))
         *      jPart.Add(jVarName, (Int32)jObj);
         *  else if (TypeName.Contains("Int64"))
         *      jPart.Add(jVarName, (Int64)jObj);
         *  else if (TypeName.Contains("Double"))
         *      jPart.Add(jVarName, (Double)jObj);
         *  else if (TypeName.Contains("String"))
         *      jPart.Add(jVarName, (string)jObj);
         *
         *  // 구분된 Recipe 저장 내용들을 Main Recipe File 에 저장
         *  jsonFile.Add(jCategory, jPart);
         *
         *  string sjsonFile = jsonFile.ToString();
         *
         *  string FilePath = "D:\\test.json";
         *
         *  System.IO.File.WriteAllText(FilePath, sjsonFile);
         * }
         */

        /*
         * public void Load_Json(string jCategory, string jVarName, out object jObj)
         * {
         *  jObj = null; // 초기화
         *
         *  System.Type type = jObj.GetType();
         *  string TypeName = type.FullName;
         *
         *
         *  string FilePath = "D:\\test.json";
         *  if (!System.IO.File.Exists(FilePath))
         *      return;
         *
         *  // Main Recipe File
         *  JObject jsonFile = JObject.Parse(File.ReadAllText(FilePath));
         *
         *  // Recipe File 내에서 구분
         *  // 1. Recipe
         *  JObject jPart = (JObject)jsonFile["jCategory"];
         *
         *  if (TypeName.Contains("Int16") || TypeName.Contains("Int32") || TypeName.Contains("Int64"))
         *      jObj = jPart[jVarName].ToString() == "" ? 0 : int.Parse(jPart[jVarName].ToString());
         *
         *  else if (TypeName.Contains("Double"))
         *      jObj = jPart[jVarName].ToString() == "" ? 0 : Double.Parse(jPart[jVarName].ToString());
         *
         *  else if (TypeName.Contains("String"))
         *      jObj = jPart[jVarName].ToString();
         * }
         */



        public void Save_Vpp(Object CogObj, string FilePath)
        {
            try
            {
                CogSerializer.SaveObjectToFile(CogObj, FilePath);
            }
            catch (Exception e)
            {
            }
        }
Beispiel #25
0
        private void btnSaveVPP_Click(object sender, EventArgs e)
        {
            string strFName;

            strFName = ASDef._INI_PATH + "\\Img\\" + AVisionProBuild.ToolName(m_nType, m_nPoint, m_aCalibCheckerboard.Name) + ".bmp";
            FileInfo fileDel = new FileInfo(strFName);

            if (fileDel.Exists)
            {
                fileDel.Delete();
            }

            // 2017.06.08
            //m_aCalibCheckerboard.Name = AVisionProBuild.MakeName("CalibCheckerboard", DateTime.Now);

            AVisionProBuild.SaveVpp(m_nType);

            strFName = ASDef._INI_PATH + "\\Img\\" + AVisionProBuild.ToolName(m_nType, m_nPoint, m_aCalibCheckerboard.Name) + ".bmp";
            // 2012.01.17
            //AVisionProBuild.SaveImg(strFName, cogDisplay);
            AVisionProBuild.SaveImg(strFName, m_cogImage);

            // 2012.04.24
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL)
            /* 2015.10.18
             * if (m_aAcqFifo.AcqFifoTool.Operator != null)
             * {
             *  // 2013.05.15
             *  if (m_aAcqFifo.GetFrameGrabberName().Contains("acA2500"))
             *  {
             *      AIniExposure aIniExposure = new AIniExposure(m_nType, m_nPoint);
             *      aIniExposure.m_nExposure = Convert.ToInt64(txtExposure.Text);
             *      aIniExposure.Write();
             *  }
             * }
             */
#elif _USE_BASLER_PYLON
            AIniExposure aIniExposure = new AIniExposure(m_nType, m_nPoint);
            // 2015.12.09
            aIniExposure.m_dExposure = Convert.ToDouble(txtExposure.Text);
            if (aIniExposure.m_dExposure > 0)
            {
                aIniExposure.Write();
            }
#endif
            // 2014.10.30
#if _USE_1Camera
            CogSerializer.SaveObjectToFile(m_aAcqFifo.GetTool(), ASDef._INI_PATH + "\\1Camera.vpp", typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
#endif

            //MessageBox.Show("Tool is Saved!");
            // 2013.12.02
            MessageBox.Show(AUtil.GetXmlLanguage("Tool_is_Saved"));
            btnSaveVPP.Enabled = false;
        }
Beispiel #26
0
        public FrmLoadTray()
        {
            visionActionDelegate = new VisionActionDelegate(VisionActionDelegateFunc);
            InitializeComponent();

            //Add any initialization after the InitializeComponent() call
            cogToolBlockEditV21.LocalDisplayVisible = false;
            mIFTool = new CogImageFileTool();
            //mIFTool.Operator.Open(Environment.GetEnvironmentVariable("VPRO_ROOT") + @"\images\coins.idb", CogImageFileModeConstants.Read);
            mAcqTool = new CogAcqFifoTool();

            toolBlock = cogToolBlockEditV21.Subject;
            try
            {
                // toolBlock = CogSerializer.LoadObjectFromFile(@"C:\PROJECTS\Stahli.Net\Bin\Debug\CognexStahli\Camera1.vpp") as CogToolBlock;  //Need to upload insernt name as given by asaf
                toolBlock = CogSerializer.LoadObjectFromFile(System.IO.Directory.GetCurrentDirectory() + "\\CognexStahli\\Camera1.vpp") as CogToolBlock; //Need to upload insernt name as given by asaf
                //if it is new insert, upload a defult
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tool block is error");
            }
            cogToolBlockEditV21.Subject         = toolBlock;
            cogToolBlockEditV21.Subject.Ran    += new EventHandler(Subject_Ran);
            cogToolBlockEditV21.SubjectChanged += new EventHandler(cogToolBlockEditV21_SubjectChanged);
            foreach (ICogTool tool in toolBlock.Tools)
            {
                calbCheckerBoard = tool as CogCalibCheckerboardTool;
                if (calbCheckerBoard != null)
                {
                    break;
                }
            }

            foreach (ICogTool tool in toolBlock.Tools)
            {
                CalibNPointTool = tool as CogCalibNPointToNPointTool;
                if (CalibNPointTool != null)
                {
                    break;
                }
            }

            foreach (ICogTool tool in toolBlock.Tools)
            {
                cogPMAlignTool = tool as CogPMAlignTool;
                if (cogPMAlignTool != null)
                {
                    break;
                }
            }

            loadOrderDataDelegate = new LoadOrderDataDelegate(LoadOrderDataDelegateFunc);
            // LoadPatternFromFile();   //13.07.15 (Ziv)
        }
Beispiel #27
0
 //重写加载Job
 private void LoadCogJobManager(string path)
 {
     try
     {
         Class1.CogJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(Application.StartupPath + path);
     }
     catch (FileNotFoundException f)
     {
         MessageBox.Show(f.FileName + "该路径下没有此文件");
     }
 }
Beispiel #28
0
        public MainWindow()
        {
            InitializeComponent();

            fifo         = CogSerializer.LoadObjectFromFile(@"C:\Users\jkhong\Desktop\fifo.vpp") as CogAcqFifoTool;
            IsFreeRun    = true;
            textBox.Text = "FreeRun";

            display   = new CogDisplay();
            WFH.Child = display;
        }
Beispiel #29
0
 public static bool SaveVpp(object tool, string path)
 {
     try
     {
         CogSerializer.SaveObjectToFile(tool, path, typeof(BinaryFormatter), CogSerializationOptionsConstants.Minimum);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #30
0
 public static void LoadVpp()
 {
     try
     {
         block = (CogToolBlock)CogSerializer.LoadObjectFromFile(vppFilePath);
         f1.textBox2.AppendText("工具组加载成功\r\n");
     }
     catch (Exception x)
     {
         f1.textBox2.AppendText("工具加载失败:" + x.Message);
     }
 }