2#include "ui_straincalibgui.h" 
    4#include <QtConcurrent/QtConcurrent> 
   11    QDialog(parent), mutexacquisitionofdata(QMutex::Recursive), mutexdriver(QMutex::Recursive),
 
   15    acquiringdata = 
false;
 
   16    enableacquisitions = 
true;
 
   22    connect(ui->btnAcquireData,SIGNAL(clicked(
bool)),
this,SLOT(onAcquireData(
bool)));
 
   23    buttons.append(ui->btn1);
 
   24    buttons.append(ui->btn2);
 
   25    buttons.append(ui->btn3);
 
   26    buttons.append(ui->btn4);
 
   27    buttons.append(ui->btn5);
 
   28    buttons.append(ui->btn6);
 
   29    buttons.append(ui->btn7);
 
   30    buttons.append(ui->btn8);
 
   31    buttons.append(ui->btn9);
 
   32    buttons.append(ui->btn10);
 
   33    buttons.append(ui->btn11);
 
   34    buttons.append(ui->btn12);
 
   35    buttons.append(ui->btn13);
 
   37    readValues.append(ui->cur1);
 
   38    readValues.append(ui->cur2);
 
   39    readValues.append(ui->cur3);
 
   40    readValues.append(ui->cur4);
 
   41    readValues.append(ui->cur5);
 
   42    readValues.append(ui->cur6);
 
   44    expValues.append(ui->exp1);
 
   45    expValues.append(ui->exp2);
 
   46    expValues.append(ui->exp3);
 
   47    expValues.append(ui->exp4);
 
   48    expValues.append(ui->exp5);
 
   49    expValues.append(ui->exp6);
 
   51    errValues.append(ui->err1);
 
   52    errValues.append(ui->err2);
 
   53    errValues.append(ui->err3);
 
   54    errValues.append(ui->err4);
 
   55    errValues.append(ui->err5);
 
   56    errValues.append(ui->err6);
 
   58    ui->freeEdit1->setValidator(&validator);
 
   59    ui->freeEdit2->setValidator(&validator);
 
   60    ui->freeEdit3->setValidator(&validator);
 
   61    ui->freeEdit4->setValidator(&validator);
 
   62    ui->freeEdit5->setValidator(&validator);
 
   63    ui->freeEdit6->setValidator(&validator);
 
   66    int bi[13]={8020,1001,8010,8030,8040,8050,8060,8070,8080,3001,4001,5001,6001};
 
   68    for (
int i=0; i<buttons.count();i++) {
 
   69        buttons.at(i)->setProperty(
"btnIndex",bi[i]);
 
   70        connect(buttons.at(i),SIGNAL(clicked(
bool)),
this,SLOT(onButtonClick(
bool)));
 
   73    connect(ui->freeAcqModeGroup,SIGNAL(toggled(
bool)),
this,SLOT(onFreeAcqMode(
bool)));
 
   75    connect(ui->buttonBox, SIGNAL(accepted()), 
this, SLOT(onClose()));
 
   78    std::string filenameOfexpectedValues = std::string(
"firmwareupdater.strain.expectedvalues.txt");
 
   79    bool b = expected_values_handler.
init(filenameOfexpectedValues.c_str());
 
   81        yError() << 
"ERROR in opening file" << filenameOfexpectedValues << 
".... using default values for expected value handler";
 
   82        expected_values_handler.
init();
 
   86        yDebug() << 
"loaded file of expected values =" << filenameOfexpectedValues;
 
   92    yDebug() << 
"expected values for" << expected_values_handler.
get_serialnumber() << 
"with thresholds = " << low << high;
 
   97    connect(&watcher, SIGNAL(finished()), 
this, SLOT(onFutureFinished()));
 
  100    ATIsens = 
new devMeasurementFns();
 
  104    if((device == 
"ETH") || (device == 
"eth"))
 
  107        yDebug() << 
"strainInterface::Network::ETH";
 
  109    else if ((device == 
"SOCKETCAN") || (device == 
"socketcan"))
 
  111        yDebug() << 
"strainInterface::Network::socketcan";
 
  114    else if((device == 
"ECAN") || (device == 
"ecan"))
 
  116        yDebug() << 
"strainInterface::Network::ecan";
 
  122        yDebug() << 
"unknown strainInterface::Network =" << device.toStdString();
 
  134    connect(&timer,SIGNAL(timeout()),
this,SLOT(onTimerTimeout()));
 
  135    timer.setInterval(500);
 
  136    timer.setSingleShot(
false);
 
  139    enabledebugprints = 
false;
 
  142    if(
false == checkDirectory())
 
  144        yError() << 
"CANNOT find the data folder. Please create it!";
 
  145        ui->labelInstructions->setText(
"You can select an acquisition from the menu ... but:" 
  146                                       "\nCANNOT find the data folder." 
  147                                       "\nIf you want your acquisition data saved, please create it!");
 
 
  166void StrainCalibGui::stopacquisitions(
bool forcestop)
 
  172    static bool alreadystopped = 
false;
 
  173    if((
false == alreadystopped) || (
true == forcestop))
 
  178        enableacquisitions = 
false;
 
  182        while(
false == mutexdriver.tryLock(250))
 
  184            ui->progress->setValue(progressvalue);
 
  185            ui->labelInstructions->setText(
"Received the QUIT command: waiting for the acquisition to terminate");
 
  194        alreadystopped = 
true;
 
  198void StrainCalibGui::onClose()
 
  200    stopacquisitions(
true);
 
  201    stopacquisitions(
true);
 
  206void StrainCalibGui::onFreeAcqMode(
bool b)
 
  209        ui->spinSamples->setEnabled(
true);
 
  210        ui->btnContainer1->setEnabled(
false);
 
  211        ui->btnContainer2->setEnabled(
false);
 
  212        ui->btnAcquireData->setEnabled(
true);
 
  213        ui->labelInstructions->setText(
"Free Acquisiton Mode");
 
  215        ui->btnContainer1->setEnabled(
true);
 
  216        ui->btnContainer2->setEnabled(
true);
 
  217        ui->btnAcquireData->setEnabled(
false);
 
  219        if(
false == checkDirectory())
 
  221            yError() << 
"CANNOT find the data folder. Please create it!";
 
  222            ui->labelInstructions->setText(
"You can select an acquisition from the menu ... but:" 
  223                                           "\nCANNOT find the data folder." 
  224                                           "\nIf you want your acquisition data saved, please create it!");
 
  228             ui->labelInstructions->setText(
"Select an acquisition from the menu");
 
  233void StrainCalibGui::onFutureFinished()
 
  235    ui->progress->setMaximum(100);
 
  237    if(!watcher.result()){
 
  238        ui->labelInstructions->setText(
"Not enough data acquired. Repeat acquisition.");
 
  244    if(ui->freeAcqModeGroup->isChecked())
 
  251        int rtrial=remap_trials();
 
  254            trial_bias=last_value;
 
  258        qDebug(
"%d\n",trial); 
 
  264void StrainCalibGui::onAcquireData(
bool b)
 
  267    if(ui->freeAcqModeGroup->isChecked())
 
  269        QString fileName = QFileDialog::getSaveFileName(NULL,
"Choose a file");
 
  270        if(fileName.isEmpty())
 
  272            yWarning() << 
"choose another file";
 
  275        fp = fopen(fileName.toLatin1().data(),
"w");
 
  278            yWarning() << 
"cannot open file" << fileName.toLatin1().data() << 
"hence i will not perform acquisition";
 
  279            ui->labelInstructions->setText(
"Cannot open file. Try once more.");
 
  284    QFuture<bool> future = QtConcurrent::run(
this,&StrainCalibGui::acquire_samples,ui->spinSamples->value());
 
  285    watcher.setFuture(future);
 
  286    ui->progress->setMaximum(100);
 
  291void StrainCalibGui::onButtonClick(
bool b)
 
  293    QPushButton *btn = (QPushButton*)sender();
 
  294    int btnIndex = btn->property(
"btnIndex").toInt();
 
  295    currentBtnIndex = buttons.indexOf(btn);
 
  305void acquire_1000_samples()
 
  308    float data[6]={0,0,0,0,0,0};
 
  309    printf(
"\n   press return to acquire ***ATI sensor*** data or 'r' to reset\n");
 
  312    if (strcmp(temp,
"r")==0)
 
  314        ATIsens->BiasForceTorqueSensor();
 
  315        printf(
"\n   bias done. press return to acquire ***ATI sensor*** data\n");
 
  321    float data_mean[6] = {0,0,0,0,0,0};
 
  322    for (i=0; i<1000; i++)
 
  325        ATIsens->ReadFTsensorData();
 
  326        ATIsens->GetFTData(
data);
 
  328        printf(
"samples:%3d [0]:%+6.2f [1]:%+6.2f [2]:%+6.2f [3]:%+6.2f [4]:%+6.2f [5]:%+6.2f\r\n",i,
data[0],
data[1],
data[2],
data[3],
data[4],
data[5]);
 
  331            data_mean[j]=data_mean[j]+
data[j];
 
  339    printf(
"means:%3d [0]:%+6.2f [1]:%+6.2f [2]:%+6.2f [3]:%+6.2f [4]:%+6.2f [5]:%+6.2f\r\n",i,data_mean[0],data_mean[1],data_mean[2],data_mean[3],data_mean[4],data_mean[5]);
 
  347void StrainCalibGui::progressbar(
void *owner, 
float percent)
 
  354    int value = 
static_cast<int>(percent * 100.0);
 
  360    if(value != thegui->progressvalue)
 
  362        thegui->progressvalue = value;
 
  366bool StrainCalibGui::get(
const unsigned int number, vector<cDownloader::strain_value_t> &values, 
bool debugprint, 
bool updateprogress)
 
  369    double t0 = yarp::os::SystemClock::nowSystem();
 
  373        yDebug() << 
"strainInterface::get(): is acquiring" << number << 
"from the 6 channels. Please wait ...";
 
  376    void * param = 
nullptr;
 
  377    void (*updateProgressBar)(
void*, float) = 
nullptr;
 
  379    if(
true == updateprogress)
 
  381        updateProgressBar = progressbar;
 
  382        param = 
reinterpret_cast<void*
>(
this);
 
  385    const bool calibmode = 
false;
 
  394    double t1 = yarp::os::SystemClock::nowSystem();
 
  400            yDebug() << 
"strainInterface::get() has succesfully acquired" << values.size() << 
"values of the 6 channels in" << (t1 - t0) << 
"seconds";
 
  401            yDebug() << 
"the values are:";
 
  402            for (
int i = 0; i < values.size(); i++)
 
  404                yDebug() << 
"#" << i + 1 << 
"=" << values[i].channel[0] << values[i].channel[1] << values[i].channel[2] << values[i].channel[3] <<
 
  405                    values[i].channel[4] << values[i].channel[5] << values[i].valid;
 
  410            yDebug() << 
"strainInterface::get() has failed acquisitions";
 
  414    return (0 == ret) ? true : 
false;
 
  417bool StrainCalibGui::print(
const vector<cDownloader::strain_value_t> &values, FILE *
fp, QList<float> ft)
 
  422        yError(
"the file pointer is invalid: I cannot print my %lu values", values.size());
 
  426    if(!ft.isEmpty() && (ft.count() == 6)){
 
  427        fprintf(fp,
"- %f %f %f %f %f %f\n\n",ft.at(0),ft.at(1),ft.at(2),ft.at(3),ft.at(4),ft.at(5));
 
  431    for(
size_t n=0; 
n<values.size(); 
n++)
 
  433        unsigned short unsigned_gaugeData[6] = {0};
 
  434        signed short signed_gaugeData[6] = {0};
 
  436        for(
size_t c=0; c<6; c++)
 
  438            unsigned_gaugeData[c] = values[values.size()-1-
n].channel[c];
 
  439            signed_gaugeData[c] = unsigned_gaugeData[c]-0x7fff;
 
  444            fprintf(fp,
"%d %d %d %d %d %d %d\n",
static_cast<int>(
n),signed_gaugeData[0],signed_gaugeData[1],signed_gaugeData[2],
 
  445                    signed_gaugeData[3],signed_gaugeData[4],signed_gaugeData[5]);
 
  449        if(enabledebugprints)
 
  451            yDebug(
"samples:%3d [0]:%+6d [1]:%+6d [2]:%+6d [3]:%+6d [4]:%+6d [5]:%+6d\r\n",
static_cast<int>(
n),signed_gaugeData[0],signed_gaugeData[1],signed_gaugeData[2],signed_gaugeData[3],signed_gaugeData[4],signed_gaugeData[5]);
 
  458bool StrainCalibGui::acquire_samples(
int samples)
 
  462    const bool enabledebugprints = 
false;
 
  464    if(
false == enableacquisitions)
 
  471    setAcquisitionOfDataActive(
true);
 
  473    vector<cDownloader::strain_value_t> values;
 
  474    bool ret = get(samples, values, enabledebugprints, 
true);
 
  479        if (samples != values.size())
 
  481            yError() << 
"cannot acquire enough strain samples. Only:" << values.size() << 
"instead of" << samples;
 
  485            if (enabledebugprints)
 
  487                yDebug(
"Acquired %lu strain samples. Ready! \n", values.size());
 
  491        if (ui->freeAcqModeGroup->isChecked()) {
 
  493            v.append(ui->freeEdit1->text().toFloat());
 
  494            v.append(ui->freeEdit2->text().toFloat());
 
  495            v.append(ui->freeEdit3->text().toFloat());
 
  496            v.append(ui->freeEdit4->text().toFloat());
 
  497            v.append(ui->freeEdit5->text().toFloat());
 
  498            v.append(ui->freeEdit6->text().toFloat());
 
  499            print(values, fp, v);
 
  515        fprintf(fp, 
"acquisition error. please check log on terminal.\n");
 
  519    setAcquisitionOfDataActive(
false);
 
  527void StrainCalibGui::showMenu()
 
  532        fp = fopen(
"./data/output0.dat",
"w");
 
  533        ui->groupBox->setTitle(
"Beginning calibration ...");
 
  534        ui->labelInstructions->setText(
"Remove all loads from the sensor\n" 
  535                                       "Orient the sensor with the flat surface facing upwards\n" 
  536                                       "Turn the sensor on (CAN message 205 2 7 0)");
 
  540        fp = fopen(
"./data/output1.dat",
"w");
 
  541        ui->groupBox->setTitle(
"(2) z+ pointing DOWNwards 5kg torques - file: output1.dat");
 
  542        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 nut\n" 
  543                                       "2. orient the assembly with the z+ axis pointing downwards\n\n" 
  547        ui->labelInstructions->setText(
"4.  apply 5.00 kg on the y- axis\n");
 
  550        ui->labelInstructions->setText(
"5.   apply 5.00 kg on the x+ axis\n");
 
  553        ui->labelInstructions->setText(
"6.   apply 5.00 kg on the y+ axis\n");
 
  556        ui->labelInstructions->setText(
"7.   apply 5.00 kg on the x- axis\n");
 
  562        fp = fopen(
"./data/output3.dat",
"w");
 
  563        ui->groupBox->setTitle(
"(10) x+ axis pointing UPwards 5kg laterals - file: output3.dat");
 
  564        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  565                                       "2. orient the structure with the x+ axis pointing upwards\n" 
  566                                       "3. remove loads\n");
 
  569        ui->labelInstructions->setText(
"4.   apply 5.00 kg on the y- axis\n");
 
  572        ui->labelInstructions->setText(
"5.   apply 5.00 kg on the z+ axis\n");
 
  575        ui->labelInstructions->setText(
"6.   apply 5.00 kg on the y+ axis\n");
 
  581        fp = fopen(
"./data/output4.dat",
"w");
 
  582        ui->groupBox->setTitle(
"(11) y+ axis pointing UPwards 5kg laterals - file: output4.dat");
 
  583        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  584                                       "2. orient the structure with the y+ axis pointing upwards\n" 
  585                                       "3. remove loads\n");
 
  588        ui->labelInstructions->setText(
"4.   apply 5.00 kg on the x+ axis\n");
 
  591        ui->labelInstructions->setText(
"5.   apply 5.00 kg on the z+ axis\n");
 
  594        ui->labelInstructions->setText(
"6.   apply 5.00 kg on the x- axis\n");
 
  601        fp = fopen(
"./data/output5.dat",
"w");
 
  602        ui->groupBox->setTitle(
"(12) x- axis pointing UPwards 5kg laterals - file: output5.dat");
 
  603        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  604                                       "2. orient the structure with the x- axis pointing upwards\n" 
  605                                       "3. remove loads\n");
 
  608        ui->labelInstructions->setText(
"4.   apply 5.00 kg on the y+ axis\n");
 
  611        ui->labelInstructions->setText(
"5.   apply 5.00 kg on the z+ axis\n");
 
  614        ui->labelInstructions->setText(
"6.   apply 5.00 kg on the y- axis\n");
 
  622        fp = fopen(
"./data/output6.dat",
"w");
 
  623        ui->groupBox->setTitle(
"(13) y- axis pointing UPwards 5kg laterals - file: output6.dat");
 
  624        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  625                                       "2. orient the structure with the y- axis pointing upwards\n" 
  626                                       "3. remove loads\n");
 
  629        ui->labelInstructions->setText(
"4.   apply 5.00 kg on the x- axis\n");
 
  632        ui->labelInstructions->setText(
"5.   apply 5.00 kg on the z+ axis\n");
 
  635        ui->labelInstructions->setText(
"6.   apply 5.00 kg on the x+ axis\n");
 
  643        fp = fopen(
"./data/output81.dat",
"w");
 
  644        ui->groupBox->setTitle(
"(3) z+ pointing UPwards 25kg compression - file: output81.dat");
 
  645        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 nut\n" 
  646                                       "2. orient the assembly with the z+ axis pointing upwards\n\n" 
  647                                       "3. remove loads\n");
 
  651        ui->labelInstructions->setText(
"4. apply 25 kg in the z- direction (compression)\n");
 
  659        fp = fopen(
"./data/output82.dat",
"w");
 
  660        ui->groupBox->setTitle(
"(1) z+ pointing DOWNwards 25kg traction - file: output82.dat");
 
  661        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 nut\n" 
  662                                       "2. screw the M10 ring on the top of the assembly\n" 
  663                                       "3. orient the assembly with the z+ axis pointing downwards\n\n" 
  664                                       "4. remove loads\n");
 
  667        ui->labelInstructions->setText(
"5. apply a 25 kg load in the z+ direction (traction)\n");
 
  675        fp = fopen(
"./data/output83.dat",
"w");
 
  676        ui->groupBox->setTitle(
"(4) x+ pointing UPwards 25kg - file: output83.dat");
 
  677        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  678                                       "2. orient the plate with the x+ axis pointing upwards\n" 
  679                                       "3. remove loads\n");
 
  682        ui->labelInstructions->setText(
"4. apply a 25 kg load in the x- direction\n");
 
  690        fp = fopen(
"./data/output84.dat",
"w");
 
  691        ui->groupBox->setTitle(
"(5) x- pointing UPwards 25kg - file: output84.dat");
 
  692        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  693                                       "2. orient the plate with the x- axis pointing upwards\n\n" 
  694                                       "3. remove loads\n");
 
  697        ui->labelInstructions->setText(
"4. apply a 25 kg load in the x+ direction\n");
 
  704        fp = fopen(
"./data/output85.dat",
"w");
 
  705        ui->groupBox->setTitle(
"(6) label 1 pointing DOWNwards 25kg - file: output85.dat");
 
  706        ui->labelInstructions->setText(
"1. assemble the assembly with label 1 pointing DOWN\n\n" 
  707                                       "3. remove loads\n");
 
  710        ui->labelInstructions->setText(
"4. apply 25kg\n");
 
  718        fp = fopen(
"./data/output86.dat",
"w");
 
  719        ui->groupBox->setTitle(
"(7) label 2 pointing DOWNwards 25kg - file: output86.dat");
 
  720        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  721                                       "2. orient the plate with label 2 pointing DOWN\n\n" 
  722                                       "3. remove loads\n");
 
  725        ui->labelInstructions->setText(
"4. apply 25kg\n");
 
  731        fp = fopen(
"./data/output87.dat",
"w");
 
  732        ui->groupBox->setTitle(
"(8) label 3 pointing DOWNwards 25kg - file: output87.dat");
 
  733        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  734                                       "2. orient the plate with label 3 pointing DOWN\n\n" 
  735                                       "3. remove loads\n");
 
  738        ui->labelInstructions->setText(
"4. apply 25kg\n");
 
  745        fp = fopen(
"./data/output88.dat",
"w");
 
  746        ui->groupBox->setTitle(
"(9) label 4 pointing DOWNwards 25kg - file: output88.dat");
 
  747        ui->labelInstructions->setText(
"1. assemble the assembly with a M10 knob\n" 
  748                                       "2. orient the plate with label 4 pointing DOWN\n\n" 
  749                                       "3. remove loads\n");
 
  752        ui->labelInstructions->setText(
"4. apply 25kg\n");
 
  767void StrainCalibGui::close_files()
 
  775void StrainCalibGui::terminate_section()
 
  781    if(!ui->freeAcqModeGroup->isChecked()){
 
  782        buttons.at(currentBtnIndex)->setStyleSheet(
"background-color: rgb(0, 175, 0);");
 
  788void StrainCalibGui::turnOffButtons()
 
  790    if(!ui->freeAcqModeGroup->isChecked()){
 
  791        foreach (QPushButton *btn, buttons) {
 
  792            btn->setEnabled(
false);
 
  795        ui->btnAcquireData->setEnabled(
true);
 
  796        ui->btnAcquireData->setText(
"Start Acquisition");
 
  797        ui->freeAcqModeGroup->setEnabled(
false);
 
  799    ui->spinSamples->setEnabled(
true);
 
  803void StrainCalibGui::turnOnButtons()
 
  805    ui->groupBox->setTitle(
"Instructions");
 
  807    if(!ui->freeAcqModeGroup->isChecked()){
 
  808        foreach (QPushButton *btn, buttons) {
 
  809            btn->setEnabled(
true);
 
  811        ui->btnAcquireData->setEnabled(
false);
 
  812        ui->freeAcqModeGroup->setEnabled(
true);
 
  813        if(
false == checkDirectory())
 
  815            yError() << 
"CANNOT find the data folder. Please create it!";
 
  816            ui->labelInstructions->setText(
"You can select an acquisition from the menu ... but:" 
  817                                           "\nCANNOT find the data folder." 
  818                                           "\nIf you want your acquisition data saved, please create it!");
 
  822             ui->labelInstructions->setText(
"Select an acquisition from the menu");
 
  825        ui->labelInstructions->setText(
"Free Acquisiton Mode");
 
  828    ui->spinSamples->setEnabled(
false);
 
  832void StrainCalibGui::bias_sensor()
 
  835        ATIsens->BiasForceTorqueSensor();
 
  840int StrainCalibGui::remap_trials()
 
  846        case 1001: 
return -1;
 
  852        case 3001: 
return -1;
 
  857        case 4001: 
return -1;
 
  862        case 5001: 
return -1;
 
  863        case 5002: 
return 10;
 
  864        case 5003: 
return 11;
 
  865        case 5004: 
return 12;
 
  867        case 6001: 
return -1;
 
  868        case 6002: 
return 13;
 
  869        case 6003: 
return 14;
 
  870        case 6004: 
return 15;
 
  872        case 8010: 
return -1;
 
  873        case 8011: 
return 16;
 
  875        case 8020: 
return -1;
 
  876        case 8021: 
return 17;
 
  878        case 8030: 
return -1;
 
  879        case 8031: 
return 18;
 
  881        case 8040: 
return -1;
 
  882        case 8041: 
return 19;
 
  884        case 8050: 
return -1;
 
  885        case 8051: 
return 20;
 
  887        case 8060: 
return -1;
 
  888        case 8061: 
return 21;
 
  890        case 8070: 
return -1;
 
  891        case 8071: 
return 22;
 
  893        case 8080: 
return -1;
 
  894        case 8081: 
return 23;
 
  901            qDebug(
"DEBUG: **** ERROR, invalid trial (%d) selected! ****\n", trial);
 
  907void StrainCalibGui::onTimerTimeout()
 
  911    current_trial=remap_trials();
 
  916    if (current_trial==-1){
 
  919                readValues.at(i)->setText(QString(
"%1").arg(last_value.
dat[i]));
 
  920                expValues.at(i)->setText(
"---");
 
  921                errValues.at(i)->setText(
"---");
 
  922                expValues.at(i)->setStyleSheet(
"");
 
  923                errValues.at(i)->setStyleSheet(
"");
 
  927            if(
true == isAcquisitionOfDataActive())
 
  929                ui->btnAcquireData->setEnabled(
false);
 
  930                ui->btnAcquireData->setText(
"Acquiring Data Now");
 
  931                ui->spinSamples->setEnabled(
false);
 
  932                ui->progress->setValue(progressvalue);
 
  936                if(ui->freeAcqModeGroup->isChecked())
 
  938                    ui->btnAcquireData->setEnabled(
true);
 
  939                    ui->btnAcquireData->setText(
"Start Acquiring Data");
 
  940                    ui->spinSamples->setEnabled(
true);
 
  944                    if(!ui->btnAcquireData->isEnabled())
 
  946                        ui->btnAcquireData->setText(
"Choose an Acquisition Mode");
 
  950                ui->progress->setValue(0);
 
  955        if(
true == isAcquisitionOfDataActive())
 
  957            ui->btnAcquireData->setEnabled(
false);
 
  958            ui->btnAcquireData->setText(
"Acquiring Data Now");
 
  959            ui->progress->setValue(progressvalue);
 
  964            ui->progress->setValue(0);
 
  970                expValues.at(i)->setText(QString(
"%1").arg(exp_vals.
dat[i]));
 
  977                readValues.at(i)->setText(QString(
"%1").arg(last.
dat[i]));
 
  979            bool in_boundary = expected_values_handler.
check_vals(last,current_trial,err_vals,in_bound);
 
  981                errValues.at(i)->setText(QString(
"%1").arg(err_vals.
dat[i]));
 
  983                if (in_bound.
dat[i]==0){
 
  984                    errValues.at(i)->setStyleSheet(
"color: rgb(255, 0, 0);");
 
  985                } 
else if (in_bound.
dat[i]==1) {
 
  986                    errValues.at(i)->setStyleSheet(
"color: rgb(0, 255, 0);");
 
  987                } 
else if (in_bound.
dat[i]==2) {
 
  988                    errValues.at(i)->setStyleSheet(
"color: orange;");
 
  993            ui->btnAcquireData->setEnabled(
true);
 
  994            ui->spinSamples->setEnabled(
false);
 
  996            if (in_boundary==
false){
 
  997             ui->btnAcquireData->setText(
"Strange values detected.\n Acquire anyway? ");
 
  999             ui->btnAcquireData->setText(
"Regular Values: Acquire Data");
 
 1006bool StrainCalibGui::tick_acquisition(
int samples)
 
 1010    if(
false == enableacquisitions)
 
 1017    vector<cDownloader::strain_value_t> values;
 
 1018    get(samples, values, enabledebugprints, 
false);
 
 1023    if(values.size() > 0)
 
 1035void StrainCalibGui::setAcquisitionOfDataActive(
const bool active)
 
 1037    mutexacquisitionofdata.lock();
 
 1038    acquiringdata = active;
 
 1039    mutexacquisitionofdata.unlock();
 
 1042bool StrainCalibGui::isAcquisitionOfDataActive()
 
 1044    bool active = 
false;
 
 1045    mutexacquisitionofdata.lock();
 
 1046    active = acquiringdata;
 
 1047    mutexacquisitionofdata.unlock();
 
 1051void StrainCalibGui::lockdriver(
const bool on)
 
 1059        mutexdriver.unlock();
 
 1063bool StrainCalibGui::checkDirectory()
 
 1065    QFileInfo dir =  QFileInfo(
"./data");
 
cDownloader * getDownloader()
 
StrainCalibGui(QString device, int bus, int pid, FirmwareUpdaterCore *core, QWidget *parent=0)
 
int strain_acquire_start(int bus, int target_id, uint8_t txratemilli=20, bool calibmode=true, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
 
int strain_acquire_stop(int bus, int target_id, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
 
int strain_acquire_get(int bus, int target_id, vector< strain_value_t > &values, const unsigned int howmany=10, void(*updateProgressBar)(void *, float)=NULL, void *arg=NULL, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, const unsigned int maxerrors=1, string *errorstring=NULL)
 
strain_acquisition_mode_t
 
@ strain_acquisition_mode_polling
 
@ strain_acquisition_mode_streaming
 
bool get_thresholds(int &low, int &high)
 
bool init(const char *filename)
 
void get_current_expected_values(signed_elem_class &values, int trial)
 
std::string get_serialnumber()
 
bool check_vals(signed_elem_class values, int trial, signed_elem_class &diff, signed_elem_class &in_bound)
 
static struct bpf_program fp
 
void extract(signed short *ss6) const
 
void remove_bias(signed_elem_class bias)
 
int get_canaddress() const