OrgData.cs 2.6 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FLY.Simulation.Blowing
{
    class OrgData
    {
        static int[] data = new int[]{
3518	,
3484	,
3634	,
3620	,
3579	,
3625	,
3635	,
3638	,
3635	,
3606	,
3611	,
3603	,
3590	,
3631	,
3646	,
3647	,
3710	,
3705	,
3607	,
3720	,
3680	,
3637	,
3659	,
3703	,
3860	,
3720	,
3615	,
3810	,
3772	,
3666	,
3614	,
3627	,
3618	,
3502	,
3575	,
3583	,
3615	,
3680	,
3730	,
3840	,
3927	,
3946	,
3923	,
3841	,
3797	,
3865	,
3810	,
3711	,
3754	,
3705	,
3723	,
3699	,
3723	,
3801	,
3786	,
3798	,
3907	,
3945	,
3828	,
3860	,
3846	,
3903	,
3871	,
3844	,
3759	,
3816	,
3886	,
3815	,
3789	,
3876	,
3942	,
3854	,
3842	,
3921	,
3846	,
3835	,
3886	,
3881	,
3820	,
3787	,
3730	,
3617	,
3650	,
3610	,
3536	,
3545	,
3564	,
3584	,
3580	,
3572	,
3571	,
3579	,
3620	,
3634	,
3484	,
3518	
        };

        public static int[] GetData(int cnt)
        {
            int idx;
            int dat;
            int last_idx;
            int last_dat;
            //数据扩展
            int[] list = new int[cnt];
            int list_idx = 0;
            idx = 0;
            dat = data[0];
            list[list_idx] = dat;
            list_idx++;

            last_idx = idx;
            last_dat = dat;

            for (int i = 0; i < data.Length; i++)
            {
                idx = i * cnt / data.Length;
                dat = data[i];

                for (int j = last_idx + 1; j <= idx; j++)
                {
                    int d = (j - last_idx) * (dat - last_dat) / (idx - last_idx) + last_dat;
                    list[list_idx] = d;
                    list_idx++;
                }
                last_idx = idx;
                last_dat = dat;
            }
            idx = cnt;
            dat = data[0];

            for (int j = last_idx + 1; j < cnt; j++)
            {
                int d = (j - last_idx) * (dat - last_dat) / (idx - last_idx) + last_dat;
                list[list_idx] = d;
                list_idx++;

            }

            //对数据滤波
            int[] data2 = new int[cnt];
            int w = (cnt/data.Length);
            for (int i = 0; i < cnt; i++)
            {
                int sum = 0;
                for (int j = (i - w / 2); j < (i - w / 2 + w); j++) 
                {
                    int index = j;
                    if (index < 0)
                        index += cnt;
                    else if (index >= cnt)
                        index -= cnt;
                    sum += list[index];
                }
                data2[i] = sum / w;
            }
            return data2;
        }
    }
}