Changeset 527763f in subsurface


Ignore:
Timestamp:
May 4, 2017, 10:50:15 AM (3 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
5a4e1a5
Parents:
4cbf64b
git-author:
Anton Lundin <glance@…> (04/27/17 11:35:02)
git-committer:
Dirk Hohndel <dirk@…> (05/04/17 10:50:15)
Message:

Start to read/write and present some OSTC4 settings

This is mostly copy-paste from the ostc3 case, but there are some minor
differences. Some minor things have different meaning, and there's a
slightly different command set, but I couldn't figure out a sane way of
joining them.

Signed-off-by: Anton Lundin <glance@…>

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/configuredivecomputerthreads.cpp

    r4cbf64b r527763f  
    364364static dc_status_t read_ostc4_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
    365365{
     366        // This code is really similar to the OSTC3 code, but there are minor
     367        // differences in what the data means, and how to communicate with the
     368        // device. If anyone can find a good way to harmonize the two, be my guest.
    366369        dc_status_t rc = DC_STATUS_SUCCESS;
    367370        dc_event_progress_t progress;
    368371        progress.current = 0;
    369         progress.maximum = 1;
     372        progress.maximum = 19;
    370373        unsigned char hardware[1];
    371374
    372375        EMIT_PROGRESS();
    373376
     377        //Read gas mixes
     378        gas gas1;
     379        gas gas2;
     380        gas gas3;
     381        gas gas4;
     382        gas gas5;
     383        unsigned char gasData[4] = { 0, 0, 0, 0 };
     384
     385        rc = hw_ostc3_device_config_read(device, OSTC3_GAS1, gasData, sizeof(gasData));
     386        if (rc != DC_STATUS_SUCCESS)
     387                return rc;
     388        gas1.oxygen = gasData[0];
     389        gas1.helium = gasData[1];
     390        gas1.type = gasData[2];
     391        gas1.depth = gasData[3];
     392        EMIT_PROGRESS();
     393
     394        rc = hw_ostc3_device_config_read(device, OSTC3_GAS2, gasData, sizeof(gasData));
     395        if (rc != DC_STATUS_SUCCESS)
     396                return rc;
     397        gas2.oxygen = gasData[0];
     398        gas2.helium = gasData[1];
     399        gas2.type = gasData[2];
     400        gas2.depth = gasData[3];
     401        EMIT_PROGRESS();
     402
     403        rc = hw_ostc3_device_config_read(device, OSTC3_GAS3, gasData, sizeof(gasData));
     404        if (rc != DC_STATUS_SUCCESS)
     405                return rc;
     406        gas3.oxygen = gasData[0];
     407        gas3.helium = gasData[1];
     408        gas3.type = gasData[2];
     409        gas3.depth = gasData[3];
     410        EMIT_PROGRESS();
     411
     412        rc = hw_ostc3_device_config_read(device, OSTC3_GAS4, gasData, sizeof(gasData));
     413        if (rc != DC_STATUS_SUCCESS)
     414                return rc;
     415        gas4.oxygen = gasData[0];
     416        gas4.helium = gasData[1];
     417        gas4.type = gasData[2];
     418        gas4.depth = gasData[3];
     419        EMIT_PROGRESS();
     420
     421        rc = hw_ostc3_device_config_read(device, OSTC3_GAS5, gasData, sizeof(gasData));
     422        if (rc != DC_STATUS_SUCCESS)
     423                return rc;
     424        gas5.oxygen = gasData[0];
     425        gas5.helium = gasData[1];
     426        gas5.type = gasData[2];
     427        gas5.depth = gasData[3];
     428        EMIT_PROGRESS();
     429
     430        m_deviceDetails->gas1 = gas1;
     431        m_deviceDetails->gas2 = gas2;
     432        m_deviceDetails->gas3 = gas3;
     433        m_deviceDetails->gas4 = gas4;
     434        m_deviceDetails->gas5 = gas5;
     435        EMIT_PROGRESS();
     436
     437        //Read Dil Values
     438        gas dil1;
     439        gas dil2;
     440        gas dil3;
     441        gas dil4;
     442        gas dil5;
     443        unsigned char dilData[4] = { 0, 0, 0, 0 };
     444
     445        rc = hw_ostc3_device_config_read(device, OSTC3_DIL1, dilData, sizeof(dilData));
     446        if (rc != DC_STATUS_SUCCESS)
     447                return rc;
     448        dil1.oxygen = dilData[0];
     449        dil1.helium = dilData[1];
     450        dil1.type = dilData[2];
     451        dil1.depth = dilData[3];
     452        EMIT_PROGRESS();
     453
     454        rc = hw_ostc3_device_config_read(device, OSTC3_DIL2, dilData, sizeof(dilData));
     455        if (rc != DC_STATUS_SUCCESS)
     456                return rc;
     457        dil2.oxygen = dilData[0];
     458        dil2.helium = dilData[1];
     459        dil2.type = dilData[2];
     460        dil2.depth = dilData[3];
     461        EMIT_PROGRESS();
     462
     463        rc = hw_ostc3_device_config_read(device, OSTC3_DIL3, dilData, sizeof(dilData));
     464        if (rc != DC_STATUS_SUCCESS)
     465                return rc;
     466        dil3.oxygen = dilData[0];
     467        dil3.helium = dilData[1];
     468        dil3.type = dilData[2];
     469        dil3.depth = dilData[3];
     470        EMIT_PROGRESS();
     471
     472        rc = hw_ostc3_device_config_read(device, OSTC3_DIL4, dilData, sizeof(dilData));
     473        if (rc != DC_STATUS_SUCCESS)
     474                return rc;
     475        dil4.oxygen = dilData[0];
     476        dil4.helium = dilData[1];
     477        dil4.type = dilData[2];
     478        dil4.depth = dilData[3];
     479        EMIT_PROGRESS();
     480
     481        rc = hw_ostc3_device_config_read(device, OSTC3_DIL5, dilData, sizeof(dilData));
     482        if (rc != DC_STATUS_SUCCESS)
     483                return rc;
     484        dil5.oxygen = dilData[0];
     485        dil5.helium = dilData[1];
     486        dil5.type = dilData[2];
     487        dil5.depth = dilData[3];
     488        EMIT_PROGRESS();
     489
     490        m_deviceDetails->dil1 = dil1;
     491        m_deviceDetails->dil2 = dil2;
     492        m_deviceDetails->dil3 = dil3;
     493        m_deviceDetails->dil4 = dil4;
     494        m_deviceDetails->dil5 = dil5;
     495
     496        //Read setpoint Values
     497        setpoint sp1;
     498        setpoint sp2;
     499        setpoint sp3;
     500        setpoint sp4;
     501        setpoint sp5;
     502        unsigned char spData[4] = { 0, 0, 0, 0};
     503
     504        rc = hw_ostc3_device_config_read(device, OSTC3_SP1, spData, sizeof(spData));
     505        if (rc != DC_STATUS_SUCCESS)
     506                return rc;
     507        sp1.sp = spData[0];
     508        sp1.depth = spData[1];
     509        EMIT_PROGRESS();
     510
     511        rc = hw_ostc3_device_config_read(device, OSTC3_SP2, spData, sizeof(spData));
     512        if (rc != DC_STATUS_SUCCESS)
     513                return rc;
     514        sp2.sp = spData[0];
     515        sp2.depth = spData[1];
     516        EMIT_PROGRESS();
     517
     518        rc = hw_ostc3_device_config_read(device, OSTC3_SP3, spData, sizeof(spData));
     519        if (rc != DC_STATUS_SUCCESS)
     520                return rc;
     521        sp3.sp = spData[0];
     522        sp3.depth = spData[1];
     523        EMIT_PROGRESS();
     524
     525        rc = hw_ostc3_device_config_read(device, OSTC3_SP4, spData, sizeof(spData));
     526        if (rc != DC_STATUS_SUCCESS)
     527                return rc;
     528        sp4.sp = spData[0];
     529        sp4.depth = spData[1];
     530        EMIT_PROGRESS();
     531
     532        rc = hw_ostc3_device_config_read(device, OSTC3_SP5, spData, sizeof(spData));
     533        if (rc != DC_STATUS_SUCCESS)
     534                return rc;
     535        sp5.sp = spData[0];
     536        sp5.depth = spData[1];
     537        EMIT_PROGRESS();
     538
     539        m_deviceDetails->sp1 = sp1;
     540        m_deviceDetails->sp2 = sp2;
     541        m_deviceDetails->sp3 = sp3;
     542        m_deviceDetails->sp4 = sp4;
     543        m_deviceDetails->sp5 = sp5;
     544
     545        //Read other settings
     546        unsigned char uData[4] = { 0 };
     547
     548#define READ_SETTING(_OSTC4_SETTING, _DEVICE_DETAIL)                                            \
     549        do {                                                                                    \
     550                rc = hw_ostc3_device_config_read(device, _OSTC4_SETTING, uData, sizeof(uData)); \
     551                if (rc != DC_STATUS_SUCCESS)                                                    \
     552                        return rc;                                                              \
     553                m_deviceDetails->_DEVICE_DETAIL = uData[0];                                     \
     554                EMIT_PROGRESS();                                                                \
     555        } while (0)
     556
     557#undef READ_SETTING
     558
     559        rc = hw_ostc3_device_config_read(device, OSTC3_PRESSURE_SENSOR_OFFSET, uData, sizeof(uData));
     560        if (rc != DC_STATUS_SUCCESS)
     561                return rc;
     562        // OSTC3 stores the pressureSensorOffset in two-complement
     563        m_deviceDetails->pressureSensorOffset = (signed char)uData[0];
     564        EMIT_PROGRESS();
     565
     566        rc = hw_ostc3_device_config_read(device, OSTC3_TEMP_SENSOR_OFFSET, uData, sizeof(uData));
     567        if (rc != DC_STATUS_SUCCESS)
     568                return rc;
     569        // OSTC3 stores the tempSensorOffset in two-complement
     570        m_deviceDetails->tempSensorOffset = (signed char)uData[0];
     571        EMIT_PROGRESS();
     572
     573        //read firmware settings
     574        unsigned char fData[64] = { 0 };
     575        rc = hw_ostc3_device_version(device, fData, sizeof(fData));
     576        if (rc != DC_STATUS_SUCCESS)
     577                return rc;
     578        int serial = fData[0] + (fData[1] << 8);
     579        m_deviceDetails->serialNo = QString::number(serial);
     580        unsigned char X, Y, Z, beta;
     581        unsigned int firmwareOnDevice = (fData[3] << 8) + fData[2];
     582        X = (firmwareOnDevice & 0xF800) >> 11;
     583        Y = (firmwareOnDevice & 0x07C0) >> 6;
     584        Z = (firmwareOnDevice & 0x003E) >> 1;
     585        beta = firmwareOnDevice & 0x0001;
     586        m_deviceDetails->firmwareVersion = QString("%1.%2.%3%4").arg(X).arg(Y).arg(Z).arg(beta?" beta":"");
     587        QByteArray ar((char *)fData + 4, 60);
     588        m_deviceDetails->customText = ar.trimmed();
     589        EMIT_PROGRESS();
     590
    374591        return rc;
    375592}
     
    377594static dc_status_t write_ostc4_settings(dc_device_t *device, DeviceDetails *m_deviceDetails, dc_event_callback_t progress_cb, void *userdata)
    378595{
     596        // This code is really similar to the OSTC3 code, but there are minor
     597        // differences in what the data means, and how to communicate with the
     598        // device. If anyone can find a good way to harmonize the two, be my guest.
    379599        dc_status_t rc = DC_STATUS_SUCCESS;
    380600        dc_event_progress_t progress;
    381601        progress.current = 0;
    382         progress.maximum = 1;
     602        progress.maximum = 18;
     603
     604        //write gas values
     605        unsigned char gas1Data[4] = {
     606                m_deviceDetails->gas1.oxygen,
     607                m_deviceDetails->gas1.helium,
     608                m_deviceDetails->gas1.type,
     609                m_deviceDetails->gas1.depth
     610        };
     611
     612        unsigned char gas2Data[4] = {
     613                m_deviceDetails->gas2.oxygen,
     614                m_deviceDetails->gas2.helium,
     615                m_deviceDetails->gas2.type,
     616                m_deviceDetails->gas2.depth
     617        };
     618
     619        unsigned char gas3Data[4] = {
     620                m_deviceDetails->gas3.oxygen,
     621                m_deviceDetails->gas3.helium,
     622                m_deviceDetails->gas3.type,
     623                m_deviceDetails->gas3.depth
     624        };
     625
     626        unsigned char gas4Data[4] = {
     627                m_deviceDetails->gas4.oxygen,
     628                m_deviceDetails->gas4.helium,
     629                m_deviceDetails->gas4.type,
     630                m_deviceDetails->gas4.depth
     631        };
     632
     633        unsigned char gas5Data[4] = {
     634                m_deviceDetails->gas5.oxygen,
     635                m_deviceDetails->gas5.helium,
     636                m_deviceDetails->gas5.type,
     637                m_deviceDetails->gas5.depth
     638        };
     639        //gas 1
     640        rc = hw_ostc3_device_config_write(device, OSTC3_GAS1, gas1Data, sizeof(gas1Data));
     641        if (rc != DC_STATUS_SUCCESS)
     642                return rc;
     643        EMIT_PROGRESS();
     644        //gas 2
     645        rc = hw_ostc3_device_config_write(device, OSTC3_GAS2, gas2Data, sizeof(gas2Data));
     646        if (rc != DC_STATUS_SUCCESS)
     647                return rc;
     648        EMIT_PROGRESS();
     649        //gas 3
     650        rc = hw_ostc3_device_config_write(device, OSTC3_GAS3, gas3Data, sizeof(gas3Data));
     651        if (rc != DC_STATUS_SUCCESS)
     652                return rc;
     653        EMIT_PROGRESS();
     654        //gas 4
     655        rc = hw_ostc3_device_config_write(device, OSTC3_GAS4, gas4Data, sizeof(gas4Data));
     656        if (rc != DC_STATUS_SUCCESS)
     657                return rc;
     658        EMIT_PROGRESS();
     659        //gas 5
     660        rc = hw_ostc3_device_config_write(device, OSTC3_GAS5, gas5Data, sizeof(gas5Data));
     661        if (rc != DC_STATUS_SUCCESS)
     662                return rc;
     663        EMIT_PROGRESS();
     664
     665        //write setpoint values
     666        unsigned char sp1Data[4] = {
     667                m_deviceDetails->sp1.sp,
     668                m_deviceDetails->sp1.depth
     669        };
     670
     671        unsigned char sp2Data[4] = {
     672                m_deviceDetails->sp2.sp,
     673                m_deviceDetails->sp2.depth
     674        };
     675
     676        unsigned char sp3Data[4] = {
     677                m_deviceDetails->sp3.sp,
     678                m_deviceDetails->sp3.depth
     679        };
     680
     681        unsigned char sp4Data[4] = {
     682                m_deviceDetails->sp4.sp,
     683                m_deviceDetails->sp4.depth
     684        };
     685
     686        unsigned char sp5Data[4] = {
     687                m_deviceDetails->sp5.sp,
     688                m_deviceDetails->sp5.depth
     689        };
     690
     691        //sp 1
     692        rc = hw_ostc3_device_config_write(device, OSTC3_SP1, sp1Data, sizeof(sp1Data));
     693        if (rc != DC_STATUS_SUCCESS)
     694                return rc;
     695        EMIT_PROGRESS();
     696        //sp 2
     697        rc = hw_ostc3_device_config_write(device, OSTC3_SP2, sp2Data, sizeof(sp2Data));
     698        if (rc != DC_STATUS_SUCCESS)
     699                return rc;
     700        EMIT_PROGRESS();
     701        //sp 3
     702        rc = hw_ostc3_device_config_write(device, OSTC3_SP3, sp3Data, sizeof(sp3Data));
     703        if (rc != DC_STATUS_SUCCESS)
     704                return rc;
     705        EMIT_PROGRESS();
     706        //sp 4
     707        rc = hw_ostc3_device_config_write(device, OSTC3_SP4, sp4Data, sizeof(sp4Data));
     708        if (rc != DC_STATUS_SUCCESS)
     709                return rc;
     710        EMIT_PROGRESS();
     711        //sp 5
     712        rc = hw_ostc3_device_config_write(device, OSTC3_SP5, sp5Data, sizeof(sp5Data));
     713        if (rc != DC_STATUS_SUCCESS)
     714                return rc;
     715        EMIT_PROGRESS();
     716
     717        //write dil values
     718        unsigned char dil1Data[4] = {
     719                m_deviceDetails->dil1.oxygen,
     720                m_deviceDetails->dil1.helium,
     721                m_deviceDetails->dil1.type,
     722                m_deviceDetails->dil1.depth
     723        };
     724
     725        unsigned char dil2Data[4] = {
     726                m_deviceDetails->dil2.oxygen,
     727                m_deviceDetails->dil2.helium,
     728                m_deviceDetails->dil2.type,
     729                m_deviceDetails->dil2.depth
     730        };
     731
     732        unsigned char dil3Data[4] = {
     733                m_deviceDetails->dil3.oxygen,
     734                m_deviceDetails->dil3.helium,
     735                m_deviceDetails->dil3.type,
     736                m_deviceDetails->dil3.depth
     737        };
     738
     739        unsigned char dil4Data[4] = {
     740                m_deviceDetails->dil4.oxygen,
     741                m_deviceDetails->dil4.helium,
     742                m_deviceDetails->dil4.type,
     743                m_deviceDetails->dil4.depth
     744        };
     745
     746        unsigned char dil5Data[4] = {
     747                m_deviceDetails->dil5.oxygen,
     748                m_deviceDetails->dil5.helium,
     749                m_deviceDetails->dil5.type,
     750                m_deviceDetails->dil5.depth
     751        };
     752        //dil 1
     753        rc = hw_ostc3_device_config_write(device, OSTC3_DIL1, dil1Data, sizeof(gas1Data));
     754        if (rc != DC_STATUS_SUCCESS)
     755                return rc;
     756        EMIT_PROGRESS();
     757        //dil 2
     758        rc = hw_ostc3_device_config_write(device, OSTC3_DIL2, dil2Data, sizeof(dil2Data));
     759        if (rc != DC_STATUS_SUCCESS)
     760                return rc;
     761        EMIT_PROGRESS();
     762        //dil 3
     763        rc = hw_ostc3_device_config_write(device, OSTC3_DIL3, dil3Data, sizeof(dil3Data));
     764        if (rc != DC_STATUS_SUCCESS)
     765                return rc;
     766        EMIT_PROGRESS();
     767        //dil 4
     768        rc = hw_ostc3_device_config_write(device, OSTC3_DIL4, dil4Data, sizeof(dil4Data));
     769        if (rc != DC_STATUS_SUCCESS)
     770                return rc;
     771        EMIT_PROGRESS();
     772        //dil 5
     773        rc = hw_ostc3_device_config_write(device, OSTC3_DIL5, dil5Data, sizeof(dil5Data));
     774        if (rc != DC_STATUS_SUCCESS)
     775                return rc;
     776        EMIT_PROGRESS();
     777
     778        //write general settings
     779        //custom text
     780        rc = hw_ostc3_device_customtext(device, m_deviceDetails->customText.toUtf8().data());
     781        if (rc != DC_STATUS_SUCCESS)
     782                return rc;
     783        EMIT_PROGRESS();
     784
     785        unsigned char data[4] = { 0 };
     786#define WRITE_SETTING(_OSTC4_SETTING, _DEVICE_DETAIL)                                          \
     787        do {                                                                                   \
     788                data[0] = m_deviceDetails->_DEVICE_DETAIL;                                     \
     789                rc = hw_ostc3_device_config_write(device, _OSTC4_SETTING, data, sizeof(data)); \
     790                if (rc != DC_STATUS_SUCCESS)                                                   \
     791                        return rc;                                                             \
     792                EMIT_PROGRESS();                                                               \
     793        } while (0)
     794
     795#undef WRITE_SETTING
     796
     797        // OSTC3 stores the pressureSensorOffset in two-complement
     798        data[0] = (unsigned char)m_deviceDetails->pressureSensorOffset;
     799        rc = hw_ostc3_device_config_write(device, OSTC3_PRESSURE_SENSOR_OFFSET, data, sizeof(data));
     800        if (rc != DC_STATUS_SUCCESS)
     801                return rc;
     802        EMIT_PROGRESS();
     803
     804        // OSTC3 stores the tempSensorOffset in two-complement
     805        data[0] = (unsigned char)m_deviceDetails->tempSensorOffset;
     806        rc = hw_ostc3_device_config_write(device, OSTC3_TEMP_SENSOR_OFFSET, data, sizeof(data));
     807        if (rc != DC_STATUS_SUCCESS)
     808                return rc;
     809        EMIT_PROGRESS();
     810
     811
     812        //sync date and time
     813        if (m_deviceDetails->syncTime) {
     814                dc_datetime_t now;
     815                dc_datetime_localtime(&now, dc_datetime_now());
     816
     817                rc = hw_ostc3_device_clock(device, &now);
     818        }
    383819
    384820        EMIT_PROGRESS();
  • desktop-widgets/configuredivecomputerdialog.cpp

    r4cbf64b r527763f  
    791791void ConfigureDiveComputerDialog::populateDeviceDetailsOSTC4()
    792792{
     793        deviceDetails->customText = ui.customTextLlineEdit_4->text();
     794        deviceDetails->diveMode = ui.diveModeComboBox_4->currentIndex();
     795        deviceDetails->saturation = ui.saturationSpinBox_4->value();
     796        deviceDetails->desaturation = ui.desaturationSpinBox_4->value();
     797        deviceDetails->lastDeco = ui.lastDecoSpinBox_4->value();
     798        deviceDetails->brightness = ui.brightnessComboBox_4->currentIndex();
     799        deviceDetails->units = ui.unitsComboBox_4->currentIndex();
     800        deviceDetails->samplingRate = ui.samplingRateComboBox_4->currentIndex();
     801        deviceDetails->salinity = ui.salinitySpinBox_4->value();
     802        deviceDetails->diveModeColor = ui.diveModeColour_4->currentIndex();
     803        deviceDetails->language = ui.languageComboBox_4->currentIndex();
     804        deviceDetails->dateFormat = ui.dateFormatComboBox_4->currentIndex();
     805        deviceDetails->compassGain = ui.compassGainComboBox_4->currentIndex();
     806        deviceDetails->syncTime = ui.dateTimeSyncCheckBox_4->isChecked();
     807        deviceDetails->safetyStop = ui.safetyStopCheckBox_4->isChecked();
     808        deviceDetails->gfHigh = ui.gfHighSpinBox_4->value();
     809        deviceDetails->gfLow = ui.gfLowSpinBox_4->value();
     810        deviceDetails->pressureSensorOffset = ui.pressureSensorOffsetSpinBox_4->value();
     811        deviceDetails->ppO2Min = ui.ppO2MinSpinBox_4->value();
     812        deviceDetails->ppO2Max = ui.ppO2MaxSpinBox_4->value();
     813        deviceDetails->futureTTS = ui.futureTTSSpinBox_4->value();
     814        deviceDetails->ccrMode = ui.ccrModeComboBox_4->currentIndex();
     815        deviceDetails->decoType = ui.decoTypeComboBox_4->currentIndex();
     816        deviceDetails->aGFSelectable = ui.aGFSelectableCheckBox_4->isChecked();
     817        deviceDetails->aGFHigh = ui.aGFHighSpinBox_4->value();
     818        deviceDetails->aGFLow = ui.aGFLowSpinBox_4->value();
     819        deviceDetails->calibrationGas = ui.calibrationGasSpinBox_4->value();
     820        deviceDetails->flipScreen = ui.flipScreenCheckBox_4->isChecked();
     821        deviceDetails->setPointFallback = ui.setPointFallbackCheckBox_4->isChecked();
     822        deviceDetails->leftButtonSensitivity = ui.leftButtonSensitivity_4->value();
     823        deviceDetails->rightButtonSensitivity = ui.rightButtonSensitivity_4->value();
     824        deviceDetails->bottomGasConsumption = ui.bottomGasConsumption_4->value();
     825        deviceDetails->decoGasConsumption = ui.decoGasConsumption_4->value();
     826        deviceDetails->modWarning = ui.modWarning_4->isChecked();
     827        deviceDetails->dynamicAscendRate = ui.dynamicAscendRate_4->isChecked();
     828        deviceDetails->graphicalSpeedIndicator = ui.graphicalSpeedIndicator_4->isChecked();
     829        deviceDetails->alwaysShowppO2 = ui.alwaysShowppO2_4->isChecked();
     830        deviceDetails->tempSensorOffset = lrint(ui.tempSensorOffsetDoubleSpinBox_4->value() * 10);
     831        deviceDetails->safetyStopLength = ui.safetyStopLengthSpinBox_4->value();
     832        deviceDetails->safetyStopStartDepth = lrint(ui.safetyStopStartDepthDoubleSpinBox_4->value() * 10);
     833        deviceDetails->safetyStopEndDepth = lrint(ui.safetyStopEndDepthDoubleSpinBox_4->value() * 10);
     834        deviceDetails->safetyStopResetDepth = lrint(ui.safetyStopResetDepthDoubleSpinBox_4->value() * 10);
     835
     836        //set gas values
     837        gas gas1;
     838        gas gas2;
     839        gas gas3;
     840        gas gas4;
     841        gas gas5;
     842
     843        gas1.oxygen = GET_INT_FROM(ui.ostc4GasTable->item(0, 1), 21);
     844        gas1.helium = GET_INT_FROM(ui.ostc4GasTable->item(0, 2), 0);
     845        gas1.type = GET_INT_FROM(ui.ostc4GasTable->item(0, 3), 0);
     846        gas1.depth = GET_INT_FROM(ui.ostc4GasTable->item(0, 4), 0);
     847
     848        gas2.oxygen = GET_INT_FROM(ui.ostc4GasTable->item(1, 1), 21);
     849        gas2.helium = GET_INT_FROM(ui.ostc4GasTable->item(1, 2), 0);
     850        gas2.type = GET_INT_FROM(ui.ostc4GasTable->item(1, 3), 0);
     851        gas2.depth = GET_INT_FROM(ui.ostc4GasTable->item(1, 4), 0);
     852
     853        gas3.oxygen = GET_INT_FROM(ui.ostc4GasTable->item(2, 1), 21);
     854        gas3.helium = GET_INT_FROM(ui.ostc4GasTable->item(2, 2), 0);
     855        gas3.type = GET_INT_FROM(ui.ostc4GasTable->item(2, 3), 0);
     856        gas3.depth = GET_INT_FROM(ui.ostc4GasTable->item(2, 4), 0);
     857
     858        gas4.oxygen = GET_INT_FROM(ui.ostc4GasTable->item(3, 1), 21);
     859        gas4.helium = GET_INT_FROM(ui.ostc4GasTable->item(3, 2), 0);
     860        gas4.type = GET_INT_FROM(ui.ostc4GasTable->item(3, 3), 0);
     861        gas4.depth = GET_INT_FROM(ui.ostc4GasTable->item(3, 4), 0);
     862
     863        gas5.oxygen = GET_INT_FROM(ui.ostc4GasTable->item(4, 1), 21);
     864        gas5.helium = GET_INT_FROM(ui.ostc4GasTable->item(4, 2), 0);
     865        gas5.type = GET_INT_FROM(ui.ostc4GasTable->item(4, 3), 0);
     866        gas5.depth = GET_INT_FROM(ui.ostc4GasTable->item(4, 4), 0);
     867
     868        deviceDetails->gas1 = gas1;
     869        deviceDetails->gas2 = gas2;
     870        deviceDetails->gas3 = gas3;
     871        deviceDetails->gas4 = gas4;
     872        deviceDetails->gas5 = gas5;
     873
     874        //set dil values
     875        gas dil1;
     876        gas dil2;
     877        gas dil3;
     878        gas dil4;
     879        gas dil5;
     880
     881        dil1.oxygen = GET_INT_FROM(ui.ostc4DilTable->item(0, 1), 21);
     882        dil1.helium = GET_INT_FROM(ui.ostc4DilTable->item(0, 2), 0);
     883        dil1.type = GET_INT_FROM(ui.ostc4DilTable->item(0, 3), 0);
     884        dil1.depth = GET_INT_FROM(ui.ostc4DilTable->item(0, 4), 0);
     885
     886        dil2.oxygen = GET_INT_FROM(ui.ostc4DilTable->item(1, 1), 21);
     887        dil2.helium = GET_INT_FROM(ui.ostc4DilTable->item(1, 2), 0);
     888        dil2.type = GET_INT_FROM(ui.ostc4DilTable->item(1, 3), 0);
     889        dil2.depth = GET_INT_FROM(ui.ostc4DilTable->item(1, 4), 0);
     890
     891        dil3.oxygen = GET_INT_FROM(ui.ostc4DilTable->item(2, 1), 21);
     892        dil3.helium = GET_INT_FROM(ui.ostc4DilTable->item(2, 2), 0);
     893        dil3.type = GET_INT_FROM(ui.ostc4DilTable->item(2, 4), 0);
     894        dil3.depth = GET_INT_FROM(ui.ostc4DilTable->item(2, 4), 0);
     895
     896        dil4.oxygen = GET_INT_FROM(ui.ostc4DilTable->item(3, 1), 21);
     897        dil4.helium = GET_INT_FROM(ui.ostc4DilTable->item(3, 2), 0);
     898        dil4.type = GET_INT_FROM(ui.ostc4DilTable->item(3, 3), 0);
     899        dil4.depth = GET_INT_FROM(ui.ostc4DilTable->item(3, 4), 0);
     900
     901        dil5.oxygen = GET_INT_FROM(ui.ostc4DilTable->item(4, 1), 21);
     902        dil5.helium = GET_INT_FROM(ui.ostc4DilTable->item(4, 2), 0);
     903        dil5.type = GET_INT_FROM(ui.ostc4DilTable->item(4, 3), 0);
     904        dil5.depth = GET_INT_FROM(ui.ostc4DilTable->item(4, 4), 0);
     905
     906        deviceDetails->dil1 = dil1;
     907        deviceDetails->dil2 = dil2;
     908        deviceDetails->dil3 = dil3;
     909        deviceDetails->dil4 = dil4;
     910        deviceDetails->dil5 = dil5;
     911
     912        //set setpoint details
     913        setpoint sp1;
     914        setpoint sp2;
     915        setpoint sp3;
     916        setpoint sp4;
     917        setpoint sp5;
     918
     919        sp1.sp = GET_INT_FROM(ui.ostc4SetPointTable->item(0, 1), 70);
     920        sp1.depth = GET_INT_FROM(ui.ostc4SetPointTable->item(0, 2), 0);
     921
     922        sp2.sp = GET_INT_FROM(ui.ostc4SetPointTable->item(1, 1), 90);
     923        sp2.depth = GET_INT_FROM(ui.ostc4SetPointTable->item(1, 2), 20);
     924
     925        sp3.sp = GET_INT_FROM(ui.ostc4SetPointTable->item(2, 1), 100);
     926        sp3.depth = GET_INT_FROM(ui.ostc4SetPointTable->item(2, 2), 44);
     927
     928        sp4.sp = GET_INT_FROM(ui.ostc4SetPointTable->item(3, 1), 120);
     929        sp4.depth = GET_INT_FROM(ui.ostc4SetPointTable->item(3, 2), 50);
     930
     931        sp5.sp = GET_INT_FROM(ui.ostc4SetPointTable->item(4, 1), 140);
     932        sp5.depth = GET_INT_FROM(ui.ostc4SetPointTable->item(4, 2), 70);
     933
     934        deviceDetails->sp1 = sp1;
     935        deviceDetails->sp2 = sp2;
     936        deviceDetails->sp3 = sp3;
     937        deviceDetails->sp4 = sp4;
     938        deviceDetails->sp5 = sp5;
    793939}
    794940
     
    11621308void ConfigureDiveComputerDialog::reloadValuesOSTC4()
    11631309{
     1310        ui.serialNoLineEdit_4->setText(deviceDetails->serialNo);
     1311        ui.firmwareVersionLineEdit_4->setText(deviceDetails->firmwareVersion);
     1312        ui.customTextLlineEdit_4->setText(deviceDetails->customText);
     1313        ui.modelLineEdit_4->setText(deviceDetails->model);
     1314        ui.diveModeComboBox_4->setCurrentIndex(deviceDetails->diveMode);
     1315        ui.saturationSpinBox_4->setValue(deviceDetails->saturation);
     1316        ui.desaturationSpinBox_4->setValue(deviceDetails->desaturation);
     1317        ui.lastDecoSpinBox_4->setValue(deviceDetails->lastDeco);
     1318        ui.brightnessComboBox_4->setCurrentIndex(deviceDetails->brightness);
     1319        ui.unitsComboBox_4->setCurrentIndex(deviceDetails->units);
     1320        ui.samplingRateComboBox_4->setCurrentIndex(deviceDetails->samplingRate);
     1321        ui.salinitySpinBox_4->setValue(deviceDetails->salinity);
     1322        ui.diveModeColour_4->setCurrentIndex(deviceDetails->diveModeColor);
     1323        ui.languageComboBox_4->setCurrentIndex(deviceDetails->language);
     1324        ui.dateFormatComboBox_4->setCurrentIndex(deviceDetails->dateFormat);
     1325        ui.compassGainComboBox_4->setCurrentIndex(deviceDetails->compassGain);
     1326        ui.safetyStopCheckBox_4->setChecked(deviceDetails->safetyStop);
     1327        ui.gfHighSpinBox_4->setValue(deviceDetails->gfHigh);
     1328        ui.gfLowSpinBox_4->setValue(deviceDetails->gfLow);
     1329        ui.pressureSensorOffsetSpinBox_4->setValue(deviceDetails->pressureSensorOffset);
     1330        ui.ppO2MinSpinBox_4->setValue(deviceDetails->ppO2Min);
     1331        ui.ppO2MaxSpinBox_4->setValue(deviceDetails->ppO2Max);
     1332        ui.futureTTSSpinBox_4->setValue(deviceDetails->futureTTS);
     1333        ui.ccrModeComboBox_4->setCurrentIndex(deviceDetails->ccrMode);
     1334        ui.decoTypeComboBox_4->setCurrentIndex(deviceDetails->decoType);
     1335        ui.aGFSelectableCheckBox_4->setChecked(deviceDetails->aGFSelectable);
     1336        ui.aGFHighSpinBox_4->setValue(deviceDetails->aGFHigh);
     1337        ui.aGFLowSpinBox_4->setValue(deviceDetails->aGFLow);
     1338        ui.calibrationGasSpinBox_4->setValue(deviceDetails->calibrationGas);
     1339        ui.flipScreenCheckBox_4->setChecked(deviceDetails->flipScreen);
     1340        ui.setPointFallbackCheckBox_4->setChecked(deviceDetails->setPointFallback);
     1341        ui.leftButtonSensitivity_4->setValue(deviceDetails->leftButtonSensitivity);
     1342        ui.rightButtonSensitivity_4->setValue(deviceDetails->rightButtonSensitivity);
     1343        ui.bottomGasConsumption_4->setValue(deviceDetails->bottomGasConsumption);
     1344        ui.decoGasConsumption_4->setValue(deviceDetails->decoGasConsumption);
     1345        ui.modWarning_4->setChecked(deviceDetails->modWarning);
     1346        ui.dynamicAscendRate_4->setChecked(deviceDetails->dynamicAscendRate);
     1347        ui.graphicalSpeedIndicator_4->setChecked(deviceDetails->graphicalSpeedIndicator);
     1348        ui.alwaysShowppO2_4->setChecked(deviceDetails->alwaysShowppO2);
     1349        ui.tempSensorOffsetDoubleSpinBox_4->setValue((double)deviceDetails->tempSensorOffset / 10.0);
     1350        ui.safetyStopLengthSpinBox_4->setValue(deviceDetails->safetyStopLength);
     1351        ui.safetyStopStartDepthDoubleSpinBox_4->setValue(deviceDetails->safetyStopStartDepth / 10.0);
     1352        ui.safetyStopEndDepthDoubleSpinBox_4->setValue(deviceDetails->safetyStopEndDepth / 10.0);
     1353        ui.safetyStopResetDepthDoubleSpinBox_4->setValue(deviceDetails->safetyStopResetDepth / 10.0);
     1354
     1355        //load gas 1 values
     1356        ui.ostc4GasTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->gas1.oxygen)));
     1357        ui.ostc4GasTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->gas1.helium)));
     1358        ui.ostc4GasTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->gas1.type)));
     1359        ui.ostc4GasTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->gas1.depth)));
     1360
     1361        //load gas 2 values
     1362        ui.ostc4GasTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->gas2.oxygen)));
     1363        ui.ostc4GasTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->gas2.helium)));
     1364        ui.ostc4GasTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->gas2.type)));
     1365        ui.ostc4GasTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->gas2.depth)));
     1366
     1367        //load gas 3 values
     1368        ui.ostc4GasTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->gas3.oxygen)));
     1369        ui.ostc4GasTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->gas3.helium)));
     1370        ui.ostc4GasTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->gas3.type)));
     1371        ui.ostc4GasTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->gas3.depth)));
     1372
     1373        //load gas 4 values
     1374        ui.ostc4GasTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->gas4.oxygen)));
     1375        ui.ostc4GasTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->gas4.helium)));
     1376        ui.ostc4GasTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->gas4.type)));
     1377        ui.ostc4GasTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->gas4.depth)));
     1378
     1379        //load gas 5 values
     1380        ui.ostc4GasTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->gas5.oxygen)));
     1381        ui.ostc4GasTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->gas5.helium)));
     1382        ui.ostc4GasTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->gas5.type)));
     1383        ui.ostc4GasTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->gas5.depth)));
     1384
     1385        //load dil 1 values
     1386        ui.ostc4DilTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->dil1.oxygen)));
     1387        ui.ostc4DilTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->dil1.helium)));
     1388        ui.ostc4DilTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->dil1.type)));
     1389        ui.ostc4DilTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->dil1.depth)));
     1390
     1391        //load dil 2 values
     1392        ui.ostc4DilTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->dil2.oxygen)));
     1393        ui.ostc4DilTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->dil2.helium)));
     1394        ui.ostc4DilTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->dil2.type)));
     1395        ui.ostc4DilTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->dil2.depth)));
     1396
     1397        //load dil 3 values
     1398        ui.ostc4DilTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->dil3.oxygen)));
     1399        ui.ostc4DilTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->dil3.helium)));
     1400        ui.ostc4DilTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->dil3.type)));
     1401        ui.ostc4DilTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->dil3.depth)));
     1402
     1403        //load dil 4 values
     1404        ui.ostc4DilTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->dil4.oxygen)));
     1405        ui.ostc4DilTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->dil4.helium)));
     1406        ui.ostc4DilTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->dil4.type)));
     1407        ui.ostc4DilTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->dil4.depth)));
     1408
     1409        //load dil 5 values
     1410        ui.ostc4DilTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->dil5.oxygen)));
     1411        ui.ostc4DilTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->dil5.helium)));
     1412        ui.ostc4DilTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->dil5.type)));
     1413        ui.ostc4DilTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->dil5.depth)));
     1414
     1415        //load setpoint 1 values
     1416        ui.ostc4SetPointTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->sp1.sp)));
     1417        ui.ostc4SetPointTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->sp1.depth)));
     1418
     1419        //load setpoint 2 values
     1420        ui.ostc4SetPointTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->sp2.sp)));
     1421        ui.ostc4SetPointTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->sp2.depth)));
     1422
     1423        //load setpoint 4 values
     1424        ui.ostc4SetPointTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->sp3.sp)));
     1425        ui.ostc4SetPointTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->sp3.depth)));
     1426
     1427        //load setpoint 4 values
     1428        ui.ostc4SetPointTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->sp4.sp)));
     1429        ui.ostc4SetPointTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->sp4.depth)));
     1430
     1431        //load setpoint 5 values
     1432        ui.ostc4SetPointTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->sp5.sp)));
     1433        ui.ostc4SetPointTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->sp5.depth)));
    11641434}
    11651435
Note: See TracChangeset for help on using the changeset viewer.