rdavin

Free App - AF Demo With Timings !!!

Discussion created by rdavin Employee on Mar 20, 2015
Latest reply on Mar 24, 2015 by rdavin

Free app here!  Get your free app here!

 

This post contains an attachment to Visual Studio 2013 Project Source Code.  The download link is at the bottom of the post. [EDIT: Version 2 was attached that cleaned up some bad code.  I discuss in my reply below dated March 24, 2015.]

 

Fellow PI Geeks - I wrote a Winform app that has a lot of goodies in it!  There’s stuff for developers of all skill levels: entry-level, intermediate, and advanced.  There’s some nice AF best practices stuff plus a couple of AF tricks that I discovered. There’s even many good .NET and UI tricks thanks to awaiting many async tasks.


TL; DR;

 

If you think the post is too long and don’t want to read it, just jump to the bottom to download the attachment containing the entire project.  Also close to the bottom are links to other project(s) you may want to check out.

 

FEATURES

 

Granted PISystemExplorer has many of these features for you to look at info, but this app provides the source code so you fetch the info in your own programs.

 

Entry-level Developers can use this to:

  • See how a PISystemPicker and AFDatabasePicker can be linked together.
  • See how to detect what AFSDK client version you are running under.
  • See info about your .NET environment.
  • See info about a PISystem and list the Data References being used.

 

Intermediate Developers can:

  • See how to get quick counts to database objects.
  • See exactly which items are checked-out! (Seriously that’s worth the price of admission.)

 

Advanced Developers, there’s an entire tab for you, the [Walk Down] tab with an insane amount of code to drool over:

  • How to find and load elements in bulk using a background task.
  • (Cool Tip!) How to load elements twice as fast by using parallel chunking.
  • (Best Practice!) The fastest way to see if an AFAttribute uses the “PI Point” data reference.
  • (Best Practice!) How to extract the PI Point name from an attribute.
  • (Cool Tip!) How to validate PIPoints for a large number of attributes.

 

General .NET and Winform UI Tips

 

Beyond AF, there’s plenty to learn from about .NET, Winforms, and general UJ:

  • Using a Console.Beep() (hey, it was new to me!)
  • How to use a BindingSource to easily populate a data grid view.
  • Awaiting async tasks so that the UI remains responsive.
  • How to hide or show a TabPage on a TabControl.
  • How to use Parallel.ForEach.
  • How to use a range partitioner with Parallel.ForEach to process in more manageable chunks.  Or as I call it, “Lose wait now, ask me how!”

 

Special Feature – Checked Out Items

 

Sometimes I just want to know if a database has items checked out.  But other times I want to know what items are checked out by who since when.  An example is provided in this app, although obviously your database must have items that are checked-out to see this feature.  Otherwise it would be like looking for a solar eclipse in the middle of the night.

 

The [Checked Out] tab:

 

CheckedOut.png

 

Snapshot: Data References

 

DataReferences.png

 

 

Snapshot: Quick Counts

 

QuickCounts.png

 

 

Walk Down Example

 

You may choose a Bulk LoadElements or Parallel.  The only difference is what appears in the gray shaded cells.  This example used Bulk:

 

Timing

Comment

 

AF Server 'RickAF'

 

Database  'Rick Database'

 

Issuing elements = AFElement.FindElements.

00:00.6

Found 2588 elements.

 

Issuing Bulk AFElement.LoadElements(elements).

00:11.1

Bulk LoadElements Completed.

 

Counting PI Point attributes.

00:01.4

PIPoint Counting Completed.

 

  Ⱶ̶—> Total  Attributes = 604787

 

  Ⱶ̶—> PIPoint Attributes = 213569

 

Fetching PI Point Tag Names.

00:38.3

TagName Walk Down Completed.

 

  Ⱶ̶—> tagnames.Count = 213569

 

  Ⱶ̶—> First Name: \\RickPI\alpha

 

  Ⱶ̶—> Last  Name: \\RickPI\omega

 

Validating Actual PIPoint(s).

00:49.5

Validation of PIPoint(s) Completed.

 

  Ⱶ̶—> points.Count = 198212

 

  Ⱶ̶—> Mismatch!

 

  Ⱶ̶—> Expected  PIPoints = 213569

 

  Ⱶ̶—> Validated PIPoints = 198212

 

Here’s just the Parallel section from another run on the same database:

 

 

Issuing Parallel AFElement.LoadElements(elements).

00:05.7

Parallel LoadElements Completed.

 


But, Wait, There’s More!

 

You even get a chance to read this nifty disclaimer!

 

*****  N O T I C E *****

THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,

EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES

OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.

 

Other applications by Rick:

 

Laggy Network FindPIPoints

 

Tutorial: A faster way to get PIPoints from a large list of AFAttributes

 

DOWNLOAD VISUAL STUDIO PROJECT FILE HERE:

Outcomes