public void ConstructsFromChRtuPointCorrectly(int ch, int rtu, int point) { var tmAnalog = new TmAnalog(ch, rtu, point); Assert.Equal(TmType.Analog, tmAnalog.Type); Assert.Equal(ch, tmAnalog.TmAddr.Ch); Assert.Equal(rtu, tmAnalog.TmAddr.Rtu); Assert.Equal(point, tmAnalog.TmAddr.Point); }
public void SetsCorrectTeleregulationToAnalog(string code, TmTeleregulation expectedTeleregulation, TmAnalog analog) { var sb = $"FBFlagsC={code}"; analog.SetTmcObjectProperties(sb); analog.Teleregulation.Should().Be(expectedTeleregulation); }
public void ReturnsFalseForWrongType(int ch, int rtu, int point) { var tmAnalog1 = new TmAnalog(ch, rtu, point); var tmStatus = new TmStatus(ch, rtu, point); var result = tmAnalog1.Equals(tmStatus); Assert.False(result); }
public void SetsCorrectFormatToAnalog(string format, byte expectedWidth, byte expectedPrecision, TmAnalog analog) { var sb = $"Format={format}"; analog.SetTmcObjectProperties(sb); analog.Width.Should().Be(expectedWidth); analog.Precision.Should().Be(expectedPrecision); }
public void ReturnsFalseForWrongFlags(int ch, int rtu, int point) { var tmAnalog1 = new TmAnalog(ch, rtu, point); var tmAnalog2 = new TmAnalog(ch, rtu, point) { Flags = TmFlags.Unreliable }; var result = tmAnalog1 == tmAnalog2; Assert.False(result); }
public void ReturnsCorrectString(int ch, int rtu, int point, float value, byte precision, string unit, string expected) { var tmAnalog = new TmAnalog(ch, rtu, point) { IsInit = true, Value = value, Precision = precision, Unit = unit }; var result = tmAnalog.ToString(); Assert.Equal(expected, result); }
public void ReturnsCorrectString(float value, byte precision, string expected) { var tmAnalog = new TmAnalog(0, 1, 1) { IsInit = true, Value = value }; var result = tmAnalog.ValueStringWithPrecision(precision); Assert.Equal(expected, result); }
public async Task <IActionResult> ShowTi(string id) { if (!TmAddr.TryParse(id, out var tmAddr, TmType.Analog)) { return(NotFound()); } var tmAnalog = new TmAnalog(tmAddr); await Task.WhenAll(_api.UpdateTagPropertiesAndClassData(tmAnalog), _api.UpdateAnalog(tmAnalog)); return(Ok(_mapper.Map <TmAnalogDto>(tmAnalog))); }
public void ReturnsFalseForWrongValue(int ch, int rtu, int point) { var tmAnalog1 = new TmAnalog(ch, rtu, point); var tmAnalog2 = new TmAnalog(ch, rtu, point) { Value = 1 }; var result = tmAnalog1 == tmAnalog2; Assert.False(result); }
public void DoesNotInitWithTmFlagsInvalid() { var tmAnalog = new TmAnalog(0, 1, 1); var tmcCommonPoint = new TmNativeDefs.TCommonPoint { TM_Flags = 0xFFFF, Data = new byte[] { 0, 0 }, }; tmAnalog.FromTmcCommonPoint(tmcCommonPoint); Assert.False(tmAnalog.IsInit); }
public void SetsCorrectValuesWithNoClass(string name, string unit, string format, short classId, byte expectedWidth, byte expectedPrecision) { var tmAnalog = new TmAnalog(0, 1, 1); tmAnalog.UpdatePropertiesWithDto(name, unit, format, classId, ""); // todo al test provider! Assert.Equal(name, tmAnalog.Name); Assert.Equal(unit, tmAnalog.Unit); Assert.Equal(expectedWidth, tmAnalog.Width); Assert.Equal(expectedPrecision, tmAnalog.Precision); Assert.Null(tmAnalog.ClassId); }
public void SetsCorrectValuesToAnalog(TmAnalog analog) { var sb = "Key1=Value1\r\nKey2=0\r\nName=Мощность\r\nUnits=МВт"; analog.SetTmcObjectProperties(sb); analog.Name.Should().Be("Мощность"); analog.Unit.Should().Be("МВт"); analog.Properties.Should().Equal(new Dictionary <string, string> { { "Key1", "Value1" }, { "Key2", "0" }, { "Name", "Мощность" }, { "Units", "МВт" }, }); }
public void ReturnsCorrectValues(int id, string name, float compareValue, short compareSign, string unit, byte precision, string expected) { var tmAnalog = new TmAnalog(id, 1, 1) { Unit = unit, Precision = precision }; var tmAlarm = new TmAlarmValue(TmAlarmType.Value, 1, name, 0, 1, true, tmAnalog, compareValue, compareSign); var result = tmAlarm.FullName; result.Should().Be(expected); }
public async Task DoWork() { Console.WriteLine(_infr.TmUserInfo?.Name); Console.WriteLine(await _api.GetSystemTimeString()); var ts = new TmStatus(20, 1, 1); var ti = new TmAnalog(20, 1, 1); await _api.UpdateTagPropertiesAndClassData(ts); await _api.UpdateStatus(ts); await _api.UpdateTagPropertiesAndClassData(ti); await _api.UpdateAnalog(ti); Console.WriteLine(ts); Console.WriteLine(ti); }
public async Task DoWork() { Tms.PrintDebug(_infr.TmUserInfo?.Name); Tms.PrintDebug(await _api.GetSystemTimeString()); var ts = new TmStatus(20, 1, 1); var ti = new TmAnalog(20, 1, 1); await _api.UpdateTagPropertiesAndClassData(ts); await _api.UpdateStatus(ts); await _api.UpdateTagPropertiesAndClassData(ti); await _api.UpdateAnalog(ti); Tms.PrintDebug(ts); Tms.PrintDebug(ti); }
public TmTeleregulateValidationResult Validate(TmAnalog tmAnalog) { if (!tmAnalog.HasTeleregulation) { return(TmTeleregulateValidationResult.AnalogHasNoTeleregulation); } if (!_infr.TmUserInfo.HasAccess(TmUserPermissions.Telecontrol)) { return(TmTeleregulateValidationResult.Forbidden); } if (tmAnalog.IsUnreliable || tmAnalog.IsInvalid || tmAnalog.IsManuallyBlocked) { return(TmTeleregulateValidationResult.AnalogIsUnreliable); } return(TmTeleregulateValidationResult.Ok); }
public void SetsCorrectValues(float value, short flags, byte width, byte precision) { var tmAnalog = new TmAnalog(0, 1, 1); var tmcCommonPoint = new TmNativeDefs.TCommonPoint { TM_Flags = 1, Data = TmNativeUtil.GetBytes(new TmNativeDefs.TAnalogPoint { AsFloat = value, Flags = flags, Format = (byte)((precision << 4) | (width)), }), }; tmAnalog.FromTmcCommonPoint(tmcCommonPoint); Assert.True(tmAnalog.IsInit); Assert.Equal(value, tmAnalog.Value); Assert.Equal(flags, (short)tmAnalog.Flags); Assert.Equal(width, tmAnalog.Width); Assert.Equal(precision, tmAnalog.Precision); }
public async Task <TmTelecontrolResult> TeleregulateByStepDown(TmAnalog analog) { return(await _api.TeleregulateByStepDown(analog).ConfigureAwait(false)); }
public async Task <TmTelecontrolResult> TeleregulateByValue(TmAnalog analog, float value) { return(await _api.TeleregulateByValue(analog, value).ConfigureAwait(false)); }
public void ReturnsFalseForTmAnalog(string properties, TmAnalog analog) { analog.SetTmcObjectProperties(properties); analog.HasTmProvider.Should().BeFalse(); }
public void ReturnsFalseForNonStatus(int ch, int rtu, int point) { TmTag tag = new TmAnalog(ch, rtu, point); tag.IsStatus.Should().BeFalse(); }
public void ReturnsTrueForAnalog(int ch, int rtu, int point) { TmTag tag = new TmAnalog(ch, rtu, point); tag.IsAnalog.Should().BeTrue(); }
public void ReturnsTrueForTmAnalog(TmAnalog analog) { analog.SetTmcObjectProperties("Provider=123"); analog.HasTmProvider.Should().BeTrue(); }
public async Task <TmTelecontrolResult> TeleregulateByCode(TmAnalog analog, int code) { return(await _api.TeleregulateByCode(analog, code).ConfigureAwait(false)); }