Пример #1
0
        public void updateData(TBFrame data)
        {
            List <IDataClientPrx> clients;

            lock (this)
            {
                clients = new List <IDataClientPrx>(_Clients);
            }
            foreach (var client in clients)
            {
                try
                {
                    client.begin_update(data);
                }
                catch (Ice.TimeoutException te)
                {
                    //DO Nothing! :D
                }
                catch (Ice.LocalException le)
                {
                    Console.Error.WriteLine("Remove Client because of: " + le.ToString());
                    lock (this)
                    {
                        _Clients.Remove(client);
                    }
                }
            }
        }
Пример #2
0
 public Receiver(ref TBFrame frame, ref Robot bot, ref AMD_IDataServer_update cb)
 {
     _Frame    = frame;
     _Bot      = bot;
     _CallBack = cb;
 }
Пример #3
0
        public void update(TBFrame data)
        {
            switch (data.Id)
            {
            case Constants.TB_COMMAND_ID:
                break;

            case Constants.TB_VELOCITY_ID:
                if (!(data is TBVelocity))
                {
                    throw new Exception("Frame is not a Velocity Frame");
                }
                TBVelocity velocityData = (TBVelocity)data;

                if (velocityData.SubId == Constants.TB_VELOCITY_FORWARD)
                {
                    _Bot.setVelocity(velocityData.speedLeft * 4, velocityData.speedRight * 4, WheelDirection.Forwards, WheelDirection.Forwards);
                }
                else if (velocityData.SubId == Constants.TB_VELOCITY_BACKWARD)
                {
                    _Bot.setVelocity(velocityData.speedLeft * 4, velocityData.speedRight * 4, WheelDirection.Backwards, WheelDirection.Backwards);
                }
                else if (velocityData.SubId == Constants.TB_VELOCITY_TURN_LEFT)
                {
                    _Bot.setVelocity(velocityData.speedLeft * 4, velocityData.speedRight * 4, WheelDirection.Backwards, WheelDirection.Forwards);
                }
                else if (velocityData.SubId == Constants.TB_VELOCITY_TURN_RIGHT)
                {
                    _Bot.setVelocity(velocityData.speedLeft * 4, velocityData.speedRight * 4, WheelDirection.Forwards, WheelDirection.Backwards);
                }
                break;

            case Constants.TB_POSITION_ID:
                if (!(data is TBPosition))
                {
                    throw new Exception("Frame is not a Position Frame");
                }
                TBPosition positionData = (TBPosition)data;
                _Bot.PositionRequested = true;
                if (positionData.SubId == Constants.TB_POSITION_FORWARD)
                {
                    _Bot.setPosition((ushort)positionData.distance);
                }
                else if (positionData.SubId == Constants.TB_POSITION_BACKWARD)
                {
                    _Bot.setPosition(-(ushort)positionData.distance);
                }
                else if (positionData.SubId == Constants.TB_POSITION_TURN_LEFT)
                {
                    _Bot.setAngle(-(ushort)positionData.distance);
                }
                else if (positionData.SubId == Constants.TB_POSITION_TURN_RIGHT)
                {
                    _Bot.setAngle((ushort)positionData.distance);
                }
                break;

            case Constants.TB_ERROR_ID:
                break;
            }
        }
Пример #4
0
        public override void update_async(AMD_IDataServer_update cb__, TBFrame data, Ice.Current current__)
        {
            Receiver r = new Receiver(ref data, ref _Bot, ref cb__);

            ThreadPool.QueueUserWorkItem(r.ThreadPoolCallback);
        }