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); } }
//------------------------------------------------------------------------------------------------------------------------ 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); } } }
//------------------------------------------------------------------------------------------------------------------------ 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); } } }
//------------------------------------------------------------------------------------------------------------------------ /// <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); }
//------------------------------------------------------------------------------------------------------------------------ /// <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); }