public void Test_CCVPercentPalette_ChooseColour_MachineTarget() { var palette = new CCVPercentPalette(); palette.Should().NotBeNull(); palette.UseMachineTargetCMV = true; palette.UseMachineTargetCMV.Should().Be(true); var data = new SubGridCellPassDataCMVEntryRecord(MEASURED_CMV, TARGET_CMV, 0, 0); var colors = new[] { palette.BelowCMVTargetRangeColour, palette.BelowCMVTargetRangeColour, palette.BelowCMVTargetRangeColour, palette.BelowCMVTargetRangeColour, palette.WithinCMVTargetRangeColour, palette.WithinCMVTargetRangeColour, palette.AboveCMVTargetRangeColour }; for (var i = 0; i < colors.Length; i++) { data.MeasuredCMV = (short)(MEASURED_CMV + i * CMV_INCREMENT); palette.ChooseColour(data.MeasuredCMV, data.TargetCMV).Should().Be(colors[i]); } }
public void Clear() { var rec = new SubGridCellPassDataCMVEntryRecord(1, 2, 3, 4); rec.Clear(); rec.Should().BeEquivalentTo(SubGridCellPassDataCMVEntryRecord.NullValue); }
public void Creation2() { var rec = new SubGridCellPassDataCMVEntryRecord(1, 2, 3, 4); rec.MeasuredCMV.Should().Be(1); rec.TargetCMV.Should().Be(2); rec.PreviousMeasuredCMV.Should().Be(3); rec.PreviousTargetCMV.Should().Be(4); }
public void Test_CompactionCoveragePalette_ChooseColour_HasNoCmvData() { var palette = new CompactionCoveragePalette(); palette.Should().NotBeNull(); var data = new SubGridCellPassDataCMVEntryRecord(CellPassConsts.NullCCV, TARGET_CMV, 0, 0); palette.ChooseColour(data.MeasuredCMV).Should().Be(palette.HasNoCMVData); }
public void Test_NullCells() { var cell = new SubGridCellPassDataCMVEntryRecord(); cell.Clear(); var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.CCV) as ClientCMVLeafSubGrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y].Equals(cell))); }
public void Test_SubGridCellPassDataCMVEntryRecord_Creation() { SubGridCellPassDataCMVEntryRecord rec = new SubGridCellPassDataCMVEntryRecord(); rec.Clear(); Assert.True(rec.MeasuredCMV == CellPassConsts.NullCCV); Assert.True(rec.TargetCMV == CellPassConsts.NullCCV); Assert.True(rec.PreviousMeasuredCMV == CellPassConsts.NullCCV); Assert.True(rec.PreviousTargetCMV == CellPassConsts.NullCCV); }
public void Test_CMVPalette_ChooseColour_NoTargetCCVColourInPVM() { var palette = new CMVPalette(); palette.Should().NotBeNull(); palette.DisplayTargetCCVColourInPVM.Should().Be(false); var data = new SubGridCellPassDataCMVEntryRecord(MEASURED_CMV, TARGET_CMV, 0, 0); var colors = new [] { Color.Green, Color.Yellow, Color.Olive, Color.Blue, Color.Blue, Color.SkyBlue, Color.SkyBlue }; for (var i = 0; i < colors.Length; i++) { data.MeasuredCMV = (short)(MEASURED_CMV + i * CMV_INCREMENT); palette.ChooseColour(data).Should().Be(colors[i]); } }
public void BinaryReaderWriter() { var instance = new SubGridCellPassDataCMVEntryRecord(1, 2, 3, 4); // Test using standard Read()/Write() var writer = new BinaryWriter(new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION)); instance.Write(writer); (writer.BaseStream as MemoryStream).Position = 0; var instance2 = new SubGridCellPassDataCMVEntryRecord(); instance2.Read(new BinaryReader(writer.BaseStream as MemoryStream)); instance.Should().BeEquivalentTo(instance2); }
public Color ChooseColour(SubGridCellPassDataCMVEntryRecord cmvData) { if (cmvData.IsDecoupled && DisplayDecoupledColourInPVM) { return(DefaultDecoupledCMVColour); } // Check to see if the value is in the target range and use the target CMV colour // if it is. CCVRange holds a min/max percentage of target CMV... var targetCMVValue = !UseMachineTargetCMV ? AbsoluteTargetCMV : cmvData.TargetCMV; if (DisplayTargetCCVColourInPVM && Range.InRange(cmvData.MeasuredCMV, targetCMVValue * _minTarget, targetCMVValue * _maxTarget)) { return(TargetCCVColour); } return(ChooseColour(cmvData.MeasuredCMV)); }
public void Test_CCVPercentPalette_ChooseColour_NullOverrideTarget() { var palette = new CCVPercentPalette(); palette.Should().NotBeNull(); palette.AbsoluteTargetCMV = CellPassConsts.NullCCV; palette.AbsoluteTargetCMV.Should().Be(CellPassConsts.NullCCV); var data = new SubGridCellPassDataCMVEntryRecord(MEASURED_CMV, TARGET_CMV, 0, 0); var colors = new[] { Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty }; for (var i = 0; i < colors.Length; i++) { data.MeasuredCMV = (short)(MEASURED_CMV + i * CMV_INCREMENT); palette.ChooseColour(data.MeasuredCMV, TARGET_CMV).Should().Be(colors[i]); } }
public new Color ChooseColour(SubGridCellPassDataCMVEntryRecord cmvData) { if (CMVCellValueToDisplay(cmvData, out var cmvPercentValue)) { if (cmvData.IsDecoupled && DisplayDecoupledColourInPVM) { return(DefaultDecoupledCMVColour); } // Check to see if the value is in the target range and use the target CMV colour // if it is. CCVRange holds a min/max percentage of target CMV... if (DisplayTargetCCVColourInPVM && Range.InRange(cmvPercentValue, MAX_PERCENTAGE_VALUE * _minTarget, MAX_PERCENTAGE_VALUE * _maxTarget)) { return(TargetCCVColour); } return(ChooseColour(cmvPercentValue)); } return(Color.Empty); }
private bool CMVCellValueToDisplay(SubGridCellPassDataCMVEntryRecord cmvData, out double cmvPercentValue) { cmvPercentValue = 0.0; if (cmvData.MeasuredCMV == CellPassConsts.NullCCV) { return(false); } if (cmvData.PreviousMeasuredCMV == CellPassConsts.NullCCV) { cmvPercentValue = MAX_PERCENTAGE_VALUE; return(true); } if (UseAbsoluteValues) { var tempValue = Math.Abs(cmvData.MeasuredCMV - cmvData.PreviousMeasuredCMV) / (double)cmvData.PreviousMeasuredCMV; cmvPercentValue = tempValue * MAX_PERCENTAGE_VALUE; return(true); } double previousPercentage; double currentPercentage; if (UseMachineTargetCMV) { if (cmvData.TargetCMV == CellPassConsts.NullCCV || cmvData.PreviousTargetCMV == CellPassConsts.NullCCV) { return(false); } if (cmvData.TargetCMV != 0 && cmvData.PreviousTargetCMV != 0) { double tempValue = (double)cmvData.PreviousTargetCMV / CellPassConsts.CCVvalueRatio; previousPercentage = cmvData.PreviousMeasuredCMV / tempValue * MAX_PERCENTAGE_VALUE; tempValue = (double)cmvData.TargetCMV / CellPassConsts.CCVvalueRatio; currentPercentage = cmvData.MeasuredCMV / tempValue * MAX_PERCENTAGE_VALUE; } else { return(false); } } else { if (AbsoluteTargetCMV != 0) { double tempValue = (double)AbsoluteTargetCMV / CellPassConsts.CCVvalueRatio; previousPercentage = cmvData.PreviousMeasuredCMV / tempValue * MAX_PERCENTAGE_VALUE; currentPercentage = cmvData.MeasuredCMV / tempValue * MAX_PERCENTAGE_VALUE; } else { return(false); } } cmvPercentValue = (currentPercentage - previousPercentage) / previousPercentage * MAX_PERCENTAGE_VALUE; return(true); }
public void IndicativeSizeInBytes() { SubGridCellPassDataCMVEntryRecord.IndicativeSizeInBytes().Should().Be(4 * sizeof(short) + sizeof(byte)); }