Logic Machine Forum
Change "visdimopacity & visdim" - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Change "visdimopacity & visdim" (/showthread.php?tid=933)



Change "visdimopacity & visdim" - JMM - 09.08.2017

Hi,

How to change the "visdimopacity and visdim" value dynamically

Code:
var Globals = {
config: {.......,"visdimopacity":"80", visdim":"3",.......... },
updateTime: '1502280884.48142',
};

Thanks

Jean-Marc.


RE: Change "visdimopacity & visdim" - admin - 10.08.2017

Code:
require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')



RE: Change "visdimopacity & visdim" - JMM - 10.08.2017

Hi Admin,

Admin, thank you, it's perfect.

Jean-Marc.


RE: Change "visdimopacity & visdim" - Habib - 10.08.2017

A stupid question. What do the parameters "visdimopacity and visdim"?


RE: Change "visdimopacity & visdim" - admin - 11.08.2017

Visualization settings: "Dim inactive visualization after" is visdim, "Dimming level" is visdimopacity


RE: Change "visdimopacity & visdim" - tassiebean - 15.06.2020

(10.08.2017, 05:56)admin Wrote:
Code:
require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')

Hi Admin,

I understand what this it is supposed to do, and I want to allow the user to turn screen dimming on or off themselves. However, can you please explain how this is used in a working code example? This looks a bit like a fragment to me and I can't figure out what to do with it. I tried a few things with no joy.

Thanks!


RE: Change "visdimopacity & visdim" - Daniel - 15.06.2020

It is full script, Set 'visdim', 0 to turn it off


RE: Change "visdimopacity & visdim" - tassiebean - 16.06.2020

(15.06.2020, 11:59)Daniel. Wrote: It is full script, Set 'visdim', 0  to turn it off
Thank you for your reply. It seems to me that the browser needs to be refreshed for this to take effect. Is that right? Can we make it immediate (not requiring a refresh)?

I have the following code:
Code:
-- Set screen dimming on/off

require('uci')

if (event.getvalue() == true) then
  log('Auto dimming on') 
  uci.set('genohm-scada', 'core', 'visdimopacity', 80)
  uci.set('genohm-scada', 'core', 'visdim', 1)
 
else
  log('Auto dimming off')
  uci.set('genohm-scada', 'core', 'visdimopacity', 80)
  uci.set('genohm-scada', 'core', 'visdim', 0)
 
end

uci.commit('genohm-scada') 

I trigger this script with a toggle button on a Visualisation screen. While it works, it does need a refresh, so my question above remains. Can we make it take effect immediately?

Thanks!


RE: Change "visdimopacity & visdim" - Erwin van der Zwart - 16.06.2020

Hi,

The changes are made server side and the client (browser) has no clue that that was done, so you always need to refresh..

Here is a custom JS to refresh to browser from server side (needs to be loaded so 1 refresh is needed after adding the JS)
Code:
$(function(){
  if (typeof grp != 'undefined') {
   grp.listen('1/1/1', function(object, state) {
     if (state == 'value') {
         location.reload();
     }
   }, true);
  }
});
Change 1/1/1 to the same address that triggers the uci update

BR,

Erwin


RE: Change "visdimopacity & visdim" - tassiebean - 16.06.2020

Hi Erwin,

Thanks you for your quick response and explanation. I implemented this (changing the 1/1/1 to my script triggering address) and it all works as expected, with the observation that the page refreshes either 2 or 3 times, rather than just once. I can live with that, although it is curious.

Thanks!


RE: Change "visdimopacity & visdim" - Erwin van der Zwart - 16.06.2020

Hi,

Try removing “, true” on line 7

BR,

Erwin


RE: Change "visdimopacity & visdim" - tassiebean - 17.06.2020

Perfect! Thanks.