Exemple #1
0
        public ChannelPower(double emiRbw, ChannelSetting channelSetting, 
            LimitSetting limitSetting, WatsEmiData watsEmiData)
        {
            foreach (WatsEmiSample sample in watsEmiData.mHSamples)
                mHPower += Math.Pow(10, sample.mRssi / 10);
            mHPower = mHPower / watsEmiData.mHSamples.Count;
            mHPower = 10 * Math.Log10(channelSetting.BandWidth * 1000 * mHPower / emiRbw);

            foreach (WatsEmiSample sample in watsEmiData.mHPairSamples)
                mHPairPower += Math.Pow(10, sample.mRssi / 10);
            mHPairPower = mHPairPower / watsEmiData.mHPairSamples.Count;
            mHPairPower = 10 * Math.Log10(channelSetting.Pair.BandWidth * 1000 * mHPairPower / emiRbw);

            foreach (WatsEmiSample sample in watsEmiData.mVSamples)
                mVPower += Math.Pow(10, sample.mRssi / 10);
            mVPower = mVPower / watsEmiData.mVSamples.Count;
            mVPower = 10 * Math.Log10(channelSetting.BandWidth * 1000 * mVPower / emiRbw);

            foreach (WatsEmiSample sample in watsEmiData.mVPairSamples)
                mVPairPower += Math.Pow(10, sample.mRssi / 10);
            mVPairPower = mVPairPower / watsEmiData.mVPairSamples.Count;
            mVPairPower = 10 * Math.Log10(channelSetting.Pair.BandWidth * 1000 * mVPairPower / emiRbw);

            if (limitSetting.UseDeltaPowerLimit
                && Utility.CalculateDeltaPower(watsEmiData.mHSamples) > Math.Abs(limitSetting.DeltaPowerLimit))
                mIsValidHPower = false;
            if (limitSetting.UseDeltaPowerLimit
                && Utility.CalculateDeltaPower(watsEmiData.mVSamples) > Math.Abs(limitSetting.DeltaPowerLimit))
                mIsValidVPower = false;
            if (limitSetting.UseDeltaPowerLimit
                && Utility.CalculateDeltaPower(watsEmiData.mHPairSamples) > Math.Abs(limitSetting.DeltaPowerLimit))
                mIsValidHPairPower = false;
            if (limitSetting.UseDeltaPowerLimit
                && Utility.CalculateDeltaPower(watsEmiData.mVPairSamples) > Math.Abs(limitSetting.DeltaPowerLimit))
                mIsValidVPairPower = false;

            if (mIsValidHPower && limitSetting.UseChannelPowerLimit && mHPower > limitSetting.ChannelPowerLimit)
                mIsValidHPower = false;
            if (mIsValidVPower && limitSetting.UseChannelPowerLimit && mVPower > limitSetting.ChannelPowerLimit)
                mIsValidVPower = false;
            if (mIsValidHPairPower && limitSetting.UseChannelPowerLimit && mHPairPower > limitSetting.ChannelPowerLimit)
                mIsValidHPairPower = false;
            if (mIsValidVPairPower && limitSetting.UseChannelPowerLimit && mVPairPower > limitSetting.ChannelPowerLimit)
                mIsValidVPairPower = false;
        }
