Board index FlightGear Development Aircraft Systems

logic filter and input conditions

Modeling aircraft systems, like electrical stuff, hydraulics, pneumatics? Feel free to ask support.

logic filter and input conditions

Postby Soitanen » Tue Nov 24, 2015 8:19 pm

Hi! I'm trying to get work my logic filter, but have no luck with it. Here is the code:
Code: Select all
<logic>
  <name>Altitude alert</name>
  <enable>
    <condition>
      <not>
        <or>
          <greater-than>
            <property>/fdm/jsbsim/fcs/flap-pos-norm</property>
            <value>0.7</value> <!-- flaps more than 20 degrees -->
          </greater-than>
          <property>/autopilot/internal/VNAV-GS</property>
        </or>
      </not>
    </condition>
  </enable>
  <debug>true</debug>
  <input>
    <condition>
      <or>
        <and>
          <property>/autopilot/internal/CMDB</property>
          <not><property>/autopilot/internal/CMDA</property></not>
        </and>
        <and>
          <property>/instrumentation/flightdirector/fd-right-on</property>
          <not><property>/instrumentation/flightdirector/fd-left-on</property></not>
        </and>
      </or>
    </condition>
    <and>
      <greater-than>
        <property>/b737/helpers/alt-diff-ft[1]</property>
        <value>300</value>
      </greater-than>
      <less-than>
        <property>/b737/helpers/alt-diff-ft[1]</property>
        <value>900</value>
      </less-than>
      <greater-than>
        <property>/b737/sound/mcp-period</property>
        <value>3</value>
      </greater-than>
    </and>
  </input>
  <input>
    <and>
      <greater-than>
        <property>/b737/helpers/alt-diff-ft[0]</property>
        <value>300</value>
      </greater-than>
      <less-than>
        <property>/b737/helpers/alt-diff-ft[0]</property>
        <value>900</value>
      </less-than>
      <greater-than>
        <property>/b737/sound/mcp-period</property>
        <value>3</value>
      </greater-than>
    </and>
  </input>
  <output>/b737/warnings/altitude-alert</output>
</logic>


What I'm waiting: only if CMDB is on and CMDA is off or FD on right side is on while FD on left side is off, I want to have first input value (using altitude reference number 1). In all other cases I want to have second input (without condition parameters) using altitude reference number 0. Maybe I'm doing something wrong, but I was looking at this my code many times and don't see error in my logic (maybe I'm wrong) or, maybe, conditions in logic filter for input do not work. Can you help me please?
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: logic filter and input conditions

Postby wlbragg » Tue Nov 24, 2015 10:05 pm

Soitanen wrote in Tue Nov 24, 2015 8:19 pm:
<not><property>/instrumentation/flightdirector/fd-left-on</property></not>
</and>
</or>
</condition>
<and>
<greater-than>

For one, this condition sequence looks wrong. I think the next "and" is floating out there in space , so to speak.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: logic filter and input conditions

Postby sanhozay » Wed Nov 25, 2015 12:33 am

This shows the general format. Obviously you have input rather than reference but the format is the same:

http://wiki.flightgear.org/Autopilot_Co ... ndition.3E

If the link doesn't take you to the correct section, look for the section "Conditional input values <condition>".
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 12:57 pm
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: logic filter and input conditions

Postby wlbragg » Wed Nov 25, 2015 3:01 am

@Soitanen

If the docs don't have what you need, one thing I do to troubleshoot is to start small and add more of the conditions and parameters as you successfully complete one of the simpler steps.
In other words start with just one of the conditions and get it to work before adding more complicated pieces. That way you can narrow down what is breaking it.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: logic filter and input conditions

Postby Soitanen » Thu Nov 26, 2015 8:07 am

Ok, I have tried to narrow down the problem.

Code: Select all
  <test>
    <switch type="bool">0</switch>
    <true type="bool">1</true>
    <false type ="bool">0</false>
  </test>

<logic>
  <input>
    <condition>
      <property>/test/switch</property>
    </condition>
    <property>/test/true</property>
  </input>
  <input>
    <property>/test/false</property>
  </input>
  <output>/test/output</output>
</logic>


Regardless of /test/switch value, I always have in output only /test/true value.

It looks like logic filter do not support conditions for input. Can someone test this issue and confirm?
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: logic filter and input conditions

Postby Thorsten » Thu Nov 26, 2015 9:26 am

The documentation of the <logic> tag however says that there's no <condition> tag needed inside <input>...
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: logic filter and input conditions

Postby Soitanen » Thu Nov 26, 2015 9:35 am

I want to alter output using this method: http://wiki.flightgear.org/Autopilot_co ... ndition.3E
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: logic filter and input conditions

Postby Johan G » Thu Nov 26, 2015 6:32 pm

I do not think you can use the <logic> filter to select different inputs, at least not the way you are trying to do it.

I think the way to do it is to use <condition> tags within the <reference> tags withing the filter you want to select one of several input properties for.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: logic filter and input conditions

Postby Torsten » Thu Nov 26, 2015 7:21 pm

For some reason, the implementation just reads the first configured <input> element.
The comment in the source code suggests that I have implemented that by intention.
http://sourceforge.net/p/flightgear/fli ... ic.cxx#l33

Unfortunately, I can't remember what that intention was :-)

So, for now, only the first<input> element in a logic filter is supported.

Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: logic filter and input conditions

Postby Soitanen » Thu Nov 26, 2015 8:22 pm

Ok, understand. I just do what I want in several steps instead of one, but it's ok.
Thank you for your attention!
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17


Return to Systems

Who is online

Users browsing this forum: No registered users and 1 guest