Exemple #1
0
 /// <summary>
 /// nternal use setting device information command function
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="lChannel">Channel number, if the channel data set to 0 XFFFFFFFF (1), if you don't need to channel number command, this parameter is invalid</param>
 /// <param name="dwCommand">Configuration commands</param>
 /// <param name="obj">objectobject</param>
 /// <param name="typeName">structure type</param>
 /// <param name="waittime">waittime</param>
 /// <returns>true:succeed;false:fail</returns>
 private static bool PSetDevConfig(int lLoginID, int lChannel, CONFIG_COMMAND dwCommand, object obj, Type typeName, int waittime)
 {
     bool returnValue = false;
     IntPtr pBoxInfo = IntPtr.Zero;
     try
     {
         pBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeName));//Allocation of fixed specified the size of the memory space
         if (pBoxInfo != IntPtr.Zero)
         {
             Marshal.StructureToPtr(obj, pBoxInfo, true);
             returnValue = NETSetDevConfig(lLoginID, dwCommand, lChannel, pBoxInfo, (UInt32)Marshal.SizeOf(typeName), waittime);
         }
     }
     catch (Exception e)
     {
         NETThrowLastError(e);
         returnValue= false;
     }
     finally
     {
         Marshal.FreeHGlobal(pBoxInfo);//Release the fixed memory allocation
         pBoxInfo = IntPtr.Zero;
     }
     return returnValue;
 }
Exemple #2
0
        /// <summary>
        /// Internal use of all information set equipment command function
        /// </summary>
        /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
        /// <param name="dwCommand">Configuration commands</param>
        /// <param name="obj">objectobject</param>
        /// <param name="typeName">struct types</param>
        /// <param name="waittime">waittime</param>
        /// <returns>true:succeed;false:fail</returns>
        private static bool PSetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand,object[] obj, Type typeName, int waittime)
        {
            bool returnValue = false;
            IntPtr pBoxInfo = IntPtr.Zero;
            try
            {
                pBoxInfo = Marshal.AllocHGlobal(obj.Length * Marshal.SizeOf(typeName));//Allocation of fixed specified the size of the memory space
                if (pBoxInfo != IntPtr.Zero)
                {
                    for (int loop = 0; loop < obj.Length; loop++)
                    {
                        Marshal.StructureToPtr(obj[loop], (IntPtr)((UInt32)pBoxInfo + (UInt32)Marshal.SizeOf(typeName) * loop), true);
                    }
                    returnValue = NETSetDevConfig(lLoginID, dwCommand, -1, pBoxInfo, (uint)obj.Length * (UInt32)Marshal.SizeOf(typeName), waittime);
                }
            }
            catch (Exception e)
            {
                NETThrowLastError(e);
                returnValue= false;
            }
            finally
            {
                Marshal.FreeHGlobal(pBoxInfo);//Release the fixed memory allocation
                pBoxInfo = IntPtr.Zero;

            }
            return returnValue;
        }
Exemple #3
0
 /// <summary>
 /// Internal use of equipment information command function
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="lChannel">channel</param>
 /// <param name="dwCommand">Configuration commands</param>
 /// <param name="obj">object Object</param>
 /// <param name="typeName">type name</param>
 /// <param name="waittime">waittime</param>
 /// <returns>true:succeed;false:fail</returns>
 private static bool PGetDevConfig(int lLoginID, int lChannel, CONFIG_COMMAND dwCommand, ref object obj, Type typeName, int waittime)
 {
     bool returnValue = false;
     IntPtr pBoxInfo = IntPtr.Zero;
     try
     {
         UInt32 returnBuffSize = 0;
         pBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeName));//Allocation of fixed specified the size of the memory space
         if (pBoxInfo != IntPtr.Zero)
         {
             returnValue = NETGetDevConfig(lLoginID, dwCommand, lChannel, pBoxInfo, (UInt32)Marshal.SizeOf(typeName), ref returnBuffSize, waittime);
             if (returnValue == true)
             {
                 obj = Marshal.PtrToStructure((IntPtr)((UInt32)pBoxInfo), typeName);
             }
         }
         NETThrowLastError(returnValue);
     }
     catch (Exception e)
     {
         NETThrowLastError(e);
         returnValue= false;
     }
     finally
     {
         Marshal.FreeHGlobal(pBoxInfo);//Release the fixed memory allocation
         pBoxInfo = IntPtr.Zero;
     }
     return returnValue;
 }
