dongfang-scrapyard.txt 6.24 KB
Newer Older
dongfang's avatar
dongfang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243

    /* This information is at least for the time not shown here but rather in some always visible bar.
    void updateBattery(UASInterface*, double, double, double, int);
    void receiveHeartbeat(UASInterface*);
    void updateMode(int id,QString mode, QString description);
    void updateLoad(UASInterface*, double);
    void updateState(UASInterface*,QString);
    void updateGPSFixType(UASInterface*,int);
    void updateSatelliteCount(double count,QString sth);
    void updateThrust(UASInterface*, double);
    void updateLocalPosition(UASInterface*,double,double,double,quint64);
    void updateGlobalPosition(UASInterface*,double,double,double,quint64);
    void selectWaypoint(int uasId, int id);
    */

    /*
    bool uavIsArmed;
    QString mode;
    QString state;
    float load;

    double batteryVoltage;
    double batteryCurrent;
    double batteryCharge;

    int GPSFixType;
    int satelliteCount;
    */




    batteryVoltage(UNKNOWN_BATTERY),
    batteryCurrent(UNKNOWN_BATTERY),
    batteryCharge(UNKNOWN_BATTERY),

    GPSFixType(UNKNOWN_GPSFIXTYPE),
    satelliteCount(UNKNOWN_COUNT),


    uavIsArmed(false),      // TODO: This is an assumption. We have no idea!
    mode("-"),
    state("-"),
    load(0),

void PrimaryFlightDisplay::updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds)
{
    Q_UNUSED(uas);
    Q_UNUSED(seconds);

    batteryVoltage = voltage;
    batteryCurrent = current;
    batteryCharge = percent;
}

void PrimaryFlightDisplay::updateGPSFixType(UASInterface* uas, int fixType) {
    Q_UNUSED(uas);
    this->GPSFixType = fixType;
}

void PrimaryFlightDisplay::updateSatelliteCount(double count, QString name) {
    Q_UNUSED(uas)
    this->satelliteCount = (int)count;
}

void PrimaryFlightDisplay::receiveHeartbeat(UASInterface*)
{
}

void PrimaryFlightDisplay::updateThrust(UASInterface* uas, double thrust)
{
    Q_UNUSED(uas);
    Q_UNUSED(thrust);
}

/*
 * TODO! Implementation or removal of this.
 * Currently a dummy.
 */
void PrimaryFlightDisplay::updateLocalPosition(UASInterface* uas,double x,double y,double z,quint64 timestamp)
{
    Q_UNUSED(uas);
    Q_UNUSED(x);
    Q_UNUSED(y);
    Q_UNUSED(z);
    Q_UNUSED(timestamp);
}

void PrimaryFlightDisplay::updateGlobalPosition(UASInterface* uas,double lat, double lon, double altitude, quint64 timestamp)
{
    Q_UNUSED(uas);
    Q_UNUSED(lat);
    Q_UNUSED(lon);
    Q_UNUSED(timestamp);

    // TODO: Examine whether this is really the GPS alt or the mix-alt coming in.
    GPSAltitude = altitude;
}


void PrimaryFlightDisplay::updateState(UASInterface* uas,QString state)
{
    // Only one UAS is connected at a time
    Q_UNUSED(uas);
    this->state = state;
}

void PrimaryFlightDisplay::updateMode(int id, QString mode, QString description)
{
    // Only one UAS is connected at a time
    Q_UNUSED(id);
    Q_UNUSED(description);
    this->mode = mode;
}

void PrimaryFlightDisplay::updateLoad(UASInterface* uas, double load)
{
    Q_UNUSED(uas);
    this->load = load;
    //updateValue(uas, "load", load, MG::TIME::getGroundTimeNow());
}

void PrimaryFlightDisplay::selectWaypoint(int uasId, int id) {
}

void PrimaryFlightDisplay::drawLinkStatsPanel (
        QPainter& painter,
        QRectF area) {
    // UAV Id
    // Droprates up, down
    QString s_linkStat("100%");
    QString s_upTime("01:23:34");

    painter.resetTransform();

    if (style == NO_OVERLAYS)
        drawInstrumentBackground(painter, area);

    painter.translate(area.center());

    QPen pen;
    pen.setWidthF(lineWidth);
    pen.setColor(amberColor);
    painter.setPen(pen);

    drawTextCenter(painter, s_linkStat, mediumTextSize, 0, -area.height()/6);
    drawTextCenter(painter, s_upTime, mediumTextSize, 0, area.height()/6);
}

void PrimaryFlightDisplay::drawMissionStatsPanel (
        QPainter& painter,
        QRectF area) {
    // Flight mode
    // next WP
    // next WP dist
    QString s_flightMode("Auto");
    QString s_nextWP("1234m\u21924");

    painter.resetTransform();

    if (style == NO_OVERLAYS)
        drawInstrumentBackground(painter, area);

    painter.translate(area.center());

    QPen pen;
    pen.setWidthF(lineWidth);
    pen.setColor(amberColor);
    painter.setPen(pen);
    drawTextCenter(painter, s_flightMode, mediumTextSize, 0, -area.height()/6);
    drawTextCenter(painter, s_nextWP, mediumTextSize, 0, area.height()/6);
}

void PrimaryFlightDisplay::drawSensorsStatsPanel (
        QPainter& painter,
        QRectF area) {
    // GPS fixmode and #sats
    // Home alt.?
    // Groundspeed?
    QString s_GPS("GPS 3D(8)");
    QString s_homealt("H.alt 472m");

    painter.resetTransform();

    if (style == NO_OVERLAYS)
        drawInstrumentBackground(painter, area);

    painter.translate(area.center());

    QPen pen;
    pen.setWidthF(lineWidth);
    pen.setColor(amberColor);
    painter.setPen(pen);

    drawTextCenter(painter, s_GPS, mediumTextSize, 0, -area.height()/6);
    drawTextCenter(painter, s_homealt, mediumTextSize, 0, area.height()/6);
}
void PrimaryFlightDisplay::drawSysStatsPanel (
        QPainter& painter,
        QRectF area) {
    // Timer
    // Battery
    // Armed/not

    /*
    energyStatus = tr("BAT [%1V | %2V%]").arg(voltage, 4, 'f', 1, QChar('0')).arg(percent, 2, 'f', 0, QChar('0'));
    if (percent < 20.0f) {
        fuelColor = warningColor;
    } else if (percent < 10.0f) {
        fuelColor = criticalColor;
    } else {
        fuelColor = infoColor;
    }
    */

    QString voltageStatus = batteryVoltage == UNKNOWN_BATTERY ? "-V" :
            tr("%1V").arg(batteryVoltage, 4, 'f', 1, QChar('0'));
    QString chargeStatus = batteryCharge == UNKNOWN_BATTERY ? "-%" :
            tr("%2%").arg(batteryCharge, 2, 'f', 0, QChar('0'));
    // We ignore current right now.

    QString batteryStatus = voltageStatus.append(" ").append(chargeStatus);

    QString s_arm = uavIsArmed ? "Armed" : "Disarmed";

    painter.resetTransform();

    if (style == NO_OVERLAYS)
        drawInstrumentBackground(painter, area);

    painter.translate(area.center());

    QPen pen;
    pen.setWidthF(lineWidth);
    pen.setColor(amberColor);
    painter.setPen(pen);

    drawTextCenter(painter, batteryStatus, mediumTextSize, 0, -area.height()/6);
    pen.setColor(redColor);
    drawTextCenter(painter, s_arm, mediumTextSize, 0, area.height()/6);
}