Пример #1
0
        // process messages from the UI Form
        void OnWinformMessageHandler(FromWinformMsg msg)
        {
            switch (msg.Command)
            {
            case FromWinformMsg.MsgEnum.Loaded:
                // the windows form is ready to go
                _simulatedBipedMoverUI = (SimulatedBipedMoverUI)msg.Object;
                break;

            case FromWinformMsg.MsgEnum.MoveJoint:
                MoveJoint((MoveJoint)msg.Object);
                break;

            case FromWinformMsg.MsgEnum.Suspend:
                Task <simengine.VisualEntity, bool> deferredTask =
                    new Task <simengine.VisualEntity, bool>(_entity, (bool)msg.Object, SuspendBipedInternal);
                _entity.DeferredTaskQueue.Post(deferredTask);
                break;

            case FromWinformMsg.MsgEnum.ChangeEntity:
            {
                string entityName = (string)msg.Object;
                if (string.IsNullOrEmpty(entityName) == false)
                {
                    if (_entity == null || _entity.State.Name != entityName || _state.Joints == null || _state.Joints.Count == 0)
                    {
                        DeleteEntityInternal();
                        simengine.EntitySubscribeRequestType req = new Microsoft.Robotics.Simulation.Engine.EntitySubscribeRequestType();
                        req.Name = entityName;
                        _simEngine.Subscribe(req, _notificationTarget);
                    }
                }
                break;
            }

            case FromWinformMsg.MsgEnum.RefreshList:
            {
                SpawnIterator(RefreshListIterator);
                break;
            }
            }
        }
Пример #2
0
        void SubscribeForEntity()
        {
            // our entity instance name is passed as a partner
            PartnerType entityPartner = Dss.ServiceModel.DsspServiceBase.DsspServiceBase.FindPartner(
                new System.Xml.XmlQualifiedName(Microsoft.Robotics.Simulation.Partners.Entity, Microsoft.Robotics.Simulation.Contract.Identifier),
                ServiceInfo.PartnerList);

            if (entityPartner == null)
            {
                LogError("Invalid entity name specified as a partner to the iRobotLite Service");
            }
            else
            {
                // PartnerType.Service is the entity instance name.
                simengine.EntitySubscribeRequestType esrt = new simengine.EntitySubscribeRequestType();

                esrt.Name       = new Uri(entityPartner.Service).LocalPath.TrimStart('/');
                esrt.Subscriber = ServiceInfo.Service;
                _simEngine.Subscribe(esrt, _notificationTarget);
            }
        }