Exemple #4
0
 /// <summary>
 /// Internal use of all equipment information command function
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="lChannel">channel</param>
 /// <param name="dwCommand">ConfigurationCommand</param>
 /// <param name="obj">object object</param>
 /// <param name="typeName">typename</param>
 /// <param name="waittime">waittime</param>
 /// <returns>true:succeed;false:fail</returns>
 private static bool PGetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand, ref object[] obj, Type typeName, int waittime)
 {
     bool returnValue = false;
     IntPtr pBoxInfo = IntPtr.Zero;
     try
     {
         UInt32 returnBuffSize = 0;
         pBoxInfo = Marshal.AllocHGlobal(obj.Length * Marshal.SizeOf(typeName));//Allocate fixed and specified memory space
         if (pBoxInfo != IntPtr.Zero)
         {
             returnValue = NETGetDevConfig(lLoginID, dwCommand, -1, pBoxInfo, (uint)obj.Length * (UInt32)Marshal.SizeOf(typeName), ref returnBuffSize, waittime);
             if (returnValue == true)
             {
                 for (int loop = 0; loop < obj.Length; loop++)
                 {
                     obj[loop] = Marshal.PtrToStructure((IntPtr)((UInt32)pBoxInfo + (UInt32)Marshal.SizeOf(typeName) * loop), typeName);
                 }
             }
         }
         NETThrowLastError(returnValue);
     }
     catch (Exception e)
     {
         NETThrowLastError(e);
         returnValue= false;
     }
     finally
     {
         Marshal.FreeHGlobal(pBoxInfo);//Release the fixed memory allocation
         pBoxInfo = IntPtr.Zero;
     }
     return returnValue;
 }
Exemple #5
0
 /// <summary>
 /// Set the device configuration
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="dwCommand"> configuration type</param>
 /// <param name="lChannel">Channel number, if the channel data set to 0 XFFFFFFFF (1), if you don't need to channel number command, this parameter is invalid</param>
 /// <param name="lpInBuffer">To store the output parameters of the buffer, according to the different types, different input configuration, see the specific data structure definition</param>
 /// <param name="dwInBufferSize">The input buffer size (in bytes).</param>
 /// <param name="waittime">waittime</param>
 /// <returns>true:succeed;false:fail</returns>
 public static bool NETSetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand, int lChannel, IntPtr lpInBuffer, UInt32 dwInBufferSize, int waittime)
 {
     bool returnValue = false;
     returnValue = CLIENT_SetDevConfig(lLoginID, (UInt32)dwCommand, lChannel, lpInBuffer, dwInBufferSize, waittime);
     NETThrowLastError(returnValue);
     return returnValue;
 }
Exemple #6
0
 /// <summary>
 /// Set the device configuration
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="dwCommand"> configuration type</param>
 /// <param name="lChannel">Channel number, if the channel data set to 0 XFFFFFFFF (1), if you don't need to channel number command, this parameter is invalid</param>
 /// <param name="lpOutBuffer">To store the output parameters of the buffer, according to the different types, different input configuration, see the specific data structure definition</param>
 /// <param name="dwOutBufferSize">The input buffer size (in bytes).</param>
 /// <returns>true:succeed;false:fail</returns>
 public static bool NETSetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand, int lChannel, IntPtr lpInBuffer, UInt32 dwInBufferSize)
 {
     return NETSetDevConfig(lLoginID, dwCommand, lChannel, lpInBuffer, dwInBufferSize, 3000);
 }
Exemple #7
0
 /// <summary>
 ///  Access to equipment
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="dwCommand">configuration type</param>
 /// <param name="lChannel">Channel number, if not channel parameter, lChannel need not, can be set to 1</param>
 /// <param name="lpOutBuffer">To store the output parameters of the buffer, according to the different types, the output of different configuration, see the specific data structure definition</param>
 /// <param name="dwOutBufferSize">The input buffer size (in bytes).</param>
 /// <param name="lpBytesReturned">The actual return buffer size, the size of the corresponding configuration, (in bytes)</param>
 /// <returns>true:sucdeed;false:fail</returns>
 public static bool NETGetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand, int lChannel, IntPtr lpOutBuffer, UInt32 dwOutBufferSize, ref UInt32 lpBytesReturned)
 {
     return NETGetDevConfig(lLoginID, dwCommand, lChannel, lpOutBuffer, dwOutBufferSize, ref lpBytesReturned, 3000);
 }
Exemple #8
0
 /// <summary>
 ///  Access to equipment
 /// </summary>
 /// <param name="lLoginID">Equipment user Login ID: CLIENT Login return values</param>
 /// <param name="dwCommand">configuration type</param>
 /// <param name="lChannel">Channel number, if not channel parameter, lChannel need not, can be set to 1</param>
 /// <param name="lpOutBuffer">To store the output parameters of the buffer, according to the different types, the output of different configuration, see the specific data structure definition</param>
 /// <param name="dwOutBufferSize">The input buffer size (in bytes).</param>
 /// <param name="lpBytesReturned">The actual return buffer size, the size of the corresponding configuration, (in bytes)</param>
 /// <param name="waittime">waittime</param>
 /// <returns>true:succeed;false:fail</returns>
 public static bool NETGetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand, int lChannel, IntPtr lpOutBuffer, UInt32 dwOutBufferSize, ref UInt32 lpBytesReturned, int waittime)
 {
     bool returnValue = false;
     returnValue = CLIENT_GetDevConfig(lLoginID, (UInt32)dwCommand, lChannel, lpOutBuffer, dwOutBufferSize, ref lpBytesReturned, waittime);
     NETThrowLastError(returnValue);
     return returnValue;
 }
