Beispiel #1
0
        public virtual IEnumerator <ITask> QueryBrickNameHandler(QueryBrickName query)
        {
            BrickNameResponse response = new BrickNameResponse();

            nxtcmd.LegoGetDeviceInfo cmd = new nxtcmd.LegoGetDeviceInfo();
            yield return(Arbiter.Choice(_legoBrickPort.SendNxtCommand(cmd),
                                        delegate(nxtcmd.LegoResponse ok)
            {
                nxtcmd.LegoResponseGetDeviceInfo queryResponse = nxtcmd.LegoResponse.Upcast <nxtcmd.LegoResponseGetDeviceInfo>(ok);
                if (queryResponse.Success)
                {
                    response.BrickName = queryResponse.BrickName;
                    query.ResponsePort.Post(response);
                }
                else
                {
                    query.ResponsePort.Post(Fault.FromException(new System.IO.FileNotFoundException(queryResponse.ErrorCode.ToString())));
                }
            },
                                        delegate(Fault fault)
            {
                query.ResponsePort.Post(fault);
            }));

            yield break;
        }
        public virtual IEnumerator<ITask> QueryBrickNameHandler(QueryBrickName query)
        {
            BrickNameResponse response = new BrickNameResponse();

            nxtcmd.LegoGetDeviceInfo cmd = new nxtcmd.LegoGetDeviceInfo();
            yield return Arbiter.Choice(_legoBrickPort.SendNxtCommand(cmd),
                delegate(nxtcmd.LegoResponse ok)
                {
                    nxtcmd.LegoResponseGetDeviceInfo queryResponse = nxtcmd.LegoResponse.Upcast<nxtcmd.LegoResponseGetDeviceInfo>(ok);
                    if (queryResponse.Success)
                    {
                        response.BrickName = queryResponse.BrickName;
                        query.ResponsePort.Post(response);
                    }
                    else
                    {
                        query.ResponsePort.Post(Fault.FromException(new System.IO.FileNotFoundException(queryResponse.ErrorCode.ToString())));
                    }
                },
                delegate(Fault fault)
                {
                    query.ResponsePort.Post(fault);
                });

            yield break;
        }