Ejemplo n.º 1
0
        /// <summary>
        /// Process the bytes received from UADP channel as Subscriber
        /// </summary>
        /// <param name="message"></param>
        /// <param name="source"></param>
        private void ProcessReceivedMessage(byte[] message, IPEndPoint source)
        {
            Utils.Trace(Utils.TraceMasks.Information, "UdpPubSubConnection.ProcessReceivedMessage from source={0}", source);

            List <DataSetReaderDataType> dataSetReaders         = GetOperationalDataSetReaders();
            List <DataSetReaderDataType> dataSetReadersToDecode = new List <DataSetReaderDataType>();

            foreach (DataSetReaderDataType dataSetReader in dataSetReaders)
            {
                // check if dataSetReaders have metadata information
                if (!ConfigurationVersionUtils.IsUsable(dataSetReader.DataSetMetaData))
                {
                    // check if it is possible to request the metadata information
                    if (dataSetReader.DataSetWriterId != 0)
                    {
                        m_udpDiscoverySubscriber.AddWriterIdForDataSetMetadata(dataSetReader.DataSetWriterId);
                    }
                }
                else
                {
                    dataSetReadersToDecode.Add(dataSetReader);
                }
            }

            UadpNetworkMessage networkMessage = new UadpNetworkMessage();

            networkMessage.DataSetDecodeErrorOccurred += NetworkMessage_DataSetDecodeErrorOccurred;
            networkMessage.Decode(MessageContext, message, dataSetReadersToDecode);
            networkMessage.DataSetDecodeErrorOccurred -= NetworkMessage_DataSetDecodeErrorOccurred;

            // Process the decoded network message
            ProcessDecodedNetworkMessage(networkMessage, source.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the "Simple" DataSetMetaData
        /// </summary>
        /// <returns></returns>
        private static DataSetMetaDataType CreateDataSetMetaDataSimple()
        {
            DataSetMetaDataType simpleMetaData = new DataSetMetaDataType();

            simpleMetaData.DataSetClassId = new Uuid(Guid.Empty);
            simpleMetaData.Name           = "Simple";
            simpleMetaData.Fields         = new FieldMetaDataCollection()
            {
                new FieldMetaData()
                {
                    Name           = "BoolToggle",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Boolean,
                    DataType       = DataTypeIds.Boolean,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int32",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int32,
                    DataType       = DataTypeIds.Int32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int32Fast",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int32,
                    DataType       = DataTypeIds.Int32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "DateTime",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.DateTime,
                    DataType       = DataTypeIds.DateTime,
                    ValueRank      = ValueRanks.Scalar
                },
            };
            // set the ConfigurationVersion relative to kTimeOfConfiguration constant
            simpleMetaData.ConfigurationVersion = new ConfigurationVersionDataType()
            {
                MinorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration),
                MajorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration)
            };

            return(simpleMetaData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the "AllTypes" DataSetMetaData
        /// </summary>
        /// <returns></returns>
        private static DataSetMetaDataType CreateDataSetMetaDataAllTypes()
        {
            DataSetMetaDataType allTypesMetaData = new DataSetMetaDataType();

            allTypesMetaData.DataSetClassId = new Uuid(Guid.Empty);
            allTypesMetaData.Name           = "AllTypes";
            allTypesMetaData.Fields         = new FieldMetaDataCollection()
            {
                new FieldMetaData()
                {
                    Name           = "BoolToggle",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Boolean,
                    DataType       = DataTypeIds.Boolean,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Byte",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Byte,
                    DataType       = DataTypeIds.Byte,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int16",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int16,
                    DataType       = DataTypeIds.Int16,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int32",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int32,
                    DataType       = DataTypeIds.Int32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "SByte",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.SByte,
                    DataType       = DataTypeIds.SByte,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt16",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt16,
                    DataType       = DataTypeIds.UInt16,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt32",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt32,
                    DataType       = DataTypeIds.UInt32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt64",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt64,
                    DataType       = DataTypeIds.UInt64,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Float",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Float,
                    DataType       = DataTypeIds.Float,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Double",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Double,
                    DataType       = DataTypeIds.Double,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "String",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.String,
                    DataType       = DataTypeIds.String,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "ByteString",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.ByteString,
                    DataType       = DataTypeIds.ByteString,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Guid",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Guid,
                    DataType       = DataTypeIds.Guid,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "DateTime",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.DateTime,
                    DataType       = DataTypeIds.DateTime,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt32Array",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt32,
                    DataType       = DataTypeIds.UInt32,
                    ValueRank      = ValueRanks.OneDimension
                },
            };
            // set the ConfigurationVersion relative to kTimeOfConfiguration constant
            allTypesMetaData.ConfigurationVersion = new ConfigurationVersionDataType()
            {
                MinorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration),
                MajorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration)
            };

            return(allTypesMetaData);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the "AllTypes" DataSet
        /// </summary>
        /// <returns></returns>
        private static PublishedDataSetDataType CreatePublishedDataSetAllTypes()
        {
            PublishedDataSetDataType publishedDataSetAllTypes = new PublishedDataSetDataType();

            publishedDataSetAllTypes.Name = "AllTypes"; //name shall be unique in a configuration
            // Define  publishedDataSetAllTypes.DataSetMetaData
            publishedDataSetAllTypes.DataSetMetaData = new DataSetMetaDataType();
            publishedDataSetAllTypes.DataSetMetaData.DataSetClassId = Uuid.Empty;
            publishedDataSetAllTypes.DataSetMetaData.Name           = publishedDataSetAllTypes.Name;
            publishedDataSetAllTypes.DataSetMetaData.Fields         = new FieldMetaDataCollection()
            {
                new FieldMetaData()
                {
                    Name           = "BoolToggle",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Boolean,
                    DataType       = DataTypeIds.Boolean,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Byte",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Byte,
                    DataType       = DataTypeIds.Byte,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int16",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int16,
                    DataType       = DataTypeIds.Int16,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Int32",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Int32,
                    DataType       = DataTypeIds.Int32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "SByte",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.SByte,
                    DataType       = DataTypeIds.SByte,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt16",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt16,
                    DataType       = DataTypeIds.UInt16,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt32",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt32,
                    DataType       = DataTypeIds.UInt32,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt64",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt64,
                    DataType       = DataTypeIds.UInt64,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Float",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Float,
                    DataType       = DataTypeIds.Float,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Double",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Double,
                    DataType       = DataTypeIds.Double,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "String",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.String,
                    DataType       = DataTypeIds.String,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "ByteString",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.ByteString,
                    DataType       = DataTypeIds.ByteString,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "Guid",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.Guid,
                    DataType       = DataTypeIds.Guid,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "DateTime",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.DateTime,
                    DataType       = DataTypeIds.DateTime,
                    ValueRank      = ValueRanks.Scalar
                },
                new FieldMetaData()
                {
                    Name           = "UInt32Array",
                    DataSetFieldId = new Uuid(Guid.NewGuid()),
                    BuiltInType    = (byte)DataTypes.UInt32,
                    DataType       = DataTypeIds.UInt32,
                    ValueRank      = ValueRanks.OneDimension
                },
            };

            // set the ConfigurationVersion relative to kTimeOfConfiguration constant
            publishedDataSetAllTypes.DataSetMetaData.ConfigurationVersion = new ConfigurationVersionDataType()
            {
                MinorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration),
                MajorVersion = ConfigurationVersionUtils.CalculateVersionTime(kTimeOfConfiguration)
            };
            PublishedDataItemsDataType publishedDataSetAllTypesSource = new PublishedDataItemsDataType();

            //create PublishedData based on metadata names
            foreach (var field in publishedDataSetAllTypes.DataSetMetaData.Fields)
            {
                publishedDataSetAllTypesSource.PublishedData.Add(
                    new PublishedVariableDataType()
                {
                    PublishedVariable = new NodeId(field.Name, PublishedValuesWrites.NamespaceIndexAllTypes),
                    AttributeId       = Attributes.Value,
                });
            }
            publishedDataSetAllTypes.DataSetSource = new ExtensionObject(publishedDataSetAllTypesSource);

            return(publishedDataSetAllTypes);
        }