Пример #1
0
        public void PushChannelData(byte[] t, double StartFreq, int channel, DataTime datatime, TimeInfo timeInfo)
        {
            m_channel   = channel;
            m_StartFreq = StartFreq;
            m_StopFreq  = m_StartFreq + 0.5;//每个子带的带宽LX

            /*记录文件初始化*/
            if (m_FlagSaveLast == false && m_FlagSave == true)
            {
                string time = timeInfo.year.ToString("d") + "_" + timeInfo.month.ToString("d") + "_" + timeInfo.day_offset.ToString("d") + "_" + timeInfo.hour.ToString("d") + "_" + timeInfo.minute.ToString("d") + "_" + timeInfo.second.ToString("d") + "_" + timeInfo.millisecond.ToString("d") + "_" + timeInfo.microsecond.ToString("d");
                path = @"\...\...\RecvData\";
                DirectoryInfo fi = new DirectoryInfo(path);
                if (!fi.Exists)
                {
                    fi.Create();
                }
                fs             = new FileStream(path + @"\" + time + ".dat", FileMode.OpenOrCreate | FileMode.Append);
                m_FlagSaveLast = true;
            }
            else if (m_FlagSaveLast == true && m_FlagSave == false)
            {
                fs.Close();
                m_FlagSaveLast = false;
            }
            if (m_FlagSave == true)
            {
                fs.Write(t, 0, (int)t.Length);
            }

            if (m_FlagTime == true)
            {
                m_time_count++;
                DataAndTime nDataAndTime = new DataAndTime();
                nDataAndTime.Time = datatime;
                nDataAndTime.Data = new byte[(int)t.Length];
                Buffer.BlockCopy(t, 0, nDataAndTime.Data, 0, (int)t.Length);
                m_queue.Enqueue(nDataAndTime);
                if (m_time_count >= 1250)
                {
                    m_time_count = 0;
                    m_FlagTime   = false;
                }
            }
            /////////////////////////////////////////////////////////////////
        }
Пример #2
0
        public DataTime Transform_DataTime(byte[] t)//时间戳解析方式LX
        {
            DataTime datatime = new DataTime();

            datatime.year   = Convert.ToUInt16((t[0] >> 1) & 0xff);
            datatime.month  = Convert.ToUInt16(((t[0] & 0x01) << 1) + ((t[1] >> 5) & 0xff));
            datatime.day    = Convert.ToUInt16(t[1] & 0x1f);
            datatime.hour   = Convert.ToUInt16((t[2] >> 4) & 0xff);
            datatime.minute = Convert.ToUInt16(((t[2] & 0x0f) << 2) + ((t[3] >> 6) & 0xff));
            datatime.second = Convert.ToUInt16(t[3] & 0x3f);

            byte[] Nanosecond = new byte[4];
            Array.Copy(t, 4, Nanosecond, 0, 4);
            Array.Reverse(Nanosecond);
            UInt32 nanosecond = BitConverter.ToUInt32(Nanosecond, 0) * 3;

            datatime.millisecond = Convert.ToUInt32(nanosecond / 1000);
            datatime.microsecond = Convert.ToUInt32(nanosecond % 1000);
            return(datatime);
        }