44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Workplace.CheckItems.S640
|
|
{
|
|
public class PcbnrRadioaddrWeight
|
|
{
|
|
public readonly Int64 PcbNr;
|
|
public readonly Int64 RadioAddr;
|
|
public double Weight;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
PcbnrRadioaddrWeight(Int64 pcbNr, Int64 radioAddr, double weight)
|
|
{
|
|
PcbNr = pcbNr;
|
|
RadioAddr = radioAddr;
|
|
Weight = weight;
|
|
}
|
|
|
|
/// <summary>
|
|
/// If (pcbNr,radioAddr) pair already exists in the list => increase it's weight
|
|
/// If (pcbNr,radioAddr) pair does not exists yet, add it to the list with it's initial weight
|
|
/// </summary>
|
|
/// <param name="list">List of (pcbNr, radioAddr, weight) tripples</param>
|
|
/// <param name="pcbNr">PCB number</param>
|
|
/// <param name="radioAddr">Radio address</param>
|
|
/// <param name="weightIncrement">Weight increment</param>
|
|
public static void Accumulate(IList<PcbnrRadioaddrWeight> list, Int64 pcbNr, Int64 radioAddr, double weightIncrement)
|
|
{
|
|
foreach (var prw in list)
|
|
{
|
|
if (prw.PcbNr == pcbNr && prw.RadioAddr == radioAddr)
|
|
{
|
|
prw.Weight += weightIncrement;
|
|
return;
|
|
}
|
|
}
|
|
list.Add(new PcbnrRadioaddrWeight(pcbNr, radioAddr, weightIncrement));
|
|
}
|
|
}
|
|
}
|