/// <inheritdoc /> public void UpdateData(object sender, EventArgs e) { try { ApplicationMode = (ApplicationMode)Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.IMDApplicationMode)); GeneralWeightError = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusGeneralWeightError))); ScaleAlarm = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleAlarm))); int LimitStatus = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusLimitStatus)); Underload = (LimitStatus == 1); Overload = (LimitStatus == 2); HigherSafeLoadLimit = (LimitStatus == 3); TareMode = EvaluateTareMode(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusManualTare)), Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusWeightType))); WeightStable = !Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusWeightMoving))); LegalForTrade = !Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleSealIsOpen))); ScaleRange = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusScaleRange)); ZeroRequired = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusZeroRequired))); CenterOfZero = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusCenterOfZero))); InsideZero = Convert.ToBoolean(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461WeightStatusInsideZero))); Decimals = Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461Decimals)); Unit = UnitIDToString(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461Unit))); Weight.Update(MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461NetValue)), Decimals), MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461GrossValue)), Decimals)); PrintableWeight.Update(MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461NetValue)), Decimals), MeasurementUtils.DigitToDouble(Convert.ToInt32(_connection.ReadFromBuffer(JetBusCommands.CIA461GrossValue)), Decimals), Decimals); } catch (KeyNotFoundException) { Console.WriteLine("KeyNotFoundException in class ProcessDataJet, update method"); } }
public void Update_existing_weight_with_all_values_should_succeed() { // Arrange Guid originalId = Guid.NewGuid(); WeightMeasurement expected = GenerateRandomWeightMeasurement(originalId); Weight bizLogic = new Weight(); var original = bizLogic.Create(expected); Assert.AreEqual(Common.MetrikOutcome.Created, original.Outcome, original.Message); // Act var artifactToUpdate = original.Artifact.Clone(); if (artifactToUpdate.Weight < 150) { artifactToUpdate.Weight += 10.0; } else { artifactToUpdate.Weight -= 10.0; } var actual = bizLogic.Update(original.Artifact, new List <string>() { "weight" }); // Assert actual.Outcome.Should().Be(Common.MetrikOutcome.Ok); actual.Artifact.EntryDate.ToUnixTimeSeconds().Should().Be(expected.EntryDate.ToUnixTimeSeconds()); actual.Artifact.Id.Should().NotBeEmpty(); actual.Artifact.Unit.Should().Be(expected.Unit); actual.Artifact.Weight.Should().Be(expected.Weight); }
public void Update_existing_weight_with_some_values_should_succeed() { // Arrange Guid originalId = Guid.NewGuid(); WeightMeasurement original = GenerateRandomWeightMeasurement(originalId); Weight bizLogic = new Weight(); var created = bizLogic.Create(original); // Act var expected = created.Artifact.Clone(); expected.Weight += 5; var actual = bizLogic.Update(expected, new List <string> { "weight" }); // Assert actual.Outcome.Should().Be(Common.MetrikOutcome.Ok); actual.Artifact.EntryDate.ToUnixTimeSeconds().Should().Be(expected.EntryDate.ToUnixTimeSeconds()); actual.Artifact.Id.Should().NotBeEmpty(); actual.Artifact.Unit.Should().Be(expected.Unit); actual.Artifact.Weight.Should().Be(expected.Weight); actual.Artifact.Weight.Should().NotBe(created.Artifact.Weight); }
public void AssignWeightDeltaOneGivenAllParametersAreOne() { // arrange - // weight.Value is a random doulbe between -0.5 and 0.5 excluding 0.0 assigned in the constructor // we set it to 0 here only to test the Update method weight.Value = 0; // act weight.Update(1, 1, 1); var weightDeltaResult = weight.WeightDelta; var valueResult = weight.Value; // assert Assert.Equal(weightDeltaResult, 1); Assert.Equal(valueResult, 1); }