1

I have a sensor that is displaying real-time data through a Python script, running on IronPython. Unfortunately, IronPython does not support pandas, so I am unable to use the pd.rolling_mean function in my Python script, or perform much data processing in real-time (as far as I understand).

When I run the below program in Visual Studio, a console application appears, and the data from the sensor starts streaming in. My goal is to calculate the rolling_mean of this data stream, and then to trigger an event once that rolling_mean exceeds a certain value.

I am limited to IronPython, because that is what the sensor company requires in order to run their real-time data script. Unfortunately, I am having trouble finding ways to process that data stream in real-time.

I was wondering if there is a way for me to write the rolling_mean in C# on the data stream that is coming in - similar to the following question: Calculate a moving std in C#.

Thank you for any feedback and support! My current code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Y to begin:");
            var input = Console.ReadLine();
            var py = Python.CreateEngine();

            var engine = Python.CreateEngine();
            var paths = engine.GetSearchPaths();
            paths.Add("C:\\Python34\\Lib\\site-packages");
            engine.SetSearchPaths(paths);

            try
            {
                py.ExecuteFile("C:\\Users\\MyName\\Desktop\\Sensor_Data.py");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            Console.WriteLine("Press Enter to Exit");
            Console.ReadLine();
        }
    }
}
Gary
  • 2,137
  • 3
  • 23
  • 41

0 Answers0