PDK, IBaseObjectV430, GetWeatherInformation

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Post Reply
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Hi all,

I am populating a WeatherInfoV400 structure by performing the IBaseObjectV430->GetWeatherInformation call on a self created SimObject. For some reason, I only seem to be getting new weather values when a reload of the simulation happens (like time of day, or season change). Otherwise, the returned struct shows always the same values, regardless of the real weather around the SimObject.

Does anyone have an idea what might be going wrong here?

Greets, Benny
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by Mike Schroeter »

Are you making realtime calls IBaseObjectV430->SetPosition(...) on your object? We use this call to know when your object has updated. The system is optimized this way to prevent repeatedly spawning expensive weather queries if the object hasn't updated / moved.

Mike
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Thanks for the quick reply, Mike.

I guess this explains it, then. No, I am not moving the object as I need to periodically check the weather around its position and decide what to do depending on the result.

So I might need to take a different approach there, like using an environmental probe that gets repositioned to my SimObject's position before doing the query on it. But of course, in the end this would simply add the strain of having an additional object that gets repositioned every time...the number of GetWeatherInformation queries stays the same.

Maybe, in the future you could an additional optional parameter to let the developer choose on whether to 'force' a new WeatherInfoV400 struct on the object, so we could see and decide for ourselves if it gets to much of a performance hog. Or at least add some information to the documentation of the method.

Do you have any other suggestion on how to do it? Regularly querying the Weather System Service and parse Metar strings? I guess the performace overhead wouldn't change that much.

Greets, Benny
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by Mike Schroeter »

The simplest solution would be to periodically call SetPosition() on your object. Is there a reason that can't be done?
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Mike Schroeter wrote: Wed Oct 24, 2018 1:08 am The simplest solution would be to periodically call SetPosition() on your object. Is there a reason that can't be done?
Hi Mike,

unfortunately, this doesn't work, either. I am try to call SetPosition with the same parameters or even rotating it periodically for testing before calling GetWeatherInformation but I still get back the same WeatherInfo struct. Only way is still if the scenery gets reloaded. Maybe something else is at play here, if it is supposed to work this way?

Greets, Benny
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by Mike Schroeter »

Is your Dynamic Weather set to 0?

Go to Options - Graphics - Weather - Simulation Settings, and verify the rate slider is not set to the minimum.

Let me know if this helps.

Mike
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

It was set to 0, indeed. Changing it to min didn't solve the issue, unfortunately.

Another thing came to my mind: I am storing the IBaseObjectV400 that gets passed into the constructor and keep using that for my requests. Is this the correct way of working or should I QueryBaseObject() for a new one every time, instead?

Greets, Benny
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by Mike Schroeter »

Caching the IBaseObject pointer should be fine.

You aren't disabling the object in any way, correct? Does the weather query return S_OK?

One thing to try... In the Weather UI, set the wind to be gusty and check if the wind speed changes over time. This would point to whether the issue is with the object simulation or the weather system.

Thanks,
Mike
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Mike,

thanks, I will try that tomorrow.

Yes...the query returns S_OK. And no, I am not disabling the object, I don't even know what that would entail. I am just creating it with a call to CreateObject() and linked it to my SimObject implementation with RegisterSimulationCategory(), beforehand, so my constructor gets called.

My custom SimObject is very basic, until now and mainly entails the overriden member from the ISimObjectV400 interface. Does the custom SimObject need an implementation of ISimulationV310 in order to work correctly, by any chance?

Greets, Benny
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by Mike Schroeter »

Yes, we do assume you have an ISimulation registered. I do understand what you are trying to do, but the ISimulation and the SetPosition() are what complete the "loop" with the P3D host. This is normally required to keep time in sync for things like cameras and collisions.

Mike
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Thanks Mike,

I guess this explains it, then. Comming from SimConnect there is still a lot to learn for me on how to do things correctly with the PDK, obviously.

Will report back how it works out.

Greets, Benny
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Mike,

indeed, that solved it... . I wanted to keep my ISimObject implementation as streamlined as possible, so I kept the ISimulation part out, as I simply don't need it, for now.

Maybe in the future it might be possible to enhance the PDK documentation concerning those issues so a broad understanding of the bigger picture of P3Ds internal workings can be achieved more easily.

Nervertheless, I thank you very much for your time and help solving this problem.

All the best,

Benny
BenBaron
Posts: 80
Joined: Fri Jan 16, 2015 7:51 am

Re: PDK, IBaseObjectV430, GetWeatherInformation

Post by BenBaron »

Hi guys,

for experimentation I tried to create a SimObject via the SimObjectManagers' CreateObject() method WITHOUT my own ISimObject implementation as I would rather want to avoid forcing the user to write my ISimObject implementations' GUID into every aircraft oder sim.cfg they intend to use my .dll with, just to have the GetWeatherInformation() method working correctly.

I then tried to register my ISimulation implementation on the BaseObject that I queried using the returned objectID from CreateObject(). Unfortunately this results in a HRESULT of E_FAIL.

So, just to make it 100% clear: is it possible to just create a SimObject via the SimObjectManagers' CreateObject() method and register an ISimulation instance with it's BaseObject?

Is it realls so, that, in order to use e.g. the GetWeatherInformation() method of a BaseObject, it needs to be embedded into my own ISimObject implementation with a registered ISimulation instance?

Greetings,

Benny
Post Reply