private void applyone_Click(object sender, RoutedEventArgs e)
        {
            FreqCollectionIndex fci = (FreqCollectionIndex)grid_collectionData.GetFocusedRow();

            setCollectionLabel(fci);
            this.Close();
        }
예제 #2
0
        /// <summary>
        /// 获取所有采集ID
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <FreqCollectionIndex> getMeasureIds()
        {
            ObservableCollection <FreqCollectionIndex> tempList = new ObservableCollection <FreqCollectionIndex>();
            string           sql      = "select DISTINCT MeasureID,StartFreq,EndFreq,CurrentActivityPlaceName,StartTime,EndTime from FreqCollectionIndex order by StartTime desc";
            SQLiteCommand    commands = new SQLiteCommand(sql, con);
            SQLiteDataReader reader   = commands.ExecuteReader();

            while (reader.Read())
            {
                FreqCollectionIndex fci = new FreqCollectionIndex();
                fci.StartFreq = Convert.ToDouble(reader["StartFreq"]);
                fci.EndFreq   = Convert.ToDouble(reader["EndFreq"]);
                fci.MeasureID = reader["MeasureID"].ToString();
                fci.CurrentActivityPlaceName = reader["CurrentActivityPlaceName"].ToString();
                fci.DisplayMem = fci.MeasureID.Substring(7, fci.MeasureID.Length - 7);
                DateTime dt = DateTime.ParseExact(fci.DisplayMem, "yyyyMMddHHmmss", null);
                fci.DisplayMem = dt.ToString("M月d h时m分s秒");
                DateTime.TryParse(reader["StartTime"].ToString(), out dt);
                fci.StartTime = dt;
                DateTime.TryParse(reader["EndTime"].ToString(), out dt);
                fci.EndTime = dt;
                tempList.Add(fci);
            }
            return(tempList);
        }
        private void deleteone_Click(object sender, RoutedEventArgs e)
        {
            FreqCollectionIndex fci = (FreqCollectionIndex)grid_collectionData.GetFocusedRow();

            collectionDataSave.deleteByMeasureId(fci.MeasureID);
            grid_collectionData.ItemsSource = collectionDataSave.getMeasureIds();
            initComboxDataDelegate();
        }
예제 #4
0
        /// <summary>
        /// 获取数据库所有原始文件路径
        /// </summary>
        /// <returns></returns>
        public ArrayList getFileNames()
        {
            ArrayList        tempList = new ArrayList();
            string           sql      = "select * from FreqCollectionIndex where MeasureID='" + MeasureID + "'  order by StartTime";
            SQLiteCommand    commands = new SQLiteCommand(sql, con);
            SQLiteDataReader reader   = commands.ExecuteReader();

            while (reader.Read())
            {
                FreqCollectionIndex fci = new FreqCollectionIndex();
                fci.StartFreq = Convert.ToDouble(reader["StartFreq"]) * 1000;
                fci.EndFreq   = Convert.ToDouble(reader["EndFreq"]) * 1000;
                fci.FreqStep  = Convert.ToDouble(reader["Step"]);
                fci.FileAddr  = Application.StartupPath + "/SqliteData/" + reader["FileAddr"];
                //tempList.Add(Application.StartupPath + "/SqliteData/" + reader["FileAddr"]);
                tempList.Add(fci);
            }
            return(tempList);
        }
