Example #1
0
        public WaveForm GetWaveForm(string name)
        {
            SqlConnection cn       = new SqlConnection(cnStr);
            WaveForm      waveform = null;

            try
            {
                cn.Open();
                SqlCommand sqlCommand = new SqlCommand("getWaveForm", cn);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                //add params
                SqlParameter param = new SqlParameter();
                param.ParameterName = "@WaveFormName";
                param.Value         = name;
                param.SqlDbType     = SqlDbType.NVarChar;
                param.Direction     = ParameterDirection.Input;
                sqlCommand.Parameters.Add(param);

                SqlDataReader myDataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
                if (myDataReader.Read())
                {
                    string type = myDataReader.GetString(1);

                    double frequency = myDataReader.GetDouble(2);
                    double bandwidth = myDataReader.GetDouble(3);
                    double?phase     = null;
                    if (!myDataReader.IsDBNull(4))
                    {
                        phase = myDataReader.GetDouble(4);
                    }
                    double?startFre = null;
                    if (!myDataReader.IsDBNull(5))
                    {
                        startFre = myDataReader.GetDouble(5);
                    }
                    double?endFre = null;
                    if (!myDataReader.IsDBNull(6))
                    {
                        endFre = myDataReader.GetDouble(6);
                    }
                    double?rolloffFactor = null;
                    if (!myDataReader.IsDBNull(7))
                    {
                        rolloffFactor = myDataReader.GetDouble(7);
                    }
                    string frechangeRate = null;
                    if (!myDataReader.IsDBNull(8))
                    {
                        frechangeRate = myDataReader.GetString(8);
                    }
                    waveform = new WaveForm(name, type, frequency, bandwidth, phase, startFre, endFre, rolloffFactor, frechangeRate);
                }

                return(waveform);
            }
            catch (SqlException ex)
            {
                LogFileManager.ObjLog.error(ex.Message);
                return(null);

                throw ex;
            }
            finally
            {
                cn.Close();
            }
        }