Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Counter

Got a good idea? You can suggest new features here.
nikus_v13
Posts: 11
Joined: Thu Sep 26, 2013 3:14 am
Location: Poland

Re: Counter

Post 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
nissse
Posts: 11
Joined: Wed Sep 08, 2010 2:13 pm

Re: Counter

Post 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
nikus_v13
Posts: 11
Joined: Thu Sep 26, 2013 3:14 am
Location: Poland

Re: Counter

Post by nikus_v13 »

I found a way to solve my problem but it is a long and complicated...
Attachments
Przechwytywanie.PNG
sintei
Posts: 26
Joined: Thu Oct 09, 2014 9:46 am

Re: Counter

Post 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!
sintei
Posts: 26
Joined: Thu Oct 09, 2014 9:46 am

Re: Counter

Post 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 :)
Post Reply