예제 #5
0
        //private void getFileNames()
        //{
        //    fileNameList = new ArrayList();
        //    CollectionDataSave cds = new CollectionDataSave();
        //    cds.openSQLiteConnection();
        //    fileNameList = cds.getFileNames();
        //}

        /// <summary>
        /// 读取原始文件进行分析
        /// </summary>
        private void readFileData()
        {
            Dictionary <double, FreqStatModel> temp = new Dictionary <double, FreqStatModel>();
            FreqStatModel freqStatModel             = null;

            for (int i = 0; i < fileNameList.Count; i++)
            {
                FreqCollectionIndex fci = (FreqCollectionIndex)fileNameList[i];
                double frequency        = fci.StartFreq;
                double step             = fci.FreqStep / 1000;
                using (FileStream fsRead = new FileStream(@fci.FileAddr, FileMode.Open))
                {
                    //long fsLen = (long)fsRead.Length;
                    //byte[] heByte = new byte[fsLen];
                    //int r = fsRead.Read(heByte, 0, heByte.Length);
                    //float[] targetData = new float[r / 4];
                    int countTemp = 0;
                    for (int k = 0; k < fsRead.Length; k += 4)
                    {
                        byte[] heBytetemp = new byte[4];
                        fsRead.Read(heBytetemp, 0, 4);
                        float targetData = BitConverter.ToSingle(heBytetemp, 0);
                        if (countTemp == freqCount)
                        {
                            countTemp = 0;
                            frequency = fci.StartFreq;
                        }
                        if (targetData + 107 < -20 || targetData + 107 > 100)
                        {
                            frequency += step;
                            countTemp++;
                            continue;
                        }
                        int AmplitudeValue = Convert.ToInt32(targetData) + 107;
                        if (!temp.ContainsKey(frequency))
                        {
                            //if (freqStatModel.DicAmplitudeCount != null)
                            //{
                            //    freqStatModel.DicAmplitudeCount.Clear();
                            //}
                            freqStatModel = new FreqStatModel();
                            freqStatModel.AmplitudeValue    = frequency;
                            freqStatModel.DicAmplitudeCount = new Dictionary <int, int>();
                            freqStatModel.DicAmplitudeCount.Add(AmplitudeValue, 1);
                            temp.Add(frequency, freqStatModel);
                        }
                        else
                        {
                            //freqStatModel = null;
                            freqStatModel = temp[frequency];
                            if (freqStatModel.DicAmplitudeCount.ContainsKey(AmplitudeValue))
                            {
                                freqStatModel.DicAmplitudeCount[AmplitudeValue] = freqStatModel.DicAmplitudeCount[AmplitudeValue] + 1;
                            }
                            else
                            {
                                freqStatModel.DicAmplitudeCount.Add(AmplitudeValue, 1);
                            }
                        }
                        frequency += step;
                        countTemp++;
                    }
                    //if (DataConvert(heByte, ref targetData))
                    //{
                    //    heByte = null;
                    //    for (int j = 0; j < targetData.Length; j++)
                    //    {
                    //        if (frequency > fci.EndFreq)
                    //        {
                    //            frequency = fci.StartFreq;
                    //        }
                    //        if (targetData[j] + 107 < -20 || targetData[j] + 107 > 100)
                    //        {
                    //            frequency += 25;
                    //            continue;
                    //        }
                    //        string AmplitudeValue = (Convert.ToInt32(targetData[j]) + 107).ToString();
                    //        if (!temp.ContainsKey(frequency))
                    //        {
                    //            //if (freqStatModel.DicAmplitudeCount != null)
                    //            //{
                    //            //    freqStatModel.DicAmplitudeCount.Clear();
                    //            //}
                    //            freqStatModel = new FreqStatModel();
                    //            freqStatModel.AmplitudeValue = frequency;
                    //            freqStatModel.DicAmplitudeCount = new Dictionary<string, int>();
                    //            freqStatModel.DicAmplitudeCount.Add(AmplitudeValue, 1);
                    //            temp.Add(frequency, freqStatModel);
                    //        }
                    //        else
                    //        {
                    //            freqStatModel = null;
                    //            freqStatModel = temp[frequency];
                    //            if (freqStatModel.DicAmplitudeCount.ContainsKey(AmplitudeValue))
                    //            {
                    //                freqStatModel.DicAmplitudeCount[AmplitudeValue] = freqStatModel.DicAmplitudeCount[AmplitudeValue] + 1;
                    //            }
                    //            else
                    //            {
                    //                freqStatModel.DicAmplitudeCount.Add(AmplitudeValue, 1);
                    //            }
                    //        }
                    //        frequency += 25;
                    //    }
                    //    targetData = null;
                    //}
                    fsRead.Close();
                    fsRead.Dispose();
                }
            }
            Dictionary <double, FreqStatModel> dictionaryAsc = temp.Where(x => x.Key >= Convert.ToDouble(freqNavBar.FreqStart) * 1000 && x.Key <= Convert.ToDouble(freqNavBar.FreqStop) * 1000).OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

            if (dictionaryAsc.Count == 0)
            {
                reminderBoxDelegate("选中频段超出数据范围!");
            }
            else
            {
                streamStatFile(dictionaryAsc);
                ctrlStatData(dictionaryAsc, freqNavBar);
            }
        }
 private void setCollectionLabel(FreqCollectionIndex freqCollectionIndex)
 {
     lab_collectIndex.Content = freqCollectionIndex.CurrentActivityPlaceName + "  " + freqCollectionIndex.DisplayMem;
     lab_collectIndex.Tag     = freqCollectionIndex;
 }