Results 251 to 260 of 737
Thread: Progamming help with FSBus dll
-
01-24-2010, 07:58 AM #251
Re: Progamming help with FSBus dll
One problem I do have with the code for the MCP is that when I select the speed hold button, it holds the speed, but engine one shuts down.
I can restart it and then it stays on and it's then under the control of the autopilot.
Not sure what is triggering this in the code.
Any ideas.
Other than this, the code seems to be doing everything it should.
David
-
01-24-2010, 08:02 AM #252
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Can you post the code of the Speed Hold button?
-
01-24-2010, 08:14 AM #253
Re: Progamming help with FSBus dll
Here's the code.
There is a lot of unecessary stuff I've commented out.
Code:#include "stdafx.h" #include "modecontrolpanel.h" // static variables: accessible by all functions in this module static int ActAlt = 0; // actual altitude static int Airspeed = 0; // knots static int AirspeedHold = 0; // 0 off, -1 on static int AltitudeLock = 0; // 0 off, -1 on static int Altitude = 0; // feet static int AltitudeSave = 0; // feet static int ApproachHold = 0; // 0 off, -1 on static int APHeading = 0; // 0..359 degrees) static int AutoThrottleArm = 0; // 0 off, -1 on static int MachHold = 0; // static int MachSpeed = 0; // 0 spd, 1 mach static int MasterAP = 0; // 0 off, 1 on static int ValFlightDir = 0; // 0: ?? // 1: ?? // 2: ?? // 3: ?? // 4: ?? static int Cmda = 0; // 0 off, -1 on static int Cmdb = 0; // 0 off, -1 on static int Cwsa = 0; // 0 off, -1 on static int Cwsb = 0; // 0 off, -1 on static int CockpitATArmed = 0; // 0 off, -1 on static int Course = 0; // 0..359 degrees) static int Disengage = 0; // 0 off, -1 on static short Engine1N1 = 0; // units: percent static short Engine1N2 = 0; // units: percent static int EngN1 = 0; // 0 off, -1 on static int FSATArmed = 0; // 0 off, -1 on static int HeadingLock = 0; // 0 off, -1 on static int LvlChg = 0; // 0 off, -1 on static int Mach = 0; // 0.01 units static int Vertspeed = 0; // feet/min static int VertspeedHold = 0; // 0 off, -1 static int apalt = 0; /*-------------- Build Glareshield Objects --------------- */ void cbModecontrolpanelBuildObjects() { MkFsbusObject(BTP_DISPLAY, C_DCOURSEL, "",cbModecontrolpanel, 20, 0); MkFsbusObject(BTP_DISPLAY, C_DCOURSER, "",cbModecontrolpanel, 26, 0); MkFsbusObject(BTP_DISPLAY, C_DIAS, "",cbModecontrolpanel, 21, 0); MkFsbusObject(BTP_DISPLAY, C_DHEADING, "",cbModecontrolpanel, 22, 0); MkFsbusObject(BTP_DISPLAY, C_DALTITUDE, "",cbModecontrolpanel, 23, 0); MkFsbusObject(BTP_DISPLAY, C_DVSPEED, "",cbModecontrolpanel, 24, 0); DisplayOptions(C_DCOURSEL, 3, 0, TRUE, 0); DisplayOptions(C_DCOURSER, 3, 0, TRUE, 0); DisplayOptions(C_DIAS, 4, 0, TRUE, 0); DisplayOptions(C_DHEADING, 3, 0, TRUE, 0); DisplayOptions(C_DALTITUDE, 5, 0, TRUE, 0); DisplayOptions(C_DVSPEED, 5, 0, TRUE, 0); MkFsbusObject(BTP_ROTARY, C_RCOURSELR, "",cbModecontrolpanel, 28, 32); MkFsbusObject(BTP_ROTARY, C_RIAS, "",cbModecontrolpanel, 28, 34); MkFsbusObject(BTP_ROTARY, C_RHEADING, "",cbModecontrolpanel, 28, 36); MkFsbusObject(BTP_ROTARY, C_RALTITUDE, "",cbModecontrolpanel, 28, 0); MkFsbusObject(BTP_ROTARY, C_RVSPEED, "",cbModecontrolpanel, 28, 2); MkFsbusObject(BTP_D_IN, C_SFLIGHTDIRL, "",cbModecontrolpanel, 28, 39); MkFsbusObject(BTP_D_IN, C_SFLIGHTDIRR, "",cbModecontrolpanel, 7, 58); MkFsbusObject(BTP_D_IN, C_SAUTOTHROTTLEARM, "",cbModecontrolpanel, 28, 38); MkFsbusObject(BTP_D_IN, C_SN1, "",cbModecontrolpanel, 7, 12); MkFsbusObject(BTP_D_IN, C_SSPDHLD, "",cbModecontrolpanel, 28, 56); MkFsbusObject(BTP_D_IN, C_SSPDINTV, "",cbModecontrolpanel, 7, 46); MkFsbusObject(BTP_D_IN, C_SCHANGEOVER, "",cbModecontrolpanel, 28, 58); MkFsbusObject(BTP_D_IN, C_SVNAV, "",cbModecontrolpanel, 28, 61); MkFsbusObject(BTP_D_IN, C_SLNAV, "",cbModecontrolpanel, 28, 62); MkFsbusObject(BTP_D_IN, C_SLVLCHG, "",cbModecontrolpanel, 7, 10); MkFsbusObject(BTP_D_IN, C_SHEADINGLOCK, "",cbModecontrolpanel, 28, 57); MkFsbusObject(BTP_D_IN, C_SVORLOC, "",cbModecontrolpanel, 28, 60); MkFsbusObject(BTP_D_IN, C_SAPP, "",cbModecontrolpanel, 28, 59); MkFsbusObject(BTP_D_IN, C_SALTHLD, "",cbModecontrolpanel, 28, 4); MkFsbusObject(BTP_D_IN, C_SALTINTV, "",cbModecontrolpanel, 7, 28); MkFsbusObject(BTP_D_IN, C_SVSPEEDHLD, "",cbModecontrolpanel, 28, 5); MkFsbusObject(BTP_D_IN, C_SCMDA, "",cbModecontrolpanel, 28, 6); MkFsbusObject(BTP_D_IN, C_SCMDB, "",cbModecontrolpanel, 7, 56); MkFsbusObject(BTP_D_IN, C_SCWSA, "",cbModecontrolpanel, 7, 62); MkFsbusObject(BTP_D_IN, C_SCWSB, "",cbModecontrolpanel, 7, 57); MkFsbusObject(BTP_D_IN, C_SAPDISENGAGE, "",cbModecontrolpanel, 28, 7); MkFsbusObject(BTP_D_OUT, C_LFLIGHTDIRL, "",cbModecontrolpanel, 8, 34); MkFsbusObject(BTP_D_OUT, C_LFLIGHTDIRR, "",cbModecontrolpanel, 8, 63); MkFsbusObject(BTP_D_OUT, C_LMASTFLIGHTL, "",cbModecontrolpanel, 8, 33); MkFsbusObject(BTP_D_OUT, C_LMASTFLIGHTR, "",cbModecontrolpanel, 8, 44); MkFsbusObject(BTP_D_OUT, C_LATARMED, "",cbModecontrolpanel, 27, 11); MkFsbusObject(BTP_D_OUT, C_LN1, "",cbModecontrolpanel, 8, 35); MkFsbusObject(BTP_D_OUT, C_LAIRSPEEDHOLD, "",cbModecontrolpanel, 28, 9); MkFsbusObject(BTP_D_OUT, C_LVNAV, "",cbModecontrolpanel, 28, 11); MkFsbusObject(BTP_D_OUT, C_LLNAV, "",cbModecontrolpanel, 8, 57); MkFsbusObject(BTP_D_OUT, C_LLVLCHG, "",cbModecontrolpanel, 8, 37); MkFsbusObject(BTP_D_OUT, C_LHEADINGLOCK, "",cbModecontrolpanel, 28, 10); MkFsbusObject(BTP_D_OUT, C_LVORLOC, "",cbModecontrolpanel, 28, 12); MkFsbusObject(BTP_D_OUT, C_LAPP, "",cbModecontrolpanel, 28, 13); MkFsbusObject(BTP_D_OUT, C_LALTITUDELOCK, "",cbModecontrolpanel, 28, 8); MkFsbusObject(BTP_D_OUT, C_LVSPEEDHLD, "",cbModecontrolpanel, 28, 14); MkFsbusObject(BTP_D_OUT, C_LCMDA, "",cbModecontrolpanel, 28, 15); MkFsbusObject(BTP_D_OUT, C_LCMDB, "",cbModecontrolpanel, 8, 42); MkFsbusObject(BTP_D_OUT, C_LCWSA, "",cbModecontrolpanel, 8, 40); MkFsbusObject(BTP_D_OUT, C_LCWSB, "",cbModecontrolpanel, 9, 47); MkFsbusObject(BTP_D_OUT, C_LAPDISENGAGEL, "",cbModecontrolpanel, 9, 61); MkFsbusObject(BTP_D_OUT, C_LAPDISENGAGER, "",cbModecontrolpanel, 9, 62); MkFsObject(FS_ALTITUDE, "",cbModecontrolpanel, 0x0574, 4, TP_I32, FS_NORMAL); MkFsObject(FS_AP_MASTER, "",cbModecontrolpanel, 0x07BC, 4, TP_UI32, FS_NORMAL); // MkFsObject(FS_AP_WINGLEVELER, "",cbModecontrolpanel, 0x07C0, 4, TP_UI32, FS_NONE); MkFsObject(FS_AP_NAV1LOCK, "",cbModecontrolpanel, 0x07C4, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_HEADINGLOCK, "",cbModecontrolpanel, 0x07C8, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_HEADING, "",cbModecontrolpanel, 0x07CC, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_ALTITUDELOCK, "",cbModecontrolpanel, 0x07D0, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_ALTITUDE, "",cbModecontrolpanel, 0x07D4, 4, TP_UI32, FS_NORMAL); // MkFsObject(FS_AP_ATTITUDEHOLD, "",cbModecontrolpanel, 0x07D8, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_AIRSPEEDHOLD, "",cbModecontrolpanel, 0x07DC, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_AIRSPEED, "",cbModecontrolpanel, 0x07E2, 2, TP_UI16, FS_NORMAL); MkFsObject(FS_AP_MACHHOLD, "",cbModecontrolpanel, 0x07E4, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_MACH, "",cbModecontrolpanel, 0x07E8, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_VSHOLD, "",cbModecontrolpanel, 0x07EC, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_VS, "",cbModecontrolpanel, 0x07F2, 2, TP_I16, FS_NORMAL); // MkFsObject(FS_AP_RPMHOLD, "",cbModecontrolpanel, 0x07F4, 4, TP_UI32, FS_NORMAL); // MkFsObject(FS_AP_RPM, "",cbModecontrolpanel, 0x07FA, 2, TP_UI16, FS_NORMAL); // MkFsObject(FS_AP_GLIDESLOPEHOLD, "",cbModecontrolpanel, 0x07FC, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AP_APPROACHHOLD, "",cbModecontrolpanel, 0x0800, 4, TP_UI32, FS_NORMAL); // MkFsObject(FS_AP_BCHOLD, "",cbModecontrolpanel, 0x0804, 4, TP_UI32, FS_NORMAL); MkFsObject(FS_AUTOTHROTTLEARM, "",cbModecontrolpanel, 0x0810, 4, TP_UI32, FS_NORMAL); //MkFsObject(FS_NAV1OBS, "",cbModecontrolpanel, 0x0C4E, 2, TP_I16, FS_NONE); MkFsObject(FS_FLIGHTDIRECTOR, "",cbModecontrolpanel, 0x2EE0, 4, TP_I32, FS_NORMAL); MkFsObject(FS_ENGINE1N2, "",cbModecontrolpanel, 0x0896, 2, TP_I16, FS_NORMAL); MkFsObject(FS_ENGINE1N1, "",cbModecontrolpanel, 0x0898, 2, TP_I16, FS_NORMAL); } void cbModecontrolpanel (int oid, int val, double dval) { int x; switch (oid) { case C_RCOURSELR: Course -= val; while (Course > 360) Course -= 360; while (Course <= 0) Course += 360; FsWrite(FS_NAV1OBS, Course); FsbusWrite(C_DCOURSEL, Course); FsbusWrite(C_DCOURSER, Course); break; case C_RIAS: if (MachSpeed == 0) { Airspeed -= val; if (Airspeed < 100) Airspeed = 100; if (Airspeed > 340) Airspeed = 340; FsWrite(FS_AP_AIRSPEED, Airspeed); FsbusWrite(C_DIAS, Airspeed); } else { Mach -= val; if (Mach > 70) Mach = 70; if (Mach < 10) Mach = 10; FsWrite(FS_AP_MACH, Mach * 65536 / 100); FsbusWrite(C_DIAS, Mach); } break; case C_RHEADING: APHeading -= val; while (APHeading > 360) APHeading -= 360; while (APHeading <= 0) APHeading += 360; x = (APHeading % 360) * 65536 / 360 + 1; FsWrite(FS_AP_HEADING, x); FsbusWrite(C_DHEADING, APHeading); break; case C_RALTITUDE: apalt += val*100; if (apalt < 0) apalt = 0; if (apalt > 39000) apalt = 39000; FsbusWrite (C_DALTITUDE, apalt); FsWrite(FS_AP_ALTITUDE, apalt*19975); break; /*Altitude += val * 10000 / 100; FsbusWrite(C_DALTITUDE, Altitude); FsWrite(FS_AP_ALTITUDE, Altitude); break;*/ case C_RVSPEED: Vertspeed += val * 10000 / 100; if (Vertspeed < -7600) Vertspeed = -7600; if (Vertspeed > 6000) Vertspeed = 6000; FsbusWrite(C_DVSPEED, Vertspeed); FsWrite(FS_AP_VS, Vertspeed); break; case C_SFLIGHTDIRL: if (val == 0) { printf("DIRL0, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 1); FsbusWrite(C_LMASTFLIGHTL, 1); FsWrite(FS_FLIGHTDIRECTOR,1); } else { FsbusWrite(C_LFLIGHTDIRL, 0); FsbusWrite(C_LMASTFLIGHTL, 0); FsWrite(FS_FLIGHTDIRECTOR, 0); } break; /*case C_SFLIGHTDIRL: if (val == 0) { printf("C_SFLIGHTDIRL event, ValFlightDir=%d\n", ValFlightDir); if (ValFlightDir == 0) { // printf("DIRL0, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 1); FsbusWrite(C_LMASTFLIGHTL, 1); FsbusWrite(C_LFLIGHTDIRR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); FsWrite(FS_FLIGHTDIRECTOR,1); ValFlightDir = 1; } else if (ValFlightDir == 1) { // printf("DIRL1, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 0); FsbusWrite(C_LMASTFLIGHTL, 0); FsWrite(FS_FLIGHTDIRECTOR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); ValFlightDir = 0; } else if (ValFlightDir == 2) { // printf("DIRL2, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 1); FsbusWrite(C_LMASTFLIGHTL, 0); FsWrite(FS_FLIGHTDIRECTOR, 1); ValFlightDir = 4; } else if (ValFlightDir == 3) { // printf("DIRL3, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 0); FsbusWrite(C_LMASTFLIGHTL, 0); FsbusWrite(C_LMASTFLIGHTR, 1); FsWrite(FS_FLIGHTDIRECTOR, 1); ValFlightDir = 2; } else if (ValFlightDir == 4) { FsbusWrite(C_LFLIGHTDIRL, 0); FsbusWrite(C_LMASTFLIGHTL, 0); ValFlightDir = 2; } } break;*/ /*case C_SFLIGHTDIRR: if (val == 0) { if (ValFlightDir == 0) { FsbusWrite(C_LFLIGHTDIRR, 1); FsbusWrite(C_LMASTFLIGHTR, 1); FsWrite(FS_FLIGHTDIRECTOR, 1); ValFlightDir = 2; } else if (ValFlightDir == 1) { FsbusWrite(C_LFLIGHTDIRR, 1); FsbusWrite(C_LMASTFLIGHTR, 0); FsWrite(FS_FLIGHTDIRECTOR, 1); ValFlightDir = 3; } else if (ValFlightDir == 2) { FsbusWrite(C_LFLIGHTDIRR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); FsWrite(FS_FLIGHTDIRECTOR, 0); ValFlightDir = 0; } else if (ValFlightDir == 3) { FsbusWrite(C_LFLIGHTDIRR, 0); ValFlightDir = 1; } else if (ValFlightDir == 4) { FsbusWrite(C_LFLIGHTDIRR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); FsbusWrite(C_LMASTFLIGHTL, 1); ValFlightDir = 1; } }*/ break; case C_SAUTOTHROTTLEARM: CockpitATArmed = (val == 0) ? 1 : 0; if (bSynchronised) // pass only when in sync FsWrite(FS_AUTOTHROTTLEARM, (val == 0) ? 1 : 0); FsbusWrite(C_LATARMED, CockpitATArmed); if (CockpitATArmed == 0) { AirspeedHold = 0; MachHold = 0; } break; case C_SN1: if ((val == 0) & (CockpitATArmed == 1)) { EngN1 = (EngN1 == 0) ? 1 : 0; if (MachSpeed == 0) FsWrite(FS_AP_AIRSPEEDHOLD, EngN1); else FsWrite(FS_AP_MACHHOLD, EngN1); if (EngN1 == 1) AirspeedHold = 0; FsbusWrite(C_LN1, EngN1); FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold); FsWrite(FS_ENGINE1N1, EngN1); FsWrite(FS_ENGINE1N2, EngN1); } break; case C_SSPDHLD: if ( (val == 0) && (CockpitATArmed == 1) ) { AirspeedHold = (AirspeedHold == 0) ? 1 : 0; FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold); if (AirspeedHold == 1) { EngN1 = 0; FsbusWrite(C_LN1, EngN1); if (MachSpeed == 0) FsWrite(FS_AP_AIRSPEEDHOLD, 1); else FsWrite(FS_AP_MACHHOLD, 1); } else { FsWrite(FS_AP_AIRSPEEDHOLD, 0); FsWrite(FS_AP_MACHHOLD, 0); } FsWrite(FS_ENGINE1N1, EngN1); FsWrite(FS_ENGINE1N2, EngN1); } break; case C_SSPDINTV: break; case C_SCHANGEOVER: if (val == 0) { MachSpeed = (MachSpeed == 0) ? 1 : 0; if (MachSpeed == 1) { DisplayOptions(C_DIAS, 3, 0, TRUE, 3); FsbusWrite(C_DIAS, Mach); FsWrite(FS_AP_MACHHOLD, 1); } else { DisplayOptions(C_DIAS, 4, 0, FALSE, 0); // Fsbus bug (p5=0) FsbusWrite(C_DIAS, Airspeed); FsWrite (FS_AP_AIRSPEEDHOLD, 1); } } break; case C_SVNAV: break; case C_SLNAV: break; case C_SLVLCHG: if ((val == 0) && (abs(ActAlt - Altitude) > 200) && ((AirspeedHold == 1) || (EngN1 == 1))) { LvlChg = (LvlChg == 0) ? 1 : 0; if (LvlChg == 1) { AltitudeLock = 0; // off FsWrite(FS_AP_ALTITUDELOCK, LvlChg); // activate x = Altitude * 65536 / 100 * 3048; // in meters * 65536 AltitudeSave = Altitude; // save for AltInt FsWrite(FS_AP_ALTITUDE, x * 19975); FsWrite(FS_AP_VSHOLD, 0); FsbusWrite(C_LLVLCHG, LvlChg); // sync lvl change if (ActAlt < Altitude) // climbing { EngN1 = 0; // force N1 off //EventHandler(C_SN1, 0, 0); // toggle -> on FsWrite(FS_AP_VS, 800); // default climb speed } else // descending { AirspeedHold = 0; // force IAS off FsWrite(FS_AP_VS, -800); // default desc. speed } } else // no level change { AltitudeLock = 1; // on FsbusWrite(C_LLVLCHG, LvlChg); // lvl-swtch } FsbusWrite(C_LALTITUDELOCK, AltitudeLock); // update altitude lock } break; case C_SHEADINGLOCK: if (val == 0) // button push only { HeadingLock = (HeadingLock == 0) ? 1 : 0; // toggle FsWrite(FS_AP_HEADINGLOCK, HeadingLock); } break; case C_SVORLOC: break; case C_SAPP: if (val == 0) // button push only { ApproachHold = (ApproachHold == 0) ? 1 : 0; // toggle FsWrite(FS_AP_APPROACHHOLD, ApproachHold); } break; case C_SALTHLD: if (val == 0) { AltitudeLock = (AltitudeLock == 0) ? 1 : 0; // toggle FsWrite(FS_AP_ALTITUDELOCK, AltitudeLock); printf("C_SALTHLD AltitudeLock=%d\n", AltitudeLock); FsbusWrite(C_LALTITUDELOCK, AltitudeLock); } break; case C_SALTINTV: if (val == 0) // button push only { if (AltitudeSave != Altitude) // changed by pilot { AltitudeSave = Altitude; // save for AltInt x = Altitude * 65536 / 10000 * 3048; // in meters * 65536 } else // unchanged { AltitudeSave = ActAlt; // save for AltInt x = (ActAlt + 50) / 100 * 100; // round to 100 x = x * 65536 / 10000 * 3048; // in meters * 65536 AltitudeLock = 1; FsbusWrite(C_LALTITUDELOCK, AltitudeLock); LvlChg = 0; FsbusWrite(C_LLVLCHG, LvlChg); } FsWrite(FS_AP_ALTITUDE, x); // new AP altitude } break; case C_SVSPEEDHLD: if (val == 0) // button push only { VertspeedHold = (VertspeedHold == 0) ? 1 : 0; // toggle FsWrite(FS_AP_VSHOLD, VertspeedHold); } break; case C_SCMDA: if ((val==0) && (Disengage == 0)) // button push only { Cmda = (Cmda == 0) ? 1 : 0; // toggle if (Cmda == 0) FsbusWrite(C_LCMDA, 0); else { FsbusWrite(C_LCMDA, 1); FsbusWrite(C_LCMDB, 0); FsbusWrite(C_LCWSA, 0); FsbusWrite(C_LCWSB, 0); FsWrite(FS_AP_MASTER, 1); } } break; case C_SCMDB: if ((val==0) && (Disengage == 0)) // button push only { Cmdb = (Cmdb == 0) ? 1 : 0; // toggle if (Cmdb == 0) FsbusWrite(C_LCMDB, 0); else { FsbusWrite(C_LCMDB, 1); FsbusWrite(C_LCWSA, 0); FsbusWrite(C_LCWSB, 0); FsWrite(FS_AP_MASTER, 1); } } break; case C_SCWSA: if ((val==0) && (Disengage == 0)) // button push only { Cwsa = (Cwsa == 0) ? 1 : 0; // toggle if (Cwsa == 0) FsbusWrite(C_LCWSA, 0); else { FsbusWrite(C_LCMDA, 0); FsbusWrite(C_LCMDB, 0); FsbusWrite(C_LCWSA, 1); FsbusWrite(C_LCWSB, 0); FsWrite(FS_AP_MASTER, 1); } } break; case C_SCWSB: if ((val==0) && (Disengage == 0)) { Cwsb = (Cwsb == 0) ? 1 : 0; // toggle if (Cwsb == 0) FsbusWrite(C_LCWSB, 0); else { FsbusWrite(C_LCMDA, 0); FsbusWrite(C_LCMDB, 0); FsbusWrite(C_LCWSA, 0); FsbusWrite(C_LCWSB, 1); FsWrite(FS_AP_MASTER, 1); } } break; case C_SAPDISENGAGE: if (val==0) { Disengage = (Disengage == 0) ? 1 : 0; // toggle if (Disengage == 0) { FsbusWrite(C_LAPDISENGAGEL, 0); FsbusWrite(C_LAPDISENGAGER, 0); } else { FsbusWrite(C_LAPDISENGAGEL, 1); FsbusWrite(C_LAPDISENGAGER, 1); FsbusWrite(C_LCMDA, 0); FsbusWrite(C_LCMDB, 0); FsbusWrite(C_LCWSA, 0); FsbusWrite(C_LCWSB, 0); FsWrite(FS_AP_MASTER, 0); } } break; case FS_AP_MASTER: break; case FS_AP_WINGLEVELER: break; case FS_AP_NAV1LOCK: break; case FS_AP_HEADINGLOCK: HeadingLock = val; FsbusWrite(C_LHEADINGLOCK, val); break; case FS_AP_HEADING: APHeading = (val + 1) * 360 / 65536; // (+1 for rounding) if (APHeading == 0) APHeading = 360; FsbusWrite(C_DHEADING, APHeading); break; case FS_NAV1OBS: Course = val; if (Course == 0) Course = 360; FsbusWrite(C_DCOURSEL, Course); FsbusWrite(C_DCOURSER, Course); break; case FS_AP_ALTITUDELOCK: AltitudeLock = val; FsbusWrite(C_LALTITUDELOCK, val); break; case FS_AP_ALTITUDE: Altitude = (val / 3048 * 2500 + 8192) / 16384; // to feet FsbusWrite(C_DALTITUDE, Altitude); break; case FS_ALTITUDE: ActAlt = val * 10000 / 3048; // to feet if ((ActAlt > 25500) && (ActAlt < 26500)) { if ((MachSpeed == 0) && (ActAlt > 26000)) cbModecontrolpanel(C_SCHANGEOVER,0,0); else if ((MachSpeed == 1) && (ActAlt < 26000)) cbModecontrolpanel(C_SCHANGEOVER,0,0); } if (abs(Altitude - ActAlt) < 10) { LvlChg = 0; FsbusWrite (C_LLVLCHG , LvlChg); FsbusWrite (C_LALTITUDELOCK , 1); } break; case FS_AP_AIRSPEEDHOLD: case FS_AP_MACHHOLD: if (AirspeedHold == 1) { FsbusWrite(C_LAIRSPEEDHOLD, 1); FsbusWrite(C_LN1, 0); } else if (EngN1 == 1) { FsbusWrite(C_LAIRSPEEDHOLD, 0); FsbusWrite(C_LN1, 1); } else { FsbusWrite(C_LAIRSPEEDHOLD, 0); FsbusWrite(C_LN1, 0); } break; case FS_AP_AIRSPEED: Airspeed = val; if (MachSpeed == 0) // display in IAS mode FsbusWrite(C_DIAS, Airspeed); // new speed break; case FS_AP_MACH: Mach = (val * 100 + 50) / 65536 ; if (MachSpeed == 1) FsbusWrite(C_DIAS, Mach); break; case FS_AP_VSHOLD: VertspeedHold = val; FsbusWrite(C_LVSPEEDHLD, VertspeedHold); break; case FS_AP_VS: Vertspeed = val; FsbusWrite(C_DVSPEED, Vertspeed); break; case FS_AP_RPMHOLD: break; case FS_AP_RPM: break; case FS_AP_GLIDESLOPEHOLD: break; case FS_AP_APPROACHHOLD: ApproachHold = val; FsbusWrite(C_LAPP, ApproachHold); break; case FS_AP_BCHOLD: break; case FS_AUTOTHROTTLEARM: break; case FS_FLIGHTDIRECTOR: if (bSynchronised == false) { if (val == 1) { // printf("DIRLFsAP, val=%d\n", val); FsbusWrite(C_LFLIGHTDIRL, 1); FsbusWrite(C_LMASTFLIGHTL, 1); FsbusWrite(C_LFLIGHTDIRR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); // FsWrite(FS_FLIGHTDIRECTOR,1); ValFlightDir = 1; } else { FsbusWrite(C_LFLIGHTDIRL, 0); FsbusWrite(C_LMASTFLIGHTL, 0); FsbusWrite(C_LFLIGHTDIRR, 0); FsbusWrite(C_LMASTFLIGHTR, 0); // FsWrite(FS_FLIGHTDIRECTOR,0); ValFlightDir = 0; } } break; case FS_ENGINE1N1: Engine1N1 = val * 100 / 16384; break; case FS_ENGINE1N2: Engine1N2 = val * 100 / 16384; break; } }
-
01-24-2010, 12:21 PM #254
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Hi,
that was the complet file.
I dont see any function they shutoff an engine.
That is a strange fault.
Did your code make a logfile??
Stefan
-
01-24-2010, 06:24 PM #255
Re: Progamming help with FSBus dll
Hi Stefan,
I'm not sure if it has made a log file. Where would I find it, and do I have to set it up to make a log file or does it do it automatically anyway.
-
01-24-2010, 06:32 PM #256
Re: Progamming help with FSBus dll
Stefan,
Could it have anything to do with this bit of the code. There is no reference to engine 2 ie:
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
Do I need to duplicate this for FS_ENGINE2N1 and FS_ENGINE2N2
Will that make any difference?
case C_SSPDHLD:
if ( (val == 0) && (CockpitATArmed == 1) )
{
AirspeedHold = (AirspeedHold == 0) ? 1 : 0;
FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold);
if (AirspeedHold == 1)
{
EngN1 = 0;
FsbusWrite(C_LN1, EngN1);
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, 1);
else
FsWrite(FS_AP_MACHHOLD, 1);
}
else
{
FsWrite(FS_AP_AIRSPEEDHOLD, 0);
FsWrite(FS_AP_MACHHOLD, 0);
}
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
}
-
01-24-2010, 06:42 PM #257
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Hello,
i donīt understand first that 2 rows.
First in the defination of this variable, it is a 0-1 "switch".
Also written nowhere in the code of other value that is a 0 or 1, with the varible.
Second, the FS_ENGINE1N1 (0x089 and FS_ENGINE1N2 (0x0896) are usually read only values.
If you write that FSUIPC offsets (in the doc the Offset is read only) dan FSUIPC reacts , than you switch off the ENG1.
Look both offsets ENG1 the N1 and N2.
Stefan
-
01-24-2010, 06:53 PM #258
Re: Progamming help with FSBus dll
Stefan,
The post was in German but the email I received to tell me about the post was in English (strange).
Should I try the code with these two lines deleted:
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
-
01-24-2010, 06:59 PM #259
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Fixed the language, sorry.
try to delet them.
-
01-24-2010, 09:53 PM #260
Re: Progamming help with FSBus dll
Deleted them and now the engine doesn't stop.
All appears to be working as it should so far.
I have to put it through it's paces with approaches etc. ILS landings etc.
Thanks again Stefan, I'll let you know how it's all going.
David
Similar Threads
-
Fsbus CDK
By flyandre in forum General Builder Questions All Aircraft TypesReplies: 4Last Post: 12-27-2014, 12:58 PM -
Need Help Getting My FSBUS NG I/O Going Again..
By JBRoberts in forum I/O Interfacing Hardware and SoftwareReplies: 14Last Post: 03-21-2010, 01:38 PM -
Fsbus ng io
By Davral in forum I/O Interfacing Hardware and SoftwareReplies: 0Last Post: 01-10-2009, 10:38 PM -
Fsbus 2.4.3
By Anderson/SBSP in forum I/O Interfacing Hardware and SoftwareReplies: 9Last Post: 11-30-2008, 04:25 PM -
Help FSBUS
By cesarfsim in forum I/O Interfacing Hardware and SoftwareReplies: 2Last Post: 10-26-2008, 02:23 PM
Search Pretty Girls from your town for night
JeeHell FMGS on a remote Computer