Пример #1
0
        public static bool Save(string pathName, VisionFlow flow)
        {
            if (flow == null)
            {
                return(false);
            }

            Common.CommonHelper.CreatePath($"{pathName}{flow.FlowName}/");

            try
            {
                foreach (Detect detect in flow.Detects)
                {
                    if (detect.GetType() == typeof(DetectGeometric))
                    {
                        (detect as DetectGeometric).Temp.WriteVisionFile($"{pathName}{flow.FlowName}/{detect.UnitID}.bmp");
                    }
                    else if (detect.GetType() == typeof(DetectPttern))
                    {
                        (detect as DetectPttern).Temp.WriteVisionFile($"{pathName}{flow.FlowName}/{detect.UnitID}.bmp");
                    }
                    else if (detect.GetType() == typeof(DetectShapeMatch))
                    {
                        (detect as DetectShapeMatch).ShapeModel.WriteShapeModel($"{pathName}{flow.FlowName}/{detect.UnitID}.temp");
                    }
                }
            }
            catch { return(false); }

            Common.SerializableHelper <VisionFlow> helper = new Common.SerializableHelper <VisionFlow>(flow);
            return(helper.JsonSerialize(pathName + flow.FlowName + "/Vision.vp"));
        }
        private static void SaveReport(Module module, DateTime time, MachineStatistic report)
        {
            bool isCurDay = true;
            bool isDay    = true;

            if (time.Hour < ReportHelper.Instance.DayShfitTime.Hours) // 上一天的夜班
            {
                isDay    = false;
                isCurDay = false;
            }
            else if (time.Hour >= ReportHelper.Instance.DayShfitTime.Hours &&
                     time.Hour < ReportHelper.Instance.NightShfitTime.Hours)
            {
            }
            else if (time.Hour >= ReportHelper.Instance.NightShfitTime.Hours)
            {
                isDay = false;
            }

            string ss     = isDay ? "白班" : "夜班";
            var    curDay = time;

            if (!isCurDay)
            {
                curDay = time.AddDays(-1);
            }

            //CreatePath(curDay);
            var sP = $"{ReportHelper.Instance.ReportPath}{curDay.ToString("yyyy-MM-dd")}\\{module}\\{ss}.txt";

            Common.SerializableHelper <MachineStatistic> helper = new Common.SerializableHelper <MachineStatistic>(report);
            helper.JsonSerialize(sP);
        }
Пример #3
0
        /// <summary>
        /// 保存今日数据
        /// </summary>
        public void Refresh()
        {
            if (this.Reoprt != null)
            {
                var now = DateTime.Now;
                if (this.Reoprt.Date.Day != now.Day)
                {
                    // 保存上一天的
                    this.Reoprt.Stop();
                    Common.SerializableHelper <DayReprot> helper = new Common.SerializableHelper <DayReprot>(this.Reoprt);
                    helper.JsonSerialize(RecordPath);

                    DayChange(now);
                    TimeDefine temp = this.Reoprt.CurRecordTime;
                    this.Reoprt      = new DayReprot();
                    this.Reoprt.Date = now;
                    this.Reoprt.Start(temp, "日期更换");
                }
                else
                {
                    if (this.Reoprt.Date.Hour != now.Hour)
                    {
                        this.Reoprt.HourChange(this.Reoprt.Date, now);
                    }

                    Common.SerializableHelper <DayReprot> helper = new Common.SerializableHelper <DayReprot>(this.Reoprt);
                    helper.JsonSerialize(RecordPath + "today.json");
                    this.SaveTotal(this.Reoprt.Total, RecordPath, this.Reoprt.Date.Hour);
                    this.Reoprt.Date = now;
                }
            }
        }
