Example #1
0
 public override void OnPortEvent(PortEventMsg msg)
 {
     try
     {
         var portEvents = msg.PortEvents.Select((x) => new PortEventExt(x)).ToList();
         Native.OnPortEvent(portEvents.ToJSON());
     }
     catch (Exception ex)
     {
         DebugEx.TraceErrorException(ex);
     }
 }
Example #2
0
 //------------------------------------------------------------------------------------------------------------------------
 public override void OnPortEvent(PortEventMsg msg)
 {
     foreach (var pe in msg.PortEvents)
     {
         try
         {
             // Echo state
             if (Ports["echoPortIn"].PortKey == pe.PortKey)
             {
                 SetPortState(Ports["echoPortOut"].PortKey, pe.State);
             }
         }
         catch (Exception ex)
         {
             DebugEx.TraceErrorException(ex);
         }
     }
 }
Example #3
0
        //------------------------------------------------------------------------------------------------------------------------
        public override void OnPortEvent(PortEventMsg msg)
        {
            foreach (var pe in msg.PortEvents)
            {
                try
                {
                    DebugEx.TraceLog("fromCloud: " + pe.PortKey + "  " + pe.State);

                    if (ReceiveFromCloudPort.PortKey == pe.PortKey)
                    {
                        //WRITE to serial
                        mySerial.WriteLine(pe.State);
                    }
                }
                catch (Exception ex)
                {
                    DebugEx.TraceErrorException(ex);
                }
            }
        }
Example #4
0
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called by Logic's Things Manager Subsystem when an EndpointOut is solved
        /// </summary>
        public void OnThingSolvedCb(object sender, YEventRouter.EvInfo evInfo, Logic.Blocks.Things.EvThingSolved ev)
        {
            //filter out invalid residency
            if (ev.Residency != Residency.Node)
            {
                return;
            }

            //check
            if (ev.PortsUpdated == null || !ev.PortsUpdated.Any())
            {
                DebugEx.Assert("Invalid input");
                return;
            }

            //send event to node
            var msg = new PortEventMsg()
            {
                PortEvents = ev.PortsUpdated.Select(p => new API.Plegma.PortEvent(p.PortKey, p.PortState, revNum: p.RevNum)).ToArray()
            };

            Node.HandlePortEventMsg(msg);
        }
Example #5
0
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called by Logic's Things Manager Subsystem when an EndpointOut is solved
        /// </summary>
        public void OnThingSolvedCb(object sender, YEventRouter.EvInfo evInfo, Logic.Blocks.Things.EvThingSolved ev)
        {
            //filter out invalid residency
            if (ev.Residency != Residency.Node)
                return;

            //check
            if (ev.PortsUpdated == null || !ev.PortsUpdated.Any())
            {
                DebugEx.Assert("Invalid input");
                return;
            }

            //send event to node
            var msg = new PortEventMsg()
            {
                PortEvents = ev.PortsUpdated.Select(p => new API.Plegma.PortEvent(p.PortKey, p.PortState, revNum: p.RevNum)).ToArray()
            };
            Node.HandlePortEventMsg(msg);
        }