Archived

This topic is now archived and is closed to further replies.

conura

Building an aircraft as a software object.

Recommended Posts

Hi all,

 

I know this isn't typically the remit of flight simulator chat but I was hoping for a bit of advice if anybody here is a coder.

 

I've just finished my first year on a Software Engineering course and have only just really began programming (First year was concerned with computational theory, algorithms etc and introductory boolean logic) and I'm now working toward a solid grasp of Java.

 

Anyway, what I am trying to build at the moment  is a trainer for a specific aircraft with an explanation of what is happening at at each stage of startup. At the moment it's command line based but I'll put in a GUI toward the end. It won't be particularly useful but it's a good learning experience and as I'm a big sim fan I thought it best to learn new concepts by testing on things I'm interested in.

 

Anyway, using OO principles, is it generally best to write the every subsystem as a seperate class? For example, having a battery class which handles all the logic of the battery, then returns a boolean such as (boolean batteryOn = true) to the main aircraft logic, which will then allow power to flow to a radio (which again is a different class with it's own set of logic).

 

Is there a simpler way to go about ultra simplistic system simulation than this?

 

Look forward to any replies! :)

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I am software enginer myself. I did a aircraft representation in C# 4.0 once. Just to learn the language syntax. Doing an Aircraft is a good learning experience specially when to use OO. An aircraft is programmers heaven for me anyways. You can have an Aircraft abstract class for example which shares common features. from that you can inherent other aircraft classes. Because in real world you have Planes, helicopters. Cargo planes etc.They share common features(Methods) but also have unique functionalities.

 

I would model aircraft systems separately like batteries, APU etc. the possibilities are endless. And if you really want be on fire. Have a look if you can apply any design patterns to your project.It is all good learning experience and fun.

 

You can do it all simple in some spaghetti code but bad practice and the learning effect is not great.

 

Good luck with your course.

Share this post


Link to post
Share on other sites

Agree with Cpt Guido.  I recall the flight simulator "Fly" from Terminal Reality was built that way.  I think you will enjoy building it that way.  Put emphasis on class composition vs. inheritance.  

Share this post


Link to post
Share on other sites

Thanks very much for the replies guys - very useful, and thank you guidos for the particularly in depth information.

 

I try to follow OO principles wherever I can and actually had already done as you'd said! I've got an abstract superclass 'Airplane' which has basic functionality common to all (well, most) aircraft (engine start, fuel pumps, flaps, lights, throttle, fuel tank) and am currently working on an inheritance subclass 737 (with a few overridden methods and additional methods like FMC on/off). The class is effectively a collection of methods which call other classes (such as radio, fuel pumps, lights) which return an argument to give me an overall aircraft status.

 

It's really good fun but becomes very complex quickly! It's also fairly overwhelming, for example I woke up at 3am and my first thought was "I can represent the fuel load from 100 % down to 0 by creating an ArrayList and removing one index every so often (certainly not normal middle of the night thoughts!).

 

Next step is actually finding a way to get the aircraft to move in a rudimentary fashion. I've nil knowledge of 3d (or 2d..) engines but was thinking movement through a 2d array could be a good way to simulate basic movement?

 

Thanks again for your replies :)

Share this post


Link to post
Share on other sites

For movement, the story could be described as the throttle can be set to a thrust level, like throttle.set(amount), meaning the throttle sends a message to the engines to produce a specific level of thrust, i.e., engine1.thrust(thrustLevel), where thrustLevel is an integer with range -5 .. 5 (negative values indicate reverse thrust).  The airplane would move a set distance/time ratio based on the level of engine thrust.  That movement also carries a a figure of momentum based on the level of thrust.  

 

As you can see, one can make all kinds of design decisions on how to set it up.  

Share this post


Link to post
Share on other sites

This is an automatic message.

 

This topic has been moved from "MS FSX Forum" to "MSFS Aircraft and Panel Design Forum". This move has been done for a number of possible reasons.

  • The most likely reason is that the post was off topic.
  • The topic could also have contained images or a video that were not appropriate to the original forum it was posted in.
  • The images might not have been "illustrative" or "explanatory" in nature.
  • The topic could have been moved because we deemed it to be more appropriately placed elsewhere.
Please ensure that your posts are "on topic" and contain illustrative images or videos as appropriate. Do not post videos or images just for entertainment purposes anywhere but in the screen shot or video forums. See our image posting rules here.

 

Members who continue to post off topic posts can be denied entry to specific forums in order to reduce and remove the practice. Your cooperation is appreciated.

Share this post


Link to post
Share on other sites