public IHttpActionResult Execute() { REngine _engine = REngine.GetInstance(null, true, null, null); SvgGraphicsDevice GraphicsDevice = new SvgGraphicsDevice(new SvgContextMapper(700, 700, SvgUnitType.Pixel, null)); _engine.Initialize(); _engine.Install(GraphicsDevice); RApplication app = new RApplication(_engine); app.DataAccessMethod = "PIAFSDK"; app.Connect("MARC-PI2016"); app.RFunction = "PI Histogram"; app.NumTags = 1; app.Mode = "Interpolated"; var tag1 = "FAC.OAK.Weather-Outside_Temperature-Val.PV"; var tag2 = "FAC.OAK.Weather-Inside_Temperature-Val.PV"; var tag3 = "FAC.OAK.Weather-Inside_Humidity-Val.PV"; var tag4 = "FAC.OAK.Weather-Outside_Humidity-Val.Pv"; var tag5 = "FAC.OAK.Power-Total_Demand_Calc.PV"; app.GetPIData(tag1, tag2, tag3, tag4, tag5, "1-Oct-2012", "1-Nov-2012", "1h"); app.GenerateGhaphic("5", "0", "1", ""); //GraphicsDevice.ClearImages(); //var evaluated = statements.Select(_engine.Evaluate).ToList(); var plots = GraphicsDevice.GetImages().Select(RenderSvg).ToList(); return(Ok(plots)); }
static void Main(string[] args) { string[] paths = new string[] { @"af:\\MARC-PI2016\IntegratingPISystemAndR\MainElement|Inside Humidity", @"af:\\MARC-PI2016\IntegratingPISystemAndR\MainElement|Inside Temperature", @"af:\\MARC-PI2016\IntegratingPISystemAndR\MainElement|OutsideTemperature" }; REngine _engine = REngine.GetInstance(null, true, null, null); SvgGraphicsDevice GraphicsDevice = new SvgGraphicsDevice(new SvgContextMapper(700, 700, SvgUnitType.Pixel, null)); _engine.Initialize(); _engine.Install(GraphicsDevice); RApplication app = new RApplication(); app.GetPIData(paths, "1-Oct-2012", "1-Nov-2012", "1h"); app.GenerateGraphic(_engine); }
public WinForm() { InitializeComponent(); REngine _engine = REngine.GetInstance(); _engine.Initialize(); MyApp = new RApplication(_engine); tsPISDKVersion.Text = "PI AF SDK Version: " + MyApp.GetVersion(); cbRFunctions.Items.Add("PI Histogram"); cbRFunctions.Items.Add("PI Density Plot"); cbRFunctions.Items.Add("PI Density Compare"); cbRFunctions.Items.Add("PI Box Plot"); cbRFunctions.Items.Add("PI Regular Correlation"); cbRFunctions.Items.Add("PI Smooth Scatter"); cbRFunctions.Items.Add("PI Multi-Correlation"); tsProgressBar.Value = 0; }
public IHttpActionResult Execute(QueryData queryData) { Stopwatch watch = new Stopwatch(); watch.Start(); try { if ((queryData.Paths == null) || (queryData.Paths.Count() < 2)) { throw new Exception("There should be at least 2 attributes within the symbol."); } if (queryData.Paths.All(m => m.Substring(0, 2) == "af") == false) { throw new Exception("PI Points are not accepted"); } IEnumerable <string> plots = null; RApplication app = new RApplication(); app.GetPIData(queryData.Paths, queryData.StartTime, queryData.EndTime, queryData.Interval); lock (_object) { System.Threading.Thread.Sleep(1000); if (lastWidth != queryData.Width) { GraphicsDevice = new SvgGraphicsDevice(new SvgContextMapper(queryData.Width, queryData.Height, SvgUnitType.Pixel, null)); _engine.Install(GraphicsDevice); lastWidth = queryData.Width; } app.GenerateGraphic(_engine); plots = GraphicsDevice.GetImages().Select(RenderSvg); } return(Ok(plots)); } catch (Exception ex) { return(BadRequest(ex.Message + "|\n" + ex.Source + "|\n" + ex.StackTrace)); } finally { watch.Stop(); } }