Martin,

After spending the day in c++ help files and inserting printf all over the
place i have managed to follow it through and get the code up and running
for one aircraft  Hopefuly tomorrow i can finalise it.

2 question for now,

Is FG running mutli thread thease days, ie do I need worry ablout clashes
betwwen an io cycle and the AI system with object?

I am not sure how the lists in the ai work but whats the difference between
_dt and dt? eg as in this line from AIManager.cxx
(*ai_list_itr)->update(_dt);


regards Harry








On Mon, Apr 20, 2009 at 4:07 AM, Harry Campigli <harryc...@gmail.com> wrote:

> Thanks Martin,
>
> My set up is one FG machine with 3 slave FG machines,  they are the 3
> window views. But I am also using the sound harware in them. The main aim is
> to get the Ai aircraft and the selected cloud layers the same in all
> windows.
> ( i have succeded with multiplayer just by forwardng on the recieved data
> steam to the slaves.)
>
> Sticking with FG convension as I see it in FG code I have cloned the native
> net controls format, just different porperties. This io stream also passes
> the cloud layer data, 3d clouds enabled and other items so they are all the
> same in the slave window views.
>
> I have added a couple of poperties to the original AI Aircraft tree, eg the
> model path string, A/c tail number, callsign and livery. This is just to
> make them easy to pick up with the io routine and also debuging.
>
> I have stored the recieved copy of the Ai aircraft properties in a new
> branch of the AI tree with the io protocol 10 times a second. this is at
> /ai[0]/models[0]/slave/aircraft[i].
>
> Hopefully having said that, you can imagine this code tacked into the
> bottom of the net io protocols, called every time a new update of the
> properties is recieved,  There is no sorting in it as yet, its only a run
> once thing for now it is purely to get to the stage of adding one aircraft
> to the ai sub system from the recieved data in the slave . After that its
> working I should be able to deal with adding update and delete.
>
> The mechanisms to attach and update the remote date are all in FG, It just
> i only do C in single chips and am in over way my head with the c++ .
>
> What I am trying to do below is create a model object, load it with the
> data and attach it to the Ai system the same way traffic manager and
> multiplayer do without changing any of the existing FG code. Once its
> attached I will keep it updated from the recieved data. (infact what I have
> found just droping the postion info the the tree works if I let the traffic
> manager system generate the models).
>
>
> Below works fine to the printf("found mp..  Thus i know i have the path
> string though ok from the master. The problem starts when I try to load the
> new aircraft object with the model path string, either the compiler
> complains (my errors) or it has a seg fault after running.
>
> Note the areas with the // commented out code my attempts to load those
> items
>
> If I leave the new object un modified (as is now in the code below) and
> attach it with the   aiMgr->attach(aircraft1);   line, it still brings about
> a seg fault. I suspect this could be because it is in fact empty. My many
> attempts give errors that seem to indicate I have created the  new object
> with    FGAIAircraft* aircraft1 = new FGAIAircraft; correctly.
>
>
>
>
> // begin work area to attach an aircraft to the ai system
>
> // earlier we ensured  Shut down of the "Traffic Manager enabled" prop as
> we are recieving our traffic
> // : info  includes at the start
> //    #include <AIModel/AIBase.hxx>
> //    #include <AIModel/AIAircraft.hxx>
> //    #include <AIModel/AIManager.hxx>
>
>
>
>  // temporary flow control just for testing in a run once only non indexed
> scenario , this node will not exist , after exit it will
>    if( ! fgHasNode("/ai[0]/models[0]/aircraft[0]/atttached")){
> printf("have start \n");
>
> // point node to the branch where the remote system AI plane data has been
> placced to
>       node = fgGetNode("/ai[0]/models[0]/slave/aircraft[0]", false);
>       SGPath mp(globals->get_fg_root());
>       SGPath mp_ai = mp;
>       temp = node->getStringValue("path"); // returns the model path
> recieved from the master machine
> "Aircraft/777/777-SingaporeAirlines.xml"
>       mp.append(temp);
>       mp_ai.append("AI");
>       mp_ai.append(temp);
>       if (mp.exists() || mp_ai.exists()) {
> printf("found mp, means the model path from the master was found on this
> machine \n");
>     }
>        FGAIAircraft* aircraft1 = new FGAIAircraft;    // create a new
> aircraft entitie to dadd to the AI system
>
> // Load the variables to the to the new AI aircraft. the model path, its
> registration number, livery and callsign
>
>
> //     aircraft1->setPath(node->getStringValue("path"));
>
>   //   temp = node->getStringValue("path");
> //aircraft->setPath("Aircraft/777/777-SingaporeAirlines.xml");
>   //   aircraft1->setPath(temp.c_str());
>
> //   temp = node->getStringValue("registration");
> //     aircraft->setRegistration(registration.c_str());
>
>     temp = node->getStringValue("callsign");
>  //    aircraft->setCallSign(temp);
>
> //    temp = node->getStringValue("livery");
> //     aircraft->setLivery(lvry.c_str());
>
>
> printf(" aircraft  loaded with strings from property tree \n");
>
>       FGAIManager *aiMgr =
> (FGAIManager*)globals->get_subsystem("ai_model");
>       if (aiMgr) {
>     aiMgr->attach(aircraft1);
>     printf("have aiMgr\n");
>
> //      i = aircraft1->getID(); // if  aircraft is attached we store this
> number
>     node = fgGetNode("/ai[0]/models[0]", false );
>     node->setBoolValue("aircraft[0]/localID",i,true); // used later with
> the a/c registration number to keep models in sync with master
>
> // temporty flow control airaft attaced to tree, create this node to we
> dont run again
>     node->setBoolValue("aircraft[0]/atttached",true);
> printf(" ID %i \n");
>
>       } // end of if aimgr
>
>   } // end of if have node
>
>
> // end of work area
>
>


-- 
Regards Harry

19b Jln Danau Poso
Sanur, Bali
80228

H +62 361 285629
M +62 812 7016328
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to