![]() |
00001 00002 // Copyright © 2013 Cathexis Innovations Inc. All rights reserved. 00003 00004 #import <Foundation/Foundation.h> 00005 #import "IDBlue.h" 00006 #import "IDataHandler.h" 00007 #import "ResponseHandlerCollection.h" 00008 #import "PacketQueue.h" 00009 #import "IDBluePacket.h" 00010 #import "IDBlueCommand.h" 00011 #import "CommandQueue.h" 00012 #import "IDBlueTimestamp.h" 00013 #import "CByteArray.h" 00014 #import "SendStatus.h" 00015 #import "RfidTag.h" 00016 #import "ResponseHandler.h" 00017 #import "ResponseFactory.h" 00018 #import "PropertyGenerator.h" 00019 00025 @interface IDBlueResponseProcessor : NSObject <IDataHandler> { 00026 @private 00027 // The circular byte queue that holds the incoming data from IDBLUE 00028 PacketQueue* _receiveBuffer; 00029 00030 // The CommandQueue object that maps commands sent to IDBLUE 00031 // to responses received from IDBLUE 00032 CommandQueue* _commandQueue; 00033 00034 // The asynchronous response callback method 00035 ResponseHandlerCollection* _handlers; 00036 00037 // Indicates that the next response from IDBLUE is asynchronous 00038 // (e.g. the user presses the front button of the IDBLUE device, 00039 // IDBLUE scans a tag then sends the result back to the host). 00040 BOOL _nextPacketAsync; 00041 00042 // The number of synchronous responses received from IDBLUE 00043 int _synchronousResponsesReceived; 00044 00045 // The number of asynchronous responses received from IDBLUE 00046 int _asynchronousResponsesReceived; 00047 00048 // ResponseFactory is used to create responses from IDBluePackets 00049 ResponseFactory* _responseFactory; 00050 00051 // PropertyGenerator is used to create IDBlueProperty objects from IDBluePackets 00052 PropertyGenerator* _propertyGenerator; 00053 } 00054 00058 -(ResponseFactory*) responseFactory; 00059 00060 00064 -(PropertyGenerator*) propertyGenerator; 00065 00075 -(id) initWithCommandQueue: (CommandQueue*) queue 00076 withReceiveBuffer: (PacketQueue*) receiveBuffer 00077 withResponseFactory: (ResponseFactory*) factory 00078 withPropertyGenerator: (PropertyGenerator*) generator; 00079 00084 -(BOOL) addHandler: (id<IResponseHandler>) handler; 00085 00090 -(BOOL) removeHandler: (id<IResponseHandler>) handler; 00091 00096 -(BOOL) hasHandler: (id<IResponseHandler>) handler; 00097 00101 -(ResponseHandlerCollection*) handlers; 00102 00106 -(NSString*) incomingBufferContents; 00107 00111 -(int) incomingBufferCount; 00112 00119 -(void) onPacketReceived:(IDBluePacket*) packet withHandler: (id<IResponseHandler>) handler; 00120 00131 -(BOOL) notifyAsyncResponse: (IDBlueResponse*) response; 00132 00141 -(BOOL) notifySyncResponse: (IDBlueCommand*) command; 00142 00143 @end