Persistence indicator.

Let Sim Innovations know about your Air Manager experience and let us know about your dream feature addition

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Persistence indicator.

#1 Post by Keith Baxter »

HI,

I HACK persistence and use it as a "tool" so this might not be something for everyone. But interesting for me.

So here are the Q's
1) What is the max file size persistence can handle? Can it handle multiple files within this limit?
2) Is it possible for persistence to upload to the persistence file in chunks rather than in one dump?
3) Can we have an indicator of the persistence state on instrument closure. Explanation.... The instrument closes and the persistence is updated. During this process AM becomes unresponsive because this update is in progress. This should be for each file. If a closure is forced the persistence is lost.
4) If one does some changes to the structure of the persistence file in say, notepad++ . AM CDT on startup.

I know this is unusual stuff but like static data and vector maps, persistence is going to be the next spotlight for saving flight plans and black box/recorder reproductions. Black box???.
Yes I ventured there as well. Recording flight details and posting data to persistence.

This is where the query arises.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Persistence indicator.

#2 Post by Keith Baxter »

Hi,

I do not see a way on how to remove specific persistence files.

Do I just make the file ID =nil and it will be removed.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

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

Re: Persistence indicator.

#3 Post by Corjan »

Hi,


1) There is no max as fas as I know
2) No
3) No
4) Persistence files should not be altered by users, only accessed from API functions.

Although possible, the persistence API is not designed to handle big data sets. It is designed to save small byte sized settings that should be persisted through instrument sessions.


Corjan

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Persistence indicator.

#4 Post by Keith Baxter »

Corjan wrote: Wed Feb 24, 2021 6:44 pm Hi,


1) There is no max as fas as I know
2) No
3) No
4) Persistence files should not be altered by users, only accessed from API functions.

Although possible, the persistence API is not designed to handle big data sets. It is designed to save small byte sized settings that should be persisted through instrument sessions.


Corjan
Yes

So processing a 500 000 record file of 122mb is not recommended.
You should be proud though. AM handles it quite well. Just takes an hour or so to close.

OK so is there an alternative or is their something in the pipeline?

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

stickandrudder
Posts: 44
Joined: Tue Sep 18, 2018 11:25 am

Re: Persistence indicator.

#5 Post by stickandrudder »

does the LUA io work in AM? e.g. io.open(), io.write() etc?

EDIT:
Does not seem like it does.
Tried this

Code: Select all

function writetofile(variable)
    file = io.open("test.txt", "w")
    file:write(variable, "\n")
    file:close()
end

writetofile("hello")

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

Re: Persistence indicator.

#6 Post by Sling »

Lua IO was in AM but it was removed. I had some code for doing this sort of thing but it stopped working around the time we got the Json and xml read sup u port. What’s really needed is also a way to write/edit the file types that currently have read only support.

BTW there are other ways, but it involves going outside of AM.

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Persistence indicator.

#7 Post by Keith Baxter »

Hi,

Well it is not too bad and works ok. The resulting data can be used to do graphs, landing practice in fact almost anything.
Loads reasonably fast.

Here I use Corjans throttle code to fetch data every 500ms. Play around with it :D :D

Code: Select all

my_canvas= canvas_add(0,0,600,600)
orange_box = persist_add("info",{})
black_box={}

canvas_draw(my_canvas,function()
	_rect(175,100,250,350)
	_fill("red")
	_rect(260,150,80,80)
	_fill("black")
	_rect(210,150,8,200)
	_fill("gold")
	_rect(380,150,8,200)
	_fill("gold")
	
end)
function xpl_dataref_subscribe_trottle(...)
    -- Local variables
    local args = {...}
    local user_callback = args[#args - 1]
    local delta_ms = table.remove(args, #args)
    local data = nil
    
    -- Replace the user callback with our own
    args[#args] = function (...)
        data = {...}
    end
    
    -- Do the actual subscribe
    xpl_dataref_subscribe(table.unpack(args))
    
    -- Start a timer that will fire the callback on requested interval
    timer_start(0, delta_ms, function()
        if data ~= nil then
            user_callback(table.unpack(data))
            data = nil
        end
    end)
end

function new_xpl_data(lat, lon, ele, speed, zulu)
	table.insert(black_box,{["laty"]=lat,["lonx"]=lon,["elevation"]=ele,["speed"]=speed,["zulu"]=zulu})
	persist_put(orange_box,black_box)
end

xpl_dataref_subscribe_trottle("sim/flightmodel/position/longitude","DOUBLE",
								"sim/flightmodel/position/latitude","DOUBLE",
								"sim/flightmodel/position/elevation","DOUBLE", 
								"sim/flightmodel/position/groundspeed", "FLOAT",
								"sim/time/zulu_time_sec","FLOAT",new_xpl_data, 500)

Code: Select all

[{
		"key":	"info",
		"value":	[{
				"laty":	28.094097,
				"elevation":	3870.242250,
				"speed":	45.895443,
				"lonx":	-26.757178,
				"zulu":	52664.417969
			}, {
				"laty":	28.094097,
				"elevation":	3868.678294,
				"speed":	46.361538,
				"lonx":	-26.757377,
				"zulu":	52664.917969
			}, {
				"laty":	28.094099,
				"elevation":	3866.624027,
				"speed":	46.963112,
				"lonx":	-26.757601,
				"zulu":	52665.453125
			}, {
				"laty":	28.094102,
				"elevation":	3864.512595,
				"speed":	47.559120,
				"lonx":	-26.757804,
				"zulu":	52665.933594
			},

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply