example using p3d PDK Weather System Service

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
mer
Posts: 25
Joined: Fri Aug 31, 2018 10:52 am

example using p3d PDK Weather System Service

Post by mer »

I found samples in the P3dLearning Centre for Custom Lights and Camera among others.

It would be really helpful if there was an example explaining how to invoke and use the Weather System Service. Could someone share such an example?

Thank you
mer
Posts: 25
Joined: Fri Aug 31, 2018 10:52 am

Re: example using p3d PDK Weather System Service

Post by mer »

I tried to access the global Pressure value using the code below

extern "C" __declspec(dllexport) void __stdcall getPressure()
{
printf("Reading global pressure : ");
CComPtr<IWeatherSystemV430> weatherSystem = PdkServices::GetWeatherSystem();
printf("weather system ");
float pressure = weatherSystem->GetGlobalBaroPressure();
printf("%f", pressure);
}

And invoking this from a C# project:
[DllImport("CameraPDK.dll", CallingConvention = CallingConvention.StdCall)]
public static extern float getPressure();


static void Main(string[] args)
{
Console.WriteLine("The global pressure is {0}",getPressure());

}

But I receive an error at getPressure():
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Could anyone please guide?
Post Reply