Пример #1
0
 /// <summary>
 /// Creates the message.
 /// </summary>
 /// <param name="encoding">The selected encoding for the message.</param>
 /// <param name="prodicerId">The prodicer identifier.</param>
 /// <param name="dataSetWriterId">The data set writer identifier.</param>
 /// <param name="fieldCount">The field count.</param>
 /// <param name="sequenceNumber">The sequence number.</param>
 /// <param name="timeStamp">The time stamp.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 protected internal override void CreateMessage(FieldEncodingEnum encoding, Guid prodicerId, ushort dataSetWriterId, ushort fieldCount, ushort sequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     OnMessageAdding(prodicerId, dataSetWriterId);
       MessageHeader = MessageHeader.GetProducerMessageHeader(this, encoding, m_lengthFieldType, MessageTypeEnum.DataKeyFrame, configurationVersion);
       //Create message header and placeholder for further header content.
       MessageHeader.FieldCount = fieldCount;
       MessageHeader.MessageSequenceNumber = sequenceNumber;
       MessageHeader.TimeStamp = timeStamp;
 }
Пример #2
0
 /// <summary>
 /// Sends the data described by a data set collection to remote destination.
 /// </summary>
 /// <param name="producerBinding">Encapsulates functionality used by the <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageWriter" /> to collect all the data (data set items) required to prepare new message and send it over the network.</param>
 /// <param name="length">Number of items to be send used to calculate the length of the message.</param>
 /// <param name="contentMask">The content mask represented as unsigned number <see cref="T:System.UInt64" />. The order of the bits starting from the least significant
 /// bit matches the order of the data items within the data set.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="dataSelector">The data selector.</param>
 /// <param name="messageSequenceNumber">The message sequence number. A monotonically increasing sequence number assigned by the publisher to each message sent.</param>
 /// <param name="timeStamp">The time stamp - the time the Data was collected.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 /// <exception cref="ArgumentOutOfRangeException">length</exception>
 public void Send(Func<int, IProducerBinding> producerBinding, ushort length, ulong contentMask, FieldEncodingEnum encoding, DataSelector 
     dataSelector, ushort messageSequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     if (length > 2)
     throw new ArgumentOutOfRangeException("length");
       m_Buffer = new Object[length];
       for (int i = 0; i < 2; i++)
     m_Buffer[i] = producerBinding(i);
       m_HaveSendData = true;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProducerAssociation"/> class.
 /// </summary>
 /// <param name="data">The semantic data description.</param>
 /// <param name="aliasName">Name of the alias - .</param>
 /// <param name="dataSet">The data set configuration.</param>
 /// <param name="bindingFactory">The binding factory.</param>
 /// <param name="encodingFactory">The encoding factory.</param>
 internal ProducerAssociation(ISemanticData data, string aliasName, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory)
     : base(data, dataSet.AssociationName)
 {
     m_ConfigurationVersion = dataSet.ConfigurationVersion;
       m_DataSetBindings =
     dataSet.DataSet.Select<FieldMetaData, IProducerBinding>
     ((_fieldMetadata) =>
     {
       IProducerBinding _ret = _fieldMetadata.GetProducerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory);
       _ret.PropertyChanged += ProducerBinding_PropertyChanged;
       return _ret;
     }).ToArray<IProducerBinding>();
       m_Timer = new Timer(1000) { AutoReset = true };
       m_Timer.Elapsed += M_Timer_Elapsed;
       m_Timer.Start();
 }
Пример #4
0
 public ProducerMessageHeader(IBinaryHeaderEncoder writer, FieldEncodingEnum encoding, MessageLengthFieldTypeEnum lengthFieldType, MessageTypeEnum messageType, ConfigurationVersionDataType configurationVersion)
 {
     m_MessageType = messageType;
     m_Encoding = encoding;
     m_lengthFieldType = lengthFieldType;
     m_HeaderWriter = new HeaderWriter(writer, PackageHeaderLength());
     MessageSequenceNumber = 0;
     ConfigurationVersion = configurationVersion;
 }
