# How is this possible

**URL:** <https://forum.inductiveautomation.com/t/how-is-this-possible/2851>\
**Category:** Ignition\
**Created:** [April 8, 2011, 6:59pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851 "2011-04-08T18:59:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 8, 2011, 6:59pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/1 "2011-04-08T18:59:36Z")

</div>

Attached is my time clock window. I have had 2 different people be able to punch in twice with no punch out. It should not allow them to do this. The button should not be enabled if they are allready punched in.  
[ClockWindow.vwin](https://us1.discourse-cdn.com/inductiveautomation/original/1X/01b551d6a1eb9384d1b9cc5693c062937943eeb6.vwin) (19.7 KB)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 8, 2011, 8:15pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/2 "2011-04-08T20:15:38Z")

</div>

I think the problem is they can press the button twice really fast before the query on the enabled button goes through. So try disabling the button in the first line of the script:`event.source.enabled = 0`Let me know.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 11, 2011, 1:26am UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/3 "2011-04-11T01:26:52Z")

</div>

These events where hours apart. I thought the same thing till I looked at the times.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 11, 2011, 12:23pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/4 "2011-04-11T12:23:30Z")

</div>

Had a couple today had to fix. Here is a screen shot’s of the records queried out in the table. When it gets to this point ( 2 records in table ) it will not let them punch in or out. I have not seen it yet where there where 3 records.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/9b8ab42b8332e8ff04339c7adf2e36e8162b357c.JPG)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/3623ce5dfb8e64db410ed3de1e3e9a61203b5887.JPG)

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 11, 2011, 12:41pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/5 "2011-04-11T12:41:50Z")

</div>

The “Enable” on the buttons was looking at a view in the database. I just changed that to look at the table itself. We will see if that helps. Is a view not re-queried every time it is needed?

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 11, 2011, 12:55pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/6 "2011-04-11T12:55:01Z")

</div>

> [@Travis.Cox](#):
>
> I think the problem is they can press the button twice really fast before the query on the enabled button goes through. So try disabling the button in the first line of the script:`event.source.enabled = 0`Let me know.

Travis,

Little confused here as both buttons are disabled until the sql query showed good one way or the other. Then the correct button would be enabled.

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [April 11, 2011, 1:32pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/7 "2011-04-11T13:32:34Z")

</div>

Just a thought, but I would also add a print statement in the button event script that contains any relevant information, including a time stamp. As long as Java logging is turned on, you can look at the logs afterwards. That might help.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 18, 2011, 11:20pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/8 "2011-04-18T23:20:01Z")

</div>

Travis we are going to have to look into this more. I am heading home from vacation but was told it is doing it still.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 20, 2011, 5:13pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/9 "2011-04-20T17:13:13Z")

</div>

While on vacation they 1 user managed to get punched in 3 times with no punch outs. I copied the data to the test server before I fixed it in the live environment. Attached is a screen shot, times are not even close. I am puzzled ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

How does or will the Store and Forward come into play on this?

I am currently at 3.7 queries per second, which should not be anything. CPU load is 2-3%.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/3fc424508e0e10dc0b4dfacd3e135836bc758ffa.JPG)

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 25, 2011, 2:04pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/10 "2011-04-25T14:04:42Z")

</div>

We had the problem again late last week. I had to remove the duplicates over the weekend.

Over the weekend I brought Ignition up to the latest version. I also brought both the Ignition server and the database server Ubuntu software fully up to date. I forced everyone out of the systems and rebooted both servers.

Complete project is attached not sure if you would need just window. I did not make any changes to this at all. I talked with Dave in tech support last week, we made some changes to the polling which did not work. He to looked at the code and felt this should not be able to happen. I can provide more info if needed.  
[BDI\_Time\_Clock (2011-04-25).proj](https://us1.discourse-cdn.com/inductiveautomation/original/1X/59af9fb7e15b14619c8c19883d6dd7e886eeb9fe.proj) (65 KB)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 25, 2011, 10:51pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/11 "2011-04-25T22:51:29Z")

</div>

We are pretty puzzled right now as well. Dave and I have both looked into this issue. With the Enabled property of the Clock In button polling the only way to get duplicate records in the database is by clicking on the button in two different clients within 5 seconds of each other. You shouldn’t get two records so far apart.

Besides that, it is possible that you have staging and publishing set to manual and the clients out there are not at the current project. Maybe you need to publish your changes?

Do you have any database clustering setup?

You can add a print statement or a database logging statement in the clocked in button script that shows you the values of all dynamic properties in the window including the count(\*) queries value.

You can also run the count(\*) query in the button’s actionPerformed event and check that it is = 0. If not you can display a message and inform the operators to let you know when they get the message. If you don’t get the message it means they were able to clock in somewhere else (other than that specific button).

It seems we need to do some further investigation.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 26, 2011, 2:48pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/12 "2011-04-26T14:48:57Z")

</div>

I will answer a couple of the questions here.

Staging and Publish is set at auto, so that is out. We are not doing and clustering on the databases so that is out.

Here it is again today.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/0a22501614abc050114d1bad092678054badbbb4.JPG)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 26, 2011, 2:55pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/13 "2011-04-26T14:55:10Z")

</div>

I know, we are shooting in the dark a little. Like I said, the only thing we can do here is add some extra code to the clock in button to see whether or not someone is able to press it when clocked in.

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [April 26, 2011, 7:02pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/14 "2011-04-26T19:02:20Z")

</div>

The second and third entry look like they are due to a double click on the button, however I don't know why they were even allowed to clock in because the button should be disabled.

To prevent the double click problem you can disable the button at the beginning of of the button event script. As for why they are able to clock in several hours apart without clocking out is still a mystery.

You should add a double check on the actionPerformed event of the clock in button that checks again to see if the person is clocked in already without a clock out time and if they are then just exit the event script without doing anything and popup a message box or log something in a file somewhere that says that someone was able to push the button when they shouldn't have been allowed to.

That's probably the next best place to start. If that popup box never appears then that would mean that there is another query somewhere that is inserting a record into that table, either within ignition or from somewhere else that has access to the database. This is quite strange indeed.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 27, 2011, 11:58am UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/15 "2011-04-27T11:58:18Z")

</div>

Mike, Dave and Travis,

We did get one to show up over night in the table. The first shows they must have went through process again and it worked, just a few seconds difference. ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/71ecaa72b87bdb5ed9283bb532d467a99bfe7e59.JPG)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2e42ea15b0d9a0836063190df062556453e07647.JPG)

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 27, 2011, 5:28pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/16 "2011-04-27T17:28:58Z")

</div>

Mike,

Here is an upload of the project after the changes we made yesterday. Looks like we are going to need some input from developers here.  
[BDI\_Time\_Clock (2011-04-27).proj](https://us1.discourse-cdn.com/inductiveautomation/original/1X/57621ce1b79f5367117629a4873408caba9cbd74.proj) (72.5 KB)

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [April 27, 2011, 5:44pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/17 "2011-04-27T17:44:08Z")

</div>

Add this in as the first line of the clock in button event script:

```python
event.source.enabled = 0
```

That will ensure that we won't be getting any entries due to the employee pressing the clock-in button twice quickly because we will be manually disabling it at the get go. Then we will be able to see if we are still getting those rare multiple clock ins that are hours apart.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 27, 2011, 6:11pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/18 "2011-04-27T18:11:53Z")

</div>

Dave,

Here is the sql code for the tables.

[code]CREATE TABLE `tbl_timeclock` (  
`id_timeclock` int(11) NOT NULL AUTO\_INCREMENT,  
`id_employee` int(11) NOT NULL,  
`clockin` datetime DEFAULT NULL,  
`clockout` datetime DEFAULT NULL,  
PRIMARY KEY (`id_timeclock`),  
KEY `fk_employees_timclock` (`id_employee`) USING BTREE,  
CONSTRAINT `fk_employees_timclock` FOREIGN KEY (`id_employee`) REFERENCES `tbl_employees` (`id_employee`) ON UPDATE CASCADE  
) ENGINE=InnoDB AUTO\_INCREMENT=32383 DEFAULT CHARSET=latin1 ROW\_FORMAT=COMPACT;

CREATE TABLE `tbl_employees` (  
`id_employee` int(11) NOT NULL AUTO\_INCREMENT,  
`id_company` int(11) NOT NULL,  
`clocknumber` int(11) DEFAULT NULL,  
`pinnumber` int(4) unsigned zerofill DEFAULT NULL,  
`fname` varchar(15) DEFAULT NULL,  
`lname` varchar(15) DEFAULT NULL,  
`active` tinyint(4) DEFAULT ‘1’,  
PRIMARY KEY (`id_employee`),  
UNIQUE KEY `NoDups` (`clocknumber`,`pinnumber`) USING BTREE,  
KEY `fk_companys_employees` (`id_company`),  
CONSTRAINT `fk_companys_employees` FOREIGN KEY (`id_company`) REFERENCES `tbl_companys` (`id_company`) ON UPDATE CASCADE  
) ENGINE=InnoDB AUTO\_INCREMENT=503 DEFAULT CHARSET=latin1 ROW\_FORMAT=COMPACT;[/code]

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [April 27, 2011, 6:30pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/19 "2011-04-27T18:30:28Z")

</div>

So like we talked about on the phone, just add the button's enabled property value to the insert query. You can get that value and assign it to a variable like so:

```python
enabledVal = event.source.enabled 
```

Then you just insert enabledVal along with the rest of your items in the insert query. If we see a 1 (or 'true' maybe) being written then that means that the button is somehow enabled but the query that is setting the enabled property is returning false.

The good news though is that with that extra check inside the script you are no longer actually getting multiple clock in's with no associated clock out's written to the database.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [April 28, 2011, 12:51pm UTC](https://forum.inductiveautomation.com/t/how-is-this-possible/2851/20 "2011-04-28T12:51:53Z")

</div>

Dave,

I did not get it put in yesterday. It is in now. We had a few more records added to table last night and from different IP addresses so not machine specific.

Good news is we were not using it to control a machine and broke something.

[Next page](https://forum.inductiveautomation.com/t/how-is-this-possible/2851.md?page=2)
