Jiahui07

Problem creating PI Point with AFSDK 2.6

Discussion created by Jiahui07 on Sep 8, 2014
Latest reply on Sep 9, 2014 by Jiahui07

Hi, All,

 

I am trying to create PI point using AFSDK 2.6, but the following error pops out, can anyone help with this?

 
// Store the data back to PI Data archive
            IDictionary<string, object> myAttributes = new Dictionary<string, object>();
            myAttributes.Add("pointtype", PIPointType.Float32);
            myAttributes.Add("archiving", 1);
            myAttributes.Add("pointsource", "L");
            myAttributes.Add("datasecurity", "piadmin: A(r,w) | piadmins: A(r,w)");
            myAttributes.Add("descriptor", "Test");
            myAttributes.Add("displaydigits", 10);
            myAttributes.Add("engunits", null);
            myAttributes.Add("excdev", 50);
            myAttributes.Add("excdevpercent", 2.5);
            myAttributes.Add("excmax", 600);
            myAttributes.Add("excmin", 0);
            myAttributes.Add("instrumenttag", null);
            myAttributes.Add("location1", 0);
            myAttributes.Add("location2", 0);
            myAttributes.Add("location3", 0);
            myAttributes.Add("location4", 0);
            myAttributes.Add("location5", 0);
            myAttributes.Add("ptclassname", "classic");
            myAttributes.Add("ptsecurity", "piadmin: A(r,w) | piadmins: A(r,w)");
            myAttributes.Add("scan", 1);
            myAttributes.Add("span", 2000000);
            myAttributes.Add("typicalvalue", 100);
            myAttributes.Add("zero", -1000000);
            myAttributes.Add("compressing", 0);

            foreach(string tag in tags)
            {
                PIPoint myPIPoint = myPIServer.CreatePIPoint(tag, myAttributes);
            }

 I borrow some codes from the following links:

 

1) https://vcampus.osisoft.com/bloggers_place/b/andreas/archive/2012/06/28/af-sdk-some-code-snippets-for-the-osisoft-af-pi-namespace.aspx

 

2) https://vcampus.osisoft.com/discussion_hall/development_with_osisoft_sdks/f/8/t/4066.aspx

 

But it gives the error:

 
=================================================================
OSIsoft.AF.PI.PIException was unhandled
  HResult=-2146233088
  Message=[-30101] One or more Database operations failed.: See Data for details
  Source=OSIsoft.AFSDK
  StatusCode=-30101
  StackTrace:
       at OSIsoft.AF.PI.PIException.ConvertAndThrowException(PIServer piServer, Exception ex, String message)
       at OSIsoft.AF.PI.PIServer.CreatePIPoint(String pointName, IDictionary`2 attributeValues)
       at simuInterface.simuInterface.Main(String[] args) in c:\Users\jaso443\Documents\PI\Code\simuInterface\simuInterface\simuInterface.cs:line 75
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
===============================================================

 Thanks.

Outcomes