Combining inputs with an SQLTag expression

I’m trying to combine a couple of inputs using SQLTags. It’s the classic 2 signals (open and close) for a valve, from which I want to derive the value position.

For testing, I created 2 points named Input_1 and Input_2 as Boolean SQLTag DB points with Read/Write access. I then created another Int1 point (Valve_Position) with the following Expression:


From the documentation this should treat each input as bits in a binary number and return the decimal equivalent as an integer with a range of 0-3, depending on what the individual bits are set to.

However when I change the values of Input_1 and Input_2, the value of Valve_Position stays resolutely at zero. Am I doing something wrong?

I was able to get this to work exactly how you described. I was concerned at first because FactorySQL resolves the expression for a DB SQLTag whereas FactoryPMI resolves it in a Client SQLTag. Both worked for me as of 3.1.1. The Client Tag updated nearly instantly. The DB SQLTag update rate depends on the scan class.

DB SQLTagbinEnc({[.]Input_1},{[.]Input_2})
Client SQLTag


Are you sure that FactorySQL is running SQLTags? If you’re in an evaluation version, reset the 2 hour trial. When I stop FSQL, the quality of the “simple” DB SQLTags still show up as good, but the expression tag shows stale. The Client SQLTag still works fine with the DB Tag without the FactorySQL engine driving it. I suspect that FactorySQL may not be running SQLTags on your FPMI datasource.

I PM’d Al on the side and pointed him to a not-yet-released update which fixes a bug that may be causing his problem. He’s going to try it out on monday and see if that’s the problem.

Hi Colby,

That update has fixed the problem.

I have noticed another issue: I have the value of 2 Boolean DB points being combined into one integer value. If I change the scan class of one of the inputs, the combined value quality changes to ‘EXPRESSION_EVAL_ERROR’ until the input changes state - if I change the scan class of both inputs, both inputs have to change state before the combined value displays the correct value again.

As the data quality of both of the inputs is good, I think the value of the combined point should update immediately.

LOL - changing the scan class of an expression input gives a bad quality until that value changes - wouldn’t it still have the correct value? I can see it now - our factory’s broken! The value’s correct, but the overlay image is all wrong! Production must cease! What can we do!?!? Wait - did you recently change a scan class on the fly? Until a reboot or a value change, dependent object overlays will indicate an error!

Jokes aside, I’m impressed that you caught that! We could use more beta testers like you, Al.

Does it make sense that the expression on the DB tag worked for me? I don’t think I’m making that up…


I’ve the unhappy knack of being able to break anything. As the saying goes “I can find the cowpat in any field”. Also, this PC is so old and cluttered that it seems to accentuate any problems!

Here to help™ :wink:

Well, I did say “not-yet-released update”, I knew there’d be one or 2 more things we could throw in before the release.

I think the situation you’re describing is understandable, considering how tags get updated, reloaded, etc. It’ll be fixed soon…


Out of curiosity, what is the rate of the scan class you’re switching to? While not agreeing with the outcome here, I’m kind of thinking that this isn’t so much a bug as it is undesired behavior…

Here’s what happened in my case:

  1. Scan class of tag modified, tag now “Unknown” quality
  2. FSQL loads tag change. Current value is NULL/Unknown
  3. The expression tag running in faster scan class executes, errors out because the sub tag’s value is unknown.
  4. Slower scan class runs, faster scan class runs, everything is fine.

So, the main question for you is whether everything is fine after both scan classes run (I’ve used the terms faster/slower, but the rates don’t matter too much).

The question becomes: what’s the correct procedure? Should an expression’s value be good even if one of its sub tags isn’t? Probably not. And how can the sub tag’s value be good if it’s never been evaluated, because the SC hasn’t run yet? Even though the value is “correct” in the database, after modifying the tag it may as well be a brand new tag to factorysql.

Anyhow, let me know if this is in line with what you’re experiencing, and we can go from there.



I’ve the unhappy knack of being able to break anything. As the saying goes “I can find the cowpat in any field”. Also, this PC is so old and cluttered that it seems to accentuate any problems!

Here to help™ :wink:[/quote]

I think i seem to have the same problem Al

Oh yes, you two are definitely somewhere near equal on your uncanny ability to run into seemingly every bug we have :smiley:

I don’t know, maybe we should keep track and hand out end-of-the-year awards…


The latest fix (FactorySQL_Upgrade_4.1.2_b1111) works well - the combined point is now refreshed at its scan rate, which makes sense.

As regards awards, an all-expenses paid visit to let you have the benefit of my ability personally would fit the bill well. Carl tried to say Sacramento was cold but we’ve all seen Baywatch, we know how you live… 8)

Haha, just for that, we should bring you out here. My, how you will be dissapointed, holding Baywatch up as your California ideal!

Dont even start to complain about your temperature. I quarantee i got any of you beat :smiley:

Fair enough, I won’t complain. But there still aren’t any bikini-clad women in rollerskates around here, contrary to popular belief!

Seoul’s a bit funny. It “snowed” as lightly as I’ve ever seen snow. It’s not that cold, but it hovers around 0C here. Check out the bottom picture of my most recent blog post. Korean girls bring out the mini-skirts and boots when it gets cold. I’m told they don’t dress like that in more mild weather.

Im safe now, but when i first started doing instrumentation, i remember bending stainless steel tubing in -45C(-49F) weather. But this winter has been mild, only got to -25C

Oh the pain! I was out today in shorts and a t-shirt. It was right around 0C. I didn’t get cold since I’d just finished working out, but that’s definately cold enough for me!