OsiSoft PI Web API for R language Is a R script to read and write data to OsiSoft PI Data Archive
It's created as a need to easily fetch, clean and join PI data into R DataFrames for further manipulation, analysis and model building. Main reference is PI Tag name that is preserved as column name in data frame.
Input could be PI Tag name or array of PI Tag names
Timestamps of PI Tags (UTC) are recalculated to your system time.
Supported read methods:
- Interpolated
- Compressed
- Summary
Supported write methods:
- write single PI tag value with timestamp
Supported summary methods:
- Average
- Total
- Minimum
- Maximum
- Range
- StdDev
- PopulationStdDev
- Count
- PercentGood
Helper Functions:
- Join data (by timestamp) defined by array of PI Tags
- Save data frames to CSV in bulk defined by array of PI Tags
- Load data frames to CSV in bulk defined by array of PI Tags
Needed packages:
- jsonlite
- httr
- lubridate
- dplyr
PIServer <- "yourPIserver"
base_url <- "https://pivision/piwebapi" # PUT YOUR BASE URL FOR PI WEB API
startTime="1-Apr-2018"
endTime="1-Feb-2019"
interval="5m"
It returns DataFrames named as PI Tag Names in PITagArray.
batchPIgetValues(PITagArray, StartTime = startTime, EndTime = endTime, Interval = interval, summaryType = "Average")
It returns DataFrames named as PI Tag Names in PITagArray:
batchPIgetCompressed(PIpointsArray, StartTime = startTime, EndTime = endTime, maxCount = 2000)
JoinedDataFrame <- joinData(PIpointsArray)
saveDataCSV(PIpointsArray)
SetUp WebAPI max return values by request, default value can be overriden in configuration
// TODO ....finish this docu...
Feel free to contribute ;)