//------------------------------------------------------------------------------ // updateData() -- updates non-critical time threads //------------------------------------------------------------------------------ void AoAIndexer::updateData(const double dt) { // update our baseclass BaseClass::updateData(dt); double aoa = getInstValue(); // let's get our values //std::cout << "AOA RED MAX = " << aoaRedMax << std::endl; //std::cout << "AOA RED MIN = " << aoaRedMin << std::endl; //std::cout << "AOA YELLOW MAX = " << aoaYellowMax << std::endl; //std::cout << "AOA YELLOW MIN = " << aoaYellowMin << std::endl; //std::cout << "AOA GREEN MAX = " << aoaGreenMax << std::endl; //std::cout << "AOA GREEN MIN = " << aoaGreenMin << std::endl; // positive (red state) if (aoa >= aoaRedMin && aoa < aoaRedMax) aoaState = 1; // neutral (green state) else if (aoa >= aoaGreenMin && aoa < aoaGreenMax) aoaState = 0; // negative (yellow state) else if (aoa >= aoaYellowMin && aoa < aoaYellowMax) aoaState = -1; else aoaState = 2; int x = 1; // map these values into the right indexer value if (aoaState == 0) x = 2; else if (aoaState == 1) x = 4; else if (aoaState == -1) x = 3; // send our select down send("index", SELECT, x, selectSD); }
//------------------------------------------------------------------------------ // drawFunc() -- draws the object(s) //------------------------------------------------------------------------------ void AnalogGauge::drawFunc() { if (drawMe) { glPushMatrix(); // move us just slightly into the background, so things will overlay us gaugePos = getInstValue(); //glTranslatef(0, 0, -0.1f); // if we are vertical, draw us growing up and down, else draw us growing left to right if (vertical) { if (outline) glBegin(GL_LINE_STRIP); else glBegin(GL_POLYGON); lcVertex2(leftBoundary, 0); lcVertex2(leftBoundary, gaugePos); lcVertex2(rightBoundary, gaugePos); lcVertex2(rightBoundary, 0); glEnd(); } else { if (outline) glBegin(GL_LINE_STRIP); else glBegin(GL_POLYGON); lcVertex2(0, leftBoundary); lcVertex2(gaugePos, leftBoundary); lcVertex2(gaugePos, rightBoundary); lcVertex2(0, rightBoundary); glEnd(); } glPopMatrix(); } }
//------------------------------------------------------------------------------ // updateData() - //------------------------------------------------------------------------------ void Adi::updateData(const LCreal dt) { // update our base class first BaseClass::updateData(dt); // drive our adi toward the actual pitch, from our current pitch, no faster // than our MAX_RATE (this allows for greater fidelity, simulates an analog adi) LCreal delta = 0; delta = alim (lcAepcDeg(pitch - curTheta), maxRate * dt); curTheta = lcAepcDeg(curTheta + delta); // now do the same thing for roll delta = alim (lcAepcRad(roll - curPhi), maxRate * dt); curPhi = lcAepcRad(curPhi + delta); // get our table, and do the linear interpolation ourself setInstVal(curTheta); scaledPitch = getInstValue(); }
//------------------------------------------------------------------------------ // updateData() - update non time-critical stuff here //------------------------------------------------------------------------------ void LandingGear::updateData(const double dt) { BaseClass::updateData(dt); // this will store our last value, so we know which way we are going double lastPos = gearPos; gearPos = getInstValue(); if (gearPos == gearUV) { gearState = 0; inTransit = false; } else if (gearPos == gearDV) { gearState = 1; inTransit = false; } // if we aren't equal to either, we are in transit else { inTransit = true; // we are going towards the gear up value if (gearPos < lastPos) gearState = 0; // we are going towards the down value else if (gearPos > lastPos) gearState = 1; // if we are equal, we do nothing } // now send our select down based on our transition flag and gear pos int x = 0; if (gearState == 0 && !inTransit) x = 1; else if (gearState == 0 && inTransit) x = 2; else if (gearState == 1 && inTransit) x = 3; else if (gearState == 1 && !inTransit) x = 4; send("gearpos", SELECT, x, gearSelSD); // determine if we have a rotary base::Pair* pair = (base::Pair*)findByName("gearpos"); if (pair != nullptr) haveRotary = true; }
//------------------------------------------------------------------------------ // drawFunc() //------------------------------------------------------------------------------ void LandingLight::drawFunc() { // if the user specifies a light radius, then it will draw this way, if (lRadius == 0) return; GLfloat currentColor[4]; GLfloat lw = 0; glGetFloatv(GL_CURRENT_COLOR, ¤tColor[0]); glGetFloatv(GL_LINE_WIDTH, &lw); // all we need is the gear up value, and we can toggle accordingly LCreal gearUpVal = getGearUpValue(); LCreal gearDownVal = getGearDownValue(); LCreal lastC = gearCurrent; gearCurrent = getInstValue(); glPushMatrix(); // determine which way we are going if (lastC >= gearCurrent) { // going towards the up position (getting closer to 0) if (gearCurrent <= gearUpVal) glColor3f(0, 0, 0); else glColor3f(0, 1, 0); } else if (lastC < gearCurrent) { // going towards the down position (getting closer to 1) if (gearCurrent >= gearDownVal) glColor3f(0, 1, 0); else glColor3f(0, 0, 0); } GLUquadricObj *qobj = gluNewQuadric(); gluDisk(qobj, 0, lRadius, 1000, 1); gluDeleteQuadric(qobj); glPopMatrix(); glColor4fv(currentColor); glLineWidth(lw); }
//------------------------------------------------------------------------------ // updateData() - //------------------------------------------------------------------------------ void LandingLight::updateData(const LCreal dt) { BaseClass::updateData(dt); LCreal gearUpVal = getGearUpValue(); LCreal gearDownVal = getGearDownValue(); LCreal lastC = gearCurrent; gearCurrent = getInstValue(); int x = 0; // determine which way we are going if (lastC >= gearCurrent) { // going towards the up position (getting closer to 0) if (gearCurrent <= gearUpVal) x = 0; else x = 1; } else if (lastC < gearCurrent) { // going towards the down position (getting closer to 1) if (gearCurrent >= gearDownVal) x = 1; else x = 0; } send("index", SELECT, x, selSD); }
//------------------------------------------------------------------------------ // updateData() //------------------------------------------------------------------------------ void DialArcSegment::updateData(const double dt) { BaseClass::updateData(dt); if (isDynamic) setSweepAngle(getInstValue()); }
//------------------------------------------------------------------------------ // updateData() //------------------------------------------------------------------------------ void Tape::updateData(const LCreal dt) { // update our base class BaseClass::updateData(dt); // std::cout << "INSTRUMENT VALUE = " << getInstValue() << std::endl; LCreal x = getInstValue(); // we take our range, add another for the 0, and then add 2 more for fillers int perRange = int(range / increment) + 3; // based on that we know how many numbers we have // we are diving by 100, so we need to find the nearest 100! LCreal temp = x / increment; int nearest = nint(temp); //std::cout << "NEAREST = " << nearest << std::endl; // we know we have 11 total number vals, and we start at the low side int val = (nearest * increment) - int(perRange/2) * increment; //if (val > 100) { // if (200 - val > 100) val = val - 100; //} //std::cout << "PER RANGE = " << perRange << std::endl; // this if for the hundreds LCreal tempVal = 0; int vis = 0; for (int i = 0; i < MAX_NUMBERS; i++) { vis = 0; if (maxNum != -1 && minNum != -1) { // inside our max and min num if (val <= maxNum && val >= minNum) { vis = 1; numberValsHunds[i] = val; } // if we are ouside our max and min numbers, we do some conversion if (convert) { vis = 1; if (val > maxNum) { tempVal = val - maxNum - increment; // find out how many increments we are passed our last value numberValsHunds[i] = int(tempVal); } else if (val < minNum) { tempVal = val + maxNum + increment; numberValsHunds[i] = int(tempVal); } } } else { vis = 1; numberValsHunds[i] = val; } numberValsHundsVis[i] = vis; // no max and min, we show everything! // now determine our thousands values tempVal = ((LCreal)val / 1000); //if (tempVal < 1 && !showNegative) numberValsThousVis[i] = 0; //else numberValsThousVis[i] = 0; numberValsThousVis[i] = vis; numberValsThous[i] = int(tempVal); val += increment; } send("number%dhunds", UPDATE_VALUE, numberValsHunds, numberValsHundsSD, MAX_NUMBERS); send("number%dthous", UPDATE_VALUE, numberValsThous, numberValsThousSD, MAX_NUMBERS); send("number%dhunds", SET_VISIBILITY, numberValsHundsVis, numberValsHundsVisSD, MAX_NUMBERS); send("number%dthous", SET_VISIBILITY, numberValsThousVis, numberValsThousVisSD, MAX_NUMBERS); LCreal unitsOfHeightPerRange = height/range; LCreal newVal = (nearest * increment) - x; newVal *= unitsOfHeightPerRange; //std::cout << "NEW VALUE = " << newVal << std::endl; if (vertical) send("tapegraphic", UPDATE_VALUE2, newVal, transTapeGraphicSD); else send("tapegraphic", UPDATE_VALUE, newVal, transTapeGraphicVSD); }