Board index FlightGear Support Interfacing

Web Panel on 2016.4.3

Connecting two computers, using generic protocol, connecting with Matlab?

Web Panel on 2016.4.3

Postby peterbr0wn » Tue Dec 13, 2016 8:34 pm

I have a web panel for the grob g115 (tutor) that I have made interactive by overlaying clickable buttons over parts of the panel.

This was working perfectly in 2016.3.1, but doesn't seem to respond correctly to button presses in 2016.4.3.
For example, clicking on the main battery switch will change the expected property in flightgear, but the switch will not refresh to the thrown position until the page is manually reloaded.

I'm noticing similar refresh problems with the radio stack buttons in phi - one click swaps the frequencies, but a second click doesn't refresh and subsequent clicks are ignored until a manual reload of the page, so I don't think its necessarily a problem with my code.

I realise this might not be the most used functionality in flightgear, but I use it to provide a separate control panel on a touchscreen monitor, so was hoping someone might have some ideas?
peterbr0wn
 
Posts: 2
Joined: Tue Dec 13, 2016 8:07 pm
Version: 2016.3.1
OS: linux, osx

Re: Web Panel on 2016.4.3

Postby Alant » Wed Dec 14, 2016 10:20 pm

I suggest you send a pm to Torsten, the author of phi. He may not be aware of this problem.

Could I look at your interactive panel as I wish to make one for my own project, and am having problems understanding how to make it interactive.

Alan
Alant
 
Posts: 1037
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10

Re: Web Panel on 2016.4.3

Postby peterbr0wn » Thu Dec 15, 2016 8:07 am

Yeah, I'll give that a try.

The code I've used is below.

