Meter Correction Factor service
- Last UpdatedApr 24, 2025
- 3 minute read
The Meter Correction Factor (MCF) service is a public API that allows external applications to retrieve the MCF value for a given accumulator.
The GetMcf method takes as input the flow rate value, density value, the rate point underlying the accumulator of interest, and the product group of the product flowing through the rate point. The method will locate the mtrfact record associated with the rate point and product group. Then, it will perform a lookup in the MCF matrix and return the MCF value where the specified flow rate and density value intersect.
Exceptions are thrown if the method fails to locate the mtrfact record or the MCF value.
The following tables provide a list of the input arguments, the return value, and possible exceptions.
Arguments
|
Name |
Type |
Description |
|---|---|---|
|
flowrate |
double |
The flow rate to be used when looking up the MCF value stored in the two-dimensional matrix. |
|
density |
double |
The density to be used when looking up the MCF value stored in the two-dimensional matrix. Note: In some scenarios, the MCF matrix might be populated based on a measurement type other than density. In these cases, you can pass the appropriate value using this argument as long as the data type is double. For example, if the MCF matrix is populated using flow rate ranges and pressure ranges (as opposed to density ranges), you should pass the pressure value into this argument. |
|
rateID |
int |
This argument is the point number (slot) of the rate record underlying the accumulator of interest. |
|
productGroupID |
int |
This argument is the point number (slot) of the product group that contains the product flowing through the rate point. |
Returns
|
Returns |
Description |
|
double |
The method returns the MCF value where the specified flow rate and density value intersect in the MCF matrix. |
Exceptions
|
Exceptions |
Description |
|---|---|
|
DensityFlowRateOutOfRangeException |
If the specified flow rate and/or density is not within the configured ranges, this exception will occur. The exception provides a detailed message to indicate which value is out of range. |
|
MeterFactorGeneratedException |
If a mtrfact record does not exist for the specified rateID and productGroupID combination, this exception will occur. The exception only occurs on first instance since a new default mtrfact record is created for the specified rateID or productGroupID combination, and the matrix will have all MCF values set to 1.0. The generated matrix will have default range limits for flow rate and density. Using ADE, the administrator should inspect the generated matrix and adjust the ranges and MCF values as needed. |
|
RecordNotFoundException |
If the Rate record or the Product Group record cannot be found, this exception will occur. The exception provides a detailed message to indicate which record was not found. |
Meter Correction Factor Programming Example
using System;
using OASySDNA.RealTime.Data.Common.Exceptions;
using OASySDNA.LMS.McfMatrixService;
namespace OASySDNA.LMS.test
{
public class Program
{
private static void Main(string[] args)
{
McfMatrixServiceFactory mcfServiceFactory
= new McfMatrixServiceFactory();
var mcfService = mcfServiceFactory.CreateMcfMatrixService();
int rateId = 1;
int productGroupId = 999;
double flowRate = 23.5;
double density = 893.7;
double mcf = 1.0; // default to 1.0 in case of exception
try
{
mcf = mcfService.GetMcf(flowRate,
density,
rateId,
productGroupId);
}
catch (DensityFlowRateOutOfRangeException ex)
{
Console.WriteLine($"error: {ex.Message}");
}
catch (MeterFactorGeneratedException ex)
{
Console.WriteLine($"error: {ex.Message}");
}
catch (RecordNotFoundException ex)
{
Console.WriteLine($"error: {ex.Message}");
}
Console.WriteLine($"rateId: {rateId}, " +
$"productGroupId: {productGroupId}, " +
$"flowRate: {flowRate}, " +
$"density: {density}, " +
$"mcf: {mcf}");
}
}
}
Note: It is recommended that the variable storing the returned MCF value be initialized to a default value (typically 1.0) before calling GetMcf so that if an exception occurs, the variable would have a predicted MCF value (as demonstrated in the programming example).