Exemple #2
0
        public static WatsEmiDataManager GetEmiDataManager(EMIFileData emiFileData, List<ChannelSetting> channelSettings)
        {
            WatsEmiDataManager watsEmiDataManager = new WatsEmiDataManager();

            Dictionary<double, double> startFrequencys = new Dictionary<double, double>();
            Dictionary<double, double> endFrequencys = new Dictionary<double, double>();
            Dictionary<ChannelSetting, WatsEmiData> datas;
            Dictionary<int, List<WatsEmiSample>> samples = null;
            ChannelSetting curChannelSetting;
            WatsEmiData curData;
            foreach (DG_Type dataGroup in emiFileData.DataGroups)
            {
                if (!startFrequencys.ContainsKey(dataGroup.DG_FB_Angle))
                    startFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_Start;
                else if (dataGroup.DG_FB_Start < startFrequencys[dataGroup.DG_FB_Angle])
                    startFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_Start;

                if (!endFrequencys.ContainsKey(dataGroup.DG_FB_Angle))
                    endFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_End;
                else if (dataGroup.DG_FB_End > endFrequencys[dataGroup.DG_FB_Angle])
                    endFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_End;

                if (!watsEmiDataManager.AllChannelSamples.TryGetValue(dataGroup.DG_FB_Angle, out datas))
                {
                    datas = new Dictionary<ChannelSetting, WatsEmiData>();
                    watsEmiDataManager.AllChannelSamples.Add(dataGroup.DG_FB_Angle, datas);
                }

                if (!watsEmiDataManager.AllSamples.TryGetValue(dataGroup.DG_FB_Angle, out samples))
                {
                    samples = new Dictionary<int, List<WatsEmiSample>>();
                    samples[0] = new List<WatsEmiSample>();
                    samples[1] = new List<WatsEmiSample>();
                    watsEmiDataManager.AllSamples.Add(dataGroup.DG_FB_Angle, samples);
                }

                foreach (DG_Data_Type data in dataGroup.DGDatas)
                {
                    if (dataGroup.DB_FB_AntennaPolarization == 0)
                        samples[0].Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    else //if (dataGroup.DB_FB_AntennaPolarization == 1)
                        samples[1].Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));

                    curChannelSetting = null;
                    foreach (ChannelSetting channelSetting in channelSettings)
                    {
                        if (data.DG_DI_Freq >= channelSetting.StartFreq
                            && data.DG_DI_Freq <= channelSetting.EndFreq
                            || data.DG_DI_Freq >= channelSetting.Pair.StartFreq
                            && data.DG_DI_Freq <= channelSetting.Pair.EndFreq)
                        {
                            curChannelSetting = channelSetting;
                            break;
                        }
                    }

                    if (curChannelSetting == null)
                        continue;

                    if (!datas.TryGetValue(curChannelSetting, out curData))
                    {
                        curData = new WatsEmiData();
                        datas.Add(curChannelSetting, curData);
                    }

                    if (dataGroup.DB_FB_AntennaPolarization == 0)
                    {
                        if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                            && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                            curData.mVSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                        else
                            curData.mVPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    }
                    else
                    {
                        if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                            && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                            curData.mHSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                        else
                            curData.mHPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    }
                }
            }

            SortEmiData(watsEmiDataManager);
            return watsEmiDataManager;
        }
Exemple #3
0
        private EmiAzimuthData GetEmiAzimuthData(EMIFileData emiData, double azimuth)
        {
            EmiAzimuthData emiAzimuthData = new EmiAzimuthData();

            emiAzimuthData.Azimuth = azimuth;
            emiAzimuthData.StartFreq = double.MaxValue;
            emiAzimuthData.EndFreq = double.MinValue;
            emiAzimuthData.HorizontalSamples = new List<WatsEmiSample>();
            emiAzimuthData.VerticalSamples = new List<WatsEmiSample>();
            emiAzimuthData.ChannelDatas = new Dictionary<ChannelSetting, WatsEmiData>();
            ChannelSetting curChannelSetting;
            WatsEmiData curData;
            foreach (DG_Type dataGroup in emiData.DataGroups)
            {
                if (dataGroup.DG_FB_Angle != azimuth)
                    continue;

                if (dataGroup.DG_FB_Start < emiAzimuthData.StartFreq)
                    emiAzimuthData.StartFreq = dataGroup.DG_FB_Start;
                if (dataGroup.DG_FB_End > emiAzimuthData.EndFreq)
                    emiAzimuthData.EndFreq = dataGroup.DG_FB_End;

                foreach (DG_Data_Type data in dataGroup.DGDatas)
                {
                    if (dataGroup.DB_FB_AntennaPolarization == 0)
                        emiAzimuthData.VerticalSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    else //if (dataGroup.DB_FB_AntennaPolarization == 1)
                        emiAzimuthData.HorizontalSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));

                    curChannelSetting = null;
                    foreach (ChannelSetting channelSetting in mChannelSettings)
                    {
                        if (data.DG_DI_Freq >= channelSetting.StartFreq
                            && data.DG_DI_Freq <= channelSetting.EndFreq
                            || data.DG_DI_Freq >= channelSetting.Pair.StartFreq
                            && data.DG_DI_Freq <= channelSetting.Pair.EndFreq)
                        {
                            curChannelSetting = channelSetting;
                            break;
                        }
                    }
                    if (curChannelSetting == null)
                        continue;

                    if (!emiAzimuthData.ChannelDatas.TryGetValue(curChannelSetting, out curData))
                    {
                        curData = new WatsEmiData();
                        emiAzimuthData.ChannelDatas.Add(curChannelSetting, curData);
                    }
                    if (dataGroup.DB_FB_AntennaPolarization == 0)
                    {
                        if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                            && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                            curData.mVSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                        else
                            curData.mVPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    }
                    else
                    {
                        if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                            && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                            curData.mHSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                        else
                            curData.mHPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                    }
                }
            }

            return emiAzimuthData;
        }
