88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
///
|
|
/// Copyright (c) 2026 Sensus Slovensko a.s.
|
|
///
|
|
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using Results;
|
|
using TBF.Rig.Generic;
|
|
|
|
namespace TBF.Rig.Output.DB.ResultsWriter
|
|
{
|
|
public class ResultsWriterCfg : ComponentCfgBase, IComponentCfg
|
|
{
|
|
public static XmlSerializer Serializer =
|
|
XmlSerializer.FromTypes(new[] { typeof(ResultsWriterCfg) })[0];
|
|
|
|
public override XmlSerializer GetSerializer()
|
|
{
|
|
return Serializer;
|
|
}
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
|
{
|
|
return new ResultsWriterCfgCtrl(cmpntEntities);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enables or disables writing.
|
|
/// </summary>
|
|
public bool Enabled;
|
|
|
|
/// <summary>
|
|
/// Target table or logical storage name for UniDataStorageWriter.
|
|
/// </summary>
|
|
public string StorageName;
|
|
|
|
/// Runtime model používaný ResultsConfigCtrl
|
|
[XmlIgnore]
|
|
public List<WMeterRsltItemSpec> SelectedItems;
|
|
|
|
public string[] Items;
|
|
|
|
/// Serializable model
|
|
public List<ResultsWriterItemCfg> SelectedItemsCfg;
|
|
|
|
ResultsWriterCfg()
|
|
{
|
|
ParentName = string.Empty; // here should be UniDataStorageWriter component name
|
|
SelectedItems = new List<WMeterRsltItemSpec>();
|
|
SelectedItemsCfg = new List<ResultsWriterItemCfg>();
|
|
Enabled = true;
|
|
StorageName = "Results";
|
|
}
|
|
|
|
public ResultsWriterCfg(string name, IComponentFactory factory)
|
|
: this()
|
|
{
|
|
Name = name;
|
|
Factory = factory;
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format(
|
|
"Name={0}, Parent={1}, Enabled={2}, StorageName={3}, Items={4}",
|
|
Name,
|
|
ParentName,
|
|
Enabled,
|
|
StorageName,
|
|
SelectedItems != null ? SelectedItems.Count : 0);
|
|
}
|
|
|
|
public void UpdateSerializableModel()
|
|
{
|
|
Items = WMeterRsltItemSpec.ToStrArray(SelectedItems);
|
|
}
|
|
|
|
public void UpdateRuntimeModel()
|
|
{
|
|
SelectedItems = new List<WMeterRsltItemSpec>();
|
|
|
|
if (Items == null)
|
|
return;
|
|
|
|
SelectedItems.AddRange(WMeterRsltItemSpec.FromStrArray(Items));
|
|
}
|
|
}
|
|
} |