Example #1
0
        void SetActuatorValueHandler(InternalSetActuatorValue setActuatorValue)
        {
            int actuatorID = setActuatorValue.actuatorID;

            if ((actuatorID > 0) && (actuatorID <= 2))
            {
                float value = _state.actuator[actuatorID - 1].value = setActuatorValue.value;

                LogVerbose("--- Actuator " + actuatorID.ToString() + " updated to " + value);

                switch (actuatorID)
                {
                case 1:
                    _srv1.LeftMotorPower = value;
                    break;

                case 2:
                    _srv1.RightMotorPower = value;
                    break;
                }
                setActuatorValue.ResponsePort.Post(new DefaultUpdateResponseType());
            }
            else
            {
                setActuatorValue.ResponsePort.Post(
                    Fault.FromCodeSubcodeReason(FaultCodes.Receiver,
                                                DsspFaultCodes.OperationFailed,
                                                "Bad Index")
                    );
            }
        }
Example #2
0
        private void SetActuator_Value(int actuatorID, float?actuatorValue)
        {
            if (actuatorValue == null)
            {
                return;
            }

            InternalSetActuatorValue update = new InternalSetActuatorValue();

            update.actuatorID   = actuatorID;
            update.value        = (float)actuatorValue;
            update.ResponsePort = new DsspResponsePort <DefaultUpdateResponseType>();

            _updatePort.Post(update);

            Activate(
                Arbiter.Choice(update.ResponsePort,
                               delegate(DefaultUpdateResponseType response)
            {
            },
                               delegate(Fault fault)
            {
                LogError("Failed to send notification");
            }
                               ));
        }