Exemple #9
0
        /// <summary>
        /// 内部使用的设置设备所有信息命令函数
        /// </summary>
        /// <param name="lLoginID">设备用户登录ID:CLIENT_Login的返回值</param>
        /// <param name="dwCommand">配制命令</param>
        /// <param name="obj">object对象</param>
        /// <param name="typeName">结构类型</param>
        /// <param name="waittime">等待时间</param>
        /// <returns>true:成功;false:失败</returns>
        private static bool PSetDevConfig(int lLoginID, CONFIG_COMMAND dwCommand,object[] obj, Type typeName, int waittime)
        {
            bool returnValue = false;
            IntPtr pBoxInfo = IntPtr.Zero;
            try
            {
                pBoxInfo = Marshal.AllocHGlobal(obj.Length * Marshal.SizeOf(typeName));//分配固定的指定大小的内存空间
                if (pBoxInfo != IntPtr.Zero)
                {
                    for (int loop = 0; loop < obj.Length; loop++)
                    {
                        Marshal.StructureToPtr(obj[loop], (IntPtr)((UInt32)pBoxInfo + (UInt32)Marshal.SizeOf(typeName) * loop), true);
                    }
                    returnValue = DHSetDevConfig(lLoginID, dwCommand, -1, pBoxInfo, (uint)obj.Length * (UInt32)Marshal.SizeOf(typeName), waittime);
                }
            }
            catch (Exception e)
            {
                DHThrowLastError(e);
                returnValue= false;
            }
            finally
            {
                Marshal.FreeHGlobal(pBoxInfo);//释放固定内存分配
                pBoxInfo = IntPtr.Zero;

            }
            return returnValue;
        }
Exemple #10
0
 /// <summary>
 /// 内部使用的设置设备信息命令函数
 /// </summary>
 /// <param name="lLoginID">设备用户登录ID:CLIENT_Login的返回值</param>
 /// <param name="lChannel">通道号,如果设置全部通道数据为0xFFFFFFFF(-1),如果命令不需要通道号,该参数无效</param>
 /// <param name="dwCommand">配制命令</param>
 /// <param name="obj">object对象</param>
 /// <param name="typeName">结构类型</param>
 /// <param name="waittime">等待时间</param>
 /// <returns>true:成功;false:失败</returns>
 private static bool PSetDevConfig(int lLoginID, int lChannel, CONFIG_COMMAND dwCommand, object obj, Type typeName, int waittime)
 {
     bool returnValue = false;
     IntPtr pBoxInfo = IntPtr.Zero;
     try
     {
         pBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeName));//分配固定的指定大小的内存空间
         if (pBoxInfo != IntPtr.Zero)
         {
             Marshal.StructureToPtr(obj, pBoxInfo, true);
             returnValue = DHSetDevConfig(lLoginID, dwCommand, lChannel, pBoxInfo, (UInt32)Marshal.SizeOf(typeName), waittime);
         }
     }
     catch (Exception e)
     {
         DHThrowLastError(e);
         returnValue= false;
     }
     finally
     {
         Marshal.FreeHGlobal(pBoxInfo);//释放固定内存分配
         pBoxInfo = IntPtr.Zero;
     }
     return returnValue;
 }
Exemple #11
0
 /// <summary>
 /// 内部使用的取设备信息命令函数
 /// </summary>
 /// <param name="lLoginID">设备用户登录ID:CLIENT_Login的返回值</param>
 /// <param name="lChannel">通道号</param>
 /// <param name="dwCommand">配制命令</param>
 /// <param name="obj">object对象</param>
 /// <param name="typeName">类型名称</param>
 /// <param name="waittime">等待时间</param>
 /// <returns>true:成功;false:失败</returns>
 private static bool PGetDevConfig(int lLoginID, int lChannel, CONFIG_COMMAND dwCommand, ref object obj, Type typeName, int waittime)
 {
     bool returnValue = false;
     IntPtr pBoxInfo = IntPtr.Zero;
     try
     {
         UInt32 returnBuffSize = 0;
         pBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeName));//分配固定的指定大小的内存空间
         if (pBoxInfo != IntPtr.Zero)
         {
             returnValue = DHGetDevConfig(lLoginID, dwCommand, lChannel, pBoxInfo, (UInt32)Marshal.SizeOf(typeName), ref returnBuffSize, waittime);
             if (returnValue == true)
             {
                 obj = Marshal.PtrToStructure((IntPtr)((UInt32)pBoxInfo), typeName);
             }
         }
         DHThrowLastError(returnValue);
     }
     catch (Exception e)
     {
         DHThrowLastError(e);
         returnValue= false;
     }
     finally
     {
         Marshal.FreeHGlobal(pBoxInfo);//释放固定内存分配
         pBoxInfo = IntPtr.Zero;
     }
     return returnValue;
 }