Beispiel #1
0
        /// <summary>
        /// PursuitCamera Start is called when service initializes
        /// </summary>
        protected override void Start()
        {
            if (_state == null)
            {
                _state = new PursuitCameraState
                {
                    MinDistance        = 4,
                    MaxDistance        = 6,
                    FieldOfView        = 45,
                    Altitude           = 2,
                    OcclusionThreshold = 0.5f,
                    PreventOcclusion   = true,
                    CameraName         = "PursuitCamera"
                };
            }

            base.Start();

            _physics = physics.PhysicsEngine.GlobalInstance;
            _simPort = sime.SimulationEngine.GlobalInstancePort;

            _simPort.Subscribe(ServiceInfo.PartnerList, _simNotify);

            base.MainPortInterleave.CombineWith(
                Arbiter.Interleave(
                    new TeardownReceiverGroup(),
                    new ExclusiveReceiverGroup(
                        Arbiter.ReceiveWithIterator <sime.InsertSimulationEntity>(true, _simNotify, OnInsertEntity),
                        Arbiter.Receive <sime.DeleteSimulationEntity>(true, _simNotify, OnDeleteEntity)
                        ),
                    new ConcurrentReceiverGroup()
                    )
                );
        }
        /// <summary>
        /// SimulatedFourByFourDriveService start gets called when service initializes
        /// </summary>
        protected override void Start()
        {
            _simEngine = sime.SimulationEngine.GlobalInstancePort;
            base.Start();

            _simEngine.Subscribe(ServiceInfo.PartnerList, _simNotify);


            //
            // don't start service handlers until we have found the entity.
            // however, do insert into the directory.
            //
            Activate(
                new Interleave(
                    new TeardownReceiverGroup(
                        Arbiter.Receive <sime.InsertSimulationEntity>(false, _simNotify, OnFoundEntity),
                        Arbiter.Receive <DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                        ),
                    new ExclusiveReceiverGroup(),
                    new ConcurrentReceiverGroup()
                    )
                );

            DirectoryInsert();
        }
        protected override void Start()
        {
            _simEngine          = simengine.SimulationEngine.GlobalInstancePort;
            _notificationTarget = new simengine.SimulationEnginePort();

            if (_state == null)
            {
                CreateDefaultState();
            }

            // PartnerType.Service is the entity instance name.
            _simEngine.Subscribe(ServiceInfo.PartnerList, _notificationTarget);

            // don't start listening to DSSP operations, other than drop, until notification of entity
            Activate(new Interleave(
                         new TeardownReceiverGroup
                         (
                             Arbiter.Receive <simengine.InsertSimulationEntity>(false, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                             Arbiter.Receive <DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup
                         (
                             Arbiter.Receive <FromWinformMsg>(true, _fromWinformPort, OnWinformMessageHandler)
                         ),
                         new ConcurrentReceiverGroup()
                         ));

            // Create the user interface form
            WinFormsServicePort.Post(new Microsoft.Ccr.Adapters.WinForms.RunForm(CreateForm));

            Activate(Arbiter.Receive(false, TimeoutPort(5000), dateTime => SpawnIterator(RefreshListIterator)));
        }
        // 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;
            }
            }
        }
Beispiel #5
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);
            }
        }
        /// <summary>
        /// Start initializes service state and listens for drop messages
        /// </summary>
        protected override void Start()
        {
            // Find our simulation entity that represents the "hardware" or real-world service.
            // To hook up with simulation entities we do the following steps
            // 1) have a manifest or some other service create us, specifying a partner named SimulationEntity
            // 2) in the simulation service (us) issue a subscribe to the simulation engine looking for
            //    an instance of that simulation entity. We use the Entity.State.Name for the match so it must be
            //    exactly the same. See SimulationTutorial2 for the creation process
            // 3) Listen for a notification telling us the entity is available
            // 4) cache reference to entity and communicate with it issuing low level commands.

            _simEngine          = simengine.SimulationEngine.GlobalInstancePort;
            _notificationTarget = new simengine.SimulationEnginePort();

            if (_state == null)
            {
                CreateDefaultState();
            }

            // enabled by default
            _state.IsEnabled = true;

            // PartnerType.Service is the entity instance name.
            _simEngine.Subscribe(ServiceInfo.PartnerList, _notificationTarget);

            // dont start listening to DSSP operations, other than drop, until notification of entity
            Activate(new Interleave(
                         new TeardownReceiverGroup
                         (
                             Arbiter.Receive <simengine.InsertSimulationEntity>(false, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                             Arbiter.Receive <DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup(),
                         new ConcurrentReceiverGroup()
                         ));
        }
        protected override void Start()
        {
            // Find our simulation entity that represents the "hardware" or real-world service.
            // To hook up with simulation entities we do the following steps
            // 1) have a manifest or some other service create us, specifying a partner named SimulationEntity
            // 2) in the simulation service (us) issue a subscribe to the simulation engine looking for
            //    an instance of that simulation entity. We use the Entity.State.Name for the match so it must be
            //    exactly the same. See SimulationTutorial2 for the creation process
            // 3) Listen for a notification telling us the entity is available
            // 4) cache reference to entity and communicate with it issuing low level commands.

            _simEngine = simengine.SimulationEngine.GlobalInstancePort;
            _notificationTarget = new simengine.SimulationEnginePort();

            if (_state == null)
                CreateDefaultState();

            // PartnerType.Service is the entity instance name. 
            _simEngine.Subscribe(ServiceInfo.PartnerList, _notificationTarget);

            // dont start listening to DSSP operations, other than drop, until notification of entity
            Activate(new Interleave(
                new TeardownReceiverGroup
                (
                    Arbiter.Receive<simengine.InsertSimulationEntity>(false, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                    Arbiter.Receive<DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                ),
                new ExclusiveReceiverGroup(),
                new ConcurrentReceiverGroup()
            ));
        }