Ejemplo n.º 1
0
        public static WrappedOp <CommandRequestOp> CreateCommandRequestOp(uint componentId, uint commandIndex, long requestId)
        {
            var schemaRequest = new SchemaCommandRequest(componentId, commandIndex);
            var op            = new CommandRequestOp
            {
                Request   = new CommandRequest(schemaRequest),
                RequestId = new RequestId <IncomingCommandRequest>(requestId)
            };

            return(new WrappedOp <CommandRequestOp>(op));
        }
Ejemplo n.º 2
0
        public void Send(EntityId entityId, uint componentId, uint commandIndex, SchemaCommandRequest request, uint?timeout, CommandParameters?parameters, Action <CommandResponses> complete, Action <StatusCode, string> fail)
        {
            long requestId;

            lock (connectionLock)
            {
                ThrowCommandFailedIfNotConnected();

                requestId = connection.SendCommandRequest(entityId.Value, new CommandRequest(componentId, commandIndex, request), timeout, parameters);
            }

            if (!requestsToComplete.TryAdd(requestId, new TaskHandler(complete, fail)))
            {
                throw new InvalidOperationException("Key already exists");
            }
        }