コード例 #1
0
 public void init()
 {
     accessResult                = null;
     detectBarcode               = null;
     commandComplete             = null;
     changedActionState          = null;
     onAsReaderTriggerKeyEvent   = null;
     onAsReaderLeftModeKeyEvent  = null;
     onAsReaderRightModeKeyEvent = null;
     readerInitialized           = null;
     updateDeviceState           = null;
     readTag = null;
     onAsReaderGUNDisconnected = null;
 }
コード例 #2
0
 public void onCommandComplete(CompleteStatus cmpStatus)
 {
     CommandComplete?.Invoke(this, cmpStatus);
 }
コード例 #3
0
ファイル: Command.cs プロジェクト: andwoo/sharedcode
 public virtual void Dispose()
 {
     onCommandComplete = null;
 }
コード例 #4
0
ファイル: Protocol.Reading.cs プロジェクト: stazz/CBAM
        public static async Task <(BackendMessageObject msg, Int32 msgSize)> ReadBackendMessageAsync(
            MessageIOArgs ioArgs,
            ResizableArray <ResettableTransformable <Int32?, Int32> > columnSizes
            )
        {
            var args   = ioArgs.Item1;
            var stream = ioArgs.Item2;
            var token  = ioArgs.Item3;
            var buffer = ioArgs.Item4;
            var code   = (BackendMessageCode)(await args.ReadByte(stream, buffer, token));
            var length = await args.ReadInt32(stream, buffer, token);

            var remaining = length - sizeof(Int32);

            if (code != BackendMessageCode.DataRow && code != BackendMessageCode.CopyData)
            {
                // Just read the whole message at once for everything else except DataRow and CopyData messages
                buffer.CurrentMaxCapacity = remaining;
                await stream.ReadSpecificAmountAsync(buffer.Array, 0, remaining, token);

                remaining = 0;
            }
            var array    = buffer.Array;
            var encoding = args.Encoding.Encoding;

            BackendMessageObject result;

            switch (code)
            {
            case BackendMessageCode.AuthenticationRequest:
                result = new AuthenticationResponse(array, length);
                break;

            case BackendMessageCode.ErrorResponse:
                result = new PgSQLErrorObject(array, encoding, true);
                break;

            case BackendMessageCode.NoticeResponse:
                result = new PgSQLErrorObject(array, encoding, false);
                break;

            case BackendMessageCode.RowDescription:
                result = new RowDescription(array, encoding);
                break;

            case BackendMessageCode.DataRow:
                (result, remaining) = await DataRowObject.ReadDataRow(args, stream, token, array, columnSizes, remaining);

                break;

            case BackendMessageCode.ParameterDescription:
                result = new ParameterDescription(array);
                break;

            case BackendMessageCode.ParameterStatus:
                result = new ParameterStatus(array, encoding);
                break;

            case BackendMessageCode.ReadyForQuery:
                result = new ReadyForQuery(array);
                break;

            case BackendMessageCode.BackendKeyData:
                result = new BackendKeyData(array);
                break;

            case BackendMessageCode.CommandComplete:
                result = new CommandComplete(array, encoding);
                break;

            case BackendMessageCode.NotificationResponse:
                result = new NotificationMessage(array, encoding);
                break;

            case BackendMessageCode.CopyInResponse:
                result = new CopyInOrOutMessage(array, true);
                break;

            case BackendMessageCode.CopyOutResponse:
                result = new CopyInOrOutMessage(array, false);
                break;

            case BackendMessageCode.CopyData:
                result = new CopyDataMessage(length);
                break;

            case BackendMessageCode.ParseComplete:
                result = MessageWithNoContents.PARSE_COMPLETE;
                break;

            case BackendMessageCode.BindComplete:
                result = MessageWithNoContents.BIND_COMPLETE;
                break;

            case BackendMessageCode.EmptyQueryResponse:
                result = MessageWithNoContents.EMPTY_QUERY;
                break;

            case BackendMessageCode.NoData:
                result = MessageWithNoContents.NO_DATA;
                break;

            case BackendMessageCode.CopyDone:
                result = MessageWithNoContents.COPY_DONE;
                break;

            case BackendMessageCode.CloseComplete:
                result = MessageWithNoContents.CLOSE_COMPLETE;
                break;

            default:
                throw new NotSupportedException("Not supported backend response: " + code);
            }

            return(result, remaining);
        }
コード例 #5
0
        internal static ViscaResponse ProcessResponse(byte[] packet, ViscaCommand pendingCmd, out bool matchesPending)
        {
            byte src       = (byte)(packet[0] >> 4);
            byte socket    = (byte)(packet[1] & 0x0F);
            byte replyType = (byte)(packet[1] >> 4);

            matchesPending = false;

            if (packet.Last() != 0xFF)
            {
                throw new ArgumentException("Invalid Data:  Does not end with expected 0xFF");
            }

            ViscaResponse response = null;

            switch (replyType)
            {
            case 4:     //Ack
                if (pendingCmd == null)
                {
                    throw new InvalidOperationException();
                }

                response       = new Acknowledgement();
                matchesPending = true;
                break;

            case 5:                     //Completion (commands/inquiries)
                if (packet.Length == 3) //Command Complete
                {
                    response = new CommandComplete();
                }
                else
                {
                    matchesPending = true;
                    response       = (ViscaInquiryResponse)Activator.CreateInstance(pendingCmd.InquiryResponseType);
                }
                break;

            case 6:     //Error
                if (packet.Length != 4)
                {
                    throw new ArgumentException("Invalid Data: Error Packet not correct.");
                }
                response = new CommandError(packet[2]);

                if (pendingCmd != null)
                {
                    matchesPending = true;
                }

                break;

            default: throw new NotSupportedException();
            }

            response.SourceAddress = src;
            response.Socket        = socket;

            if (response is ViscaInquiryResponse)
            {
                //process only the meat data of the packet (strip out header and footer bytes)
                byte[] data = new byte[packet.Length - 3];

                Array.Copy(packet, 2, data, 0, packet.Length - 3);

                ((ViscaInquiryResponse)response).ProcessResponse_Internal(data);
            }

            return(response);
        }