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); } }
public void Save_Parameter(MyDefine common) { // serialize JSON directly to a file Console.WriteLine(Utils.file_config); using (StreamWriter file = File.CreateText(Utils.file_config)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, common); } }
public bool Load_Parameter(ref MyDefine common) { //common = new MyDefine(); if (!File.Exists(Utils.file_config)) { Console.WriteLine($"file {Utils.file_config} not found..."); return(false); } using (StreamReader file = File.OpenText(Utils.file_config)) { JsonSerializer serializer = new JsonSerializer(); common = (MyDefine)serializer.Deserialize(file, typeof(MyDefine)); } //common.Print_Infor(); Console.WriteLine($"file {Utils.file_config} load ok..."); return(true); }
public void UpdateData(MyDefine Common) { mToolBlockProcess = CogSerializer.LoadObjectFromFile(Common.file_toolblock_process) as CogToolBlock; mIFTool.Operator.Open(Common.file_image_database, CogImageFileModeConstants.Read); }