Thinking about sumations

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:

  1. 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.
  2. Have each hour meter set to reset on 0 of that tag.
  3. 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,

I decided to set this up using a tag and reset the tag on success.
Now I’ve got the same setup but I’m looking at recording history to a database for 512 tags.

I had tried to setup a block group since I don’t think the number of items is going to change,

Here I’m looking at the 2 tables created by using the method above and the new table I’d like to look and function just like the motorrun table.
It seems like I’m locked into creating block items as table rows. Can I change this so it will be more manageable ?

Most modern databases aren’t good at handling table with many columns (on the order of a few hundred). The point of the Block Group is for handling cases like yours that would have too many datapoints to efficiently store them into columns. You can create a new column that is the name or number of the tag and then use that in your where clause to filter out the results.

If you really want each data point to be a new column, then you have to use the standard group. Beware using this method for more than 100 columns though, queries against it become very memory intensive.

Thanks for walking me through Transaction groups…
I think Ive got everything exactly how I wanted and I definitely appreciate the help.