41256members
184131posts

Automatically Refresh Embedded Mimic Query List using Script

Highlighted
Crewman

Automatically Refresh Embedded Mimic Query List using Script

Hello

 

I would be grateful if someone could help me write a script which updates a query list say every 10 seconds.

 

I tried

 

Public Sub Mimic_Refresh

 

While true

Mimic.Layers("Mimic").Item("Lst_1").sql  = Mimic.Layers("Mimic").Item("Lst_1").sql &" "

Sleep 10000

 

Wend

End Sub

 

But does not work.

 

Grateful for any help

 

Thanks

 

Tdog

9 REPLIES 9
Highlighted
Lieutenant JG

Re: Automatically Refresh Embedded Mimic Query List using Script

That's not what scripting is for, it is single threaded and can be aborted by another scripting running.

 

What is the SQL doing/showing? If you're referencing database objects and include the id field the row content should update automatically. If its a data table/grid then it won't auto update.

 

 

Highlighted
Crewman

Re: Automatically Refresh Embedded Mimic Query List using Script

Hi adamwoodland

 

Perhaps if you look at this link

 

https://www.se.com/ww/en/faqs/FA383074/

 

This is close to what I wish to achieve only I would like to automate the query refresh at regular intervals.

 

surely the code fragment detailed in the link could be placed within a mimic script loop incorporating a sleep/wait command after a refresh for x amount of seconds before looping again?

 

Thank you for your reply.

 

Tdog

Highlighted
Commander

Re: Automatically Refresh Embedded Mimic Query List using Script

I agree with Adam, this is not what scripting is intended for.

 

If you want an SQL query on the page to be updated every so often, then you will need the animation property for it to change.  This can be done by having the SQL animation include a meaningless point reference where that point is updated every X seconds.

 

The demo database has a horrible 'clock' example which has a noisy point that does something every second (I believe).  So you could add that to the animation.

 

Something like

'SELECT stuff you care about

FROM place you care about

WHERE things you care about are true AND (' + "PointValue" ' > -1 OR TRUE)'

 

In this way the query is different every x seconds, but the result of the query is still the same.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Highlighted
Crewman

Re: Automatically Refresh Embedded Mimic Query List using Script

BevanWeiss

 

Thank you for the response - interesting idea.

 

Regards

 

Tdog

Highlighted
Sisko

Re: Automatically Refresh Embedded Mimic Query List using Script

Many embedded lists will refresh automatically - ones which directly query database tables descending from CDBObject, such as points and RTUs. Lists such as events and historic data will not.

 

As an aside, if you DON'T want a query to refresh automatically there's an 'interest' checkbox on the embedded list object's properties.

 

Naturally, causing too regular refresh using the SQL animation method will cause extra database load, plus operator distraction as lists refresh - the trick is to find the right frequency - perhaps there is some other database item which changes, and you can JOIN using that?

 

The SQL animation method also requires you to take careful note of your " and ' characters, and to escape them as needed. This can get tricky when editing in the animation box, so using Notepad and cutting/pasting may help you.

The ' is used for string literals in animations and also for the SQL, so double-up single quotes for SQL within the single quotes.

Highlighted
Crewman

Re: Automatically Refresh Embedded Mimic Query List using Script

Thank you for the detailed response

Highlighted
Lieutenant JG

Re: Automatically Refresh Embedded Mimic Query List using Script

I had asked for something similar quite a while back. Probably buried somewhere in the old forums. Mine was slightly more complicated due to have multiple embedded lists on the mimic I wanted to all refresh at the same time automatically. I was able to create a button on the Mimic that would refresh all of the embedded lists, that uses a small bit of script in the background. 

Highlighted
Cadet

Re: Automatically Refresh Embedded Mimic Query List using Script

Hi Tdog,

 

I got this to work with Animations on the embedded list. On the "SQL" property use a IIF( "~Global.List Update Trigger" > 0, 'SELECT * FROM CDBPoint, '' )  Then just toggle that Update Trigger with a Logic Program using the normal timer properties of the logic program.

 

-Brandon

Highlighted
Crewman

Re: Automatically Refresh Embedded Mimic Query List using Script

Thank you very much for taking time and effort to respond.

 

I will look into this

 

Tdog