Esempio n. 1
0
            /// <summary>
            /// Read the JSON object and convert to the object.  This will allow the serializer to
            /// automatically convert the object.  No special instructions need to be done and all
            /// the properties found in the JSON string need to be used.
            ///
            /// DataSet.EarthWaterMassDataSet decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject{DataSet.EarthWaterMassDataSet}(encodedEns)
            ///
            /// </summary>
            /// <param name="reader">NOT USED. JSON reader.</param>
            /// <param name="objectType">NOT USED> Type of object.</param>
            /// <param name="existingValue">NOT USED.</param>
            /// <param name="serializer">Serialize the object.</param>
            /// <returns>Serialized object.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                // Check if anything is written
                if (reader.TokenType != JsonToken.Null)
                {
                    // Load the object
                    JObject jsonObject = JObject.Load(reader);

                    // Decode the data
                    int NumElements        = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMELEMENTS];
                    int ElementsMultiplier = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ELEMENTSMULTIPLIER];

                    // Create the object
                    var data = new EarthWaterMassDataSet(DataSet.Ensemble.DATATYPE_FLOAT, NumElements, ElementsMultiplier, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.WaterMassEarthID);

                    // Velocity East
                    data.VelocityEast = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELEAST];

                    // Velocity North
                    data.VelocityNorth = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELNORTH];

                    // Velocity Vertical
                    data.VelocityVertical = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELVERTICAL];

                    // Water Mass Depth Layer
                    data.WaterMassDepthLayer = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_WATERMASSDEPTHLAYER];

                    return(data);
                }

                return(null);
            }
Esempio n. 2
0
            /// <summary>
            /// Read the JSON object and convert to the object.  This will allow the serializer to
            /// automatically convert the object.  No special instructions need to be done and all
            /// the properties found in the JSON string need to be used.
            ///
            /// DataSet.EarthWaterMassDataSet decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject{DataSet.EarthWaterMassDataSet}(encodedEns)
            ///
            /// </summary>
            /// <param name="reader">NOT USED. JSON reader.</param>
            /// <param name="objectType">NOT USED> Type of object.</param>
            /// <param name="existingValue">NOT USED.</param>
            /// <param name="serializer">Serialize the object.</param>
            /// <returns>Serialized object.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                // Check if anything is written
                if (reader.TokenType != JsonToken.Null)
                {
                    // Load the object
                    JObject jsonObject = JObject.Load(reader);

                    // Decode the data
                    int NumElements        = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMELEMENTS];
                    int ElementsMultiplier = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ELEMENTSMULTIPLIER];

                    // Create the object
                    var data = new EarthWaterMassDataSet(DataSet.Ensemble.DATATYPE_FLOAT, NumElements, ElementsMultiplier, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.WaterMassEarthID);

                    // Velocity East
                    data.VelocityEast = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELEAST];

                    // Velocity North
                    data.VelocityNorth = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELNORTH];

                    // Velocity Vertical
                    data.VelocityVertical = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELVERTICAL];

                    // Velocity Error
                    data.VelocityQ = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_VELQ];

                    // Water Mass Depth Layer
                    data.WaterMassDepthLayer = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_WATERMASSDEPTHLAYER];

                    // Water Mass Depth Layer Far
                    data.BtRefLayerFar = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_LAYER_FAR];

                    // Water Mass Depth Layer Min
                    data.BtRefLayerMin = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_LAYER_MIN];

                    // Water Mass Depth Layer Near
                    data.BtRefLayerNear = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_LAYER_NEAR];

                    // Water Mass Correlation Beam 0
                    data.BtRefLayerCorrBeam0 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_CORR_0];

                    // Water Mass Correlation Beam 1
                    data.BtRefLayerCorrBeam1 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_CORR_1];

                    // Water Mass Correlation Beam 2
                    data.BtRefLayerCorrBeam2 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_CORR_2];

                    // Water Mass Correlation Beam 3
                    data.BtRefLayerCorrBeam3 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_CORR_3];

                    // Water Mass Percent Good Beam 0
                    data.BtRefLayerPercentGoodBeam0 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_PG_0];

                    // Water Mass Percent Good Beam 1
                    data.BtRefLayerPercentGoodBeam1 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_PG_1];

                    // Water Mass Percent Good Beam 2
                    data.BtRefLayerPercentGoodBeam2 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_PG_2];

                    // Water Mass Percent Good Beam 3
                    data.BtRefLayerPercentGoodBeam3 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_PG_3];

                    // Water Mass Echo Intensity Beam 0
                    data.BtRefLayerEchoIntensityBeam0 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_ECHO_0];

                    // Water Mass Echo Intensity Beam 1
                    data.BtRefLayerEchoIntensityBeam1 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_ECHO_1];

                    // Water Mass Echo Intensity Beam 2
                    data.BtRefLayerEchoIntensityBeam2 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_ECHO_2];

                    // Water Mass Echo Intensity Beam 3
                    data.BtRefLayerEchoIntensityBeam3 = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_WM_ECHO_3];

                    return(data);
                }

                return(null);
            }