public static void XmlSFAttributeRpcEncSingleNsTest() { BasicHttpBinding binding = null; EndpointAddress endpointAddress = null; ChannelFactory <ICalculatorRpcEnc> factory1 = null; ICalculatorRpcEnc serviceProxy1 = null; // *** SETUP *** \\ binding = new BasicHttpBinding(); endpointAddress = new EndpointAddress(Endpoints.BasicHttpRpcEncSingleNs_Address); factory1 = new ChannelFactory <ICalculatorRpcEnc>(binding, endpointAddress); serviceProxy1 = factory1.CreateChannel(); // *** EXECUTE Variation *** \\ try { var dateTime = DateTime.Now; var intParams = new IntParams() { P1 = 5, P2 = 10 }; var floatParams = new FloatParams() { P1 = 5.0f, P2 = 10.0f }; var byteParams = new ByteParams() { P1 = 5, P2 = 10 }; Assert.Equal(3, serviceProxy1.Sum2(1, 2)); Assert.Equal(intParams.P1 + intParams.P2, serviceProxy1.Sum(intParams)); Assert.Equal(string.Format("{0}{1}", intParams.P1, intParams.P2), serviceProxy1.Concatenate(intParams)); Assert.Equal((float)(floatParams.P1 / floatParams.P2), serviceProxy1.Divide(floatParams)); Assert.Equal((new byte[] { byteParams.P1, byteParams.P2 }), serviceProxy1.CreateSet(byteParams)); Assert.Equal(dateTime, serviceProxy1.ReturnInputDateTime(dateTime)); Guid guid = Guid.NewGuid(); serviceProxy1.AddIntParams(guid, intParams); IntParams outputIntParams = serviceProxy1.GetAndRemoveIntParams(guid); Assert.NotNull(outputIntParams); Assert.Equal(intParams.P1, outputIntParams.P1); Assert.Equal(intParams.P2, outputIntParams.P2); } catch (Exception ex) { Assert.True(false, ex.Message); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy1); } }
/// <summary> /// Called when a parameter is changed. Note that these values should all be pre-clamped /// </summary> /// <param name="param"></param> /// <param name="newValue"></param> internal void FloatParamChanged(FloatParams param, float newValue) { // Though the external float param setter permits setting vector params, the LSL wrapper // detects that and routes those cases to the internal vector param setter. // Reminder: the motor float timescale params are now vector params. //m_log.DebugFormat("[FloatParamChanged] {0} <- {1}", param, newValue); switch (param) { case FloatParams.VehicleBuoyancy: // Constrain the buoyancy to the gravity multiplier extent. This maintains // compatibility with GM=1 but permits similar behaviors with other values. float gm = Math.Abs(_actor.Properties.Material.GravityMultiplier); if (gm == 0) gm = 1.0f; newValue = Utils.Clamp(newValue, -gm, gm); _props.ParamsFloat[param] = newValue; SetVehicleBuoyancy(); break; case FloatParams.VehicleHoverEfficiency: _props.ParamsFloat[param] = newValue; SetVehicleHover(); break; case FloatParams.VehicleHoverHeight: _props.ParamsFloat[param] = newValue; SetVehicleHover(); break; case FloatParams.VehicleHoverTimescale: _props.ParamsFloat[param] = newValue; SetVehicleHover(); break; } // Update the active shadow copy. _props.ParamsFloat[param] = newValue; _actor.WakeUp(); }
/// <summary> /// Clamps a float param /// /// WARNING: This code is almost always executed from outside the physics thread. /// </summary> /// <param name="param"></param> /// <param name="newValue"></param> /// <returns>clamped_newvalue</returns> internal static float ClampFloatParam(FloatParams param, float newValue) { if (float.IsNaN(newValue)) newValue = 0; switch (param) { case FloatParams.VehicleAngularDeflectionEfficiency: return Utils.Clamp(newValue, 0.0f, 1.0f); case FloatParams.VehicleAngularDeflectionTimescale: return Utils.Clamp(newValue, VehicleLimits.MinPhysicsTimestep, VehicleLimits.MaxTimescale); case FloatParams.VehicleBankingEfficiency: return Utils.Clamp(newValue, -1.0f, 1.0f); case FloatParams.VehicleInvertedBankingModifier: return Utils.Clamp(newValue, -10.0f, 10.0f); case FloatParams.VehicleBankingMix: return Utils.Clamp(newValue, 0.0f, 1.0f); case FloatParams.VehicleBankingTimescale: return Utils.Clamp(newValue, VehicleLimits.MinPhysicsTimestep, VehicleLimits.MaxTimescale); case FloatParams.VehicleMouselookAltitude: return Utils.Clamp(newValue, VehicleLimits.ThresholdMouselookAngle, (float)Math.PI); case FloatParams.VehicleMouselookAzimuth: return Utils.Clamp(newValue, VehicleLimits.ThresholdMouselookAngle, (float)Math.PI); case FloatParams.VehicleBankingAzimuth: return Utils.Clamp(newValue, VehicleLimits.ThresholdBankAngle, (float)Math.PI); case FloatParams.VehicleBuoyancy: return Utils.Clamp(newValue, -2.0f, 30.0f); // Wider range because of gravity multiplier case FloatParams.VehicleHoverEfficiency: return Utils.Clamp(newValue, 0.0f, 1.0f); case FloatParams.VehicleHoverHeight: return Utils.Clamp(newValue, VehicleLimits.MinRegionHeight, VehicleLimits.MaxRegionHeight); case FloatParams.VehicleHoverTimescale: return Utils.Clamp(newValue, VehicleLimits.MinPhysicsTimestep, VehicleLimits.MaxHoverTimescale); case FloatParams.VehicleLinearDeflectionEfficiency: return Utils.Clamp(newValue, 0.0f, 1.0f); case FloatParams.VehicleLinearDeflectionTimescale: return Utils.Clamp(newValue, VehicleLimits.MinPhysicsTimestep, VehicleLimits.MaxTimescale); case FloatParams.VehicleVerticalAttractionTimescale: return Utils.Clamp(newValue, VehicleLimits.MinPhysicsTimestep, VehicleLimits.MaxAttractTimescale); default: //no clamping? return newValue; } }
public override void SetVehicleFloatParam(FloatParams param, float value) { _scene.QueueCommand( new Commands.GenericSyncCmd(this, (PhysxScene scene) => { value = Vehicle.VehicleDynamics.ClampFloatParam(param, value); CheckCreateVehicleProperties(); _properties.VehicleProps.ParamsFloat[param] = value; CheckCreateVehicleDynamics(); _vehicleDynamics.FloatParamChanged(param, value); } ) ); }
private static void RunVariation(string serviceAddress, bool isMultiNs = false) { BasicHttpBinding binding = null; EndpointAddress endpointAddress = null; ChannelFactory <ICalculator> factory1 = null; ChannelFactory <IHelloWorld> factory2 = null; ICalculator serviceProxy1 = null; IHelloWorld serviceProxy2 = null; // *** SETUP *** \\ binding = new BasicHttpBinding(); endpointAddress = new EndpointAddress(serviceAddress); factory1 = new ChannelFactory <ICalculator>(binding, endpointAddress); serviceProxy1 = factory1.CreateChannel(); if (isMultiNs) { factory2 = new ChannelFactory <IHelloWorld>(binding, endpointAddress); serviceProxy2 = factory2.CreateChannel(); } // *** EXECUTE Variation *** \\ try { var dateTime = DateTime.Now; string testStr = "test string"; var intParams = new IntParams() { P1 = 5, P2 = 10 }; var floatParams = new FloatParams() { P1 = 5.0f, P2 = 10.0f }; var byteParams = new ByteParams() { P1 = 5, P2 = 10 }; Assert.Equal(3, serviceProxy1.Sum2(1, 2)); Assert.Equal(intParams.P1 + intParams.P2, serviceProxy1.Sum(intParams)); Assert.Equal(string.Format("{0}{1}", intParams.P1, intParams.P2), serviceProxy1.Concatenate(intParams)); Assert.Equal((float)(floatParams.P1 / floatParams.P2), serviceProxy1.Divide(floatParams)); Assert.Equal((new byte[] { byteParams.P1, byteParams.P2 }), serviceProxy1.CreateSet(byteParams)); Assert.Equal(dateTime, serviceProxy1.ReturnInputDateTime(dateTime)); Guid guid = Guid.NewGuid(); serviceProxy1.AddIntParams(guid, intParams); IntParams outputIntParams = serviceProxy1.GetAndRemoveIntParams(guid); Assert.NotNull(outputIntParams); Assert.Equal(intParams.P1, outputIntParams.P1); Assert.Equal(intParams.P2, outputIntParams.P2); if (isMultiNs) { Guid guid2 = Guid.NewGuid(); serviceProxy2.AddString(guid2, testStr); Assert.Equal(testStr, serviceProxy2.GetAndRemoveString(guid2)); } } catch (Exception ex) { Assert.True(false, ex.Message); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy1); if (isMultiNs) { ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy2); } } }