Logging Boolean Tag

That's why you should past code in this forum as "preformatted text", with occasional exceptions to provide context. It helps us help you.

No, only retentive timers running the PLC count in this case, in my book, because Ignition won't roll over its own retentive timers. Not fit for purpose.

Ok so undo the retentive?
Sorry for my lack of knowledge. I know all this is pretty elementary. Thanks for helping me.

No, undo the "hour meter" selection. Use "direct value". Use that same value as the "any change" trigger. Separate transaction groups for each boolean status.

Then do "only execute once trigger is active? Then do another transaction group with the same thing but change it to "is !=0(or true) ?

Yes.

Perhaps you should review the various Transaction group training topics before we continue:

I went through transaction group videos and thats how i got what i had. Just struggling with it all.

We are aiming to get this:

This means two columns, t_stamp and someBoolean, in your database.

via this:

You said:

But that isn't what you have.

Start with just one machine's boolean status. Make a transaction group with this one item. Set the transaction group to record the timestamp, and be triggered by any change of the boolean.

Get that part working today. Check that every change of the boolean produces a row in the database.

Let it record all day tomorrow. We can resume Thursday.

ok sounds good. Thanks

What about BETWEEN?

BETWEEN uses >= and <=, that is, equality is a match at both ends. That requires that you subtract one millisecond from your end timestamp before passing it to queries. :frowning_face:

(Sadly, IA's historian uses BETWEEN, and therefore requires the one-millisecond end adjustment.)

If your timestamps in the DB have more than millisecond precision (lots of things have microsecond or even nanosecond timestamps), even the adjustment leaves open a tiny window for errors.

Learn to use half-open time intervals.

1 Like

@pturmel You have some time to continue this? I believe we have the data we're looking for now.

Sure. What brand of database is this?

@pturmel Standard group? Is that what you're asking?

No, is your database MySQL, MariaDB, MS SQL, PostgreSQL, Oracle? Something else? So I can offer SQL with the right syntax.

@pturmel MS SQL

Ok. Update your testing named query to have this:

SELECT *,
	LEAD(t_stamp) OVER (ORDER BY t_stamp) AS t_next
FROM ChargeTime
WHERE
	t_stamp >= (
		SELECT TOP 1 t_stamp
		FROM ChargeTime
		WHERE t_stamp < :startts
		ORDER BY t_stamp DESC
	)
	AND t_stamp < :endts
ORDER BY t_stamp

The nested query extracts the very last timestamp from before startts so that we can compute the truncated time from the startts to the t_stamp in the first actual row yesterday.

Make sure you pass yesterday's timestamp range. Please run in the Perspective view w/ table I recommended you create. Copy the dataset results (as CSV) to a preformatted text block here.

You will see that each result row has the time range for each run/stop interval.

"Copy the dataset results (as CSV) to a preformatted text block here."

Can you show me this please. I was thinking the data would be binded to the querie.