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

    Recent Gotchas

    I have been buried in a System Platform project for several months now & finally have a moment to surface.  I ran into a few things that caused me a few headaches and am documenting them here to hopefully save everyone some time.


    1) DASABCIP & Optimize For UDT

    This project I’ve been on was using ArchestrA 2012 with an AB CompactLogix L45 (Rev 19).  We’ve got AOIs that match 1-to-1 with templates, etc.  One of the newer features in RSLogix is the ability to set an attribute’s external access level.  In our AOIs, we set some things to “None”, some to “Read only”, and some to “Read/Write”.  As it turns out, having a parameter with “None” did not play nicely with the “Optimize User Defined Data Types” checkbox.  Since it’s been 4 months since I found this & left myself a cryptic note to blog about it, I decided to verify this today.  For the AOIs with an attribute with an external access of “none”, none of the attributes could be read or written.  You get a series of errors in the SMC actually (Ends with: Failed to add block <04a692a0> with base name TEST_Tag.XYZ in CIP_Port.Test_PLC_ENBT.Test_PLC_BP.Test_PLC_CLX, tag does not exist in the PLC or the tag or some of it’s UDT members is configured for External Access=None in the PLC).  The solution was to uncheck the “Optimize User Defined Data Types” checkbox.

    2) Field Attributes

    Also discovered something weird with field attributes in a template that are getting their IO assignment via scripting AND the “Output destination differs from input source” checkbox is UNCHECKED.  The values were reading in just fine, but writes would not work.  Apparently, this is a known issue with field attributes and you need to set the OutputDest anyway.  I have verified this in testing (IAS 2012 P01).

    3) AAPKG Import

    I was importing some templates from another galaxy using aapkgs.  The template is fairly complex and script execution order mattered for speed reasons.  As an organizational scheme, I named the scripts in a way that they would sort in the IDE in the same order I intended them to execute.  On a whim, I decided to check the script execution order after the import.  The scripts were all out of order.  My best guess is that they imported in the original order of creation (essentially by some identity column number from the galaxy DB).

    4) For Loops

    We’ve got a lot of ArchestrA code that gets a dataset from a database, retrieves the size of the dataset, and then iterates the dataset row by row.  The problem is that unlike every other For instruction in the world, the ArchestrA For instruction tries to guess which direction to increment if the “Step #” is omitted.  Note:  I haven’t actually verified all of the other programming languages in the world.  Most For instructions default to +1 as an increment when omitted.  The ArchestrA one will default to +1 OR –1 depending on the direction from the starting variable to the ending variable.  Seems rather innocuous until you do something like the snippet below & your code starts bombing out when the end variable (i.e. Count) equals 0. 


    Count

    =

    SomeObject.Count;
    For i = 1 To Count
        ‘ Do Something
    Next;

    So you end up having to wrap all of your For loops in if statements like this:

    Count = SomeObject.Count;
    If (Count > 0) Then
       
    For i = 1 To Count
            ‘ Do Something
        Next;
    EndIf;

    I’m sure they did it that way to prevent infinite loops, but it’s still a pain in the…

    5) Popup Graphics

    I had a few ArchestrA graphics that were only called via scripting like the example below.


    Dim

    graphicInfo As aaGraphic.GraphicInfo;
    Dim cpValues[2] As aaGraphic.CustomPropertyValuePair;

    ‘ Set the input parameter values
    cpValues[1] = new aaGraphic.CustomPropertyValuePair("Command", "YesNo", True);
    cpValues[2] = new aaGraphic.CustomPropertyValuePair("Message",
       
    "Are you sure you want to delete this?", True);

    ‘ Setup the popup graphic properties
    graphicInfo.Identity = TempName;
    graphicInfo.GraphicName = "Me.gr_MessageBox";
    graphicInfo.Resizable = False;
    graphicInfo.HasTitleBar = False;
    graphicInfo.WindowType = 1; ‘ 0 = Modal; 1 = Modeless
    graphicInfo.WindowRelativePosition = 1; ‘ 1 = Window
    graphicInfo.WindowLocation = 0; ’0 = Center
    graphicInfo.CustomProperties = cpValues;

    ‘ Show the popup graphic
    ShowGraphic(graphicInfo);

    When I made changes to theses graphics that were only popped up via scripting, those changes didn’t deploy out.  What I realized was that the system didn’t know these graphics were even used by the system.  I understand it would be an incredible pain to have to troll through all of the scripting to figure out what graphics are used dynamically.  My workaround was to include a hidden (invisible) element on one of my graphics that called the popup in the traditional fashion.  This provided the system with a reference to indicate that it should be deployed out.  My invisible element was a piece of text that said “Do NOT delete this or else certain popups will not be deployed out.”

    6) Animation Copying

    This isn’t a gotcha, but a new feature one of my colleagues showed me the other day.  At least I think it’s new.  I certainly haven’t noticed it before if it isn’t new.  You can copy & paste animations from one ArchestrA graphic element to another.  That’s a great time saver.

    image

    9 Responses to “Recent Gotchas”

    1. jdb says:

      Animation copying – halleluia!

    2. Dan Wilson says:

      The ShowGraphic feature is pretty cool when it works. I love being able to display/hide a graphic via symbol scripting. We’re fighting with the new Associate Galaxy Graphics option on a managed application right now. This appears to be a new gotcha too!

    3. Richard says:

      I am pretty new to this but has anyone seen any samples on how to enumerate printers inside system platform?

      we want to do a print screen – usually in Intouch use the PrintScreen function? and set up printer to print to as default.

      How can this be done in system platform any help apprieatiated

      • Andy Robinson says:

        The magic potion for making this happen is WMI.

        First, take a read to figure out how to use WMI to work with printers.
        http://msdn.microsoft.com/en-us/library/windows/desktop/aa394598(v=vs.85).aspx

        The next question is how do you use WMI from System Platform. Below is a really quick snippet I took from something we’ve done to query the status of services. Hopefully this will give you a jumpstart on your work.

        Dim MOS as System.Management.ManagementObjectSearcher;
        Dim MS as System.Management.ManagementScope;
        Dim MOC as System.Management.ManagementObjectCollection;
        Dim MO as System.Management.ManagementObject;

        ‘Create objects
        MOS = New System.Management.ManagementObjectSearcher();

        ‘ Update path name
        ‘ Make a connection to a remote computer.
        ‘ Replace the “FullComputerName” section of the
        ‘ string “\\FullComputerName\root\cimv2″ with
        ‘ the full computer name or IP address of the
        ‘ remote computer.
        If UseLocal Then
        MS = New System.Management.ManagementScope(
        “\\localhost\root\cimv2″);
        Else
        MS = New System.Management.ManagementScope(
        “\\” + Me.MachineNameToUse + “\root\cimv2″);
        EndIf;

        ‘ Initiate connection of ManagementScope object
        MS.Connect();

        ‘ Setup the WqlObjectQuery’s query string
        MOS.Query = New System.Management.WqlObjectQuery(
        “SELECT * FROM Win32_Service WHERE Name = ‘” +
        Me.ServiceName + “‘”);

        ‘ Assign ManagementScope object to ManagementObjectSearcher
        MOS.Scope = MS;

        If Me.Debug.Level > 4 Then
        LogMessage(“Begin read of frequent Management Object Searcher properties”);
        EndIf;

        ‘ Create the ManagementObjectCollection by
        ‘ initiating the ManagementObjectSearcher’s query
        MOC = MOS.Get();

        ‘ Iterate through each ManagementObject object
        ‘ in the ManagementObjectCollection
        For Each MO In MOC
        ‘ Get & store process ID
        Me.ProcessID = System.Convert.ToInt32(MO.Properties["ProcessId"].Value);

        ‘ Get the start mode & store to temp variables
        StartMode = System.Convert.ToString(MO.Properties["StartMode"].Value);

        ‘ Finalize the current ManagementObject object
        MO.Dispose();

        ‘ Ignore any other services with the same name.
        Exit For;
        Next;

        ‘Finalize all other objects
        MOS.Dispose();

    4. Myles Morris says:

      Cheers for the test on aapkg import script order.
      Yep the Outputdest has been an issue since 1.0, I’ve always banged it in there. (InputSource all then copy/paste).
      Copy animation has been around since 3.0 – saved me heaps of time. Hold the shift key down to past animation to multiple graphics.

    5. Hey thanks for posting that. I have seen a few of these, but the ‘For loops’ gotcha got me the other day. Now I understand why. I was helping a colleague and we seemed to be getting an output from a loop that shouldn’t execute. I now realise that we were effectively writing

      For X = 1 to Y

      when Y was 0. We expected 0 iterations and were getting 1.

      With graphics called only by scripts, we usually usually set the Associate Galaxy Graphics switch on the App to avoid the problem altogether, then all graphics are deployed even if ArchestrA can’t see where you use them.

      This is fine for us as we only have one HMI App template, so if a symbol is in the galaxy it should be needed.

      Just migrating to 2012 R2 at the moment and I have found a new gotcha.

      I configure symbols when they first appear (often with an OnShow script), but some of that code was written assuming it would only execute once. In R2, when you close an ArchestrA symbol it stays in memory. The next time you use it, the custom properties no longer have their default values. You need to re-initialise them unless you can live with the old values

      Peter

    6. ken says:

      Anyone have the cannot communicate with target platform – and get stuck not being able to deploy an object or group of objects ? I have had this happen twice! The first time I deleted a small object and things went back to working – the second time I am still working on it.

      • Have you remembered to check the bind order of your NIC’s. I confess to forgetting this last week! How embarrassing!

        • Ken says:

          After performing some checks we determined the Galaxy DB was corrupted . Some particular objects would never deploy , yet others did just fine. Fortunately the project was nto that large and we were able to salvage at least the graphics and the code. From now on the BKU’s are done frequently and at the DB level . That NIC binding order thing is one of those things that gets me about WW – seems that the access method being used for those NIC via IAS is flawed, but I guess they have a reason. I have had experience with other real time systems operating at speed communicate well without regard to what order the NIC cards were bound in. I had that issue with regards to the InTouchViewer aargh. What happens in that Chinese Railway Project.. Hmmmm seems a hacker has a simple slam..hmmm.

    Leave a Reply