• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

A-Level Computing Project - how to do this....?

Messages
3
Country
unitedkingdom
Hello all,

Recently signed up here for help with this, I am doing a FS App for an A-Level computing project. I have chosen to base it on flight simulator, and am finally at the point of starting the coding after writing the report.

Essentially, this app, to run just on the FS machine, will monitor airspeed, yaw, bank, pitch, gear and flap deployment upon gauges, present warning messages (whose urgency will be variable) when airspeed or an angle etc exceed the lower safety limit - taken from the aircraft.cfg files or looked up online. And will also issue piloting advice messages to assist in resolving a safety issue - such as excessive airspeed, eventually informing of a crash if a safety factor is over the maximum safety limit or that the aircraft has returned to a safe situation. Additionally, a user will be able to click on a button to display gauges showing these safety factors, the data read from the simulator, over time.

I have attached a few plans to hopefully describe my project better...

Main_Screen.jpg

Main_Screen_With_Message.jpg

Help_Settings.jpg

Graphs.jpg


Anyway, I've already planned out psuedocode algorithms, and the actual logic of this part of the project I have a good idea about completing with the use of variables from FSX.

Code:
This is the main feature and purpose of the program. This process is run as soon as a flight is initiated:

Monitor whether aircraft exceeds safety limits
Warn if limit(s) exceeded
Begin issuing instructions to correct the problem
Continue to warn if issue not resolved, these warnings becoming more urgent as does the problem
When ‘fatal’ limit exceeded, inform of crash
As algorithm:

Flight initiated

(Airspeed(0 - X)/Bank/Pitch/Flaps/Gear)SafetyExceededMessage = ‘written descriptions of outcomes of resulting crashes for each factor being exceeded’

//Have multiple messages (0-X) of different theoretical outcomes for each factor

Whilst (current airspeed or bank angle or pitch angle > lower limit of safety)
   
    Display ‘warning’ message for X seconds
   
    For every X seconds whilst current > lower limit
        
Repeat ‘warning’ message with iteratively increased message size, colour, urgency of  wording etc
   
    If PilotingAssistance = True

Display “Reduce airspeed, bank or pitch angle by (current - lower limit)” every X seconds
       
        Whilst iterate (maximum safety limit – current < X – (X * i))
           
            Message made (i) times larger or urgent etc

    If (current < lower limit)

        Display ‘safety returned’ message
   
    If (current airspeed or bank angle or pitch angle > maximum limit of safety)

SafetyExceededMessageToDisplay = (Airspeed(RandomInt(0-X))/Bank/Pitch)SafetyExceededMessage

//Whichever of those 3 factors has been exceeded
       
        Display ‘crashed’ message + SafetyExceededMessageToDisplay

//Various messages possible at random adds a degree of further ‘realism’

Pause operation until message dismissed by user

Allow simulation to continue to run and end algorithm
//These 2 lines of code possibly as an ‘End()’ function for use in below if statement

