Ejemplo n.º 1
0
        public static ArrayList SelectStimulusSet(long seriesConfigId, string dbConnectionString)
        {
            ArrayList result = new ArrayList();

            using (SqlConnection connection = new SqlConnection(dbConnectionString))
            {
                connection.Open();
                using (SqlCommand select = new SqlCommand())
                {
                    select.CommandType = CommandType.StoredProcedure;
                    select.CommandText = "SelectFullStimulusSetForSeriesConfig";
                    select.Connection  = connection;

                    SqlParameter param = select.Parameters.Add("@series_config_id", SqlDbType.BigInt, 1);
                    param.Value = seriesConfigId;

                    using (SqlDataReader reader = select.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Stimulus s = new Stimulus();
                            int      i = 0;
                            s.Id       = reader.GetInt64(0);
                            s.Name     = reader.GetString(1);
                            s.Filename = reader.GetString(2);
                            s.Type     = (StimulusType)reader.GetInt64(3);
                            s.Prob     = reader.GetDouble(4);
                            reader.GetInt64(5);
                            s.Pos = (Position)reader.GetInt64(6);

                            /*
                             * Stimulus.id, Stimulus.name, Stimulus.filename, Stimulus.type, Stimulus.prob,  SeriesStimulus.series_config_id
                             */
                            result.Add(s);
                        }
                    }
                }
            }
            return(result);
        }
        public Stimulus GetStimulusForTime(int time)
        {
            Order order = Config.OrderType;

            switch (order)
            {
            case Order.Fixed:
            {
                int  interval = (int)Config.MaxInt;
                int  index    = time / interval - 1;
                bool exact    = time % interval < Constants.TIME_CHUNK_MS;
                if (index >= 0 && index < Config.SelectedStimulusSet.Count && exact)
                {
                    Stimulus s = (Stimulus)Config.SelectedStimulusSet[index];
                    return(s);
                }
            }
            break;

            case Order.Probability:
                break;
            }
            return(null);
        }