当前位置: 首页>>代码示例>>C#>>正文


C# IHandler.ProcessResponse方法代码示例

本文整理汇总了C#中IHandler.ProcessResponse方法的典型用法代码示例。如果您正苦于以下问题:C# IHandler.ProcessResponse方法的具体用法?C# IHandler.ProcessResponse怎么用?C# IHandler.ProcessResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHandler的用法示例。


在下文中一共展示了IHandler.ProcessResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute


//.........这里部分代码省略.........
                        // Ensure an error was not received
                        tempString = _incomingResponseBuffer.ToString();
                        if (tempString.Equals(Global.Constants.STOPPED_MESSAGE) || tempString.Equals(Global.Constants.NO_DATA_MESSAGE) || tempString.Equals(Global.Constants.SEARCHING_MESSAGE) || tempString.Equals(Global.Constants.UNABLE_TO_CONNECT_MESSAGE))
                        {
                            continue;
                        }

                        // Convert the hex string to actual bits
                        parsingBuffer = Utility.HexStringToByteArray(tempString);
                        
                        fixed (byte* p1 = parsingBuffer)
                        {
                            // Get the CAN ID (we grab 12 bits to compare the 3 hex characters -- note, the last bit is always 0)
                            idBuffer = (uint)(((parsingBuffer[0] << 8) | parsingBuffer[1]) & BITMASK_ID) >> 4;

                            // Get the PCI Code
                            pciBuffer = (uint)parsingBuffer[1] & BITMASK_PCITYPE;

                            // If an ECU filter is set, confirm the idBuffer equals the ECU's Return Address
                            if(SelectedEcuFilter != Global.Constants.NoSelection && idBuffer != SelectedEcuFilter.ReturnAddress)
                            {
                                log.Error("Filtering for [" + SelectedEcuFilter.ReturnAddressString + "]. Message from [" + idBuffer.ToString("X6") + "] rejected.");
                                returnValue = false;
                                break;
                            }

                            switch (pciBuffer)
                            {
                                case (uint)FrameTypes.SINGLE_FRAME:
                                {
                                    try
                                    {
                                        // Send the data payload to the handler
                                        handler.ProcessResponse(
                                            ProcessSingleFrameResponse(handler, parsingBuffer)
                                        );

                                            // Exit gracefully
                                            _hasMoreResponses = false;
                                    }
                                    catch (ProtocolProcessingException e)
                                    {
                                        log.Error("Single Frame Processing Exception Occurred for [" + handler.Name + ":" + handler.Request + "]:", e);
                                        returnValue = false;
                                    }
                                    break;
                                }

                                case (uint)FrameTypes.FIRST_FRAME:
                                {
                                    try
                                    {
                                        // Process the First Frame. The data bytes and other session information
                                        // for this multiframe response will be stored in the _responseBuffer.
                                        ProcessFirstFrameResponse(idBuffer, handler, parsingBuffer);
                                    }
                                    catch (ProtocolProcessingException e)
                                    {
                                        log.Error("First Frame Processing Exception Occurred for [" + handler.Name + ":" + handler.Request + "]:", e);

                                            // Cancel this Request/Response Cycle
                                            _responseBuffer.Remove(idBuffer);
                                        returnValue = false;
                                    }
                                    break;
                                }
开发者ID:miaozhendaoren,项目名称:obd-express,代码行数:67,代码来源:CAN_11_Bit_ISO15765_Protocol.cs

示例2: Execute


//.........这里部分代码省略.........
                        }

                        // Remove the prompt if it exists
                        if (this._incomingResponseBuffer[0] == '>')
                        {
                            this._incomingResponseBuffer.Remove(0, 1);
                        }

                        // Ensure an error was not received
                        tempString = this._incomingResponseBuffer.ToString();
                        if (tempString.Equals(stoppedMessage) || tempString.Equals(noDataMessage) || tempString.Equals(searchingMessage) || tempString.Equals(unableConnectMessage))
                        {
                            continue;
                        }

                        // Convert the hex string to actual bits
                        parsingBuffer = Utility.HexStringToByteArray(tempString);
                        
                        fixed (byte* p1 = parsingBuffer)
                        {
                            // Get the CAN ID
                            idBuffer = (uint)(((parsingBuffer[0] << 8) | parsingBuffer[1]) & BITMASK_ID) >> 5;

                            // Get the PCI Code
                            pciBuffer = (uint)parsingBuffer[1] & BITMASK_PCITYPE;

                            switch (pciBuffer)
                            {
                                case (uint)FrameTypes.SINGLE_FRAME:
                                {
                                    try
                                    {
                                        // Send the data payload to the handler
                                        handler.ProcessResponse(
                                            ProcessSingleFrameResponse(handler, parsingBuffer)
                                        );

                                        // Exit gracefully
                                        this._hasMoreResponses = false;
                                    }
                                    catch (ProtocolProcessingException e)
                                    {
                                        log.Error("Single Frame Processing Exception Occurred for [" + handler.Name + ":" + handler.Request + "]:", e);
                                        returnValue = false;
                                    }
                                    break;
                                }

                                case (uint)FrameTypes.FIRST_FRAME:
                                {
                                    try
                                    {
                                        // Process the First Frame. The data bytes and other session information
                                        // for this multiframe response will be stored in the _responseBuffer.
                                        ProcessFirstFrameResponse(idBuffer, handler, parsingBuffer);
                                    }
                                    catch (ProtocolProcessingException e)
                                    {
                                        log.Error("First Frame Processing Exception Occurred for [" + handler.Name + ":" + handler.Request + "]:", e);

                                        // Cancel this Request/Response Cycle
                                        this._responseBuffer.Remove(idBuffer);
                                        returnValue = false;
                                    }
                                    break;
                                }
开发者ID:CDMirel,项目名称:obd-express,代码行数:67,代码来源:CAN_11_Bit_ISO15765_Protocol.cs


注:本文中的IHandler.ProcessResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。