Пример #1
0
        protected void RecordCSTData(string key, List <double> list)
        {
            TxtFile t_I = new TxtFile();

            try
            {
                string root = ParPathRoot.PathRoot + "软件运行记录\\RecordData\\" + key + "\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string pathDir = Log.CreateAllTimeFile(root);

                string path = pathDir + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + ".txt";
                string name = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() +
                              ":" + DateTime.Now.Second.ToString() + ":" + DateTime.Now.Millisecond.ToString();

                t_I.WriteText(path, key);//写入
                for (int i = 0; i < list.Count; ++i)
                {
                    t_I.WriteText(path, i.ToString() + "=" + list[i].ToString());//写入
                }
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #2
0
        //写入文本
        public void WriteTxt(AlarmInfo alarmInfo)
        {
            try
            {
                TxtFile t_I = new TxtFile();
                //文件
                string strFileLog = PathAlarmHour + "Alarm.txt";

                string value = "Alarm:" + alarmInfo.Alarm
                               + "       " + "Time:" + alarmInfo.Time;
                t_I.WriteText(strFileLog, value);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #3
0
        //写入文本
        public void WriteTxt(StateInfo stateInfo)
        {
            try
            {
                TxtFile t_I = new TxtFile();
                //文件
                string strFileLog = PathStateHour + "State.txt";

                string value = "State:" + stateInfo.State
                               + "       " + "Time:" + stateInfo.Time;
                t_I.WriteText(strFileLog, value);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #4
0
        public void FunRecordCell(int noCamera, string nameCell, string name, double time, bool blResult, string type)
        {
            try
            {
                string root = ParPathRoot.PathRoot + "软件运行记录\\RecordCell\\Camera" + noCamera + "\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string pathDir = Log.CreateAllTimeFile(root);

                string path    = pathDir + nameCell + name + ".txt";
                string timeNow = DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();

                //记录个数
                NameCell = nameCell;
                double[] num = NumRunInfo;
                if (blResult)
                {
                    num[0] = num[0] + 1;//OK
                }
                else
                {
                    num[1] = num[1] + 1; //NG
                }
                num[2]     = num[2] + 1; //Sum
                NumRunInfo = num;
                double co = 0;
                if (num[2] != 0)
                {
                    co = Math.Round((double)num[0] / (double)num[2], 2);
                }

                string  result = "NumOK=" + num[0].ToString() + ";NumNG=" + num[1].ToString() + ";Sum=" + num[2].ToString() + ";OK/Sum=" + co.ToString() + "\r\n" + type;
                string  all    = timeNow + "\r\n" + time + "ms\r\n" + result + "\r\n";
                TxtFile txt    = new TxtFile();
                txt.WriteText(path, all);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #5
0
        public void RobotLog(string msg)
        {
            TxtFile t_I = new TxtFile();

            try
            {
                string root = ParPathRoot.PathRoot + "软件运行记录\\RecordData\\Robot\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string pathDir = Log.CreateAllTimeFile(root);

                string path = pathDir + "RobotLog" + ".txt";
                string name = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString() + ":" + DateTime.Now.Millisecond.ToString();
                t_I.WriteText(path, name + "---------" + msg);//写入时间
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #6
0
        protected void RecordPreciseData(int id, string data)
        {
            TxtFile t_I = new TxtFile();

            try
            {
                string root = ParPathRoot.PathRoot + "软件运行记录\\RecordData\\Precise\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string pathDir = Log.CreateAllTimeFile(root);

                string path = pathDir + "PreciseData" + ".txt";
                string name = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() +
                              ":" + DateTime.Now.Second.ToString() + ":" + DateTime.Now.Millisecond.ToString();
                t_I.WriteText(path, name + "----->ID: " + id.ToString() + "------->" + data);//写入时间
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Пример #7
0
        /// <summary>
        /// 记录图像处理的节拍和整体的节拍
        /// </summary>
        protected void RecordTact(int noCamera, int pos, Hashtable htResult)
        {
            TxtFile t_I = new TxtFile();

            try
            {
                sw_Tact.Stop();
                long tFull = sw_Tact.ElapsedMilliseconds;

                string root = ComValue.c_PathRecord + "RecordCamera\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string pathDir = Log.CreateAllTimeFile(root);

                string path = pathDir + "Camera" + noCamera.ToString() + "-Pos" + pos.ToString() + ".txt";
                string name = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString() + ":" + DateTime.Now.Millisecond.ToString();
                t_I.WriteText(path, name);//写入时间

                //记录每个单子算子的时间
                List <int> key_L = new List <int>();
                foreach (string str in htResult.Keys)
                {
                    if (str.Contains("C"))
                    {
                        key_L.Add(int.Parse(str.Replace("C", "").Replace("T", "")));
                    }
                }
                key_L.Sort();

                //记录单元格运行时间
                foreach (int index in key_L)
                {
                    string nameCell = "C" + index.ToString();
                    if (htResult[nameCell] is BaseResultHObject)
                    {
                        if (((BaseResultHObject)htResult[nameCell]).Pos != pos)
                        {
                            continue;
                        }
                        //单元格运行时间
                        string cell     = ((BaseResultHObject)htResult[nameCell]).NameCell + ((BaseResultHObject)htResult[nameCell]).Type;
                        double cellTime = ((BaseResultHObject)htResult[nameCell]).TactTime;
                        t_I.WriteText(path, cell + "=" + cellTime.ToString() + "ms");

                        //运行状态
                        NameCell = nameCell + "_Main";
                        BaseResult result = (BaseResult)htResult[nameCell];
                        double[]   num    = NumRunInfo;
                        if (result.BlResult)
                        {
                            num[0] = num[0] + 1;//OK
                        }
                        else
                        {
                            num[1] = num[1] + 1; //NG
                        }
                        num[2]     = num[2] + 1; //Sum
                        NumRunInfo = num;
                        double co = 0;
                        if (num[2] != 0)
                        {
                            co = Math.Round((double)num[0] / (double)num[2], 2);
                        }
                        string type = result.LevelError_e.ToString() + "-" + result.TypeErrorProcess_e.ToString() + "-" + result.Annotation;
                        string info = "NumOK=" + num[0].ToString() + ";NumNG=" + num[1].ToString() + ";Sum=" + num[2].ToString() + ";OK/Sum=" + co.ToString() + "**Result:" + type;
                        t_I.WriteText(path, info);
                    }
                }

                //记录图像处理时间
                long tImageP = long.Parse(htResult["TimeImageP-Pos" + pos.ToString()].ToString());
                t_I.WriteText(path, "图像处理=" + tImageP.ToString());

                //记录显示时间
                long tDisplayImage     = long.Parse(htResult["TimeDisplayImage-Pos" + pos.ToString()].ToString());
                long tDisplayROI       = long.Parse(htResult["TimeDisplayROI-Pos" + pos.ToString()].ToString());
                long tDisplayShape     = long.Parse(htResult["TimeDisplayShape-Pos" + pos.ToString()].ToString());
                long tDisplayInfoImage = long.Parse(htResult["TimeDisplayInfoImage-Pos" + pos.ToString()].ToString());
                long tDisplayInfo      = long.Parse(htResult["TimeDisplayInfo-Pos" + pos.ToString()].ToString());
                long tDisplayAll       = long.Parse(htResult["TimeDisplayAllTime-Pos" + pos.ToString()].ToString());

                string infoDisplay = string.Format("显示时间={5}:画面={0};  ROI={1};  形状={2};  画面信息={3};  信息={4}", tDisplayImage, tDisplayROI, tDisplayShape, tDisplayInfoImage, tDisplayInfo, tDisplayAll);
                t_I.WriteText(path, infoDisplay);

                //记录内存处理时间
                long tMemory = long.Parse(htResult["Memory-Rubbish" + pos.ToString()].ToString());
                t_I.WriteText(path, "垃圾清除+内存监控=" + tMemory);

                //记录整体节拍
                t_I.WriteText(path, "整体节拍" + tFull + "\n\r");
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }