示例#1
0
        void _ReadMonReadings(DGObjects objs)
        {
            if (objs.rawDataSet.Tables.Count <= 1)
            {
                return;
            }

            DataTable dt = objs.rawDataSet.Tables[1];

            foreach (DataRow row in dt.Rows)
            {
                if (IsDbNull(row, "monPointName") || IsDbNull(row, "time"))
                {
                    continue;
                }
                // if both the reading and the value are null, skip it
                if (IsDbNull(row, "reading") && IsDbNull(row, "value"))
                {
                    continue;
                }

                MonReading reading = new MonReading();
                reading.monPointName = ReadString(row, "monPointName");
                reading.time         = ReadDateTime(row, "time").Value;
                reading.component    = ReadString(row, "component");
                reading.reading      = ReadString(row, "reading");
                reading.unit         = ReadString(row, "unit");

                double?value = ReadDouble(row, "value");
                if (value == null)
                {
                    try
                    {
                        reading.value = Double.Parse(reading.reading);
                    }
                    catch (Exception)
                    {
                        // do nothing
                    }
                }
                else
                {
                    reading.value = value.Value;
                }

                MonPoint monPnt;
                if (objs.containsKey(reading.monPointName))
                {
                    monPnt = objs[reading.monPointName] as MonPoint;
                }
                else
                {
                    continue;
                }

                _AddReading(monPnt, reading);
            }
        }
示例#2
0
        void _AddReading(MonPoint monPnt, MonReading reading)
        {
            Dictionary <string, List <MonReading> > readingsDict =
                monPnt.readingsDict;
            List <MonReading> readings;

            if (readingsDict.ContainsKey(reading.component))
            {
                readings = readingsDict[reading.component];
            }
            else
            {
                readings = new List <MonReading>();
                readingsDict[reading.component] = readings;
            }
            readings.Add(reading);
        }
示例#3
0
 void _AddReading(MonPoint monPnt, MonReading reading)
 {
     Dictionary<string, List<MonReading>> readingsDict =
         monPnt.readingsDict;
     List<MonReading> readings;
     if (readingsDict.ContainsKey(reading.component))
         readings = readingsDict[reading.component];
     else
     {
         readings = new List<MonReading>();
         readingsDict[reading.component] = readings;
     }
     readings.Add(reading);
 }
示例#4
0
        void _ReadMonReadings(DGObjects objs)
        {
            if (objs.rawDataSet.Tables.Count <= 1)
                return;

            DataTable dt = objs.rawDataSet.Tables[1];
            foreach (DataRow row in dt.Rows)
            {
                if (IsDbNull(row, "monPointName") || IsDbNull(row, "time"))
                    continue;
                // if both the reading and the value are null, skip it
                if (IsDbNull(row, "reading") && IsDbNull(row, "value"))
                    continue;

                MonReading reading = new MonReading();
                reading.monPointName = ReadString(row, "monPointName");
                reading.time = ReadDateTime(row, "time").Value;
                reading.component = ReadString(row, "component");
                reading.reading = ReadString(row, "reading");
                reading.unit = ReadString(row, "unit");

                double? value = ReadDouble(row, "value");
                if (value == null)
                {
                    try
                    {
                        reading.value = Double.Parse(reading.reading);
                    }
                    catch(Exception)
                    {
                        // do nothing
                    }
                }
                else
                    reading.value = value.Value;

                MonPoint monPnt;
                if (objs.containsKey(reading.monPointName))
                    monPnt = objs[reading.monPointName] as MonPoint;
                else
                    continue;

                _AddReading(monPnt, reading);
            }
        }