RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About ArchestrAnaut Blog
  • About Our Authors
  • Email Subscription
  •  

    Notes on Quality

    July 27th, 2011

    I have a couple notes on quality to share.  Not code quality or manufacturing quality, but OPC quality.  For a quick read & good background on how the OPC quality integer is constructed, read this.  I needed a couple SQL functions that mirror the IAS quality checking functions.  FYI, for those that don’t know, there are 5 of these functions:  IsGood, IsBad, IsUncertain, IsInitializing, & IsUsable.

    Here’s a somewhat abbreviated run down of how the OPC quality number is constructed.  An OPC quality is made up of 4 chucks: extended status (vendor specific; 1 byte), major status (good, bad, or uncertain; 2 bits), minor status (based on the major status; 4 bits), and limit status (is it clamped or not; 2 bits).  For each major status, there are 16 available minor statuses possible (0-15) though only the first 8 are defined.

    I ran a quick test to reverse engineer the IAS functions (see script at bottom of blog).  What I found was the following:

    Major Minor IsBad IsInitializing IsUncertain IsGood IsUsable
    0 0-7 True False False False False
    0 8-15 False True False False False
    1 0-7 False False True False True
    1 8-15 True False False False False
    2 0-7 True False False False False
    2 8-15 True False False False False
    3 0-7 False False False True True
    3 8-15 True False False False False

    To summarize the table, it looks like they appropriated part of the bad quality range (major = 0) for initializing which makes sense.  Though you could argue that there was already a status defined for this scenario (Not Connected:  Major = 0, Minor = 2).  Major status 2 isn’t used anywhere, so it got lumped into Bad, which also makes sense.  The minor statuses 0-7 for Good (Major = 3) and Uncertain (Major = 1) work as expected, but 8-15 got lumped into Bad.  I know they’re not defined, but they’re still part of the Good/Uncertain major status.  Glad I ran the test.  Maybe this is different in later versions (the tested version is 3.0 SP2).  The final observation is that IsUsable checks the quality for Good or Uncertain as well as checking the value is also a valid value (i.e. not NaN).

    The test script:
    (The one interesting note here is that you can write directly to the UDA.Quality attribute, which could be useful if you’re doing something fancy surrounding the data’s quality.)

    Dim i as Integer;

    Log header row
    LogMessage("Value,Quality,IsGood,IsBad,IsUncertain,IsInitializing,IsUsable");
    Iterate through all of the possible OPC qualities
    For i = 0 to 255
        ‘ Force the PV quality
       
    Me.PV.Quality = i;
       

        ‘ Log data row for the quality
        LogMessage(
           
    Me.PV.Value + "," +
           
    Me.PV.Quality + "," +
           
    IsGood(Me.PV) + "," +
            IsBad(
    Me.PV) + "," + 
           
    IsUncertain(Me.PV) + "," +
            IsInitializing(
    Me.PV) + "," +
            IsUsable(
    Me.PV));
    Next;

    ‘ Log message for end of test
    LogMessage("——————-");


    Bug in Alarm DB Purge/Archive Utility

    July 25th, 2011

    I found a “feature” in the Alarm DB Purge/Archive utility last week.  The password entry box will only accept 9 characters.  So, if the password for the account is longer than that, you’re out of luck.

    image


    Splitting a CSV into an IAS Array

    July 25th, 2011

    A fairly common activity if you are interacting with external systems is to exchange data with the external system via a CSV.  The primary reason people do this is to avoid having to create a large number of registers or data exchange elements for an unknown quantity of values. 

    Think about the following simple example.  Say you have a robot stacking boxes on a pallet.  For each job the robot does it has a list of legal boxes that can go on that pallet.  The data from your MES system might look like this.

    J1234, L1, L2, L3, L4

    This string may be saying a new job is “J1234”, and the list of acceptable lots/boxes that can go on this particular pallet is “L1, L2, L3, L4”

    One approach might be to run down the string character by character, peeling off characters and sticking them in some holding register then doing something with that value when you get to a delimiter.  It works but it’s really inefficient and quite messy.

    Regular expressions to the rescue!

    The first thing you need to figure out is how to write a regular expression to pick apart a CSV.  I’ve seen, and used, about 10 different approaches but I’ll start you off with the most simple one.

    [^,]+

    According to my trusty RegexBuddy explanation tool here is a technical explanation

    Match any character that is NOT a “,” between one and unlimited times, as many times as possible, giving back as needed (greedy)

    In english that means match all the characters up until you find a comma.  It doesn’t matter if it’s one comma or multiple commas.  Then start your next match when you find the next non-comma.  What’s neat about this approach is that you don’t have to worry about skipping over blanks.  It works automatically.  If you did care about blanks you could use a ? in place of the +.  This indicates you only want 1 match at a time.  Play with your favorite regex design tool (my favorite is Regex Buddy) and see what you get.

    So, on to the actual code.  It’s pretty short and commented so I’ll just do a dump here.

    ‘Dimension your variables

    Dim RegexObj as System.Text.RegularExpressions.Regex;
    Dim MatchResults As System.Text.RegularExpressions.MatchCollection;
    Dim Match As System.Text.RegularExpressions.Match;

    Dim Index as Integer;

    ‘Setup the Regular Expression with the configured Regex
    RegexObj = New System.Text.RegularExpressions.Regex(Me.Regex,System.Text.RegularExpressions.RegexOptions.IgnoreCase);

    ‘Use the regular expression to compare against the CSV
    MatchResults = RegexObj.Matches(Me.csv);

    ‘Redim the array to match the number of results
    Me.Array.Dimension1 = MatchResults.Count;

    ‘Loop through the matches and copy them into the array
    for each Match in MatchResults[]
         
    Index = Index + 1;
         
    Me.Array[Index] = Match;
    next;

    One of the neat tricks you’ll see is that I redim my array on the fly to the count of actual matches.  One piece of code I left out was clearing the array before populating it, but that is really oustide the scope of what we’re doing here.

    Another option you could use is the .Net split function or the Regex split functionality.  Either way there are lots of options for splitting CSV’s so try out a few and figure out what works best for you.

    - Andy


    OpsManage 2011 Call For Papers

    July 14th, 2011

    The call for papers has gone out!  Actually the site has been ready to receive abstracts for a week or so now.  I submitted my abstract a couple nights ago.  I’m planning on talking about the two or three best or most popular posts from the blog.  I might also get a little irreverent and ask some open questions like when is this coming, is this in the roadmap, why is this taking so long… not unlike the character you find here on the blog.

    To be fair the submissions haven’t been reviewed so I have no idea if I’ll actually be accepted or not.  I’ll keep my fingers crossed… and maybe try to bribe a few people on the inside.  Just kidding, I’d never do that publicly.

    Here’s the email I got with the call.  You should be able to follow the links.

    Call for Presentations: Now Live!

    Call for PresentationsDo you have a success story resulting from Invensys Operations Management products and solutions?  Would you be interested in sharing your milestones with conference attendees?
    Here’s your chance to submit your presentation abstract.

    If your abstract is selected, you will get the opportunity to share your experience by presenting at this year’s OpsManage’11 conference series.
    This year’s conference will focus on the four key areas of Operational Excellence: Control, Asset, Environment & Safety, and People.   Your experiences and results within these four categories (one or all of them!) will be shared with our attendees and management, as well as industry analysts and media.

    The Call for Presentations website is now open.
    Deadline for all abstract submittals is August 26, 2011.


    Good Article on some Checkpointing Nuances and China Rail

    July 11th, 2011

    I think any good App Server engineer needs to learn about checkpointing.  It’s such a critical piece of how App Server does what it does that you can’t simply be ignorant of it.  Fortunately it works so well that most people never have to troubleshoot it… as opposed to troubleshooting why you can’t get communications with a platform to deploy something.

    Here’s an article that came out a couple days ago that discusses some instances where the checkpointing system may not act appropriately, or at least how you think it should.

    Mash Here

    The second article discusses the success of using App Server on the High Speed Chinese Rail project.  I haven’t had  a chance to read it yet but I expect it will be really good.  I think anytime someone tries to tell you App Server can’t scale you can point to this as published evidence of the fact that it can.

    Mash Here


    The Sneaky DCOM Enable Checkbox

    July 8th, 2011

    So I (we) haven’t written anything in a while.  Sorry about that.  I was away on vacation on the beautiful upper panhandle of Florida.  Anyone who says these aren’t the most spectacular beaches in the world obviously hasn’t seen the sand that’s so white it’s almost blinding and a consistency somewhere between salt and sugar.. just amazing.  Anyway, my partner in crime, David, is off for two weeks in Yosemite hiking up Half Dome and gosh knows where else.

    On to the topic at hand.  A couple weeks ago we had an issue where no matter what we did we could not deploy a platform to an ill functioning app server node.  It had been pretty sick after a nasty virus infection and we were ready to straighten everything out.

    The key symptom was an error message that told us the deployment activity couldn’t get the “version interface from the remote bootstrap”.  First thing I do is check to make sure that the aabootstrap service exists and is running.  This service is the a core piece of everything you do in App Server.  Use the following command line to check on it if you don’t like to open the services.msc console.

    sc query aabootstrap

    Comes back that it exists and is running so that’s not the issue.  We check name resolution, networking, etc.  All are perfect.  Finally we give up and call tech support.  I get one of my favorite guys, Chuan He!  After talking for a few minutes we check in a very odd place, DCOM settings.  I’ve played around plenty with DCOM for cross machine and cross domain communications for OPC but never for App Server.  After digging through DCOM config we discover that DCOM is disabled on the computer.  DCOM is a bit of a foundational element for many many things in modern distributed SCADAs so if this isn’t running you’ve got big problems.  To find this setting go to Start—> Run –> dcomcnfg –> Component Services –> Right click on My Computer.  Your default properties page should look like this.

    clip_image002

    What we found was Enable DCOM was unchecked.  Could this have been a result of the Virus… maybe?  Or maybe it was something one of our many virus cleaners did to “protect” the machine.  Who knows but we were certainly happy to find it.  After checking the checkbox and verifying the other settings on this page we once again attempted to deploy the platform and this time it took off like a champ. 

    I’ve been doing App Server for about 6 years now and that’s the first time I’ve seen this.  Good to learn something new, bad that it had to cause so many problems.

    - Andy