// Token: 0x06000007 RID: 7 RVA: 0x000022DC File Offset: 0x000004DC public bool Write(string[] sItemIDArray, object[] oValArray, out int[] nErrorArray) { int num = sItemIDArray.Count <string>(); nErrorArray = new int[num]; bool result; try { IOPCItemIO iopcitemIO = (IOPCItemIO)this.m_OPCServer; OPCITEMVQT[] array = new OPCITEMVQT[num]; for (int i = 0; i < oValArray.Count <object>(); i++) { array[i] = new OPCITEMVQT { vDataValue = oValArray[i] }; } IntPtr intPtr; iopcitemIO.WriteVQT(num, sItemIDArray, array, out intPtr); Marshal.Copy(intPtr, nErrorArray, 0, num); Marshal.FreeCoTaskMem(intPtr); result = true; } catch (Exception ex) { #if DEBUG Debug.WriteLine(ex); #endif result = false; } return(result); }
/// <summary> /// Writes the value, quality and timestamp for a set of items. /// </summary> /// <param name="items">The set of item values to write.</param> /// <returns>The results of the write operation for each item.</returns> public virtual OpcItemResult[] Write(TsCDaItemValue[] items) { if (items == null) { throw new ArgumentNullException(nameof(items)); } lock (this) { if (m_server == null) { throw new NotConnectedException(); } string methodName = "IOPCItemIO.WriteVQT"; int count = items.Length; if (count == 0) { throw new ArgumentOutOfRangeException("items.Length", "0"); } // initialize arguments. string[] itemIDs = new string[count]; for (int ii = 0; ii < count; ii++) { itemIDs[ii] = items[ii].ItemName; } OpcRcw.Da.OPCITEMVQT[] values = Technosoftware.DaAeHdaClient.Com.Da.Interop.GetOPCITEMVQTs(items); IntPtr pErrors = IntPtr.Zero; // invoke COM method. try { IOPCItemIO server = BeginComCall <IOPCItemIO>(methodName, true); server.WriteVQT( count, itemIDs, values, out pErrors); } catch (Exception e) { ComCallError(methodName, e); throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e); } finally { EndComCall(methodName); } // unmarshal results. int[] errors = Technosoftware.DaAeHdaClient.Utilities.Interop.GetInt32s(ref pErrors, count, true); // construct result array. OpcItemResult[] results = new OpcItemResult[count]; for (int ii = 0; ii < count; ii++) { results[ii] = new OpcItemResult(items[ii]); results[ii].ServerHandle = null; results[ii].Result = Technosoftware.DaAeHdaClient.Utilities.Interop.GetResultID(errors[ii]); results[ii].DiagnosticInfo = null; // convert COM code to unified DA code. if (errors[ii] == Result.E_BADRIGHTS) { results[ii].Result = new OpcResult(OpcResult.Da.E_READONLY, Result.E_BADRIGHTS); } // apply request options. if ((filters_ & (int)TsCDaResultFilter.ItemName) == 0) { results[ii].ItemName = null; } if ((filters_ & (int)TsCDaResultFilter.ItemPath) == 0) { results[ii].ItemPath = null; } if ((filters_ & (int)TsCDaResultFilter.ClientHandle) == 0) { results[ii].ClientHandle = null; } } // return results. return(results); } }