/// <summary>
        /// 初始化系统参数
        /// </summary>
        public static void InitialSysPara()
        {
            string   ConfigFile = ConfigPath + "Config.dat";
            FileInfo fileInfo   = new FileInfo(ConfigFile);

            if (!Directory.Exists(fileInfo.DirectoryName))
            {
                Directory.CreateDirectory(fileInfo.DirectoryName);
                LogNet.WriteError("InitialSysPara():Create Directory!");
                SysPara = new Para();
                return;
            }
            else
            {
                if (File.Exists(ConfigFile))
                {
                    SysPara = (Para)CommonMethod.GetDataFromFile(ConfigFile);
                }
                else
                {
                    LogNet.WriteError("InitialSysPara():Config.dat is not exist!");
                    SysPara = new Para();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 记录GTS指令错误
        /// </summary>
        /// <param name="context"></param>
        /// <param name="code"></param>
        public void WriteError(String context, short code)
        {
            string Log_Component = context + "--------" + code;

            // 如果指令执行返回值为非0,说明指令执行错误,向屏幕输出错误结果
            #if !DEBUG
            if (code != 0)
            {
                LogRecord.WriteError(Log_Component);
            }
            #endif
        }
Esempio n. 3
0
 /// <summary>
 ///  监听同心度和表面质量
 /// </summary>
 private void MonitorCoaSurface()
 {
     try
     {
         Invoke(new Action(() =>
         {
             labCoaxility.Text = OpcUaClient.ReadNode <double>(s_coaxilitySign).ToString();
             labSurface.Text   = OpcUaClient.ReadNode <string>(s_surfaceSign);
         }));
     }
     catch (Exception ex)
     {
         LogNetProgramer.WriteError("异常", ex.Message);
     }
 }
Esempio n. 4
0
        public static void WriteMsg(MessageType degree, object obj, string strMsg, string strMark = "", Exception ex = null)
        {
            string strKey = (obj != null ? obj.GetType().FullName : "") + (string.IsNullOrEmpty(strMark) ? "" : "  Mark:" + strMark);

            switch (degree)
            {
            case MessageType.DEBUG:
                logNet.WriteDebug(strKey, strMsg);
                break;

            case MessageType.ERROR:
                logNet.WriteError(strKey, strMsg);
                break;

            case MessageType.FATAL:
                logNet.WriteFatal(strKey, strMsg);
                break;

            case MessageType.INFO:
                logNet.WriteInfo(strKey, strMsg);
                break;

            case MessageType.NONE:
                logNet.WriteDescrition(strMsg);
                break;

            case MessageType.WARN:
                logNet.WriteWarn(strKey, strMsg);
                break;

            case MessageType.EXCEPTION:
                logNet.WriteException(strKey, ex);
                break;
            }
        }
Esempio n. 5
0
        ILogNet logNetTime = new LogNetDateTime(Application.ResourceAssembly + "\\LogByTime", GenerateMode.ByEveryDay);//按每天
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            // 一般日志写入
            logNet.WriteDebug("调试信息");
            logNet.WriteInfo("一般信息");
            logNet.WriteWarn("警告信息");
            logNet.WriteError("错误信息");
            logNet.WriteFatal("致命信息");
            logNet.WriteException(null, new IndexOutOfRangeException());

            // 带有关键字的写入,关键字建议为方法名或是类名,方便分析的时候归类搜索
            logNet.WriteDebug("userButton1_Click", "调试信息");
            logNet.WriteInfo("TestForm", "一般信息");
            logNet.WriteWarn("随便什么", "警告信息");
            logNet.WriteError("userButton1_Click", "错误信息");
            logNet.WriteFatal("userButton1_Click", "致命信息");
            logNet.WriteException("userButton1_Click", new IndexOutOfRangeException());

            // 日志查看器
            using (HslCommunication.LogNet.FormLogNetView form = new HslCommunication.LogNet.FormLogNetView())
            {
                form.ShowDialog();
            }
        }