Esempio n. 1
0
        /// <summary>
        /// This method populates the base class data to the given proxy.
        /// </summary>
        /// <param name="proxy">Proxy.</param>
        protected void PopulateExtensibleResponseToProxy(XsdNs.ExtensibleResponseType proxy)
        {
            // Creating a data record to enclose result information
            var record     = new Item_DataRecord();
            var resultItem = new Item_Category(RequestResult.ToString());

            record.Add(RESULT_FIELD_NAME, resultItem);
            var messageItem = new Item_Text(RequestResultMessage);

            record.Add(MESSAGE_FIELD_NAME, messageItem);

            // Creating a proxy and adding it as an extension
            proxy.Extension = new object[1];
            var recordProp = (XsdNs.DataRecordPropertyType)record.GetObjectForXml_Result("ExtResp_");

            recordProp.DataRecord.identifier = IDENTIFIER;
            proxy.Extension[0] = recordProp;
        }
Esempio n. 2
0
        // This example shows
        // 1) How to create an Item_DataRecord object and enclose it in an Observation
        // 2) How to read an Item_DataRecord enclosed in an Observation

        public void Create()
        {
            // This example creates a data record with the following structure:
            // - dataRecord
            //   - MyMeas: Item_Measurement, 45.3 s, good quality (implicit)
            //   - MyTime: Item_TimeInstant, 2018-03-02T14:22:05Z, bad quality (explicit)
            //   - NestedRecord: Item_DataRecord
            //     - NestedMeas: Item_Measurement, -0.34 m, good quality (implicit)

            // The easiest way to add fields is to use the collection initialiser as below.
            // In each row, the items are as follows:
            // 1) the name of the data record field,
            // 2) the related Item_* object,
            // 3) data quality information (optional)
            var dataRecord = new MsgMeas.Item_DataRecord()
            {
                // Adding a measurement value
                { "MyMeas", new MsgMeas.Item_Measurement("s", 45.3) },

                // Adding a time instant
                { "MyTime", new MsgMeas.Item_TimeInstant(DateTime.Parse("2018-03-02T14:22:05Z").ToUniversalTime()),
                  MsgMeas.DataQuality.CreateBad() }
            };

            // You can also use the "Add" method. The code below shows this. In addition,
            // it shows that a data record can nest another data record.
            var nestedDataRecord = new MsgMeas.Item_DataRecord()
            {
                { "NestedMeas", new MsgMeas.Item_Measurement("m", -0.34) }
            };

            dataRecord.Add("NestedRecord", nestedDataRecord);

            // Now, you can include the data record in an Observation, for instance.
            var observation = new MsgMeas.Observation(dataRecord);
            var xmlBytes    = observation.ToXmlBytes();
            // Send XML bytes to network...
        }