About radar thing, if I understand well, the TFC object is the closest to what we want.
So when I look the TFC controller, there is a loop, which go threw th AI/MP tree, and take each model in range.
This is typically the code of the radar, with few more things : all the radar stuff will execpt models like the inRange do. (So terrain will except etc...)
This is all correct.
5H1N0B1 wrote in Tue Feb 25, 2014 4:31 pm:My greatest concern here is that the radar code/loop/update HAVE to work without the canvas. I means it has to work in total independance, that you can have the radar updating without having a canvas or MapStructure. And this for obvious reasons like using the radar in other application (like missiles...<taking a witch voice>my dear little missile </taking a witch voice>)
right, the correct way is to come up with your own Radar/Target classes and only use them inside the lcontroller file's searchCmd() method - that way, you have no tight coupling, and can easily reuse your radar/target for other purposes, such as AI traffic or AI-guided missiles.
So to me we have to solution to update TFC( or TARGET) positions :
- Have in the TFC controller something like myRADAR.getTargetArray() -> and this will return an TARGET array each time it's necessary.
- Radar code fill a property tree in /instrumentation/RADAR[0]/targets, and the TFC get it with the actual loop instead of look into AI/models
I have a great preference for the first one. (the second is just transform an array into a property tree and transfrm the property tree into an array ->aberration)
right, what you'll want to do - referring to TFC.lcontroller- is replacing the "TrafficModel" (currently representing a single aircraft with TCAS) with your own "Target" class.
SearchCmd() would then be modified to query a RadarClass object that returns a list of "TargetClass" objects.
That way, your own code will never have any dependencies regarding MapStructure or Canvas.
We tried to explain the concept previously:
viewtopic.php?f=71&t=21993#p199912But to do the first on I could have problem : I don't really know actually how can I call an object myRADAR, that doesn't exist in the TFC controller function.
Perhaps Global variable ? I don't really know. (I'll have to check the doc about variable visibilty...)
Any idea from nasal non humain coder ?
I think Philosopher was going to come up with a tutorial on doing exactly that - but these are basically the steps:
- you create your Radar class, i.e. in your aircraft (or the radar-mapstructure dialog for testing purposes, i.e. inside the Nasal/open block)
Basically, depending on how/where you create an object, it will "live" in a certain namespace - which you need to prefix.
Then, you come up with the correct namespace where your object lives, see:
http://wiki.flightgear.org/Howto:Unders ... nd_MethodsYou can use print(closuer()[0]) to print the active namespace to the console:
http://plausible.org/nasal/lib.htmlFor testing purpsoes, none of this is important however - you can simply instantiate (=create an object) your class at the top of the "radar-mapstructure" dialog.
The only thing you'll have to change later on is a single line to point to your aircraft's namespace, e.g. "m20005.radar".
That's exactly the way, the ND is internally structured and set up to work with different aircraft, too.