AnsweredAssumed Answered

Module DB PI Unit Search COM object trouble

Question asked by pmmcann on Jan 5, 2016
Latest reply on Jun 7, 2016 by pmmcann

I am writing a .NET Web API for mobile devices to communicate with our PI and SQL systems.

 

I have a get method that takes in some parameters, and attempts to search for Unit batches using the PiModuleDB.PIUnitBatchSearch.

 

I have created the modules and units in the module database and can search using the UI in PI System Management Tools to find the PIUnitBatches without issue.

 

When stepping through the resulting PiUnitBatchList after the search in my code however, I am not able to access any properties of the PIUnitBatch objects. In debug, I see only COM object threads that state the function evaluation requires all threads to run, and when I force it to execute, the resulting message is " the type name "PIUnitBatch" does not exist in the context PISDK.PISDK.

 

It is as if there is no access to the ModuleDB or the COM translation is in some way broken. I have a hunch it is due to how I am creating the connection tot he PI Server.

 

The PIServerConnection is an object of a class i created that handles cache, creating new ServerManagers, opening the connection to the PiServers, and storing the current server name for this instance of PI Server connection.

 

has anyone done PIUnitBatchSearch before in C# with the PI SDK? I also get similar results when trying to use the PIBatchDB.PIBatchSearch();

 

Other methods in the API work find when getting tag snapshots, creating tags, and modifying tag data.

 

Code below:

          

            PIModuleDB pmdb = PiServerConnection.ModuleDb;



            PIUnitBatchList unitBatchList = pmdb.PIUnitBatchSearch(userProvidedStart, userProvidedEnd);

            foreach (PIUnitBatch batch in unitBatchList)
            {
                string tempStart = Convert.ToString(batch.StartTime);
                string tempEnd = Convert.ToString(batch.EndTime);
                string batchID = batch.BatchID;

               ... 

            }

 

 

if anyone has created a web api to perform actions similar to this, please let me know what you did. Thanks!

Outcomes