Exemplo n.º 1
0
		protected override void Start()
		{
			// Configure default state. It will be replaced by the drive during configuration.
			if (_state == null)
			{
				_state = new pxencoder.EncoderState();
				_state.HardwareIdentifier = -1;			// 1=Left 2=Right
				_state.TicksPerRevolution = 100;

				SaveState(_state);
			}

            base.Start();

            MainPortInterleave.CombineWith(new Interleave(
                new ExclusiveReceiverGroup(
                    // prepare listening for Power Brick's encoder change notifications
                    Arbiter.Receive<powerbrick.UpdateMotorEncoder>(true, notificationPortEncoder, MotorEncoderNotificationHandler)
                ),
                new ConcurrentReceiverGroup()
            ));

			// display HTTP service Uri
			LogInfo("Service uri: " + ServiceInfo.HttpUri());

			// Subscribe to the Hardware Controller for encoder notifications
			if (ValidState(_state))
			{
				SubscribeToPowerBrick();
			}
		}
        protected override void Start()
        {
            // Configure default state. It will be replaced by the drive during configuration.
            if (_state == null)
            {
                _state = new pxencoder.EncoderState();
                _state.HardwareIdentifier = -1;                                 // 1=Left 2=Right
                _state.TicksPerRevolution = 100;

                SaveState(_state);
            }

            base.Start();

            MainPortInterleave.CombineWith(new Interleave(
                                               new ExclusiveReceiverGroup(
                                                   // prepare listening for Power Brick's encoder change notifications
                                                   Arbiter.Receive <powerbrick.UpdateMotorEncoder>(true, notificationPortEncoder, MotorEncoderNotificationHandler)
                                                   ),
                                               new ConcurrentReceiverGroup()
                                               ));

            // display HTTP service Uri
            LogInfo("Service uri: " + ServiceInfo.HttpUri());

            // Subscribe to the Hardware Controller for encoder notifications
            if (ValidState(_state))
            {
                SubscribeToPowerBrick();
            }
        }
Exemplo n.º 3
0
        protected override void Start()
        {
            //configure default state
            if (_state == null)
            {
                _state = new encoder.EncoderState();
                _state.HardwareIdentifier = -1;
                _state.TicksPerRevolution = 6;

                SaveState(_state);
            }

            // Listen for each of my handlers
            _mainInterleave = ActivateDsspOperationHandlers();

            // Publish the service to the local Node Directory
            DirectoryInsert();

            // display HTTP service Uri
            LogInfo(LogGroups.Console, "Service uri: ");

            // Subscribe to NXT for encoder notifications
            if (ValidState(_state))
            {
                SubscribeToNXT();
            }
        }
 private static bool ValidState(pxencoder.EncoderState state)
 {
     if (state != null)
     {
         if (state.HardwareIdentifier >= 1 && state.HardwareIdentifier <= 2)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        public IEnumerator <ITask> ReplaceHandler(encoder.Replace replace)
        {
            if (_subscribed)
            {
                throw new InvalidOperationException("Already subscribed");
            }
            else if (ValidState(replace.Body))
            {
                _state = replace.Body;
                SaveState(_state);
                replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
                SubscribeToNXT();
            }
            else
            {
                throw new InvalidOperationException("Invalid State for replacement");
            }

            yield break;
        }
        public IEnumerator <ITask> ReplaceHandler(pxencoder.Replace replace)
        {
            //LogInfo("TrackRoamerEncoder : ReplaceHandler()");

            if (_subscribed)
            {
                LogError("TrackRoamerEncoder : ReplaceHandler(): Already subscribed");
            }
            else if (ValidState(replace.Body))
            {
                //_state = (TREncoderState)replace.Body;
                _state = replace.Body;
                SaveState(_state);
                replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
                SubscribeToPowerBrick();
            }
            else
            {
                LogError("TrackRoamerEncoder : ReplaceHandler(): Invalid State for replacement");
            }

            yield break;
        }
Exemplo n.º 7
0
        public IEnumerator<ITask> ReplaceHandler(pxencoder.Replace replace)
        {
            //LogInfo("TrackRoamerEncoder : ReplaceHandler()");

			if (_subscribed)
			{
				LogError("TrackRoamerEncoder : ReplaceHandler(): Already subscribed");
			}
			else if (ValidState(replace.Body))
			{
				//_state = (TREncoderState)replace.Body;
				_state = replace.Body;
				SaveState(_state);
				replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
				SubscribeToPowerBrick();
			}
			else
			{
				LogError("TrackRoamerEncoder : ReplaceHandler(): Invalid State for replacement");
			}

            yield break;
        }
 public virtual IEnumerator<ITask> EncoderHttpGetHandler(HttpGet get)
 {
     int hardwareIdentifier = _state.ToGenericState(_genericState).HardwareIdentifier;
     pxencoder.EncoderState encoderState = new pxencoder.EncoderState(hardwareIdentifier, (int)_state.CurrentEncoderDegrees);
     get.ResponsePort.Post(new dssphttp.HttpResponseType(encoderState));
     yield break;
 }