Example #1
0
 private void GetReadingDetailsForChannel(DAQChannel ch)
 {
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     parameters.Add("@cid",ch.ID);
     IDataReader reader = ExecuteQuery("SELECT rd_id,rd_time,rd_point from READING_DETAIL where rd_cid = @cid order by rd_time asc", parameters);
     while (reader.Read())
     {
         ReadingDetail rd = new ReadingDetail();
         rd.ID = reader.GetInt32(0);
         rd.ParentChannel = ch;
         rd.Time = reader.GetInt32(1);
         rd.Reading = reader.GetFloat(2);
         ch.ReadingDetails.Add(rd);
     }
     reader.Close();
 }
Example #2
0
 public ReadingDetail CreateDetailForChannelandReading(DAQChannel ch, int time, int reading)
 {
     ReadingDetail rd = new ReadingDetail();
     rd.Time = time;
     rd.Reading = reading;
     rd.ParentChannel = ch;
     SQLiteCommand cmd = _connection.CreateCommand();
     cmd.CommandText = Properties.Settings.Default.INSERT_READING_DETAIL;
     cmd.Parameters.Add(new SQLiteParameter("@rid", ch.ParentReading.ID));
     cmd.Parameters.Add(new SQLiteParameter("@cid", ch.ID));
     cmd.Parameters.Add(new SQLiteParameter("@time", time));
     cmd.Parameters.Add(new SQLiteParameter("@point", reading));
     int rdid = Convert.ToInt32(cmd.ExecuteScalar());
     rd.ID = rdid;
     ch.ReadingDetails.Add(rd);
     return rd;
 }
Example #3
0
 private void GetChannelsForReading(Reading r)
 {
     Dictionary<int, ChannelConfig> configDictionary = new Dictionary<int, ChannelConfig>();
     foreach (ChannelConfig cc in GetChannelConfigs())
     {
         configDictionary.Add(cc.ID, cc);
     }
     Dictionary<string,object> parameters = new Dictionary<string,object>();
     parameters.Add("@rid",r.ID);
     IDataReader reader = ExecuteQuery("SELECT c_id,c_details,c_channelnumber,c_ccid from channel where c_rid = @rid ORDER by c_channelnumber asc", parameters);
     while (reader.Read())
     {
         DAQChannel ch = new DAQChannel();
         int ccid = reader.GetInt32(3);
         ch.Config = configDictionary[ccid];
         ch.ID = reader.GetInt32(0);
         ch.Details = reader.GetString(1);
         ch.Channel = reader.GetInt32(2);
         ch.ParentReading = r;
         r.ChannelList.Add(ch);
     }
     reader.Close();
     foreach (DAQChannel ch in r.ChannelList)
     {
         GetReadingDetailsForChannel(ch);
     }
 }
Example #4
0
        public DAQChannel CreateChannelForReading(Reading r,ChannelConfig cc, string details,int number)
        {
            SQLiteCommand cmd = _connection.CreateCommand();
            cmd.CommandText = Properties.Settings.Default.INSERT_CHANNEL;
            cmd.Parameters.Add(new SQLiteParameter("@rid",r.ID));
            cmd.Parameters.Add(new SQLiteParameter("@details",details));
            cmd.Parameters.Add(new SQLiteParameter("@number",number));
            cmd.Parameters.Add(new SQLiteParameter("@channelconfig", cc.ID));
            int cid = Convert.ToInt32(cmd.ExecuteScalar());

            DAQChannel ch = new DAQChannel();
            ch.ID = cid;
            ch.Details = details;
            ch.ParentReading = r;
            ch.Channel = number;
            ch.Config = cc;
            r.ChannelList.Add(ch);
            return ch;
        }