Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------------------------
        private void OnRxPythonMsg(SharpPy msg)
        {
#if DEBUG
            DebugEx.TraceLog("OnRxPython " + msg.payload + ", syncid: " + msg.syncid + ", watcherid " + msg.watcherid);
            if (PendingRequests.Count != 0)
            {
                DebugEx.TraceLogInlineBegin("PENDING syncids: ");
                foreach (var item in PendingRequests.Keys)
                {
                    DebugEx.TraceLogInline(item.ToString());
                }
                DebugEx.TraceLogInlineEnd("");
            }
            DebugEx.TraceLog("This watcherid:" + this.WatcherId);
#endif
            if (Active)
            {
                if (msg.watcherid == this.WatcherId)
                {
                    int syncId = msg.syncid;
                    if (syncId == 0)
                    {
                        return;
                    }
                    var payload = this.sensor.DeserializePayload(msg.payload);
                    this.sensor.OnGetValue(payload);
                }
            }
        }
Ejemplo n.º 2
0
 public override void Read()
 {
     SharpPy msg = new SharpPy()
     {
         operation = CMD.Position,
         payload = "",
     };
     base.ReadContinuously(msg);
 }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------------------------------------------------

        public void SendMessage(string data)
        {
            SharpPy msg = new SharpPy()
            {
                payload = data
            };

            this.sharppyiface.Send2python(msg);
        }
Ejemplo n.º 4
0
        public override void Read()
        {
            SharpPy msg = new SharpPy()
            {
                operation = CMD.Position,
                payload   = "",
            };

            base.ReadContinuously(msg);
        }
Ejemplo n.º 5
0
        //------------------------------------------------------------------------------------------------------------------------

        //send mesg for processing to python
        public void Send2python(SharpPy data)
        {
            lock (this)
            {
                if (data.payload == null)
                {
                    data.payload = String.Empty;
                }
                var csharp2pythonmessage = JsonConvert.SerializeObject(data);

                //DebugEx.TraceLog("Send to python " + csharp2pythonmessage);
                sw.WriteLine(csharp2pythonmessage);
                sw.WriteLine("\n");
            }
        }
Ejemplo n.º 6
0
        //------------------------------------------------------------------------------------------------------------------------
        public void StartMonitorEvents <Req>(Req data)
        {
            //each event (i.e gesture, motion) has its own sync id
            var syncid = GetNewSyncId();
            var w      = new Waiter();
            //construct sharppy msg
            SharpPy msg = new SharpPy()
            {
                isRequest = true,
                watcherid = WatcherId,
                syncid    = syncid,
                payload   = (data as SharpPy).payload,
                operation = (data as SharpPy).operation,
            };

            lock (w)
            {
                this.sharppyiface.Send2python(msg);
            }
            //DebugEx.TraceLog("continue w:" + WatcherId + " sid:" + syncid);
        }
Ejemplo n.º 7
0
        //------------------------------------------------------------------------------------------------------------------------

        //send mesg for processing to python
        public void Send2python(SharpPy data)
        {
            lock (this)
            {
                if (data.payload == null)
                    data.payload = String.Empty;
                var csharp2pythonmessage = JsonConvert.SerializeObject(data);

                //DebugEx.TraceLog("Send to python " + csharp2pythonmessage);
                sw.WriteLine(csharp2pythonmessage);
                sw.WriteLine("\n");
            }
        }