Open Revel8804 opened 3 years ago
Not really 100% on what you are asking for. is this related? https://github.com/odwdinc/Python-SimConnect/issues/62
Just to confirm "simvar watcher sample program"
MSFS SDK\Samples\SimvarWatcher\bin\x64\Release\Simvars.exe
Can you prove sample of how you receive the data in Simvars.exe or better yet can you save and share the .simvars file.
Sorry I will try to be more clear. I was going through a lot of documents when I wrote the original question.
Yes the SimVar watcher program is the one from
MSFS SDK\Samples\SimvarWatcher\bin\x64\Release\Simvars.exe
Here is a screenshot of an example
So in the screenshot I am pulling the PLANE ALTITUDE, PLANE HEADING DEGREES TRUE, PLANE LATITUDE and PLANE LONGITUDE of Aircraft SimObject 2607.
I would like to be able to pull that same data into the Python_SimConnect
Ok I may be able to help, how do you get the SimObject ObjectID?
I think this is what you are looking for. Could you test the code below with the code form Tree
https://github.com/odwdinc/Python-SimConnect/tree/AI-SimObject-Data-Test
from SimConnect import *
import logging
from SimConnect.Enum import *
from time import sleep
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
LOGGER.info("START")
# creat simconnection and pass used user classes
sm = SimConnect()
aq = AircraftRequests(sm)
AI_OBJECT_ID = 2607
pa = aq.find("PLANE_ALTITUDE")
pa.OBJECT_ID = AI_OBJECT_ID
phdyt = aq.find("PLANE_HEADING_DEGREES_TRUE")
phdyt.OBJECT_ID = AI_OBJECT_ID
pla = aq.find("PLANE_LATITUDE")
pla.OBJECT_ID = AI_OBJECT_ID
plo = aq.find("PLANE_LONGITUDE")
plo.OBJECT_ID = AI_OBJECT_ID
while not sm.quit:
print("PLANE ALTITUDE:", pa.value)
print("PLANE HEADING DEGREES TRUE:", phdyt.value)
print("PLANE LATITUDE:", pla.value)
print("PLANE LONGITUDE:", plo.value)
sleep(2)
sm.exit()
quit()
Ok I may be able to help, how do you get the SimObject ObjectID?
I am going to test that now.
Right now though I am getting the SImObjectID from ... Enable Dev Mode then Options -> Sim Objects. It will show all the objects in a certain area around you.
from SimConnect import * import logging from SimConnect.Enum import * from time import sleep logging.basicConfig(level=logging.DEBUG) LOGGER = logging.getLogger(__name__) LOGGER.info("START") # creat simconnection and pass used user classes sm = SimConnect() aq = AircraftRequests(sm) AI_OBJECT_ID = 2607 pa = aq.find("PLANE_ALTITUDE") pa.OBJECT_ID = AI_OBJECT_ID phdyt = aq.find("PLANE_HEADING_DEGREES_TRUE") phdyt.OBJECT_ID = AI_OBJECT_ID pla = aq.find("PLANE_LATITUDE") pla.OBJECT_ID = AI_OBJECT_ID plo = aq.find("PLANE_LONGITUDE") plo.OBJECT_ID = AI_OBJECT_ID while not sm.quit: print("PLANE ALTITUDE:", pa.value) print("PLANE HEADING DEGREES TRUE:", phdyt.value) print("PLANE LATITUDE:", pla.value) print("PLANE LONGITUDE:", plo.value) sleep(2) sm.exit() quit()
FANTASTIC that is working.
PLANE HEADING DEGREES TRUE: 0.5611127944972876 PLANE LATITUDE: 32.07699151244722 PLANE LONGITUDE: -101.56553905217461 PLANE ALTITUDE: 2512.946367107889 PLANE HEADING DEGREES TRUE: 0.5611127944972876 PLANE LATITUDE: 32.07699151244722 PLANE LONGITUDE: -101.56553905217461 PLANE ALTITUDE: 2512.946367107889 PLANE HEADING DEGREES TRUE: 0.5611127944972876 PLANE LATITUDE: 32.07699151244722 PLANE LONGITUDE: -101.56553905217461 PLANE ALTITUDE: 2512.946367107889 PLANE HEADING DEGREES TRUE: 0.5611127944972876 PLANE LATITUDE: 32.07699151244722 PLANE LONGITUDE: -101.56553905217461 PLANE ALTITUDE: 2512.946367107889 PLANE HEADING DEGREES TRUE: 0.5611127944972876 PLANE LATITUDE: 32.07699151244722 PLANE LONGITUDE: -101.56553905217461
Now to add on to that I would like to be able to do something like (Not great at python yet. I may not be using the correct language, but i hope you get the point.)
for x in AI_OBJECT_ID.AIRPLANE long = aq.find("PLANE_LATITUDE")
lat = aq.find("PLANE_LONGITUDE")
Then I can have the Coordinates or each plane to plot on the map.
I working out how to get the list of ID's in python.
what I can tell form the documentation. OBJECT_ID = 1 is the users aircraft
Next to get a list of id's it looks like we need to call SimConnect_RequestDataOnSimObjectType
Remarks The data will be returned on all the relevant objects within the specified radius, but they will not be returned in any specific order. It is the responsibility of the client program to sort the returned data into order, if that is required. Information is returned in a SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE structure, one structure per object.
For testing I set up this request. Data definition: PLANE ALTITUDE SIMCONNECT_SIMOBJECT_TYPE: AIRCRAFT RadiusMeters: 200000 I sleep for 5s to collect data. putting a logger on the SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE only seems to return 2-3 objects :( not the 20 -30 form SimVar watcher...
from SimConnect import *
import logging
from SimConnect.Enum import *
from time import sleep
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
LOGGER.info("START")
# creat simconnection and pass used user classes
sm = SimConnect()
aq = AircraftRequests(sm)
pa = aq.find("PLANE_ALTITUDE")
pa._deff_test()
sm.dll.RequestDataOnSimObjectType(
sm.hSimConnect,
pa.DATA_REQUEST_ID.value,
pa.DATA_DEFINITION_ID.value,
DWORD(200000),
SIMCONNECT_SIMOBJECT_TYPE.SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT,
)
temp = DWORD(0)
sm.dll.GetLastSentPacketID(sm.hSimConnect, temp)
pa.LastID = temp.value
sleep(5)
sm.exit()
quit()
For now you can hard-set with code below.
Note: fill AI_OBJECT_ID_LIST with list of the ID's you want to check.
from SimConnect import *
import logging
from SimConnect.Enum import *
from time import sleep
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
LOGGER.info("START")
# creat simconnection and pass used user classes
sm = SimConnect()
aq = AircraftRequests(sm)
pa = aq.find("PLANE_ALTITUDE")
phdyt = aq.find("PLANE_HEADING_DEGREES_TRUE")
pla = aq.find("PLANE_LATITUDE")
plo = aq.find("PLANE_LONGITUDE")
AI_OBJECT_ID_LIST = [1, 2607]
while not sm.quit:
for ob_id in AI_OBJECT_ID_LIST:
plo.OBJECT_ID = ob_id
pla.OBJECT_ID = ob_id
phdyt.OBJECT_ID = ob_id
pa.OBJECT_ID = ob_id
print("PLANE ALTITUDE:", pa.value)
print("PLANE HEADING DEGREES TRUE:", phdyt.value)
print("PLANE LATITUDE:", pla.value)
print("PLANE LONGITUDE:", plo.value)
sleep(2)
sm.exit()
quit()
I am trying to pull the data from other SimObjects, such as AI aircraft.
I can use the simvar watcher sample program, to see that the data can be pulled. Just not sure how to do that with this program