Exemplo n.º 1
0
 internal static Opc.Dx.SourceServer[] GetSourceServers(ref IntPtr pInput, int count, bool deallocate)
 {
     Opc.Dx.SourceServer[] serverArray = null;
     if ((pInput != IntPtr.Zero) && (count > 0))
     {
         serverArray = new Opc.Dx.SourceServer[count];
         IntPtr ptr = pInput;
         for (int i = 0; i < count; i++)
         {
             OpcRcw.Dx.SourceServer server = (OpcRcw.Dx.SourceServer)Marshal.PtrToStructure(ptr, typeof(OpcRcw.Dx.SourceServer));
             serverArray[i]                  = new Opc.Dx.SourceServer();
             serverArray[i].ItemName         = server.szItemName;
             serverArray[i].ItemPath         = server.szItemPath;
             serverArray[i].Version          = server.szVersion;
             serverArray[i].Name             = server.szName;
             serverArray[i].Description      = server.szDescription;
             serverArray[i].ServerType       = server.szServerType;
             serverArray[i].ServerURL        = server.szServerURL;
             serverArray[i].DefaultConnected = server.bDefaultSourceServerConnected != 0;
             ptr = (IntPtr)(ptr.ToInt32() + Marshal.SizeOf(typeof(OpcRcw.Dx.SourceServer)));
         }
         if (deallocate)
         {
             Marshal.FreeCoTaskMem(pInput);
             pInput = IntPtr.Zero;
         }
     }
     return(serverArray);
 }
Exemplo n.º 2
0
 internal static OpcRcw.Dx.SourceServer[] GetSourceServers(Opc.Dx.SourceServer[] input)
 {
     OpcRcw.Dx.SourceServer[] serverArray = null;
     if ((input != null) && (input.Length > 0))
     {
         serverArray = new OpcRcw.Dx.SourceServer[input.Length];
         for (int i = 0; i < input.Length; i++)
         {
             serverArray[i]               = new OpcRcw.Dx.SourceServer();
             serverArray[i].dwMask        = 0x7fffffff;
             serverArray[i].szItemName    = input[i].ItemName;
             serverArray[i].szItemPath    = input[i].ItemPath;
             serverArray[i].szVersion     = input[i].Version;
             serverArray[i].szName        = input[i].Name;
             serverArray[i].szDescription = input[i].Description;
             serverArray[i].szServerType  = input[i].ServerType;
             serverArray[i].szServerURL   = input[i].ServerURL;
             serverArray[i].bDefaultSourceServerConnected = input[i].DefaultConnected ? 1 : 0;
         }
     }
     return(serverArray);
 }