Mathematica Asked on February 12, 2021
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
]
```
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP