MNE-CPP  beta 0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mnertclientsquidcontroldgl.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "../mnertclient.h"
43 #include "ui_mnertclientsquidcontroldgl.h"
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // USED NAMESPACES
48 //=============================================================================================================
49 
50 using namespace MneRtClientPlugin;
51 
52 //*************************************************************************************************************
53 //=============================================================================================================
54 // DEFINE MEMBER METHODS
55 //=============================================================================================================
56 
57 mnertclientSQUIDControlDgl::mnertclientSQUIDControlDgl(MneRtClient* p_pMneRtClient,QWidget *parent) :
58  QDialog(parent),
59  ui(new Ui::mnertclientSQUIDControlDgl),
60  m_pMneRtClient(p_pMneRtClient)
61 
62 {
63  ui->setupUi(this);
64 
65  // retune connect
66  connect(ui->m_Qbn_retune, &QPushButton::released, this, &mnertclientSQUIDControlDgl::SendRetune);
67  connect(ui->m_Qbn_Cancel, &QPushButton::released, this, &mnertclientSQUIDControlDgl::Cancel);
68  connect(ui->m_Qbn_SyncGUI,&QPushButton::released, this, &mnertclientSQUIDControlDgl::SyncGUI);
69 
70  // init
71  Init();
72 }
73 
74 mnertclientSQUIDControlDgl::~mnertclientSQUIDControlDgl()
75 {
76  delete ui;
77 }
78 void mnertclientSQUIDControlDgl::Init()
79 {
80  // Send the init command to labview to call SQUID VI.
81  //SendCMD("INIC");
82  SendCMD("INIT");
83 }
84 
85 void mnertclientSQUIDControlDgl::SendRetune()
86 {
87  SendCMD("RETU");
88 }
89 void mnertclientSQUIDControlDgl::Cancel()
90 {
91  SendCMD("CANC");
92  this->close();
93 }
94 
95 void mnertclientSQUIDControlDgl::SyncGUI()
96 {
97  SendCMD("SYNC");
98 }
99 
100 void mnertclientSQUIDControlDgl::SendCMD(QString CMDSTR)
101 {
102 
103  if(m_pMneRtClient->m_bCmdClientIsConnected)
104  {
105  //set the control field in FLL JSON value as CMDSTR
106  (*m_pMneRtClient->m_pRtCmdClient)["FLL"].pValues()[0].setValue(CMDSTR);
107  (*m_pMneRtClient->m_pRtCmdClient)["FLL"].send();
108 
109  this->ui->m_tx_info->setText(CMDSTR);
110  // Read reply
111  QString t_sReply = m_pMneRtClient->m_pRtCmdClient->readAvailableData();
112 
113  this->ui->m_tx_info->setText(QString("Reply:")+t_sReply);
114 
115  ReplyCmdProc(t_sReply);
116 
117  }
118 }
119 void mnertclientSQUIDControlDgl::ReplyCmdProc(QString sReply)
120 {
121 
122  QString cmd = sReply.left(4);
123  sReply.remove(0,4);
124  int fcmd = 0;
125  QList < QString > tmp;
126 
127  if (cmd == "INIT") fcmd = 1;
128  else if(cmd=="INIC") fcmd = 2;
129  else if(cmd=="SYNC") fcmd = 3;
130 
131  switch (fcmd)
132  {
133  case 1:
134  // if the reply is coming from INIT command, then initialize the FLL config.
135  tmp = sReply.split("#");
136  //get the channels
137  //load channel information from files
138  tmp[1] = GenChnInfo(tmp[1]);
139  InitChannels(tmp[1]);
140  //init GUI controls
141  InitGUIConfig(tmp[0]);
142  UpdateGUI();
143  break;
144  case 2:
145  // get the channels
146  InitChannels(sReply);
147  break;
148  case 3:
149  InitGUIConfig(tmp[0]);
150  UpdateGUI();
151  break;
152  default:
153  break;
154  }
155 }
156 QString mnertclientSQUIDControlDgl::GenChnInfo(QString nChan)
157 {
158  QString chaninfo;
159  for (int i=0;i<nChan.toInt();i++){
160  chaninfo += "MEG_"+tr("%1").arg(i+1)+"|";
161  }
162  return chaninfo;
163 }
164 
165 void mnertclientSQUIDControlDgl::InitChannels(QString sReply)
166 {
167  QList < QString > tmp = sReply.split("|");
168  ui->m_Qcb_channel->addItems(tmp);
169 
170 }
171 
172 void mnertclientSQUIDControlDgl::UpdateGUI()
173 {
174  // according to m_GUISM to set the items status in the GUI
175  //set CommType 255-group, 11-single channel
176  int curindex = 0;
177 
178  switch (m_GUISM.CommType){
179  case 255:
180  curindex = 0;
181  break;
182  case 11:
183  curindex = 9;
184  break;
185  default:
186  curindex = m_GUISM.CommType - 130;
187  break;
188  }
189 
190  ui->m_Qcb_commtype->setCurrentIndex( curindex );
191 
192  //set Channel
193  ui->m_Qcb_channel->setCurrentIndex( m_GUISM.ChannelSel );
194  if (m_GUISM.ChannelStat == 0)
195  ui->m_Qcb_channel->setEnabled(true);
196  else
197  ui->m_Qcb_channel->setDisabled(true);
198 
199  //set operate mode
200  ui->m_Qcb_opermode->setCurrentIndex( m_GUISM.OperMode-1 );
201 
202  //set Retune
203  if(m_GUISM.Retune == 0)
204  ui->m_Qbn_retune->setEnabled(true);
205  else
206  ui->m_Qbn_retune->setDisabled(true);
207  //set Heat this
208  if(m_GUISM.HeatThis == 0)
209  ui->m_Qbn_heat->setEnabled(true);
210  else
211  ui->m_Qbn_heat->setDisabled(true);
212 
213  //Atune
214  if(m_GUISM.Atune == 0)
215  ui->m_Qbn_atune->setEnabled(true);
216  else
217  ui->m_Qbn_atune->setDisabled(true);
218 
219  //reset
220  if(m_GUISM.Reset == 0)
221  ui->m_Qbn_reset->setEnabled(true);
222  else
223  ui->m_Qbn_reset->setDisabled(true);
224  //Heat&Tune
225  if(m_GUISM.HeatAndTune == 0)
226  ui->m_Qbn_heatTune->setEnabled(true);
227  else
228  ui->m_Qbn_heatTune->setDisabled(true);
229 
230  //save
231  if(m_GUISM.Save == 0)
232  ui->m_Qbn_save->setEnabled(true);
233  else
234  ui->m_Qbn_save->setDisabled(true);
235 
236  //_save --- %$save
237  if(m_GUISM._Save == 0)
238  ui->m_Qbn_save1->setEnabled(true);
239  else
240  ui->m_Qbn_save1->setDisabled(true);
241 
242  //Group Heat
243  if(m_GUISM.GroupHeat == 0)
244  ui->m_Qbn_groupheat->setEnabled(true);
245  else
246  ui->m_Qbn_groupheat->setDisabled(true);
247 
248  //Last
249  if(m_GUISM.Last == 0)
250  ui->m_Qbn_last->setEnabled(true);
251  else
252  ui->m_Qbn_last->setDisabled(true);
253 
254  //Default
255  if(m_GUISM.Default == 0)
256  ui->m_Qbn_default->setEnabled(true);
257  else
258  ui->m_Qbn_default->setDisabled(true);
259 
260  // high pass
261  ui->m_Qcb_hp->setCurrentIndex( m_GUISM.HighPass );
262  // low pass
263  ui->m_Qcb_lp->setCurrentIndex( m_GUISM.LowPass );
264  //pregain
265  ui->m_Qcb_pregain->setCurrentIndex( m_GUISM.PreGain-1 );
266  //postgain
267  ui->m_Qcb_postgain->setCurrentIndex( m_GUISM.PostGain-1 );
268  //slew
269  ui->m_Qcb_slew->setCurrentIndex( m_GUISM.Slew-1);
270 
271  //heattime
272  ui->m_Qsb_heattime->setValue(m_GUISM.HeatTime);
273  //cooltime
274  ui->m_Qsb_cooltime->setValue(m_GUISM.CoolTime);
275  //offset
276  ui->m_Qdsb_offset->setValue(m_GUISM.offset);
277  //bias
278  ui->m_Qdsb_bias->setValue(m_GUISM.bias);
279  //modulation
280  ui->m_Qdsb_mod->setValue(m_GUISM.modulation);
281  //autoreset
282  ui->m_Qcb_auto_reset->setCurrentIndex(m_GUISM.AutoRest);
283  //resetlock
284  ui->m_Qcb_reset_lock->setCurrentIndex(m_GUISM.ResetLock);
285 
286  //tunecheck
287  if(m_GUISM.TuneCheck == 0)
288  ui->m_Qbn_tunecheck->setEnabled(true);
289  else
290  ui->m_Qbn_tunecheck->setDisabled(true);
291  //amp
292  if(m_GUISM.Amp == 0)
293  ui->m_Qbn_amp->setEnabled(true);
294  else
295  ui->m_Qbn_amp->setDisabled(true);
296  //integrator Reset
297  if(m_GUISM.IntegratorReset == 0)
298  ui->m_Qbn_int_reset->setEnabled(true);
299  else
300  ui->m_Qbn_int_reset->setDisabled(true);
301  //MicroReset
302  if(m_GUISM.MicroReset == 0)
303  ui->m_Qbn_mirco_reset->setEnabled(true);
304  else
305  ui->m_Qbn_mirco_reset->setDisabled(true);
306 }
307 void mnertclientSQUIDControlDgl::InitGUIConfig(QString sReply)
308 {
309  QList < QString > tmp = sReply.split("|");
310 
311  int ind = 0;
312 // int nFLL = tmp[1].toInt();
313 // for (int i=0; i<nFLL; i++)
314 // {
315 // FLLPara t;
316 // t.Bias = 0;
317 // t.Mod = 0;
318 // t.Mode = 0;
319 // t.LoPass = 0;
320 // t.LPBW = 0;
321 // t.HiPass = 0;
322 // t.HPBW =0;
323 // t.offset =0;
324 // t.PreGain = 1;
325 // t.PostGain =1;
326 // t.slew =0;
327 
328 // t.AutoReset =0;
329 // t.ResetLock =0;
330 // t.channame = "MEG_"+tr("%1").arg(i+1);
331 // m_FLLConfig.m_Fll.push_back(t);
332 // }
333 
334  // Set the current status of GUI Status Machine
335  m_GUISM.CommType = tmp[ind].toInt();
336  m_GUISM.ChannelSel = tmp[ind+1].toInt();
337  m_GUISM.ChannelStat = tmp[ind+2].toInt();
338  m_GUISM.OperMode = tmp[ind+3].toInt();
339 
340  m_GUISM.Retune = tmp[ind+4].toInt();
341  m_GUISM.HeatThis = tmp[ind+5].toInt();
342  m_GUISM.Atune = tmp[ind+6].toInt();
343  m_GUISM.Reset = tmp[ind+7].toInt();
344  m_GUISM.HeatAndTune = tmp[ind+8].toInt();
345  m_GUISM.GroupHeat = tmp[ind+9].toInt();
346  m_GUISM.Last = tmp[ind+10].toInt();
347  m_GUISM.Default = tmp[ind+11].toInt();
348  m_GUISM.Save = tmp[ind+12].toInt();
349  m_GUISM._Save = tmp[ind+13].toInt();
350 
351 
352  m_GUISM.HighPass = tmp[ind+14].toInt();
353  m_GUISM.LowPass = tmp[ind+15].toInt();
354  m_GUISM.Slew = tmp[ind+16].toInt();
355  m_GUISM.PreGain = tmp[ind+17].toInt();
356  m_GUISM.PostGain= tmp[ind+18].toInt();
357  m_GUISM.AutoRest= tmp[ind+19].toInt();
358  m_GUISM.ResetLock=tmp[ind+20].toInt();
359 
360  m_GUISM.offset = tmp[ind+21].toFloat();
361  m_GUISM.bias = tmp[ind+22].toFloat();
362  m_GUISM.modulation = tmp[ind+23].toFloat();
363  m_GUISM.HeatTime = tmp[ind+24].toFloat();
364  m_GUISM.CoolTime = tmp[ind+25].toFloat();
365 
366  m_GUISM.TuneCheck = tmp[ind+26].toInt();
367  m_GUISM.Amp = tmp[ind+27].toInt();
368  m_GUISM.IntegratorReset = tmp[ind+28].toInt();
369  m_GUISM.MicroReset = tmp[ind+29].toInt();
370 
371 }
372 
Contains the declaration of the MneRtClientSQUIDControlDGL class.
The MneRtClient class provides a RT server connection.
Definition: mnertclient.h:115
The mnertclientSQUIDControlDgl class provides the SQUID control dialog.