Пример #1
0
        /// <summary>
        /// 转换为TDOA定位结果
        /// </summary>
        /// <param name="pDataFrame"></param>
        /// <param name="pParameter"></param>
        protected override void InternalConverter(RmtpDataFrame pDataFrame, object pParameter)
        {
            var index = 0;

            Frequency = BitConverter.ToInt64(pDataFrame.Data, index);
            index    += sizeof(Int64);

            Count  = BitConverter.ToInt16(pDataFrame.Data, index);
            index += sizeof(UInt16);

            for (var i = 0; i < Count; i++)
            {
                var tdoa = new TdoaData();

                tdoa.IsValid = pDataFrame.Data[index];
                index       += 1;

                tdoa.Sequency = BitConverter.ToUInt16(pDataFrame.Data, index);
                index        += sizeof(UInt16);

                tdoa.Long = BitConverter.ToInt32(pDataFrame.Data, index);
                index    += sizeof(int);

                tdoa.Lat = BitConverter.ToInt32(pDataFrame.Data, index);
                index   += sizeof(int);

                tdoa.Height = BitConverter.ToInt32(pDataFrame.Data, index);
                index      += sizeof(int);

                tdoa.ConfidenceRadius = BitConverter.ToDouble(pDataFrame.Data, index);
                index += sizeof(double);

                tdoa.TdoaQuality = BitConverter.ToSingle(pDataFrame.Data, index);
                index           += sizeof(float);

                tdoa.LeftTopLong = BitConverter.ToInt32(pDataFrame.Data, index);
                index           += sizeof(int);

                tdoa.LeftTopLat = BitConverter.ToInt32(pDataFrame.Data, index);
                index          += sizeof(int);

                tdoa.RightBottomLong = BitConverter.ToInt32(pDataFrame.Data, index);
                index += sizeof(int);

                tdoa.RightBottomLat = BitConverter.ToInt32(pDataFrame.Data, index);
                index += sizeof(int);

                tdoa.DateType = pDataFrame.Data[index];
                index        += sizeof(byte);

                tdoa.FileExtension = Encoding.UTF8.GetString(pDataFrame.Data, index, 5);
                index += 5;

                tdoa.AreaWidth = BitConverter.ToInt32(pDataFrame.Data, index);
                index         += sizeof(int);

                tdoa.AreaHeight = BitConverter.ToInt32(pDataFrame.Data, index);
                index          += sizeof(int);

                tdoa.ResultLength = BitConverter.ToInt32(pDataFrame.Data, index);
                index            += sizeof(int);

                for (var j = 0; j < tdoa.ResultLength; j++)
                {
                    switch (tdoa.DateType)
                    {
                    case 0:
                        tdoa.LocationResults.Add(pDataFrame.Data[index]);
                        index += 1;
                        break;

                    case 1:
                        tdoa.LocationResults.Add(BitConverter.ToInt16(pDataFrame.Data, index));
                        index += sizeof(short);
                        break;

                    case 3:
                        tdoa.LocationResults.Add(BitConverter.ToInt32(pDataFrame.Data, index));
                        index += sizeof(int);
                        break;
                    }
                }

                tdoa.DeviceCount = pDataFrame.Data[index];
                index           += sizeof(byte);

                for (var j = 0; j < tdoa.DeviceCount; j++)
                {
                    var dpd = new DeviceSpectrumData();
                    dpd.Sequency = pDataFrame.Data[index];
                    index       += sizeof(byte);

                    dpd.IdLength = BitConverter.ToUInt16(pDataFrame.Data, index);
                    index       += sizeof(UInt16);

                    dpd.Id = Encoding.UTF8.GetString(pDataFrame.Data, index, dpd.IdLength);
                    index += dpd.IdLength;

                    MonitorIdList.Add(dpd.Id);

                    // 时域数据
                    dpd.TimeDomainDataType = pDataFrame.Data[index];
                    index += sizeof(byte);

                    dpd.TimeDomainDataCount = BitConverter.ToInt32(pDataFrame.Data, index);
                    index += sizeof(int);

                    dpd.XAxisUnit = Encoding.UTF8.GetString(pDataFrame.Data, index, 8);
                    index        += 8;

                    dpd.YAxisUnit = Encoding.UTF8.GetString(pDataFrame.Data, index, 8);
                    index        += 8;

                    dpd.SampleFrequency = BitConverter.ToDouble(pDataFrame.Data, index);
                    index += sizeof(double);

                    for (var k = 0; k < dpd.TimeDomainDataCount; k++)
                    {
                        if (dpd.TimeDomainDataType == 0)
                        {
                            dpd.TimeDomainDatas.Add(BitConverter.ToInt16(pDataFrame.Data, index));
                            index += sizeof(Int16);
                        }
                        else
                        {
                            dpd.TimeDomainDatas.Add(BitConverter.ToSingle(pDataFrame.Data, index));
                            index += sizeof(float);
                        }
                    }
                    // 频谱数据
                    dpd.SpectrumDataType = pDataFrame.Data[index];
                    index += sizeof(byte);

                    dpd.SpectrumDataCount = BitConverter.ToInt32(pDataFrame.Data, index);
                    index += sizeof(int);

                    for (var k = 0; k < dpd.SpectrumDataCount; k++)
                    {
                        if (dpd.SpectrumDataType == 0)
                        {
                            dpd.SpectrumDatas.Add(BitConverter.ToInt16(pDataFrame.Data, index));
                            index += sizeof(Int16);
                        }
                        else
                        {
                            dpd.SpectrumDatas.Add(BitConverter.ToSingle(pDataFrame.Data, index));
                            index += sizeof(float);
                        }
                    }

                    tdoa.DeviceDatas.Add(dpd);
                }
                // 相关数据
                tdoa.CorelationCount = pDataFrame.Data[index];
                index += sizeof(byte);

                for (var j = 0; j < tdoa.CorelationCount; j++)
                {
                    var csd = new CorelationData();
                    csd.LeftDeviceSequency = pDataFrame.Data[index];
                    index += sizeof(byte);

                    csd.RightDeviceSequency = pDataFrame.Data[index];
                    index += sizeof(byte);

                    csd.CorelationTdoa = BitConverter.ToDouble(pDataFrame.Data, index);
                    index += sizeof(double);

                    csd.CorelationQuality = BitConverter.ToDouble(pDataFrame.Data, index);
                    index += sizeof(double);

                    csd.XAxisUnit = Encoding.UTF8.GetString(pDataFrame.Data, index, 8);
                    index        += 8;

                    csd.YAxisUnit = Encoding.UTF8.GetString(pDataFrame.Data, index, 8);
                    index        += 8;

                    csd.StartTime = BitConverter.ToDouble(pDataFrame.Data, index);
                    index        += sizeof(double);

                    csd.TimeStep = BitConverter.ToDouble(pDataFrame.Data, index);
                    index       += sizeof(double);

                    csd.CorelationDataType = pDataFrame.Data[index];
                    index += sizeof(byte);

                    csd.CorelationDataCount = BitConverter.ToInt32(pDataFrame.Data, index);
                    index += sizeof(int);

                    for (var k = 0; k < csd.CorelationDataCount; k++)
                    {
                        if (csd.CorelationDataType == 0)
                        {
                            csd.CorelationDatas.Add(BitConverter.ToInt16(pDataFrame.Data, index));
                            index += sizeof(UInt16);
                        }
                        else
                        {
                            csd.CorelationDatas.Add(BitConverter.ToSingle(pDataFrame.Data, index));
                            index += sizeof(float);
                        }
                    }

                    tdoa.CorelationDatas.Add(csd);
                }

                Add(tdoa);
            }
            if (pDataFrame.Data.Length - index > 0)
            {
                SetPropertyValue(this, System.Text.Encoding.UTF8.GetString(pDataFrame.Data, index, pDataFrame.Data.Length - index));
            }
        }
Пример #2
0
 internal void Add(TdoaData pData)
 {
     _tdoaList.Add(pData);
 }