AnswerBun.com

Create a dynamic growing list in Manipulate from data obtained by URLExcecute of API

Mathematica Asked on January 6, 2022

I have a test API which sends me data from one or more tags in a SCADA/Historian system. For one tag, I refresh the API call every 5 seconds and generate a simple ListPlot[] of this single current value. The variable currentvalue is also to be stored in a growing list.

In the code below, I using the function AppendTo[]to add the dynamic variable to the list. In a grid, I plot the single point, give the single value, and provide the list.

However, the list never grows. The current value appended to the list dynamically updates whenever the value from the SCADA updates. But I cannot seem to append this new data to the list. I would like to keep a history of the data that has been imported.

Any advice is greatly appreciated.

Manipulate[
 
 Newvalue = 0;
 OldValue = 0;
 currentvalue = 0;
 HydrateList2 = {};
 
 currentvalue = Dynamic[Refresh[
                            
    URLExecute[
         "http://LAPTOP-QC9NCDI2:55235/api/v2/getTagData", {"tags" -> 
           "LAPTOP-XXXXX.GBXXXField.Sine.Tag0001" 
                    }][[3]][[2]][[1]][[2]],
                        UpdateInterval -> 5]];(*Find the correct spot in array*)
 
 NewValue = currentvalue[[1]][[2]][[2]];(*Extracting numerical value*)
 
 
 (*If[NewValue[NotEqual]OldValue,
                ArrValue=NewValue;
                AppendTo[HydrateList2,N[ArrValue]];
                OldValue=ArrValue;
            ,""
            ];*)
 
 AppendTo[HydrateList2, NewValue];
 
 Grid[{{ ListPlot[{{1, NewValue}}, ImageSize -> 400], NewValue, 
    HydrateList2}}],
 
 
 TrackedSymbols -> {currentvalue},
 Paneled -> False
 ]
```

Add your own answers!

Related Questions

Making histogram from a vector

1  Asked on June 24, 2021 by physmath

   

Table Glitch / Error with binary data

0  Asked on June 23, 2021 by atlasgeo

   

Search in a Dataset

0  Asked on June 22, 2021 by andr-paschold

   

How to make a table from two lists?

5  Asked on June 22, 2021 by user2895279

     

Stationarity Check of TimeSeries

0  Asked on June 21, 2021 by curiousdatascientist

   

Non-linear equation

2  Asked on June 20, 2021 by armin-sharafi

         

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP