3 Replies Latest reply on Oct 1, 2015 1:35 PM by mdspath

    trying to use UpdateValue for a string PiPoint but do not want to add duplicate values

      I'm trying to write a utility to add string values into a string PiPoint. I have that part working but I'm not sure how to prevent the user from adding duplicate values.
      I've been looing into the AFUpdateOption Enum but since the time is sent into UpdateValue from the timedate control with no seconds and milliseconds but the values in PI have seconds and milliseconds, there is never the "same time".


        Member nameValueDescription
      Replace0Add the value to the archive. If any values exist at the same time, will
      overwrite one of them and set its Substituted flag.
      Insert1Add the value to the archive. Any existing values at the same time are not
      NoReplace2Add the value to the archive only if no value exists at the same time. If a
      value already exists for that time, the passed value is ignored.
      ReplaceOnly3Replace an existing value in the archive at the specified time. If no
      existing value is found, the passed value is ignored.
      InsertNoCompression5Add the value to the archive without compression. If this value is written
      to the snapshot, the previous snapshot value will be written to the archive,
      without regard to compression settings. Note that if a subsequent snapshot value
      is written without the InsertNoCompression option, the value added with
      the InsertNoCompression option is still subject to compression.
      Remove6Remove the value from the archive if a value exists at the passed time.
        • Re: trying to use UpdateValue for a string PiPoint but do not want to add duplicate values
          Kenji Hashimoto

          If you tag use exception and compression, duplicate values should not go to archives.

          Please check tag attributes. Compressiong = on and excmax and compmax are set. (ExcDev and comdev does not work. The string should be exactly the same)

          However, you can see 2 events at the last timestamp. ("test3" value) because of snapshot and archived value.

          I put a lot of the same values for this test but results were following.

          Also if there are annotations, these events are not compressed.

          If you don't want to update timestamp for duplicate value events, then you can use following way.

          At first, check snapshot value

          If the new value comes, check the snapshot contains the same value

          If the new value is different value from snapshot value, then use updatevalue

          • Re: trying to use UpdateValue for a string PiPoint but do not want to add duplicate values
            Eugene Lee

            Hi Mike,


            You can configure the datetime control to be able to select the seconds as well. I have not been able to get it to display milliseconds since the control doesn't support it. This way, you will be able to control the seconds and the AFUpdateOption Enum 'NoReplace' can help to prevent duplicates.



            timePicker = new DateTimePicker();
            timePicker.Format = DateTimePickerFormat.Custom;
            timePicker.CustomFormat = "dd-MMM-yy hh:mm:ss";
            timePicker.ShowUpDown = true;



            If you want to remove milliseconds before doing UpdateValue, you can do this if you have a DateTime




            or this if you have an AFTime