Exemple #4
0
        private void ViewExcelButton_Click(object sender, EventArgs e)
        {
            if (WatsEmiReportTool.Utility.GetExcelVersion() < 0)
            {
                MessageBox.Show("Excel was not installed !");
                return;
            }

            ExportSettingForm exportSettingForm = new ExportSettingForm();
            if (exportSettingForm.ShowDialog() == DialogResult.Cancel)
                return;

            string reportTemplateFile;
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Select report file name";

            Excel.XlFileFormat excelFormat;
            if (exportSettingForm.ExportOffice2003)
            {
                reportTemplateFile = System.AppDomain.CurrentDomain.BaseDirectory
                 + "ReportTemplate.xls";
                //excelFormat = Excel.XlFileFormat.xlExcel8;
                //excelFormat = Excel.XlFileFormat.xlWorkbookNormal;
                saveFileDialog.Filter = "report file(*.xls)|*.xls";
            }
            else
            {
                reportTemplateFile = System.AppDomain.CurrentDomain.BaseDirectory
                 + "ReportTemplate.xlsx";
                //excelFormat = Excel.XlFileFormat.xlExcel12;
                saveFileDialog.Filter = "report file(*.xlsx)|*.xlsx";
            }

            do
            {
                if (DialogResult.Cancel == saveFileDialog.ShowDialog())
                    return;

                if (saveFileDialog.FileName.Equals(reportTemplateFile,
                    StringComparison.OrdinalIgnoreCase))
                {
                    MessageBox.Show("Can't select report template file !");
                    continue;
                }

                try
                {
                    File.Copy(reportTemplateFile, saveFileDialog.FileName, true);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Can't save file " + saveFileDialog.FileName
                        + "!\r\n" + "Select another file name for report.");
                    continue;
                }

                mExportFileName = saveFileDialog.FileName;
                break;

            } while (true);

            //Hide();
            mExportStatusForm.Show();
            mCancelExport = false;
            //ExportButton.Enabled = false;

            mExportThread = new Thread(delegate()
            {
                bool isReportSucceed = false;
                string[] subBands = new string[2];

                System.Globalization.CultureInfo Oldci = null;
                Excel._Application app = null;
                Excel.WorkbookClass workBook = null;
                Excel.Sheets sheets = null;
                Excel.Worksheet sheet = null;
                Excel.Worksheet summarySheet;
                try
                {
                    Oldci = System.Threading.Thread.CurrentThread.CurrentCulture;
                    System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");

                    app = new Excel.Application();
                    app.DisplayAlerts = false;
                    object objOpt = System.Reflection.Missing.Value;

                    UpdateStatus("Initialize ...");
                    workBook = (Excel.WorkbookClass)app.Workbooks.Open(
                        mExportFileName, objOpt, false, objOpt, objOpt, objOpt, true,
                        objOpt, objOpt, true, objOpt, objOpt, objOpt, objOpt, objOpt);

                    sheets = workBook.Worksheets;

                    summarySheet = (Excel.Worksheet)sheets["Summary"];
                    summarySheet.Cells[1, 6] = mEmiFileData.Site_ID;

                    UpdateStatus("Export Cover sheet ...");
                    /* Cover Sheet */
                    sheet = (Excel.Worksheet)sheets["Cover"];
                    if (!string.IsNullOrEmpty(mEmiFileData.PI_ID))
                        sheet.Cells[15, 5] = mEmiFileData.PI_ID;
                    if (!string.IsNullOrEmpty(mEmiFileData.PA_UserName))
                        sheet.Cells[17, 5] = mEmiFileData.PA_UserName;

                    Dictionary<double, double> startFrequencys = new Dictionary<double, double>();
                    Dictionary<double, double> endFrequencys = new Dictionary<double, double>();
                    WatsEmiDataManager dataManager = new WatsEmiDataManager();
                    Dictionary<ChannelSetting, WatsEmiData> datas;
                    Dictionary<int, List<WatsEmiSample>> samples = null;
                    ChannelSetting curChannelSetting;
                    WatsEmiData curData;
                    foreach (DG_Type dataGroup in mEmiFileData.DataGroups)
                    {
                        if (mCancelExport)
                            return;

                        if (!startFrequencys.ContainsKey(dataGroup.DG_FB_Angle))
                            startFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_Start;
                        else if (dataGroup.DG_FB_Start < startFrequencys[dataGroup.DG_FB_Angle])
                            startFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_Start;

                        if (!endFrequencys.ContainsKey(dataGroup.DG_FB_Angle))
                            endFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_End;
                        else if (dataGroup.DG_FB_End > endFrequencys[dataGroup.DG_FB_Angle])
                            endFrequencys[dataGroup.DG_FB_Angle] = dataGroup.DG_FB_End;

                        if (!dataManager.AllChannelSamples.TryGetValue(dataGroup.DG_FB_Angle, out datas))
                        {
                            datas = new Dictionary<ChannelSetting, WatsEmiData>();
                            dataManager.AllChannelSamples.Add(dataGroup.DG_FB_Angle, datas);
                        }

                        if (!dataManager.AllSamples.TryGetValue(dataGroup.DG_FB_Angle, out samples))
                        {
                            samples = new Dictionary<int, List<WatsEmiSample>>();
                            samples[0] = new List<WatsEmiSample>();
                            samples[1] = new List<WatsEmiSample>();
                            dataManager.AllSamples.Add(dataGroup.DG_FB_Angle, samples);
                        }

                        foreach (DG_Data_Type data in dataGroup.DGDatas)
                        {
                            if (mCancelExport)
                                return;

                            if (dataGroup.DB_FB_AntennaPolarization == 0)
                                samples[0].Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                            else //if (dataGroup.DB_FB_AntennaPolarization == 1)
                                samples[1].Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));

                            curChannelSetting = null;
                            foreach (ChannelSetting channelSetting in mChannelSettings)
                            {
                                if (mCancelExport)
                                    return;

                                if (data.DG_DI_Freq >= channelSetting.StartFreq
                                    && data.DG_DI_Freq <= channelSetting.EndFreq
                                    || data.DG_DI_Freq >= channelSetting.Pair.StartFreq
                                    && data.DG_DI_Freq <= channelSetting.Pair.EndFreq)
                                {
                                    curChannelSetting = channelSetting;
                                    break;
                                }
                            }

                            if (curChannelSetting == null)
                                continue;

                            if (!datas.TryGetValue(curChannelSetting, out curData))
                            {
                                curData = new WatsEmiData();
                                datas.Add(curChannelSetting, curData);
                            }

                            if (dataGroup.DB_FB_AntennaPolarization == 0)
                            {
                                if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                                    && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                                    curData.mVSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                                else
                                    curData.mVPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                            }
                            else
                            {
                                if (data.DG_DI_Freq >= curChannelSetting.StartFreq
                                    && data.DG_DI_Freq <= curChannelSetting.EndFreq)
                                    curData.mHSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                                else
                                    curData.mHPairSamples.Add(new WatsEmiSample(data.DG_DI_Freq, data.DG_DI_RSSI));
                            }
                        }
                    }

                    for (int i = 1; i < dataManager.AllChannelSamples.Count; i++)
                    {
                        if (mCancelExport)
                            return;

                        ((Excel.Range)summarySheet.Rows[3, objOpt]).Copy(objOpt);
                        ((Excel.Range)summarySheet.Cells[3 + i, 1]).EntireRow.Insert(objOpt, objOpt);
                    }

                    UpdateStatus("Export Device Info sheet ...");

                    /* Device Info Sheet */
                    sheet = (Excel.Worksheet)sheets["Device info"];
                    sheet.Cells[18, 12] = mEmiFileData.SA_RBW + "kHz";
                    sheet.Cells[19, 12] = mEmiFileData.SA_VBW + "kHz";
                    sheet.Cells[20, 12] = mEmiFileData.SA_Detector;
                    sheet.Cells[21, 12] = mEmiFileData.SA_Trace;
                    sheet.Cells[22, 12] = mEmiFileData.SA_Attenuation_Value + "dB";
                    sheet.Cells[23, 12] = mEmiFileData.SA_REF_LEVEL + "dBm";

                    int channelIndex;
                    Excel.Range range;
                    int summaryAngleStartRowIndex = 3;

                    List<Excel.Range> boldBorderRanges = new List<Excel.Range>();
                    boldBorderRanges.Add(summarySheet.get_Range(summarySheet.Cells[1, 1],
                        summarySheet.Cells[2, 14]));
                    foreach (KeyValuePair<double, Dictionary<ChannelSetting, WatsEmiData>> pair in dataManager.AllChannelSamples)
                    {
                        UpdateStatus("Export sheet " + pair.Key.ToString() + "\x00B0" + " ...");

                        if (mCancelExport)
                            return;

                        ((Excel.Worksheet)sheets["template"]).Copy(objOpt, workBook.ActiveSheet);
                        sheet = (Excel.Worksheet)workBook.ActiveSheet;
                        sheet.Name = pair.Key.ToString() + "\x00B0";
                        sheet.Cells[2, 3] = mEmiFileData.Site_ID;
                        sheet.Cells[2, 11] = mEmiFileData.Site_ID;
                        sheet.Cells[3, 3] = mEmiFileData.Site_Address;
                        sheet.Cells[4, 3] = WatsEmiReportTool.Utility.ConvertLatitude(mEmiFileData.Site_Latitude);
                        sheet.Cells[4, 11] = WatsEmiReportTool.Utility.ConvertLongtitude(mEmiFileData.Site_Longitude);
                        if (mLimitSetting.UseChannelPowerLimit)
                            sheet.Cells[5, 11] = mLimitSetting.ChannelPowerLimit.ToString();
                        else
                            sheet.Cells[5, 11] = "";

                        if (mLimitSetting.UseDeltaPowerLimit)
                            sheet.Cells[5, 15] = mLimitSetting.DeltaPowerLimit.ToString();
                        else
                            sheet.Cells[5, 15] = "";

                        sheet.Cells[6, 3] = WatsEmiReportTool.Utility.ConvertToDate(mEmiFileData.PA_TestTime);
                        sheet.Cells[6, 11] = mEmiFileData.PA_UserName;

                        summarySheet.Cells[summaryAngleStartRowIndex, 1] = pair.Key.ToString() + "\x00B0";

                        channelIndex = 0;
                        foreach (KeyValuePair<ChannelSetting, WatsEmiData> dataPair in pair.Value)
                        {
                            if (mCancelExport)
                                return;

                            if (channelIndex > 0)
                            {
                                ((Excel.Range)sheet.Rows[11, objOpt]).Copy(objOpt);
                                ((Excel.Range)sheet.Cells[11 + channelIndex, 1]).EntireRow.Insert(objOpt, objOpt);

                                ((Excel.Range)summarySheet.Rows[summaryAngleStartRowIndex, objOpt]).Copy(objOpt);
                                ((Excel.Range)summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 1]).EntireRow.Insert(objOpt, objOpt);
                            }

                            sheet.Cells[11 + channelIndex, 3] = dataPair.Key.ChannelName;
                            sheet.Cells[11 + channelIndex, 4] = dataPair.Key.CenterFreq;
                            sheet.Cells[11 + channelIndex, 5] = dataPair.Key.BandWidth;

                            //channel pair
                            sheet.Cells[11 + channelIndex, 10] = dataPair.Key.Pair.ChannelName;
                            sheet.Cells[11 + channelIndex, 11] = dataPair.Key.Pair.CenterFreq;
                            sheet.Cells[11 + channelIndex, 12] = dataPair.Key.Pair.BandWidth;

                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 5] = dataPair.Key.ChannelName;
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 6] = dataPair.Key.CenterFreq;
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 9] = dataPair.Key.Pair.ChannelName;
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 10] = dataPair.Key.Pair.CenterFreq;

                            WatsEmiReportTool.ChannelPower channelPower = new WatsEmiReportTool.ChannelPower(mEmiFileData.SA_RBW, dataPair.Key, mLimitSetting, dataPair.Value);
                            sheet.Cells[11 + channelIndex, 8] = channelPower.HPower;
                            sheet.Cells[11 + channelIndex, 15] = channelPower.HPairPower;
                            sheet.Cells[11 + channelIndex, 6] = channelPower.VPower;
                            sheet.Cells[11 + channelIndex, 13] = channelPower.VPairPower;

                            subBands[0] = "";
                            subBands[1] = "";
                            if (dataPair.Key.ODUSubBand.Length == 1)
                                subBands[0] = dataPair.Key.ODUSubBand;
                            else if (dataPair.Key.ODUSubBand.Length == 3)
                            {
                                subBands[0] = dataPair.Key.ODUSubBand.Substring(0, 1);
                                subBands[1] = dataPair.Key.ODUSubBand.Substring(2);
                            }
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 3] = subBands[0];
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 4] = subBands[1];

                            if (!channelPower.IsValidVPower || !channelPower.IsValidVPairPower)
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 13] = "X";
                            else
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 13] = "";

                            if (!channelPower.IsValidHPower || !channelPower.IsValidHPairPower)
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 14] = "X";
                            else
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 14] = "";

                            if (!channelPower.IsValidVPower)
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 7] = "X";
                                sheet.Cells[11 + channelIndex, 7] = "X";
                            }
                            else
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 7] = "";
                                sheet.Cells[11 + channelIndex, 7] = "";
                            }

                            if (!channelPower.IsValidHPower)
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 8] = "X";
                                sheet.Cells[11 + channelIndex, 9] = "X";
                            }
                            else
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 8] = "";
                                sheet.Cells[11 + channelIndex, 9] = "";
                            }

                            if (!channelPower.IsValidVPairPower)
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 11] = "X";
                                sheet.Cells[11 + channelIndex, 14] = "X";
                            }
                            else
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 11] = "";
                                sheet.Cells[11 + channelIndex, 14] = "";
                            }

                            if (!channelPower.IsValidHPairPower)
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 12] = "X";
                                sheet.Cells[11 + channelIndex, 16] = "X";
                            }
                            else
                            {
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex, 12] = "";
                                sheet.Cells[11 + channelIndex, 16] = "";
                            }

                            channelIndex++;
                        }

                        if (channelIndex > 1)
                        {
                            range = sheet.get_Range(sheet.Cells[11, 1], sheet.Cells[11 + channelIndex - 1, 1]);
                            range.ClearContents();
                            range.Merge(objOpt);

                            range = sheet.get_Range(sheet.Cells[11, 2], sheet.Cells[11 + channelIndex - 1, 2]);
                            range.ClearContents();
                            range.Merge(objOpt);

                            range = summarySheet.get_Range(summarySheet.Cells[summaryAngleStartRowIndex, 1],
                                summarySheet.Cells[summaryAngleStartRowIndex + channelIndex - 1, 1]);
                            range.Merge(objOpt);
                        }

                        boldBorderRanges.Add(summarySheet.get_Range(summarySheet.Cells[summaryAngleStartRowIndex, 1],
                            summarySheet.Cells[summaryAngleStartRowIndex + channelIndex - 1, 14]));

                        summaryAngleStartRowIndex += channelIndex;

                        sheet.Cells[11, 1] = startFrequencys[pair.Key].ToString()
                            + "-" + endFrequencys[pair.Key].ToString();
                        sheet.Cells[11, 2] = pair.Key.ToString() + "\x00B0";

                        List<BitMapInfo> bitmapInfos = mBitmaps[pair.Key];
                        int pictureRows = bitmapInfos.Count;
                        if (pictureRows > 1)
                        {
                            for (int i = 0; i < pictureRows - 1; i++)
                            {
                                ((Excel.Range)sheet.Rows[12 + channelIndex, objOpt]).Copy(objOpt);
                                ((Excel.Range)sheet.Cells[13 + channelIndex + i, 1]).EntireRow.Insert(objOpt, objOpt);
                            }
                        }

                        for (int i = 0; i < pictureRows; i++)
                        {
                            UpdateStatus("Export sheet " + pair.Key.ToString() + "\x00B0 vertical picture "
                                + (i + 1).ToString() + " ...");
                            if (mCancelExport)
                                return;

                            sheet.Cells[12 + channelIndex + i, 1] = bitmapInfos[i].Title1;
                            range = (Excel.Range)sheet.Cells[12 + channelIndex + i, 1];

                            range.Select();

                            float left = Convert.ToSingle(range.Left) + 15;
                            float top = Convert.ToSingle(range.Top) + 15;
                            float width = 310;
                            float height = 150;

                            sheet.Shapes.AddPicture(bitmapInfos[i].BmpFile1, Microsoft.Office.Core.MsoTriState.msoFalse,
                                Microsoft.Office.Core.MsoTriState.msoTrue, left, top, width, height);

                            UpdateStatus("Export sheet " + pair.Key.ToString() + "\x00B0 horizontal picture "
                                + (i + 1).ToString() + " ...");

                            if (mCancelExport)
                                return;

                            sheet.Cells[12 + channelIndex + i, 9] = bitmapInfos[i].Title2;
                            range = (Excel.Range)sheet.Cells[12 + channelIndex + i, 9];

                            range.Select();

                            left = Convert.ToSingle(range.Left) + 15;
                            top = Convert.ToSingle(range.Top) + 15;
                            width = 310;
                            height = 150;

                            sheet.Shapes.AddPicture(bitmapInfos[i].BmpFile2, Microsoft.Office.Core.MsoTriState.msoFalse,
                                Microsoft.Office.Core.MsoTriState.msoTrue, left, top, width, height);
                        }
                    }

                    foreach (Excel.Range boldBorderRange in boldBorderRanges)
                    {
                        boldBorderRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).Weight = Excel.XlBorderWeight.xlMedium;
                        boldBorderRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).Weight = Excel.XlBorderWeight.xlMedium;
                        boldBorderRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).Weight = Excel.XlBorderWeight.xlMedium;
                        boldBorderRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight).Weight = Excel.XlBorderWeight.xlMedium;
                    }

                    UpdateStatus("Delete template sheet ...");
                    ((Excel.Worksheet)sheets["template"]).Delete();

                    isReportSucceed = true;
                    UpdateStatus("Save export file, please wait ...");
                    workBook.Save();

                    /*
                    workBook.SaveAs(mExportFileName, Excel.XlFileFormat.xlWorkbookNormal,
                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                        Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing,
                        Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    */

                    UpdateStatus("Export succeed !");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Create report failed !\r\nException: " + ex.Message);
                }
                finally
                {
                    if (Oldci != null)
                    {
                        System.Threading.Thread.CurrentThread.CurrentCulture = Oldci;
                    }

                    if (app != null)
                        app.Quit();
                    ExcelAppKiller.Kill(app);

                    WatsEmiReportTool.Utility.ReleaseCom(sheet);
                    WatsEmiReportTool.Utility.ReleaseCom(sheets);
                    WatsEmiReportTool.Utility.ReleaseCom(workBook);
                    WatsEmiReportTool.Utility.ReleaseCom(app);

                    GC.Collect(System.GC.GetGeneration(sheet));
                    GC.Collect(System.GC.GetGeneration(sheets));
                    GC.Collect(System.GC.GetGeneration(workBook));
                    GC.Collect(System.GC.GetGeneration(app));

                    GC.Collect();

                    /*
                    ReleaseCom(sheet);
                    ReleaseCom(sheets);
                    ReleaseCom(workBook);
                    if (app != null)
                        app.Quit();
                    ExcelAppKiller.Kill(app);
                    ReleaseCom(app);

                    GC.Collect();
                    */
                }

                if (isReportSucceed)
                {
                    try
                    {
                        UpdateStatus("Open excel ...");

                        Process process = Process.Start("excel", "\"" + mExportFileName + "\"");
                        process.Close();
                    }
                    catch (System.Exception ex)
                    {

                    }
                }

                UpdateStatus("Finished");
            }
            );

            mExportThread.Start();
        }