• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    /v1/point-values PUT not updating in datasources other than virtual

    User help
    2
    6
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MattFoxM
      MattFox
      last edited by MattFox

      Morning All,

      I've got data coming into my API which I'm relaying into mango after parsing the data.
      Problem is the points are not updating. These points are in datafile datasources, are 'settable' and are still not updating in mango, despite the 201 Created status response.

      The system sending this data is dropping their FTP uploads in favour of HTTP posts.
      The other issue is despite adding a poll class as suggested by Phil I'm still not triggering these updates.
      Any advice would be hugely appreciated and I'd be rather grateful.
      Am still on 3.5.6 - this may have to change at some point but I'll likely need some advice on going about this and not destroying my production install..

      Fox

      EDIT: Alternatively, how hard would it be to convert the Data File datasources into Virtual datasources? If I could manage that, it would save a lot of fluff.

      Do not follow where the path may lead; go instead where there is no path.
      And leave a trail - Muriel Strode

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi Fox,

        Can you post your poll class? What is the logging type of your points?

        The PUT endpoint behaves like a set through Mango. If the user your PUT'ing the value through the API has permission to set the point, you should see that get to the poll class's method I said you had to implement:

        public boolean setPointValueImpl(DataPointRT dataPoint, PointValueTime valueTime,
                    SetPointSource source)
        

        You could do something in this method to prove to yourself it got there. If that returns true, then it will call setPointValue on the DataPointRT and that has some subtleties from logging type.

        EDIT: Alternatively, how hard would it be to convert the Data File datasources into Virtual datasources? If I could manage that, it would save a lot of fluff.

        You would have to do some work to ensure the id to xid set was the same (i.e. SELECT id, xid FROM dataPoints; and save that to make a bunch of update statements for the modified points. Here's an old python script that will convert all data source and data points in a JSON file to virtual sources and points (you may want to make them no change point locators): https://github.com/infiniteautomation/ma-devtools/blob/master/PythonUtilities/Simulation/virtualizeDataSources.py

        You would have to delete the old, import the new, and then run the SQL update statements to set the ID based on the XID such that old data wasn't lost. So, possible by maybe not trivial.

        1 Reply Last reply Reply Quote 0
        • MattFoxM
          MattFox
          last edited by MattFox

          Thanks for your help with this Phil!

          import com.infiniteautomation.datafilesource.rt.AbstractPollClass;
          import com.infiniteautomation.datafilesource.rt.PollClassInvoker;
          
          import com.serotonin.m2m2.rt.dataImage.DataPointRT;
          import com.serotonin.m2m2.rt.dataImage.PointValueTime;
          import com.serotonin.m2m2.rt.dataImage.SetPointSource;
          
          public abstract class PutPollClass extends AbstractPollClass {
          	/* @Override
          	public abstract void run(long time, PollClassInvoker invoker, String[] arguments); */
          	
          	 @Override
          	public boolean setPointValueImpl(DataPointRT dataPoint, PointValueTime valueTime,SetPointSource source) {
          		return true;
          	} 
          }
          

          Is the poll class data code.

          I'm using the API with an admin bearer token for simplicity. Should I take the login API route instead?

          What is the logging type of your points?

          "loggingType":"ALL",

          You would have to delete the old, import the new, and then run the SQL update statements to set the ID based on the XID such that old data wasn't lost. So, possible by maybe not trivial.

          So stupid question... By deleting means I'd still need to backup my data right? Or do you mean calling a DELETE FROM ... SQL query? Ah no wait I see now, you use the id to link point values to the datapoint, not the XID. Gotta admit I do like that. Will be good to get this sorted asap as data hasn't come in for two days now.

          Do not follow where the path may lead; go instead where there is no path.
          And leave a trail - Muriel Strode

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            The issue with the poll class it will not work as an abstract class, it must be able to be instantiated so that it may be run. I just tested and was able to set values to data file points when my poll class looked like this:

            import com.infiniteautomation.datafilesource.rt.AbstractPollClass;
            import com.infiniteautomation.datafilesource.rt.PollClassInvoker;
            
            import com.serotonin.m2m2.rt.dataImage.DataPointRT;
            import com.serotonin.m2m2.rt.dataImage.PointValueTime;
            import com.serotonin.m2m2.rt.dataImage.SetPointSource;
            
            public class PutPollClass extends AbstractPollClass {
            	 @Override
            	public void run(long time, PollClassInvoker invoker, String[] arguments) {}
            	
            	 @Override
            	public boolean setPointValueImpl(DataPointRT dataPoint, PointValueTime valueTime,SetPointSource source) {
            		return true;
            	} 
            }
            

            Remember, you'll need to recompile the class, and then restart the data source for the modifications to be applied.

            MattFoxM 1 Reply Last reply Reply Quote 0
            • MattFoxM
              MattFox @phildunlap
              last edited by

              @phildunlap said in /v1/point-values PUT not updating in datasources other than virtual:

              The issue with the poll class it will not work as an abstract class

              Ah that's where I was going wrong! I think I was having issues with it compiling which is why I threw that unnecessary abstract in front... Thanks Phil, definitely feeling like a prized pillock today!

              May tomorrow go better?

              Fox

              Do not follow where the path may lead; go instead where there is no path.
              And leave a trail - Muriel Strode

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by

                No worries, the data file data source probably requires the most Java knowledge outside of writing scripts that invoke the code. Even then, the scripts get to benefit from JavaScripts willingness to store any ole' type into a variable, where everything needs to be properly typed and declared in the data file classes. Tricky when there are but few examples and it's closed source!

                I would guess there was an informative event raised about a failure to instantiate the poll class, but I couldn't say.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post