interprocess C# python real time

前端 未结 3 1053
走了就别回头了
走了就别回头了 2020-12-19 13:41

I\'m working on a project where I\'ll have one application in C# and another one in Python. The C# application will continuously analyse stream of data and raise a flag each

3条回答
  •  太阳男子
    2020-12-19 14:25

    You may use our aktos-dcs and aktos-dcs-cs libraries. I have successfully used these libraries in production in order to make an RFID Reader (from Impinj) communicate with (actually, integrated in) our telemetry system. The RFID reader has a C# API and we are heavily using Python in our telemetry system.

    The simplest test case is a pinger-ponger application, and here is how it looks like with these libraries:

    pinger.cs:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using aktos_dcs_cs;
    
    namespace pinger
    {
        class Pinger : Actor
        {
            public void handle_PingMessage(Dictionary msg)
            {
                Console.WriteLine("Pinger handled PingMessage: {0} ", msg["text"]);
    
                string msg_ser = @"
                        {""PongMessage"": 
                            {""text"": ""this is proper message from csharp implementation""}
                        }
                    ";
                System.Threading.Thread.Sleep(2000);
                send(msg_ser);
            }
    
        }
    
    
        class Program
        {
            static void Main(string[] args)
            {
                Pinger x = new Pinger(); 
                Actor.wait_all(); 
            }
        }
    }
    

    ponger.py:

    from aktos_dcs import *
    
    class Pinger(Actor):
        def handle_PingMessage(self, msg_raw):
            msg = get_msg_body(msg_raw)
            print "Pinger got ping message: ", msg['text'], (time.time() - msg_raw['timestamp'])
            sleep(2)
            self.send({'PongMessage': {'text': "Hello ponger, this is pinger 1!"}})
    
    if __name__ == "__main__":
        ProxyActor()
        pinger = Pinger()
        pinger.send({'PongMessage': {'text': "Hello ponger, this is STARTUP MESSAGE!"}})
    
        wait_all()
    

提交回复
热议问题