Ejemplo n.º 1
0
        private BsonDocument buildMSATemperature(ModuleMSATemperatureTest tcd)
        {
            Measurement measurement = null;

            // Initialize object that will be stored under 'device' in mongo document
            BsonDocument nestedDevice = null;
            if (tcd.ModuleTest != null)
            {
                try
                {
                    measurement = tcd.ModuleTest.Measurement;
                }
                catch (Exception exc)
                {
                    Program.log("ERROR Module MSA test: " + tcd.Id + " - " + exc.Message);
                }
                finally
                {
                    nestedDevice = SyncManager.Instance.getNestedDevice(measurement);
                }
            }
            if (nestedDevice == null)
                return null;

            // Initialize object that will be stored under 'meta' in mongo document
            BsonDocument nestedMeta = SyncManager.Instance.getNestedMeta(measurement);
            if (nestedMeta == null)
                return null;

            // Initialize object that will be stored under 'data' in mongo document
            BsonDocument nestedData = SyncManager.Instance.getNestedData(tcd, excludeDataFields);

            // Custom code to move some set fields to meta object
            nestedMeta.Add("SetTemperature_C", nestedData["SetTemperature_C"]);
            nestedData.Remove("SetTemperature_C");
            nestedMeta.Add("SetVoltage", nestedData["VccSetPoint"]);
            nestedData.Remove("VccSetPoint");

            //System.Diagnostics.Trace.WriteLine("D " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            // Initialize object in root of the document
            BsonDocument rootDoc = new BsonDocument {
                 { "_id",  tcd.Id.ToString()},
                 { "mid", measurement.Id.ToString()},
                 { "timestamp", tcd.TimeStamp},
                 { "type", domain() },
                 { "subtype",  "msatemp" },
                 { "result", getResult( nestedData["Result"].ToString()) },
                 { "downstatus", getDownStatus( nestedData["Result"].ToString()) },
                 { "status", getStatus(measurement.Result) }
            };
            nestedData.Remove("Result");

            rootDoc.Add("device", nestedDevice);
            rootDoc.Add("meta", nestedMeta);
            rootDoc.Add("data", nestedData);

            return rootDoc;
        }
Ejemplo n.º 2
0
        private BsonDocument buildMSATemperature(ModuleMSATemperatureTest tcd)
        {
            Measurement measurement = null;

            // Initialize object that will be stored under 'device' in mongo document
            BsonDocument nestedDevice = null;

            if (tcd.ModuleTest != null)
            {
                try
                {
                    measurement = tcd.ModuleTest.Measurement;
                }
                catch (Exception exc)
                {
                    Program.log("ERROR Module MSA test: " + tcd.Id + " - " + exc.Message);
                }
                finally
                {
                    nestedDevice = SyncManager.Instance.getNestedDevice(measurement);
                }
            }
            if (nestedDevice == null)
            {
                return(null);
            }

            // Initialize object that will be stored under 'meta' in mongo document
            BsonDocument nestedMeta = SyncManager.Instance.getNestedMeta(measurement);

            if (nestedMeta == null)
            {
                return(null);
            }

            // Initialize object that will be stored under 'data' in mongo document
            BsonDocument nestedData = SyncManager.Instance.getNestedData(tcd, excludeDataFields);

            // Custom code to move some set fields to meta object
            nestedMeta.Add("SetTemperature_C", nestedData["SetTemperature_C"]);
            nestedData.Remove("SetTemperature_C");
            nestedMeta.Add("SetVoltage", nestedData["VccSetPoint"]);
            nestedData.Remove("VccSetPoint");

            //System.Diagnostics.Trace.WriteLine("D " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            // Initialize object in root of the document
            BsonDocument rootDoc = new BsonDocument {
                { "_id", tcd.Id.ToString() },
                { "mid", measurement.Id.ToString() },
                { "timestamp", tcd.TimeStamp },
                { "type", domain() },
                { "subtype", "msatemp" },
                { "result", getResult(nestedData["Result"].ToString()) },
                { "downstatus", getDownStatus(nestedData["Result"].ToString()) },
                { "status", getStatus(measurement.Result) }
            };

            nestedData.Remove("Result");

            rootDoc.Add("device", nestedDevice);
            rootDoc.Add("meta", nestedMeta);
            rootDoc.Add("data", nestedData);

            return(rootDoc);
        }