/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.ReferenceTypeId) != 0) { m_referenceTypeId = decoder.ReadNodeId(null); } if ((attibutesToLoad & AttributesToSave.TypeDefinitionId) != 0) { m_typeDefinitionId = decoder.ReadNodeId(null); } if ((attibutesToLoad & AttributesToSave.ModellingRuleId) != 0) { m_modellingRuleId = decoder.ReadNodeId(null); } if ((attibutesToLoad & AttributesToSave.NumericId) != 0) { m_numericId = decoder.ReadUInt32(null); } }
/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.Executable) != 0) { m_executable = decoder.ReadBoolean(null); } if ((attibutesToLoad & AttributesToSave.UserExecutable) != 0) { m_userExecutable = decoder.ReadBoolean(null); } }
/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.InverseName) != 0) { m_inverseName = decoder.ReadLocalizedText(null); } if ((attibutesToLoad & AttributesToSave.Symmetric) != 0) { m_symmetric = decoder.ReadBoolean(null); } }
/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.Value) != 0) { WrappedValue = decoder.ReadVariant(null); } if ((attibutesToLoad & AttributesToSave.DataType) != 0) { m_dataType = decoder.ReadNodeId(null); } if ((attibutesToLoad & AttributesToSave.ValueRank) != 0) { m_valueRank = decoder.ReadInt32(null); } if ((attibutesToLoad & AttributesToSave.ArrayDimensions) != 0) { UInt32Collection arrayDimensions = decoder.ReadUInt32Array(null); if (arrayDimensions != null && arrayDimensions.Count > 0) { m_arrayDimensions = new ReadOnlyList<uint>(arrayDimensions); } else { m_arrayDimensions = null; } } }
/// <summary> /// Decodes a message from a buffer. /// </summary> public static IEncodeable DecodeMessage(byte[] buffer, System.Type expectedType, ServiceMessageContext context) { if (buffer == null) throw new ArgumentNullException("buffer"); if (context == null) throw new ArgumentNullException("context"); BinaryDecoder decoder = new BinaryDecoder(buffer, context); try { return decoder.DecodeMessage(expectedType); } finally { decoder.Close(); } }
/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.EventNotifier) != 0) { m_eventNotifier = decoder.ReadByte(null); } if ((attibutesToLoad & AttributesToSave.ContainsNoLoops) != 0) { m_containsNoLoops = decoder.ReadBoolean(null); } }
/// <summary> /// Acknowledges the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="eventId">The event id.</param> /// <param name="comment">The comment.</param> /// <returns></returns> public uint Acknowledge( ServerSystemContext context, byte[] eventId, LocalizedText comment) { // get the user name from the context. string userName = String.Empty; if (context.UserIdentity != null) { userName = context.UserIdentity.DisplayName; } // get the comment. string commentText = String.Empty; if (comment != null) { commentText = comment.Text; } System.Runtime.InteropServices.ComTypes.FILETIME ftActiveTime; // unpack the event id. ServiceMessageContext messageContext = new ServiceMessageContext(); messageContext.NamespaceUris = context.NamespaceUris; messageContext.ServerUris = context.ServerUris; messageContext.Factory = context.EncodeableFactory; BinaryDecoder decoder = new BinaryDecoder(eventId, messageContext); string source = decoder.ReadString(null); string conditionName = decoder.ReadString(null); ftActiveTime.dwHighDateTime = decoder.ReadInt32(null); ftActiveTime.dwLowDateTime = decoder.ReadInt32(null); int cookie = decoder.ReadInt32(null); decoder.Close(); string methodName = "IOPCEventServer.AckCondition"; IntPtr pErrors = IntPtr.Zero; try { IOPCEventServer server = BeginComCall<IOPCEventServer>(methodName, true); server.AckCondition( 1, userName, commentText, new string[] { source }, new string[] { conditionName }, new System.Runtime.InteropServices.ComTypes.FILETIME[] { ftActiveTime }, new int[] { cookie }, out pErrors); } catch (Exception e) { ComCallError(methodName, e); return StatusCodes.BadUnexpectedError; } finally { EndComCall(methodName); } // unmarshal results. int[] errors = ComUtils.GetInt32s(ref pErrors, 1, true); if (errors[0] == ResultIds.S_ALREADYACKED) { return StatusCodes.BadConditionBranchAlreadyAcked; } else if (errors[0] < 0) { return StatusCodes.BadEventIdUnknown; } return StatusCodes.Good; }
/// <summary> /// Converts a VARIANT value to a Builtin Type. /// </summary> private object VariantValueToScalarValue(object value, NodeId builtinTypeId) { switch ((uint)builtinTypeId.Identifier) { case DataTypes.Guid: { return new Uuid((string)value); } case DataTypes.XmlElement: { XmlDocument document = new XmlDocument(); document.InnerXml = (string)value; return document.DocumentElement; } case DataTypes.NodeId: { return NodeId.Parse((string)value); } case DataTypes.ExpandedNodeId: { return ExpandedNodeId.Parse((string)value); } case DataTypes.QualifiedName: { return QualifiedName.Parse((string)value); } case DataTypes.LocalizedText: { return new LocalizedText(ComUtils.GetLocale(m_lcid), (string)value); } case DataTypes.StatusCode: { return new StatusCode((uint)value); } case DataTypes.DiagnosticInfo: { BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext); DiagnosticInfo decodedValue = decoder.ReadDiagnosticInfo(null); decoder.Close(); return decodedValue; } case DataTypes.DataValue: { BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext); DataValue decodedValue = decoder.ReadDataValue(null); decoder.Close(); return decodedValue; } case DataTypes.Structure: { BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext); ExtensionObject decodedValue = decoder.ReadExtensionObject(null); decoder.Close(); return decodedValue; } } return value; }
/// <summary> /// Updates the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="decoder">The decoder.</param> /// <param name="attibutesToLoad">The attributes to load.</param> public override void Update(ISystemContext context, BinaryDecoder decoder, AttributesToSave attibutesToLoad) { base.Update(context, decoder, attibutesToLoad); if ((attibutesToLoad & AttributesToSave.SuperTypeId) != 0) { m_superTypeId = decoder.ReadNodeId(null); } if ((attibutesToLoad & AttributesToSave.IsAbstract) != 0) { m_isAbstract = decoder.ReadBoolean(null); } }