Пример #4
0
        public static VisionFlow Load(string pathName)
        {
            Common.SerializableHelper <VisionFlow> helper = new Common.SerializableHelper <VisionFlow>();
            var flow = helper.DeJsonSerialize(pathName + "//Vision.vp");

            try
            {
                if (flow != null && flow.Detects.Count > 0)
                {
                    foreach (Detect detect in flow.Detects)
                    {
                        if (detect.GetType() == typeof(DetectGeometric))
                        {
                            (detect as DetectGeometric).Temp.ReadVisionFile($"{pathName}\\{detect.UnitID}.bmp");
                        }
                        else if (detect.GetType() == typeof(DetectPttern))
                        {
                            (detect as DetectPttern).Temp.ReadVisionFile($"{pathName}\\{detect.UnitID}.bmp");
                        }
                        else if (detect.GetType() == typeof(DetectShapeMatch))
                        {
                            (detect as DetectShapeMatch).ShapeModel.ReadShapeModel($"{pathName}\\{detect.UnitID}.temp");
                        }
                    }
                }
            }
            catch (HalconException ex)
            {
                Debug.WriteLine(ex.Message);
                return(null);
            }

            return(flow);
        }
        /// <summary>
        /// 加载程式
        /// </summary>
        /// <param name="name">程式名称</param>
        /// <returns></returns>
        public static ProgramFlow Load(string path)
        {
            Common.SerializableHelper <ProgramFlow> helper = new Common.SerializableHelper <ProgramFlow>();
            ProgramFlow flow = helper.DeJsonSerialize(path);

            return(flow);
        }
 public static void Save()
 {
     Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>(MFlexHelper.Instance);
     helper.JsonSerialize(Variable.sPath_Configure + "MFlex.json");
     if (MFlexHelper.Instance.CodeFunc != string.Empty)
     {
         MFlexHelper.Instance.CodeBean = ReadCodeBean.Load(MFlexHelper.Instance.CodeFunc);
     }
 }
Пример #7
0
 public static void Save()
 {
     Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>(MFlexHelper.Instance);
     helper.JsonSerialize(PathDefine.sPathConfigure + "MFlex.json");
     if (MFlexHelper.Instance.CodeFunc != string.Empty)
     {
         MFlexHelper.Instance.CodeBean = VisionFlow.Load(VisionToolCtrl.sPathVision + MFlexHelper.Instance.CodeFunc);
     }
 }
Пример #8
0
        public static void Load()
        {
            Common.SerializableHelper <CameraDefine> helper = new Common.SerializableHelper <CameraDefine>();
            var temp = helper.DeJsonSerialize(Variable.sPath_Configure + "Camera.config");

            if (temp != null)
            {
                CameraDefine.Instance = temp;
            }
        }
        public static void Load()
        {
            Common.SerializableHelper <FeederHelper> helper = new Common.SerializableHelper <FeederHelper>();
            FeederHelper.Instance = helper.DeJsonSerialize(Variable.sPath_Configure + "Feeder.json");

            if (FeederHelper.Instance == null)
            {
                FeederHelper.Instance = new FeederHelper();
                FeederHelper.Instance.FeederInfo.Add(new FeederBean());
                FeederHelper.Instance.FeederInfo.Add(new FeederBean());
            }
        }
