Esempio n. 1
0
        public async void WriteToRobot(DeviceMessage message)
        {
            RobotSession robotSession = this;
            Int32        num          = robotSession._seqNum;
            Int32        num1         = num;

            robotSession._seqNum = num + 1;
            if (num1 >= 255)
            {
                _seqNum = 0;
            }
            message.setSequence((Byte)_seqNum);
            Byte[]     data       = message.Data;
            DataWriter dataWriter = new DataWriter();

            try
            {
                dataWriter.WriteBytes(data);
                await _socket.OutputStream.WriteAsync(dataWriter.DetachBuffer());
            }
            finally
            {
                if (dataWriter != null)
                {
                    dataWriter.Dispose();
                }
            }
        }
Esempio n. 2
0
 public SensorControl(RobotSession robotSession)
 {
     _robotSession = robotSession;
 }
 public CollisionControl(RobotSession robotSession)
 {
     _robotSession = robotSession;
 }
Esempio n. 4
0
 internal async Task<Boolean> Connect()
 {
     Boolean flag;
     Debug.WriteLine(String.Concat("Connecting: ", _info.DisplayName));
     try
     {
     
         if (_info == null)
         {
             Debug.WriteLine(String.Concat("Unable to build Service for ", this));
             flag = false;
             return flag;
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;Debug.WriteLine(String.Concat("Exception looking up service ", _info.DisplayName, " ", exception.Message));
         flag = false;
         return flag;
     }
     var dispatcher = Deployment.Current.Dispatcher;
     _session = new RobotSession(_info, this, dispatcher);
     if (!await _session.Initialize())
     {
         flag = false;
     }
     else
     {
         InternalSetConnectionState(ConnectionState.Connected);
         Debug.WriteLine(String.Concat("Connected: ", ToString()));
         _sensorControl = new SensorControl(_session);
         _collisionControl = new CollisionControl(_session);
         _session._responseDelegate = new RobotSession.RobotResponseDelegate(OnResponseReceived);
         flag = true;
     }
     return flag;
 }