Ejemplo n.º 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();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            ValidateState();

            base.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();

            MainPortInterleave.CombineWith(new Interleave(
                                               new TeardownReceiverGroup(),
                                               new ExclusiveReceiverGroup
                                               (
                                                   Arbiter.Receive <simengine.InsertSimulationEntity>(true, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                                                   Arbiter.ReceiveWithIterator <irobottypes.Connect>(true, _mainPort, ConnectHandler)
                                               ),
                                               new ConcurrentReceiverGroup()
                                               ));

            SubscribeForEntity();
        }
Ejemplo n.º 4
0
        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)));
        }
        /// <summary>
        /// Start initializes SimulatedBumperService and listens for drop messages
        /// </summary>
        protected override void Start()
        {
            // Find the Bumper entity we are supposed to be hooked up with
            // Detailed explanation on how simulation services compose with the simulation entities
            // can be found in SimulationTutorial2 and also in the InitializeSimulation() method
            // of other simulation service (like the SimulatedDifferentialDrive)

            _notificationTarget = new simengine.SimulationEnginePort();

            // PartnerType.Service is the entity instance name
            simengine.SimulationEngine.GlobalInstancePort.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 <dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup(),
                         new ConcurrentReceiverGroup()
                         ));
        }
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            _notificationTarget = new simengine.SimulationEnginePort();
            _utilitiesPort      = DsspHttpUtilitiesService.Create(Environment);
            simengine.SimulationEngine.GlobalInstancePort.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 <dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup(),
                         new ConcurrentReceiverGroup()
                         ));
        }
        /// <summary>
        /// Locates the camera entity.
        /// </summary>
        /// <param name="responsePort">The response port.</param>
        /// <returns>Standard ccr iterator</returns>
        private IEnumerator <ITask> LocateCameraEntity(PortSet <VisualEntity, Fault> responsePort)
        {
            // Subscribe for it in the simulation engine
            var simenginePort     = simengine.SimulationEngine.GlobalInstancePort;
            var notificationPort  = new simengine.SimulationEnginePort();
            var subscribeResponse = simenginePort.Subscribe(ServiceInfo.PartnerList, notificationPort);
            var subscribeFailure  = (Fault)subscribeResponse;

            if (subscribeFailure != null)
            {
                responsePort.Post(subscribeFailure);
                yield break;
            }

            var insertPort = notificationPort.P6;

            yield return(insertPort.Receive(inserted => responsePort.Post(inserted.Body)));

            yield break;
        }
Ejemplo n.º 8
0
        protected override void Start()
        {

            _notificationTarget = new simengine.SimulationEnginePort();
            simengine.SimulationEngine.GlobalInstancePort.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<dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                ),
                new ExclusiveReceiverGroup(),
                new ConcurrentReceiverGroup()
            ));

            // start notification method
            SpawnIterator<DateTime>(DateTime.Now, CheckForStateChange);
        }
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            _notificationTarget = new simengine.SimulationEnginePort();

            // PartnerType.Service is the entity instance name.
            simengine.SimulationEngine.GlobalInstancePort.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 <dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup(),
                         new ConcurrentReceiverGroup()
                         ));

            // start notification method
            SpawnIterator <DateTime>(DateTime.Now, CheckForStateChange);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Start initializes SimulatedDepthcamService and listens for drop messages
        /// </summary>
        protected override void Start()
        {
            const double KinectMaxValidDepthMm = 4000.0;
            const double KinectMinValidDepthMm = 800.0;

            if (this._state == null)
            {
                // no config file found, initialize default state according to KinectReservedSampleValues
                this._state = new DepthCamSensorState();
                this._state.MaximumRange             = KinectMaxValidDepthMm / 1000.0;
                this._state.MinimumRange             = KinectMinValidDepthMm / 1000.0;
                this._state.FurtherThanMaxDepthValue = (short)4095.0;
                this._state.NearerThanMinDepthValue  = (short)0.0;

                this.SaveState(this._state);
            }

            this._physicsEngine = physics.PhysicsEngine.GlobalInstance;
            _notificationTarget = new simengine.SimulationEnginePort();

            utilitiesPort = DsspHttpUtilitiesService.Create(Environment);

            // PartnerType.Service is the entity instance name.
            simengine.SimulationEngine.GlobalInstancePort.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 <dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                         ),
                         new ExclusiveReceiverGroup(),
                         new ConcurrentReceiverGroup()
                         ));
        }
        /// <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()
                         ));
        }
Ejemplo n.º 12
0
        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()
            ));
        }
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {			
			// Get the notification target
            _notificationTarget = new simengine.SimulationEnginePort();

            // PartnerType.Service is the entity instance name
            simengine.SimulationEngine.GlobalInstancePort.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<dssp.DsspDefaultDrop>(false, _mainPort, DefaultDropHandler)
                ),
                new ExclusiveReceiverGroup(),
                new ConcurrentReceiverGroup()
            ));


        }