49 #include "../babymeg.h"
51 #include "ui_babymegsquidcontroldgl.h"
65 BabyMEGSQUIDControlDgl::BabyMEGSQUIDControlDgl(
BabyMEG* p_pBabyMEG,QWidget *parent) :
68 , m_pBabyMEG(p_pBabyMEG)
71 connect(
this,&BabyMEGSQUIDControlDgl::SendCMDToMEGSource,p_pBabyMEG,&BabyMEG::comFLL);
78 connect(ui->m_Qbn_Cancel, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Cancel);
79 connect(ui->m_Qbn_SyncGUI,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::SyncGUI);
81 connect(ui->m_Qbn_retune, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Retune);
82 connect(ui->m_Qbn_heat, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Heat);
83 connect(ui->m_Qbn_atune, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Atune);
84 connect(ui->m_Qbn_reset, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Reset);
85 connect(ui->m_Qbn_heatTune, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::HeatTune);
86 connect(ui->m_Qbn_save, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Save);
87 connect(ui->m_Qbn_save1, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Save1);
88 connect(ui->m_Qbn_groupheat, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::GroupHeat);
89 connect(ui->m_Qbn_last, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Last);
90 connect(ui->m_Qbn_default,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Default);
92 connect(ui->m_Qbn_tunecheck,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::TuneCheck);
93 connect(ui->m_Qbn_amp, &QPushButton::released,
this, &BabyMEGSQUIDControlDgl::Amp);
94 connect(ui->m_Qbn_int_reset,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::IntReset);
95 connect(ui->m_Qbn_mirco_reset,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::MicroReset);
99 connect(ui->m_Qcb_commtype,SIGNAL(activated(
int)),
this,SLOT(CommType(
int)));
100 connect(ui->m_Qcb_channel,SIGNAL(activated(
int)),
this,SLOT(ChanSele(
int)));
101 connect(ui->m_Qcb_opermode,SIGNAL(activated(
int)),
this,SLOT(OperMode(
int)));
102 connect(ui->m_Qcb_hp,SIGNAL(activated(
int)),
this,SLOT(HighPass(
int)));
103 connect(ui->m_Qcb_lp,SIGNAL(activated(
int)),
this,SLOT(LowPass1(
int)));
104 connect(ui->m_Qcb_slew,SIGNAL(activated(
int)),
this,SLOT(SlewSele(
int)));
105 connect(ui->m_Qcb_pregain,SIGNAL(activated(
int)),
this,SLOT(PreGaini(
int)));
106 connect(ui->m_Qcb_postgain,SIGNAL(activated(
int)),
this,SLOT(PostGain(
int)));
107 connect(ui->m_Qcb_auto_reset,SIGNAL(activated(
int)),
this,SLOT(AutoRest(
int)));
108 connect(ui->m_Qcb_reset_lock,SIGNAL(activated(
int)),
this,SLOT(RestLock(
int)));
110 connect(ui->m_Qcb_bar_graph_select,SIGNAL(activated(
int)),
this,SLOT(BarGraph(
int)));
113 connect(ui->m_Qbn_heattime,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::HeatTime);
114 connect(ui->m_Qbn_cooltime,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::CoolTime);
115 connect(ui->m_Qbn_offset,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::AdOffset);
116 connect(ui->m_Qbn_bias,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::AdjuBias);
117 connect(ui->m_Qbn_mod,&QPushButton::released,
this, &BabyMEGSQUIDControlDgl::AdjuModu);
127 ui->tbw_parameters->setRowCount(TableRows);
128 ui->tbw_parameters->setColumnCount(TableCols);
129 for (
int i=0; i<TableCols; i++)
130 ui->tbw_parameters->setColumnWidth(i,70);
132 ui->tbw_parameters->setHorizontalHeaderLabels(QString(
"Channel;Value;Channel;Value;Channel;Value;Channel;Value;Channel;Value;Channel;Value").split(
";"));
134 for (
int i=0; i<TableRows;i++)
135 for(
int j=0;j<TableCols;j++)
136 ui->tbw_parameters->setItem(i,j,
new QTableWidgetItem(
" "));
138 ui->tbw_parameters->setCurrentCell(0,0);
142 initplotflag =
false;
145 ui->lay_tune->addWidget(d_timeplot);
150 BabyMEGSQUIDControlDgl::~BabyMEGSQUIDControlDgl()
156 void BabyMEGSQUIDControlDgl::closeEvent(QCloseEvent *event)
163 int NumRect = m_GUISM.ParaGraph.size();
165 for (
int i=0; i< NumRect ; i++)
167 int ro = floor(i/(TableCols/2));
168 int co = i - ro*(TableCols/2);
169 ui->tbw_parameters->item(ro,1+2*co)->setText(tr(
"%1").arg(m_GUISM.ParaGraph.at(i)));
170 ui->tbw_parameters->item(ro,0+2*co)->setText(chanNames.at(i));
175 float BabyMEGSQUIDControlDgl::mmin(MatrixXf tmp,
int chan)
177 int cols = tmp.cols();
179 float ret = tmp(chan,0);
180 for (
int i=0; i<cols; i++)
182 if (tmp(chan,i) < ret)
189 float BabyMEGSQUIDControlDgl::mmax(MatrixXf tmp,
int chan)
191 int cols = tmp.cols();
193 float ret = tmp(chan,0);
194 for (
int i=0; i<cols; i++)
196 if (tmp(chan,i) > ret)
202 void BabyMEGSQUIDControlDgl::TuneGraphDispProc(MatrixXf tmp)
206 int cols = tmp.cols();
207 int chanIndx = ui->m_Qcb_channel->currentIndex();
210 settings.maxX = cols;
211 settings.minY = mmin(tmp,chanIndx);
212 settings.maxY = mmax(tmp,chanIndx);
213 settings.xlabel = QString(
"%1 samples/second").arg(m_pBabyMEG->sfreq) ;
214 settings.ylabel = QString(
"Amplitude [rel. unit]");
216 d_timeplot->setPlotSettings(settings);
221 for(
int i=0; i<cols;i++)
222 F.append(QPointF(i,tmp(chanIndx,i)));
224 d_timeplot->setCurveData(0,F);
230 void BabyMEGSQUIDControlDgl::TuneCheck()
234 ProcCmd(
"BUTNTUNECHEC",index,
"TuneCheck is processing !");
236 void BabyMEGSQUIDControlDgl::Amp()
240 ProcCmd(
"BUTNDOOOOAMP",index,
"Requiring Amp is processing !");
242 void BabyMEGSQUIDControlDgl::IntReset()
246 ProcCmd(
"BUTNINTRESET",index,
"IntReset is processing !");
248 void BabyMEGSQUIDControlDgl::MicroReset()
252 ProcCmd(
"BUTNMICRESET",index,
"MicroReset is processing !");
255 void BabyMEGSQUIDControlDgl::Save()
259 ProcCmd(
"BUTNDOOOSAVE",index,
"Save is processing !");
262 void BabyMEGSQUIDControlDgl::Save1()
266 ProcCmd(
"BUTNDOOSAVE1",index,
"Save1 is processing !");
269 void BabyMEGSQUIDControlDgl::GroupHeat()
273 ProcCmd(
"BUTNGROUPHEA",index,
"GroupHeat is processing !");
276 void BabyMEGSQUIDControlDgl::Last()
280 ProcCmd(
"BUTNDOOOLAST",index,
"Last is processing !");
283 void BabyMEGSQUIDControlDgl::Default()
287 ProcCmd(
"BUTNDDEFAULT",index,
"Default is processing !");
291 void BabyMEGSQUIDControlDgl::Retune()
295 ProcCmd(
"BUTNDORETUNE",index,
"Retune is processing !");
298 void BabyMEGSQUIDControlDgl::Heat()
302 ProcCmd(
"BUTNDOOOHEAT",index,
"Heat is processing !");
304 void BabyMEGSQUIDControlDgl::Atune()
308 ProcCmd(
"BUTNDOOATUNE",index,
"Atune is processing !");
310 void BabyMEGSQUIDControlDgl::Reset()
314 ProcCmd(
"BUTNDOIRESET",index,
"Reset is processing !");
316 void BabyMEGSQUIDControlDgl::HeatTune()
320 ProcCmd(
"BUTNHEATTUNE",index,
"HeatTune is processing !");
324 void BabyMEGSQUIDControlDgl::AdOffset()
327 index = ui->m_Qsb_offset->value();
328 ProcCmd(
"UPDEADOFFSET",index,
"Offset is changed !");
332 void BabyMEGSQUIDControlDgl::AdjuBias()
335 index = ui->m_Qsb_bias->value();
336 ProcCmd(
"UPDEADJUBIAS",index,
"Bias is changed !");
340 void BabyMEGSQUIDControlDgl::AdjuModu()
343 index = ui->m_Qsb_mod->value();
344 ProcCmd(
"UPDEADJUMODU",index,
"Modulation is changed !");
348 void BabyMEGSQUIDControlDgl::HeatTime()
351 index = ui->m_Qsb_heattime->value();
352 ProcCmd(
"UPDEHEATTIME",index,
"Heat Time is changed !");
355 void BabyMEGSQUIDControlDgl::CoolTime()
358 index = ui->m_Qsb_cooltime->value();
359 ProcCmd(
"UPDECOOLTIME",index,
"Cool Time is changed !");
362 void BabyMEGSQUIDControlDgl::AutoRest(
int index)
364 ProcCmd(
"UPDEAUTOREST",index,
"Auto Reset is changed !");
366 void BabyMEGSQUIDControlDgl::RestLock(
int index)
368 ProcCmd(
"UPDERESTLOCK",index,
"Reset Lock is changed !");
371 void BabyMEGSQUIDControlDgl::PreGaini(
int index)
373 ProcCmd(
"UPDEPREGAINI",++index,
"Pre Gain is changed !");
376 void BabyMEGSQUIDControlDgl::PostGain(
int index)
378 ProcCmd(
"UPDEPOSTGAIN",++index,
"Post Gain is changed !");
382 void BabyMEGSQUIDControlDgl::SlewSele(
int index)
384 ProcCmd(
"UPDESLEWSELE",++index,
"Slew Selection is changed !");
388 void BabyMEGSQUIDControlDgl::LowPass1(
int index)
390 ProcCmd(
"UPDELOWPASS1",index,
"low pass filter is changed !");
394 void BabyMEGSQUIDControlDgl::HighPass(
int index)
396 ProcCmd(
"UPDEHIGHPASS",index,
"high pass filter is changed !");
400 void BabyMEGSQUIDControlDgl::OperMode(
int index)
402 ProcCmd(
"UPDEOPERMODE",index,
"Operate Mode is changed !");
405 void BabyMEGSQUIDControlDgl::ChanSele(
int index)
407 ProcCmd(
"UPDECHANSELE",index,
"Channel is changed !");
410 void BabyMEGSQUIDControlDgl::BarGraph(
int index)
412 ProcCmd(
"UPDEBARGRAPH",index,
"Bar graph select is changed !");
415 void BabyMEGSQUIDControlDgl::CommType(
int index)
418 if (index==0) A = tr(
"255");
419 else if(index == 9) {A=tr(
"11");}
420 else if(index > 0 && index < 9){A = tr(
"%1").arg(index+130);}
422 QString CMDStr =
"UPDECOMMTYPE|"+A+
"|";
423 QString newline = QString(
"Communication Type is changed!|"+CMDStr+
"index"+tr(
"%1").arg(index));
428 void BabyMEGSQUIDControlDgl::UpdateInfo(QString newText)
430 QString content = ui->m_tx_info->toPlainText();
431 content = content +
"\n" + newText;
432 ui->m_tx_info->setText(content);
433 ui->m_tx_info->verticalScrollBar()->setValue(ui->m_tx_info->verticalScrollBar()->maximum());
436 void BabyMEGSQUIDControlDgl::Init()
440 qDebug()<<
"Send init command\n";
444 void BabyMEGSQUIDControlDgl::Cancel()
450 void BabyMEGSQUIDControlDgl::SyncGUI()
455 void BabyMEGSQUIDControlDgl::SendCMD(QString CMDSTR)
457 emit SendCMDToMEGSource(CMDSTR);
460 void BabyMEGSQUIDControlDgl::RcvCMDData(QByteArray DATA)
462 QString t_sReply(DATA);
464 QString newline = QString(
"Reply:")+t_sReply;
467 ReplyCmdProc(t_sReply);
470 void BabyMEGSQUIDControlDgl::ReplyCmdProc(QString sReply)
473 QString cmd = sReply.left(4);
476 QList < QString > tmp;
478 if (cmd ==
"INIT") fcmd = 1;
479 else if(cmd==
"INIC") fcmd = 2;
480 else if(cmd==
"SYNC") fcmd = 3;
481 else if(cmd==
"UPDE") fcmd = 4;
482 else if(cmd==
"BUTN") fcmd = 5;
491 tmp = sReply.split(
"#");
498 InitChannels(tmp[2]);
501 InitGUIConfig(tmp[0]);
506 InitChannels(sReply);
509 InitGUIConfig(sReply);
513 InitGUIConfig(sReply);
523 QString BabyMEGSQUIDControlDgl::GenChnInfo(QString nChan)
526 for (
int i=0;i<nChan.toInt();i++){
527 chaninfo +=
"MEG_"+tr(
"%1").arg(i+1)+
"|";
532 void BabyMEGSQUIDControlDgl::InitChannels(QString sReply)
541 QList <QString> t_chanNames = sReply.split(
"|");
545 for (
int i=0;i<t_chanNames.size();i++)
547 QString T = t_chanNames.at(i);
548 if (T.left(3)==
"MEG")
549 chanNames.push_back(T);
553 ui->m_Qcb_channel->addItems(chanNames);
557 void BabyMEGSQUIDControlDgl::UpdateGUI()
563 switch (m_GUISM.CommType){
571 curindex = m_GUISM.CommType - 130;
575 ui->m_Qcb_commtype->setCurrentIndex( curindex );
578 ui->m_Qcb_channel->setCurrentIndex( m_GUISM.ChannelSel );
580 QString newline = QString(
"Debug: ChannelStat = ")+tr(
"%1").arg(m_GUISM.ChannelStat);
583 if (m_GUISM.ChannelStat == 0)
584 ui->m_Qcb_channel->setEnabled(
true);
586 ui->m_Qcb_channel->setDisabled(
true);
589 ui->m_Qcb_opermode->setCurrentIndex( m_GUISM.OperMode );
592 if(m_GUISM.Retune == 0)
593 ui->m_Qbn_retune->setEnabled(
true);
595 ui->m_Qbn_retune->setDisabled(
true);
597 if(m_GUISM.HeatThis == 0)
598 ui->m_Qbn_heat->setEnabled(
true);
600 ui->m_Qbn_heat->setDisabled(
true);
603 if(m_GUISM.Atune == 0)
604 ui->m_Qbn_atune->setEnabled(
true);
606 ui->m_Qbn_atune->setDisabled(
true);
609 if(m_GUISM.Reset == 0)
610 ui->m_Qbn_reset->setEnabled(
true);
612 ui->m_Qbn_reset->setDisabled(
true);
614 if(m_GUISM.HeatAndTune == 0)
615 ui->m_Qbn_heatTune->setEnabled(
true);
617 ui->m_Qbn_heatTune->setDisabled(
true);
620 if(m_GUISM.Save == 0)
621 ui->m_Qbn_save->setEnabled(
true);
623 ui->m_Qbn_save->setDisabled(
true);
626 if(m_GUISM._Save == 0)
627 ui->m_Qbn_save1->setEnabled(
true);
629 ui->m_Qbn_save1->setDisabled(
true);
632 if(m_GUISM.GroupHeat == 0)
633 ui->m_Qbn_groupheat->setEnabled(
true);
635 ui->m_Qbn_groupheat->setDisabled(
true);
638 if(m_GUISM.Last == 0)
639 ui->m_Qbn_last->setEnabled(
true);
641 ui->m_Qbn_last->setDisabled(
true);
644 if(m_GUISM.Default == 0)
645 ui->m_Qbn_default->setEnabled(
true);
647 ui->m_Qbn_default->setDisabled(
true);
650 ui->m_Qcb_hp->setCurrentIndex( m_GUISM.HighPass );
652 ui->m_Qcb_lp->setCurrentIndex( m_GUISM.LowPass );
654 ui->m_Qcb_pregain->setCurrentIndex( m_GUISM.PreGain-1 );
656 ui->m_Qcb_postgain->setCurrentIndex( m_GUISM.PostGain-1 );
658 ui->m_Qcb_slew->setCurrentIndex( m_GUISM.Slew-1);
661 ui->m_Qsb_heattime->setValue(m_GUISM.HeatTime);
663 ui->m_Qsb_cooltime->setValue(m_GUISM.CoolTime);
665 ui->m_Qsb_offset->setValue(m_GUISM.offset);
667 ui->m_Qsb_bias->setValue(m_GUISM.bias);
669 ui->m_Qsb_mod->setValue(m_GUISM.modulation);
671 ui->m_Qcb_auto_reset->setCurrentIndex(m_GUISM.AutoRest);
673 ui->m_Qcb_reset_lock->setCurrentIndex(m_GUISM.ResetLock);
676 if(m_GUISM.TuneCheck == 0)
677 ui->m_Qbn_tunecheck->setEnabled(
true);
679 ui->m_Qbn_tunecheck->setDisabled(
true);
682 ui->m_Qbn_amp->setEnabled(
true);
684 ui->m_Qbn_amp->setDisabled(
true);
698 ui->m_Qcb_bar_graph_select->setCurrentIndex( m_GUISM.BarGraphSelect);
706 void BabyMEGSQUIDControlDgl::InitGUIConfig(QString sReply)
708 QList < QString > tmp = sReply.split(
"|");
712 m_GUISM.CommType = tmp[ind].toInt();
713 m_GUISM.ChannelSel = tmp[ind+1].toInt();
714 m_GUISM.ChannelStat = tmp[ind+2].toInt();
715 m_GUISM.OperMode = tmp[ind+3].toInt();
717 m_GUISM.Retune = tmp[ind+4].toInt();
718 m_GUISM.HeatThis = tmp[ind+5].toInt();
719 m_GUISM.Atune = tmp[ind+6].toInt();
720 m_GUISM.Reset = tmp[ind+7].toInt();
721 m_GUISM.HeatAndTune = tmp[ind+8].toInt();
722 m_GUISM.GroupHeat = tmp[ind+9].toInt();
723 m_GUISM.Last = tmp[ind+10].toInt();
724 m_GUISM.Default = tmp[ind+11].toInt();
725 m_GUISM.Save = tmp[ind+12].toInt();
726 m_GUISM._Save = tmp[ind+13].toInt();
729 m_GUISM.HighPass = tmp[ind+14].toInt();
730 m_GUISM.LowPass = tmp[ind+15].toInt();
731 m_GUISM.Slew = tmp[ind+16].toInt();
732 m_GUISM.PreGain = tmp[ind+17].toInt();
733 m_GUISM.PostGain= tmp[ind+18].toInt();
734 m_GUISM.AutoRest= tmp[ind+19].toInt();
735 m_GUISM.ResetLock=tmp[ind+20].toInt();
737 m_GUISM.offset = tmp[ind+21].toFloat();
738 m_GUISM.bias = tmp[ind+22].toFloat();
739 m_GUISM.modulation = tmp[ind+23].toFloat();
740 m_GUISM.HeatTime = tmp[ind+24].toFloat();
741 m_GUISM.CoolTime = tmp[ind+25].toFloat();
743 m_GUISM.TuneCheck = tmp[ind+26].toInt();
744 m_GUISM.Amp = tmp[ind+27].toInt();
745 m_GUISM.IntegratorReset = tmp[ind+28].toInt();
746 m_GUISM.MicroReset = tmp[ind+29].toInt();
749 m_GUISM.BarGraphSelect = tmp[ind+30].toInt();
751 int count = tmp[ind+31].toInt();
753 if (m_GUISM.ParaGraph.size()>0) m_GUISM.ParaGraph.clear();
754 for (
int i=0;i<count;i++)
755 m_GUISM.ParaGraph.append(tmp[ind+32+i].toFloat());
759 void BabyMEGSQUIDControlDgl::ProcCmd(QString cmd,
int index, QString Info)
761 QString A = tr(
"%1").arg(index);
762 QString CMDStr = cmd+
"|"+A+
"|";
763 QString newline = Info+
"|"+CMDStr+
"index"+A;
The BabyMEG class provides a Fiff data simulator.
void DataToSquidCtrlGUI(MatrixXf tmp)
void SendCMDDataToSQUIDControl(QByteArray DATA)
Contains the declaration of the BabyMEGSQUIDControlDGL class.
The BabyMEGSQUIDControlDgl class provides the SQUID control dialog.