示例#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);
                }
            }
        }
示例#2
0
 public override void Read()
 {
     SharpPy msg = new SharpPy()
     {
         operation = CMD.Position,
         payload = "",
     };
     base.ReadContinuously(msg);
 }
示例#3
0
        //------------------------------------------------------------------------------------------------------------------------

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

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

            base.ReadContinuously(msg);
        }
示例#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");
            }
        }
示例#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);
        }
示例#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");
            }
        }