Пример #5
0
 /// <summary>
 /// Gets the producer message header.
 /// </summary>
 /// <param name="writer">The writer <see cref="IBinaryHeaderEncoder" /> to populate the payload with the header information.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="lengthFieldType">Type of the length field in the the message header.</param>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 /// <returns>MessageHeader.</returns>
 internal static MessageHeader GetProducerMessageHeader(IBinaryHeaderEncoder writer, FieldEncodingEnum encoding, MessageLengthFieldTypeEnum lengthFieldType, MessageTypeEnum messageType, ConfigurationVersionDataType configurationVersion)
 {
     return new ProducerMessageHeader(writer, encoding, lengthFieldType, messageType, configurationVersion);
 }
Пример #6
0
        /// <summary>
        /// Sends the data described by a data set collection to remote destination.
        /// </summary>
        /// <param name="producerBinding">Encapsulates functionality used by the <see cref="IMessageWriter" /> to collect all the data (data set items) required to prepare new message and send it over the network.</param>
        /// <param name="length">Number of items to be send used to calculate the length of the message.</param>
        /// <param name="contentMask">The content mask represented as unsigned number <see cref="UInt64" />. The order of the bits starting from the least significant
        /// bit matches the order of the data items within the data set.</param>
        /// <param name="encoding">The encoding.</param>
        /// <param name="dataSelector">The data selector.</param>
        /// <param name="messageSequenceNumber">The message sequence number. A monotonically increasing sequence number assigned by the publisher to each message sent.</param>
        /// <param name="timeStamp">The time stamp - the time the Data was collected.</param>
        /// <param name="configurationVersion">The configuration version.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">Impossible to convert null value
        /// or</exception>
        void IMessageWriter.Send(Func<int, IProducerBinding> producerBinding, ushort length, ulong contentMask, FieldEncodingEnum encoding, DataSelector dataSelector,
            ushort messageSequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
        {
            lock (this)
              {
            if (State.State != HandlerState.Operational)
              return;
            ContentMask = contentMask;

            CreateMessage(encoding, dataSelector.PublisherId, dataSelector.DataSetWriterId, length, messageSequenceNumber, timeStamp, configurationVersion);
            //UInt64 _mask = 0x1;
            for (int i = 0; i < length; i++)
            {
              //TODO: Implement ContentMask https://github.com/mpostol/OPC-UA-OOI/issues/89
              //if ((ContentMask & _mask) > 0)
              //{
              IProducerBinding _pb = producerBinding(i);
              switch (encoding)
              {
            case FieldEncodingEnum.VariantFieldEncoding:
              WriteValueVariant(_pb);
              break;
            case FieldEncodingEnum.CompressedFieldEncoding:
              WriteValue(_pb);
              break;
            case FieldEncodingEnum.DataValueFieldEncoding:
              WriteDataValue(_pb);
              break;
              }
              //}
              //_mask = _mask << 1;
            }
            SendMessage();
              }
        }
Пример #7
0
 //methods
 /// <summary>
 /// Creates the message.
 /// </summary>
 /// <param name="encoding">The selected encoding for the message.</param>
 /// <param name="prodicerId">The prodicer identifier.</param>
 /// <param name="dataSetWriterId">The data set writer identifier.</param>
 /// <param name="fieldCount">The field count.</param>
 /// <param name="sequenceNumber">The sequence number.</param>
 /// <param name="timeStamp">The time stamp.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 protected internal abstract void CreateMessage(FieldEncodingEnum encoding, Guid prodicerId, UInt16 dataSetWriterId, ushort fieldCount, ushort sequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion);
 public void Send(Func<int, IProducerBinding> producerBinding, ushort length, ulong contentMask, FieldEncodingEnum encoding, DataSelector dataSelector, 
     ushort messageSequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     IsOk++;
     Assert.AreEqual<int>(3, length);
 }
Пример #9
0
 protected internal override void CreateMessage(FieldEncodingEnum encoding, Guid prodicerId, ushort dataSetWriterId, ushort fieldCount, ushort sequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     MassageCreated = true;
 }
 public void ConfigurationVersionDataTypeTestMethod()
 {
     ConfigurationVersionDataType _newInstance = new ConfigurationVersionDataType() { MajorVersion = 1, MinorVersion = 2 };
       Assert.AreEqual<string>("1.2", _newInstance.ToString());
 }