public void Save() { if (FileSavePath != null) { AccessJosnSerializer.ObjectToJson(FileSavePath, this); } }
public override Object Read() { VisionCode2dParam tempvision2dCodeParam = null; string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; //tempvision2dCodeParam = (VisionCode2dParam)AccessXmlSerializer.XmlToObject(strPath, vision2dCodeParam.GetType()); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; Vision2dCode vision2DCode = (Vision2dCode)AccessJosnSerializer.JsonToObject(strPath, this.GetType()); if (vision2DCode == null || vision2DCode.vision2dCodeParam == null) { _logger.Warn(m_strStepName + ": 视觉处理项目加载失败,请检查"); MessageBox.Show(m_strStepName + ": 视觉处理项目加载失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } vision2dCodeParam = tempvision2dCodeParam = vision2DCode.vision2dCodeParam; string Mode2dcodePath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_data_code_model.dcm";; if (vision2dCodeParam != null && Mode2dcodePath != null && File.Exists(Mode2dcodePath)) { if (Mode2dCode != null) { HOperatorSet.ClearDataCode2dModel(Mode2dCode); } Mode2dCode = null; HOperatorSet.ReadDataCode2dModel(Mode2dcodePath, out Mode2dCode); if (Mode2dCode == null || Mode2dCode.Length <= 0) { _logger.Warn(m_strStepName + ": 2维码模板读取失败,请检查"); MessageBox.Show(m_strStepName + ": 2维码模板读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // MessageBox.Show(m_strStepName + ": 2维码模板读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (vision2dCodeParam != null && File.Exists(vision2dCodeParam.Mode2dcodeSearchPath)) { if (Mode2dCodeSearch != null && Mode2dCodeSearch.IsInitialized()) { Mode2dCodeSearch.Dispose(); } HOperatorSet.ReadRegion(out Mode2dCodeSearch, vision2dCodeParam.Mode2dcodeSearchPath); if (Mode2dCodeSearch == null || Mode2dCodeSearch.IsInitialized()) { _logger.Warn(m_strStepName + ": 2维码搜索区域读取失败,请检查"); } // MessageBox.Show(m_strStepName + ": 2维码搜索区域读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { _logger.Warn(m_strStepName + ": 2维码搜索区域读取失败,请检查"); // MessageBox.Show(m_strStepName + ": 2维码搜索区域读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } GC.Collect(); return(vision2dCodeParam); }
public override object Read() { try { VisionFitCircleParam tempvisionFitCircleParam = null; string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; //tempvisionFitCircleParam = (VisionFitCircleParam)AccessXmlSerializer.XmlToObject(strPath, visionFitCircleParam.GetType()); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; VisionFitCircircle fitCircircle = (VisionFitCircircle)AccessJosnSerializer.JsonToObject(strPath, this.GetType()); if (fitCircircle != null && fitCircircle.visionFitCircleParam != null) { visionFitCircleParam = tempvisionFitCircleParam = fitCircircle.visionFitCircleParam; } else { _logger.Warn(m_strStepName + ": 视觉处理项目加载失败,请检查"); MessageBox.Show(m_strStepName + ": 视觉处理项目加载失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } return(visionFitCircleParam); //object obj = new object(); //string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; //AccessJosnSerializer.ObjectToJson(strPath,obj); } catch (Exception e) { _logger.Warn(m_strStepName + "读取失败:" + e.Message); } return(null); }
public override void Save() { string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; // AccessXmlSerializer.ObjectToXml(strPath, vision1dCodeParam); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; AccessJosnSerializer.ObjectToJson(strPath, this); }
public virtual void Save() { string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; AccessXmlSerializer.ObjectToXml(strPath, this); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; AccessJosnSerializer.ObjectToJson(strPath, this); }
public override void Save(string strPath) { string regionsavepath = strPath; //strPath = strPath + "\\" + m_strStepName + ".xml"; //AccessXmlSerializer.ObjectToXml(strPath, visionShapParam); AccessJosnSerializer.ObjectToJson(strPath, this); //SaveRegions(regionsavepath); }
public virtual Object Read() { string strPath = ""; strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; AccessJosnSerializer.ObjectToJson(strPath, this); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; return(AccessXmlSerializer.XmlToObject(strPath, this.GetType())); }
public override bool Save(string strpath) { if (AccessJosnSerializer.ObjectToJson(strpath, this)) { FilePath = strpath; return(true); } return(false); }
public object ReadObj() { object obj = AccessJosnSerializer.JsonToObject(@"E:\TorqueTest.json", typeof(RecordData)); if (obj != null) { recordData = (RecordData)obj; } return(obj); }
public override Object Read() { //string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; //blobParam = (BlobParam)AccessXmlSerializer.XmlToObject(strPath, blobParam.GetType()); string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; VisionBlob obj = (VisionBlob)AccessJosnSerializer.JsonToObject(strPath, this.GetType()); GC.Collect(); return(blobParam); }
public static SysFunParam Read() { object obj = new object(); obj = AccessJosnSerializer.JsonToObject(AppDomain.CurrentDomain.BaseDirectory + "SysFunConfig.json", typeof(SysFunParam)); if (obj != null) { sysFunParam = (SysFunParam)obj; return(sysFunParam); } return(null); }
public static DispCalibParam Read(string strFilePath) { DispCalibParam dispCalibParam = null; if (File.Exists(strFilePath)) { dispCalibParam = (DispCalibParam)AccessJosnSerializer.JsonToObject(strFilePath, typeof(DispCalibParam)); } else { dispCalibParam = new DispCalibParam(); } return(dispCalibParam); }
public override void Save(string strPath) { try { //if (visionFitCircleParam != null) // AccessXmlSerializer.ObjectToXml(strPath, visionFitCircleParam); AccessJosnSerializer.ObjectToJson(strPath, this); } catch (Exception e) { _logger.Warn(m_strStepName + "保存失败:" + e.Message); } }
public override void Save() { try { //string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; //if (visionFitCircleParam != null) // AccessXmlSerializer.ObjectToXml(strPath, visionFitCircleParam); string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + m_strStepName + "\\" + m_strStepName + ".json"; AccessJosnSerializer.ObjectToJson(strPath, this); } catch (Exception e) { _logger.Warn(m_strStepName + "保存失败:" + e.Message); } }
public override object Read(string strpath) { object t = null; t = AccessJosnSerializer.JsonToObject(strpath, GetType()); if (t != null && t is UsrShapePoint) { UsrShapePoint pt = (UsrShapePoint)t; X = pt.X; Y = pt.Y; FilePath = strpath; } return(null); }
public override object Read(string strpath) { object t = null; t = AccessJosnSerializer.JsonToObject(strpath, GetType()); if (t != null && t is UsrShapeRect) { UsrShapeRect pt = (UsrShapeRect)t; X1 = pt.X1; Y1 = pt.Y1; X2 = pt.X2; Y2 = pt.Y2; FilePath = strpath; } return(null); }
public override void Save() { //string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; //if (strSavePath != "") // strPath = strSavePath + "\\" + m_strStepName + ".xml"; //AccessXmlSerializer.ObjectToXml(strPath, visionShapParam); string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; if (strSavePath != "") { strPath = strSavePath + "\\" + m_strStepName + ".json"; } AccessJosnSerializer.ObjectToJson(strPath, this); // SaveRegions(); }
public override object Read(string strpath) { object t = null; //t = AccessXmlSerializer.XmlToObject(strpath, GetType()); t = AccessJosnSerializer.JsonToObject(strpath, GetType()); if (t != null && t is UsrShapeRect2) { UsrShapeRect2 pt = (UsrShapeRect2)t; CenterX = pt.CenterX; CenterY = pt.CenterY; Len1 = pt.Len1; Len2 = pt.Len2; Phi = pt.Phi; FilePath = strpath; } return(null); }
public override object Read(string strpath) { object t = null; //t = AccessXmlSerializer.XmlToObject(strpath, GetType()); t = AccessJosnSerializer.JsonToObject(strpath, GetType()); if (t != null && t is UsrShapeCircle) { UsrShapeCircle pt = (UsrShapeCircle)t; CircleCenterX = pt.CircleCenterX; CircleCenterY = pt.CircleCenterY; CircleRadius = pt.CircleRadius; CircleRadius = pt.CircleRadius; CircleStartAngle = pt.CircleStartAngle; CircleEndAngle = pt.CircleEndAngle; FilePath = strpath; } return(null); }
public override Object Read() { Code1dParam tempvision1dCodeParam = null; string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; // tempvision1dCodeParam = (Code1dParam)AccessXmlSerializer.XmlToObject(strPath, vision1dCodeParam.GetType()); strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; Vision1dCode vision1DCode = (Vision1dCode)AccessJosnSerializer.JsonToObject(strPath, this.GetType()); if (vision1DCode == null || vision1DCode.vision1dCodeParam == null) { _logger.Warn(m_strStepName + ": 视觉处理项目加载失败,请检查"); MessageBox.Show(m_strStepName + ": 视觉处理项目加载失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } vision1dCodeParam = tempvision1dCodeParam = vision1DCode.vision1dCodeParam; string Mode1dcodePath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_bar_code_model.bcm"; if (Mode1dcodePath != null && File.Exists(Mode1dcodePath)) { if (Mode1dCode != null) { HOperatorSet.ClearBarCodeModel(Mode1dCode); } HOperatorSet.ReadBarCodeModel(Mode1dcodePath, out Mode1dCode); } if (File.Exists(vision1dCodeParam.Mode1dcodeSearchPath)) { if (Mode1dCodeSearch != null && Mode1dCodeSearch.IsInitialized()) { Mode1dCodeSearch.Dispose(); } HOperatorSet.ReadRegion(out Mode1dCodeSearch, vision1dCodeParam.Mode1dcodeSearchPath); } GC.Collect(); return(vision1dCodeParam); }
public void Save(string strFileSavePath) { FileSavePath = strFileSavePath; AccessJosnSerializer.ObjectToJson(FileSavePath, this); }
public void Save(string Path) { // dispTraces.Add("SecondTrace", new List<DispTraceBaseElement>() { dispTraces["FiristTrace"][0], dispTraces["FiristTrace"][1] }); AccessJosnSerializer.ObjectToJson("D:\\123.json", dispTraces); }
public void Save(string strpath) { AccessJosnSerializer.ObjectToJson(@"E:\TorqueTest.json", recordData); }
public override void Save(string strPath) { //AccessXmlSerializer.ObjectToXml(strPath, vision1dCodeParam); AccessJosnSerializer.ObjectToJson(strPath, this); }
public override Object Read() { try { VisionShapParam tempvisionShapParam = null; string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml"; if (strSavePath != "") { strPath = strSavePath + "\\" + m_strStepName + ".xml"; } strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json"; if (strSavePath != "") { strPath = strSavePath + "\\" + m_strStepName + ".json"; } object visionShapMatch2 = AccessJosnSerializer.JsonToObject(strPath, typeof(object)); //string json = visionShapMatch2.ToString(); //var q = JsonConvert.DeserializeObject<dynamic>(json); //Newtonsoft.Json.Linq.JObject jobj = Newtonsoft.Json.Linq.JObject.Parse(json); //string jsonShapelist= jobj["shapeslist"].ToString(); //List<shapeparam> ss = JsonConvert.DeserializeObject<List<shapeparam>>(jsonShapelist); //var qq = JsonConvert.DeserializeObject<dynamic>(jsonShapelist); //Newtonsoft.Json.Linq.JObject jobjShape = Newtonsoft.Json.Linq.JObject.Parse(qq.ToString()); //string jsonShapelists = jobjShape["usrshape"].ToString(); VisionShapMatch visionShapMatch = (VisionShapMatch)AccessJosnSerializer.JsonToObject(strPath, this.GetType()); string str = visionShapMatch2.ToString(); int indexFindex = str.IndexOf("\"shapeslist\":"); string sub1 = str.Substring(indexFindex); int indexFirist = sub1.IndexOf("["); string sub2 = sub1.Substring(indexFirist); int indexLast = sub2.IndexOf("]"); int nLen = indexLast - indexFirist; if (indexLast != -1 && indexFirist != -1 && nLen > 0) { string sub = sub2.Substring(0, indexLast + 1); string strReg = "<Item>"; List <object> list = (List <object>)JsonConvert.DeserializeObject(sub, typeof(List <object>)); // List<shapeparam> list = (List<shapeparam>)AccessJosnSerializer.JsonToObject(strPath,typeof( shapeparam)); for (int i = 0; i < list.Count; i++) { if (list[i].ToString() != null) { int index = list[i].ToString().IndexOf("\"usrshape\": "); if (index != -1) { string Itemstring = list[i].ToString(); string subusrshape = list[i].ToString().Substring(index); int index2 = subusrshape.IndexOf("{"); int index3 = subusrshape.IndexOf("}"); if (index2 != -1 && index3 != -1) { int nLenOfUserShape = index3 - index2; string subusrshapeObj = subusrshape.Substring(index2 - 1, nLenOfUserShape + 2); Type TY = AssemblyOperate.GetTypeFromAssembly(visionShapMatch.shapeslist[i].usrshape.UserTypeName); UserShape tem = (UserShape)JsonConvert.DeserializeObject(subusrshapeObj, TY); visionShapMatch.shapeslist[i].usrshape = tem; } } } } } if (visionShapMatch == null || visionShapMatch.visionShapParam == null) { MessageBox.Show(m_strStepName + ": 视觉处理项目加载失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.Warn(m_strStepName + ": 视觉处理项目加载失败,请检查"); return(null); } visionShapParam = tempvisionShapParam = visionShapMatch.visionShapParam; this.shapeslist.Clear(); int nIndex = 0; for (int s = 0; s < visionShapMatch.shapeslist.Count; s++) { shapeslist.Add(new shapeparam() { name = visionShapMatch.shapeslist[s].name, shapeType = visionShapMatch.shapeslist[s].shapeType, usrshape = visionShapMatch.shapeslist[s].usrshape.Clone(), }); } string ModeShmPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_Mode.shm"; if (visionShapParam != null && visionShapParam.ModeType == eModleType.形状 && File.Exists(ModeShmPath)) { if (ModeID != null) { HOperatorSet.ClearShapeModel(ModeID); } ModeID = null; HOperatorSet.ReadShapeModel(ModeShmPath, out ModeID); if (ModeID == null || ModeID.Length <= 0) { MessageBox.Show(m_strStepName + "读取项目:" + "模板读取失败", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.Warn(m_strStepName + "读取项目:" + "模板读取失败"); } } else { _logger.Warn(m_strStepName + "读取项目:" + "模板读取失败"); MessageBox.Show(m_strStepName + "读取项目:" + "模板读取失败", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } string SeachRectRegionPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_SearchRect.hobj"; if (visionShapParam != null && File.Exists(SeachRectRegionPath)) { if (RegionSearch != null && RegionSearch.IsInitialized()) { RegionSearch.Dispose(); } HOperatorSet.ReadRegion(out RegionSearch, SeachRectRegionPath); if (RegionSearch == null || RegionSearch.IsInitialized()) { _logger.Warn(m_strStepName + "读取项目:" + "搜索区域读取失败"); } } else { _logger.Warn(m_strStepName + "读取项目:" + "搜索区域读取失败"); } string RoiRegionPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_Roi.hobj"; if (visionShapParam != null && File.Exists(RoiRegionPath)) { if (RegionRoi != null && RegionRoi.IsInitialized()) { RegionRoi.Dispose(); } HOperatorSet.ReadRegion(out RegionRoi, RoiRegionPath); if (RegionRoi == null || RegionRoi.IsInitialized()) { _logger.Warn(m_strStepName + "读取项目:" + "roi读取失败"); } } else { _logger.Warn(m_strStepName + "读取项目:" + "roi读取失败"); } } catch (Exception e1) { _logger.Warn(m_strStepName + "读取项目:" + e1.Message); MessageBox.Show(m_strStepName + "读取项目:" + e1.Message, "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch { _logger.Warn(m_strStepName + "读取项目失败"); MessageBox.Show(m_strStepName + "读取项目失败", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); } GC.Collect(); return(visionShapParam); }
public static void Save() { AccessJosnSerializer.ObjectToJson(AppDomain.CurrentDomain.BaseDirectory + "SysFunConfig.json", sysFunParam); }