public bool LoadConfiguration(ISystemContext context, ArchiveItem item)
{
using (StreamReader reader = item.OpenArchive())
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
// check for end or error.
if (line == null)
{
break;
}
// ignore blank lines.
line = line.Trim();
if (String.IsNullOrEmpty(line))
{
continue;
}
// ignore commented out lines.
if (line.StartsWith("//"))
{
continue;
}
BuiltInType dataType = BuiltInType.String;
int valueRank = ValueRanks.Scalar;
int samplingInterval = 0;
int simulationType = 0;
int amplitude = 0;
int period = 0;
int archiving = 0;
int stepped = 0;
int useSlopedExtrapolation = 0;
int treatUncertainAsBad = 0;
int percentDataBad = 0;
int percentDataGood = 0;
// get data type.
if (!ExtractField(1, ref line, out dataType))
{
return false;
}
// get value rank.
if (!ExtractField(1, ref line, out valueRank))
{
return false;
}
// get sampling interval.
if (!ExtractField(1, ref line, out samplingInterval))
{
return false;
}
// get simulation type.
if (!ExtractField(1, ref line, out simulationType))
{
return false;
}
// get simulation amplitude.
if (!ExtractField(1, ref line, out amplitude))
{
return false;
}
// get simulation period.
if (!ExtractField(1, ref line, out period))
{
return false;
}
// get flag indicating whether new data is generated.
if (!ExtractField(1, ref line, out archiving))
{
return false;
}
// get flag indicating whether stepped interpolation is used.
if (!ExtractField(1, ref line, out stepped))
{
return false;
}
// get flag indicating whether sloped interpolation should be used.
if (!ExtractField(1, ref line, out useSlopedExtrapolation))
{
return false;
}
// get flag indicating whether sloped interpolation should be used.
if (!ExtractField(1, ref line, out treatUncertainAsBad))
{
return false;
}
// get the maximum permitted of bad data in an interval.
if (!ExtractField(1, ref line, out percentDataBad))
{
return false;
}
// get the minimum amount of good data in an interval.
if (!ExtractField(1, ref line, out percentDataGood))
{
return false;
}
// update the item.
item.DataType = dataType;
item.ValueRank = valueRank;
item.SimulationType = simulationType;
item.Amplitude = amplitude;
item.Period = period;
item.SamplingInterval = samplingInterval;
item.Archiving = archiving != 0;
item.Stepped = stepped != 0;
item.AggregateConfiguration = new AggregateConfiguration();
item.AggregateConfiguration.UseServerCapabilitiesDefaults = false;
item.AggregateConfiguration.UseSlopedExtrapolation = useSlopedExtrapolation != 0;
item.AggregateConfiguration.TreatUncertainAsBad = treatUncertainAsBad != 0;
item.AggregateConfiguration.PercentDataBad = (byte)percentDataBad;
item.AggregateConfiguration.PercentDataGood = (byte)percentDataGood;
break;
}
}
return true;
}