Example #1
0
 /// <summary>
 /// 设备回调
 /// </summary>
 private static void AddDeviceCallbackF(int deviceType, IntPtr deviceHandlePtr, IntPtr deviceNamePtr)
 {
     if (deviceType <= (int)DeviceType.MONITOR)
     {
         var deviceHandle = IntPtrHelper.IntPtrToUTF8string(deviceHandlePtr);
         var deviceName   = IntPtrHelper.IntPtrToUTF8string(deviceNamePtr);
         log.Info("AddDeviceCallback: deviceType:" + deviceType + "  deviceHandle:" + deviceHandle + "  deviceName:" + deviceName);
         var device = new QLDevice((DeviceType)deviceType, deviceHandle, deviceName);
         deviceManager.AddDevice(device);
     }
     else
     {
         throw new Exception(string.Format("DeviceType:{0} 设备不支持", deviceType));
     }
 }
Example #2
0
        /// <summary>
        /// 日志回调
        /// </summary>
        private static void AddLogCallbackF(long timestamp, bool expired, int funclevel, int pid, int tid, IntPtr lev, IntPtr comp, IntPtr msg, int len)
        {
            var output    = string.Empty;
            var level     = IntPtrHelper.IntPtrToUTF8string(lev);
            var component = IntPtrHelper.IntPtrTostring(comp);
            var message   = IntPtrHelper.IntPtrTostring(msg);

            if (string.IsNullOrEmpty(component))
            {
                component = "wrapper";
            }

            output += string.Format(" [PID:{0}][TID:{1}] ", pid, tid);;

            output += component + "  " + message;

            for (int i = 0; i < funclevel; i++)
            {
                output += "  ";
            }

            if (level == "DEBUG")
            {
                log.Debug(output);
            }
            else if (level == "INFO")
            {
                log.Info(output);
            }
            else if (level == "WARN")
            {
                log.Warn(output);
            }
            else if (level == "ERROR")
            {
                log.Error(output);
            }
            else
            {
                log.Fatal(output);
            }
        }
Example #3
0
        public static string GetVersion()
        {
            var intPtrVersion = PlcmHelper.getVersion();

            return(IntPtrHelper.IntPtrToUTF8string(intPtrVersion));
        }