public virtual void UpdateAssessmentDetails( Quantity? quantity, MatterState? matterState, DustinessOrVolatility? dustinessOrVolatility, bool healthSurveillanceRequired, UserForAuditing currentUser) { Quantity = quantity; MatterState = matterState; DustinessOrVolatility = dustinessOrVolatility; HealthSurveillanceRequired = healthSurveillanceRequired; SetLastModifiedDetails(currentUser); }
public ControlSystem Calculate(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility) { if (hazardousSubstanceGroupCode == null || !matterState.HasValue || !quantity.HasValue || !dustinessOrVolatility.HasValue) return _controlSystemRepository.GetById((long)ControlSystemEnum.None); var rules = GetHazardousSubstanceGroupRules(); var rule = rules.FirstOrDefault(h => h.Group == hazardousSubstanceGroupCode && h.MatterState == matterState && h.Quantity == quantity && h.DustinessOrVolatility == dustinessOrVolatility); if(rule == null) { throw new NoneMatchingControlSystemRuleException(hazardousSubstanceGroupCode, matterState, quantity, dustinessOrVolatility); } return _controlSystemRepository.GetById((long)rule.ControlSystem); }
/// <summary> /// 反应物物态切换接口 /// </summary> /// <param name="state">要切换成的物态</param> public void StateSwitch(MatterState state) { switch (state) { case MatterState.gas: MatterIsGas(); break; case MatterState.liquid: MatterIsLiquid(); break; case MatterState.solid: MatterIsSolid(); break; } }
public JsonResult GetControlSystem(long riskAssessmentId, string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility) { var controlSystemDto = _controlSystemService.Calculate(hazardousSubstanceGroupCode, matterState, quantity, dustinessOrVolatility); _hazardousSubstanceRiskAssessmentService.SaveLastRecommendedControlSystem(new SaveLastRecommendedControlSystemRequest { Id = riskAssessmentId, CompanyId = CurrentUser.CompanyId, ControlSystemId = controlSystemDto.Id, UserId = CurrentUser.UserId }); var url = Url.Action("LoadControlSystem", new { controlSystem = controlSystemDto.Description }); return Json(new { ControlSystemId = controlSystemDto.Id, ControlSystem = controlSystemDto.Description, Url = url }, JsonRequestBehavior.AllowGet); }
public void Given_various_parameters_When_calculate_called_Then_returns_correct_control_system( string hazardGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility, string expectedDescription) { //When var controlSystemCalculationService = new ControlSystemCalculationService(_repository.Object); var controlSystem = controlSystemCalculationService.Calculate(hazardGroupCode, matterState, quantity, dustinessOrVolatility); //Then Assert.AreEqual(expectedDescription, controlSystem.Description); }
public HazardousSubstanceGroupRule(string group, MatterState matterState, Quantity quantity, DustinessOrVolatility dustinessOrVolatility, ControlSystemEnum controlSystem) { Group = group; MatterState = matterState; Quantity = quantity; DustinessOrVolatility = dustinessOrVolatility; ControlSystem = controlSystem; }
public NoneMatchingControlSystemRuleException(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility) : base(string.Format("No matching control system rule configured. Hazardous Substance Group Code is {0}. MatterStateId is {1}. QuantityId is {2}. DustinessOrVolatileId is {3}.", hazardousSubstanceGroupCode, matterState.GetValueOrDefault(),quantity.GetValueOrDefault(),dustinessOrVolatility.GetValueOrDefault())) {}
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.R)) { Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } left = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow); right = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow); jump = Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W); if (state == MatterState.Solid) { // Checks the bottom left, bottom middle, and bottom right of the player's hitbox BoxCollider2D box = gameObject.GetComponent <BoxCollider2D>(); Vector2 leftPoint = new Vector2(box.bounds.center.x - box.bounds.extents.x, box.bounds.center.y - box.bounds.extents.y); Vector2 midPoint = new Vector2(box.bounds.center.x, box.bounds.center.y - box.bounds.extents.y); Vector2 rightPoint = new Vector2(box.bounds.center.x + box.bounds.extents.x, box.bounds.center.y - box.bounds.extents.y); LayerMask mask = ~LayerMask.GetMask(new string[] { "Solid", "Liquid", "Gas" }); // If any of the three raycasts hit and any of the three jump buttons are pressed, jump if ((Physics2D.Raycast(leftPoint, Vector2.down, 0.1f, mask) || Physics2D.Raycast(midPoint, Vector2.down, 0.1f, mask) || Physics2D.Raycast(rightPoint, Vector2.down, 0.1f, mask)) && jump) { rigidbody.AddForce(Vector2.up * jumpSpeed); } } // Temperature temperature -= heatLossRate * Time.deltaTime; temperature = Mathf.Clamp(temperature, minTemp, maxTemp); animator.SetFloat("Temperature", temperature); thermo.GetComponent <Thermometer>().SetTemperature(temperature); if (temperature < freezingTemp) { state = MatterState.Solid; gameObject.layer = 8; } else if (temperature < boilingTemp) { state = MatterState.Liquid; gameObject.layer = 9; } else { state = MatterState.Gas; gameObject.layer = 10; } }
public void Given_a_HSRA_when_copy_then_matter_state_is_set(MatterState state) { //Given var user = new UserForAuditing(); var riskAssessment = HazardousSubstanceRiskAssessment.Create("new title", "new reference", 1, user, new HazardousSubstance()); riskAssessment.MatterState = state; //When var result = riskAssessment.Copy("Test Clone Reference", "", user) as HazardousSubstanceRiskAssessment; //Then Assert.That(result.MatterState, Is.EqualTo(state)); }
public ControlSystemDto Calculate(string hazardousSubstanceGroupCode, MatterState? matterState, Quantity? quantity, DustinessOrVolatility? dustinessOrVolatility) { var controlSystem = _controlSystemCalculationService.Calculate(hazardousSubstanceGroupCode, matterState, quantity, dustinessOrVolatility); return new ControlSystemDtoMapper().Map(controlSystem); }