If ((Gear/Flaps)Extended = True and CurrentAirspeed > (Gear/Flap)SafeAirspeedLimit)

        SafetyExceededMessageToDisplay = (Gear/Flap(RandomInt(0 – X))SafetyExceeded         Message

        Display ‘crashed’ message + SafetyExceededMessageToDisplay

Pause operation until message dismissed by user

Allow simulation to continue to run and end algorithm
    
Each ‘X’ can be any integer - yet to be decided

Code:
Graphing of Data

This is an ‘additional’ feature, and one where the storage of data is involved:

Continuously record data on various factors fed from the simulated aircraft.
Store this data to memory.
When user requests graphs’ display – in or outside of flight - output this data in graphical form.
User can adjust the display of this data slightly – per desired time period.
Adjust the graphs’ appearances accordingly.
Allow the closure of graphs.

As algorithm:

TimePeriodOnXAxisChoice = 1 // Default setting

Every minute in simulation:

    LoggedAirspeedAt(X)Minutes = CurrentAirspeed // Read this variable through API / SDK.
   
LoggedAltitude...

When DisplayGraphs Button Clicked:

    If TimePeriodOnXAxisChoiceBoxInput != 1 // Variable stores input in text box on form

        TimePeriodOnXAxisChoice = TimePeriodOnXAxisChoiceBoxInput


    Display graphs for LoggedAirspeed, LoggedAltitude... // Graphical aspect – display the forms.

    YAxisName = ‘Airspeed/Altitude etc’ // Names to be displayed in the form.

    XAxisName = ‘Minutes in to flight duration – At (TimePeriodOnXAxisChoice) minute intervals’

    For each graph:

        i++
       
        // Numerical values to plot on graph

        Y = LoggedAirspeed/AltitudeAt((TimePeriodOnXAxisChoice)*i)Minutes

        at:

        X = TimePeriodOnXAxisChoice * i

    If GraphsClose Clicked:

        Close graphs window

// Perhaps adjust colours of sections of graph lines as colour coded, if more than one graph plot is within any of the given iterated ranges of increased danger for a safety factor – Call and see part of the previous algorithm.

// Must consider way to avoid displaying too much data – Allow user to input range of time in past to show data for?

Obviously, those aren't completed and will need additions and changes when I've started making it, but hopefully allow you to see my rough ideas.

Having already discussed the early planing stage of this on the flightsim.com forums, what I need help with from you FS developers, before making a start on producing it, is how I actually 'go about making it'. I have been advised to use C++, and having read a fair bit of the SDK HTML document guide, it looks like 'SimConnect' and 'panels and gauges SDK' is what I need?

I was told I could produce an XML gauge, and have read some of these example projects, however it appears it would not be possible to produce it as a separate windows program and must be another window within the simulator itself. is this correct? Ideally, I'd need this to be a windows program that can connect to FSX via SimConnect.

it looks like making an XML gauge would be fairly simple, and I can use a tool to graphically design it before adding C++ code to it? But what other options to producing this project could I take? I don't have massive amounts of time available and really need this to be produced and ready for testing by the new year.

Although you may be struggling to fully understand what I am trying to do, I would really appreciate assurance that this project is feasible and an explanation of how to get started with it all. I have a development environment setup now with FSX and Visual Studio in place, but don't know how to begin, despite reading some guides. This is very daunting to me to start from complete scratch.

Many Thanks for your time.
 
Well, you are certainly ambitious, that's for sure and certain. The only thing I can offer at this time is this. XML may only be used whilst within the FS envelope. That is, an out-of-process executable connecting via SimConnect cannot use XML display 'gauges'.

So, either script the entire project in XML as an in-process module/gauge, or code the entire project as an out-of-process executable in C++...
 
So if I gave you a C# project that does half the work for you, is that defeating the purpose of you learning how to program as a project?
I do have a semi completed project getting this sort of data for display on a generic set of gauges. The idea was it would run on an auxiliary monitor and auto switch to the relevant gauges when changing between piston engines, turbines, jets etc but it is fairly permanently stalled while I do other projects.

Regards

Richard
 
Thanks for replies both of you.

Is it the case that XML is significantly quicker and easier to produce than a separate .exe? If do an .exe, how do I go about making a start on that?

Is the above project possible to display in an XML project? Graphs too?

Rich, I'm sort of not bothered about the 'learning', though I'm hoping to do Comp Sci at Uni next year, I feel confident enough in my programming ability but C++ is new to me. I could change to C# easily enough, which I do have plenty of experience in. Thanks to the pressure of this A-Level project, all I care about doing is getting it done quickly, giving me time to learn the theory content of the course for this year and getting a good mark. I doubt I'd get done for copying your work, especially if I adapted it slightly. If you wouldn't mind, it would massively help me if I could use it to just 'look at' and not to copy it -I'm not intending to sell this afterwards, if you fear me making money off your work!

My original thought was to do it on a networked device like an iPhone, but this would consume too much time. I'm now hoping to display it maybe across multi-monitors. I also thought about making the gauges alter automatically for each aircraft model currently selected, but have scrapped this idea for the same time related reasons.

Again, thanks ever so much and I look forward to reading your replies.

Gordon
 
Hello Gordon,

you can use C# .exe for this - look up managed SimConnect code examples in ESP SDK. There is some basic info there and you can extrapolate the rest from C++ reference.
 
Hi Peter, I will do that. Would you be able to provide a rough estimate of how long this would take to do? I'm probably now looking at creating an external program, and perhaps will use C# instead.
 
I have no idea. Of course it depends a lot on your skill.

I guess I could get the raw data (in C++ anyway) relatively quickly but personally I have no idea how to work graphics, so... that'd be about it.
 
Back
Top