using 'Persistence' right ...

Support for Air Player desktop on ARM devices, like the Raspberry Pi.

Moderators: russ, Ralph

Post Reply
Message
Author
drnicolas
Posts: 115
Joined: Tue Aug 02, 2016 12:03 pm

using 'Persistence' right ...

#1 Post by drnicolas »

I am thinking of using the persistence-feature.
If I understand the wiki right, persistence is meant to save some values when shutting down the sim.

First idea would be to save the position of the heading bug, OBS setting or Kollsman-setting and have it at the same position next time.
Same to frequencies, Squawk-Code and/or directinal gyro.

This is how my real avionics behaves.

Is there a typical piece of code which is executed when starting Airplayer?
EDIT: Of course, this is where the isntument is drawn first.

But how do I save the values right at shutting down or losing connection ?
Cool would be a function which is always executed when losing connection the flightsim or shutting down.
Air Manager 3.6 Home Use - Rpi AirpLayer with 7" Touchscreen

User avatar
Corjan
Posts: 2936
Joined: Thu Nov 19, 2015 9:04 am

Re: using 'Persistence' right ...

#2 Post by Corjan »

Hi,


Not sure if I understand your question correct, but when you add persistence code to your instrument this will happen:
- When the instrument is being closed, the latest persistence values are written to disk.
- When the instrument is being started, these persistence values are read from disk.


Hope this answers your question, please let me know if it doesn't,

Corjan

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: using 'Persistence' right ...

#3 Post by Ralph »

You can write your persistence data to the sim when you start the instrument, but... that means that you should not start the instruments before the sim is fully up and running. Maybe you can do something with triggering a write when the sim starts the first time, but that can be tricky I think, because you never know when it's fully initialized.

drnicolas
Posts: 115
Joined: Tue Aug 02, 2016 12:03 pm

Re: using 'Persistence' right ...

#4 Post by drnicolas »

I think this is what I want: A signal when the sim is ready to accept commands.

Currently simulator is sending data to the panel. This may be the right way and working. But the more realistic behaviour would be to adopt settings from panel rather then first showing the sim's setting. E.g. freq-settimgs, Transponder, QNH and so on.
Air Manager 3.6 Home Use - Rpi AirpLayer with 7" Touchscreen

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: using 'Persistence' right ...

#5 Post by Sling »

drnicolas,

It really depends on how you want the persistence to function but I use persist_put every time I change a value. This way persist always has the latest value. It's easy to recall all the persist values at code start and then compare those to the sim values and change any that are different. It doesn't matter if the sim or the AM instrument is started first.

I find the best way to determine when the sim is running is by checking subscribe data. If in the unusual circumstance your instrument doesn't use something that changes very often just subscribe to something that always updates like time in seconds and that will force the callback to run. I normally allow it to callback at least once before updating anything as I think from memory it does the callback once anyway if the sim is not running.

Tony

drnicolas
Posts: 115
Joined: Tue Aug 02, 2016 12:03 pm

Re: using 'Persistence' right ...

#6 Post by drnicolas »

Okay, a kind of 'heartbeat'-function. Not bad.
Air Manager 3.6 Home Use - Rpi AirpLayer with 7" Touchscreen

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: using 'Persistence' right ...

#7 Post by Sling »

Yes exactly. I think I called one of my functions watchdog as I liken it to a watchdog timer.

drnicolas
Posts: 115
Joined: Tue Aug 02, 2016 12:03 pm

Re: using 'Persistence' right ...

#8 Post by drnicolas »

It's been quite a long time since I asked for something like a trigger or watchdog-function.
I did not proceed with that, so it is time to ask if someone else has now found something like that.

In fact, I run my panel on a Rpi independently form the simulator.
I want my panel behave like my real world panel.
When I shutdown my aircraft several settings persist until I come back:
- Heading bug for the autopilot
- OBS setting for NAV1/2
- Transponder code
- Frequencies on the variuous NAVCOMs

Actually, my panel seems to read the values from simulator which means:
- Heading bug is set to 0
-OBS set to 0
-Freq set to the settings from the situation XP loads

Of course, I can live with that, butt better would be to know when XP is shutting down and when XP is ready to receive commands.
In the first case, I need to save my settings to disk, in the latter I want to send those settings to XP as a "welcome message"

ANy ideas ?
Contantly watching values form XP seems to be difficult. I think of monitoring the time
Air Manager 3.6 Home Use - Rpi AirpLayer with 7" Touchscreen

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: using 'Persistence' right ...

#9 Post by Sling »

I assume you have tried to use the persistence functions for this and can't get it to work the way you expect. If so can you post the code you used to try and make this work. What you want is exactly what the persistence functions are for so it's fairly easy to implement.

https://siminnovations.com/wiki/index.p ... ersistence

As for the sim running thing you will be able to establish that by checking for always changing sim data (time) in a dataref callback.

Tony

Post Reply