Mercurial > public > ostc_companion
comparison OSTC2Operations.cpp @ 1:0b3630a29ad8
Initial version based on previous repository.
Project was ported to QT6 and in now cmake based.
| author | Ideenmodellierer <tiefenrauscher@web.de> |
|---|---|
| date | Thu, 27 Nov 2025 18:40:28 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:76ccd6ce50c0 | 1:0b3630a29ad8 |
|---|---|
| 1 ////////////////////////////////////////////////////////////////////////////// | |
| 2 /// \file OSTC2Operations.cpp | |
| 3 /// \brief Implementing various operations for the new OSTC2 (hwOS) dive computer | |
| 4 /// \author JD Gascuel. | |
| 5 /// \sa ComputerOperations.h | |
| 6 /// | |
| 7 /// \copyright (c) 2011-2016 JD Gascuel. All rights reserved. | |
| 8 /// $Id$ | |
| 9 ////////////////////////////////////////////////////////////////////////////// | |
| 10 // | |
| 11 // BSD 2-Clause License: | |
| 12 // | |
| 13 // Redistribution and use in source and binary forms, with or without | |
| 14 // modification, are permitted provided that the following conditions | |
| 15 // are met: | |
| 16 // | |
| 17 // 1. Redistributions of source code must retain the above copyright notice, | |
| 18 // this list of conditions and the following disclaimer. | |
| 19 // | |
| 20 // 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 21 // this list of conditions and the following disclaimer in the documentation | |
| 22 // and/or other materials provided with the distribution. | |
| 23 // | |
| 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 25 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 26 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 27 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
| 28 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 29 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 30 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 31 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 32 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 33 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 34 // THE POSSIBILITY OF SUCH DAMAGE. | |
| 35 // | |
| 36 ////////////////////////////////////////////////////////////////////////////// | |
| 37 | |
| 38 #include "OSTC2Operations.h" | |
| 39 #include "HexFile.h" | |
| 40 #include "Utils/Log.h" | |
| 41 | |
| 42 #define FIRMWARE_SIZE 0x17F40 | |
| 43 | |
| 44 #include <QApplication> | |
| 45 #include <QProgressBar> | |
| 46 #include <QRegularExpression> | |
| 47 extern QProgressBar* progress; | |
| 48 | |
| 49 ////////////////////////////////////////////////////////////////////////////// | |
| 50 | |
| 51 OSTC2Operations::OSTC2Operations() | |
| 52 { | |
| 53 emulatorName = "OSTC2p"; | |
| 54 } | |
| 55 | |
| 56 ////////////////////////////////////////////////////////////////////////////// | |
| 57 | |
| 58 QStringList OSTC2Operations::listPorts() const | |
| 59 { | |
| 60 return listBluetoothPorts(); | |
| 61 } | |
| 62 | |
| 63 ////////////////////////////////////////////////////////////////////////////// | |
| 64 #if 0 | |
| 65 QRegExp OSTC2Operations::portTemplate() const | |
| 66 { | |
| 67 #if defined(Q_OS_MAC) | |
| 68 return QRegExp("tty.OSTC[0-9]+.*", Qt::CaseInsensitive); | |
| 69 #elif defined(Q_OS_LINUX) | |
| 70 // Seems ok for debian, ubuntu, redhat, CentOS and SUSE (google dixit) | |
| 71 return QRegExp("ttyUSB.*", Qt::CaseSensitive); | |
| 72 #elif defined(Q_OS_WIN) | |
| 73 return QRegExp("COM.*", Qt::CaseSensitive); | |
| 74 #endif | |
| 75 } | |
| 76 #endif | |
| 77 QRegularExpression OSTC2Operations::portTemplate() const | |
| 78 { | |
| 79 #if defined(Q_OS_MAC) | |
| 80 return QRegularExpression("tty.OSTC[0-9]+.*", | |
| 81 QRegularExpression::CaseInsensitiveOption); | |
| 82 #elif defined(Q_OS_LINUX) | |
| 83 // Debian, Ubuntu, RedHat, CentOS, SUSE | |
| 84 return QRegularExpression("ttyUSB.*"); // default: case-sensitive | |
| 85 #elif defined(Q_OS_WIN) | |
| 86 return QRegularExpression("COM.*"); // default: case-sensitive | |
| 87 #endif | |
| 88 } | |
| 89 ////////////////////////////////////////////////////////////////////////////// | |
| 90 | |
| 91 //void OSTC2pOperations::loadFirmware(HexFile& hex, const QString& fileName) const | |
| 92 //{ | |
| 93 // hex.allocate(FIRMWARE_SIZE); | |
| 94 // hex.load(fileName, progress); | |
| 95 // progress->reset(); | |
| 96 //} | |
| 97 | |
| 98 ////////////////////////////////////////////////////////////////////////////// | |
| 99 | |
| 100 QString OSTC2Operations::model() const | |
| 101 { | |
| 102 return "OSTC2"; | |
| 103 } | |
| 104 | |
| 105 HardwareOperations::CompanionFeatures OSTC2Operations::supported() const | |
| 106 { | |
| 107 // No ICON, no DUMPSCREEN. | |
| 108 return CompanionFeatures(PARAMETERS|DATE|NAME|FIRMWARE | |
| 109 |HELIUM_DIVE|CCR_DIVE|BLUETOOTH); | |
| 110 } | |
| 111 | |
| 112 ////////////////////////////////////////////////////////////////////////////// | |
| 113 | |
| 114 QSize OSTC2Operations::nameSize() const | |
| 115 { | |
| 116 return QSize(12, 5); | |
| 117 } | |
| 118 | |
| 119 ////////////////////////////////////////////////////////////////////////////// | |
| 120 | |
| 121 void OSTC2Operations::getIdentity() | |
| 122 { | |
| 123 descriptionString.clear(); | |
| 124 | |
| 125 LOG_TRACE("Getting model..."); | |
| 126 HardwareDescriptor hw = hardwareDescriptor(); | |
| 127 if( hw != HW_OSTC2_a && hw != HW_OSTC2_b && hw != HW_OSTC2_c ) | |
| 128 LOG_THROW("Not an OSTC2."); | |
| 129 | |
| 130 LOG_TRACE("Getting identity..."); | |
| 131 getCommonIdentity(); | |
| 132 | |
| 133 LOG_TRACE("Found " << descriptionString); | |
| 134 } | |
| 135 | |
| 136 ////////////////////////////////////////////////////////////////////////////// | |
| 137 | |
| 138 QString OSTC2Operations::firmwareTemplate() const | |
| 139 { | |
| 140 return "*_firmware.hex"; | |
| 141 } |
