4 Replies Latest reply on Apr 15, 2019 9:19 PM by John Messinger

    Null values from PIDataPipe ListSignUpsByServer and AsReadOnly

    arikyudin222

      Hello guys,

      I'm struggling with AF SDK 2018 SP2 PIDataPipe class, where I'm trying to use register for snapshot updates using AddSignups method and then list the monitored PIPoints by the PI server.

      The problem is that while AddSignups method returns null as expected when there are no errors, AsReadOnly and ListSignUpsByServer always return the same null value, no matter what. While the expected values are IList<PIPoint>.

       

      I use the same pi data pipe to both register the pi points for snapshot monitoring and for listing the monitored pi points.

      Is there a working example of how to use this function or am I doing something wrong?

       

      Thanks,

      Arik

        • Re: Null values from PIDataPipe ListSignUpsByServer and AsReadOnly
          John Messinger

          Hi Arik,

           

          Can you please post a code snippet of your usage of these methods (including your code to show how you are instantiating the datapipe)? I am unable to reproduce this issue - I can retrieve a non-null point list using either PIDataPipe method.

            • Re: Null values from PIDataPipe ListSignUpsByServer and AsReadOnly
              arikyudin222

              Hello John,

              Thanks for your reply.

              I'll mention that my code is written in Python (3.6) the AF SDK 2018 is imported using Pythonnet library. Everything is working well, I'm able to poll snapshot updates, and archives, without any issues.

              Here is part of my code:

               

              class BaseAFWrapper:

                  _executor = ThreadPoolExecutor(max_workers=50, thread_name_prefix='PI_WRAPPER_EXECUTOR')

                  def __init__(self, *args, **kwargs):

                    self._loop = kwargs.get('loop') or asyncio.get_event_loop()

               

              class PointWrapper(BaseAFWrapper):

                def __init__(self, **kwargs):

                    super().__init__(**kwargs)

                    self._pi_snapshot_data_pipe = PIDataPipe(AFDataPipeType.Snapshot)

                    self._pi_archive_data_pipe = PIDataPipe(AFDataPipeType.Archive)

                 

                 async def poll_snapshot_events(self, pi_server, pi_points_ilist):

                    await self.add_to_signups(pi_points_ilist)

                    while True:

                      snapshot_events = await self._loop.run_in_executor(self._executor,
                                                                         self._pi_snapshot_data_pipe.GetUpdateEvents,
                                                                         settings.pi_data.snapshot_events_per_poll)

                     results = []

                     for snapshot_event in snapshot_events:

                         err = settings.pi_data.valid_data_code

                        af_value = snapshot_event.Value

                        if isinstance(af_value.Value, AFEnumerationValue):

                           err = af_value.Value.Value

                           value = float('nan')

                        else:

                           value = af_value.Value

                        results.append((af_value.PIPoint.ID, af_value.Timestamp.UtcSeconds, value, err))

                        await asyncio.sleep(0)

                     yield results

                     await asyncio.sleep(settings.pi_data.time_between_snapshot_events_poll)

                 

                async def add_to_signups(self, pi_points_ilist):

                    await self._loop.run_in_executor(self._executor, self._pi_snapshot_data_pipe.AddSignups, pi_points_ilist)

               

                async def list_signups_by_server(self):

                    await self._loop.run_in_executor(self._executor, self._pi_snapshot_data_pipe.AsReadOnly)

               

               

              Later in my code I create an instance of PointWraper class:

              point_wrapper = PointWrapper()

              errors = await point_wrapper.add_to_signups(pi_points_ilist)  # pi_points_ilist is <IList>PIPoint returned from PI Server using PIPoint.FindPIPoints

              registered_points = await point_wrapper.list_signups_by_server()

               

              Erros gets null value, assuming that this is correct, is this function return null on success. While for some reason registered_points value is always null, while <IList>PIPoint is expected.