TwinFan / XPPlanes

Display additional planes controled by network messages
https://twinfan.github.io/XPPlanes/
2 stars 1 forks source link

UDP Data Transfer and Use for simulator #4

Open NCC21864 opened 2 months ago

NCC21864 commented 2 months ago

I'm building an ATC simulator,now I wonder how can I transfer my UDP data From Server to the Flight data,my own UDP data just decode like AI_ID[idx] = sAC_ID; //x Temp[0] = MyArray[11]; Temp[1] = MyArray[12]; Temp[2] = MyArray[13]; Temp[3] = MyArray[14]; AI_X[idx] = BitConverter.ToSingle(Temp, 0); //y Temp[0] = MyArray[15]; Temp[1] = MyArray[16]; Temp[2] = MyArray[17]; Temp[3] = MyArray[18]; AI_Y[idx] = BitConverter.ToSingle(Temp, 0);
............................................................. Temp[0] = MyArray[35]; Temp[1] = MyArray[36]; Temp[2] = MyArray[37]; Temp[3] = MyArray[38]; AI_SPD[idx] = BitConverter.ToSingle(Temp, 0); I wonder How can I connect The Plugin in and create Aircraft

TwinFan commented 2 months ago

I'm sorry, the question is not very clear. Please read the documentation.

The message formats XPPlanes can deal with are documented there. You need to send data in such a format. I recommend using the XPPTraffic format as that can control all available features. You send the data to broadcast port 49800 or multicast port 49900, or what you configured the plugin to listen to.

Example .JSON files are provided in docs. An example Python script, which can send such .JSON files, is provided in script/SendData.py.

Installation instructions for the plugin itself are provided as well. Granted...all of that is fairly brief as I am assuming that people developing for X-Plane have experience with X-Plane setup, plugin installation, and for this project also in development. Don't forget to install CSL models, which only are the plane objects XPPlane will draw. For its installation the documentation refers to my LiveTraffic plugin with a very detailed instructions.

I can try to help you as best as I can afford, but you would need to be more specific what you have trouble with.

NCC21864 commented 2 months ago

could I get a simple way to communicate?I need get solution in a hurry

NCC21864 commented 1 month ago

My UDP data send from a server,which struct is:ID,LocalX,LocalY...HDG etc. I wish the plugin can receive the message like this

TwinFan commented 1 month ago

In the documentation you would find that XPPlanes also understands a simple comma-separated format named RTTFC taken over from RealTraffic. It is specified in this PDF in the secton "RTTFC/RTDEST format" starting on page 4 and looks like this:

RTTFC,hexid, lat, lon, baro_alt, baro_rate, gnd, track, gsp, cs_icao, ac_type, ac_tailno,
from_iata, to_iata, timestamp, source, cs_iata, msg_type, alt_geom, IAS, TAS, Mach,
track_rate, roll, mag_heading, true_heading, geom_rate, emergency, category, nav_qnh,
nav_altitude_mcp, nav_altitude_fms, nav_heading, nav_modes, seen, rssi, winddir,
windspd, OAT, TAT, isICAOhex,augmentation_status,authentication

Most of these fields aren't essential for XPPlanes and you can leave them empty. Haven't tried...but you should be good by just sending values for "RTTFC", hexid, lat, lon, gnd, ac_type, timestamp, alt_geom, true_heading. For any fields you don't fill just send nothing, but keep the separating commans in the data, so you'll always have 42 commas in the data.

Also for this format there is an example file available.

NCC21864 commented 1 month ago

now I Have receive and convert my data to json and send by udp port 49800,the status of plugins display as (waiting for data)😭,can't wait to get your contact way and get your help,best wishes

NCC21864 commented 1 month ago

now the plugin has received the data,log says that Couldn't convert to FlightData object, unknown format or data insufficient: maybe my frequency of data sending is too high? I have about 200 "json" to send,if any need, I can slow it down

TwinFan commented 1 month ago

Attach X-Plane's Log.txt and one of your JSON you had sent.

NCC21864 commented 1 month ago

I Have successfully Build it,thanks for your help

NCC21864 commented 1 month ago

more,I wanna know about the max amount of aircraft

TwinFan commented 1 month ago

XPPlanes implements no limit on the number of aircraft.

NCC21864 commented 1 month ago

that's incredible,you are just completely genius

NCC21864 commented 3 weeks ago

i'm back!,now i have a problem.i need the plane "shouldBeRemoved" if there is no data received in 2 seconds,i have set the gracePeriod = 2,but the plane didnt disappear as my wish,looking forward to your help

TwinFan commented 3 weeks ago

To be able to help you please set logging level to debug (LogLevel 0 in XPPlanes.prf), run another session that produces your issue, then attach both XPPlanes.prf and the resulting Log.txt file from the X-Plane directory.