private void m_adapter_OnProfinetArrival(ConnectionInfoEthernet sender, Stream stream) { RT.FrameIds frameID; //Real Time RT.DecodeFrameId(stream, out frameID); if (frameID == RT.FrameIds.DCP_Identify_ResPDU || frameID == RT.FrameIds.DCP_Identify_ReqPDU || frameID == RT.FrameIds.DCP_Get_Set_PDU || frameID == RT.FrameIds.DCP_Hello_ReqPDU) { DCP.ServiceIds serviceID; uint xid; ushort responseDelayFactor; ushort dcpDataLength; DCP.DecodeHeader(stream, out serviceID, out xid, out responseDelayFactor, out dcpDataLength); Dictionary <DCP.BlockOptions, object> blocks; DCP.DecodeAllBlocks(stream, dcpDataLength, out blocks); if (OnDcpMessage != null) { OnDcpMessage(sender, new DcpMessageArgs(serviceID, xid, responseDelayFactor, blocks)); } } else if (frameID == RT.FrameIds.PTCP_DelayReqPDU) { //ignore this for now } else if (frameID >= RT.FrameIds.RTC_Start && frameID <= RT.FrameIds.RTC_End) { long dataPos = stream.Position; stream.Position = stream.Length - 4; UInt16 cycleCounter; RT.DataStatus dataStatus; RT.TransferStatus transferStatus; RT.DecodeRTCStatus(stream, out cycleCounter, out dataStatus, out transferStatus); stream.Position = dataPos; if (OnCyclicMessage != null) { OnCyclicMessage(sender, cycleCounter, dataStatus, transferStatus, stream, (int)(stream.Length - dataPos - 4)); } } else if (frameID == RT.FrameIds.Alarm_Low || frameID == RT.FrameIds.Alarm_High) { UInt16 alarmDestinationEndpoint; UInt16 alarmSourceEndpoint; RT.PDUTypes pduType; RT.AddFlags addFlags; UInt16 sendSeqNum; UInt16 ackSeqNum; UInt16 varPartLen; RT.DecodeRTAHeader(stream, out alarmDestinationEndpoint, out alarmSourceEndpoint, out pduType, out addFlags, out sendSeqNum, out ackSeqNum, out varPartLen); if (OnAcyclicMessage != null) { OnAcyclicMessage(sender, alarmDestinationEndpoint, alarmSourceEndpoint, pduType, addFlags, sendSeqNum, ackSeqNum, varPartLen, stream); } } else { Trace.TraceWarning("Unclassified RT message"); } }
private void m_adapter_OnProfinetArrival(ConnectionInfoEthernet sender, Stream stream) { RT.FrameIds frame_id; //Real Time RT.DecodeFrameId(stream, out frame_id); if (frame_id == RT.FrameIds.DCP_Identify_ResPDU || frame_id == RT.FrameIds.DCP_Identify_ReqPDU || frame_id == RT.FrameIds.DCP_Get_Set_PDU || frame_id == RT.FrameIds.DCP_Hello_ReqPDU) { DCP.ServiceIds service_id; uint xid; ushort response_delay_factor; ushort dcp_data_length; DCP.DecodeHeader(stream, out service_id, out xid, out response_delay_factor, out dcp_data_length); Dictionary <DCP.BlockOptions, object> blocks; DCP.DecodeAllBlocks(stream, dcp_data_length, out blocks); if (OnDcpMessage != null) { OnDcpMessage(sender, service_id, xid, response_delay_factor, blocks); } } else if (frame_id == RT.FrameIds.PTCP_DelayReqPDU) { //ignore this for now } else if (frame_id >= RT.FrameIds.RTC_Start && frame_id <= RT.FrameIds.RTC_End) { long data_pos = stream.Position; stream.Position = stream.Length - 4; UInt16 CycleCounter; RT.DataStatus DataStatus; RT.TransferStatus TransferStatus; RT.DecodeRTCStatus(stream, out CycleCounter, out DataStatus, out TransferStatus); stream.Position = data_pos; if (OnCyclicMessage != null) { OnCyclicMessage(sender, CycleCounter, DataStatus, TransferStatus, stream, (int)(stream.Length - data_pos - 4)); } } else if (frame_id == RT.FrameIds.Alarm_Low || frame_id == RT.FrameIds.Alarm_High) { UInt16 AlarmDestinationEndpoint; UInt16 AlarmSourceEndpoint; RT.PDUTypes PDUType; RT.AddFlags AddFlags; UInt16 SendSeqNum; UInt16 AckSeqNum; UInt16 VarPartLen; RT.DecodeRTAHeader(stream, out AlarmDestinationEndpoint, out AlarmSourceEndpoint, out PDUType, out AddFlags, out SendSeqNum, out AckSeqNum, out VarPartLen); if (OnAcyclicMessage != null) { OnAcyclicMessage(sender, AlarmDestinationEndpoint, AlarmSourceEndpoint, PDUType, AddFlags, SendSeqNum, AckSeqNum, VarPartLen, stream); } } else { Trace.TraceWarning("Unclassified RT message"); } }