panel.html (with css bits removed as it isn't interesting).
Code: Select all
<script type="text/javascript" charset="utf-8" src="/3rdparty/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/lib/jquery.fganimate.js"></script>
<script type="text/javascript" charset="utf-8" src="/lib/fgfs.js"></script>
<script type="text/javascript" charset="utf-8" src="/lib/fgcommand.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="/lib/props.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="controls.js" type="text/javascript"></script>
</head>
<body data-fgpanel="true" data-fgpanel-props="Panel1-properties.json">
  <div class="HeaderPanel">
    <div id="Warnings" class="instrument" data-fgpanel-instrument="Warnings.json"></div>
  </div>
  <div class="PanelContainer">
    <div class="MainPanel">
      <div id="Engine6" class="instrument" data-fgpanel-instrument="MPF.json"></div>
      <div id="Engine7" class="instrument" data-fgpanel-instrument="RPM.json"></div>
      <div id="Flight1" class="instrument" data-fgpanel-instrument="ASI.json"></div>
      <div id="Flight2" class="instrument" data-fgpanel-instrument="AI.json"></div>
      <div id="Flight3" class="instrument" data-fgpanel-instrument="ALT.json">
        <input type="button" class="controlButton" id="AltSetDown" name="AltSetDown" value="-"/>
        <input type="button" class="controlButton" id="AltSetUp" name="AltSetUp" value="+"/>
      </div> 
      <div id="Flight4" class="instrument" data-fgpanel-instrument="TC.json"></div>
      <div id="Flight5" class="instrument" data-fgpanel-instrument="KI525A.json">
        <input type="button" class="controlButton" id="CourseDown" name="CourseDown" value="-"/>
        <input type="button" class="controlButton" id="CourseUp" name="CourseUp" value="+"/>
        <input type="button" class="controlButton" id="BugDown" name="BugDown" value="-"/>
        <input type="button" class="controlButton" id="BugUp" name="BugUp" value="+"/>
      </div> 
      <div id="Flight6" class="instrument" data-fgpanel-instrument="VSI.json"></div>
      <div id="Flight7" class="instrument" data-fgpanel-instrument="KI204.json">
        <input type="button" class="controlButton" id="KI204SelectDown" name="KI204SelectDown" value="-"/>
        <input type="button" class="controlButton" id="KI204SelectUp" name="KI204SelectUp" value="+"/>
      </div> 
      <div id="GPS" class="instrument" data-fgpanel-instrument="GPS.json"></div>
    </div>
    <div class="RightPanel">
      <div id="KMA26" class="radioShort instrument" data-fgpanel-instrument="KMA26.json">
        <input type="button" class="controlButton" id="KMA26Com1Select" name="KMA26Com1Select" value="S"/>
        <input type="button" class="controlButton" id="KMA26Com2Select" name="KMA26Com2Select" value="S"/>
        <input type="button" class="controlButton" id="KMA26Nav1Select" name="KMA26Nav1Select" value="S"/>
        <input type="button" class="controlButton" id="KMA26Nav2Select" name="KMA26Nav2Select" value="S"/>
        <input type="button" class="controlButton" id="KMA26SelectDown" name="KMA26SelectDown" value="S"/>
        <input type="button" class="controlButton" id="KMA26SelectUp" name="KMA26SelectUp" value="S"/>
      </div>
      <div id="KX155" class="radio instrument" data-fgpanel-instrument="KX155.json">
        <input type="button" class="controlButton" id="KX155ComVolDown" name="KX155ComVolDown" value="-"/>
        <input type="button" class="controlButton" id="KX155ComVolUp" name="KX155ComVolUp" value="+"/>
        <input type="button" class="controlButton" id="KX155ComSwap" name="KX155ComSwap" value="S"/>
        <input type="button" class="controlButton" id="KX155ComSelectDown" name="KX155ComSelectDown" value="-"/>
        <input type="button" class="controlButton" id="KX155ComSelectUp" name="KX155ComSelectUp" value="+"/>
        <input type="button" class="controlButton" id="KX155ComSelectDecDown" name="KX155ComSelectDecDown" value="-"/>
        <input type="button" class="controlButton" id="KX155ComSelectDecUp" name="KX155ComSelectDecUp" value="+"/>
        <input type="button" class="controlButton" id="KX155NavVolDown" name="KX155NavVolDown" value="-"/>
        <input type="button" class="controlButton" id="KX155NavVolUp" name="KX155NavVolUp" value="+"/>
        <input type="button" class="controlButton" id="KX155NavSwap" name="KX155NavSwap" value="S"/>
        <input type="button" class="controlButton" id="KX155NavSelectDown" name="KX155NavSelectDown" value="-"/>
        <input type="button" class="controlButton" id="KX155NavSelectUp" name="KX155NavSelectUp" value="+"/>
        <input type="button" class="controlButton" id="KX155NavSelectDecDown" name="KX155NavSelectDecDown" value="-"/>
        <input type="button" class="controlButton" id="KX155NavSelectDecUp" name="KX155NavSelectDecUp" value="+"/>
      </div>
      <div id="KN53" class="radioShort instrument" data-fgpanel-instrument="KN53.json">
        <input type="button" class="controlButton" id="KN53VolDown" name="KN53VolDown" value="-"/>
        <input type="button" class="controlButton" id="KN53VolUp" name="KN53VolUp" value="+"/>
        <input type="button" class="controlButton" id="KN53Swap" name="KN53Swap" value="S"/>
        <input type="button" class="controlButton" id="KN53SelectDown" name="KN53SelectDown" value="-"/>
        <input type="button" class="controlButton" id="KN53SelectUp" name="KN53SelectUp" value="+"/>
        <input type="button" class="controlButton" id="KN53SelectDecDown" name="KN53SelectDecDown" value="-"/>
        <input type="button" class="controlButton" id="KN53SelectDecUp" name="KN53SelectDecUp" value="+"/>
      </div>
      <div id="KT70" class="radioShort instrument" data-fgpanel-instrument="KT70.json">
        <input type="button" class="controlButton" id="KT70D1Up" name="KT70D1Up" value="-"/>
        <input type="button" class="controlButton" id="KT70D1Down" name="KT70D1Down" value="+"/>
        <input type="button" class="controlButton" id="KT70D2Up" name="KT70D2Up" value="-"/>
        <input type="button" class="controlButton" id="KT70D2Down" name="KT70D2Down" value="+"/>
        <input type="button" class="controlButton" id="KT70D3Up" name="KT70D3Up" value="-"/>
        <input type="button" class="controlButton" id="KT70D3Down" name="KT70D3Down" value="+"/>
        <input type="button" class="controlButton" id="KT70D4Up" name="KT70D4Up" value="-"/>
        <input type="button" class="controlButton" id="KT70D4Down" name="KT70D4Down" value="+"/>
        <input type="button" class="controlButton" id="KT70SelectUp" name="KT70SelectUp" value="-"/>
        <input type="button" class="controlButton" id="KT70SelectDown" name="KT70SelectDown" value="+"/>
        <input type="button" class="controlButton" id="KT70Vfr" name="KT70Vfr" value="+"/>
        <input type="button" class="controlButton" id="KT70Idt" name="KT70Idt" value="+"/>
      </div>
    </div>
  </div>
  <div class="LowerPanelContainer">
    <div class="LowerLeftPanel">
      <div id="Engine2" class="instrument" data-fgpanel-instrument="Oil.json"></div>
      <div id="Engine3" class="instrument" data-fgpanel-instrument="FP-CHT.json"></div>
      <div id="Engine4" class="instrument" data-fgpanel-instrument="Battery.json"></div>
      <div id="Engine5" class="instrument" data-fgpanel-instrument="Fuel.json"></div>
    </div>
    <div class="LowerMiddlePanel">
      <div id="Engine1" class="small instrument" data-fgpanel-instrument="EGT_OAT.json"></div>
      <div id="EngLabels" class="instrument" data-fgpanel-instrument="EngineLabels.json"></div>
      <div id="KDI572" class="small instrument" data-fgpanel-instrument="KDI572.json">
        <input type="button" class="controlButton" id="KDI572SelectDown" name="KDI572SelectDown" value="-"/>
        <input type="button" class="controlButton" id="KDI572SelectUp" name="KDI572SelectUp" value="+"/>
      </div>
      <div id="Misc1" class="small instrument" data-fgpanel-instrument="GMeter.json">
        <input type="button" class="controlButton" id="GReset" name="GReset" value="R"/>
      </div> 
      <div id="SwitchPanel" class="instrument" data-fgpanel-instrument="SwitchPanel.json">
        <input type="button" class="controlButton" id="InstrLightsOn" name="InstrLightsOn" value="R"/>
        <input type="button" class="controlButton" id="InstrLightsOff" name="InstrLightsOff" value="R"/>
        <input type="button" class="controlButton" id="StrobeWhite" name="StrobeWhite" value="R"/>
        <input type="button" class="controlButton" id="StrobeRed" name="StrobeRed" value="R"/>
        <input type="button" class="controlButton" id="StrobeOff" name="StrobeOff" value="R"/>
        <input type="button" class="controlButton" id="NavLightsOn" name="NavLightsOn" value="R"/>
        <input type="button" class="controlButton" id="NavLightsOff" name="NavLightsOff" value="R"/>
        <input type="button" class="controlButton" id="LdgLightsOn" name="LdgLightOn" value="R"/>
        <input type="button" class="controlButton" id="LdgLightsOff" name="LdgLightOff" value="R"/>
        <input type="button" class="controlButton" id="PitotHtOn" name="PitotHtOn" value="R"/>
        <input type="button" class="controlButton" id="PitotHtOff" name="PitotHtOff" value="R"/>
        <input type="button" class="controlButton" id="AvMasterOn" name="AvMasterOn" value="R"/>
        <input type="button" class="controlButton" id="AvMasterOff" name="AvMasterOff" value="R"/>
        <input type="button" class="controlButton" id="MagnetoUp" name="MagnetoUp" value="R"/>
        <input type="button" class="controlButton" id="MagnetoDown" name="MagnetoDown" value="R"/>
        <input type="button" class="controlButton" id="Start" name="Start" value="R"/>
        <input type="button" class="controlButton" id="FuelPumpOn" name="FuelPumpOn" value="R"/>
        <input type="button" class="controlButton" id="FuelPumpOff" name="FuelPumpOff" value="R"/>
        <input type="button" class="controlButton" id="GenOn" name="GenOn" value="R"/>
        <input type="button" class="controlButton" id="GenOff" name="GenOff" value="R"/>
        <input type="button" class="controlButton" id="GenReset" name="GenReset" value="R"/>
        <input type="button" class="controlButton" id="BatOn" name="BatOn" value="R"/>
        <input type="button" class="controlButton" id="BatOff" name="BatOff" value="R"/>
      </div>
    </div>
    <div class="LowerRightPanel">
      <div id="ELT" class="smallHalf instrument" data-fgpanel-instrument="ELT.json">
        <input type="button" class="controlButton" id="ELTOn" name="ELTOn" value="-"/>
        <input type="button" class="controlButton" id="ELTArm" name="ELTArm" value="+"/>
      </div>
      <div id="UHF" class="small instrument" data-fgpanel-instrument="KTR909_UHF.json">
        <input type="button" class="controlButton" id="UHFVolDown" name="UHFVolDown" value="-"/>
        <input type="button" class="controlButton" id="UHFVolUp" name="UHFVolUp" value="+"/>
        <input type="button" class="controlButton" id="UHFSelectDown" name="UHFSelectDown" value="-"/>
        <input type="button" class="controlButton" id="UHFSelectUp" name="UHFSelectUp" value="+"/>
        <input type="button" class="controlButton" id="UHFSelectDecDown" name="UHFSelectDecDown" value="-"/>
        <input type="button" class="controlButton" id="UHFSelectDecUp" name="UHFSelectDecUp" value="+"/>
      </div>
      <div id="KA51" class="smallHalf instrument" data-fgpanel-instrument="KA51.json">
        <input type="button" class="controlButton" id="KA51Manual" name="KA51Manual" value="R"/>
        <input type="button" class="controlButton" id="KA51Auto" name="KA51Auto" value="R"/>
        <input type="button" class="controlButton" id="KA51cw" name="KA51cw" value="R"/>
        <input type="button" class="controlButton" id="KA51ccw" name="KA51ccw" value="R"/>
      </div>
      <div id="Brake" class="instrument" data-fgpanel-instrument="Brakes.json">
        <input type="button" class="controlButton" id="BrakeOn" name="BrakeOn" value="+"/>
        <input type="button" class="controlButton" id="BrakeOff" name="BrakeOff" value="-"/>
      </div>
      <div id="Flaps" class="medium instrument" data-fgpanel-instrument="Flaps.json">
        <input type="button" class="controlButton" id="FlapUp" name="FlapUp" value="-"/>
        <input type="button" class="controlButton" id="FlapTakeOff" name="FlapTakeOff" value="+"/>
        <input type="button" class="controlButton" id="FlapLand" name="FlapLand" value="-"/>
        <input type="button" class="controlButton" id="FlapFull" name="FlapFull" value="+"/>
      </div>
      <div id="Trim" class="instrument" data-fgpanel-instrument="Trim.json">
        <input type="button" class="controlButton" id="TrimDown" name="TrimDown" value="-"/>
        <input type="button" class="controlButton" id="TrimUp" name="TrimUp" value="+"/>
      </div>
      <div id="AltStatic" class="instrument" data-fgpanel-instrument="AltStatic.json">
        <input type="button" class="controlButton" id="AltStatAlt" name="AltStatAlt" value="-"/>
        <input type="button" class="controlButton" id="AltStatNorm" name="AltStatNorm" value="+"/>
      </div>
    </div>
  </div>
</body>
</html>

controls.js (basically a rip off/extension of the phi radio):
Code: Select all
$(document).ready(
    function() {

      var rp = new Array();
      rp["#altSet"] = "/instrumentation/altimeter/setting-hpa";
      rp["#ki204Select"] = "/instrumentation/nav[1]/radials/selected-deg";
      rp["#pilotG"] = "/accelerations/pilot-g";
      rp["#pilotGMin"] = "/accelerations/pilot-gmin";
      rp["#pilotGMax"] = "/accelerations/pilot-gmax";
      rp["#courseSet"] = "/instrumentation/kcs55/ki525/selected-course-deg";
      rp["#bugSet"] = "/instrumentation/kcs55/ki525/selected-heading-deg";
      rp["#com1u"] = "/instrumentation/comm/frequencies/selected-mhz";
      rp["#com1s"] = "/instrumentation/comm/frequencies/standby-mhz";
      rp["#nav1u"] = "/instrumentation/nav/frequencies/selected-mhz";
      rp["#nav1s"] = "/instrumentation/nav/frequencies/standby-mhz";
      rp["#com2u"] = "/instrumentation/comm[1]/frequencies/selected-mhz";
      rp["#com2s"] = "/instrumentation/comm[1]/frequencies/standby-mhz";
      rp["#nav2u"] = "/instrumentation/nav[1]/frequencies/selected-mhz";
      rp["#nav2s"] = "/instrumentation/nav[1]/frequencies/standby-mhz";
      rp["#adf1u"] = "/instrumentation/adf/frequencies/selected-khz";
      rp["#adf1s"] = "/instrumentation/adf/frequencies/standby-khz";
      rp["#dme1u"] = "/instrumentation/dme/frequencies/selected-mhz";
      rp["#InstrLightsSwitch"] = "/controls/switches/instr-lights";
      rp["#StrobeSwitch"] = "/controls/switches/strobes";
      rp["#NavLightsSwitch"] = "/controls/switches/nav-lights";
      rp["#LdgLightSwitch"] = "/controls/switches/landing-light";
      rp["#PitotHeatSwitch"] = "/controls/switches/pitot-heat";
      rp["#AvionicMasterSwitch"] = "/controls/switches/avionic-master";
      rp["#MagnetoSwitch"] = "/controls/engines/engine/magnetos";
      rp["#FuelPumpSwitch"] = "/controls/engines/engine/fuel-pump";
      rp["#GenSwitch"] = "/controls/switches/generator";
      rp["#StartSwitch"] = "/controls/engines/engine/starter";
      rp["#BatSwitch"] = "/controls/electric/battery-switch";
      rp["#Brakes"] = "/controls/gear/brake-parking";
      rp["#ElevatorTrim"] = "/controls/flight/elevator-trim";
      rp["#Flaps"] = "/controls/flight/flaps";
      rp["#Elt"] = "/controls/switches/elt";
      rp["#AltStatic"] = "/controls/switches/alt-static";
      rp["#kma26Com1Sel"] = "/instrumentation/kma26/com1sel";
      rp["#kma26Com2Sel"] = "/instrumentation/kma26/com2sel";
      rp["#kma26Com3Sel"] = "/instrumentation/kma26/com3sel";
      rp["#kma26Nav1Sel"] = "/instrumentation/kma26/nav1sel";
      rp["#kma26Nav2Sel"] = "/instrumentation/kma26/nav2sel";
      rp["#kma26Sel"] = "/instrumentation/kma26/primaryradio";
      rp["#kn53NavVol"] = "/instrumentation/kn53/navvol-norm";
      rp["#nav1Volume"] = "/instrumentation/nav/volume";
      rp["#dmeSelector"] = "/instrumentation/dme/switch-position";
      rp["#kx155NavVol"] = "/instrumentation/kx155a/navvol-norm";
      rp["#kx155ComVol"] = "/instrumentation/kx155a/commvol-norm";
      rp["#com2Volume"] = "/instrumentation/comm[1]/volume";
      rp["#kt70D1"] = "/instrumentation/transponder/inputs/digit";
      rp["#kt70D2"] = "/instrumentation/transponder/inputs/digit[1]";
      rp["#kt70D3"] = "/instrumentation/transponder/inputs/digit[2]";
      rp["#kt70D4"] = "/instrumentation/transponder/inputs/digit[3]";
      rp["#kt70Select"] = "/instrumentation/transponder/inputs/knob-mode";
      rp["#kt70Idt"] = "/instrumentation/transponder/inputs/ident-btn";

      var vp = new Array();
      vp["#Elt"] = 0;
      vp["#ki204Select"] = 0;
      vp["#courseSet"] = 0;
      vp["#bugSet"] = 0;
      vp["#MagnetoSwitch"] = 0;
      vp["#Brakes"] = 0;
      vp["#ElevatorTrim"] = 0;
      vp["#kma26Com1Sel"] = 0;
      vp["#kma26Com2Sel"] = 0;
      vp["#kma26Nav1Sel"] = 0;
      vp["#kma26Nav2Sel"] = 0;
      vp["#kma26Sel"] = 0;
      vp["#kn53NavVol"] = 0;
      vp["#nav1s"] = 0;
      vp["#dmeSelector"] = 0;
      vp["#kx155NavVol"] = 0;
      vp["#kx155ComVol"] = 0;
      vp["#kt70D1"] = 0;
      vp["#kt70D2"] = 0;
      vp["#kt70D3"] = 0;
      vp["#kt70D4"] = 0;
      vp["#kt70Select"] = 0;

      $("#KT70Idt").mousedown(function() {
        fgCommand.propertyAssign(rp["#kt70Idt"], 1);
      });
      $("#KT70Idt").mouseup(function() {
        fgCommand.propertyAssign(rp["#kt70Idt"], 0);
      });
      $("#KT70Vfr").click(function() {
          fgCommand.propertyAssign(rp["#kt70D1"], 0);         
          fgCommand.propertyAssign(rp["#kt70D2"], 0);         
          fgCommand.propertyAssign(rp["#kt70D3"], 2);         
          fgCommand.propertyAssign(rp["#kt70D4"], 1);         
      });
      $("#KT70SelectUp").click(function() {
        if (vp["#kt70Select"] < 5) {
            fgCommand.propertyAssign(rp["#kt70Select"], vp["#kt70Select"] + 1);
        }
      });
      $("#KT70SelectDown").click(function() {
        if (vp["#kt70Select"] > 0) {
            fgCommand.propertyAssign(rp["#kt70Select"], vp["#kt70Select"] - 1);
        }
      });

      $("#KT70D1Up").click(function() {
        if (vp["#kt70D1"] < 7) {
            fgCommand.propertyAssign(rp["#kt70D1"], vp["#kt70D1"] + 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D1"], 0);         
        }
      });
      $("#KT70D1Down").click(function() {
        if (vp["#kt70D1"] > 0) {
            fgCommand.propertyAssign(rp["#kt70D1"], vp["#kt70D1"] - 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D1"], 7);         
        }
      });
      $("#KT70D2Up").click(function() {
        if (vp["#kt70D2"] < 7) {
            fgCommand.propertyAssign(rp["#kt70D2"], vp["#kt70D2"] + 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D2"], 0);         
        }
      });
      $("#KT70D2Down").click(function() {
        if (vp["#kt70D2"] > 0) {
            fgCommand.propertyAssign(rp["#kt70D2"], vp["#kt70D2"] - 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D2"], 7);         
        }
      });
      $("#KT70D3Up").click(function() {
        if (vp["#kt70D3"] < 7) {
            fgCommand.propertyAssign(rp["#kt70D3"], vp["#kt70D3"] + 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D3"], 0);         
        }
      });
      $("#KT70D3Down").click(function() {
        if (vp["#kt70D3"] > 0) {
            fgCommand.propertyAssign(rp["#kt70D3"], vp["#kt70D3"] - 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D3"], 7);         
        }
      });
      $("#KT70D4Up").click(function() {
        if (vp["#kt70D4"] < 7) {
            fgCommand.propertyAssign(rp["#kt70D4"], vp["#kt70D4"] + 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D4"], 0);         
        }
      });
      $("#KT70D4Down").click(function() {
        if (vp["#kt70D4"] > 0) {
            fgCommand.propertyAssign(rp["#kt70D4"], vp["#kt70D4"] - 1);
        }
        else {
            fgCommand.propertyAssign(rp["#kt70D4"], 7);         
        }
      });

      $("#KX155ComSelectDecUp").click(function() {
        var val = vp["#com2s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart < 0.95) {
            result = vp["#com2s"] + 0.05;
        }
        else {
            result = intPart;         
        }
        fgCommand.propertyAssign(rp["#com2s"], result.toFixed(2));
      });
      $("#KX155ComSelectDecDown").click(function() {
        var val = vp["#com2s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart > 0.00) {
            result = vp["#com2s"] - 0.05;
         }
         else {
            result = vp["#com2s"] + 0.95;         
         }
        fgCommand.propertyAssign(rp["#com2s"], result.toFixed(2));
      });
      $("#KX155ComSelectUp").click(function() {
        var val = vp["#com2s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart < 136) {
            result = vp["#com2s"] + 1;
         }
         else {
            result = 118.0 + (val - intPart);         
         }
        fgCommand.propertyAssign(rp["#com2s"], result.toFixed(2));
      });
      $("#KX155ComSelectDown").click(function() {
        var val = vp["#com2s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart > 118) {
            result = vp["#com2s"] - 1;
         }
         else {
            result = 136.0 + (val - intPart);
         }
        fgCommand.propertyAssign(rp["#com2s"], result.toFixed(2));
      });
      $("#KX155ComSwap").click(function() {
        fgCommand.propertySwap(rp["#com2u"], rp["#com2s"]);
      });
      $("#KX155ComVolUp").click(function() {
        if (vp["#kx155ComVol"] < 1) {
            fgCommand.propertyAssign(rp["#kx155ComVol"], vp["#kx155ComVol"] + 0.1);
        }
      });
      $("#KX155ComVolDown").click(function() {
        if (vp["#kx155ComVol"] > 0) {
            fgCommand.propertyAssign(rp["#kx155ComVol"], vp["#kx155ComVol"] - 0.1);
         }
      });
      $("#KX155NavSelectDecUp").click(function() {
        var val = vp["#nav2s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart < 0.95) {
            result = vp["#nav2s"] + 0.05;
        }
        else {
            result = intPart;         
        }
        fgCommand.propertyAssign(rp["#nav2s"], result.toFixed(2));
      });
      $("#KX155NavSelectDecDown").click(function() {
        var val = vp["#nav2s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart > 0.00) {
            result = vp["#nav2s"] - 0.05;
         }
         else {
            result = vp["#nav2s"] + 0.95;         
         }
        fgCommand.propertyAssign(rp["#nav2s"], result.toFixed(2));
      });
      $("#KX155NavSelectUp").click(function() {
        var val = vp["#nav2s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart < 117) {
            result = vp["#nav2s"] + 1;
         }
         else {
            result = 108.0 + (val - intPart);         
         }
        fgCommand.propertyAssign(rp["#nav2s"], result.toFixed(2));
      });
      $("#KX155NavSelectDown").click(function() {
        var val = vp["#nav2s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart > 108) {
            result = vp["#nav2s"] - 1;
         }
         else {
            result = 117.0 + (val - intPart);
         }
        fgCommand.propertyAssign(rp["#nav2s"], result.toFixed(2));
      });
      $("#KX155NavSwap").click(function() {
        fgCommand.propertySwap(rp["#nav2u"], rp["#nav2s"]);
      });
      $("#KX155NavVolUp").click(function() {
        if (vp["#kx155NavVol"] < 1) {
            fgCommand.propertyAssign(rp["#kx155NavVol"], vp["#kx155NavVol"] + 0.1);
        }
      });
      $("#KX155NavVolDown").click(function() {
        if (vp["#kx155NavVol"] > 0) {
            fgCommand.propertyAssign(rp["#kx155NavVol"], vp["#kx155NavVol"] - 0.1);
         }
      });
      $("#KDI572SelectUp").click(function() {
        if (vp["#dmeSelector"] < 3) {
            fgCommand.propertyAssign(rp["#dmeSelector"], vp["#dmeSelector"] + 1);
        }
      });
      $("#KDI572SelectDown").click(function() {
        if (vp["#dmeSelector"] > 0) {
            fgCommand.propertyAssign(rp["#dmeSelector"], vp["#dmeSelector"] - 1);
        }
      });
      $("#KN53SelectDecUp").click(function() {
        var val = vp["#nav1s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart < 0.95) {
            result = vp["#nav1s"] + 0.05;
        }
        else {
            result = intPart;         
        }
        fgCommand.propertyAssign(rp["#nav1s"], result.toFixed(2));
      });
      $("#KN53SelectDecDown").click(function() {
        var val = vp["#nav1s"];
        var intPart = Math.floor(val);
        var decPart = val - intPart;
        var result;

        if (decPart > 0.00) {
            result = vp["#nav1s"] - 0.05;
         }
         else {
            result = vp["#nav1s"] + 0.95;         
         }
        fgCommand.propertyAssign(rp["#nav1s"], result.toFixed(2));
      });
      $("#KN53SelectUp").click(function() {
        var val = vp["#nav1s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart < 117) {
            result = vp["#nav1s"] + 1;
         }
         else {
            result = 108.0 + (val - intPart);         
         }
        fgCommand.propertyAssign(rp["#nav1s"], result.toFixed(2));
      });
      $("#KN53SelectDown").click(function() {
        var val = vp["#nav1s"];
        var intPart = Math.floor(val);
        var result;

        if (intPart > 108) {
            result = vp["#nav1s"] - 1;
         }
         else {
            result = 117.0 + (val - intPart);
         }
        fgCommand.propertyAssign(rp["#nav1s"], result.toFixed(2));
      });
      $("#KN53Swap").click(function() {
        fgCommand.propertySwap(rp["#nav1u"], rp["#nav1s"]);
      });
      $("#KN53VolUp").click(function() {
        if (vp["#kn53NavVol"] < 1) {
            fgCommand.propertyAssign(rp["#kn53NavVol"], vp["#kn53NavVol"] + 0.1);
        }
      });
      $("#KN53VolDown").click(function() {
        if (vp["#kn53NavVol"] > 0) {
            fgCommand.propertyAssign(rp["#kn53NavVol"], vp["#kn53NavVol"] - 0.1);
         }
      });
      $("#KMA26SelectDown").click(function() {
        if (vp["#kma26Sel"] > 0) {
            fgCommand.propertyAssign(rp["#kma26Sel"], vp["#kma26Sel"] - 1);
         }
      });
      $("#KMA26SelectUp").click(function() {
        if (vp["#kma26Sel"] < 4) {
            fgCommand.propertyAssign(rp["#kma26Sel"], vp["#kma26Sel"] + 1);
        }
      });
      $("#KMA26Com1Select").click(function() {
        if (vp["#kma26Com1Sel"]) {
            fgCommand.propertyAssign(rp["#kma26Com1Sel"], 0);
          }
          else {
            fgCommand.propertyAssign(rp["#kma26Com1Sel"], 1);           
          }
      });
      $("#KMA26Com2Select").click(function() {
        if (vp["#kma26Com2Sel"]) {
            fgCommand.propertyAssign(rp["#kma26Com2Sel"], 0);
          }
          else {
            fgCommand.propertyAssign(rp["#kma26Com2Sel"], 1);           
          }
      });
      $("#KMA26Nav1Select").click(function() {
        if (vp["#kma26Nav1Sel"]) {
            fgCommand.propertyAssign(rp["#kma26Nav1Sel"], 0);
            fgCommand.propertyAssign(rp["#nav1Volume"], 0);
          }
          else {
            fgCommand.propertyAssign(rp["#kma26Nav1Sel"], 0);           
            fgCommand.propertyAssign(rp["#nav1Volume"], vp["#kn53NavVol"]);
          }
      });
      $("#KMA26Nav2Select").click(function() {
        if (vp["#kma26Nav2Sel"]) {
            fgCommand.propertyAssign(rp["#kma26Nav2Sel"], 0);
          }
          else {
            fgCommand.propertyAssign(rp["#kma26Nav2Sel"], 1);           
          }
      });
      $("#AltStatAlt").click(function() {
        fgCommand.propertyAssign(rp["#AltStatic"], 1);
      });
      $("#AltStatNorm").click(function() {
        fgCommand.propertyAssign(rp["#AltStatic"], 0);
      });
      $("#ELTOn").click(function() {
        fgCommand.propertyAssign(rp["#Elt"], 1);
      });
      $("#ELTArm").click(function() {
        fgCommand.propertyAssign(rp["#Elt"], 0);
      });
      $("#FlapUp").click(function() {
        fgCommand.propertyAssign(rp["#Flaps"], 0);
      });
      $("#FlapTakeOff").click(function() {
          fgCommand.propertyAssign(rp["#Flaps"], 0.25);
      });
      $("#FlapLand").click(function() {
          fgCommand.propertyAssign(rp["#Flaps"], 0.75);
      });
      $("#FlapFull").click(function() {
          fgCommand.propertyAssign(rp["#Flaps"], 1);
      });
      $("#TrimDown").click(function() {
        if (vp["#ElevatorTrim"] < 1)
          fgCommand.propertyAssign(rp["#ElevatorTrim"], vp["#ElevatorTrim"] + 0.01);
      });
      $("#TrimUp").click(function() {
        if (vp["#ElevatorTrim"] > -1)
          fgCommand.propertyAssign(rp["#ElevatorTrim"], vp["#ElevatorTrim"] - 0.01);
      });
      $("#BrakeOn").click(function() {
        if (vp["#Brakes"] < 1)
          fgCommand.propertyAssign(rp["#Brakes"], vp["#Brakes"] + 0.1);
      });
      $("#BrakeOff").click(function() {
        if (vp["#Brakes"] > 0)
          fgCommand.propertyAssign(rp["#Brakes"], vp["#Brakes"] - 0.1);
      });
      $("#BatOn").click(function() {
        fgCommand.propertyAssign(rp["#BatSwitch"], 1);
      });
      $("#BatOff").click(function() {
        fgCommand.propertyAssign(rp["#BatSwitch"], 0);
      });
      $("#GenOn").click(function() {
        fgCommand.propertyAssign(rp["#GenSwitch"], 1);
      });
      $("#GenOff").click(function() {
        fgCommand.propertyAssign(rp["#GenSwitch"], 0);
      });
      $("#GenReset").mousedown(function() {
        fgCommand.propertyAssign(rp["#GenSwitch"], -1);
      });
      $("#GenReset").mouseup(function() {
        fgCommand.propertyAssign(rp["#GenSwitch"], 0);
      });
      $("#FuelPumpOn").click(function() {
        fgCommand.propertyAssign(rp["#FuelPumpSwitch"], 1);
      });
      $("#FuelPumpOff").click(function() {
        fgCommand.propertyAssign(rp["#FuelPumpSwitch"], 0);
      });
      $("#Start").mousedown(function() {
        fgCommand.propertyAssign(rp["#StartSwitch"], 1);
      });
      $("#Start").mouseup(function() {
        fgCommand.propertyAssign(rp["#StartSwitch"], 0);
      });
      $("#MagnetoDown").click(function() {
        if (vp["#MagnetoSwitch"] > 0)
          fgCommand.propertyAssign(rp["#MagnetoSwitch"], vp["#MagnetoSwitch"] - 1);
      });
      $("#MagnetoUp").click(function() {
        if (vp["#MagnetoSwitch"] < 3)
          fgCommand.propertyAssign(rp["#MagnetoSwitch"], vp["#MagnetoSwitch"] + 1);
      });
      $("#AvMasterOff").click(function() {
        fgCommand.propertyAssign(rp["#AvionicMasterSwitch"], 0);
      });
      $("#AvMasterOn").click(function() {
        fgCommand.propertyAssign(rp["#AvionicMasterSwitch"], 1);
      });
      $("#PitotHtOff").click(function() {
        fgCommand.propertyAssign(rp["#PitotHeatSwitch"], 0);
      });
      $("#PitotHtOn").click(function() {
        fgCommand.propertyAssign(rp["#PitotHeatSwitch"], 1);
      });
      $("#LdgLightsOff").click(function() {
        fgCommand.propertyAssign(rp["#LdgLightSwitch"], 0);
      });
      $("#LdgLightsOn").click(function() {
        fgCommand.propertyAssign(rp["#LdgLightSwitch"], 1);
      });
      $("#NavLightsOff").click(function() {
        fgCommand.propertyAssign(rp["#NavLightSwitch"], 0);
      });
      $("#NavLightsOn").click(function() {
        fgCommand.propertyAssign(rp["#NavLightsSwitch"], 1);
      });
      $("#InstrLightsOff").click(function() {
        fgCommand.propertyAssign(rp["#InstrLightsSwitch"], 0);
      });
      $("#InstrLightsOn").click(function() {
        fgCommand.propertyAssign(rp["#InstrLightsSwitch"], 1);
      });
      $("#StrobeWhite").click(function() {
        fgCommand.propertyAssign(rp["#StrobeSwitch"], 1);
      });
      $("#StrobeOff").click(function() {
        fgCommand.propertyAssign(rp["#StrobeSwitch"], 0);
      });
      $("#StrobeRed").click(function() {
        fgCommand.propertyAssign(rp["#StrobeSwitch"], -1);
      });
      $("#AltSetDown").click(function() {
        fgCommand.propertyAssign(rp["#altSet"], vp["#altSet"] - 0.25);
      });
      $("#AltSetUp").click(function() {
        fgCommand.propertyAssign(rp["#altSet"], vp["#altSet"] + 0.25);
      });
      $("#KI204SelectDown").click(function() {
        fgCommand.propertyAssign(rp["#ki204Select"], vp["#ki204Select"] - 2.5);
      });
      $("#KI204SelectUp").click(function() {
        fgCommand.propertyAssign(rp["#ki204Select"], vp["#ki204Select"] + 2.5);
      });
      $("#CourseDown").click(function() {
        fgCommand.propertyAssign(rp["#courseSet"], vp["#courseSet"] - 2.5);
      });
      $("#CourseUp").click(function() {
        fgCommand.propertyAssign(rp["#courseSet"], vp["#courseSet"] + 2.5);
      });
      $("#BugDown").click(function() {
        fgCommand.propertyAssign(rp["#bugSet"], vp["#bugSet"] - 2.55);
      });
      $("#BugUp").click(function() {
        fgCommand.propertyAssign(rp["#bugSet"], vp["#bugSet"] + 2.5);
      });
      $("#GReset").click(function() {
        fgCommand.propertyAssign(rp["#pilotG"], 0);
        fgCommand.propertyAssign(rp["#pilotGMin"], 1);
        fgCommand.propertyAssign(rp["#pilotGMax"], 1);
      });

      PropertyChangeListener(function() {
        SetListener(rp["#kt70Select"], function(n) {
          vp["#kt70Select"] = n.value;
        });
        SetListener(rp["#kt70D1"], function(n) {
          vp["#kt70D1"] = n.value;
        });
        SetListener(rp["#kt70D2"], function(n) {
          vp["#kt70D2"] = n.value;
        });
        SetListener(rp["#kt70D3"], function(n) {
          vp["#kt70D3"] = n.value;
        });
        SetListener(rp["#kt70D4"], function(n) {
          vp["#kt70D4"] = n.value;
        });
        SetListener(rp["#com2s"], function(n) {
          vp["#com2s"] = n.value;
        });
        SetListener(rp["#kx155ComVol"], function(n) {
          vp["#kx155ComVol"] = n.value;
          if (vp["#kma26Com2Sel"]) {
            fgCommand.propertyAssign(rp["#com2Volume"], vp["#kx155ComVol"]);
          }
        });
        SetListener(rp["#nav2s"], function(n) {
          vp["#nav2s"] = n.value;
        });
        SetListener(rp["#kx155NavVol"], function(n) {
          vp["#kx155NavVol"] = n.value;
          if (vp["#kma26Nav2Sel"]) {
            fgCommand.propertyAssign(rp["#nav2Volume"], vp["#kx155NavVol"]);
          }
        });
        SetListener(rp["#dmeSelector"], function(n) {
          vp["#dmeSelector"] = n.value;
        });
        SetListener(rp["#nav1s"], function(n) {
          vp["#nav1s"] = n.value;
        });
        SetListener(rp["#kn53NavVol"], function(n) {
          vp["#kn53NavVol"] = n.value;
          if (vp["#kma26Nav1Sel"]) {
            fgCommand.propertyAssign(rp["#nav1Volume"], vp["#kn53NavVol"]);
          }
        });
        SetListener(rp["#kma26Sel"], function(n) {
          vp["#kma26Sel"] = n.value;
          fgCommand.propertyAssign(rp["#kma26Com3Sel"], vp["#kma26Sel"] == 3);         
          fgCommand.propertyAssign(rp["#kma26Com2Sel"], vp["#kma26Sel"] == 2);         
          fgCommand.propertyAssign(rp["#kma26Com1Sel"], vp["#kma26Sel"] == 1);         
        });
        SetListener(rp["#kma26Com1Sel"], function(n) {
          vp["#kma26Com1Sel"] = n.value;
        });
        SetListener(rp["#kma26Com2Sel"], function(n) {
          vp["#kma26Com2Sel"] = n.value;
        });
        SetListener(rp["#kma26Nav1Sel"], function(n) {
          vp["#kma26Nav1Sel"] = n.value;
        });
        SetListener(rp["#kma26Nav2Sel"], function(n) {
          vp["#kma26Nav2Sel"] = n.value;
        });
        SetListener(rp["#altSet"], function(n) {
          vp["#altSet"] = n.value;
        });
        SetListener(rp["#ki204Select"], function(n) {
          vp["#ki204Select"] = n.value;
        });
        SetListener(rp["#courseSet"], function(n) {
          vp["#courseSet"] = n.value;
        });
        SetListener(rp["#bugSet"], function(n) {
          vp["#bugSet"] = n.value;
        });
        SetListener(rp["#MagnetoSwitch"], function(n) {
          vp["#MagnetoSwitch"] = n.value;
        });
        SetListener(rp["#Brakes"], function(n) {
          vp["#Brakes"] = n.value;
        });
        SetListener(rp["#ElevatorTrim"], function(n) {
          vp["#ElevatorTrim"] = n.value;
        });
      });
});
Last edited by peterbr0wn on Thu Dec 15, 2016 2:55 pm, edited 2 times in total.
peterbr0wn
 
Posts: 2
Joined: Tue Dec 13, 2016 8:07 pm
Version: 2016.3.1
OS: linux, osx

Re: Web Panel on 2016.4.3

Postby Alant » Thu Dec 15, 2016 9:51 am

Thanks

I will look this evening.

Alan
Alant
 
Posts: 1037
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10


Return to Interfacing

Who is online

Users browsing this forum: starvi and 0 guests