📄 instrumentcal.h
字号:
//
// Copyright 2004-2007 Thomas C. McDermott, N5EG
// This file is part of VNAR - the Vector Network Analyzer program.
//
// VNAR is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// VNAR is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with VNAR, if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Modified: 05-10-2005 TCM Add routines for Internal Crystal Calibration
// Modified: 08-05-2006 TCM Add Error-Checking in case the cal results are poor
//
#pragma once
#include "DisplayRoutines.h"
#include "USB_EZ_interface.h"
#include "Constants.h"
#include <math.h>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
#define NUMCALSTEPS 6 // 6 mandatory calibration steps
namespace VNAR3
{
/// <summary>
/// Summary for InstrumentCal
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
/// Instrument Detector Calibration
public __gc class InstrumentCal : public System::Windows::Forms::Form
{
public:
InstrumentCal(CalDataSet* CalDS, VNADevice* VNADev, FrequencyGrid* fg, String* StartDir)
{
InitializeComponent();
VNA = VNADev; ///< VNA hardware device
Cal = CalDS; ///< Calibration Dataset
StartUpDir = StartDir; ///< Directory where execution started
FG = fg; ///< Frequency Grid from parent
Iphase = new int __gc[1024]; ///< I-Phase measurements
Qphase = new int __gc[1024]; ///< Q-Phase Measurements
ReflMagRegression = new int __gc[21, 60]; ///< Shorted Reflection amplitude measurements
ReflMagPhDir = new int __gc[21, 3]; ///< Directivity Reflection raw ADC counts
ReflMagPhOpen = new int __gc[21, 3]; ///< Open Reflection raw ADC counts
ReflMagPhShort = new int __gc[21, 3]; ///< Shorted Reflection raw ADC counts
ReflDetailMagPhShort = new int __gc[1024, 3]; ///< Shorted Detailed Reflection raw ADC counts
TranMag = new int __gc[21, 60]; ///< Transmission Amplitude raw ADC counts
BufferI = new int __gc[7]; ///< holds raw I reading set
BufferQ = new int __gc[7]; ///< holds raw Q reading set
BufferM = new int __gc[7]; ///< holds raw magnitude reading set Lo
BufferN = new int __gc[7]; ///< holds raw magnitude reading set Hi
BufferP = new int __gc[7]; ///< holds raw magnitude reading set Mid
for(int k=0; k<NUMCALSTEPS; k++)
CalStepPass[k] = false; ///< pass/fail for each calibration step
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Label * label1;
private: System::Windows::Forms::Button * OKbutton;
private: System::Windows::Forms::Button * Cancelbutton;
private: System::Windows::Forms::Label * label2;
private: System::Windows::Forms::Button * RxPhaseButton;
private: System::Windows::Forms::Button * TxPhaseButton;
private: System::Windows::Forms::Label * label4;
private: System::Windows::Forms::Label * label5;
private: System::Windows::Forms::Label * RxPhaseStat;
private: System::Windows::Forms::Label * TxPhaseStat;
private: System::Windows::Forms::ProgressBar * progressBar1;
private: System::Windows::Forms::Label * label6;
private: System::Windows::Forms::Label * label7;
private: System::Windows::Forms::Button * TxLowAmpButton;
private: System::Windows::Forms::Label * label8;
private: System::Windows::Forms::Label * TxLowAmpStat;
private: System::Windows::Forms::Button * FrequencyCalButton;
private: System::Windows::Forms::Label * label3;
private: System::Windows::Forms::Label * FrequencyCalStat;
private: System::Windows::Forms::TextBox * MeasFreqTextBox;
private: System::Windows::Forms::Label * label9;
private: System::Windows::Forms::Button * FreqEnterButton;
private: System::Windows::Forms::Label * label10;
private: System::Windows::Forms::Label * label11;
private: System::Windows::Forms::Label * label12;
private: System::Windows::Forms::Button * DirectivityCalButton;
private: System::Windows::Forms::Label * DirectivityCalStat;
private: System::Windows::Forms::Label * label14;
private: System::Windows::Forms::Button * RxAmpButtonOpen;
private: System::Windows::Forms::Label * RxAmpStatShort;
private: System::Windows::Forms::Label * label15;
private: System::Windows::Forms::Label * RxAmpStatOpen;
private: System::Windows::Forms::Button * RxAmpButtonShort;
private: System::Windows::Forms::Label * ICO1Label;
private: System::Windows::Forms::Label * ICO2Label;
private: System::Windows::Forms::GroupBox * Optional;
private: System::ComponentModel::IContainer * components;
private:
/// <summary>
/// Required designer variable.
/// </summary>
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager* resources = (new System::ComponentModel::ComponentResourceManager(__typeof(InstrumentCal)));
this->label1 = (new System::Windows::Forms::Label());
this->OKbutton = (new System::Windows::Forms::Button());
this->Cancelbutton = (new System::Windows::Forms::Button());
this->RxPhaseButton = (new System::Windows::Forms::Button());
this->label2 = (new System::Windows::Forms::Label());
this->TxPhaseButton = (new System::Windows::Forms::Button());
this->label4 = (new System::Windows::Forms::Label());
this->label5 = (new System::Windows::Forms::Label());
this->RxPhaseStat = (new System::Windows::Forms::Label());
this->RxAmpStatShort = (new System::Windows::Forms::Label());
this->TxPhaseStat = (new System::Windows::Forms::Label());
this->progressBar1 = (new System::Windows::Forms::ProgressBar());
this->label6 = (new System::Windows::Forms::Label());
this->label7 = (new System::Windows::Forms::Label());
this->TxLowAmpButton = (new System::Windows::Forms::Button());
this->label8 = (new System::Windows::Forms::Label());
this->TxLowAmpStat = (new System::Windows::Forms::Label());
this->FrequencyCalButton = (new System::Windows::Forms::Button());
this->label3 = (new System::Windows::Forms::Label());
this->FrequencyCalStat = (new System::Windows::Forms::Label());
this->MeasFreqTextBox = (new System::Windows::Forms::TextBox());
this->label9 = (new System::Windows::Forms::Label());
this->FreqEnterButton = (new System::Windows::Forms::Button());
this->label10 = (new System::Windows::Forms::Label());
this->label11 = (new System::Windows::Forms::Label());
this->label12 = (new System::Windows::Forms::Label());
this->DirectivityCalButton = (new System::Windows::Forms::Button());
this->DirectivityCalStat = (new System::Windows::Forms::Label());
this->label14 = (new System::Windows::Forms::Label());
this->RxAmpButtonOpen = (new System::Windows::Forms::Button());
this->label15 = (new System::Windows::Forms::Label());
this->RxAmpStatOpen = (new System::Windows::Forms::Label());
this->RxAmpButtonShort = (new System::Windows::Forms::Button());
this->ICO1Label = (new System::Windows::Forms::Label());
this->ICO2Label = (new System::Windows::Forms::Label());
this->Optional = (new System::Windows::Forms::GroupBox());
this->SuspendLayout();
//
// label1
//
this->label1->BackColor = System::Drawing::Color::Transparent;
this->label1->Font = (new System::Drawing::Font(S"Verdana", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->label1->Location = System::Drawing::Point(144, 6);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(426, 29);
this->label1->TabIndex = 0;
this->label1->Text = S"Detector Calibration";
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// OKbutton
//
this->OKbutton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->OKbutton->Location = System::Drawing::Point(456, 488);
this->OKbutton->Name = S"OKbutton";
this->OKbutton->Size = System::Drawing::Size(101, 30);
this->OKbutton->TabIndex = 1;
this->OKbutton->Text = S"Save";
this->OKbutton->Click += new System::EventHandler(this, &InstrumentCal::OKbutton_Click);
//
// Cancelbutton
//
this->Cancelbutton->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->Cancelbutton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->Cancelbutton->Location = System::Drawing::Point(584, 488);
this->Cancelbutton->Name = S"Cancelbutton";
this->Cancelbutton->Size = System::Drawing::Size(105, 28);
this->Cancelbutton->TabIndex = 2;
this->Cancelbutton->Text = S"Cancel";
this->Cancelbutton->Click += new System::EventHandler(this, &InstrumentCal::Cancelbutton_Click);
//
// RxPhaseButton
//
this->RxPhaseButton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->RxPhaseButton->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->RxPhaseButton->Location = System::Drawing::Point(520, 64);
this->RxPhaseButton->Name = S"RxPhaseButton";
this->RxPhaseButton->Size = System::Drawing::Size(176, 48);
this->RxPhaseButton->TabIndex = 3;
this->RxPhaseButton->Text = S"Refl Phase Detector Calibration";
this->RxPhaseButton->Click += new System::EventHandler(this, &InstrumentCal::RxPhaseButton_Click);
//
// label2
//
this->label2->BackColor = System::Drawing::Color::Transparent;
this->label2->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->label2->Location = System::Drawing::Point(96, 64);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(414, 48);
this->label2->TabIndex = 5;
this->label2->Text = S"Connect approximately one meter long 50-ohm cable, shorted at far end, to Tx conn"
S"ector.";
//
// TxPhaseButton
//
this->TxPhaseButton->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->TxPhaseButton->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->TxPhaseButton->Location = System::Drawing::Point(520, 208);
this->TxPhaseButton->Name = S"TxPhaseButton";
this->TxPhaseButton->Size = System::Drawing::Size(176, 48);
this->TxPhaseButton->TabIndex = 6;
this->TxPhaseButton->Text = S"Trans Phase Detector Calibration";
this->TxPhaseButton->Click += new System::EventHandler(this, &InstrumentCal::TxPhaseButton_Click);
//
// label4
//
this->label4->BackColor = System::Drawing::Color::Transparent;
this->label4->Location = System::Drawing::Point(152, 32);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(415, 28);
this->label4->TabIndex = 9;
this->label4->Text = S"(This calibration normally needs to be run only one time.)";
this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// label5
//
this->label5->BackColor = System::Drawing::Color::Transparent;
this->label5->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Underline, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->label5->Location = System::Drawing::Point(16, 38);
this->label5->Name = S"label5";
this->label5->Size = System::Drawing::Size(67, 20);
this->label5->TabIndex = 10;
this->label5->Text = S"Status";
//
// RxPhaseStat
//
this->RxPhaseStat->BackColor = System::Drawing::Color::Transparent;
this->RxPhaseStat->Location = System::Drawing::Point(16, 56);
this->RxPhaseStat->Name = S"RxPhaseStat";
this->RxPhaseStat->Size = System::Drawing::Size(48, 48);
this->RxPhaseStat->TabIndex = 11;
this->RxPhaseStat->Visible = false;
//
// RxAmpStatShort
//
this->RxAmpStatShort->BackColor = System::Drawing::Color::Transparent;
this->RxAmpStatShort->Location = System::Drawing::Point(16, 104);
this->RxAmpStatShort->Name = S"RxAmpStatShort";
this->RxAmpStatShort->Size = System::Drawing::Size(48, 48);
this->RxAmpStatShort->TabIndex = 12;
this->RxAmpStatShort->Visible = false;
//
// TxPhaseStat
//
this->TxPhaseStat->BackColor = System::Drawing::Color::Transparent;
this->TxPhaseStat->Location = System::Drawing::Point(16, 200);
this->TxPhaseStat->Name = S"TxPhaseStat";
this->TxPhaseStat->Size = System::Drawing::Size(48, 48);
this->TxPhaseStat->TabIndex = 13;
this->TxPhaseStat->Visible = false;
//
// progressBar1
//
this->progressBar1->Location = System::Drawing::Point(32, 520);
this->progressBar1->Maximum = 1024;
this->progressBar1->Name = S"progressBar1";
this->progressBar1->Size = System::Drawing::Size(664, 13);
this->progressBar1->TabIndex = 15;
//
// label6
//
this->label6->BackColor = System::Drawing::Color::Transparent;
this->label6->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->label6->Location = System::Drawing::Point(96, 208);
this->label6->Name = S"label6";
this->label6->Size = System::Drawing::Size(408, 56);
this->label6->TabIndex = 16;
this->label6->Text = S"Connect approximately three meter long (plus or minus one-half meter) 50-ohm cabl"
S"e and 40 dB attenuator from Rx to Tx.";
//
// label7
//
this->label7->BackColor = System::Drawing::Color::Transparent;
this->label7->Font = (new System::Drawing::Font(S"Verdana", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
(System::Byte)0));
this->label7->Location = System::Drawing::Point(96, 112);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -