Ah, yeah, it won’t work if the defaults are null. I had a thought that that might be the case, but was hoping for the best. In that case, you’ll either need to change the defaults, or have your insert query specify each column and a 0 value, which I know is a bit of work.
Do you need to reset each motor individually, or all together? Because here’s something I’ve worked out that seems decent, but would really be best if you were logging and resetting all of them at the same time:
- Create a “log and reset” SQLTag for the group (or if it was based on an expression, like time of day, it could just be an item in the group). It will be a boolean, or 0/1 integer.
- Have each hour meter set to reset on 0 of that tag.
- Have the group set to insert new records (and make sure your mode is opc->db), and have it set to trigger on that item, on 1, with “reset trigger” and “only execute once” enabled.
So, this works because the hour meter reset is only on the edge of the value change. When everything starts, the trigger will be 0, all hour meters will start at 0, and begin counting, according to their values. When you trigger it to log (the trigger tag goes to 1 for whatever reason), the group will log according to the trigger, and then “reset” the trigger by writing a 0. On the next execution, all of the items will see the 0 and reset the hour meters.
Setting this up for all of your motors shouldn’t be too bad, since you’re using the same settings for all of them. Bring them all into the group, then select them all, right click, and hit “edit”. You can multi edit them to set up the hour meter mode and reset condition. Be careful not to touch the “target” property, or you’ll wipe out the unique column names.
Hope this helps,