Пример #10
0
        /// <summary>
        /// 获得 某天 某时的数据
        /// </summary>
        /// <param name="day"></param>
        public DayReprot GetData(DateTime day, int startTime, int endTime, TreeView view = null, ZedGraphControl zgc = null, DataGridView gridView = null)
        {
            try
            {
                string path = $"{StatisticsPath}//{day.Year}年//{day.Month}月//{day.Day}号";
                if (Directory.Exists(path))
                {
                    DayReprot report = new DayReprot();
                    Common.SerializableHelper <DayReprot> helper = new Common.SerializableHelper <DayReprot>();
                    // 拿到当天记录
                    report = helper.DeJsonSerialize(path + "//today.json");
                    // 根据时间进行筛选
                    report = report.GetTimeTotal(startTime, endTime);
                    // 获得对应时间的统计
                    report.Total = this.GetCount(path, startTime, endTime);

                    if (view != null)
                    {
                        this.SetTree(report, view);
                    }

                    if (zgc != null)
                    {
                        this.SetChart(report, zgc);
                    }

                    if (gridView != null)
                    {
                        this.SetGridView(report, gridView);
                    }

                    return(report);
                }
                else
                {
                    if (view != null)
                    {
                        view.Nodes.Clear();
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public static void Save()
        {
            Common.SerializableHelper <ZDTHelper> helper = new Common.SerializableHelper <ZDTHelper>(ZDTHelper.Instance);
            helper.JsonSerialize(Variable.sPath_Configure + "ZDT.json");


            if (ZDTHelper.Instance.JY_Config.ReadCodeBean != string.Empty)
            {
                ZDTHelper.Instance.SPICodeBean = ReadCodeBean.Load(ZDTHelper.Instance.JY_Config.ReadCodeBean);
            }

            if (ZDTHelper.Instance.BJZS_Config.ReadCodeBean != string.Empty)
            {
                ZDTHelper.Instance.TrayCodeBean = ReadCodeBean.Load(ZDTHelper.Instance.BJZS_Config.ReadCodeBean);
            }
        }
        public static bool Load()
        {
            if (File.Exists(Variable.sPath_Configure + "MFlex.json"))
            {
                Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>();
                var temp = helper.DeJsonSerialize(Variable.sPath_Configure + "MFlex.json");
                if (temp != null)
                {
                    MFlexHelper.Instance = temp;
                    if (MFlexHelper.Instance.CodeFunc != string.Empty)
                    {
                        MFlexHelper.Instance.CodeBean = ReadCodeBean.Load(MFlexHelper.Instance.CodeFunc);
                    }
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        public static bool Load()
        {
            if (File.Exists(PathDefine.sPathConfigure + "MFlex.json"))
            {
                Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>();
                var temp = helper.DeJsonSerialize(PathDefine.sPathConfigure + "MFlex.json");
                if (temp != null)
                {
                    MFlexHelper.Instance = temp;
                    if (MFlexHelper.Instance.CodeFunc != string.Empty)
                    {
                        MFlexHelper.Instance.CodeBean = VisionFlow.Load(VisionToolCtrl.sPathVision + MFlexHelper.Instance.CodeFunc);
                    }
                    return(true);
                }
            }

            return(false);
        }
 public static void Save()
 {
     Common.SerializableHelper <FeederHelper> helper = new Common.SerializableHelper <FeederHelper>(FeederHelper.Instance);
     helper.JsonSerialize(Variable.sPath_Configure + "Feeder.json");
 }
 /// <summary>
 /// 保存程式
 /// </summary>
 /// <param name="program"></param>
 /// <returns></returns>
 public static bool Save(ProgramFlow program)
 {
     Common.SerializableHelper <ProgramFlow> helper = new Common.SerializableHelper <ProgramFlow>(program);
     return(helper.JsonSerialize(PathDefine.sPathProgram + $"{CommonHelper.GetEnumDescription(typeof(Module), program.Module)}\\{program.ProgramName}.json"));
 }
Пример #16
0
 public static void Save(ReadCodeBean bean)
 {
     Common.SerializableHelper <ReadCodeBean> helper = new Common.SerializableHelper <ReadCodeBean>(bean);
     helper.JsonSerialize(Variable.sPath_ReadCodeBean + bean.BeanName + ".json");
 }
Пример #17
0
 public static ReadCodeBean Load(string name)
 {
     Common.SerializableHelper <ReadCodeBean> helper = new Common.SerializableHelper <ReadCodeBean>();
     return(helper.DeJsonSerialize(Variable.sPath_ReadCodeBean + name + ".json"));
 }
Пример #18
0
 public static void Save()
 {
     Common.SerializableHelper <CameraDefine> helper = new Common.SerializableHelper <CameraDefine>(CameraDefine.Instance);
     helper.JsonSerialize(Variable.sPath_Configure + "Camera.config");
 }
 public static void Save()
 {
     Common.SerializableHelper <ReportHelper> helper = new Common.SerializableHelper <ReportHelper>(ReportHelper.Instance);
     helper.JsonSerialize(PathDefine.sPathReport + "Report.json");
 }