Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ChtEgtWorker::doWork()
- {
- //qDebug() << Q_FUNC_INFO << " on thread: " << QThread::currentThread();
- QMutexLocker locker(m_mutex);
- // This prints...
- qDebug() << "FOO1";
- const size_t COUNT = 2;
- // drefs =
- // "sim/cockpit2/engine/indicators/CHT_CYL_deg_cel",
- // "sim/cockpit2/engine/indicators/EGT_CYL_deg_cel"
- const char* drefs[COUNT] = { DATAREFS::CHT_ALL_CYLS , DATAREFS::EGT_ALL_CYLS };
- // This prints...
- qDebug() << "FOO2";
- float* chtEgtValues[COUNT];
- // For each row in the array, we need 4 * 4 = 16 bytes
- chtEgtValues[0] = (float*)(malloc(4 * sizeof(float))); // cht values
- chtEgtValues[1] = (float*)(malloc(4 * sizeof(float))); // egt values
- // This prints...
- qDebug() << "FOO3";
- // Allocated size of each element in the egtValues array
- int sizes[COUNT] = { 4, 4 };
- if (getDREFs(m_socket, drefs, chtEgtValues, COUNT, sizes) < 0)
- {
- qDebug() << "An error occurred";
- return;
- }
- // This DOES NOT print: We get an invalid pointer error (munmap_chunk(): invalid pointer)
- qDebug() << "FOO4";
- float cht1 = chtEgtValues[0][0];
- float cht1F = convertCtoF(cht1);
- float mappedCht1F = mapValueToNewRange(cht1F, 0, 500, 0, 90);
- m_engine->setChtCyl1(static_cast<int>(mappedCht1F));
- qDebug() << "cht1: " << cht1;
- qDebug() << "cht1F: " << cht1F;
- //qDebug() << "mappedCht1F: " << mappedCht1F;
- float cht2 = chtEgtValues[0][1];
- float cht2F = convertCtoF(cht2);
- float mappedCht2F = mapValueToNewRange(cht2F, 0, 500, 0, 90);
- m_engine->setChtCyl2(static_cast<int>(mappedCht2F));
- qDebug() << "cht2F: " << cht2F;
- float cht3 = chtEgtValues[0][2];
- float cht3F = convertCtoF(cht3);
- float mappedCht3F = mapValueToNewRange(cht3F, 0, 500, 0, 90);
- m_engine->setChtCyl3(static_cast<int>(mappedCht3F));
- qDebug() << "cht3F: " << cht3F;
- float cht4 = chtEgtValues[0][3];
- float cht4F = convertCtoF(cht4);
- float mappedCht4F = mapValueToNewRange(cht4F, 0, 500, 0, 90);
- m_engine->setChtCyl4(static_cast<int>(mappedCht4F));
- qDebug() << "cht4F: " << cht4F;
- float egt1 = chtEgtValues[1][0];
- float egt1F = convertCtoF(egt1);
- float mappedEgt1F = mapValueToNewRange(egt1F, 0, 1600, 0, 90);
- m_engine->setEgtCyl1(static_cast<int>(mappedEgt1F));
- qDebug() << "egt1: " << egt1;
- qDebug() << "egt1F: " << egt1F;
- //qDebug() << "mappedEgt1F: " << mappedEgt1F;
- float egt2 = chtEgtValues[1][1];
- float egt2F = convertCtoF(egt2);
- float mappedEgt2F = mapValueToNewRange(egt2F, 0, 1600, 0, 90);
- m_engine->setEgtCyl2(static_cast<int>(mappedEgt2F));
- qDebug() << "egt2F: " << egt2F;
- float egt3 = chtEgtValues[1][2];
- float egt3F = convertCtoF(egt3);
- float mappedEgt3F = mapValueToNewRange(egt3F, 0, 1600, 0, 90);
- m_engine->setEgtCyl3(static_cast<int>(mappedEgt3F));
- qDebug() << "egt3F: " << egt3F;
- float egt4 = chtEgtValues[1][3];
- float egt4F = convertCtoF(egt4);
- float mappedEgt4F = mapValueToNewRange(egt4F, 0, 1600, 0, 90);
- m_engine->setEgtCyl4(static_cast<int>(mappedEgt4F));
- qDebug() << "egt4F: " << egt4F;
- for (size_t i = 0; i < COUNT; i++)
- {
- delete [] chtEgtValues[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment