Page 2 of 2

Re: Counter

Posted: Mon Oct 14, 2013 4:13 pm
by nikus_v13
Hi I have another problem. I have two photoelectric barriers to count visitors. connected, for example, 1 and 2 buttons on the keyboard to do that after the termination of the first and then the second counter will count it as one and the opposite situation as -1. I tried to use jump to another macro enable and distable buttons clear pending events etc. but it did not work. Can you help me one mor time ?
https://www.youtube.com/watch?v=NFQXi-j_5nY control sample

Re: Counter

Posted: Tue Oct 15, 2013 2:24 pm
by nissse
Pako wrote:
nikus_v13 wrote:I want to make something like this: https://www.youtube.com/watch?v=M_X-KrfMF-4
and use eventghost to count visitors.
Yes, now I finally understand.
In this case, we do not need a new feature.
Similar things you can do using EventGhost for many years.
This can be solved in different ways.
Here you see one of them (you may need to add the Webserver plugin to your configuration):
Counter-demo.png
Here's a copy of that part of the tree (you can do copy / paste to tree):

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640">
    <Folder Name="Counter - demo" Expanded="True">
        <Macro Name="Webserver: Increment persistent value: visitorCounter" Expanded="True">
            <Event Name="Main.VisitorPlus" />
            <Action>
                Webserver.GetPersistentValue(u'visitorCounter')
            </Action>
            <Action>
                EventGhost.PythonCommand(u'eg.result=str(int(eg.result)+1) if eg.result is not None else "1"')
            </Action>
            <Action>
                Webserver.SetPersistentValue(u'visitorCounter', u'{eg.result}')
            </Action>
            <Action>
                Webserver.GetPersistentValue(u'visitorCounter')
            </Action>
            <Action>
                EventGhost.ShowOSD(u'{eg.result}', u'0;-48;0;0;0;700;0;0;0;0;3;2;1;66;Comic Sans MS', (255, 0, 0), (0, 0, 0), 1, (5, 5), 0, 0.0, True)
            </Action>
        </Macro>
        <Macro Name="Webserver: Decrement persistent value: visitorCounter" Expanded="True">
            <Event Name="Main.VisitorMinus" />
            <Action>
                Webserver.GetPersistentValue(u'visitorCounter')
            </Action>
            <Action>
                EventGhost.PythonCommand(u'eg.result=str(int(eg.result)-1) if eg.result is not None else "0"')
            </Action>
            <Action>
                Webserver.SetPersistentValue(u'visitorCounter', u'{eg.result}')
            </Action>
            <Action>
                Webserver.GetPersistentValue(u'visitorCounter')
            </Action>
            <Action>
                EventGhost.ShowOSD(u'{eg.result}', u'0;-48;0;0;0;700;0;0;0;0;3;2;1;66;Comic Sans MS', (255, 0, 0), (0, 0, 0), 1, (5, 5), 0, 0.0, True)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Pako
Hello

Is there any way to display this counter on a webpage using the webserver plugin instead of the OSD

Re: Counter

Posted: Wed Oct 16, 2013 5:42 pm
by nikus_v13
I found a way to solve my problem but it is a long and complicated...

Re: Counter

Posted: Tue Oct 21, 2014 6:34 am
by sintei
Hello,
I'm trying to use the persistent variables in the webserver.
And I can set a variable and see it in webserver plugin.
But how do I print/use it?
To be more specific, what's the commando in EG, ex eg.globals.mypersistentvalue does not work.
Cheers!

Re: Counter

Posted: Tue Oct 21, 2014 8:50 pm
by sintei
Still learning.. managed to understand "eg.results" better :)
so putting a persistent value is just using the action set persistent variable:
Set mypersistentvalue with value {eg.globals.myvariable}

Getting it back I had to use the "get persistent value" action and a little python script to put it back to my normal variable in the startup, OR when called upon by an event or whatever:
eg.plugins.Webserver.GetPersistentValue(u'mypersistentvalue', False)
eg.globals.myvariable = eg.result

Now my eg.globals.myvariable has the same variable as before a reboot of EG :)