1 #include "lms7002_pnlTxTSP_view.h"
2 #include "lms7002_gui_utilities.h"
3 #include "numericSlider.h"
4 #include "lms7002_dlgGFIR_Coefficients.h"
5 #include "lms7suiteAppFrame.h"
6 
7 using namespace lime;
8 using namespace LMS7002_WXGUI;
9 
10 indexValueMap hbi_ovr_txtsp_IndexValuePairs;
11 indexValueMap tsgfcw_txtsp_IndexValuePairs;
12 indexValueMap cmix_gain_txtsp_IndexValuePairs;
13 
lms7002_pnlTxTSP_view(wxWindow * parent)14 lms7002_pnlTxTSP_view::lms7002_pnlTxTSP_view( wxWindow* parent )
15 :
16 pnlTxTSP_view( parent )
17 {
18 
19 }
20 
lms7002_pnlTxTSP_view(wxWindow * parent,wxWindowID id,const wxPoint & pos,const wxSize & size,long style)21 lms7002_pnlTxTSP_view::lms7002_pnlTxTSP_view( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
22     : pnlTxTSP_view(parent, id, pos, size, style), lmsControl(nullptr)
23 {
24     wndId2Enum[rgrMODE_TX] = LMS7param(MODE_TX);
25     wndId2Enum[chkBSTART_TXTSP] = LMS7param(BSTART_TXTSP);
26     wndId2Enum[chkCMIX_BYP_TXTSP] = LMS7param(CMIX_BYP_TXTSP);
27     wndId2Enum[cmbCMIX_GAIN_TXTSP] = LMS7param(CMIX_GAIN_TXTSP);
28     wndId2Enum[cmbDCCORRI_TXTSP] = LMS7param(DCCORRI_TXTSP);
29     wndId2Enum[cmbDCCORRQ_TXTSP] = LMS7param(DCCORRQ_TXTSP);
30     wndId2Enum[chkDC_BYP_TXTSP] = LMS7param(DC_BYP_TXTSP);
31     wndId2Enum[chkEN_TXTSP] = LMS7param(EN_TXTSP);
32     wndId2Enum[cmbGCORRI_TXTSP] = LMS7param(GCORRI_TXTSP);
33     wndId2Enum[cmbGCORRQ_TXTSP] = LMS7param(GCORRQ_TXTSP);
34     wndId2Enum[chkGC_BYP_TXTSP] = LMS7param(GC_BYP_TXTSP);
35     wndId2Enum[chkGFIR1_BYP_TXTSP] = LMS7param(GFIR1_BYP_TXTSP);
36     wndId2Enum[cmbGFIR1_L_TXTSP] = LMS7param(GFIR1_L_TXTSP);
37     wndId2Enum[cmbGFIR1_N_TXTSP] = LMS7param(GFIR1_N_TXTSP);
38     wndId2Enum[chkGFIR2_BYP_TXTSP] = LMS7param(GFIR2_BYP_TXTSP);
39     wndId2Enum[cmbGFIR2_L_TXTSP] = LMS7param(GFIR2_L_TXTSP);
40     wndId2Enum[cmbGFIR2_N_TXTSP] = LMS7param(GFIR2_N_TXTSP);
41     wndId2Enum[chkGFIR3_BYP_TXTSP] = LMS7param(GFIR3_BYP_TXTSP);
42     wndId2Enum[cmbGFIR3_L_TXTSP] = LMS7param(GFIR3_L_TXTSP);
43     wndId2Enum[cmbGFIR3_N_TXTSP] = LMS7param(GFIR3_N_TXTSP);
44     wndId2Enum[cmbHBI_OVR_TXTSP] = LMS7param(HBI_OVR_TXTSP);
45     wndId2Enum[cmbIQCORR_TXTSP] = LMS7param(IQCORR_TXTSP);
46     wndId2Enum[chkISINC_BYP_TXTSP] = LMS7param(ISINC_BYP_TXTSP);
47     wndId2Enum[chkPH_BYP_TXTSP] = LMS7param(PH_BYP_TXTSP);
48     wndId2Enum[cmbCMIX_SC_TXTSP] = LMS7param(CMIX_SC_TXTSP);
49 
50     wndId2Enum[rgrTSGFCW_TXTSP] = LMS7param(TSGFCW_TXTSP);
51     wndId2Enum[chkTSGSWAPIQ_TXTSP] = LMS7param(TSGSWAPIQ_TXTSP);
52     wndId2Enum[rgrTSGMODE_TXTSP] = LMS7param(TSGMODE_TXTSP);
53     wndId2Enum[rgrINSEL_TXTSP] = LMS7param(INSEL_TXTSP);
54     wndId2Enum[rgrTSGFC_TXTSP] = LMS7param(TSGFC_TXTSP);
55     wndId2Enum[cmbDTHBIT_TX] = LMS7param(DTHBIT_TX);
56 
57     wndId2Enum[rgrSEL0] = LMS7param(SEL_TX);
58     wndId2Enum[rgrSEL01] = LMS7param(SEL_TX);
59     wndId2Enum[rgrSEL02] = LMS7param(SEL_TX);
60     wndId2Enum[rgrSEL03] = LMS7param(SEL_TX);
61     wndId2Enum[rgrSEL04] = LMS7param(SEL_TX);
62     wndId2Enum[rgrSEL05] = LMS7param(SEL_TX);
63     wndId2Enum[rgrSEL06] = LMS7param(SEL_TX);
64     wndId2Enum[rgrSEL07] = LMS7param(SEL_TX);
65     wndId2Enum[rgrSEL08] = LMS7param(SEL_TX);
66     wndId2Enum[rgrSEL09] = LMS7param(SEL_TX);
67     wndId2Enum[rgrSEL10] = LMS7param(SEL_TX);
68     wndId2Enum[rgrSEL11] = LMS7param(SEL_TX);
69     wndId2Enum[rgrSEL12] = LMS7param(SEL_TX);
70     wndId2Enum[rgrSEL13] = LMS7param(SEL_TX);
71     wndId2Enum[rgrSEL14] = LMS7param(SEL_TX);
72     wndId2Enum[rgrSEL15] = LMS7param(SEL_TX);
73 
74     lblNCOangles.push_back(txtAnglePHO0);
75     lblNCOangles.push_back(txtAnglePHO01);
76     lblNCOangles.push_back(txtAnglePHO02);
77     lblNCOangles.push_back(txtAnglePHO03);
78     lblNCOangles.push_back(txtAnglePHO04);
79     lblNCOangles.push_back(txtAnglePHO05);
80     lblNCOangles.push_back(txtAnglePHO06);
81     lblNCOangles.push_back(txtAnglePHO07);
82     lblNCOangles.push_back(txtAnglePHO08);
83     lblNCOangles.push_back(txtAnglePHO09);
84     lblNCOangles.push_back(txtAnglePHO10);
85     lblNCOangles.push_back(txtAnglePHO11);
86     lblNCOangles.push_back(txtAnglePHO12);
87     lblNCOangles.push_back(txtAnglePHO13);
88     lblNCOangles.push_back(txtAnglePHO14);
89     lblNCOangles.push_back(txtAnglePHO15);
90 
91     rgrNCOselections.push_back(rgrSEL0);
92     rgrNCOselections.push_back(rgrSEL01);
93     rgrNCOselections.push_back(rgrSEL02);
94     rgrNCOselections.push_back(rgrSEL03);
95     rgrNCOselections.push_back(rgrSEL04);
96     rgrNCOselections.push_back(rgrSEL05);
97     rgrNCOselections.push_back(rgrSEL06);
98     rgrNCOselections.push_back(rgrSEL07);
99     rgrNCOselections.push_back(rgrSEL08);
100     rgrNCOselections.push_back(rgrSEL09);
101     rgrNCOselections.push_back(rgrSEL10);
102     rgrNCOselections.push_back(rgrSEL11);
103     rgrNCOselections.push_back(rgrSEL12);
104     rgrNCOselections.push_back(rgrSEL13);
105     rgrNCOselections.push_back(rgrSEL14);
106     rgrNCOselections.push_back(rgrSEL15);
107 
108     txtNCOinputs.push_back(txtFCWPHO0);
109     txtNCOinputs.push_back(txtFCWPHO01);
110     txtNCOinputs.push_back(txtFCWPHO02);
111     txtNCOinputs.push_back(txtFCWPHO03);
112     txtNCOinputs.push_back(txtFCWPHO04);
113     txtNCOinputs.push_back(txtFCWPHO05);
114     txtNCOinputs.push_back(txtFCWPHO06);
115     txtNCOinputs.push_back(txtFCWPHO07);
116     txtNCOinputs.push_back(txtFCWPHO08);
117     txtNCOinputs.push_back(txtFCWPHO09);
118     txtNCOinputs.push_back(txtFCWPHO10);
119     txtNCOinputs.push_back(txtFCWPHO11);
120     txtNCOinputs.push_back(txtFCWPHO12);
121     txtNCOinputs.push_back(txtFCWPHO13);
122     txtNCOinputs.push_back(txtFCWPHO14);
123     txtNCOinputs.push_back(txtFCWPHO15);
124 
125     wxArrayString temp;
126 
127     temp.clear();
128     for(int i=0; i<8; ++i)
129         temp.push_back(wxString::Format(_("%i"), i));
130     cmbGFIR1_L_TXTSP->Set(temp);
131     cmbGFIR2_L_TXTSP->Set(temp);
132     cmbGFIR3_L_TXTSP->Set(temp);
133 
134     temp.clear();
135     for (int i = 0; i<16; ++i)
136         temp.push_back(wxString::Format(_("%i"), i));
137     cmbDTHBIT_TX->Set(temp);
138 
139     temp.clear();
140     temp.push_back("2^1");
141     temp.push_back("2^2");
142     temp.push_back("2^3");
143     temp.push_back("2^4");
144     temp.push_back("2^5");
145     temp.push_back("Bypass");
146     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(0, 0));
147     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(1, 1));
148     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(2, 2));
149     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(3, 3));
150     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(4, 4));
151     hbi_ovr_txtsp_IndexValuePairs.push_back(indexValuePair(5, 7));
152     cmbHBI_OVR_TXTSP->Set(temp);
153 
154     tsgfcw_txtsp_IndexValuePairs.push_back(indexValuePair(0, 1));
155     tsgfcw_txtsp_IndexValuePairs.push_back(indexValuePair(1, 2));
156 
157     cmix_gain_txtsp_IndexValuePairs.push_back(indexValuePair(0, 2));
158     cmix_gain_txtsp_IndexValuePairs.push_back(indexValuePair(1, 2));
159     cmix_gain_txtsp_IndexValuePairs.push_back(indexValuePair(2, 0));
160     cmix_gain_txtsp_IndexValuePairs.push_back(indexValuePair(3, 0));
161     cmix_gain_txtsp_IndexValuePairs.push_back(indexValuePair(4, 1));
162 
163     LMS7002_WXGUI::UpdateTooltips(wndId2Enum, true);
164 }
165 
Initialize(lms_device_t * pControl)166 void lms7002_pnlTxTSP_view::Initialize(lms_device_t* pControl)
167 {
168     lmsControl = pControl;
169     assert(lmsControl != nullptr);
170     uint16_t value;
171     if (LMS_ReadParam(lmsControl,LMS7param(MASK),&value)!=0  || value != 0)
172          value = 1;
173     wxArrayString temp;
174     temp.clear();
175     temp.push_back("-6 dB");
176     temp.push_back(value ? "-3 dB":"-6 dB");
177     temp.push_back("0 dB");
178     temp.push_back(value ? "+3 dB":"+6 dB");
179     temp.push_back("+6 dB");
180     cmbCMIX_GAIN_TXTSP->Set(temp);
181 }
182 
ParameterChangeHandler(wxSpinEvent & event)183 void lms7002_pnlTxTSP_view::ParameterChangeHandler(wxSpinEvent& event)
184 {
185     wxCommandEvent evt;
186     evt.SetInt(event.GetInt());
187     evt.SetId(event.GetId());
188     evt.SetEventObject(event.GetEventObject());
189     ParameterChangeHandler(evt);
190 }
191 
ParameterChangeHandler(wxCommandEvent & event)192 void lms7002_pnlTxTSP_view::ParameterChangeHandler( wxCommandEvent& event )
193 {
194     assert(lmsControl != nullptr);
195     LMS7Parameter parameter;
196     try
197     {
198         parameter = wndId2Enum.at(reinterpret_cast<wxWindow*>(event.GetEventObject()));
199     }
200     catch (std::exception & e)
201     {
202         std::cout << "Control element(ID = " << event.GetId() << ") don't have assigned LMS parameter." << std::endl;
203         return;
204     }
205     long value = event.GetInt();
206     if(event.GetEventObject() == cmbIQCORR_TXTSP)
207     {
208         float angle = atan(value / 2048.0) * 180 / 3.141596;
209         txtPhaseAlpha->SetLabel(wxString::Format("%.3f", angle));
210     }
211     else if (event.GetEventObject() == rgrTSGFCW_TXTSP)
212     {
213         value = index2value(value, tsgfcw_txtsp_IndexValuePairs);
214     }
215     else if (event.GetEventObject() == cmbHBI_OVR_TXTSP)
216     {
217         value = index2value(value, hbi_ovr_txtsp_IndexValuePairs);
218     }
219     else if(event.GetEventObject() == cmbCMIX_GAIN_TXTSP)
220     {
221         LMS_WriteParam(lmsControl, LMS7_CMIX_GAIN_TXTSP_R3, value % 0x2);
222         value = index2value(value, cmix_gain_txtsp_IndexValuePairs);
223     }
224 
225     LMS_WriteParam(lmsControl,parameter,value);
226 
227     if(event.GetEventObject() == rgrMODE_TX)
228         UpdateNCOinputs();
229 }
230 
OnNCOSelectionChange(wxCommandEvent & event)231 void lms7002_pnlTxTSP_view::OnNCOSelectionChange(wxCommandEvent& event)
232 {
233     wxRadioButton* btn = reinterpret_cast<wxRadioButton*>(event.GetEventObject());
234     int value = 0;
235     for (size_t i = 0; i < rgrNCOselections.size(); ++i)
236         if (btn == rgrNCOselections[i])
237         {
238             value = i;
239             break;
240         }
241     LMS_WriteParam(lmsControl,LMS7param(SEL_TX),value);
242 }
243 
onbtnReadBISTSignature(wxCommandEvent & event)244 void lms7002_pnlTxTSP_view::onbtnReadBISTSignature( wxCommandEvent& event )
245 {
246     uint16_t value;
247     LMS_ReadParam(lmsControl,LMS7param(BSTATE_TXTSP),&value);
248     lblBSTATE_TXTSP->SetLabel(wxString::Format("%i", value));
249     LMS_ReadParam(lmsControl,LMS7param(BSIGI_TXTSP),&value);
250     lblBSIGI_TXTSP->SetLabel(wxString::Format("0x%0.6X", value));
251     LMS_ReadParam(lmsControl,LMS7param(BSIGQ_TXTSP),&value);
252     lblBSIGQ_TXTSP->SetLabel(wxString::Format("0x%0.6X", value));
253 }
254 
OnbtnLoadDCIClick(wxCommandEvent & event)255 void lms7002_pnlTxTSP_view::OnbtnLoadDCIClick( wxCommandEvent& event )
256 {
257     long value = 0;
258     txtDC_REG_TXTSP->GetValue().ToLong(&value, 16);
259     LMS_WriteParam(lmsControl,LMS7param(DC_REG_TXTSP),value);
260     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDI_TXTSP),0);
261     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDI_TXTSP),1);
262     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDI_TXTSP),0);
263 }
264 
OnbtnLoadDCQClick(wxCommandEvent & event)265 void lms7002_pnlTxTSP_view::OnbtnLoadDCQClick( wxCommandEvent& event )
266 {
267     long value = 0;
268     txtDC_REG_TXTSP->GetValue().ToLong(&value, 16);
269     LMS_WriteParam(lmsControl,LMS7param(DC_REG_TXTSP),value);
270     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDQ_TXTSP),0);
271     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDQ_TXTSP),1);
272     LMS_WriteParam(lmsControl,LMS7param(TSGDCLDQ_TXTSP),0);
273 }
274 
onbtnGFIR1Coef(wxCommandEvent & event)275 void lms7002_pnlTxTSP_view::onbtnGFIR1Coef( wxCommandEvent& event )
276 {
277     lms7002_dlgGFIR_Coefficients *dlg = new lms7002_dlgGFIR_Coefficients(this);
278     std::vector<double> coefficients;
279     const int maxCoefCount = 40;
280     coefficients.resize(maxCoefCount, 0);
281     uint16_t ch;
282     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
283     ch = (ch == 2) ? 1 : 0;
284     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
285     int status =  LMS_GetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR1, &coefficients[0]);
286     if (status < 0)
287     {
288         wxMessageBox(_("Failed to read GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
289         dlg->Destroy();
290         return;
291     }
292 
293     dlg->SetCoefficients(coefficients);
294     if (dlg->ShowModal() == wxID_OK)
295     {
296         coefficients = dlg->GetCoefficients();
297         status = LMS_SetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR1, &coefficients[0],coefficients.size());
298         if (status != 0)
299             wxMessageBox(_("Failed to set GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
300     }
301     dlg->Destroy();
302     UpdateGUI();
303 }
304 
onbtnGFIR2Coef(wxCommandEvent & event)305 void lms7002_pnlTxTSP_view::onbtnGFIR2Coef( wxCommandEvent& event )
306 {
307     lms7002_dlgGFIR_Coefficients *dlg = new lms7002_dlgGFIR_Coefficients(this);
308     std::vector<double> coefficients;
309     const int maxCoefCount = 40;
310     coefficients.resize(maxCoefCount, 0);
311     uint16_t ch;
312     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
313     ch = (ch == 2) ? 1 : 0;
314     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
315     int status =  LMS_GetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR2, &coefficients[0]);
316     if (status < 0)
317     {
318         wxMessageBox(_("Failed to read GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
319         dlg->Destroy();
320         return;
321     }
322     dlg->SetCoefficients(coefficients);
323     if (dlg->ShowModal() == wxID_OK)
324     {
325         coefficients = dlg->GetCoefficients();
326         status = LMS_SetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR2, &coefficients[0],coefficients.size());
327         if (status != 0)
328             wxMessageBox(_("Failed to set GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
329     }
330     dlg->Destroy();
331     UpdateGUI();
332 }
333 
onbtnGFIR3Coef(wxCommandEvent & event)334 void lms7002_pnlTxTSP_view::onbtnGFIR3Coef( wxCommandEvent& event )
335 {
336     lms7002_dlgGFIR_Coefficients *dlg = new lms7002_dlgGFIR_Coefficients(this);
337     std::vector<double> coefficients;
338     const int maxCoefCount = 120;
339     coefficients.resize(maxCoefCount, 0);
340     uint16_t ch;
341     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
342     ch = (ch == 2) ? 1 : 0;
343     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
344     int status =  LMS_GetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR3, &coefficients[0]);
345     if (status < 0)
346     {
347         wxMessageBox(_("Failed to read GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
348         dlg->Destroy();
349         return;
350     }
351     dlg->SetCoefficients(coefficients);
352     if (dlg->ShowModal() == wxID_OK)
353     {
354         coefficients = dlg->GetCoefficients();
355         status = LMS_SetGFIRCoeff(lmsControl, LMS_CH_TX, ch, LMS_GFIR3, &coefficients[0],coefficients.size());
356         if (status != 0)
357             wxMessageBox(_("Failed to set GFIR coefficients"), _("ERROR"), wxICON_ERROR | wxOK);
358     }
359     dlg->Destroy();
360     UpdateGUI();
361 }
362 
OnbtnUploadNCOClick(wxCommandEvent & event)363 void lms7002_pnlTxTSP_view::OnbtnUploadNCOClick( wxCommandEvent& event )
364 {
365     LMS_WriteParam(lmsControl,LMS7param(MODE_TX),rgrMODE_TX->GetSelection());
366     assert(txtNCOinputs.size() == 16);
367     uint16_t ch;
368     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
369     ch = (ch == 2) ? 1 : 0;
370     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
371     if (rgrMODE_TX->GetSelection() == 0)
372     {
373         float_type nco_freq[16];
374         for (int i = 0; i < 16; ++i)
375         {
376             txtNCOinputs[i]->GetValue().ToDouble(&nco_freq[i]);
377             nco_freq[i] *= 1e6;
378         }
379         long value;
380         txtFCWPHOmodeAdditional->GetValue().ToLong(&value);
381         LMS_SetNCOFrequency(lmsControl,LMS_CH_TX,ch,nco_freq,value);
382     }
383     else //PHO mode
384     {
385         float_type nco_phase[16];
386         for (int i = 0; i < 16; ++i)
387         {
388             txtNCOinputs[i]->GetValue().ToDouble(&nco_phase[i]);
389         }
390         double freq_MHz;
391         txtFCWPHOmodeAdditional->GetValue().ToDouble(&freq_MHz);
392         LMS_SetNCOPhase(lmsControl, LMS_CH_TX, ch-1, nco_phase, freq_MHz);
393     }
394     UpdateGUI();// API changes nco selection
395 }
396 
OnbtnSetLPFClick(wxCommandEvent & event)397 void lms7002_pnlTxTSP_view::OnbtnSetLPFClick( wxCommandEvent& event )
398 {
399     uint16_t ch;
400     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
401     ch = (ch == 2) ? 1 : 0;
402     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
403     double bw;
404     txtLPFBW->GetValue().ToDouble(&bw);
405     if (LMS_SetGFIRLPF(lmsControl, LMS_CH_TX, ch, true, bw*1e6)!=0)
406         wxMessageBox(_("GFIR configuration failed"), _("Error"));
407     UpdateGUI();// API changes nco selection
408 }
409 
UpdateNCOinputs()410 void lms7002_pnlTxTSP_view::UpdateNCOinputs()
411 {
412     assert(txtNCOinputs.size() == 16);
413     uint16_t ch;
414     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
415     ch = (ch == 2) ? 1 : 0;
416     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
417     if (rgrMODE_TX->GetSelection() == 0) //FCW mode
418     {
419         float_type freq[16] = { 0 };
420         float_type pho=0;
421         LMS_GetNCOFrequency(lmsControl, LMS_CH_TX, ch, freq, &pho);
422         for (size_t i = 0; i < txtNCOinputs.size(); ++i)
423         {
424             txtNCOinputs[i]->SetValue(wxString::Format(_("%.6f"), freq[i]/1e6));
425         }
426         txtFCWPHOmodeAdditional->SetValue(wxString::Format(_("%3.3f"), pho));
427         lblFCWPHOmodeName->SetLabel(_("PHO (deg)"));
428         tableTitleCol1->SetLabel(_("FCW (MHz)"));
429         tableTitleCol2->SetLabel(_("PHO (deg)"));
430     }
431     else //PHO mode
432     {
433         float_type phase[16] = { 0 };
434         float_type fcw = 0;
435         LMS_GetNCOPhase(lmsControl, LMS_CH_TX, ch, phase, &fcw);
436         for (size_t i = 0; i < txtNCOinputs.size(); ++i)
437         {
438             txtNCOinputs[i]->SetValue(wxString::Format(_("%.3f"), phase[i]));
439         }
440         txtFCWPHOmodeAdditional->SetValue(wxString::Format(_("%.6f"), fcw/1e6));
441         lblFCWPHOmodeName->SetLabel(_("FCW (MHz)"));
442         tableTitleCol2->SetLabel(_("FCW (MHz)"));
443         tableTitleCol1->SetLabel(_("PHO (deg)"));
444     }
445 }
446 
UpdateGUI()447 void lms7002_pnlTxTSP_view::UpdateGUI()
448 {
449     LMS7002_WXGUI::UpdateControlsByMap(this, lmsControl, wndId2Enum);
450     float_type freq;
451     LMS_GetClockFreq(lmsControl,LMS_CLOCK_TXTSP,&freq);
452     lblRefClk->SetLabel(wxString::Format(_("%3.3f"), freq/1e6));
453 
454     uint16_t hbi;
455     LMS_ReadParam(lmsControl,LMS7param(HBI_OVR_TXTSP),&hbi);
456     cmbHBI_OVR_TXTSP->SetSelection(value2index(hbi, hbi_ovr_txtsp_IndexValuePairs));
457 
458     int16_t value;
459     LMS_ReadParam(lmsControl,LMS7param(TSGFCW_TXTSP),(uint16_t*)&value);
460 
461     rgrTSGFCW_TXTSP->SetSelection(value2index(value, tsgfcw_txtsp_IndexValuePairs));
462 
463     LMS_ReadParam(lmsControl,LMS7param(IQCORR_TXTSP),(uint16_t*)&value);
464     int bitsToShift = (15 - LMS7param(IQCORR_TXTSP).msb - LMS7param(IQCORR_TXTSP).lsb);
465     value = value << bitsToShift;
466     value = value >> bitsToShift;
467     cmbIQCORR_TXTSP->SetValue(value);
468 
469     LMS_ReadParam(lmsControl,LMS7param(SEL_TX),(uint16_t*)&value);
470     assert(rgrNCOselections.size() == 16);
471     rgrNCOselections[value & 0xF]->SetValue(true);
472     UpdateNCOinputs();
473 
474     LMS_ReadParam(lmsControl,LMS7param(DCCORRI_TXTSP),(uint16_t*)&value);
475     int8_t dccorr = value;
476     cmbDCCORRI_TXTSP->SetValue(dccorr);
477     LMS_ReadParam(lmsControl,LMS7param(DCCORRQ_TXTSP),(uint16_t*)&value);
478     dccorr = value;
479     cmbDCCORRQ_TXTSP->SetValue(dccorr);
480 
481     uint16_t g_cmix;
482     LMS_ReadParam(lmsControl,LMS7param(CMIX_GAIN_TXTSP),&g_cmix);
483     value = value2index(g_cmix, cmix_gain_txtsp_IndexValuePairs);
484     LMS_ReadParam(lmsControl,LMS7param(CMIX_GAIN_TXTSP_R3),&g_cmix);
485     if (g_cmix)
486         value |= 1;
487     else
488         value &= ~1;
489     cmbCMIX_GAIN_TXTSP->SetSelection(value);
490 
491     uint16_t ch;
492     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
493     ch = (ch == 2) ? 1 : 0;
494     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
495 
496     double sr = 0;
497     LMS_GetSampleRate(lmsControl, LMS_CH_TX, ch , &sr, nullptr);
498     txtRATEVAL->SetLabel(wxString::Format("%3.3f MHz", sr/1e6));
499     //check if B channel is enabled
500     LMS_ReadParam(lmsControl,LMS7param(MAC),(uint16_t*)&value);
501     if (value >= 2)
502     {
503         LMS_ReadParam(lmsControl,LMS7param(MIMO_SISO),(uint16_t*)&value);
504         if (value != 0)
505             wxMessageBox(_("MIMO channel B is disabled"), _("Warning"));
506     }
507 }
508 
PHOinputChanged(wxCommandEvent & event)509 void lms7002_pnlTxTSP_view::PHOinputChanged(wxCommandEvent& event)
510 {
511     uint16_t ch;
512     LMS_ReadParam(lmsControl,LMS7param(MAC),&ch);
513     ch = (ch == 2) ? 1 : 0;
514     ch += 2*LMS7SuiteAppFrame::m_lmsSelection;
515     // Write values for NCO phase or frequency each time they change - to ease the tuning of these values in measurements
516     if (rgrMODE_TX->GetSelection() == 0)
517     {
518         double angle;
519         txtFCWPHOmodeAdditional->GetValue().ToDouble(&angle);
520         LMS_SetNCOFrequency(lmsControl,LMS_CH_TX,ch,nullptr,angle);
521     }
522     else //PHO mode
523     {
524         double freq;
525         txtFCWPHOmodeAdditional->GetValue().ToDouble(&freq);
526         LMS_SetNCOPhase(lmsControl, LMS_CH_TX, ch, nullptr, freq*1e6);
527     }
528 
529     assert(lblNCOangles.size() == 16);
530     if (rgrMODE_TX->GetSelection() == 1)
531     {
532         double freq;
533         txtFCWPHOmodeAdditional->GetValue().ToDouble(&freq);
534         for (int i = 0; i < 16; ++i){
535             lblNCOangles[i]->SetLabel(wxString::Format("%3.3f", freq));
536         }
537     }
538     else
539     {
540         double angle;
541         txtFCWPHOmodeAdditional->GetValue().ToDouble(&angle);
542         for (int i = 0; i < 16; ++i){
543             lblNCOangles[i]->SetLabel(wxString::Format("%3.3f", angle));
544         }
545     }
546 }
547 
txtFCWPHOmodeAdditional_OnMouseWheel(wxMouseEvent & event)548 void lms7002_pnlTxTSP_view::txtFCWPHOmodeAdditional_OnMouseWheel(wxMouseEvent& event){
549     double angle = 0;
550     txtFCWPHOmodeAdditional->GetValue().ToDouble(&angle);
551     int change = event.GetWheelRotation()/120;
552     angle += change*0.1;
553     txtFCWPHOmodeAdditional->SetValue(wxString::Format(_("%.1f"), angle > 0 ? angle : 0));
554 }
555