Refactorization : BenchControl -> Rig

This commit is contained in:
Milan Hanajik
2021-03-05 16:12:24 +01:00
parent 84c8ec26b6
commit 6cf3bd6160
1461 changed files with 6330 additions and 6330 deletions
@@ -0,0 +1,48 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public enum CodeType
{
UniqueNr,
FlowtubeNr, /// Prvé 3 znaky sa zhodujú s poslednými 3 znakmi názvu
FlowtubeNrLU, /// Začiatok kódu sa zhoduje s názvom
BatchNr,
BatchNrContainingPartName,
DateMMYY,
QualityCheck,
}
public enum CodeForm
{
Barcode,
QRCode,
Keyboard,
OkNok,
}
public enum CodeLocation
{
OnPart,
OnPallet,
}
public enum LifetimeManagement
{
None,
OneYear,
Count,
}
public enum ReleaseStatus
{
In_preparation,
Released,
ReleasedActive,
Deactivated,
Count,
}
}
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "Output.DB.ProductionMonitoring"; } } /// For backward compatibility
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Tracing.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Tracing(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Tracing(cfg); }
public IComponentCfg DefaultConfig() { return new MonitoringCfg(this.GetType().Namespace.Substring(24), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(MonitoringCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,58 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.ProductionTracing
{
///
/// Class and file name is preserved for backward compatibility
///
public class MonitoringCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(MonitoringCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new TracingCfgCtrl(); }
public string ConnStr;
public string ConnStr2;
public string NetAdapter;
public bool CheckPreviousRecords;
public bool SaveTracingRecords;
/// Private parameterless constructor invoked by all other (public) constructors
MonitoringCfg()
{
ParentName = string.Empty;
NetAdapter = string.Empty;
ConnStr = "server=10.42.128.16; database=sledovanie2020; uid=vyroba2020; pwd=qwerty; charset=utf8;";
ConnStr2 = "server=10.42.128.16; database=sledovanie2019; uid=vyroba2019; pwd=qwerty; charset=utf8;";
CheckPreviousRecords = true;
SaveTracingRecords = true;
}
public MonitoringCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, CheckPrev.={1}, SaveRecords={2}, ConnStr={3}, , ConnStr2={4}",
Name,
CheckPreviousRecords,
SaveTracingRecords,
ConnStr,
ConnStr2);
}
}
}
@@ -0,0 +1,696 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using log4net;
using NHibernate;
using NHibernate.Criterion;
using Config.Entities;
using TracingDB.Entities;
using Events.Entities;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public enum Retv
{
OK,
Error,
}
class DateTimeComparer : IComparer<DateTime>
{
public int Compare(DateTime x, DateTime y)
{
return DateTime.Compare(x, y);
}
}
public class Tracing : ComponentBase, IOperation, GenericDevices.IResultsWriter, GenericDevices.IStartInfoReader, Generic.IDevice
{
private static readonly ILog log = LogManager.GetLogger(typeof(Tracing));
public override string ToString() { return string.Format("Tracing({0})", Cfg.ToString(1)); }
public const string WorkstepName = "Test_bench";
MonitoringCfg tracingCfg;
string workplace
{
get
{
TBF.Rig.GenericDevices.IBenchInfo benchInfo = TBF.Rig.Sequences.ProcessData.BenchInfo;
return (benchInfo != null) ? benchInfo.TestBenchName : "TestBench";
}
}
readonly IPAddress ipAddress;
readonly IPAddress netMask;
public IPAddress IPAddress { get { return ipAddress; } }
public IPAddress NetMask { get { return netMask; } }
enum OpState
{
None,
CheckPreviousRecordsScheduled,
CheckPreviousRecordsRunning,
SaveTracingRecordsScheduled,
SaveTracingRecordsRunning,
}
///
OpState currentOpState;
bool opCompleted;
bool anyError;
/// <summary>
/// Watermeters to check at the beginning of the cycle
/// </summary>
IList<Results.Entities.WaterMeter> waterMeters;
/// <summary>
/// Data (tracing records) to write at the end of cycle
/// </summary>
Results.Entities.Batch batch;
ISessionFactory sessionFactory; /// Factory to create database sessions that is initialized in the constructor
IList<Process> processes;
Dictionary<int, Process> processDictionary;
Dictionary<int, IList<Workstep>> workstepsDictionary;
ISessionFactory sessionFactory2; /// Factory to create database sessions that is initialized in the constructor
IList<Process> processes2;
Dictionary<int, Process> processDictionary2;
Dictionary<int, IList<Workstep>> workstepsDictionary2;
///
/// Previous workstep verification info
///
Process currentProcess; /// Currently used process
Workstep currentWorkstep; /// Currently used workstep of this test bench
Workstep verifiedWorkstep;
Part verifiedPart; /// Applicable when verifyReferencePart == false
bool verifyReferencePart;
public Tracing() {}
public Tracing(Generic.IComponentCfg cfg)
: base(cfg)
{
tracingCfg = cfg as MonitoringCfg;
if (tracingCfg == null) throw new ArgumentException("tracingCfg");
Network.AdapterInfo.RefreshNetAdaptersInfo();
Network.AdapterInfo netadapter = Network.AdapterInfo.GetNetAdapter(tracingCfg.NetAdapter);
ipAddress = netadapter.IPAddress;
netMask = netadapter.NetMask;
currentOpState = OpState.None;
log.Warn(this.ToString());
}
///
/// IDevice interface implementation
///
public void Initialize()
{
if (tracingCfg.DebugLevel == DebugMode.Simulate) return;
string ipAddress = GetIPAddress();
///
/// Session factory is used to create database sessions
///
sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildSessionFactory();
///
/// Session factory 2 is used to create the 2nd database sessions
///
if (!string.IsNullOrEmpty(tracingCfg.ConnStr2))
{
sessionFactory2 = FluentNHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(tracingCfg.ConnStr2))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TracingDB.Entities.Process>())
.ExposeConfiguration(TracingDB.DB.BuildSchema)
.BuildSessionFactory();
}
///
/// Register this test bench in the tracing DB for approx. 2 weeks
///
ISession session = sessionFactory.OpenSession();
#if !DEBUG
/// Only a release version registers a workplace
TracingDB.DB.RegisterWorkplace(session,
workplace,
Users.GlobalData.GetCurrentUserName(),
GetIPAddress(),
"<multiple>",
WorkstepName,
DateTime.Now + new TimeSpan(15, 0, 0, 0));
#endif
session.Flush();
session.Close();
TracingDB.DB.SessionFactory = sessionFactory;
if (session != null) session.Dispose();
currentProcess = null;
}
///
string GetIPAddress()
{
return (ipAddress != null) ? ipAddress.ToString() : "1.2.3.4";
}
///
public void RunDeviceBefore() { }
public void RunDeviceAfter() { }
///
public void StopDevice()
{
if (tracingCfg.DebugLevel == DebugMode.Simulate) return;
using (ISession session = sessionFactory.OpenSession())
{
TracingDB.DB.UnregisterWorkplaceObsolete(session, workplace);
session.Flush();
}
}
public void StopDevice2() {}
/// <summary>
/// Reads information on start of a cycle, Events: Event.InfoRead
/// </summary>
/// <param name="waterMeters">Results of water meters</param>
/// <returns>Reference to the operation</returns>
public IOperation ReadStartInfoOp(IList<Results.Entities.WaterMeter> waterMeters)
{
if (!tracingCfg.CheckPreviousRecords)
{
return null;
}
else if ((currentOpState == OpState.CheckPreviousRecordsRunning) || (currentOpState == OpState.SaveTracingRecordsRunning))
{
throw new Exception("Sequence error");
}
else
{
this.waterMeters = waterMeters;
currentOpState = OpState.CheckPreviousRecordsScheduled;
return this;
}
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
if (!tracingCfg.SaveTracingRecords)
{
return null;
}
else if ((currentOpState == OpState.CheckPreviousRecordsRunning) || (currentOpState == OpState.SaveTracingRecordsRunning))
{
throw new Exception("Sequence error");
}
else
{
this.batch = batch;
currentOpState = OpState.SaveTracingRecordsScheduled;
return this;
}
}
/// <summary>Start this operation</summary>
public void Start()
{
if (currentOpState == OpState.CheckPreviousRecordsScheduled)
{
currentOpState = OpState.CheckPreviousRecordsRunning;
}
else if (currentOpState == OpState.SaveTracingRecordsScheduled)
{
currentOpState = OpState.SaveTracingRecordsRunning;
}
opCompleted = false;
anyError = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten or Event.Error</returns>
public Event Run()
{
if (currentOpState == OpState.CheckPreviousRecordsRunning)
{
if (tracingCfg.DebugLevel == DebugMode.Simulate)
{
return Event.InfoRead;
}
else if (!opCompleted)
{
log.WarnFormat("{0} : Run() : currentOp = {1}", Name, currentOpState);
opCompleted = true;
if (CheckPreviousRecords(waterMeters) != Retv.OK) anyError = true;
return anyError ? Event.InfoNotRead : Event.InfoRead;
}
else
{
return anyError ? Event.InfoNotRead : Event.InfoRead;
}
}
else if (currentOpState == OpState.SaveTracingRecordsRunning)
{
if (tracingCfg.DebugLevel == DebugMode.Simulate || batch.WaterMeters.Count == 0)
{
return Event.ResultsWritten;
}
else if (!opCompleted)
{
log.WarnFormat("{0} : Run() : currentOp = {1}", Name, currentOpState);
opCompleted = true;
if (SaveTracingRecords(batch) != Retv.OK) anyError = true;
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
try
{
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
string.Format("Nepodarilo sa uložiť výsledky do sledovacej DB: Číslo dávky={0}", batch.BatchNr),
string.Format("Nepodarilo sa uložiť výsledky do sledovacej DB\r\nČíslo dávky = {0}", batch.BatchNr),
SubscriberGroup.Metrology | SubscriberGroup.Maintenance | SubscriberGroup.Production);
}
catch (Exception exc)
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
}
else
{
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
try
{
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
string.Format("Nepodarilo sa uložiť výsledky do sledovacej DB: Číslo dávky={0}", batch.BatchNr),
string.Format("Nepodarilo sa uložiť výsledky do sledovacej DB\r\nČíslo dávky = {0}", batch.BatchNr),
SubscriberGroup.Metrology | SubscriberGroup.Maintenance | SubscriberGroup.Production);
}
catch (Exception exc)
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
}
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
currentOpState = OpState.None;
}
Retv CheckPreviousRecords(IList<Results.Entities.WaterMeter> waterMeters)
{
Retv retVal = Retv.Error;
bool isAtLeastOneNOK = false;
using (ISession session = sessionFactory.OpenSession())
{
for (int i = 0; i < waterMeters.Count; i++)
{
Results.Entities.WaterMeter wm = waterMeters[i];
if ((wm != null) && !wm.Disabled)
{
CheckPreviousRecordOfSingleWM(session, wm, 1);
if (wm.LastRecordIsNok)
{
isAtLeastOneNOK = true;
}
}
}
retVal = Retv.OK;
}
if (isAtLeastOneNOK && (sessionFactory2 != null))
{
using (ISession session2 = sessionFactory2.OpenSession())
{
for (int i = 0; i < waterMeters.Count; i++)
{
Results.Entities.WaterMeter wm = waterMeters[i];
if ((wm != null) && !wm.Disabled && wm.LastRecordIsNok)
{
CheckPreviousRecordOfSingleWM(session2, wm, 2);
}
}
retVal = Retv.OK;
}
}
return retVal;
}
Retv CheckPreviousRecordOfSingleWM(ISession session, Results.Entities.WaterMeter wm, int sessionId)
{
if (string.IsNullOrEmpty(wm.SerialNr))
{
/// S/N is missing
wm.ProcessId = 0;
wm.SessionId = 0;
wm.LastRecordIsNok = false; /// OK, this is an RFID comm. error, not a production tracing error
return Retv.OK;
}
///
/// Get all already existing reference records with Code == wm.SerialNr, refRecords[0] will be the most recent one
///
ReferenceRecord refRecord = null;
Workstep workstep = null;
ProjectionList projections = Projections.ProjectionList();
projections.Add(Projections.Property(() => refRecord.Id)); /// rslt[0] = reference record ID
projections.Add(Projections.Property(() => workstep.Id)); /// rslt[1] = workstep ID
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rslt[2] = process ID
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rslt[3] = reference record time stamp
///
/// Get all reference records with Code == SerialNr from all worksteps different from 'Test_bench'
///
IList<object[]> results = session.QueryOver<ReferenceRecord>(() => refRecord)
.Where(rr => (rr.Code == wm.SerialNr))
.JoinQueryOver<Workstep>(rr => rr.Workstep, () => workstep)
.And(ws => (ws.Name != WorkstepName))
.Select(projections)
.List<object[]>();
if (results.Count == 0)
{
/// No records found
wm.ProcessId = 0;
wm.SessionId = sessionId;
wm.LastRecordIsNok = true; /// NOK
///
return Retv.OK;
}
///
/// Get processId of the last record
///
int processId = 0;
DateTime lastTimeStamp = DateTime.MinValue;
foreach (var rslt in results)
{
if (DateTime.Compare((DateTime)rslt[3], lastTimeStamp) > 0)
{
lastTimeStamp = (DateTime)rslt[3];
processId = (int)rslt[2];
}
}
if (processId == 0) return Retv.Error; /// This should never happen
if ((currentProcess == null) || (currentProcess.Id != processId))
{
///
/// Process changed ==> update currentProcess / currentWorkstep / verifiedWorkstep / verifiedPart / verifyReferencePart
///
var processes = session.QueryOver<Process>()
.Where(p => (p.Id == processId))
.List();
if (processes.Count != 1) return Retv.Error;
IList<Workstep> worksteps = session.QueryOver<Workstep>()
.Where(ws => (ws.Process == processes[0]))
.And( ws => (ws.Name == WorkstepName))
.List();
if (worksteps.Count != 1) return Retv.Error;
Workstep vWS;
Part vP;
bool vRP;
///
if (!TracingDB.DB.AnalyzeProcess(session, processes[0], worksteps[0], out vWS, out vRP, out vP))
{
return Retv.Error; /// Unable to
}
currentProcess = processes[0];
currentWorkstep = worksteps[0];
verifiedWorkstep = vWS;
verifiedPart = vP;
verifyReferencePart = vRP;
}
wm.ProcessId = currentProcess.Id;
wm.SessionId = sessionId;
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
foreach (var rslt in results)
{
if ((verifiedWorkstep.Id == (int)rslt[1]) && (processId == (int)rslt[2]))
{
/// This record fits verification requirements
wm.LastRecordIsNok = false; /// OK
break;
}
}
return Retv.OK;
}
/// <summary>
/// Write results of a batch of water meters to the DB
/// </summary>
/// <param name="session">DB session</param>
/// <param name="batch">Batch entity</param>
Retv SaveTracingRecords(Results.Entities.Batch batch)
{
ITransaction transaction = null;
ISession session = null;
///
/// Save to regular tracing DB
///
try
{
session = sessionFactory.OpenSession();
transaction = session.BeginTransaction();
int writtenRecordsCount = 0;
foreach (var wMtr in batch.WaterMeters)
{
if (wMtr.SessionId == 1)
{
writtenRecordsCount += SaveSingleWM2DB(session, wMtr);
}
}
transaction.Commit();
session.Flush();
log.ErrorFormat("Batch {0}: {1} of {2} watermeters written to the regular production tracing DB",
batch.BatchNr, writtenRecordsCount, batch.WaterMeters.Count);
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
log.WarnFormat("Failed to write results of batch {0} to production tracing DB: {1}",
batch.BatchNr, exc.Message);
return Retv.Error;
}
finally
{
if (session != null)
{
session.Close();
session.Dispose();
}
}
if (sessionFactory2 != null)
{
///
/// Save to alternative tracing DB
///
transaction = null;
session = null;
try
{
session = sessionFactory2.OpenSession();
transaction = session.BeginTransaction();
int writtenRecordsCount = 0;
foreach (var wMtr in batch.WaterMeters)
{
if (wMtr.SessionId == 2)
{
writtenRecordsCount += SaveSingleWM2DB(session, wMtr);
}
}
transaction.Commit();
session.Flush();
log.ErrorFormat("Batch {0}: {1} of {2} watermeters written to the alternative production tracing DB",
batch.BatchNr, writtenRecordsCount, batch.WaterMeters.Count);
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
log.WarnFormat("Failed to write results of batch {0} to production tracing DB: {1}",
batch.BatchNr, exc.Message);
return Retv.Error;
}
finally
{
if (session != null)
{
session.Close();
session.Dispose();
}
}
}
return Retv.OK;
}
/// <summary>
/// Write one meter results to the DB
/// </summary>
/// <param name="session">DB session</param>
/// <param name="wm">Watermeter entity</param>
/// <returns>Number of written reference record</returns>
int SaveSingleWM2DB(ISession session, Results.Entities.WaterMeter wm)
{
if (string.IsNullOrEmpty(wm.SerialNr) || (wm.ProcessId == 0))
{
/// Without PCB number there is no DB activity
return 0;
}
else if ((currentProcess != null) && (wm.ProcessId == currentProcess.Id))
{
/// Process is already loaded => save a reference record for this WM
session.SaveOrUpdate(new ReferenceRecord(currentProcess, currentWorkstep, wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
return 1;
}
else if (wm.ProcessId != 0)
{
/// Process ID is already known, however process and workstep have to be loaded
IList<Process> processes = session.QueryOver<Process>()
.Where(x => (x.Id == wm.ProcessId))
.List();
if (processes.Count != 1) return 0;
foreach (var ws in processes[0].Worksteps)
{
if (ws.Name == WorkstepName)
{
session.SaveOrUpdate(new ReferenceRecord(processes[0], ws, wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
return 1;
}
}
return 0; /// No workste with 'WorkstepName' found
}
else
{
///
/// Process ID is unknown => do everything from scratch
///
/// Get all already existing reference records with Code == wm.SerialNr, refRecords[0] will be the most recent one
IList<ReferenceRecord> refRecords;
int trialsCount = 0;
do
{
if (trialsCount > 0) ReadProcessesFromDB(session);
refRecords = session.QueryOver<ReferenceRecord>()
.Where(rr => (rr.Code == wm.SerialNr))
.OrderBy(rr => rr.TimeStamp).Desc
.List();
trialsCount++;
}
while (refRecords.Count == 0 && trialsCount <= 2);
/// Save a new reference record from this test bench if workstep "Test_bench" is defined in the obtained WM process
IList<Workstep> worksteps;
if ((refRecords.Count > 0) && workstepsDictionary.TryGetValue(refRecords[0].Process.Id, out worksteps) && (worksteps.Count == 1))
{
session.SaveOrUpdate(new ReferenceRecord(refRecords[0].Process, worksteps[0], wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
return 1;
}
return 0;
}
}
/// <summary>
/// Updates processes, processDictionary and workstepsDictionary
/// </summary>
/// <param name="session">DB session</param>
void ReadProcessesFromDB(ISession session)
{
processes = session.QueryOver<Process>()
.List();
processDictionary = new Dictionary<int, Process>();
workstepsDictionary = new Dictionary<int, IList<Workstep>>();
///
foreach (var pr in processes)
{
IList<Workstep> worksteps = session.QueryOver<Workstep>()
.Where(ws => ((ws.Process == pr) && (ws.Name == WorkstepName)))
.List();
processDictionary.Add(pr.Id, pr);
workstepsDictionary.Add(pr.Id, worksteps);
}
}
}
}
@@ -0,0 +1,147 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
using System.Collections.Generic;
using System.Net;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public partial class TracingCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
MonitoringCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as MonitoringCfg;
Redraw();
}
}
public TracingCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
if (config == null) return;
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
connStrTextBox.Text = config.ConnStr;
connStr2TextBox.Text = config.ConnStr2;
checkPreviousRecordsCheckBox.Checked = config.CheckPreviousRecords;
saveTracingRecordsCheckBox.Checked = config.SaveTracingRecords;
Network.AdapterInfo.RefreshNetAdaptersInfo();
IList<Network.AdapterInfo> adapters = Network.AdapterInfo.NetAdapters;
string cfgAdapter = string.Empty;
foreach (Network.AdapterInfo ai in adapters)
{
string record;
if (ai.IPAddress == null)
{
/// This happens with network adapters that currently have no IP address,
/// for instance not connected wireless or dial-up adapters
record = "???.???.???.???";
}
else
{
/// Do not consider IPv6 adapters as well as "Any", "Broadcast", "Loopback" or "None" addresses
if ((ai.IPAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) ||
ai.IPAddress.Equals(IPAddress.Any) ||
ai.IPAddress.Equals(IPAddress.Broadcast) ||
ai.IPAddress.Equals(IPAddress.IPv6Any) ||
ai.IPAddress.Equals(IPAddress.IPv6Loopback) ||
ai.IPAddress.Equals(IPAddress.IPv6None) ||
ai.IPAddress.Equals(IPAddress.Loopback) ||
ai.IPAddress.Equals(IPAddress.None))
{
continue;
}
record = ai.IPAddress.ToString();
}
record += " - " + ai.Description;
int i = netAdapterComboBox.Items.Add(record);
if (ai.Description == config.NetAdapter)
{
/// Select the adapter currently in the configuration
netAdapterComboBox.SelectedIndex = i;
}
}
/// Select the first one if the adapter from the configuration does not exist on the system
if (netAdapterComboBox.SelectedIndex < 0 && netAdapterComboBox.Items.Count > 0)
{
netAdapterComboBox.SelectedIndex = 0;
}
}
public void Unlock()
{
nameTextBox.Enabled = true;
connStrTextBox.Enabled = true;
connStr2TextBox.Enabled = true;
netAdapterComboBox.Enabled = true;
checkPreviousRecordsCheckBox.Enabled = true;
saveTracingRecordsCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
flags |= UpdateDifferent(ref config.ConnStr, connStrTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ConnStr2, connStr2TextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.CheckPreviousRecords, checkPreviousRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.SaveTracingRecords, saveTracingRecordsCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
/// Network adapter
string strAdapter = netAdapterComboBox.Text;
int iDash = strAdapter.IndexOf(" - ");
string netAdapter = (iDash < 0) ? "" : strAdapter.Substring(iDash + 3);
if (config.NetAdapter != netAdapter)
{
config.NetAdapter = netAdapter;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
return flags;
}
}
}
@@ -0,0 +1,184 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.DB.ProductionTracing
{
partial class TracingCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.connStrTextBox = new System.Windows.Forms.TextBox();
this.connStrLabel = new System.Windows.Forms.Label();
this.saveTracingRecordsCheckBox = new System.Windows.Forms.CheckBox();
this.checkPreviousRecordsCheckBox = new System.Windows.Forms.CheckBox();
this.netAdapterLabel = new System.Windows.Forms.Label();
this.netAdapterComboBox = new System.Windows.Forms.ComboBox();
this.connStr2TextBox = new System.Windows.Forms.TextBox();
this.connStr2Label = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(117, 32);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(326, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(5, 35);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(38, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name:";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(114, 10);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// connStrTextBox
//
this.connStrTextBox.Enabled = false;
this.connStrTextBox.Location = new System.Drawing.Point(8, 74);
this.connStrTextBox.Name = "connStrTextBox";
this.connStrTextBox.Size = new System.Drawing.Size(435, 20);
this.connStrTextBox.TabIndex = 4;
//
// connStrLabel
//
this.connStrLabel.AutoSize = true;
this.connStrLabel.Location = new System.Drawing.Point(5, 58);
this.connStrLabel.Name = "connStrLabel";
this.connStrLabel.Size = new System.Drawing.Size(92, 13);
this.connStrLabel.TabIndex = 3;
this.connStrLabel.Text = "Connection string:";
//
// saveTracingRecordsCheckBox
//
this.saveTracingRecordsCheckBox.AutoSize = true;
this.saveTracingRecordsCheckBox.Enabled = false;
this.saveTracingRecordsCheckBox.Location = new System.Drawing.Point(117, 221);
this.saveTracingRecordsCheckBox.Name = "saveTracingRecordsCheckBox";
this.saveTracingRecordsCheckBox.Size = new System.Drawing.Size(177, 17);
this.saveTracingRecordsCheckBox.TabIndex = 10;
this.saveTracingRecordsCheckBox.Text = "Save production tracing records";
this.saveTracingRecordsCheckBox.UseVisualStyleBackColor = true;
//
// checkPreviousRecordsCheckBox
//
this.checkPreviousRecordsCheckBox.AutoSize = true;
this.checkPreviousRecordsCheckBox.Enabled = false;
this.checkPreviousRecordsCheckBox.Location = new System.Drawing.Point(117, 199);
this.checkPreviousRecordsCheckBox.Name = "checkPreviousRecordsCheckBox";
this.checkPreviousRecordsCheckBox.Size = new System.Drawing.Size(138, 17);
this.checkPreviousRecordsCheckBox.TabIndex = 9;
this.checkPreviousRecordsCheckBox.Text = "Check previous records";
this.checkPreviousRecordsCheckBox.UseVisualStyleBackColor = true;
//
// netAdapterLabel
//
this.netAdapterLabel.AutoSize = true;
this.netAdapterLabel.Location = new System.Drawing.Point(5, 147);
this.netAdapterLabel.Name = "netAdapterLabel";
this.netAdapterLabel.Size = new System.Drawing.Size(89, 13);
this.netAdapterLabel.TabIndex = 7;
this.netAdapterLabel.Text = "Network adapter:";
//
// netAdapterComboBox
//
this.netAdapterComboBox.Enabled = false;
this.netAdapterComboBox.FormattingEnabled = true;
this.netAdapterComboBox.Location = new System.Drawing.Point(8, 163);
this.netAdapterComboBox.Name = "netAdapterComboBox";
this.netAdapterComboBox.Size = new System.Drawing.Size(435, 21);
this.netAdapterComboBox.TabIndex = 8;
//
// connStr2TextBox
//
this.connStr2TextBox.Enabled = false;
this.connStr2TextBox.Location = new System.Drawing.Point(8, 118);
this.connStr2TextBox.Name = "connStr2TextBox";
this.connStr2TextBox.Size = new System.Drawing.Size(434, 20);
this.connStr2TextBox.TabIndex = 6;
//
// connStr2Label
//
this.connStr2Label.AutoSize = true;
this.connStr2Label.Location = new System.Drawing.Point(5, 102);
this.connStr2Label.Name = "connStr2Label";
this.connStr2Label.Size = new System.Drawing.Size(101, 13);
this.connStr2Label.TabIndex = 5;
this.connStr2Label.Text = "Connection string 2:";
//
// TracingCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.connStr2TextBox);
this.Controls.Add(this.connStr2Label);
this.Controls.Add(this.netAdapterComboBox);
this.Controls.Add(this.netAdapterLabel);
this.Controls.Add(this.saveTracingRecordsCheckBox);
this.Controls.Add(this.checkPreviousRecordsCheckBox);
this.Controls.Add(this.connStrTextBox);
this.Controls.Add(this.connStrLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TracingCfgCtrl";
this.Size = new System.Drawing.Size(450, 250);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox connStrTextBox;
private System.Windows.Forms.Label connStrLabel;
private System.Windows.Forms.CheckBox saveTracingRecordsCheckBox;
private System.Windows.Forms.CheckBox checkPreviousRecordsCheckBox;
private System.Windows.Forms.Label netAdapterLabel;
private System.Windows.Forms.ComboBox netAdapterComboBox;
private System.Windows.Forms.TextBox connStr2TextBox;
private System.Windows.Forms.Label connStr2Label;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,61 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace TBF.Rig.Output.DB.ProductionTracing
{
public class WMPart
{
public string Name;
public int ProcessId;
public string OraDBType;
public string Description;
public string Code;
public DateTime TimeStamp;
public CodeType CodeType;
public CodeForm CodeForm;
public CodeLocation CodeLocation;
public string UserName;
public string Workplace;
public WMPart() {}
public static IList<WMPart> FindWMParts(MySqlConnection dbConn, string pcbNumber)
{
IList<WMPart> foundParts = new List<WMPart>(); /// initially empty
if (string.IsNullOrEmpty(pcbNumber)) return foundParts; /// return an empty list
try
{
dbConn.Open();
//IList<Entities.ReferenceRecord> referenceRecords = session
// .QueryOver<Entities.ReferenceRecord>()
// .Where(x => (x.Code == pcbNumber))
// .OrderBy(x => x.TimeStamp).Desc
// .List<Entities.ReferenceRecord>();
MySqlCommand cmd = dbConn.CreateCommand();
cmd.CommandText = string.Format("SELECT Id, TimeStamp, UserName, Workplace, Result, Process_id, Workstep_id FROM ReferenceRecord WHERE Code = {0}", pcbNumber);
cmd.ExecuteNonQuery();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
foundParts.Add( new WMPart() { Code = pcbNumber, ProcessId = dr.GetInt32(5), /* etc */ } );
}
dr.Close();
cmd.Dispose();
}
catch
{
}
return foundParts;
}
}
}
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SaveDiverterCorrections
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { SaveDiverterCorr.ResetStaticProperties(); }
public IComponent DummyComponent() { return new SaveDiverterCorr(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new SaveDiverterCorr(cfg); }
public IComponentCfg DefaultConfig() { return new SaveDiverterCorrCfg(this.GetType().Namespace.Substring(18), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(SaveDiverterCorrCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,259 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using NHibernate;
using NHibernate.Criterion;
using Config;
using Config.Entities;
using TracingDB.Entities;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Output.DB.SaveDiverterCorrections
{
public enum Retv
{
OK,
Error,
}
public class SaveDiverterCorr : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(SaveDiverterCorr));
public override string ToString() { return string.Format("SaveDiverterCorr({0})", Cfg.ToString(1)); }
SaveDiverterCorrCfg myCfg;
enum CurrentOp
{
None,
SaveDiverterCorrections,
}
CurrentOp currentOp;
bool opCompleted;
bool anyError;
/// <summary>
/// Results to parse for reference flowmeter corrections
/// </summary>
Results.Entities.Batch batch;
IList<MeasurementCorrection> newCorrections;
public SaveDiverterCorr() {}
public SaveDiverterCorr(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as SaveDiverterCorrCfg;
currentOp = CurrentOp.None;
log.Warn(this.ToString());
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
if (currentOp != CurrentOp.None)
throw new Exception("Sequence error");
else
currentOp = CurrentOp.SaveDiverterCorrections;
this.batch = batch;
return this;
}
IList<MeasurementCorrection> CalculateCorrectionsFromResuls(Results.Entities.Batch batch, string diverterName)
{
/// Create a list of all test flows in this procedure
IList<double> targetFlows = new List<double>();
foreach (var tr in batch.TestRslts)
{
if (tr.TestDone && tr.Evaluate() &&
(tr.Name().Contains(myCfg.PatternForShortTests) || tr.Name().Contains(myCfg.PatternForLongTests)) &&
(tr.Components != null) && (tr.Components.Diverter == diverterName))
{
double trgtFlow = (tr.TestData.Qfrom + tr.TestData.Qto) / 2;
if (!targetFlows.Contains(trgtFlow)) targetFlows.Add(trgtFlow);
}
}
IList<MeasurementCorrection> rslt = new List<MeasurementCorrection>();
foreach (double trgtFlow in targetFlows)
{
IList<Results.Entities.TestRslt> shortTestRslts = new List<Results.Entities.TestRslt>();
IList<Results.Entities.TestRslt> longTestRslts = new List<Results.Entities.TestRslt>();
///
foreach (var tr in batch.TestRslts)
{
if (tr.TestDone && tr.Evaluate() && (tr.Components != null) && (tr.Components.Diverter == diverterName) &&
(trgtFlow == (tr.TestData.Qfrom + tr.TestData.Qto) / 2))
{
if (tr.Name().Contains(myCfg.PatternForShortTests)) shortTestRslts.Add(tr);
else if (tr.Name().Contains(myCfg.PatternForLongTests)) longTestRslts.Add(tr);
}
}
if (shortTestRslts.Count == 1 && longTestRslts.Count == 1)
{
Results.Entities.TestRslt shTR = shortTestRslts[0];
Results.Entities.TestRslt loTR = longTestRslts[0];
/// Calculate a correction and add it to the list
try
{
double factor = loTR.PulsesMaster / shTR.PulsesMaster * (loTR.MassEnd - loTR.MassStart) / (shTR.MassEnd - shTR.MassStart);
double correction = (factor - 1.0) * loTR.TestTime / (myCfg.ShortTestDiversionsCount - 1);
rslt.Add(new MeasurementCorrection { RangeIx = 0, Measurement = (float)trgtFlow, Correction = (float)correction });
log.InfoFormat("Calculated diverter correction at {0} m3/h: {1} s", trgtFlow, correction);
}
catch (Exception exc)
{
log.ErrorFormat("Error when calculationg diverter correction at {0} m3/h: {1}", trgtFlow, exc.Message);
}
}
}
return rslt;
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt)
{
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
{
session.Delete(dbCmpnt.Corrections[i]);
}
dbCmpnt.Corrections = new List<MeasurementCorrection>();
runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
session.SaveOrUpdate(dbCmpnt);
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = 0;
dbCmpnt.Corrections.Add(mc);
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibInfoCfg;
if (cfg != null)
{
cfg.CalibCertificateNr = string.Format(myCfg.CertificateFmt, batch.StartTime, batch.EndTime, batch.BatchNr);
cfg.CalibDate = DateTime.Now;
cfg.CalibValidDate = DateTime.Now + new TimeSpan(myCfg.ValidityDays, 0, 0, 0);
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
}
/// <summary>Start this operation</summary>
public void Start()
{
opCompleted = false;
anyError = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten or Event.Error</returns>
public Event Run()
{
if (myCfg.DebugLevel == DebugMode.Simulate)
{
opCompleted = true;
return Event.ResultsWritten;
}
if (currentOp == CurrentOp.SaveDiverterCorrections)
{
if (!opCompleted)
{
ITransaction transaction = null;
try
{
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
transaction = session.BeginTransaction();
for (int div = 1; div <= myCfg.DivertersCount(); div++)
{
string diverterName = myCfg.GetDiverterName(div);
Elde.Diverter.Diverter diverter = TbfComponents.FindComponent(diverterName) as Elde.Diverter.Diverter;
if (diverter != null)
{
var cmpntEntities = session.QueryOver<Component>()
.Where(cmpnt => (cmpnt.Name == diverterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(diverterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
{
log.ErrorFormat("No unique diverter named {0}", diverterName);
continue;
}
newCorrections = CalculateCorrectionsFromResuls(batch, diverterName);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, newCorrections);
}
}
transaction.Commit();
session.Flush();
opCompleted = true;
log.WarnFormat("Measurement corrections successfully saved");
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
anyError = true;
log.ErrorFormat("Failed to write corrections calculated from batch {0}: {1}", batch.BatchNr, exc.Message);
}
}
if (anyError)
return Event.ErrorProcessingResults;
else
return Event.ResultsWritten;
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
currentOp = CurrentOp.None;
}
}
}
@@ -0,0 +1,89 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SaveDiverterCorrections
{
public class SaveDiverterCorrCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SaveDiverterCorrCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new SaveDiverterCorrCfgCtrl(); }
public string Diverter1;
public string Diverter2;
public string Diverter3;
public string Diverter4;
public string Diverter5;
public string Diverter6;
public string PatternForShortTests;
public string PatternForLongTests;
public int ShortTestDiversionsCount;
public string CertificateFmt;
public int ValidityDays;
public int DivertersCount() { return 6; }
/// <summary>
/// Get flowmeter name
/// </summary>
/// <param name="d">Flowmeter index 1 .. FlowmetersCount()==7</param>
/// <returns>Flowmeter name or null</returns>
public string GetDiverterName(int d)
{
switch (d)
{
case 1: return Diverter1;
case 2: return Diverter2;
case 3: return Diverter3;
case 4: return Diverter4;
case 5: return Diverter5;
case 6: return Diverter6;
case 7: return ShortTestDiversionsCount.ToString();
default: return null;
}
}
/// Private parameterless constructor invoked by all other (public) constructors
SaveDiverterCorrCfg()
{
ParentName = string.Empty;
Diverter1 = "Div1";
Diverter2 = "Div2";
Diverter3 = null;
Diverter4 = null;
Diverter5 = null;
Diverter6 = null;
ShortTestDiversionsCount = 10;
PatternForShortTests = "short";
PatternForLongTests = "long";
}
public SaveDiverterCorrCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}",
Name,
string.IsNullOrEmpty(Diverter1) ? "---" : Diverter1,
string.IsNullOrEmpty(Diverter2) ? "---" : Diverter2,
string.IsNullOrEmpty(Diverter3) ? "---" : Diverter3,
string.IsNullOrEmpty(Diverter4) ? "---" : Diverter4,
string.IsNullOrEmpty(Diverter5) ? "---" : Diverter5,
string.IsNullOrEmpty(Diverter6) ? "---" : Diverter6);
}
}
}
@@ -0,0 +1,185 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Output.DB.SaveDiverterCorrections
{
public partial class SaveDiverterCorrCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
ComponentParametersDlg parent;
SaveDiverterCorrCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as SaveDiverterCorrCfg;
Redraw();
}
}
public SaveDiverterCorrCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
diverter1ComboBox.Items.Add("---");
diverter2ComboBox.Items.Add("---");
diverter3ComboBox.Items.Add("---");
diverter4ComboBox.Items.Add("---");
diverter5ComboBox.Items.Add("---");
diverter6ComboBox.Items.Add("---");
///
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.Rig.Elde.Diverter.DiverterFactory)
{
diverter1ComboBox.Items.Add(cmpnt.Name);
diverter2ComboBox.Items.Add(cmpnt.Name);
diverter3ComboBox.Items.Add(cmpnt.Name);
diverter4ComboBox.Items.Add(cmpnt.Name);
diverter5ComboBox.Items.Add(cmpnt.Name);
diverter6ComboBox.Items.Add(cmpnt.Name);
}
}
}
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
diverter1ComboBox.Text = string.IsNullOrEmpty(config.Diverter1) ? "---" : config.Diverter1;
diverter2ComboBox.Text = string.IsNullOrEmpty(config.Diverter2) ? "---" : config.Diverter2;
diverter3ComboBox.Text = string.IsNullOrEmpty(config.Diverter3) ? "---" : config.Diverter3;
diverter4ComboBox.Text = string.IsNullOrEmpty(config.Diverter4) ? "---" : config.Diverter4;
diverter5ComboBox.Text = string.IsNullOrEmpty(config.Diverter5) ? "---" : config.Diverter5;
diverter6ComboBox.Text = string.IsNullOrEmpty(config.Diverter6) ? "---" : config.Diverter6;
patternShortTextBox.Text = config.PatternForShortTests;
patternLongTextBox.Text = config.PatternForLongTests;
diversionsCountTextBox.Text = config.ShortTestDiversionsCount.ToString();
certificateTextBox.Text = config.CertificateFmt;
validityTextBox.Text = config.ValidityDays.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
diverter1ComboBox.Enabled = true;
diverter2ComboBox.Enabled = true;
diverter3ComboBox.Enabled = true;
diverter4ComboBox.Enabled = true;
diverter5ComboBox.Enabled = true;
diverter6ComboBox.Enabled = true;
patternShortTextBox.Enabled = true;
patternLongTextBox.Enabled = true;
diversionsCountTextBox.Enabled = true;
certificateTextBox.Enabled = true;
validityTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!diverter1ComboBox.Items.Contains(diverter1ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter1Label.Text);
}
if (!diverter2ComboBox.Items.Contains(diverter2ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter2Label.Text);
}
if (!diverter3ComboBox.Items.Contains(diverter3ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter3Label.Text);
}
if (!diverter4ComboBox.Items.Contains(diverter4ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter4Label.Text);
}
if (!diverter5ComboBox.Items.Contains(diverter5ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter5Label.Text);
}
if (!diverter6ComboBox.Items.Contains(diverter6ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", diverter6Label.Text);
}
int tmp;
if (!int.TryParse(diversionsCountTextBox.Text, out tmp) || tmp <= 2)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text);
}
if (!int.TryParse(validityTextBox.Text, out tmp) || tmp < 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text);
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
}
flags |= UpdateDifferent(ref config.Diverter1, diverter1ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter2, diverter2ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter3, diverter3ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter4, diverter4ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter5, diverter5ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Diverter6, diverter6ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.PatternForShortTests, patternShortTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.PatternForLongTests, patternLongTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ShortTestDiversionsCount, diversionsCountTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.CertificateFmt, certificateTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ValidityDays, validityTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
return flags;
}
}
}
@@ -0,0 +1,369 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.DB.SaveDiverterCorrections
{
partial class SaveDiverterCorrCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.diverter1Label = new System.Windows.Forms.Label();
this.diverter1ComboBox = new System.Windows.Forms.ComboBox();
this.diverter2ComboBox = new System.Windows.Forms.ComboBox();
this.diverter2Label = new System.Windows.Forms.Label();
this.diverter3ComboBox = new System.Windows.Forms.ComboBox();
this.diverter3Label = new System.Windows.Forms.Label();
this.diverter4ComboBox = new System.Windows.Forms.ComboBox();
this.diverter4Label = new System.Windows.Forms.Label();
this.diverter5ComboBox = new System.Windows.Forms.ComboBox();
this.diverter5Label = new System.Windows.Forms.Label();
this.diverter6ComboBox = new System.Windows.Forms.ComboBox();
this.diverter6Label = new System.Windows.Forms.Label();
this.certificateTextBox = new System.Windows.Forms.TextBox();
this.certificateLabel = new System.Windows.Forms.Label();
this.validityTextBox = new System.Windows.Forms.TextBox();
this.validityLabel = new System.Windows.Forms.Label();
this.paternShortLabel = new System.Windows.Forms.Label();
this.patternShortTextBox = new System.Windows.Forms.TextBox();
this.patternLongTextBox = new System.Windows.Forms.TextBox();
this.patternLongLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.diversionsCountTextBox = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(124, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(285, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(15, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(136, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// diverter1Label
//
this.diverter1Label.AutoSize = true;
this.diverter1Label.Location = new System.Drawing.Point(15, 57);
this.diverter1Label.Name = "diverter1Label";
this.diverter1Label.Size = new System.Drawing.Size(53, 13);
this.diverter1Label.TabIndex = 3;
this.diverter1Label.Text = "Diverter 1";
//
// diverter1ComboBox
//
this.diverter1ComboBox.Enabled = false;
this.diverter1ComboBox.FormattingEnabled = true;
this.diverter1ComboBox.Location = new System.Drawing.Point(124, 54);
this.diverter1ComboBox.Name = "diverter1ComboBox";
this.diverter1ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter1ComboBox.TabIndex = 4;
//
// diverter2ComboBox
//
this.diverter2ComboBox.Enabled = false;
this.diverter2ComboBox.FormattingEnabled = true;
this.diverter2ComboBox.Location = new System.Drawing.Point(124, 78);
this.diverter2ComboBox.Name = "diverter2ComboBox";
this.diverter2ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter2ComboBox.TabIndex = 6;
//
// diverter2Label
//
this.diverter2Label.AutoSize = true;
this.diverter2Label.Location = new System.Drawing.Point(15, 81);
this.diverter2Label.Name = "diverter2Label";
this.diverter2Label.Size = new System.Drawing.Size(53, 13);
this.diverter2Label.TabIndex = 5;
this.diverter2Label.Text = "Diverter 2";
//
// diverter3ComboBox
//
this.diverter3ComboBox.Enabled = false;
this.diverter3ComboBox.FormattingEnabled = true;
this.diverter3ComboBox.Location = new System.Drawing.Point(124, 102);
this.diverter3ComboBox.Name = "diverter3ComboBox";
this.diverter3ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter3ComboBox.TabIndex = 8;
//
// diverter3Label
//
this.diverter3Label.AutoSize = true;
this.diverter3Label.Location = new System.Drawing.Point(15, 105);
this.diverter3Label.Name = "diverter3Label";
this.diverter3Label.Size = new System.Drawing.Size(53, 13);
this.diverter3Label.TabIndex = 7;
this.diverter3Label.Text = "Diverter 3";
//
// diverter4ComboBox
//
this.diverter4ComboBox.Enabled = false;
this.diverter4ComboBox.FormattingEnabled = true;
this.diverter4ComboBox.Location = new System.Drawing.Point(124, 126);
this.diverter4ComboBox.Name = "diverter4ComboBox";
this.diverter4ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter4ComboBox.TabIndex = 10;
//
// diverter4Label
//
this.diverter4Label.AutoSize = true;
this.diverter4Label.Location = new System.Drawing.Point(15, 129);
this.diverter4Label.Name = "diverter4Label";
this.diverter4Label.Size = new System.Drawing.Size(53, 13);
this.diverter4Label.TabIndex = 9;
this.diverter4Label.Text = "Diverter 4";
//
// diverter5ComboBox
//
this.diverter5ComboBox.Enabled = false;
this.diverter5ComboBox.FormattingEnabled = true;
this.diverter5ComboBox.Location = new System.Drawing.Point(124, 150);
this.diverter5ComboBox.Name = "diverter5ComboBox";
this.diverter5ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter5ComboBox.TabIndex = 12;
//
// diverter5Label
//
this.diverter5Label.AutoSize = true;
this.diverter5Label.Location = new System.Drawing.Point(15, 153);
this.diverter5Label.Name = "diverter5Label";
this.diverter5Label.Size = new System.Drawing.Size(53, 13);
this.diverter5Label.TabIndex = 11;
this.diverter5Label.Text = "Diverter 5";
//
// diverter6ComboBox
//
this.diverter6ComboBox.Enabled = false;
this.diverter6ComboBox.FormattingEnabled = true;
this.diverter6ComboBox.Location = new System.Drawing.Point(124, 174);
this.diverter6ComboBox.Name = "diverter6ComboBox";
this.diverter6ComboBox.Size = new System.Drawing.Size(69, 21);
this.diverter6ComboBox.TabIndex = 14;
//
// diverter6Label
//
this.diverter6Label.AutoSize = true;
this.diverter6Label.Location = new System.Drawing.Point(15, 177);
this.diverter6Label.Name = "diverter6Label";
this.diverter6Label.Size = new System.Drawing.Size(53, 13);
this.diverter6Label.TabIndex = 13;
this.diverter6Label.Text = "Diverter 6";
//
// certificateTextBox
//
this.certificateTextBox.Enabled = false;
this.certificateTextBox.Location = new System.Drawing.Point(124, 244);
this.certificateTextBox.Name = "certificateTextBox";
this.certificateTextBox.Size = new System.Drawing.Size(285, 20);
this.certificateTextBox.TabIndex = 20;
//
// certificateLabel
//
this.certificateLabel.AutoSize = true;
this.certificateLabel.Location = new System.Drawing.Point(15, 247);
this.certificateLabel.Name = "certificateLabel";
this.certificateLabel.Size = new System.Drawing.Size(54, 13);
this.certificateLabel.TabIndex = 19;
this.certificateLabel.Text = "Certificate";
//
// validityTextBox
//
this.validityTextBox.Enabled = false;
this.validityTextBox.Location = new System.Drawing.Point(124, 267);
this.validityTextBox.Name = "validityTextBox";
this.validityTextBox.Size = new System.Drawing.Size(43, 20);
this.validityTextBox.TabIndex = 22;
//
// validityLabel
//
this.validityLabel.AutoSize = true;
this.validityLabel.Location = new System.Drawing.Point(15, 270);
this.validityLabel.Name = "validityLabel";
this.validityLabel.Size = new System.Drawing.Size(71, 13);
this.validityLabel.TabIndex = 21;
this.validityLabel.Text = "Validity (days)";
//
// paternShortLabel
//
this.paternShortLabel.AutoSize = true;
this.paternShortLabel.Location = new System.Drawing.Point(15, 201);
this.paternShortLabel.Name = "paternShortLabel";
this.paternShortLabel.Size = new System.Drawing.Size(107, 13);
this.paternShortLabel.TabIndex = 15;
this.paternShortLabel.Text = "Pattern for short tests";
//
// patternShortTextBox
//
this.patternShortTextBox.Enabled = false;
this.patternShortTextBox.Location = new System.Drawing.Point(124, 198);
this.patternShortTextBox.Name = "patternShortTextBox";
this.patternShortTextBox.Size = new System.Drawing.Size(107, 20);
this.patternShortTextBox.TabIndex = 16;
//
// patternLongTextBox
//
this.patternLongTextBox.Enabled = false;
this.patternLongTextBox.Location = new System.Drawing.Point(124, 221);
this.patternLongTextBox.Name = "patternLongTextBox";
this.patternLongTextBox.Size = new System.Drawing.Size(107, 20);
this.patternLongTextBox.TabIndex = 18;
//
// patternLongLabel
//
this.patternLongLabel.AutoSize = true;
this.patternLongLabel.Location = new System.Drawing.Point(15, 224);
this.patternLongLabel.Name = "patternLongLabel";
this.patternLongLabel.Size = new System.Drawing.Size(104, 13);
this.patternLongLabel.TabIndex = 17;
this.patternLongLabel.Text = "Pattern for long tests";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(245, 201);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(132, 13);
this.label1.TabIndex = 23;
this.label1.Text = "Short test diversions count";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(245, 224);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(131, 13);
this.label2.TabIndex = 24;
this.label2.Text = "Long test diversions count";
//
// diversionsCountTextBox
//
this.diversionsCountTextBox.Enabled = false;
this.diversionsCountTextBox.Location = new System.Drawing.Point(378, 198);
this.diversionsCountTextBox.Name = "diversionsCountTextBox";
this.diversionsCountTextBox.Size = new System.Drawing.Size(31, 20);
this.diversionsCountTextBox.TabIndex = 25;
//
// textBox2
//
this.textBox2.Enabled = false;
this.textBox2.Location = new System.Drawing.Point(378, 221);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(31, 20);
this.textBox2.TabIndex = 26;
this.textBox2.Text = "1";
//
// SaveDiverterCorrCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox2);
this.Controls.Add(this.diversionsCountTextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.patternLongLabel);
this.Controls.Add(this.patternLongTextBox);
this.Controls.Add(this.patternShortTextBox);
this.Controls.Add(this.paternShortLabel);
this.Controls.Add(this.validityTextBox);
this.Controls.Add(this.validityLabel);
this.Controls.Add(this.certificateTextBox);
this.Controls.Add(this.certificateLabel);
this.Controls.Add(this.diverter6ComboBox);
this.Controls.Add(this.diverter6Label);
this.Controls.Add(this.diverter5ComboBox);
this.Controls.Add(this.diverter5Label);
this.Controls.Add(this.diverter4ComboBox);
this.Controls.Add(this.diverter4Label);
this.Controls.Add(this.diverter3ComboBox);
this.Controls.Add(this.diverter3Label);
this.Controls.Add(this.diverter2ComboBox);
this.Controls.Add(this.diverter2Label);
this.Controls.Add(this.diverter1ComboBox);
this.Controls.Add(this.diverter1Label);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "SaveDiverterCorrCfgCtrl";
this.Size = new System.Drawing.Size(450, 300);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label diverter1Label;
private System.Windows.Forms.ComboBox diverter1ComboBox;
private System.Windows.Forms.ComboBox diverter2ComboBox;
private System.Windows.Forms.Label diverter2Label;
private System.Windows.Forms.ComboBox diverter3ComboBox;
private System.Windows.Forms.Label diverter3Label;
private System.Windows.Forms.ComboBox diverter4ComboBox;
private System.Windows.Forms.Label diverter4Label;
private System.Windows.Forms.ComboBox diverter5ComboBox;
private System.Windows.Forms.Label diverter5Label;
private System.Windows.Forms.ComboBox diverter6ComboBox;
private System.Windows.Forms.Label diverter6Label;
private System.Windows.Forms.TextBox certificateTextBox;
private System.Windows.Forms.Label certificateLabel;
private System.Windows.Forms.TextBox validityTextBox;
private System.Windows.Forms.Label validityLabel;
private System.Windows.Forms.Label paternShortLabel;
private System.Windows.Forms.TextBox patternShortTextBox;
private System.Windows.Forms.TextBox patternLongTextBox;
private System.Windows.Forms.Label patternLongLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox diversionsCountTextBox;
private System.Windows.Forms.TextBox textBox2;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { SaveFlowmeterCorr.ResetStaticProperties(); }
public IComponent DummyComponent() { return new SaveFlowmeterCorr(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new SaveFlowmeterCorr(cfg); }
public IComponentCfg DefaultConfig() { return new SaveFlowmeterCorrCfg(this.GetType().Namespace.Substring(18), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(SaveFlowmeterCorrCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,274 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using NHibernate;
using NHibernate.Criterion;
using Config;
using Config.Entities;
using TracingDB.Entities;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
{
public enum Retv
{
OK,
Error,
}
public class SaveFlowmeterCorr : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(SaveFlowmeterCorr));
public override string ToString() { return string.Format("SaveFlowmeterCorr({0})", Cfg.ToString(1)); }
SaveFlowmeterCorrCfg myCfg;
enum CurrentOp
{
None,
SaveFlowmeterCorrections,
}
CurrentOp currentOp;
bool opCompleted;
bool anyError;
/// <summary>
/// Results to parse for reference flowmeter corrections
/// </summary>
Results.Entities.Batch batch;
IList<MeasurementCorrection> newCorrections;
public SaveFlowmeterCorr() {}
public SaveFlowmeterCorr(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as SaveFlowmeterCorrCfg;
currentOp = CurrentOp.None;
log.Warn(this.ToString());
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
if (currentOp != CurrentOp.None)
throw new Exception("Sequence error");
else
currentOp = CurrentOp.SaveFlowmeterCorrections;
this.batch = batch;
return this;
}
IList<MeasurementCorrection> GetCorrections(Results.Entities.Batch batch, string flowmeterName, int rngIx, double tempRngLo, double tempRngHi)
{
IList<MeasurementCorrection> rslt = new List<MeasurementCorrection>();
foreach (var tr in batch.TestRslts)
{
if (tr.TestDone && tr.Components != null && tr.Components.Flowmeter == flowmeterName &&
tr.RepetitionNr == 1 && tr.Evaluate() && tr.TempLimLo() >= tempRngLo && tr.TempLimHi() <= tempRngHi)
{
double flow = 0;
double errorMaster = 0;
if (tr.Repeats() == 1)
{
flow = tr.FlowVolume;
errorMaster = tr.ErrorMaster;
}
else
{
int count = 0;
foreach (var tr2 in batch.TestRslts)
{
if (tr2.TestDone && (tr2.TestData.Name == tr.TestData.Name))
{
flow += tr2.FlowVolume;
errorMaster += tr2.ErrorMaster;
count++;
}
}
flow /= count;
errorMaster /= count;
}
double correction = Formulas.CorrectionFromError(flow, errorMaster);
rslt.Add(new MeasurementCorrection { RangeIx = rngIx, Measurement = (float)flow, Correction = (float)correction });
}
}
return rslt;
}
void DeleteExistingCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx)
{
/// Delete correction from DB entity
for (int i = dbCmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (dbCmpnt.Corrections[i].RangeIx == rangeIx)
{
session.Delete(dbCmpnt.Corrections[i]);
dbCmpnt.Corrections.RemoveAt(i);
}
}
session.SaveOrUpdate(dbCmpnt);
/// Delete corrections from runtime flowmeter component
for (int i = runtimeCmpnt.Corrections.Count - 1; i >= 0; i--)
{
if (runtimeCmpnt.Corrections[i].RangeIx == rangeIx)
{
runtimeCmpnt.Corrections.RemoveAt(i);
}
}
}
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
{
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
foreach (var mc in corrections)
{
mc.RangeIx = rangeIx;
dbCmpnt.Corrections.Add(mc);
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
session.SaveOrUpdate(mc);
}
ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(dbCmpnt) as ICalibRangesCfg;
if (cfg != null)
{
cfg.SetCalibDate(rangeIx, DateTime.Now);
if (!string.IsNullOrEmpty(myCfg.CertificateFmt))
{
cfg.SetCalibCertificate(rangeIx, string.Format(myCfg.CertificateFmt, batch.StartTime, batch.EndTime, batch.BatchNr));
}
if (myCfg.ValidityDays > 0)
{
cfg.SetCalibValidDate(rangeIx, DateTime.Now + new TimeSpan(myCfg.ValidityDays, 0, 0, 0));
}
Component modified = cfg.CreateDbEntity();
dbCmpnt.Parameters = modified.Parameters;
}
session.SaveOrUpdate(dbCmpnt);
}
/// <summary>Start this operation</summary>
public void Start()
{
opCompleted = false;
anyError = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten or Event.Error</returns>
public Event Run()
{
if (myCfg.DebugLevel == DebugMode.Simulate)
{
opCompleted = true;
return Event.ResultsWritten;
}
if (currentOp == CurrentOp.SaveFlowmeterCorrections)
{
if (!opCompleted)
{
ITransaction transaction = null;
try
{
ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
transaction = session.BeginTransaction();
for (int fmtr = 1; fmtr <= myCfg.FlowmetersCount(); fmtr++)
{
string flowmeterName = myCfg.GetFlowmeterName(fmtr);
Elde.FlowMeter.FlowMeter flowmeter = TbfComponents.FindComponent(flowmeterName) as Elde.FlowMeter.FlowMeter;
if (flowmeter != null)
{
var cmpntEntities = session.QueryOver<Component>()
.Where(cmpnt => (cmpnt.Name == flowmeterName))
.List();
var runtimeComponent = TbfComponents.FindComponent(flowmeterName);
if ((cmpntEntities.Count != 1) || (runtimeComponent == null))
{
log.ErrorFormat("No unique flowmeter named {0}", myCfg.GetFlowmeterName(fmtr));
continue;
}
for (int rng = 0; rng <= myCfg.RangesCount(); rng++)
{
if (myCfg.FlowmtrRangeEnabled(fmtr, rng))
{
double tempRngLo = flowmeter.GetTempLo(rng);
double tempRngHi = flowmeter.GetTempHi(rng);
newCorrections = GetCorrections(batch, flowmeterName, rng, tempRngLo, tempRngHi);
DeleteExistingCorrections(session, cmpntEntities[0], runtimeComponent, rng);
SaveNewCorrections(session, cmpntEntities[0], runtimeComponent, rng, newCorrections);
}
}
}
}
transaction.Commit();
session.Flush();
opCompleted = true;
log.WarnFormat("Measurement corrections successfully saved");
}
catch (Exception exc)
{
if (transaction != null && !transaction.WasCommitted) transaction.Rollback();
anyError = true;
log.ErrorFormat("Failed to write corrections calculated from batch {0}: {1}", batch.BatchNr, exc.Message);
}
}
if (anyError)
return Event.ErrorProcessingResults;
else
return Event.ResultsWritten;
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
currentOp = CurrentOp.None;
}
}
}
@@ -0,0 +1,232 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
{
public class SaveFlowmeterCorrCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SaveFlowmeterCorrCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new SaveFlowmeterCorrCfgCtrl(); }
public string Flowmeter1;
public string Flowmeter2;
public string Flowmeter3;
public string Flowmeter4;
public string Flowmeter5;
public string Flowmeter6;
public string Flowmeter7;
public bool Flowm1Rng1;
public bool Flowm1Rng2;
public bool Flowm1Rng3;
public bool Flowm1Rng4;
public bool Flowm1Rng5;
public bool Flowm2Rng1;
public bool Flowm2Rng2;
public bool Flowm2Rng3;
public bool Flowm2Rng4;
public bool Flowm2Rng5;
public bool Flowm3Rng1;
public bool Flowm3Rng2;
public bool Flowm3Rng3;
public bool Flowm3Rng4;
public bool Flowm3Rng5;
public bool Flowm4Rng1;
public bool Flowm4Rng2;
public bool Flowm4Rng3;
public bool Flowm4Rng4;
public bool Flowm4Rng5;
public bool Flowm5Rng1;
public bool Flowm5Rng2;
public bool Flowm5Rng3;
public bool Flowm5Rng4;
public bool Flowm5Rng5;
public bool Flowm6Rng1;
public bool Flowm6Rng2;
public bool Flowm6Rng3;
public bool Flowm6Rng4;
public bool Flowm6Rng5;
public bool Flowm7Rng1;
public bool Flowm7Rng2;
public bool Flowm7Rng3;
public bool Flowm7Rng4;
public bool Flowm7Rng5;
public string CertificateFmt;
public int ValidityDays;
public int FlowmetersCount() { return 7; }
public int RangesCount() { return 5; }
/// <summary>
/// Get flowmeter name
/// </summary>
/// <param name="f">Flowmeter index 1 .. FlowmetersCount()==7</param>
/// <returns>Flowmeter name or null</returns>
public string GetFlowmeterName(int f)
{
switch (f)
{
case 1: return Flowmeter1;
case 2: return Flowmeter2;
case 3: return Flowmeter3;
case 4: return Flowmeter4;
case 5: return Flowmeter5;
case 6: return Flowmeter6;
case 7: return Flowmeter7;
default: return null;
}
}
/// <summary>
/// Is range enabled
/// </summary>
/// <param name="f">Flowmeter index 1 .. FlowmetersCount()==7</param>
/// <param name="r">Range index 0 .. RangesCount()==5</param>
/// <returns>ture if the range is enabled</returns>
public bool FlowmtrRangeEnabled(int f, int r)
{
if (f == 1)
{
switch (r)
{
case 0: return !(Flowm1Rng1 || Flowm1Rng2 || Flowm1Rng3 || Flowm1Rng4 || Flowm1Rng5);
case 1: return Flowm1Rng1;
case 2: return Flowm1Rng2;
case 3: return Flowm1Rng3;
case 4: return Flowm1Rng4;
case 5: return Flowm1Rng5;
default: break;
}
}
else if (f == 2)
{
switch (r)
{
case 0: return !(Flowm2Rng1 || Flowm2Rng2 || Flowm2Rng3 || Flowm2Rng4 || Flowm2Rng5);
case 1: return Flowm2Rng1;
case 2: return Flowm2Rng2;
case 3: return Flowm2Rng3;
case 4: return Flowm2Rng4;
case 5: return Flowm2Rng5;
default: break;
}
}
else if (f == 3)
{
switch (r)
{
case 0: return !(Flowm3Rng1 || Flowm3Rng2 || Flowm3Rng3 || Flowm3Rng4 || Flowm3Rng5);
case 1: return Flowm3Rng1;
case 2: return Flowm3Rng2;
case 3: return Flowm3Rng3;
case 4: return Flowm3Rng4;
case 5: return Flowm3Rng5;
default: break;
}
}
else if (f == 4)
{
switch (r)
{
case 0: return !(Flowm4Rng1 || Flowm4Rng2 || Flowm4Rng3 || Flowm4Rng4 || Flowm4Rng5);
case 1: return Flowm4Rng1;
case 2: return Flowm4Rng2;
case 3: return Flowm4Rng3;
case 4: return Flowm4Rng4;
case 5: return Flowm4Rng5;
default: break;
}
}
else if (f == 5)
{
switch (r)
{
case 0: return !(Flowm5Rng1 || Flowm5Rng2 || Flowm5Rng3 || Flowm5Rng4 || Flowm5Rng5);
case 1: return Flowm5Rng1;
case 2: return Flowm5Rng2;
case 3: return Flowm5Rng3;
case 4: return Flowm5Rng4;
case 5: return Flowm5Rng5;
default: break;
}
}
else if (f == 6)
{
switch (r)
{
case 0: return !(Flowm6Rng1 || Flowm6Rng2 || Flowm6Rng3 || Flowm6Rng4 || Flowm6Rng5);
case 1: return Flowm6Rng1;
case 2: return Flowm6Rng2;
case 3: return Flowm6Rng3;
case 4: return Flowm6Rng4;
case 5: return Flowm6Rng5;
default: break;
}
}
else if (f == 7)
{
switch (r)
{
case 0: return !(Flowm7Rng1 || Flowm7Rng2 || Flowm7Rng3 || Flowm7Rng4 || Flowm7Rng5);
case 1: return Flowm7Rng1;
case 2: return Flowm7Rng2;
case 3: return Flowm7Rng3;
case 4: return Flowm7Rng4;
case 5: return Flowm7Rng5;
default: break;
}
}
return false;
}
/// Private parameterless constructor invoked by all other (public) constructors
SaveFlowmeterCorrCfg()
{
ParentName = string.Empty;
Flowmeter1 = "I1";
Flowmeter2 = "I2";
Flowmeter3 = "I3";
Flowmeter4 = null;
Flowmeter5 = null;
Flowmeter6 = null;
Flowmeter7 = null;
}
public SaveFlowmeterCorrCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}, Flowmtr7={7}",
Name,
string.IsNullOrEmpty(Flowmeter1) ? "---" : Flowmeter1,
string.IsNullOrEmpty(Flowmeter2) ? "---" : Flowmeter2,
string.IsNullOrEmpty(Flowmeter3) ? "---" : Flowmeter3,
string.IsNullOrEmpty(Flowmeter4) ? "---" : Flowmeter4,
string.IsNullOrEmpty(Flowmeter5) ? "---" : Flowmeter5,
string.IsNullOrEmpty(Flowmeter6) ? "---" : Flowmeter6,
string.IsNullOrEmpty(Flowmeter7) ? "---" : Flowmeter7);
}
}
}
@@ -0,0 +1,375 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
{
public partial class SaveFlowmeterCorrCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
ComponentParametersDlg parent;
SaveFlowmeterCorrCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as SaveFlowmeterCorrCfg;
Redraw();
}
}
public SaveFlowmeterCorrCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
flowmeter1ComboBox.Items.Add("---");
flowmeter2ComboBox.Items.Add("---");
flowmeter3ComboBox.Items.Add("---");
flowmeter4ComboBox.Items.Add("---");
flowmeter5ComboBox.Items.Add("---");
flowmeter6ComboBox.Items.Add("---");
flowmeter7ComboBox.Items.Add("---");
///
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.Rig.Elde.FlowMeter.FlowMeterFactory)
{
flowmeter1ComboBox.Items.Add(cmpnt.Name);
flowmeter2ComboBox.Items.Add(cmpnt.Name);
flowmeter3ComboBox.Items.Add(cmpnt.Name);
flowmeter4ComboBox.Items.Add(cmpnt.Name);
flowmeter5ComboBox.Items.Add(cmpnt.Name);
flowmeter6ComboBox.Items.Add(cmpnt.Name);
flowmeter7ComboBox.Items.Add(cmpnt.Name);
}
}
}
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
flowmeter1ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter1) ? "---" : config.Flowmeter1;
flowm1Rng1CheckBox.Checked = config.Flowm1Rng1;
flowm1Rng2CheckBox.Checked = config.Flowm1Rng2;
flowm1Rng3CheckBox.Checked = config.Flowm1Rng3;
flowm1Rng4CheckBox.Checked = config.Flowm1Rng4;
flowm1Rng5CheckBox.Checked = config.Flowm1Rng5;
flowm1Rng0CheckBox.Checked = !(config.Flowm1Rng1 || config.Flowm1Rng2 || config.Flowm1Rng3 || config.Flowm1Rng4 || config.Flowm1Rng5);
flowmeter2ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter2) ? "---" : config.Flowmeter2;
flowm2Rng1CheckBox.Checked = config.Flowm2Rng1;
flowm2Rng2CheckBox.Checked = config.Flowm2Rng2;
flowm2Rng3CheckBox.Checked = config.Flowm2Rng3;
flowm2Rng4CheckBox.Checked = config.Flowm2Rng4;
flowm2Rng5CheckBox.Checked = config.Flowm2Rng5;
flowm2Rng0CheckBox.Checked = !(config.Flowm2Rng1 || config.Flowm2Rng2 || config.Flowm2Rng3 || config.Flowm2Rng4 || config.Flowm2Rng5);
flowmeter3ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter3) ? "---" : config.Flowmeter3;
flowm3Rng1CheckBox.Checked = config.Flowm3Rng1;
flowm3Rng2CheckBox.Checked = config.Flowm3Rng2;
flowm3Rng3CheckBox.Checked = config.Flowm3Rng3;
flowm3Rng4CheckBox.Checked = config.Flowm3Rng4;
flowm3Rng5CheckBox.Checked = config.Flowm3Rng5;
flowm3Rng0CheckBox.Checked = !(config.Flowm3Rng1 || config.Flowm3Rng2 || config.Flowm3Rng3 || config.Flowm3Rng4 || config.Flowm3Rng5);
flowmeter4ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter4) ? "---" : config.Flowmeter4;
flowm4Rng1CheckBox.Checked = config.Flowm4Rng1;
flowm4Rng2CheckBox.Checked = config.Flowm4Rng2;
flowm4Rng3CheckBox.Checked = config.Flowm4Rng3;
flowm4Rng4CheckBox.Checked = config.Flowm4Rng4;
flowm4Rng5CheckBox.Checked = config.Flowm4Rng5;
flowm4Rng0CheckBox.Checked = !(config.Flowm4Rng1 || config.Flowm4Rng2 || config.Flowm4Rng3 || config.Flowm4Rng4 || config.Flowm4Rng5);
flowmeter5ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter5) ? "---" : config.Flowmeter5;
flowm5Rng1CheckBox.Checked = config.Flowm5Rng1;
flowm5Rng2CheckBox.Checked = config.Flowm5Rng2;
flowm5Rng3CheckBox.Checked = config.Flowm5Rng3;
flowm5Rng4CheckBox.Checked = config.Flowm5Rng4;
flowm5Rng5CheckBox.Checked = config.Flowm5Rng5;
flowm5Rng0CheckBox.Checked = !(config.Flowm5Rng1 || config.Flowm5Rng2 || config.Flowm5Rng3 || config.Flowm5Rng4 || config.Flowm5Rng5);
flowmeter6ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter6) ? "---" : config.Flowmeter6;
flowm6Rng1CheckBox.Checked = config.Flowm6Rng1;
flowm6Rng2CheckBox.Checked = config.Flowm6Rng2;
flowm6Rng3CheckBox.Checked = config.Flowm6Rng3;
flowm6Rng4CheckBox.Checked = config.Flowm6Rng4;
flowm6Rng5CheckBox.Checked = config.Flowm6Rng5;
flowm6Rng0CheckBox.Checked = !(config.Flowm6Rng1 || config.Flowm6Rng2 || config.Flowm6Rng3 || config.Flowm6Rng4 || config.Flowm6Rng5);
flowmeter7ComboBox.Text = string.IsNullOrEmpty(config.Flowmeter7) ? "---" : config.Flowmeter7;
flowm7Rng1CheckBox.Checked = config.Flowm7Rng1;
flowm7Rng2CheckBox.Checked = config.Flowm7Rng2;
flowm7Rng3CheckBox.Checked = config.Flowm7Rng3;
flowm7Rng4CheckBox.Checked = config.Flowm7Rng4;
flowm7Rng5CheckBox.Checked = config.Flowm7Rng5;
flowm7Rng0CheckBox.Checked = !(config.Flowm7Rng1 || config.Flowm7Rng2 || config.Flowm7Rng3 || config.Flowm7Rng4 || config.Flowm7Rng5);
certificateTextBox.Text = config.CertificateFmt;
validityTextBox.Text = config.ValidityDays.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
flowmeter1ComboBox.Enabled = true;
flowm1Rng0CheckBox.Enabled = true;
flowm1Rng1CheckBox.Enabled = true;
flowm1Rng2CheckBox.Enabled = true;
flowm1Rng3CheckBox.Enabled = true;
flowm1Rng4CheckBox.Enabled = true;
flowm1Rng5CheckBox.Enabled = true;
flowmeter2ComboBox.Enabled = true;
flowm2Rng0CheckBox.Enabled = true;
flowm2Rng1CheckBox.Enabled = true;
flowm2Rng2CheckBox.Enabled = true;
flowm2Rng3CheckBox.Enabled = true;
flowm2Rng4CheckBox.Enabled = true;
flowm2Rng5CheckBox.Enabled = true;
flowmeter3ComboBox.Enabled = true;
flowm3Rng0CheckBox.Enabled = true;
flowm3Rng1CheckBox.Enabled = true;
flowm3Rng2CheckBox.Enabled = true;
flowm3Rng3CheckBox.Enabled = true;
flowm3Rng4CheckBox.Enabled = true;
flowm3Rng5CheckBox.Enabled = true;
flowmeter4ComboBox.Enabled = true;
flowm4Rng0CheckBox.Enabled = true;
flowm4Rng1CheckBox.Enabled = true;
flowm4Rng2CheckBox.Enabled = true;
flowm4Rng3CheckBox.Enabled = true;
flowm4Rng4CheckBox.Enabled = true;
flowm4Rng5CheckBox.Enabled = true;
flowmeter5ComboBox.Enabled = true;
flowm5Rng0CheckBox.Enabled = true;
flowm5Rng1CheckBox.Enabled = true;
flowm5Rng2CheckBox.Enabled = true;
flowm5Rng3CheckBox.Enabled = true;
flowm5Rng4CheckBox.Enabled = true;
flowm5Rng5CheckBox.Enabled = true;
flowmeter6ComboBox.Enabled = true;
flowm6Rng0CheckBox.Enabled = true;
flowm6Rng1CheckBox.Enabled = true;
flowm6Rng2CheckBox.Enabled = true;
flowm6Rng3CheckBox.Enabled = true;
flowm6Rng4CheckBox.Enabled = true;
flowm6Rng5CheckBox.Enabled = true;
flowmeter7ComboBox.Enabled = true;
flowm7Rng0CheckBox.Enabled = true;
flowm7Rng1CheckBox.Enabled = true;
flowm7Rng2CheckBox.Enabled = true;
flowm7Rng3CheckBox.Enabled = true;
flowm7Rng4CheckBox.Enabled = true;
flowm7Rng5CheckBox.Enabled = true;
certificateTextBox.Enabled = true;
validityTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!flowmeter1ComboBox.Items.Contains(flowmeter1ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter1Label.Text);
}
if ((flowmeter1ComboBox.Text != "---") &&
(flowm1Rng0CheckBox.Checked == (flowm1Rng1CheckBox.Checked || flowm1Rng2CheckBox.Checked || flowm1Rng3CheckBox.Checked ||
flowm1Rng4CheckBox.Checked || flowm1Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter1Label.Text);
}
if (!flowmeter2ComboBox.Items.Contains(flowmeter2ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter2Label.Text);
}
if ((flowmeter2ComboBox.Text != "---") &&
(flowm2Rng0CheckBox.Checked == (flowm2Rng1CheckBox.Checked || flowm2Rng2CheckBox.Checked || flowm2Rng3CheckBox.Checked ||
flowm2Rng4CheckBox.Checked || flowm2Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter2Label.Text);
}
if (!flowmeter3ComboBox.Items.Contains(flowmeter3ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter3Label.Text);
}
if ((flowmeter3ComboBox.Text != "---") &&
(flowm3Rng0CheckBox.Checked == (flowm3Rng1CheckBox.Checked || flowm3Rng2CheckBox.Checked || flowm3Rng3CheckBox.Checked ||
flowm3Rng4CheckBox.Checked || flowm3Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter3Label.Text);
}
if (!flowmeter4ComboBox.Items.Contains(flowmeter4ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter4Label.Text);
}
if ((flowmeter4ComboBox.Text != "---") &&
(flowm4Rng0CheckBox.Checked == (flowm4Rng1CheckBox.Checked || flowm4Rng2CheckBox.Checked || flowm4Rng3CheckBox.Checked ||
flowm4Rng4CheckBox.Checked || flowm4Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter4Label.Text);
}
if (!flowmeter5ComboBox.Items.Contains(flowmeter5ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter5Label.Text);
}
if ((flowmeter5ComboBox.Text != "---") &&
(flowm5Rng0CheckBox.Checked == (flowm5Rng1CheckBox.Checked || flowm5Rng2CheckBox.Checked || flowm5Rng3CheckBox.Checked ||
flowm5Rng4CheckBox.Checked || flowm5Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter5Label.Text);
}
if (!flowmeter6ComboBox.Items.Contains(flowmeter6ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter6Label.Text);
}
if ((flowmeter6ComboBox.Text != "---") &&
(flowm6Rng0CheckBox.Checked == (flowm6Rng1CheckBox.Checked || flowm6Rng2CheckBox.Checked || flowm6Rng3CheckBox.Checked ||
flowm6Rng4CheckBox.Checked || flowm6Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter6Label.Text);
}
if (!flowmeter7ComboBox.Items.Contains(flowmeter7ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", flowmeter7Label.Text);
}
if ((flowmeter7ComboBox.Text != "---") &&
(flowm7Rng0CheckBox.Checked == (flowm7Rng1CheckBox.Checked || flowm7Rng2CheckBox.Checked || flowm7Rng3CheckBox.Checked ||
flowm7Rng4CheckBox.Checked || flowm7Rng5CheckBox.Checked)))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid ranges for {0}", flowmeter7Label.Text);
}
int tmp;
if (!int.TryParse(validityTextBox.Text, out tmp) || tmp < 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text);
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
}
flags |= UpdateDifferent(ref config.Flowmeter1, flowmeter1ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm1Rng1, flowm1Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm1Rng2, flowm1Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm1Rng3, flowm1Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm1Rng4, flowm1Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm1Rng5, flowm1Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter2, flowmeter2ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm2Rng1, flowm2Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm2Rng2, flowm2Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm2Rng3, flowm2Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm2Rng4, flowm2Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm2Rng5, flowm2Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter3, flowmeter3ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm3Rng1, flowm3Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm3Rng2, flowm3Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm3Rng3, flowm3Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm3Rng4, flowm3Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm3Rng5, flowm3Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter4, flowmeter4ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm4Rng1, flowm4Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm4Rng2, flowm4Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm4Rng3, flowm4Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm4Rng4, flowm4Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm4Rng5, flowm4Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter5, flowmeter5ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm5Rng1, flowm5Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm5Rng2, flowm5Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm5Rng3, flowm5Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm5Rng4, flowm5Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm5Rng5, flowm5Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter6, flowmeter6ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm6Rng1, flowm6Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm6Rng2, flowm6Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm6Rng3, flowm6Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm6Rng4, flowm6Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm6Rng5, flowm6Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowmeter7, flowmeter7ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm7Rng1, flowm7Rng1CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm7Rng2, flowm7Rng2CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm7Rng3, flowm7Rng3CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm7Rng4, flowm7Rng4CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.Flowm7Rng5, flowm7Rng5CheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.CertificateFmt, certificateTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(ref config.ValidityDays, validityTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
return flags;
}
}
}
@@ -0,0 +1,912 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections
{
partial class SaveFlowmeterCorrCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.flowmeter1Label = new System.Windows.Forms.Label();
this.flowmeter1ComboBox = new System.Windows.Forms.ComboBox();
this.flowm1Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowm1Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm1Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm1Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm1Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter2ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter2Label = new System.Windows.Forms.Label();
this.flowm3Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm3Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm3Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm3Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm3Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter3ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter3Label = new System.Windows.Forms.Label();
this.flowm4Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm4Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm4Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm4Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm4Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter4ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter4Label = new System.Windows.Forms.Label();
this.flowm5Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm5Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm5Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm5Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm5Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter5ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter5Label = new System.Windows.Forms.Label();
this.flowm5Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm4Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm3Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm2Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm1Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.flowm6Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm6Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm6Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm6Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm6Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm6Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter6ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter6Label = new System.Windows.Forms.Label();
this.flowm7Rng0CheckBox = new System.Windows.Forms.CheckBox();
this.flowm7Rng5CheckBox = new System.Windows.Forms.CheckBox();
this.flowm7Rng4CheckBox = new System.Windows.Forms.CheckBox();
this.flowm7Rng3CheckBox = new System.Windows.Forms.CheckBox();
this.flowm7Rng2CheckBox = new System.Windows.Forms.CheckBox();
this.flowm7Rng1CheckBox = new System.Windows.Forms.CheckBox();
this.flowmeter7ComboBox = new System.Windows.Forms.ComboBox();
this.flowmeter7Label = new System.Windows.Forms.Label();
this.certificateTextBox = new System.Windows.Forms.TextBox();
this.certificateLabel = new System.Windows.Forms.Label();
this.validityTextBox = new System.Windows.Forms.TextBox();
this.validityLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(95, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(212, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(15, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(107, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// flowmeter1Label
//
this.flowmeter1Label.AutoSize = true;
this.flowmeter1Label.Location = new System.Drawing.Point(15, 80);
this.flowmeter1Label.Name = "flowmeter1Label";
this.flowmeter1Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter1Label.TabIndex = 3;
this.flowmeter1Label.Text = "Flowmeter 1";
//
// flowmeter1ComboBox
//
this.flowmeter1ComboBox.Enabled = false;
this.flowmeter1ComboBox.FormattingEnabled = true;
this.flowmeter1ComboBox.Location = new System.Drawing.Point(95, 77);
this.flowmeter1ComboBox.Name = "flowmeter1ComboBox";
this.flowmeter1ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter1ComboBox.TabIndex = 4;
//
// flowm1Rng1CheckBox
//
this.flowm1Rng1CheckBox.AutoSize = true;
this.flowm1Rng1CheckBox.Enabled = false;
this.flowm1Rng1CheckBox.Location = new System.Drawing.Point(245, 80);
this.flowm1Rng1CheckBox.Name = "flowm1Rng1CheckBox";
this.flowm1Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng1CheckBox.TabIndex = 6;
this.flowm1Rng1CheckBox.Text = "1";
this.flowm1Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowm1Rng2CheckBox
//
this.flowm1Rng2CheckBox.AutoSize = true;
this.flowm1Rng2CheckBox.Enabled = false;
this.flowm1Rng2CheckBox.Location = new System.Drawing.Point(275, 80);
this.flowm1Rng2CheckBox.Name = "flowm1Rng2CheckBox";
this.flowm1Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng2CheckBox.TabIndex = 7;
this.flowm1Rng2CheckBox.Text = "2";
this.flowm1Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm1Rng3CheckBox
//
this.flowm1Rng3CheckBox.AutoSize = true;
this.flowm1Rng3CheckBox.Enabled = false;
this.flowm1Rng3CheckBox.Location = new System.Drawing.Point(305, 80);
this.flowm1Rng3CheckBox.Name = "flowm1Rng3CheckBox";
this.flowm1Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng3CheckBox.TabIndex = 8;
this.flowm1Rng3CheckBox.Text = "3";
this.flowm1Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm1Rng4CheckBox
//
this.flowm1Rng4CheckBox.AutoSize = true;
this.flowm1Rng4CheckBox.Enabled = false;
this.flowm1Rng4CheckBox.Location = new System.Drawing.Point(335, 80);
this.flowm1Rng4CheckBox.Name = "flowm1Rng4CheckBox";
this.flowm1Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng4CheckBox.TabIndex = 9;
this.flowm1Rng4CheckBox.Text = "4";
this.flowm1Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm1Rng5CheckBox
//
this.flowm1Rng5CheckBox.AutoSize = true;
this.flowm1Rng5CheckBox.Enabled = false;
this.flowm1Rng5CheckBox.Location = new System.Drawing.Point(365, 80);
this.flowm1Rng5CheckBox.Name = "flowm1Rng5CheckBox";
this.flowm1Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng5CheckBox.TabIndex = 10;
this.flowm1Rng5CheckBox.Text = "5";
this.flowm1Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng5CheckBox
//
this.flowm2Rng5CheckBox.AutoSize = true;
this.flowm2Rng5CheckBox.Enabled = false;
this.flowm2Rng5CheckBox.Location = new System.Drawing.Point(365, 104);
this.flowm2Rng5CheckBox.Name = "flowm2Rng5CheckBox";
this.flowm2Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng5CheckBox.TabIndex = 18;
this.flowm2Rng5CheckBox.Text = "5";
this.flowm2Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng4CheckBox
//
this.flowm2Rng4CheckBox.AutoSize = true;
this.flowm2Rng4CheckBox.Enabled = false;
this.flowm2Rng4CheckBox.Location = new System.Drawing.Point(335, 104);
this.flowm2Rng4CheckBox.Name = "flowm2Rng4CheckBox";
this.flowm2Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng4CheckBox.TabIndex = 17;
this.flowm2Rng4CheckBox.Text = "4";
this.flowm2Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng3CheckBox
//
this.flowm2Rng3CheckBox.AutoSize = true;
this.flowm2Rng3CheckBox.Enabled = false;
this.flowm2Rng3CheckBox.Location = new System.Drawing.Point(305, 104);
this.flowm2Rng3CheckBox.Name = "flowm2Rng3CheckBox";
this.flowm2Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng3CheckBox.TabIndex = 16;
this.flowm2Rng3CheckBox.Text = "3";
this.flowm2Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng2CheckBox
//
this.flowm2Rng2CheckBox.AutoSize = true;
this.flowm2Rng2CheckBox.Enabled = false;
this.flowm2Rng2CheckBox.Location = new System.Drawing.Point(275, 104);
this.flowm2Rng2CheckBox.Name = "flowm2Rng2CheckBox";
this.flowm2Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng2CheckBox.TabIndex = 15;
this.flowm2Rng2CheckBox.Text = "2";
this.flowm2Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng1CheckBox
//
this.flowm2Rng1CheckBox.AutoSize = true;
this.flowm2Rng1CheckBox.Enabled = false;
this.flowm2Rng1CheckBox.Location = new System.Drawing.Point(245, 104);
this.flowm2Rng1CheckBox.Name = "flowm2Rng1CheckBox";
this.flowm2Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng1CheckBox.TabIndex = 14;
this.flowm2Rng1CheckBox.Text = "1";
this.flowm2Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter2ComboBox
//
this.flowmeter2ComboBox.Enabled = false;
this.flowmeter2ComboBox.FormattingEnabled = true;
this.flowmeter2ComboBox.Location = new System.Drawing.Point(95, 101);
this.flowmeter2ComboBox.Name = "flowmeter2ComboBox";
this.flowmeter2ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter2ComboBox.TabIndex = 12;
//
// flowmeter2Label
//
this.flowmeter2Label.AutoSize = true;
this.flowmeter2Label.Location = new System.Drawing.Point(15, 104);
this.flowmeter2Label.Name = "flowmeter2Label";
this.flowmeter2Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter2Label.TabIndex = 11;
this.flowmeter2Label.Text = "Flowmeter 2";
//
// flowm3Rng5CheckBox
//
this.flowm3Rng5CheckBox.AutoSize = true;
this.flowm3Rng5CheckBox.Enabled = false;
this.flowm3Rng5CheckBox.Location = new System.Drawing.Point(365, 128);
this.flowm3Rng5CheckBox.Name = "flowm3Rng5CheckBox";
this.flowm3Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng5CheckBox.TabIndex = 26;
this.flowm3Rng5CheckBox.Text = "5";
this.flowm3Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm3Rng4CheckBox
//
this.flowm3Rng4CheckBox.AutoSize = true;
this.flowm3Rng4CheckBox.Enabled = false;
this.flowm3Rng4CheckBox.Location = new System.Drawing.Point(335, 128);
this.flowm3Rng4CheckBox.Name = "flowm3Rng4CheckBox";
this.flowm3Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng4CheckBox.TabIndex = 25;
this.flowm3Rng4CheckBox.Text = "4";
this.flowm3Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm3Rng3CheckBox
//
this.flowm3Rng3CheckBox.AutoSize = true;
this.flowm3Rng3CheckBox.Enabled = false;
this.flowm3Rng3CheckBox.Location = new System.Drawing.Point(305, 128);
this.flowm3Rng3CheckBox.Name = "flowm3Rng3CheckBox";
this.flowm3Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng3CheckBox.TabIndex = 24;
this.flowm3Rng3CheckBox.Text = "3";
this.flowm3Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm3Rng2CheckBox
//
this.flowm3Rng2CheckBox.AutoSize = true;
this.flowm3Rng2CheckBox.Enabled = false;
this.flowm3Rng2CheckBox.Location = new System.Drawing.Point(275, 128);
this.flowm3Rng2CheckBox.Name = "flowm3Rng2CheckBox";
this.flowm3Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng2CheckBox.TabIndex = 23;
this.flowm3Rng2CheckBox.Text = "2";
this.flowm3Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm3Rng1CheckBox
//
this.flowm3Rng1CheckBox.AutoSize = true;
this.flowm3Rng1CheckBox.Enabled = false;
this.flowm3Rng1CheckBox.Location = new System.Drawing.Point(245, 128);
this.flowm3Rng1CheckBox.Name = "flowm3Rng1CheckBox";
this.flowm3Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng1CheckBox.TabIndex = 22;
this.flowm3Rng1CheckBox.Text = "1";
this.flowm3Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter3ComboBox
//
this.flowmeter3ComboBox.Enabled = false;
this.flowmeter3ComboBox.FormattingEnabled = true;
this.flowmeter3ComboBox.Location = new System.Drawing.Point(95, 125);
this.flowmeter3ComboBox.Name = "flowmeter3ComboBox";
this.flowmeter3ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter3ComboBox.TabIndex = 20;
//
// flowmeter3Label
//
this.flowmeter3Label.AutoSize = true;
this.flowmeter3Label.Location = new System.Drawing.Point(15, 128);
this.flowmeter3Label.Name = "flowmeter3Label";
this.flowmeter3Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter3Label.TabIndex = 19;
this.flowmeter3Label.Text = "Flowmeter 3";
//
// flowm4Rng5CheckBox
//
this.flowm4Rng5CheckBox.AutoSize = true;
this.flowm4Rng5CheckBox.Enabled = false;
this.flowm4Rng5CheckBox.Location = new System.Drawing.Point(365, 152);
this.flowm4Rng5CheckBox.Name = "flowm4Rng5CheckBox";
this.flowm4Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng5CheckBox.TabIndex = 34;
this.flowm4Rng5CheckBox.Text = "5";
this.flowm4Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm4Rng4CheckBox
//
this.flowm4Rng4CheckBox.AutoSize = true;
this.flowm4Rng4CheckBox.Enabled = false;
this.flowm4Rng4CheckBox.Location = new System.Drawing.Point(335, 152);
this.flowm4Rng4CheckBox.Name = "flowm4Rng4CheckBox";
this.flowm4Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng4CheckBox.TabIndex = 33;
this.flowm4Rng4CheckBox.Text = "4";
this.flowm4Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm4Rng3CheckBox
//
this.flowm4Rng3CheckBox.AutoSize = true;
this.flowm4Rng3CheckBox.Enabled = false;
this.flowm4Rng3CheckBox.Location = new System.Drawing.Point(305, 152);
this.flowm4Rng3CheckBox.Name = "flowm4Rng3CheckBox";
this.flowm4Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng3CheckBox.TabIndex = 32;
this.flowm4Rng3CheckBox.Text = "3";
this.flowm4Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm4Rng2CheckBox
//
this.flowm4Rng2CheckBox.AutoSize = true;
this.flowm4Rng2CheckBox.Enabled = false;
this.flowm4Rng2CheckBox.Location = new System.Drawing.Point(275, 152);
this.flowm4Rng2CheckBox.Name = "flowm4Rng2CheckBox";
this.flowm4Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng2CheckBox.TabIndex = 31;
this.flowm4Rng2CheckBox.Text = "2";
this.flowm4Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm4Rng1CheckBox
//
this.flowm4Rng1CheckBox.AutoSize = true;
this.flowm4Rng1CheckBox.Enabled = false;
this.flowm4Rng1CheckBox.Location = new System.Drawing.Point(245, 152);
this.flowm4Rng1CheckBox.Name = "flowm4Rng1CheckBox";
this.flowm4Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng1CheckBox.TabIndex = 30;
this.flowm4Rng1CheckBox.Text = "1";
this.flowm4Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter4ComboBox
//
this.flowmeter4ComboBox.Enabled = false;
this.flowmeter4ComboBox.FormattingEnabled = true;
this.flowmeter4ComboBox.Location = new System.Drawing.Point(95, 149);
this.flowmeter4ComboBox.Name = "flowmeter4ComboBox";
this.flowmeter4ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter4ComboBox.TabIndex = 28;
//
// flowmeter4Label
//
this.flowmeter4Label.AutoSize = true;
this.flowmeter4Label.Location = new System.Drawing.Point(15, 152);
this.flowmeter4Label.Name = "flowmeter4Label";
this.flowmeter4Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter4Label.TabIndex = 27;
this.flowmeter4Label.Text = "Flowmeter 4";
//
// flowm5Rng5CheckBox
//
this.flowm5Rng5CheckBox.AutoSize = true;
this.flowm5Rng5CheckBox.Enabled = false;
this.flowm5Rng5CheckBox.Location = new System.Drawing.Point(365, 176);
this.flowm5Rng5CheckBox.Name = "flowm5Rng5CheckBox";
this.flowm5Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng5CheckBox.TabIndex = 42;
this.flowm5Rng5CheckBox.Text = "5";
this.flowm5Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm5Rng4CheckBox
//
this.flowm5Rng4CheckBox.AutoSize = true;
this.flowm5Rng4CheckBox.Enabled = false;
this.flowm5Rng4CheckBox.Location = new System.Drawing.Point(335, 176);
this.flowm5Rng4CheckBox.Name = "flowm5Rng4CheckBox";
this.flowm5Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng4CheckBox.TabIndex = 41;
this.flowm5Rng4CheckBox.Text = "4";
this.flowm5Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm5Rng3CheckBox
//
this.flowm5Rng3CheckBox.AutoSize = true;
this.flowm5Rng3CheckBox.Enabled = false;
this.flowm5Rng3CheckBox.Location = new System.Drawing.Point(305, 176);
this.flowm5Rng3CheckBox.Name = "flowm5Rng3CheckBox";
this.flowm5Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng3CheckBox.TabIndex = 40;
this.flowm5Rng3CheckBox.Text = "3";
this.flowm5Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm5Rng2CheckBox
//
this.flowm5Rng2CheckBox.AutoSize = true;
this.flowm5Rng2CheckBox.Enabled = false;
this.flowm5Rng2CheckBox.Location = new System.Drawing.Point(275, 176);
this.flowm5Rng2CheckBox.Name = "flowm5Rng2CheckBox";
this.flowm5Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng2CheckBox.TabIndex = 39;
this.flowm5Rng2CheckBox.Text = "2";
this.flowm5Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm5Rng1CheckBox
//
this.flowm5Rng1CheckBox.AutoSize = true;
this.flowm5Rng1CheckBox.Enabled = false;
this.flowm5Rng1CheckBox.Location = new System.Drawing.Point(245, 176);
this.flowm5Rng1CheckBox.Name = "flowm5Rng1CheckBox";
this.flowm5Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng1CheckBox.TabIndex = 38;
this.flowm5Rng1CheckBox.Text = "1";
this.flowm5Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter5ComboBox
//
this.flowmeter5ComboBox.Enabled = false;
this.flowmeter5ComboBox.FormattingEnabled = true;
this.flowmeter5ComboBox.Location = new System.Drawing.Point(95, 173);
this.flowmeter5ComboBox.Name = "flowmeter5ComboBox";
this.flowmeter5ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter5ComboBox.TabIndex = 36;
//
// flowmeter5Label
//
this.flowmeter5Label.AutoSize = true;
this.flowmeter5Label.Location = new System.Drawing.Point(15, 176);
this.flowmeter5Label.Name = "flowmeter5Label";
this.flowmeter5Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter5Label.TabIndex = 35;
this.flowmeter5Label.Text = "Flowmeter 5";
//
// flowm5Rng0CheckBox
//
this.flowm5Rng0CheckBox.AutoSize = true;
this.flowm5Rng0CheckBox.Enabled = false;
this.flowm5Rng0CheckBox.Location = new System.Drawing.Point(196, 176);
this.flowm5Rng0CheckBox.Name = "flowm5Rng0CheckBox";
this.flowm5Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm5Rng0CheckBox.TabIndex = 37;
this.flowm5Rng0CheckBox.Text = "0";
this.flowm5Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm4Rng0CheckBox
//
this.flowm4Rng0CheckBox.AutoSize = true;
this.flowm4Rng0CheckBox.Enabled = false;
this.flowm4Rng0CheckBox.Location = new System.Drawing.Point(196, 152);
this.flowm4Rng0CheckBox.Name = "flowm4Rng0CheckBox";
this.flowm4Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm4Rng0CheckBox.TabIndex = 29;
this.flowm4Rng0CheckBox.Text = "0";
this.flowm4Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm3Rng0CheckBox
//
this.flowm3Rng0CheckBox.AutoSize = true;
this.flowm3Rng0CheckBox.Enabled = false;
this.flowm3Rng0CheckBox.Location = new System.Drawing.Point(196, 128);
this.flowm3Rng0CheckBox.Name = "flowm3Rng0CheckBox";
this.flowm3Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm3Rng0CheckBox.TabIndex = 21;
this.flowm3Rng0CheckBox.Text = "0";
this.flowm3Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm2Rng0CheckBox
//
this.flowm2Rng0CheckBox.AutoSize = true;
this.flowm2Rng0CheckBox.Enabled = false;
this.flowm2Rng0CheckBox.Location = new System.Drawing.Point(196, 104);
this.flowm2Rng0CheckBox.Name = "flowm2Rng0CheckBox";
this.flowm2Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm2Rng0CheckBox.TabIndex = 13;
this.flowm2Rng0CheckBox.Text = "0";
this.flowm2Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm1Rng0CheckBox
//
this.flowm1Rng0CheckBox.AutoSize = true;
this.flowm1Rng0CheckBox.Enabled = false;
this.flowm1Rng0CheckBox.Location = new System.Drawing.Point(196, 80);
this.flowm1Rng0CheckBox.Name = "flowm1Rng0CheckBox";
this.flowm1Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm1Rng0CheckBox.TabIndex = 5;
this.flowm1Rng0CheckBox.Text = "0";
this.flowm1Rng0CheckBox.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(193, 58);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(179, 13);
this.label1.TabIndex = 43;
this.label1.Text = "Ranges to calibrate (either 0 or 1...5)";
//
// flowm6Rng0CheckBox
//
this.flowm6Rng0CheckBox.AutoSize = true;
this.flowm6Rng0CheckBox.Enabled = false;
this.flowm6Rng0CheckBox.Location = new System.Drawing.Point(196, 200);
this.flowm6Rng0CheckBox.Name = "flowm6Rng0CheckBox";
this.flowm6Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng0CheckBox.TabIndex = 46;
this.flowm6Rng0CheckBox.Text = "0";
this.flowm6Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm6Rng5CheckBox
//
this.flowm6Rng5CheckBox.AutoSize = true;
this.flowm6Rng5CheckBox.Enabled = false;
this.flowm6Rng5CheckBox.Location = new System.Drawing.Point(365, 200);
this.flowm6Rng5CheckBox.Name = "flowm6Rng5CheckBox";
this.flowm6Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng5CheckBox.TabIndex = 51;
this.flowm6Rng5CheckBox.Text = "5";
this.flowm6Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm6Rng4CheckBox
//
this.flowm6Rng4CheckBox.AutoSize = true;
this.flowm6Rng4CheckBox.Enabled = false;
this.flowm6Rng4CheckBox.Location = new System.Drawing.Point(335, 200);
this.flowm6Rng4CheckBox.Name = "flowm6Rng4CheckBox";
this.flowm6Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng4CheckBox.TabIndex = 50;
this.flowm6Rng4CheckBox.Text = "4";
this.flowm6Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm6Rng3CheckBox
//
this.flowm6Rng3CheckBox.AutoSize = true;
this.flowm6Rng3CheckBox.Enabled = false;
this.flowm6Rng3CheckBox.Location = new System.Drawing.Point(305, 200);
this.flowm6Rng3CheckBox.Name = "flowm6Rng3CheckBox";
this.flowm6Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng3CheckBox.TabIndex = 49;
this.flowm6Rng3CheckBox.Text = "3";
this.flowm6Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm6Rng2CheckBox
//
this.flowm6Rng2CheckBox.AutoSize = true;
this.flowm6Rng2CheckBox.Enabled = false;
this.flowm6Rng2CheckBox.Location = new System.Drawing.Point(275, 200);
this.flowm6Rng2CheckBox.Name = "flowm6Rng2CheckBox";
this.flowm6Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng2CheckBox.TabIndex = 48;
this.flowm6Rng2CheckBox.Text = "2";
this.flowm6Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm6Rng1CheckBox
//
this.flowm6Rng1CheckBox.AutoSize = true;
this.flowm6Rng1CheckBox.Enabled = false;
this.flowm6Rng1CheckBox.Location = new System.Drawing.Point(245, 200);
this.flowm6Rng1CheckBox.Name = "flowm6Rng1CheckBox";
this.flowm6Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm6Rng1CheckBox.TabIndex = 47;
this.flowm6Rng1CheckBox.Text = "1";
this.flowm6Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter6ComboBox
//
this.flowmeter6ComboBox.Enabled = false;
this.flowmeter6ComboBox.FormattingEnabled = true;
this.flowmeter6ComboBox.Location = new System.Drawing.Point(95, 197);
this.flowmeter6ComboBox.Name = "flowmeter6ComboBox";
this.flowmeter6ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter6ComboBox.TabIndex = 45;
//
// flowmeter6Label
//
this.flowmeter6Label.AutoSize = true;
this.flowmeter6Label.Location = new System.Drawing.Point(15, 200);
this.flowmeter6Label.Name = "flowmeter6Label";
this.flowmeter6Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter6Label.TabIndex = 44;
this.flowmeter6Label.Text = "Flowmeter 6";
//
// flowm7Rng0CheckBox
//
this.flowm7Rng0CheckBox.AutoSize = true;
this.flowm7Rng0CheckBox.Enabled = false;
this.flowm7Rng0CheckBox.Location = new System.Drawing.Point(196, 224);
this.flowm7Rng0CheckBox.Name = "flowm7Rng0CheckBox";
this.flowm7Rng0CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng0CheckBox.TabIndex = 54;
this.flowm7Rng0CheckBox.Text = "0";
this.flowm7Rng0CheckBox.UseVisualStyleBackColor = true;
//
// flowm7Rng5CheckBox
//
this.flowm7Rng5CheckBox.AutoSize = true;
this.flowm7Rng5CheckBox.Enabled = false;
this.flowm7Rng5CheckBox.Location = new System.Drawing.Point(365, 224);
this.flowm7Rng5CheckBox.Name = "flowm7Rng5CheckBox";
this.flowm7Rng5CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng5CheckBox.TabIndex = 59;
this.flowm7Rng5CheckBox.Text = "5";
this.flowm7Rng5CheckBox.UseVisualStyleBackColor = true;
//
// flowm7Rng4CheckBox
//
this.flowm7Rng4CheckBox.AutoSize = true;
this.flowm7Rng4CheckBox.Enabled = false;
this.flowm7Rng4CheckBox.Location = new System.Drawing.Point(335, 224);
this.flowm7Rng4CheckBox.Name = "flowm7Rng4CheckBox";
this.flowm7Rng4CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng4CheckBox.TabIndex = 58;
this.flowm7Rng4CheckBox.Text = "4";
this.flowm7Rng4CheckBox.UseVisualStyleBackColor = true;
//
// flowm7Rng3CheckBox
//
this.flowm7Rng3CheckBox.AutoSize = true;
this.flowm7Rng3CheckBox.Enabled = false;
this.flowm7Rng3CheckBox.Location = new System.Drawing.Point(305, 224);
this.flowm7Rng3CheckBox.Name = "flowm7Rng3CheckBox";
this.flowm7Rng3CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng3CheckBox.TabIndex = 57;
this.flowm7Rng3CheckBox.Text = "3";
this.flowm7Rng3CheckBox.UseVisualStyleBackColor = true;
//
// flowm7Rng2CheckBox
//
this.flowm7Rng2CheckBox.AutoSize = true;
this.flowm7Rng2CheckBox.Enabled = false;
this.flowm7Rng2CheckBox.Location = new System.Drawing.Point(275, 224);
this.flowm7Rng2CheckBox.Name = "flowm7Rng2CheckBox";
this.flowm7Rng2CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng2CheckBox.TabIndex = 56;
this.flowm7Rng2CheckBox.Text = "2";
this.flowm7Rng2CheckBox.UseVisualStyleBackColor = true;
//
// flowm7Rng1CheckBox
//
this.flowm7Rng1CheckBox.AutoSize = true;
this.flowm7Rng1CheckBox.Enabled = false;
this.flowm7Rng1CheckBox.Location = new System.Drawing.Point(245, 224);
this.flowm7Rng1CheckBox.Name = "flowm7Rng1CheckBox";
this.flowm7Rng1CheckBox.Size = new System.Drawing.Size(32, 17);
this.flowm7Rng1CheckBox.TabIndex = 55;
this.flowm7Rng1CheckBox.Text = "1";
this.flowm7Rng1CheckBox.UseVisualStyleBackColor = true;
//
// flowmeter7ComboBox
//
this.flowmeter7ComboBox.Enabled = false;
this.flowmeter7ComboBox.FormattingEnabled = true;
this.flowmeter7ComboBox.Location = new System.Drawing.Point(95, 221);
this.flowmeter7ComboBox.Name = "flowmeter7ComboBox";
this.flowmeter7ComboBox.Size = new System.Drawing.Size(69, 21);
this.flowmeter7ComboBox.TabIndex = 53;
//
// flowmeter7Label
//
this.flowmeter7Label.AutoSize = true;
this.flowmeter7Label.Location = new System.Drawing.Point(15, 224);
this.flowmeter7Label.Name = "flowmeter7Label";
this.flowmeter7Label.Size = new System.Drawing.Size(64, 13);
this.flowmeter7Label.TabIndex = 52;
this.flowmeter7Label.Text = "Flowmeter 7";
//
// certificateTextBox
//
this.certificateTextBox.Enabled = false;
this.certificateTextBox.Location = new System.Drawing.Point(95, 249);
this.certificateTextBox.Name = "certificateTextBox";
this.certificateTextBox.Size = new System.Drawing.Size(212, 20);
this.certificateTextBox.TabIndex = 61;
//
// certificateLabel
//
this.certificateLabel.AutoSize = true;
this.certificateLabel.Location = new System.Drawing.Point(15, 252);
this.certificateLabel.Name = "certificateLabel";
this.certificateLabel.Size = new System.Drawing.Size(54, 13);
this.certificateLabel.TabIndex = 60;
this.certificateLabel.Text = "Certificate";
//
// validityTextBox
//
this.validityTextBox.Enabled = false;
this.validityTextBox.Location = new System.Drawing.Point(95, 273);
this.validityTextBox.Name = "validityTextBox";
this.validityTextBox.Size = new System.Drawing.Size(69, 20);
this.validityTextBox.TabIndex = 63;
//
// validityLabel
//
this.validityLabel.AutoSize = true;
this.validityLabel.Location = new System.Drawing.Point(15, 276);
this.validityLabel.Name = "validityLabel";
this.validityLabel.Size = new System.Drawing.Size(71, 13);
this.validityLabel.TabIndex = 62;
this.validityLabel.Text = "Validity (days)";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(313, 252);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(120, 13);
this.label2.TabIndex = 64;
this.label2.Text = "(0=start 1-end, 2=batch)";
//
// SaveFlowmeterCorrCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label2);
this.Controls.Add(this.validityTextBox);
this.Controls.Add(this.validityLabel);
this.Controls.Add(this.certificateTextBox);
this.Controls.Add(this.certificateLabel);
this.Controls.Add(this.flowm7Rng0CheckBox);
this.Controls.Add(this.flowm7Rng5CheckBox);
this.Controls.Add(this.flowm7Rng4CheckBox);
this.Controls.Add(this.flowm7Rng3CheckBox);
this.Controls.Add(this.flowm7Rng2CheckBox);
this.Controls.Add(this.flowm7Rng1CheckBox);
this.Controls.Add(this.flowmeter7ComboBox);
this.Controls.Add(this.flowmeter7Label);
this.Controls.Add(this.flowm6Rng0CheckBox);
this.Controls.Add(this.flowm6Rng5CheckBox);
this.Controls.Add(this.flowm6Rng4CheckBox);
this.Controls.Add(this.flowm6Rng3CheckBox);
this.Controls.Add(this.flowm6Rng2CheckBox);
this.Controls.Add(this.flowm6Rng1CheckBox);
this.Controls.Add(this.flowmeter6ComboBox);
this.Controls.Add(this.flowmeter6Label);
this.Controls.Add(this.label1);
this.Controls.Add(this.flowm5Rng0CheckBox);
this.Controls.Add(this.flowm4Rng0CheckBox);
this.Controls.Add(this.flowm3Rng0CheckBox);
this.Controls.Add(this.flowm2Rng0CheckBox);
this.Controls.Add(this.flowm1Rng0CheckBox);
this.Controls.Add(this.flowm5Rng5CheckBox);
this.Controls.Add(this.flowm5Rng4CheckBox);
this.Controls.Add(this.flowm5Rng3CheckBox);
this.Controls.Add(this.flowm5Rng2CheckBox);
this.Controls.Add(this.flowm5Rng1CheckBox);
this.Controls.Add(this.flowmeter5ComboBox);
this.Controls.Add(this.flowmeter5Label);
this.Controls.Add(this.flowm4Rng5CheckBox);
this.Controls.Add(this.flowm4Rng4CheckBox);
this.Controls.Add(this.flowm4Rng3CheckBox);
this.Controls.Add(this.flowm4Rng2CheckBox);
this.Controls.Add(this.flowm4Rng1CheckBox);
this.Controls.Add(this.flowmeter4ComboBox);
this.Controls.Add(this.flowmeter4Label);
this.Controls.Add(this.flowm3Rng5CheckBox);
this.Controls.Add(this.flowm3Rng4CheckBox);
this.Controls.Add(this.flowm3Rng3CheckBox);
this.Controls.Add(this.flowm3Rng2CheckBox);
this.Controls.Add(this.flowm3Rng1CheckBox);
this.Controls.Add(this.flowmeter3ComboBox);
this.Controls.Add(this.flowmeter3Label);
this.Controls.Add(this.flowm2Rng5CheckBox);
this.Controls.Add(this.flowm2Rng4CheckBox);
this.Controls.Add(this.flowm2Rng3CheckBox);
this.Controls.Add(this.flowm2Rng2CheckBox);
this.Controls.Add(this.flowm2Rng1CheckBox);
this.Controls.Add(this.flowmeter2ComboBox);
this.Controls.Add(this.flowmeter2Label);
this.Controls.Add(this.flowm1Rng5CheckBox);
this.Controls.Add(this.flowm1Rng4CheckBox);
this.Controls.Add(this.flowm1Rng3CheckBox);
this.Controls.Add(this.flowm1Rng2CheckBox);
this.Controls.Add(this.flowm1Rng1CheckBox);
this.Controls.Add(this.flowmeter1ComboBox);
this.Controls.Add(this.flowmeter1Label);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "SaveFlowmeterCorrCfgCtrl";
this.Size = new System.Drawing.Size(450, 300);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label flowmeter1Label;
private System.Windows.Forms.ComboBox flowmeter1ComboBox;
private System.Windows.Forms.CheckBox flowm1Rng1CheckBox;
private System.Windows.Forms.CheckBox flowm1Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm1Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm1Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm1Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter2ComboBox;
private System.Windows.Forms.Label flowmeter2Label;
private System.Windows.Forms.CheckBox flowm3Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm3Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm3Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm3Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm3Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter3ComboBox;
private System.Windows.Forms.Label flowmeter3Label;
private System.Windows.Forms.CheckBox flowm4Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm4Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm4Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm4Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm4Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter4ComboBox;
private System.Windows.Forms.Label flowmeter4Label;
private System.Windows.Forms.CheckBox flowm5Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm5Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm5Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm5Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm5Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter5ComboBox;
private System.Windows.Forms.Label flowmeter5Label;
private System.Windows.Forms.CheckBox flowm5Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm4Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm3Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm2Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm1Rng0CheckBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox flowm6Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm6Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm6Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm6Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm6Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm6Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter6ComboBox;
private System.Windows.Forms.Label flowmeter6Label;
private System.Windows.Forms.CheckBox flowm7Rng0CheckBox;
private System.Windows.Forms.CheckBox flowm7Rng5CheckBox;
private System.Windows.Forms.CheckBox flowm7Rng4CheckBox;
private System.Windows.Forms.CheckBox flowm7Rng3CheckBox;
private System.Windows.Forms.CheckBox flowm7Rng2CheckBox;
private System.Windows.Forms.CheckBox flowm7Rng1CheckBox;
private System.Windows.Forms.ComboBox flowmeter7ComboBox;
private System.Windows.Forms.Label flowmeter7Label;
private System.Windows.Forms.TextBox certificateTextBox;
private System.Windows.Forms.Label certificateLabel;
private System.Windows.Forms.TextBox validityTextBox;
private System.Windows.Forms.Label validityLabel;
private System.Windows.Forms.Label label2;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,48 @@
///
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SensusOracle
{
public class DatabaseCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DatabaseCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new DatabaseCfgCtrl(); }
/// <summary> Serialized parameters </summary>
public bool TestMode;
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public ProcedureParams ProcParams;
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
public override IParamsProvider CreateProcParamsProvider() { return new ProcedureParams(true); }
/// Private parameterless constructor invoked by all other (public) constructors
DatabaseCfg()
{
ProcParams = new ProcedureParams(true);
}
public DatabaseCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
TestMode = false;
}
public string ToString(int i)
{
return string.Format("Name={0} TestMode={1}", Name, TestMode);
}
}
}
@@ -0,0 +1,76 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SensusOracle
{
public partial class DatabaseCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
DatabaseCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as DatabaseCfg;
Redraw();
}
}
public DatabaseCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
testModeCheckBox.Checked = config.TestMode;
}
public void Unlock()
{
nameTextBox.Enabled = true;
testModeCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
public CfgUpdateFlags UpdateCfg()
{
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.RestartRqrd;
}
flags |= UpdateDifferent(ref config.TestMode, testModeCheckBox.Checked, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
return flags;
}
}
}
+100
View File
@@ -0,0 +1,100 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.DB.SensusOracle
{
partial class DatabaseCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.testModeCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(123, 59);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(19, 62);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(120, 31);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// testModeCheckBox
//
this.testModeCheckBox.AutoSize = true;
this.testModeCheckBox.Enabled = false;
this.testModeCheckBox.Location = new System.Drawing.Point(123, 113);
this.testModeCheckBox.Name = "testModeCheckBox";
this.testModeCheckBox.Size = new System.Drawing.Size(155, 17);
this.testModeCheckBox.TabIndex = 12;
this.testModeCheckBox.Text = "TestMode (no writes to DB)";
this.testModeCheckBox.UseVisualStyleBackColor = true;
//
// DatabaseCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.testModeCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "DatabaseCfgCtrl";
this.Size = new System.Drawing.Size(383, 291);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.CheckBox testModeCheckBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+27
View File
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.DB.SensusOracle
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "Sensus-Oracle-Database"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Database.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Database(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Database(cfg); }
public IComponentCfg DefaultConfig() { return new DatabaseCfg("Sensus-Oracle-DB", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(DatabaseCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,291 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Config.Entities;
using Results.Output;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.DB.SensusOracle
{
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public DBUsed DBUsed; /// 0
public WMKind WMKind; /// 1
public int WMTypeId; /// 2
public int YearOfManufacture; /// 3
public bool SaveResults; /// 4
public bool ReadStartInfo; /// 5
public bool StartInfoIsRequired; /// 6
public DesigMode DesigMode; /// 7
public Results.Output.LogType DesigType; /// 8
public override void InitializeAll()
{
DBUsed = DBUsed.Production; /// 0
WMKind = WMKind.iPERL; /// 1
WMTypeId = 2; /// 2
YearOfManufacture = DateTime.Now.Year; /// 3
#if TURA_SPECIAL
SaveResults = false; /// 4
#else
SaveResults = true; /// 4
#endif
ReadStartInfo = true; /// 5
StartInfoIsRequired = false; /// 6
DesigMode = DesigMode.Auto; /// 7
DesigType = Results.Output.LogType.Just_Q3Q2Q1; /// 8
}
string[] paramNames = new string[]
{
"Database", /// 0
"Kind of WMs", /// 1
"WM type ID", /// 2
"Year of manufacture", /// 3
"Save results", /// 4
"Read start info", /// 5
"Start info is required", /// 6
"Designation Mode", /// 7
"Designation when mode is 'As_specified'", /// 8
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override ICollection<string> ParamValues(int i)
{
IList<string> retVal = new List<string>();
switch (i)
{
case 0:
for (DBUsed db = 0; db < DBUsed.Count; db++) retVal.Add(db.ToString());
return retVal;
case 1:
for (WMKind wm = 0; wm < WMKind.Count; wm++) retVal.Add(wm.ToString());
return retVal;
case 2:
default:
return null;
case 3:
int year = DateTime.Now.Year;
return new string[] { year.ToString(), (year + 1).ToString() };
case 4:
case 5:
case 6:
return new string[] { Strings.yes, Strings.no };
case 7:
for (DesigMode md = 0; md < DesigMode.Count; md++) retVal.Add(md.ToString());
return retVal;
case 8:
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++) retVal.Add(wm.ToString());
return retVal;
}
}
public override string ToString(int i)
{
switch (i)
{
case 0: return DBUsed.ToString();
case 1: return WMKind.ToString();
case 2: return WMTypeId.ToString();
case 3: return YearOfManufacture.ToString();
case 4: return SaveResults ? Strings.yes : Strings.no;
case 5: return ReadStartInfo ? Strings.yes : Strings.no;
case 6: return StartInfoIsRequired ? Strings.yes : Strings.no;
case 7: return DesigMode.ToString();
case 8: return DesigType.ToString();
default: return string.Empty;
}
}
/// Retrieves parameters from UI controls
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0:
for (DBUsed db = 0; db < DBUsed.Count; db++)
{
if (db.ToString() == strValue)
{
DBUsed = db;
return CfgUpdateFlags.None;
}
}
break;
case 1:
for (WMKind wm = 0; wm < WMKind.Count; wm++)
{
if (wm.ToString() == strValue)
{
WMKind = wm;
return CfgUpdateFlags.None;
}
}
break;
case 2: WMTypeId = int.Parse(strValue); break;
case 3: YearOfManufacture = int.Parse(strValue); break;
case 4: SaveResults = (strValue == Strings.yes); break;
case 5: ReadStartInfo = (strValue == Strings.yes); break;
case 6: StartInfoIsRequired = (strValue == Strings.yes); break;
case 7:
for (DesigMode db = 0; db < DesigMode.Count; db++)
{
if (db.ToString() == strValue)
{
DesigMode = db;
return CfgUpdateFlags.None;
}
}
break;
case 8:
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++)
{
if (wm.ToString() == strValue)
{
DesigType = wm;
return CfgUpdateFlags.None;
}
}
break;
}
return CfgUpdateFlags.None;
}
/// Verifies whether strings in UI controls represent valid parameters
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int idummy;
switch (i)
{
case 0:
for (DBUsed db = 0; db < DBUsed.Count; db++)
{
if (db.ToString() == strValue) return true;
}
break;
case 1:
for (WMKind wm = 0; wm < WMKind.Count; wm++)
{
if (wm.ToString() == strValue) return true;
}
break;
case 2:
if (int.TryParse(strValue, out idummy) && idummy >= 0)
return true;
break;
case 3:
if (int.TryParse(strValue, out idummy) && idummy >= DateTime.Now.Year && idummy <= DateTime.Now.Year + 1)
return true;
break;
case 4:
case 5:
case 6:
if (strValue == Strings.yes || strValue == Strings.no)
return true;
break;
case 7:
for (DesigMode db = 0; db < DesigMode.Count; db++)
{
if (db.ToString() == strValue) return true;
}
break;
case 8:
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++)
{
if (wm.ToString() == strValue) return true;
}
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ProcedureParams prms)
{
prms.DBUsed = this.DBUsed;
prms.WMKind = this.WMKind;
prms.WMTypeId = this.WMTypeId;
prms.YearOfManufacture = this.YearOfManufacture;
prms.SaveResults = this.SaveResults;
prms.ReadStartInfo = this.ReadStartInfo;
prms.StartInfoIsRequired = this.StartInfoIsRequired;
prms.DesigMode = this.DesigMode;
prms.DesigType = this.DesigType;
}
public IParamsProvider Clone()
{
ProcedureParams pars = new ProcedureParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
ProcedureParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcedureParams;
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
if (tmp != null) tmp.CopyContentTo(this);
}
catch
{
}
}
public ProcedureParams()
{
}
public ProcedureParams(bool initialize)
{
if (initialize) InitializeAll();
}
public ProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}
+18
View File
@@ -0,0 +1,18 @@
///
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output
{
public enum Culture
{
system,
CS,
DE,
EN,
IT,
PL,
RU,
SK,
Count
}
}
@@ -0,0 +1,28 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.EventTriggers.Iperl
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Trigger.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Trigger(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Trigger(cfg); }
public IComponentCfg DefaultConfig() { return new TriggerCfg(this.GetType().Namespace.Substring(15), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TriggerCfg.Serializer, component, this);;
}
}
}
@@ -0,0 +1,106 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.Rig.Output.EventTriggers.Iperl
{
public class Trigger : ComponentBase, IOperation, GenericDevices.IEventTrigger
{
private static readonly ILog log = LogManager.GetLogger(typeof(Trigger));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); }
readonly TriggerCfg triggerCfg;
Results.Entities.Batch batch;
public Trigger() {}
public Trigger(Generic.IComponentCfg cfg)
: base(cfg)
{
triggerCfg = cfg as TriggerCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
TriggerCfg newCfg = args.Cfg as TriggerCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
triggerCfg.EventSource = newCfg.EventSource;
triggerCfg.Culture = newCfg.Culture;
triggerCfg.EliminateSpaces = newCfg.EliminateSpaces;
triggerCfg.PrintCaption = newCfg.PrintCaption;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
Process(batch);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsProcessed</returns>
public Event Run()
{
return Event.ResultsProcessed;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void Process(Results.Entities.Batch batch)
{
return;
}
}
}
@@ -0,0 +1,165 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
using System.Collections.Generic;
namespace TBF.Rig.Output.EventTriggers.Iperl
{
/// <summary>
/// Serializable configuration of Output.EventTriggers.Standard component.
/// </summary>
public class TriggerCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TriggerCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
///
/// Serialized parameters
///
public string EventSource;
public Culture Culture;
public bool EliminateSpaces;
public bool PrintCaption;
/// Private parameterless constructor invoked by all other (public) constructors
TriggerCfg() {}
public TriggerCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
EventSource = "Výsledky iPERL";
Culture = Culture.EN;
EliminateSpaces = false;
PrintCaption = false;
}
string[] paramNames = new string[]
{
"Event source",
"Culture",
"Eliminate spaces",
"Print caption",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
switch (i)
{
case 1:
IList<string> listOfValues = new List<string>();
for (Culture cu = 0; cu < Culture.Count; cu++) listOfValues.Add(cu.ToString());
return listOfValues;
case 2:
return new string[] { Strings.yes, Strings.no };
default:
return null;
}
}
public string ToString(int i)
{
switch (i)
{
case -1: return string.Format("Name={0}, FNameFmt={1}, NoSpaces={2}", Name, EventSource, EliminateSpaces);
case 0: return EventSource;
case 1: return Culture.ToString();
case 2: return EliminateSpaces ? Strings.yes : Strings.no;
case 3: return PrintCaption ? Strings.yes : Strings.no;
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: EventSource = strValue; return CfgUpdateFlags.RestartRqrd;
case 1:
for (Culture cu = 0; cu < Culture.Count; cu++)
{
if (strValue == cu.ToString())
{
if (Culture != cu)
{
Culture = cu;
return CfgUpdateFlags.RestartRqrd;
}
else
{
return CfgUpdateFlags.None;
}
}
}
return CfgUpdateFlags.Error;
case 2: EliminateSpaces = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
case 3: PrintCaption = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
switch (i)
{
case 0: return true;
case 1:
for (Culture cu = 0; cu < Culture.Count; cu++)
{
if (strValue == cu.ToString()) return true;
}
break;
case 2:
case 3:
if (strValue == Strings.yes || strValue == Strings.no) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(TriggerCfg prms)
{
prms.EventSource = this.EventSource;
prms.Culture = this.Culture;
prms.EliminateSpaces = this.EliminateSpaces;
prms.PrintCaption = this.PrintCaption;
}
public Config.Entities.IParamsProvider Clone()
{
TriggerCfg pars = new TriggerCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
@@ -0,0 +1,28 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.EventTriggers.Standard
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Trigger.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Trigger(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Trigger(cfg); }
public IComponentCfg DefaultConfig() { return new TriggerCfg(this.GetType().Namespace.Substring(15), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TriggerCfg.Serializer, component, this);;
}
}
}
@@ -0,0 +1,280 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using log4net;
using NHibernate;
using Events.Entities;
namespace TBF.Rig.Output.EventTriggers.Standard
{
public class Trigger : ComponentBase, IOperation, GenericDevices.IEventTrigger
{
private static readonly ILog log = LogManager.GetLogger(typeof(Trigger));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); }
readonly TriggerCfg triggerCfg;
string src { get { return triggerCfg.EventSource; } }
Results.Entities.Batch batch;
public Trigger() {}
public Trigger(Generic.IComponentCfg cfg)
: base(cfg)
{
triggerCfg = cfg as TriggerCfg;
if (triggerCfg == null) throw new ArgumentException("triggerCfg");
log.Warn(this.ToString());
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
TriggerCfg newCfg = args.Cfg as TriggerCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
triggerCfg.EventSource = newCfg.EventSource;
triggerCfg.FailedWMsPct = newCfg.FailedWMsPct;
triggerCfg.Mid1Name = newCfg.Mid1Name;
triggerCfg.Mid1ErrAfterCorr = newCfg.Mid1ErrAfterCorr;
triggerCfg.Mid1Err = newCfg.Mid1Err;
triggerCfg.Mid2Name = newCfg.Mid2Name;
triggerCfg.Mid2ErrAfterCorr = newCfg.Mid2ErrAfterCorr;
triggerCfg.Mid2Err = newCfg.Mid2Err;
triggerCfg.Mid3Name = newCfg.Mid3Name;
triggerCfg.Mid3ErrAfterCorr = newCfg.Mid3ErrAfterCorr;
triggerCfg.Mid3Err = newCfg.Mid3Err;
triggerCfg.Mid4Name = newCfg.Mid4Name;
triggerCfg.Mid4ErrAfterCorr = newCfg.Mid4ErrAfterCorr;
triggerCfg.Mid4Err = newCfg.Mid4Err;
triggerCfg.Mid5Name = newCfg.Mid5Name;
triggerCfg.Mid5ErrAfterCorr = newCfg.Mid5ErrAfterCorr;
triggerCfg.Mid5Err = newCfg.Mid5Err;
triggerCfg.E1 = newCfg.E1;
triggerCfg.E2 = newCfg.E2;
triggerCfg.E3 = newCfg.E3;
triggerCfg.E4 = newCfg.E4;
triggerCfg.E5 = newCfg.E5;
triggerCfg.E6 = newCfg.E6;
triggerCfg.E7 = newCfg.E7;
triggerCfg.E8 = newCfg.E8;
triggerCfg.E9 = newCfg.E9;
triggerCfg.E10 = newCfg.E10;
triggerCfg.E11 = newCfg.E11;
triggerCfg.E12 = newCfg.E12;
triggerCfg.E13 = newCfg.E13;
triggerCfg.E14 = newCfg.E14;
triggerCfg.E15 = newCfg.E15;
triggerCfg.E16 = newCfg.E16;
triggerCfg.E21 = newCfg.E21;
triggerCfg.E36 = newCfg.E36;
#if TURA_IPERL || TURA_SPECIAL
triggerCfg.E26 = newCfg.E26;
triggerCfg.E27 = newCfg.E27;
triggerCfg.E28 = newCfg.E28;
#endif
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
Process(batch);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsProcessed</returns>
public Event Run()
{
return Event.ResultsProcessed;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void Process(Results.Entities.Batch batch)
{
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count == 0)
{
return;
}
try
{
ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
///
/// Event on high percentage of failed meters
///
if (triggerCfg.FailedWMsPct > 0)
{
/// Triggering this event is enabled
int failedWMs = batch.FailedMetersCount();
int passedWMs = batch.PassedMetersCount();
if (100 * failedWMs >= triggerCfg.FailedWMsPct * (failedWMs + passedWMs))
{
TBF.UiBridge.Bridge.TriggerEvent(session, src, EventClass.BadResults, Severity.Warning,
"Príliš veľa chybných kusov v jednej dávke",
string.Format("Číslo dávky: {0}\r\nspolu {1} kusov, dobrých {2} ks., chybných {3} ks.",
batch.BatchNr, passedWMs + failedWMs, passedWMs, failedWMs),
SubscriberGroup.Production);
}
}
///
/// Event MIDx relative error measured against a scale is too large
///
string[] midName = new string[] { triggerCfg.Mid1Name,
triggerCfg.Mid2Name,
triggerCfg.Mid3Name,
triggerCfg.Mid4Name,
triggerCfg.Mid5Name };
double[] maxMidErr = new double[] { triggerCfg.Mid1Err,
triggerCfg.Mid2Err,
triggerCfg.Mid3Err,
triggerCfg.Mid4Err,
triggerCfg.Mid5Err };
double[] maxMidErrAfterCorr = new double[] { triggerCfg.Mid1ErrAfterCorr,
triggerCfg.Mid2ErrAfterCorr,
triggerCfg.Mid3ErrAfterCorr,
triggerCfg.Mid4ErrAfterCorr,
triggerCfg.Mid5ErrAfterCorr };
for (int i = 0; i < midName.Length; i++)
{
if (!string.IsNullOrEmpty(midName[i]))
{
/// This MID# enabled
foreach (var tr in batch.TestRslts)
{
if (tr.RefFlowmeter() == midName[i])
{
/// This test result was obtained using MID#
double midErrAfterCorr = Config.Formulas.ErrorFromVolumes(tr.ConstMasterCorr, tr.ConstMaster);
if (midErrAfterCorr >= maxMidErrAfterCorr[i])
{
TBF.UiBridge.Bridge.TriggerEvent(session, src, EventClass.EquipmentHW, Severity.Error,
string.Format("Príliš veľká chyba merača prietoku {0} po KOREKCII oproti váhe", midName[i]),
string.Format("Číslo dávky: {0}\r\nPrietokomer: {1}\r\nRelatívna chyba po korekcii: {2}%\r\nMax. dovolená chyba: {3}%",
batch.BatchNr, midName[i], Utils.DoubleToStr(midErrAfterCorr, 3), maxMidErrAfterCorr[i]),
SubscriberGroup.Metrology | SubscriberGroup.Maintenance | SubscriberGroup.Production);
}
if (tr.ErrorMaster >= maxMidErr[i])
{
TBF.UiBridge.Bridge.TriggerEvent(session, src, EventClass.EquipmentHW, Severity.Error,
string.Format("Príliš veľká chyba merača prietoku {0} oproti váhe", midName[i]),
string.Format("Číslo dávky: {0}\r\nPrietokomer: {1}\r\nRelatívna chyba: {2}%\r\nMax. dovolená chyba: {3}%",
batch.BatchNr, midName[i], Utils.DoubleToStr(tr.ErrorMaster, 3), maxMidErr[i]),
SubscriberGroup.Metrology | SubscriberGroup.Maintenance | SubscriberGroup.Production);
}
}
}
}
}
///
/// Events on Ex flags
///
long eFlags = batch.ErrorFlags();
long iFlags = batch.InfoFlags();
///
if (triggerCfg.E1) OnExTriggerEvent(session, eFlags, iFlags, 1);
if (triggerCfg.E2) OnExTriggerEvent(session, eFlags, iFlags, 2);
if (triggerCfg.E3) OnExTriggerEvent(session, eFlags, iFlags, 3);
if (triggerCfg.E4) OnExTriggerEvent(session, eFlags, iFlags, 4);
if (triggerCfg.E5) OnExTriggerEvent(session, eFlags, iFlags, 5);
if (triggerCfg.E6) OnExTriggerEvent(session, eFlags, iFlags, 6);
if (triggerCfg.E7) OnExTriggerEvent(session, eFlags, iFlags, 7);
if (triggerCfg.E8) OnExTriggerEvent(session, eFlags, iFlags, 8);
if (triggerCfg.E9) OnExTriggerEvent(session, eFlags, iFlags, 9);
if (triggerCfg.E10) OnExTriggerEvent(session, eFlags, iFlags, 10);
if (triggerCfg.E11) OnExTriggerEvent(session, eFlags, iFlags, 11);
if (triggerCfg.E12) OnExTriggerEvent(session, eFlags, iFlags, 12);
if (triggerCfg.E13) OnExTriggerEvent(session, eFlags, iFlags, 13);
if (triggerCfg.E14) OnExTriggerEvent(session, eFlags, iFlags, 14);
if (triggerCfg.E15) OnExTriggerEvent(session, eFlags, iFlags, 15);
if (triggerCfg.E16) OnExTriggerEvent(session, eFlags, iFlags, 16);
if (triggerCfg.E21) OnExTriggerEvent(session, eFlags, iFlags, 21);
if (triggerCfg.E36) OnExTriggerEvent(session, eFlags, iFlags, 36);
#if TURA_IPERL || TURA_SPECIAL
if (triggerCfg.E26) OnExTriggerEvent(session, eFlags, iFlags, 26);
if (triggerCfg.E27) OnExTriggerEvent(session, eFlags, iFlags, 27);
if (triggerCfg.E28) OnExTriggerEvent(session, eFlags, iFlags, 28);
#endif
}
catch (Exception exc)
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
}
void OnExTriggerEvent(ISession session, long eFlags, long iFlags, int x)
{
long mask = 1L << (x - 1);
Severity severity;
if ((eFlags & mask) != 0)
{
severity = Severity.Error;
}
else if ((iFlags & mask) != 0)
{
severity = Severity.Warning;
}
else
{
return;
}
string moreInfo = string.Format("E{0}", x);
TBF.UiBridge.Bridge.TriggerEvent(session, src, EventClass.TestingProcess, severity,
string.Format("Príznak chyby procesu E{0} je aktívny", x),
string.Format("Číslo dávky: {0}\r\n{1}", batch.BatchNr, moreInfo),
SubscriberGroup.Production);
}
}
}
@@ -0,0 +1,411 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
using System.Collections.Generic;
namespace TBF.Rig.Output.EventTriggers.Standard
{
/// <summary>
/// Serializable configuration of Output.EventTriggers.Standard component.
/// </summary>
public class TriggerCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TriggerCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
///
/// Serialized parameters
///
public string EventSource;
public int FailedWMsPct; /// 0 = off, 1..100% event is triggered when percentage reaches this level
public string Mid1Name;
public double Mid1ErrAfterCorr; /// [%] Event triggered when rel. error of MID1 against a scale after a correction reached this level
public double Mid1Err; /// [%] Event triggered when rel. error of MID1 against a scale reached this level
public string Mid2Name;
public double Mid2ErrAfterCorr; /// [%] Event triggered when rel. error of MID2 against a scale after a correction reached this level
public double Mid2Err; /// [%] Event triggered when rel. error of MID2 against a scale reached this level
public string Mid3Name;
public double Mid3ErrAfterCorr; /// [%] Event triggered when rel. error of MID3 against a scale after a correction reached this level
public double Mid3Err; /// [%] Event triggered when rel. error of MID3 against a scale reached this level
public string Mid4Name;
public double Mid4ErrAfterCorr; /// [%] Event triggered when rel. error of MID4 against a scale after a correction reached this level
public double Mid4Err; /// [%] Event triggered when rel. error of MID4 against a scale reached this level
public string Mid5Name;
public double Mid5ErrAfterCorr; /// [%] Event triggered when rel. error of MID5 against a scale after a correction reached this level
public double Mid5Err; /// [%] Event triggered when rel. error of MID5 against a scale reached this level
public bool E1;
public bool E2;
public bool E3;
public bool E4;
public bool E5;
public bool E6;
public bool E7;
public bool E8;
public bool E9;
public bool E10;
public bool E11;
public bool E12;
public bool E13;
public bool E14;
public bool E15;
public bool E16;
public bool E21;
#if TURA_IPERL || TURA_SPECIAL
public bool E26;
public bool E27;
public bool E28;
#endif
public bool E36;
/// Private parameterless constructor invoked by all other (public) constructors
TriggerCfg() {}
public TriggerCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
EventSource = "Výsledky"; /// 0
FailedWMsPct = 20; /// 1
Mid1Name = "I1"; /// 2
Mid1ErrAfterCorr = 0.3; /// 3
Mid1Err = 0.6; /// 4
Mid2Name = "I2"; /// 5
Mid2ErrAfterCorr = 0.3; /// 6
Mid2Err = 0.6; /// 7
Mid3Name = "I3"; /// 8
Mid3ErrAfterCorr = 0.3; /// 9
Mid3Err = 0.6; /// 10
Mid4Name = ""; /// 11
Mid4ErrAfterCorr = 0.3; /// 12
Mid4Err = 0.6; /// 13
Mid5Name = ""; /// 14
Mid5ErrAfterCorr = 0.3; /// 15
Mid5Err = 0.6; /// 16
E1 = false; /// 17
E2 = false; /// 18
E3 = false; /// 19
E4 = false; /// 20
E5 = false; /// 21
E6 = false; /// 22
E7 = false; /// 23
E8 = false; /// 24
E9 = false; /// 25
E10 = false; /// 26
E11 = false; /// 27
E12 = false; /// 28
E13 = false; /// 29
E14 = false; /// 30
E15 = false; /// 31
E16 = false; /// 32
E21 = false; /// 33
#if TURA_IPERL || TURA_SPECIAL
E26 = false; /// 34
E27 = false; /// 35
E28 = false; /// 36
#endif
E36 = true; /// 34 or 37
}
string[] paramNames = new string[]
{
"Event source", /// 0
"Percentage of failed meters", /// 1
"MID 1 name", /// 2
"MID 1 rel.err.after corr.", /// 3
"MID 1 rel.error", /// 4
"MID 2 name", /// 5
"MID 2 rel.err.after corr.", /// 6
"MID 2 rel.error", /// 7
"MID 3 name", /// 8
"MID 3 rel.err.after corr.", /// 9
"MID 3 rel.error", /// 10
"MID 4 name", /// 11
"MID 4 rel.err.after corr.", /// 12
"MID 4 rel.error", /// 13
"MID 5 name", /// 14
"MID 5 rel.err.after corr.", /// 15
"MID 5 rel.error", /// 16
"E1", /// 17
"E2", /// 18
"E3", /// 19
"E4", /// 20
"E5", /// 21
"E6", /// 22
"E7", /// 23
"E8", /// 24
"E9", /// 25
"E10", /// 26
"E11", /// 27
"E12", /// 28
"E13", /// 29
"E14", /// 30
"E15", /// 31
"E16", /// 32
"E21", /// 33
#if TURA_IPERL || TURA_SPECIAL
"E26", /// 34
"E27", /// 35
"E28", /// 36
#endif
"E36", /// 34 or 37
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
if (i >= 17)
{
return new string[] { Strings.yes, Strings.no };
}
return null;
}
public string ToString(int i)
{
switch (i)
{
case 0: return EventSource;
case 1: return FailedWMsPct.ToString();
case 2: return Mid1Name;
case 3: return Mid1ErrAfterCorr.ToString();
case 4: return Mid1Err.ToString();
case 5: return Mid2Name;
case 6: return Mid2ErrAfterCorr.ToString();
case 7: return Mid2Err.ToString();
case 8: return Mid3Name;
case 9: return Mid3ErrAfterCorr.ToString();
case 10: return Mid3Err.ToString();
case 11: return Mid4Name;
case 12: return Mid4ErrAfterCorr.ToString();
case 13: return Mid4Err.ToString();
case 14: return Mid5Name;
case 15: return Mid5ErrAfterCorr.ToString();
case 16: return Mid5Err.ToString();
case 17: return E1 ? Strings.yes : Strings.no;
case 18: return E2 ? Strings.yes : Strings.no;
case 19: return E3 ? Strings.yes : Strings.no;
case 20: return E4 ? Strings.yes : Strings.no;
case 21: return E5 ? Strings.yes : Strings.no;
case 22: return E6 ? Strings.yes : Strings.no;
case 23: return E7 ? Strings.yes : Strings.no;
case 24: return E8 ? Strings.yes : Strings.no;
case 25: return E9 ? Strings.yes : Strings.no;
case 26: return E10 ? Strings.yes : Strings.no;
case 27: return E11 ? Strings.yes : Strings.no;
case 28: return E12 ? Strings.yes : Strings.no;
case 29: return E13 ? Strings.yes : Strings.no;
case 30: return E14 ? Strings.yes : Strings.no;
case 31: return E15 ? Strings.yes : Strings.no;
case 32: return E16 ? Strings.yes : Strings.no;
case 33: return E21 ? Strings.yes : Strings.no;
#if TURA_IPERL || TURA_SPECIAL
case 34: return E26 ? Strings.yes : Strings.no;
case 35: return E27 ? Strings.yes : Strings.no;
case 36: return E28 ? Strings.yes : Strings.no;
case 37: return E36 ? Strings.yes : Strings.no;
#else
case 34: return E36 ? Strings.yes : Strings.no;
#endif
default:
return string.Format("Name={0}, EventSource={1}, FailedWMsPct={2}, ...", Name, EventSource, FailedWMsPct);
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: EventSource = strValue; return CfgUpdateFlags.AnyChange;
case 1: FailedWMsPct = int.Parse(strValue); return CfgUpdateFlags.AnyChange;
case 2: Mid1Name = strValue; return CfgUpdateFlags.AnyChange;
case 3: Mid1ErrAfterCorr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 4: Mid1Err = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 5: Mid2Name = strValue; return CfgUpdateFlags.AnyChange;
case 6: Mid2ErrAfterCorr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 7: Mid2Err = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 8: Mid3Name = strValue; return CfgUpdateFlags.AnyChange;
case 9: Mid3ErrAfterCorr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 10: Mid3Err = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 11: Mid4Name = strValue; return CfgUpdateFlags.AnyChange;
case 12: Mid4ErrAfterCorr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 13: Mid4Err = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 14: Mid5Name = strValue; return CfgUpdateFlags.AnyChange;
case 15: Mid5ErrAfterCorr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 16: Mid5Err = Utils.ParseUDouble(strValue); return CfgUpdateFlags.AnyChange;
case 17: E1 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 18: E2 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 19: E3 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 20: E4 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 21: E5 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 22: E6 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 23: E7 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 24: E8 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 25: E9 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 26: E10 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 27: E11 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 28: E12 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 29: E13 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 30: E14 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 31: E15 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 32: E16 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 33: E21 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
#if TURA_IPERL || TURA_SPECIAL
case 34: E26 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 35: E27 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 36: E28 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
case 37: E36 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
#else
case 34: E36 = (strValue == Strings.yes); return CfgUpdateFlags.AnyChange;
#endif
default: return CfgUpdateFlags.None;
}
}
/// <summary>
/// Validate string form of a parameter value
/// </summary>
/// <param name="i">Parameter index</param>
/// <param name="strValue">String form of a parameter</param>
/// <param name="message">Message in case value is not valid</param>
/// <returns>true when string form of a parameter is OK</returns>
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int percentage;
double relError;
switch (i)
{
case 0:
case 2:
case 5:
case 8:
case 11:
case 14:
return true;
case 1:
if (int.TryParse(strValue, out percentage) && (0 <= percentage) && (percentage <= 100)) return true;
message = "Percentage of failed meters is invalid, should be 1..100, 0 = off";
return false;
case 3:
case 4:
case 6:
case 7:
case 9:
case 10:
case 12:
case 13:
case 15:
case 16:
if (Utils.TryParseUDouble(strValue, out relError)) return true;
message = "relative error of MID is invalid or less then 0";
return false;
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
#if TURA_IPERL || TURA_SPECIAL
case 35:
case 36:
case 37:
#endif
if (strValue == Strings.yes || strValue == Strings.no) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(TriggerCfg prms)
{
prms.EventSource = this.EventSource; /// 0
prms.FailedWMsPct = this.FailedWMsPct; /// 1
prms.Mid1Name = this.Mid1Name; /// 2
prms.Mid1ErrAfterCorr = this.Mid1ErrAfterCorr; /// 3
prms.Mid1Err = this.Mid1Err; /// 4
prms.Mid2Name = this.Mid2Name; /// 5
prms.Mid2ErrAfterCorr = this.Mid2ErrAfterCorr; /// 6
prms.Mid2Err = this.Mid2Err; /// 7
prms.Mid3Name = this.Mid3Name; /// 8
prms.Mid3ErrAfterCorr = this.Mid3ErrAfterCorr; /// 9
prms.Mid3Err = this.Mid3Err; /// 10
prms.Mid4Name = this.Mid4Name; /// 11
prms.Mid4ErrAfterCorr = this.Mid4ErrAfterCorr; /// 12
prms.Mid4Err = this.Mid4Err; /// 13
prms.Mid5Name = this.Mid5Name; /// 14
prms.Mid5ErrAfterCorr = this.Mid5ErrAfterCorr; /// 15
prms.Mid5Err = this.Mid5Err; /// 16
prms.E1 = this.E1; /// 17
prms.E2 = this.E2; /// 18
prms.E3 = this.E3; /// 19
prms.E4 = this.E4; /// 20
prms.E5 = this.E5; /// 21
prms.E6 = this.E6; /// 22
prms.E7 = this.E7; /// 23
prms.E8 = this.E8; /// 24
prms.E9 = this.E9; /// 25
prms.E10 = this.E10; /// 26
prms.E11 = this.E11; /// 27
prms.E12 = this.E12; /// 28
prms.E13 = this.E13; /// 29
prms.E14 = this.E14; /// 30
prms.E15 = this.E15; /// 31
prms.E16 = this.E16; /// 32
prms.E21 = this.E21; /// 33
#if TURA_IPERL || TURA_SPECIAL
prms.E26 = this.E26; /// 34
prms.E27 = this.E27; /// 35
prms.E28 = this.E28; /// 36
#endif
prms.E36 = this.E36; /// 34 or 37
}
public Config.Entities.IParamsProvider Clone()
{
TriggerCfg pars = new TriggerCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Basic
{
public class FactoryCompound : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Compound"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Basic.Compound", this, Config.Entities.MetersKind.Combined); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Combined;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Basic
{
public class FactoryHeatMeters : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".HeatMeters"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Basic.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.HeatMeter;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Basic
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Basic.Single", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
+433
View File
@@ -0,0 +1,433 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
namespace TBF.Rig.Output.FileWriters.Basic
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Basic({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
string separatorStr;
/// <summary>
/// Result items to print
/// </summary>
string header;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> rsltItems;
string footer;
Results.Entities.Batch batch;
bool abort;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
switch (writerCfg.Separator)
{
default:
case Separator.None: separatorStr = string.Empty; break;
case Separator.Space: separatorStr = " "; break;
case Separator.Tabulator: separatorStr = "\t"; break;
case Separator.Comma: separatorStr = ","; break;
case Separator.Semicolon: separatorStr = ";"; break;
}
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
rsltItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.SelectedItems);
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.Separator = newCfg.Separator;
writerCfg.SaveGoodOnly = newCfg.SaveGoodOnly;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.PrintCaption = newCfg.PrintCaption;
writerCfg.Header = newCfg.Header;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.Footer = newCfg.Footer;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Eliminate spaces conditionally, depesing on bool WriterCfg.EliminateSpaces
/// </summary>
/// <param name="item">Input string</param>
/// <returns>Output string</returns>
string ElSpaces(string item)
{
if (writerCfg.EliminateSpaces)
return item.Replace(" ", string.Empty);
else
return item;
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}.txt", directory, time);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
abort = false;
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (string.IsNullOrEmpty(destination) || batch == null ||
batch.WaterMeters == null ||
batch.WaterMeters.Count == 0)
{
return;
}
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr)
{
///----------
/// Header
///----------
if (!string.IsNullOrEmpty(writerCfg.Header))
{
wrtr.Write(header);
}
///----------------
/// Common items
///----------------
string[] leftColumn = new string[commonItems.Count];
string[] rightColumn = new string[commonItems.Count];
int cnt = 0;
foreach (var v in commonItems)
{
leftColumn[cnt] = v.Caption;
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty;
cnt++;
}
/// Determine max. left column width in characters
int maxLen = 0;
foreach (var s in leftColumn) if (s.Length > maxLen) maxLen = s.Length;
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
if (abort) return;
wrtr.Write(leftColumn[i]);
if (!writerCfg.EliminateSpaces)
{
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
}
wrtr.Write(separatorStr);
wrtr.WriteLine(rightColumn[i]);
}
if (commonItems.Count > 0) wrtr.WriteLine(); /// Write an empty line in case there is at least one common item
///--------
/// Body
///--------
WriteWMs(batch, wrtr);
///----------
/// Footer
///----------
if (!string.IsNullOrEmpty(writerCfg.Footer))
{
wrtr.Write(footer);
}
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWMs(Results.Entities.Batch batch, StreamWriter wr)
{
/// Determine column widths
int[] columnWidths = new int[rsltItems.Count];
int totalWidth = 0;
for (int i = 0; i < rsltItems.Count; i++)
{
if (abort) return;
columnWidths[i] = writerCfg.PrintCaption ? ElSpaces(rsltItems[i].Caption).Length : 0;
foreach (var wm in batch.WaterMeters)
{
if (!writerCfg.SaveGoodOnly || wm.Passed)
{
string itemText = rsltItems[i].Print(wm);
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
int len = ElSpaces(itemText).Length;
if (len > columnWidths[i]) columnWidths[i] = len;
}
}
totalWidth += columnWidths[i];
}
totalWidth += 3 * (rsltItems.Count - 1);
if (totalWidth < 0) totalWidth = 0;
string horizontalLine = new String('-', totalWidth);
if (writerCfg.PrintCaption)
{
//wr.WriteLine(horizontalLine); /// Horizontal line above the header
/// Write column headers
for (int i = 0; i < rsltItems.Count; i++)
{
if (abort) return;
string caption = ElSpaces(rsltItems[i].Caption);
wr.Write(caption);
if (i < rsltItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - rsltItems[i].Caption.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
}
//wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
int rowsCount = 0;
foreach (var wm in batch.WaterMeters)
{
if (!writerCfg.SaveGoodOnly || wm.Passed)
{
if (abort) return;
Results.WMeterRsltItemSpec.TableRowNr = ++rowsCount;
for (int i = 0; i < rsltItems.Count; i++)
{
Results.WMeterRsltItemSpec.TableColumnNr = i + 1;
/// Fetch the item
string itemText = rsltItems[i].Print(wm);
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
string itemText2 = ElSpaces(itemText);
wr.Write(itemText2);
if (i < rsltItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
}
}
//wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
}
}
}
@@ -0,0 +1,79 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Basic
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public Separator Separator;
public bool EliminateSpaces;
public bool PrintCaption;
public bool SaveGoodOnly;
public string Header;
public string[] CommonItems;
public string[] SelectedItems;
public string Footer;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}.csv";
Separator = Separator.None;
EliminateSpaces = false;
PrintCaption = false;
SaveGoodOnly = false;
Header = string.Empty;
Footer = string.Empty;
}
public string ToString(int i)
{
return string.Format("{0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, NoSpaces={7}, GoodOnly={8}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Separator,
EliminateSpaces,
SaveGoodOnly);
}
}
}
@@ -0,0 +1,358 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Basic
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
public bool Compound;
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] selectedItems;
string footer;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
selectedItems = config.SelectedItems;
footer = config.Footer;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
separatorLabel.Text = "Separator";
goodOnlyCheckBox.Text = "Good only";
eliminateSpacesCheckBox.Text = "No spaces";
printCaptionCheckBox.Text = "Print caption";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
selectItemsButton.Text = "Selected items";
footerButton.Text = Strings.Footer;
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
printCaptionCheckBox.Checked = config.PrintCaption;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
printCaptionCheckBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
selectItemsButton.Enabled = true;
footerButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
{
config.Separator = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
{
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.EliminateSpaces != eliminateSpacesCheckBox.Checked)
{
config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.PrintCaption != printCaptionCheckBox.Checked)
{
config.PrintCaption = printCaptionCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SelectedItems != selectedItems)
{
config.SelectedItems = selectedItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Footer != footer)
{
config.Footer = footer;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void selectItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(selectedItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
selectedItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
+397
View File
@@ -0,0 +1,397 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters.Basic
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.selectItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.commonItemsButton = new System.Windows.Forms.Button();
this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.printCaptionCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 52);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 55);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(259, 56);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 26;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 206);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 17;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 203);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 18;
//
// selectItemsButton
//
this.selectItemsButton.Enabled = false;
this.selectItemsButton.Location = new System.Drawing.Point(108, 277);
this.selectItemsButton.Name = "selectItemsButton";
this.selectItemsButton.Size = new System.Drawing.Size(146, 23);
this.selectItemsButton.TabIndex = 24;
this.selectItemsButton.Text = "Selected items";
this.selectItemsButton.UseVisualStyleBackColor = true;
this.selectItemsButton.Click += new System.EventHandler(this.selectItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 97);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 7;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 119);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 9;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 141);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 11;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 94);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 8;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 116);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 10;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 138);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 12;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(259, 79);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 27;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 73);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 6;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 76);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 5;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 160);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 14;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 163);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 13;
this.fileNameFmtLabel.Text = "File name format";
//
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 235);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 19;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 181);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 16;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 184);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 15;
this.cultureLabel.Text = "Cullture";
//
// eliminateSpacesCheckBox
//
this.eliminateSpacesCheckBox.AutoSize = true;
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(20, 256);
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.eliminateSpacesCheckBox.TabIndex = 20;
this.eliminateSpacesCheckBox.Text = "No spaces";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 252);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 23;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 227);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 22;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 302);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 25;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
//
// printCaptionCheckBox
//
this.printCaptionCheckBox.AutoSize = true;
this.printCaptionCheckBox.Location = new System.Drawing.Point(20, 277);
this.printCaptionCheckBox.Name = "printCaptionCheckBox";
this.printCaptionCheckBox.Size = new System.Drawing.Size(85, 17);
this.printCaptionCheckBox.TabIndex = 21;
this.printCaptionCheckBox.Text = "Print caption";
this.printCaptionCheckBox.UseVisualStyleBackColor = true;
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.printCaptionCheckBox);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.selectItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label separatorLabel;
private System.Windows.Forms.ComboBox separatorComboBox;
private System.Windows.Forms.Button selectItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.CheckBox eliminateSpacesCheckBox;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.CheckBox printCaptionCheckBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Elde
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Elde", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
+470
View File
@@ -0,0 +1,470 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Elde
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Enhanced({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
string separatorStr;
/// Items to print
string header;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
Results.Entities.Batch batch;
bool abort;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
switch (writerCfg.Separator)
{
default:
case Separator.None: separatorStr = string.Empty; break;
case Separator.Space: separatorStr = " "; break;
case Separator.Tabulator: separatorStr = "\t"; break;
case Separator.Comma: separatorStr = ","; break;
case Separator.Semicolon: separatorStr = ";"; break;
}
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(new string[] {
"72~Date / Time~~None~: {0:yyyy/MM/dd} / {0:HH:mm} Page : 1/1~~0~Left",
"50~Watermeter Type~~None~: {0}~~0~Left",
"64~Device No~~None~: {0}~~0~Left",
"66~Personal~~None~: {0}~~0~Left",
} );
testItems = Results.WMeterRsltItemSpec.FromStrArray(new string[] {
"1~Test~~None~~~0~Left",
"258~Met. t.~~None~~~0~Left",
"257~Fl.~~None~~~0~Left",
"25~Dev. [%]~~Pct~~~0~Left",
"202~Flow [m3/h]~~m3ph~~F6~0~Left",
"14~Test time [s]~~s~~F1~0~Left",
"16~T1 [°C]~~C~~F1~0~Left",
"17~T2 [°C]~~C~~F1~0~Left",
"5~Density [kg/m3]~~kgpm3~~F3~0~Left",
"131~Mass [kg]~~kg~~F3~0~Left",
"19~Pressure [MPa]~~MPa~~F2~0~Left",
"229~Volume [L]~~l~~F4~0~Left",
} );
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.Separator = newCfg.Separator;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.Header = newCfg.Header;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.Footer = newCfg.Footer;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Eliminate spaces conditionally, depesing on bool WriterCfg.EliminateSpaces
/// </summary>
/// <param name="item">Input string</param>
/// <returns>Output string</returns>
string ElSpaces(string item)
{
if (writerCfg.EliminateSpaces)
return item.Replace(" ", string.Empty);
else
return item;
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}.txt", directory, time);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
abort = false;
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0) return;
if (!string.IsNullOrEmpty(destination))
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
}
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr)
{
string toPrint;
///
/// Get a sample water meter (to save common and test items)
///
Results.Entities.WaterMeter sampleWM = null;
foreach (var wm in batch.WaterMeters)
{
if (wm != null)
{
sampleWM = wm;
break;
}
}
if (sampleWM == null) return; /// No water meters
///----------
/// Header
///----------
if (!string.IsNullOrEmpty(writerCfg.Header)) wrtr.Write(header);
wrtr.WriteLine();
///----------------
/// Common items
///----------------
string[] leftColumn = new string[commonItems.Count];
string[] rightColumn = new string[commonItems.Count];
int cnt = 0;
foreach (var item in commonItems)
{
leftColumn[cnt] = item.Caption;
rightColumn[cnt] = item.Print(sampleWM);
cnt++;
}
/// Determine max. left column width in characters
int maxLen = 0;
foreach (var s in leftColumn) if (s.Length > maxLen) maxLen = s.Length;
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
if (abort) return;
wrtr.Write(leftColumn[i]);
if (!writerCfg.EliminateSpaces)
{
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
}
wrtr.Write(separatorStr);
wrtr.WriteLine(rightColumn[i]);
}
///---------
/// Tests
///---------
wrtr.WriteLine();
wrtr.WriteLine("Test Met. Fl. Dev. Flow Test time T1 T2 Density Mass Pressure Volume");
wrtr.WriteLine(" t. [%] [m3/h] [s] [°C] [°C] [kg/m3] [kg] [MPa] [L]");
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------");
int emptyTestsLeft = 5;
int[] widths = new int[] { 11, 5, 6, 9, 12, 12, 8, 11, 10, 15, 8, 1 }; /// Widths of columns
foreach (var testRslt in batch.RegularTestRslts())
{
if (testRslt.Publish() == Config.Entities.Publish.Always)
{
for (int i = 0; i < Math.Min(testItems.Count, widths.Length); i++)
{
wrtr.Write(toPrint = testItems[i].Print(sampleWM, testRslt.Name()));
for (int j = 0; j < Math.Max(1, widths[i] - toPrint.Length); j++) wrtr.Write(' ');
}
wrtr.WriteLine();
wrtr.WriteLine();
if (emptyTestsLeft > 0) emptyTestsLeft--;
}
}
///----------------
/// Water meters
///----------------
wrtr.WriteLine();
wrtr.WriteLine();
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.WriteLine("No | Prod. No | Initial Volume [L] | End Volume [L] | Deviation [%] |Sen| Result.");
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.Write(" ");
for (int i = 0; i < 3; i++)
{
foreach (var testRslt in batch.RegularTestRslts())
{
if (testRslt.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = testRslt.Name());
for (int j = 0; j < Math.Max(1, (i<2 ? 8 : 7) - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write("- ");
}
wrtr.WriteLine();
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
foreach (var wm in batch.WaterMeters)
{
if (wm != null)
{
wrtr.Write(' ');
wrtr.Write(toPrint = wm.WMPosition.ToString());
for (int j = 0; j < Math.Max(1, 3 - toPrint.Length); j++) wrtr.Write(' ');
wrtr.Write(toPrint = wm.SerialNr);
for (int j = 0; j < Math.Max(1, 14 - toPrint.Length); j++) wrtr.Write(' ');
/// Volume start
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.VolumeStart.ToString("F2"));
for (int j = 0; j < Math.Max(1, 8 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
/// Volume end
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.VolumeEnd.ToString("F2"));
for (int j = 0; j < Math.Max(1, 8 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
/// Error
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (mtr.Publish() == Config.Entities.Publish.Always)
{
wrtr.Write(toPrint = mtr.Error.ToString("F2"));
for (int j = 0; j < Math.Max(1, 7 - toPrint.Length); j++) wrtr.Write(' ');
}
}
for (int k = 0; k < emptyTestsLeft; k++) wrtr.Write(" ");
wrtr.Write(" ");
wrtr.Write(wm.Passed ? "OK" : "Not suitable");
wrtr.WriteLine();
}
}
wrtr.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------");
wrtr.WriteLine();
wrtr.Write("Producer: ");
wrtr.Write(toPrint = sampleWM.WaterMeterData.Producer);
for (int j = 0; j < Math.Max(1, 30 - toPrint.Length); j++) wrtr.Write(' ');
wrtr.WriteLine("Explanation :");
wrtr.WriteLine(" M - Mass Method");
wrtr.WriteLine(" V - Volumetric Method");
wrtr.WriteLine(" P - Start / Stop");
wrtr.WriteLine(" F - Flow start");
wrtr.WriteLine(" S - Synchro");
wrtr.WriteLine(" C - Count imp.");
wrtr.WriteLine();
wrtr.WriteLine("-------------------------------------------------------------------------");
///----------
/// Footer
///----------
if (!string.IsNullOrEmpty(writerCfg.Footer)) wrtr.Write(footer);
wrtr.Write('\f'); /// Form feed
}
}
}
@@ -0,0 +1,77 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Elde
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public Separator Separator;
public bool EliminateSpaces;
public bool SaveGoodOnly;
public string Header;
public string[] CommonItems;
public string[] SelectedItems;
public string Footer;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}.txt";
Separator = Separator.None;
EliminateSpaces = false;
SaveGoodOnly = false;
Header = string.Empty;
Footer = string.Empty;
}
public string ToString(int i)
{
return string.Format("{0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, NoSpaces={7}, GoodOnly={8}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Separator,
EliminateSpaces,
SaveGoodOnly);
}
}
}
@@ -0,0 +1,373 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Elde
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] testItems;
string footer;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
testItems = config.SelectedItems;
footer = config.Footer;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces";
goodOnlyCheckBox.Text = "Good only";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items";
footerButton.Text = Strings.Footer;
upgradeWizardButton.Text = "Upgrade wizard";
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
testItemsButton.Enabled = true;
footerButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
{
config.Separator = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.EliminateSpaces != eliminateSpacesCheckBox.Checked)
{
config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
{
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SelectedItems != testItems)
{
config.SelectedItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Footer != footer)
{
config.Footer = footer;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void upgradeWizardButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This wizzard will overwrite curent settings." + Environment.NewLine +
"Do you want to continue?",
"Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
///
/// Use legacy common items (English)
///
commonItems = new string[] {
"3~Batch number:~~None~~~0~",
"72~Date and time:~~None~{0:yyyy.MM.dd HH:mm}~~0~",
"2~Procedure:~~None~~~0~",
"66~User:~~None~~~0~",
"26~Ambient temperature:~~C~{0} °C~F1~0~",
"27~Ambient pressure:~~mbar~{0} mbar~F0~0~",
"28~Ambient humidity:~~Pct~{0} %~F0~0~",
};
commonItemsButton_Click(this, null);
testItemsButton_Click(this, null);
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
+397
View File
@@ -0,0 +1,397 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.FileWriters.Elde
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.upgradeWizardButton = new System.Windows.Forms.Button();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 6);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 49);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 52);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 49);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 203);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 19;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 200);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 20;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 275);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 25;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 116);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 138);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 113);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 135);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 70);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 70);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 73);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 157);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 160);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format";
//
// eliminateSpacesCheckBox
//
this.eliminateSpacesCheckBox.AutoSize = true;
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(20, 241);
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.eliminateSpacesCheckBox.TabIndex = 21;
this.eliminateSpacesCheckBox.Text = "No spaces";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 225);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 23;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 300);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 26;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 250);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 24;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// upgradeWizardButton
//
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 250);
this.upgradeWizardButton.Name = "upgradeWizardButton";
this.upgradeWizardButton.Size = new System.Drawing.Size(80, 48);
this.upgradeWizardButton.TabIndex = 27;
this.upgradeWizardButton.Text = "Upgrade wizard";
this.upgradeWizardButton.UseVisualStyleBackColor = true;
this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click);
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 178);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 181);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 264);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 22;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.upgradeWizardButton);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label separatorLabel;
private System.Windows.Forms.ComboBox separatorComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox eliminateSpacesCheckBox;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button upgradeWizardButton;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public class FactoryCompound : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Compound"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.Compound", this, Config.Entities.MetersKind.Combined); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Combined;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public class FactoryHeatMeters : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".HeatMeters"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.HeatMeter;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Enhanced.Single", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
@@ -0,0 +1,452 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Enhanced({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
string separatorStr;
/// Items to print
string header;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
Results.Entities.Batch batch;
bool abort;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
switch (writerCfg.Separator)
{
default:
case Separator.None: separatorStr = string.Empty; break;
case Separator.Space: separatorStr = " "; break;
case Separator.Tabulator: separatorStr = "\t"; break;
case Separator.Comma: separatorStr = ","; break;
case Separator.Semicolon: separatorStr = ";"; break;
}
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.SelectedItems); /// TestID info will be overwritten later on
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.SubtitleFormat = newCfg.SubtitleFormat;
writerCfg.Separator = newCfg.Separator;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.Header = newCfg.Header;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.Footer = newCfg.Footer;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Eliminate spaces conditionally, depesing on bool WriterCfg.EliminateSpaces
/// </summary>
/// <param name="item">Input string</param>
/// <returns>Output string</returns>
string ElSpaces(string item)
{
if (writerCfg.EliminateSpaces)
return item.Replace(" ", string.Empty);
else
return item;
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}.txt", directory, time);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
abort = false;
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0) return;
if (!string.IsNullOrEmpty(destination))
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
}
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr)
{
///----------
/// Header
///----------
if (!string.IsNullOrEmpty(writerCfg.Header)) wrtr.Write(header);
wrtr.WriteLine();
///----------------
/// Common items
///----------------
string[] leftColumn = new string[commonItems.Count];
string[] rightColumn = new string[commonItems.Count];
int cnt = 0;
foreach (var v in commonItems)
{
leftColumn[cnt] = v.Caption;
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty;
cnt++;
}
/// Determine max. left column width in characters
int maxLen = 0;
foreach (var s in leftColumn) if (s.Length > maxLen) maxLen = s.Length;
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
if (abort) return;
wrtr.Write(leftColumn[i]);
if (!writerCfg.EliminateSpaces)
{
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
}
wrtr.Write(separatorStr);
wrtr.WriteLine(rightColumn[i]);
}
///--------
/// Body
///--------
foreach (var wm in batch.WaterMeters)
{
if (!writerCfg.SaveGoodOnly || wm.Passed)
{
if (abort) return;
WriteWM(wrtr, wm);
}
}
///----------
/// Footer
///----------
if (!string.IsNullOrEmpty(writerCfg.Footer)) wrtr.Write(footer);
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWM(StreamWriter wr, Results.Entities.WaterMeter wm)
{
wr.WriteLine();
/// Write water meter number and s/n
#if ORACLE_DB
wr.WriteLine(writerCfg.SubtitleFormat, wm.WMPosition, wm.SerialNr, wm.SerialNrAux, wm.CompleteSerialNr,
Strings.Water_Meter, Strings.SerialNr, Strings.Main_WM_SerialNr, Strings.Aux_WM_SerialNr);
#else
wr.WriteLine(writerCfg.SubtitleFormat, wm.WMPosition, wm.SerialNr, wm.SerialNrAux, string.Empty,
Strings.Water_Meter, Strings.SerialNr, Strings.Main_WM_SerialNr, Strings.Aux_WM_SerialNr);
#endif
/// Determine column widths
int[] columnWidths = new int[testItems.Count];
int totalWidth = 0;
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
columnWidths[i] = ElSpaces(testItems[i].Caption).Length;
foreach (var mtr in wm.RegularMeterTestRslts())
{
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
string itemText = testItems[i].Print(wm, mtr.Name());
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
int len = ElSpaces(itemText).Length;
if (len > columnWidths[i]) columnWidths[i] = len;
}
}
totalWidth += columnWidths[i];
}
totalWidth += 3 * (testItems.Count - 1);
if (totalWidth < 0) totalWidth = 0;
string horizontalLine = new String('-', totalWidth);
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line above the header
}
/// Write column headers
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
string caption = ElSpaces(testItems[i].Caption);
wr.Write(caption);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - testItems[i].Caption.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
}
/// Write table data
int rowsCount = 0;
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (abort) return;
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always)
{
Results.WMeterRsltItemSpec.TableRowNr = ++rowsCount;
for (int i = 0; i < testItems.Count; i++)
{
Results.WMeterRsltItemSpec.TableColumnNr = i + 1;
/// Fetch the item
string itemText = testItems[i].Print(wm, mtr.Name());
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
string itemText2 = ElSpaces(itemText);
wr.Write(itemText2);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
}
}
if (!writerCfg.EliminateSpaces)
{
wr.WriteLine(horizontalLine); /// Horizontal line below the body
}
}
}
}
@@ -0,0 +1,79 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public string SubtitleFormat;
public Culture Culture;
public Separator Separator;
public bool EliminateSpaces;
public bool SaveGoodOnly;
public string Header;
public string[] CommonItems;
public string[] SelectedItems;
public string Footer;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}.txt";
SubtitleFormat = "{4} {0}, {5} {1}";
Separator = Separator.None;
EliminateSpaces = false;
SaveGoodOnly = false;
Header = string.Empty;
Footer = string.Empty;
}
public string ToString(int i)
{
return string.Format("{0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, NoSpaces={7}, GoodOnly={8}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Separator,
EliminateSpaces,
SaveGoodOnly);
}
}
}
@@ -0,0 +1,382 @@
///
/// Copyright (c) 2016-2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Enhanced
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] testItems;
string footer;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
testItems = config.SelectedItems;
footer = config.Footer;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
cultureLabel.Text = "Culture";
fileNameFmtLabel.Text = "File name format";
subtitleFmtLabel.Text = "Subtitle format";
separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces";
goodOnlyCheckBox.Text = "Good only";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items";
footerButton.Text = Strings.Footer;
upgradeWizardButton.Text = "Upgrade wizard";
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
subtitleFmtTextBox.Text = config.SubtitleFormat;
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
subtitleFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
testItemsButton.Enabled = true;
footerButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SubtitleFormat != subtitleFmtTextBox.Text)
{
config.SubtitleFormat = subtitleFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
{
config.Separator = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.EliminateSpaces != eliminateSpacesCheckBox.Checked)
{
config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
{
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SelectedItems != testItems)
{
config.SelectedItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Footer != footer)
{
config.Footer = footer;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void upgradeWizardButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This wizzard will overwrite curent settings." + Environment.NewLine +
"Do you want to continue?",
"Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
///
/// Use legacy common items (English)
///
commonItems = new string[] {
"3~Batch number:~~None~~~0~",
"72~Date and time:~~None~{0:yyyy.MM.dd HH:mm}~~0~",
"2~Procedure:~~None~~~0~",
"66~User:~~None~~~0~",
"26~Ambient temperature:~~C~{0} °C~F1~0~",
"27~Ambient pressure:~~mbar~{0} mbar~F0~0~",
"28~Ambient humidity:~~Pct~{0} %~F0~0~",
};
commonItemsButton_Click(this, null);
testItemsButton_Click(this, null);
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
@@ -0,0 +1,468 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters.Enhanced
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.upgradeWizardButton = new System.Windows.Forms.Button();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.subtitleFmtTextBox = new System.Windows.Forms.TextBox();
this.subtitleFmtLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 6);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 49);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 52);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 49);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 224);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 19;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 221);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 20;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 296);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 25;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 116);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 138);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 113);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 135);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 70);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 70);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 73);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 157);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 160);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format";
//
// eliminateSpacesCheckBox
//
this.eliminateSpacesCheckBox.AutoSize = true;
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(20, 262);
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.eliminateSpacesCheckBox.TabIndex = 21;
this.eliminateSpacesCheckBox.Text = "No spaces";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 246);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 23;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 321);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 26;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 271);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 24;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// upgradeWizardButton
//
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 271);
this.upgradeWizardButton.Name = "upgradeWizardButton";
this.upgradeWizardButton.Size = new System.Drawing.Size(80, 48);
this.upgradeWizardButton.TabIndex = 27;
this.upgradeWizardButton.Text = "Upgrade wizard";
this.upgradeWizardButton.UseVisualStyleBackColor = true;
this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click);
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 178);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 181);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 285);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 22;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// subtitleFmtTextBox
//
this.subtitleFmtTextBox.Enabled = false;
this.subtitleFmtTextBox.Location = new System.Drawing.Point(108, 200);
this.subtitleFmtTextBox.Name = "subtitleFmtTextBox";
this.subtitleFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.subtitleFmtTextBox.TabIndex = 29;
//
// subtitleFmtLabel
//
this.subtitleFmtLabel.AutoSize = true;
this.subtitleFmtLabel.Location = new System.Drawing.Point(17, 203);
this.subtitleFmtLabel.Name = "subtitleFmtLabel";
this.subtitleFmtLabel.Size = new System.Drawing.Size(74, 13);
this.subtitleFmtLabel.TabIndex = 28;
this.subtitleFmtLabel.Text = "Subtitle format";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(257, 211);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(174, 13);
this.label1.TabIndex = 30;
this.label1.Text = "4:wmStr 5:s/n 6:main s/n 7:aux.s/n";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(257, 198);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(168, 13);
this.label2.TabIndex = 31;
this.label2.Text = "0:pos 1:s/n 2:aux.s/n 3:compl.s/n";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(257, 155);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(138, 13);
this.label3.TabIndex = 32;
this.label3.Text = "0:end t. 1:start t. 2:batch nr.";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(257, 168);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(128, 13);
this.label4.TabIndex = 33;
this.label4.Text = "3:bench name 4:bench id";
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.subtitleFmtTextBox);
this.Controls.Add(this.subtitleFmtLabel);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.upgradeWizardButton);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(440, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label separatorLabel;
private System.Windows.Forms.ComboBox separatorComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox eliminateSpacesCheckBox;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button upgradeWizardButton;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.TextBox subtitleFmtTextBox;
private System.Windows.Forms.Label subtitleFmtLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+40
View File
@@ -0,0 +1,40 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters
{
public enum YearFolders
{
None,
TwoDigit,
FourDigit,
Count
}
public enum MonthFolders
{
None,
Digit,
TwoDigit,
Name,
Count
}
public enum DayFolders
{
None,
Digit,
TwoDigit,
Count
}
public enum Separator
{
None,
Space,
Tabulator,
Comma,
Semicolon,
Count
}
}
@@ -0,0 +1,210 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System;
using System.IO;
using log4net;
namespace TBF.Rig.Output.FileWriters.ImageArchiver
{
/// <summary>
/// Implements an operation 'ProcessResultsOp(batch)' that copies files from folder
/// Path.Combine(Program.ImagesDir, batch.BatchNr.ToString(), wm.WMPosition.ToString())
/// for each water meter in the batch to a destination folder specified by the component properties.
/// </summary>
public class Archiver : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Archiver));
public override string ToString() { return string.Format("Output.FileWriters.Basic({0})", Cfg.ToString(1)); }
readonly ArchiverCfg writerCfg;
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
ArchiverCfg tmpcfg = args.Cfg as ArchiverCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = tmpcfg.DestinationPath;
writerCfg.DestinationPath2 = tmpcfg.DestinationPath2;
writerCfg.YearFolders = tmpcfg.YearFolders;
writerCfg.MonthFolders = tmpcfg.MonthFolders;
writerCfg.DayFolders = tmpcfg.DayFolders;
writerCfg.ArchiveFormat = tmpcfg.ArchiveFormat;
writerCfg.SaveGoodOnly = tmpcfg.SaveGoodOnly;
}
}
};
}
#endregion Configuration Change Handling
Results.Entities.Batch batch;
bool abort; /// Set to 'true' by Stop() operation to abort writing to the file
public Archiver() {}
public Archiver(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as ArchiverCfg;
log.Debug(ToString());
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="endTime">Date and time</param>
/// <returns>File name</returns>
string GetArchivePath(string destinationPath, DateTime startTime, DateTime endTime, int wmPosition, string wmSN)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1}\\", directory, endTime.Year.ToString("D4"));
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1}\\", directory, (endTime.Year % 100).ToString("D2"));
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (endTime.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, endTime.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1}\\", directory, endTime.Month.ToString("D2"));
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, endTime.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1}\\", directory, endTime.Day.ToString("D2"));
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.ArchiveFormat)) throw new Exception();
return directory + string.Format(writerCfg.ArchiveFormat, startTime, endTime, batch.BatchNr, wmPosition, wmSN);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}-{2}", directory, endTime, wmPosition);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
MoveFilesToArchive(batch, writerCfg.DestinationPath);
MoveFilesToArchive(batch, writerCfg.DestinationPath2);
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void MoveFilesToArchive(Results.Entities.Batch batch, string destination)
{
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0
|| string.IsNullOrEmpty(destination))
{
return;
}
foreach (var wm in batch.WaterMeters)
{
if (wm != null && (!writerCfg.SaveGoodOnly || wm.Passed))
{
string srcFolder = Path.Combine(Program.ImagesDir, batch.BatchNr.ToString(), wm.WMPosition.ToString());
try
{
/// TODO: Copy files when files are on different disks.
wm.ArchivePath = GetArchivePath(destination, batch.StartTime, batch.EndTime, wm.WMPosition, wm.SerialNr);
Directory.Move(srcFolder, wm.ArchivePath);
}
catch
{
log.ErrorFormat("Failed to move archive files from {0}", srcFolder);
}
}
}
}
}
}
@@ -0,0 +1,65 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.ImageArchiver
{
public class ArchiverCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ArchiverCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new ArchiverCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string ArchiveFormat;
public bool SaveGoodOnly;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
ArchiverCfg()
{
}
public ArchiverCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
ArchiveFormat = "{1:yyyyMMdd-HHmm}-{3}";
SaveGoodOnly = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, ArchiveFmt={5}, GoodOnly={6}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
ArchiveFormat,
SaveGoodOnly);
}
}
}
@@ -0,0 +1,182 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.ImageArchiver
{
public partial class ArchiverCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
public bool Compound;
ArchiverCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as ArchiverCfg;
Redraw();
}
}
string[] selectedItems;
public ArchiverCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
archiveFmtTextBox.Text = config.ArchiveFormat;
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
archiveFmtTextBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
break;
}
}
if (config.ArchiveFormat != archiveFmtTextBox.Text)
{
config.ArchiveFormat = archiveFmtTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
{
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Archiver.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
}
}
@@ -0,0 +1,327 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters.ImageArchiver
{
partial class ArchiverCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.archiveFmtTextBox = new System.Windows.Forms.TextBox();
this.archiveFmtLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 54);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(221, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 57);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(335, 53);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 16;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 103);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 7;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 127);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 9;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 151);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 11;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 100);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 8;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 124);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 10;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 148);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 12;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(335, 78);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 17;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 77);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(221, 20);
this.destination2TextBox.TabIndex = 6;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 80);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 5;
this.destination2Label.Text = "Destination 2";
//
// archiveFmtTextBox
//
this.archiveFmtTextBox.Enabled = false;
this.archiveFmtTextBox.Location = new System.Drawing.Point(108, 172);
this.archiveFmtTextBox.Name = "archiveFmtTextBox";
this.archiveFmtTextBox.Size = new System.Drawing.Size(223, 20);
this.archiveFmtTextBox.TabIndex = 14;
//
// archiveFmtLabel
//
this.archiveFmtLabel.AutoSize = true;
this.archiveFmtLabel.Location = new System.Drawing.Point(17, 175);
this.archiveFmtLabel.Name = "archiveFmtLabel";
this.archiveFmtLabel.Size = new System.Drawing.Size(75, 13);
this.archiveFmtLabel.TabIndex = 13;
this.archiveFmtLabel.Text = "Archive format";
//
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(108, 200);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 15;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(337, 175);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(101, 13);
this.label1.TabIndex = 18;
this.label1.Text = "{0} = start date/time";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(337, 190);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(99, 13);
this.label2.TabIndex = 19;
this.label2.Text = "{1} = end date/time";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(337, 219);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(92, 13);
this.label4.TabIndex = 20;
this.label4.Text = "{3} = WM position";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(337, 233);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 13);
this.label5.TabIndex = 21;
this.label5.Text = "{4} = WM s/n";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(337, 204);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(76, 13);
this.label3.TabIndex = 22;
this.label3.Text = "{2} = Batch nr.";
//
// ArchiverCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label3);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.archiveFmtTextBox);
this.Controls.Add(this.archiveFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "ArchiverCfgCtrl";
this.Size = new System.Drawing.Size(455, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox archiveFmtTextBox;
private System.Windows.Forms.Label archiveFmtLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label3;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.ImageArchiver
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Archiver.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Archiver(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Archiver(cfg); }
public IComponentCfg DefaultConfig() { return new ArchiverCfg("FileWriter.ImageArchiver", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(ArchiverCfg.Serializer, component, this);
(cfg as ArchiverCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.IperlLogger
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg(this.GetType().Namespace.Substring(15), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,545 @@
///
/// Copyright (c) 2018-2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using log4net;
using Config;
using Config.Entities;
using Results.Output;
using Events.Entities;
namespace TBF.Rig.Output.FileWriters.IperlLogger
{
public enum Retv
{
OK,
Error,
}
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Sensus-Oracle-Database({0})", Cfg.ToString(1)); }
WriterCfg writerCfg;
enum CurrentOp
{
None,
WriteResults,
}
CurrentOp currentOp;
bool opCompleted;
bool anyError;
/// <summary>
/// Results to print
/// </summary>
Results.Entities.Batch batch;
string fileName;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
currentOp = CurrentOp.None;
log.Warn(this.ToString());
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetLogFileName(DateTime time)
{
string directory = writerCfg.DestinationPath; /// Ends with "\\";
Directory.CreateDirectory(directory);
if (writerCfg.YearFolders)
{
directory = string.Format("{0}{1}\\", directory, time.Year.ToString());
Directory.CreateDirectory(directory);
}
if (writerCfg.MonthFolders)
{
directory = string.Format("{0}{1}\\", directory, time.Month.ToString("D2"));
Directory.CreateDirectory(directory);
}
if (writerCfg.DayFolders)
{
directory = string.Format("{0}{1}\\", directory, time.Day.ToString("D2"));
Directory.CreateDirectory(directory);
}
return string.Format("{0}{1}_{2}.log", directory, time.Hour.ToString("D2"), time.Minute.ToString("D2"));
}
/// <summary>
/// Writes the test cycle results into a file, Events: Event.ResultsWritten
/// </summary>
/// <param name="procedure">Procedure to print the results of</param>
/// <param name="unsortedResults">Results to write into the file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
if (currentOp != CurrentOp.None)
{
throw new Exception("Sequence error");
}
this.batch = batch;
currentOp = CurrentOp.WriteResults;
try
{
fileName = GetLogFileName(batch.StartTime);
}
catch
{
fileName = string.Empty;
log.Error("Unable to create IperlLogger file name");
}
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
opCompleted = false;
anyError = false;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten or Event.Error</returns>
public Event Run()
{
if (currentOp == CurrentOp.WriteResults)
{
if (batch.WaterMeters.Count == 0) return Event.ResultsWritten;
if (!opCompleted && !string.IsNullOrEmpty(fileName))
{
log.WarnFormat("{0} : Going to write Iperl Log to file {1}", Name, fileName);
using (TextWriter logger = new StreamWriter(System.IO.File.Create(fileName)))
{
try
{
anyError = anyError || (WriteLogsToDisk(logger, batch) != Retv.OK);
logger.Flush();
logger.Close();
log.WarnFormat("{0} : Batch #{1} written OK", Name, batch.BatchNr);
}
catch (Exception exc)
{
anyError = true;
log.WarnFormat("{0} : Failed to write batch #{1}: {2}", Name, batch.BatchNr, exc.Message);
}
}
opCompleted = true;
}
if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
{
try
{
NHibernate.ISession session = Events.DB.CreateSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
string.Format("Nepodarilo sa uložiť logy pre WZ Datenbank: Číslo dávky={0}", batch.BatchNr),
string.Format("Nepodarilo sa uložiť logy pre WZ Datenbank\r\nČíslo dávky = {0}", batch.BatchNr),
SubscriberGroup.Metrology | SubscriberGroup.Maintenance | SubscriberGroup.Production);
}
catch (Exception exc)
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
}
return anyError ? Event.ErrorProcessingResults: Event.ResultsWritten;
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>
public void Stop()
{
currentOp = CurrentOp.None;
}
public Retv WriteLogsToDisk(TextWriter logger, Results.Entities.Batch batch)
{
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
/// Obtain one representative water meter data
Results.Entities.WaterMeter wm0 = null;
foreach (var wm in batch.WaterMeters)
{
if (wm != null && wm.WaterMeterData != null)
{
wm0 = wm;
if (wm0.CompleteTestInfos == null)
{
wm0.CompleteTestInfos = (TBF.Rig.Sequences.ProcessData.CompleteTestInfos != null)
? TBF.Rig.Sequences.ProcessData.CompleteTestInfos
: Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
}
break;
}
}
if (wm0 == null)
{
log.Error("Not a single watermeter in the batch");
return Retv.Error; /// Not a single watermeter in the batch
}
SensusTestInfo[] testInfos = wm0.CompleteTestInfos as SensusTestInfo[];
if (testInfos == null)
{
log.Error("CompleteTestInfos of the first water meter is null");
return Retv.Error; /// No test infos
}
log.Warn("Using CompleteTestInfos:");
foreach (var cti in testInfos)
{
log.WarnFormat(" Test={0} PrfNrDB={1} QBzDB={2} PrfNrOpto={3} QBzOpto={4} PrfNrLog={5} QBzLog={6} Range={7}",
cti.TestName, cti.PruefungsNrDB, cti.QBezeichnungDB, cti.PruefungsNrOpto,
cti.QBezeichnungOpto, cti.PruefungsNrLog, cti.QBezeichnungLog, cti.Range);
}
Results.Entities.WaterMeterData wmData = wm0.WaterMeterData;
Results.Entities.MeterTestRslt[] wm0trs = new Results.Entities.MeterTestRslt[testInfos.Length];
double totalTestTime = 0;
int maxPruefungsNr = 0;
for (int j = 0; j < testInfos.Length; j++)
{
if (testInfos[j].PruefungsNrLog != 0)
{
if (Math.Abs(testInfos[j].PruefungsNrLog) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testInfos[j].PruefungsNrLog);
wm0trs[j] = wm0.GetMeterTestRslt(testInfos[j].TestName);
if (wm0trs[j] != null)
{
totalTestTime += wm0trs[j].TargetTime();
}
else
{
log.ErrorFormat("Missing test result for test {0}", testInfos[j].TestName);
return Retv.Error; /// Missing test result for one of specified tests
}
}
}
logger.WriteLine("[Wasserzähler-Daten]");
logger.WriteLine(string.Format("PruefPunkte={0}", (maxPruefungsNr > 15) ? 20 : ((maxPruefungsNr > 10) ? 15 : ((maxPruefungsNr > 5) ? 10 : 5))));
logger.WriteLine(string.Format("Typ={0}", batch.ProcedureName)); /// iP 020 Q3_4 R160 A XXXX
logger.WriteLine(string.Format("MetroKlasse={0}", wmData.MetrologicalClass));
logger.WriteLine(string.Format("Zulassungszeichen={0}", wmData.ApprovalInfo));
logger.WriteLine(string.Format("Qn={0}", wmData.Q3_Qn.ToString("F1", Program.AltCulture)));
logger.WriteLine(string.Format("Impulsrate=1"));
logger.WriteLine(string.Format("WZid={0}", wmData.WMTypeId));
logger.WriteLine(string.Format("RevWzTyp={0}", wm0.WMTypeRevision));
logger.WriteLine(string.Format("RevPruefstandWzTyp=2"));
for (int j = 0; j < testInfos.Length; j++)
{
if (testInfos[j].PruefungsNrLog != 0)
{
string fId = testInfos[j].PruefungsNrLog.ToString((testInfos[j].PruefungsNrLog > 0) ? "D2" : "D1");
string qBz = testInfos[j].QBezeichnungLog;
Results.Entities.MeterTestRslt wm0r = wm0trs[j];
bool pb_100_110 = (testInfos[j].Range == Range.R100_110);
if (wm0r != null)
{
/// An existing test
logger.WriteLine(string.Format("Durchfluss{0}={1}", fId, Units.ConvertTo(Unit.lph, (wm0r.Qfrom() + wm0r.Qto()) / 2).ToString("F1", Program.AltCulture)));
logger.WriteLine(string.Format("Prüfzeit{0}={1}", fId, wm0r.TargetTime().ToString("F0")));
logger.WriteLine(string.Format("Prüfbereich100_110{0}={1}", fId, (pb_100_110 ? 1 : 0)));
logger.WriteLine(string.Format("PrüfbereichMin{0}={1}", fId, (pb_100_110 ? 100 : 90)));
logger.WriteLine(string.Format("PrüfbereichMax{0}={1}", fId, (pb_100_110 ? 110 : 100)));
logger.WriteLine(string.Format("QBezeichnung{0}={1}", fId, qBz));
if (testInfos[j].PruefungsNrLog > 0)
{
/// Test is not an adjustment
logger.WriteLine(string.Format("PosFehlergrenze{0}={1}", fId, (wm0r.ErrLimHi() - wm0r.Uncertainty()).ToString("F1", Program.AltCulture)));
logger.WriteLine(string.Format("NegFehlergrenze{0}={1}", fId, (wm0r.ErrLimLo() + wm0r.Uncertainty()).ToString("F1", Program.AltCulture)));
logger.WriteLine(string.Format("PosFehlergrenzeWarm{0}=0,0", fId));
logger.WriteLine(string.Format("NegFehlergrenzeWarm{0}=0,0", fId));
}
}
else
{
logger.WriteLine(string.Format("Durchfluss{0}=0,0", fId));
logger.WriteLine(string.Format("Prüfzeit{0}=0", fId));
logger.WriteLine(string.Format("Prüfbereich100_110{0}=0", fId));
logger.WriteLine(string.Format("PrüfbereichMin{0}=0", fId));
logger.WriteLine(string.Format("PrüfbereichMax{0}=0", fId));
logger.WriteLine(string.Format("QBezeichnung{0}=", fId));
}
}
}
logger.WriteLine(string.Format("GetriebeImpulse=2,000")); /// 2,000
logger.WriteLine(string.Format("OptikAufsetzen=0")); /// 0
logger.WriteLine(string.Format("Warm_Kalt=0")); /// 0
logger.WriteLine(string.Format("Füllzeit=0")); /// 0
logger.WriteLine(string.Format("EvakVorneZeit=0")); /// 0
logger.WriteLine(string.Format("EvakHintenZeit={0}", 0)); /// 90
logger.WriteLine(string.Format("Spüllzeit={0}", 0)); /// 60
logger.WriteLine(string.Format("Spüldurchfluss={0}", 0)); /// 5000,0
logger.WriteLine(string.Format("Abpresszeit={0}", 0)); /// 60
logger.WriteLine(string.Format("Abpressdruck={0}", 0)); /// 0,0
logger.WriteLine(string.Format("Entwässerzeit={0}", 0)); /// 10
logger.WriteLine(string.Format("DinA4_Format={0}", 0)); /// 0
logger.WriteLine(string.Format("Netzwerk_Format={0}", 0)); /// 0
logger.WriteLine(string.Format("Zählernr_Format={0}", 0)); /// 1
logger.WriteLine(string.Format("WZ_Gruppe=24")); /// 24 - iPerl
logger.WriteLine(string.Format("MittelwertTiefe={0}", 0)); /// 1
logger.WriteLine(string.Format("EndKriterium={0}", 0)); /// 0
logger.WriteLine(string.Format("Justieren={0}", 1)); /// 1
logger.WriteLine(string.Format("Bemerkung=")); ///
logger.WriteLine(string.Format("Gesamtprüfzeit={0}", totalTestTime.ToString("F0")));
logger.WriteLine(string.Format("Gegenprüfung={0}", 0)); /// 0
logger.WriteLine(string.Format("Geändert_von={0}", 6)); /// 4459
logger.WriteLine(string.Format("Geändert_am={0:dd.MM.yyyy HH:mm:ss}", DateTime.Now)); /// 29.05.2015 13:46:17
for (int i = 0; i < batch.WaterMeters.Count; i++)
{
Results.Entities.WaterMeter wMtr = batch.WaterMeters[i];
if ((wMtr == null) || (wMtr.ErrorFlags & ((int)ErrorFlagMask.E26 | (int)ErrorFlagMask.E27 | (int)ErrorFlagMask.E28)) != 0)
{
logger.WriteLine();
logger.WriteLine(string.Format("[Zählerdaten_{0}]", wMtr.WMPosition));
logger.WriteLine("geprüft=0");
}
else
{
bool testRsltIsMissing = false;
Results.Entities.MeterTestRslt[] wmtrs = new Results.Entities.MeterTestRslt[testInfos.Length];
for (int j = 0; j < testInfos.Length; j++)
{
if (testInfos[j].PruefungsNrLog != 0)
{
wmtrs[j] = wMtr.GetMeterTestRslt(testInfos[j].TestName);
if (wmtrs[j] == null) testRsltIsMissing = true; /// Missing test result for one of specified tests
}
}
logger.WriteLine();
logger.WriteLine(string.Format("[Zählerdaten_{0}]", wMtr.WMPosition));
if (testRsltIsMissing)
{
logger.WriteLine("geprüft=0");
}
else
{
logger.WriteLine("geprüft=1");
logger.WriteLine(string.Format("Zählernummer="));
logger.WriteLine(string.Format("FertigsNr={0}", wMtr.SerialNr));
logger.WriteLine(string.Format("bestanden={0}", wMtr.Passed ? 1 : 0)); /// 1
logger.WriteLine(string.Format("Prüfflag={0}", wMtr.HydrPruefung)); /// 96
logger.WriteLine(string.Format("FestWertWZ=0")); /// 0
logger.WriteLine(string.Format("Dicht={0}", 1)); /// 1
logger.WriteLine(string.Format("PrüfIndex={0}", wMtr.Pruefindex)); /// 7301
logger.WriteLine(string.Format("GeprüftIndex=1")); /// 1
for (int j = 0; j < testInfos.Length; j++)
{
if (testInfos[j].PruefungsNrLog != 0)
{
Results.Entities.MeterTestRslt mtr = wmtrs[j];
string flID = testInfos[j].PruefungsNrLog.ToString((testInfos[j].PruefungsNrLog > 0) ? "D2" : "D1");
if (mtr != null)
{
logger.WriteLine(string.Format("Q{0}bestanden={1}", flID, 1));
logger.WriteLine(string.Format("Durchfluss{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.FlowVolume()), 5, true)));
logger.WriteLine(string.Format("Fehler{0}={1}", flID, mtr.Error.ToString(Program.AltCulture)));
logger.WriteLine(string.Format("ZeitImpulse{0}={1}", flID, mtr.TestTime.ToString(Program.AltCulture)));
logger.WriteLine(string.Format("Impulse{0}={1}", flID, 0));
logger.WriteLine(string.Format("Volumen{0}={1}", flID, mtr.VolumeMeter.ToString(Program.AltCulture)));
logger.WriteLine(string.Format("KorrFehler{0}={1}", flID, (mtr.TestData().Method != null) && mtr.TestData().Method.Contains("iPerlCommunication") && ((mtr.WaterMeter.Q2CorrRL != 0) || (mtr.WaterMeter.Q2CorrLR != 0))
? mtr.WaterMeter.Q2ErrWOCorrection.ToString(Program.AltCulture)
: mtr.Error.ToString(Program.AltCulture)));
logger.WriteLine(string.Format("KorrDurchfluss{0}={1}", flID, 0));
logger.WriteLine(string.Format("Q{0}KorrBestanden={1}", flID, 0));
logger.WriteLine(string.Format("Anfangsstand{0}={1}", flID, 0)); /// TODO
logger.WriteLine(string.Format("Endstand{0}={1}", flID, 0)); /// TODO
logger.WriteLine(string.Format("QMittelwert{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.FlowVolume()), 5, true)));
logger.WriteLine(string.Format("QStandardAbweichung{0}={1}", flID, 0));
logger.WriteLine(string.Format("ImpedanzMittelwert{0}={1}", flID, "0,00000"));
logger.WriteLine(string.Format("AusfallGrund{0}={1}", flID, 0));
}
}
}
logger.WriteLine(string.Format("AusfallGrundGesamt={0}", 0));
logger.WriteLine(string.Format("AuftragNum={0}", wMtr.PurchaseOrder));
logger.WriteLine(string.Format("MaterialNum={0}", 38140500));
logger.WriteLine(string.Format("Prefix={0}", "8SEN01"));
logger.WriteLine(string.Format("Suffix="));
logger.WriteLine(string.Format("Palette={0}", 0));
logger.WriteLine(string.Format("Umkarton={0}", 0));
logger.WriteLine(string.Format("ZNr_komplett="));
logger.WriteLine(string.Format("OptikBewertung=0,00000"));
logger.WriteLine(string.Format("IdProduziert={0}", 0));
logger.WriteLine(string.Format("Calibration_alt={0}", wMtr.OrigCalibFactor));
logger.WriteLine(string.Format("Calibration={0}", wMtr.CalibFactor));
logger.WriteLine(string.Format("Firmware={0}", wMtr.FWVersion)); /// 5.066
logger.WriteLine(string.Format("FlexFlowFehler={0}", 0)); /// 0
logger.WriteLine(string.Format("FlexFlowAuftrag={0}", 0)); /// 4248189
logger.WriteLine(string.Format("JustierWert=0,2")); /// 0,2
logger.WriteLine(string.Format("Corrected2Hz={0}", wMtr.Hz2CorrectionDone ? 1 : 0));
logger.WriteLine(string.Format("Q2Corrected={0}", ((wMtr.Q2CorrRL != 0) || (wMtr.Q2CorrLR != 0)) ? 1 : 0));
logger.WriteLine(string.Format("Q2CorrectionRight={0}", wMtr.Q2CorrLR));
logger.WriteLine(string.Format("Q2CorrectionLeft={0}", wMtr.Q2CorrRL));
logger.WriteLine(string.Format("Q2CorrectionFlowRight={0}", wMtr.Q2CorrFlowRight));
logger.WriteLine(string.Format("FlowDirectionRight={0}", wMtr.Q2CorrFlowRight));
logger.WriteLine(string.Format("Position={0}", wMtr.WMPosition));
}
}
}
logger.WriteLine();
logger.WriteLine("[Prüfdaten]");
///
logger.WriteLine(string.Format("Startzeit={0}", batch.StartTime.ToString("HH:mm:ss")));
logger.WriteLine(string.Format("Endezeit={0}", batch.EndTime.ToString("HH:mm:ss")));
logger.WriteLine(string.Format("Datum={0}", batch.StartTime.ToString("dd.MM.yyyy")));
logger.WriteLine(string.Format("GesamtDauer={0}", batch.EndTime.Subtract(batch.StartTime).TotalSeconds));
logger.WriteLine(string.Format("Dichtprüfung={0}", 0)); /// 1
foreach (var cti in testInfos)
{
if (cti.PruefungsNrLog != 0)
{
string pNrStr = cti.PruefungsNrLog.ToString((cti.PruefungsNrLog > 0) ? "D2" : "D1");
Results.Entities.TestRslt tr = wm0.GetTestRslt(cti.TestName);
if (tr != null)
{
logger.WriteLine(string.Format("Q{0}_geprüft=1", pNrStr));
WriteOneToDisk(logger, pNrStr, tr);
}
else
{
logger.WriteLine(string.Format("Q{0}_geprüft=0", pNrStr));
}
}
}
logger.WriteLine(string.Format("FüllenDruck={0}", 0)); /// 0,00
logger.WriteLine(string.Format("EvakVorneDruck={0}", 0)); /// 0,00
logger.WriteLine(string.Format("EvakHintenDruck={0}", 0)); /// -1,00
logger.WriteLine(string.Format("Spüldurchfluss={0}", 0)); /// 4722,00
logger.WriteLine(string.Format("AbpressDruck={0}", 0)); /// 20,13
logger.WriteLine(string.Format("AbpressDruckVorne={0}", 0)); /// 20,16
logger.WriteLine(string.Format("AbpressDruckBeginn={0}", 0)); /// 0,00
logger.WriteLine(string.Format("EntwässernDruck={0}", 0)); /// -1,00
logger.WriteLine(string.Format("ZaehlwerktestAnfang={0}", 0)); /// 0,00000
logger.WriteLine(string.Format("ZaehlwerktestEnde={0}", 0)); /// 0,00000
logger.WriteLine(string.Format("ZaehlwerktestImpulse={0}", 0)); /// 0
logger.WriteLine(string.Format("MeldungZaehler={0}", 0)); /// 0
logger.WriteLine();
logger.WriteLine("[allgemein]");
///
logger.WriteLine(string.Format("Prüfer={0}", batch.UserName));
logger.WriteLine(string.Format("PrüferID={0}", batch.UserNumber));
logger.WriteLine(string.Format("AuftragKompakt={0}", 0)); /// 4248189
logger.WriteLine(string.Format("VariantenCode={0}", "IP")); /// IPRO04CMECAZDKAMMXB1AA2011201101AEUAA1XX314NM1XXXLX
logger.WriteLine(string.Format("SollStückzahl={0}", 3)); /// 1000
logger.WriteLine(string.Format("IstStückzahl={0}", 3)); /// 61
logger.WriteLine(string.Format("Bemerkung=§")); /// §
logger.WriteLine(string.Format("BetriebsArt={0}", 3)); /// C
logger.WriteLine(string.Format("BuchstabenVorEtikett=8SEN01")); /// 8SEN01
logger.WriteLine(string.Format("BuchstabenNachEtikett=")); ///
logger.WriteLine(string.Format("StehenderStartStop={0}", 0)); /// 0
logger.WriteLine(string.Format("ID_WzPruefreihe={0}", batch.BatchNr)); /// 2583
logger.WriteLine(string.Format("ID_Pruefstand={0}", 18000 + batch.TestBenchId)); /// 18004
logger.WriteLine(string.Format("DichteKorrektur=0,00000")); /// 0,00000
logger.WriteLine(string.Format("LuftauftriebsKorrekturfaktor=1,00000")); /// 1,00100
logger.WriteLine(string.Format("ProgrammVersion={0}", Program.Version));
logger.WriteLine(string.Format("LetzteAenderung={0}", Program.BuildDateTime.ToShortDateString()));
logger.WriteLine(string.Format("QuarzTakt={0}", 0)); /// 1953,125
#endif
return Retv.OK; /// OK
}
void WriteOneToDisk(TextWriter logger, string id, Results.Entities.TestRslt tr)
{
logger.WriteLine(string.Format("Prüfvolumen{0}={1}", id, Config.Units.ConvertTo(Unit.l, tr.TestData.TargetVolume).ToString(Program.AltCulture)));
logger.WriteLine(string.Format("Prüfmasse{0}={1}", id, 0)); /// 3,72610
logger.WriteLine(string.Format("Temp1_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp2_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp3_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp4_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp5_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp6_P{0}={1}", id, 0)); /// 20,0
logger.WriteLine(string.Format("Temp7_P{0}={1}", id, 0)); /// 0,0
logger.WriteLine(string.Format("Temp8_P{0}={1}", id, 0)); /// 0,0
logger.WriteLine(string.Format("Druck1_P{0}={1}", id, Config.Units.ConvertTo(Unit.bar, tr.PressUpMean).ToString(Program.AltCulture)));
logger.WriteLine(string.Format("Druck2_P{0}={1}", id, Config.Units.ConvertTo(Unit.bar, tr.PressDownMean).ToString(Program.AltCulture)));
logger.WriteLine(string.Format("K-Faktor{0}={1}", id, 0)); /// 0,99820080
logger.WriteLine(string.Format("Q_Waage{0}={1}", id, 0)); /// 26,89887
logger.WriteLine(string.Format("Q_Vergleich{0}={1}", id, 0)); /// 26,83427
logger.WriteLine(string.Format("Fehler_Vergleich{0}={1}", id, 0)); /// -0,24014
logger.WriteLine(string.Format("VZ_ZeitImpulse{0}={1}", id, 0)); /// 500,07962
logger.WriteLine(string.Format("VZ_Impulse{0}={1}", id, 0)); /// 4473091
logger.WriteLine(string.Format("ZeitImpulse_VZ{0}={1}", id, 0)); /// 976718
logger.WriteLine(string.Format("VorwahlZähler{0}={1}", id, 0)); /// 0,00000
logger.WriteLine(string.Format("VZ_Nummer{0}={1}", id, 0)); /// 3
logger.WriteLine(string.Format("Anfangsgewicht{0}={1}", id, 0)); /// 4,66535
logger.WriteLine(string.Format("Endgewicht{0}={1}", id, 0)); /// 8,39145
logger.WriteLine(string.Format("MinDurchfluss{0}={1}", id, Config.Units.ConvertTo(Unit.lph, tr.FlowMin).ToString(Program.AltCulture)));
logger.WriteLine(string.Format("MaxDurchfluss{0}={1}", id, Config.Units.ConvertTo(Unit.lph, tr.FlowMax).ToString(Program.AltCulture)));
logger.WriteLine(string.Format("Q_Einstellzeit{0}={1}", id, 0)); /// 4,17
logger.WriteLine(string.Format("Pumpennummer{0}={1}", id, 0)); /// 3
logger.WriteLine(string.Format("Drehzahl{0}={1}", id, 0)); /// 1743
logger.WriteLine(string.Format("DAW_Wert{0}={1}", id, 0)); /// 2700
logger.WriteLine(string.Format("Leitfähigkeit{0}={1}", id, 0)); /// 543,10
logger.WriteLine(string.Format("LuftDruck{0}={1}", id, 0)); /// 0,0
logger.WriteLine(string.Format("LuftFeuchtigkeit{0}={1}", id, 0)); /// 0,0
logger.WriteLine(string.Format("HyDruck{0}={1}", id, 0)); /// 6,2
logger.WriteLine(string.Format("VorratsDruckHy{0}={1}", id, 0)); /// 6,3
logger.WriteLine(string.Format("Anfangsgewicht2_{0}={1}", id, 0)); /// 37,94400
logger.WriteLine(string.Format("Endgewicht2_{0}={1}", id, 0)); /// 37,94200
logger.WriteLine(string.Format("Prüfmasse2_{0}={1}", id, 0)); /// -0,00200
logger.WriteLine(string.Format("GegenWaage{0}={1}", id, 0)); /// 1
}
}
}
@@ -0,0 +1,150 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.IperlLogger
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
public string DestinationPath; /// Directory path into which the logs will be saved
public bool YearFolders;
public bool MonthFolders;
public bool DayFolders;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
DestinationPath = Program.HomeDir + "Logs\\";
YearFolders = true;
MonthFolders = true;
DayFolders = true;
}
string[] paramNames = new string[]
{
"Destination path",
"Year folders",
"Month folders",
"Day folders",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
switch (i)
{
case 1:
case 2:
case 3:
return new string[] { Strings.yes, Strings.no };
default:
return null;
}
}
public string ToString(int i)
{
if (i == -1)
{
return string.Format("{0}: Dest.={1}, Y={2}, M={3}, D={4}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders);
}
switch (i)
{
case 0: return DestinationPath;
case 1: return YearFolders ? Strings.yes : Strings.no;
case 2: return MonthFolders ? Strings.yes : Strings.no;
case 3: return DayFolders ? Strings.yes : Strings.no;
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: DestinationPath = strValue; return CfgUpdateFlags.RestartRqrd;
case 1: YearFolders = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
case 2: MonthFolders = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
case 3: DayFolders = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
return true;
case 1:
case 2:
case 3:
if (strValue == Strings.yes || strValue == Strings.no) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(WriterCfg prms)
{
prms.DestinationPath = this.DestinationPath;
prms.YearFolders = this.YearFolders;
prms.MonthFolders = this.MonthFolders;
prms.DayFolders = this.DayFolders;
}
public Config.Entities.IParamsProvider Clone()
{
WriterCfg pars = new WriterCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public class FactoryCompound : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Compound"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.OneFilePerMeter.Compound", this, Config.Entities.MetersKind.Combined); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Combined;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public class FactoryHeatMeters : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".HeatMeters"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.OneFilePerMeter.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.HeatMeter;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.OneFilePerMeter.Single", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
@@ -0,0 +1,444 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Enhanced({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
string separatorStr;
///
/// Items to print
///
string header;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
Results.Entities.Batch batch;
bool abort; /// Set to 'true' by Stop() operation to abort writing to files
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
switch (writerCfg.Separator)
{
default:
case Separator.None: separatorStr = string.Empty; break;
case Separator.Space: separatorStr = " "; break;
case Separator.Tabulator: separatorStr = "\t"; break;
case Separator.Comma: separatorStr = ","; break;
case Separator.Semicolon: separatorStr = ";"; break;
}
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.SelectedItems); /// TestID info will be overwritten later on
footer = string.IsNullOrEmpty(writerCfg.Footer) ? string.Empty : writerCfg.Footer.Replace("~", Environment.NewLine);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.Separator = newCfg.Separator;
writerCfg.EliminateSpaces = newCfg.EliminateSpaces;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.SelectedItems = newCfg.SelectedItems;
writerCfg.Header = newCfg.Header;
writerCfg.Footer = newCfg.Footer;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Eliminate spaces conditionally, depesing on bool WriterCfg.EliminateSpaces
/// </summary>
/// <param name="item">Input string</param>
/// <returns>Output string</returns>
string ElSpaces(string item)
{
if (writerCfg.EliminateSpaces)
return item.Replace(" ", string.Empty);
else
return item;
}
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}.txt", directory, time);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into a file</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (!string.IsNullOrEmpty(destination))
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
}
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr)
{
///----------
/// Header
///----------
if (!string.IsNullOrEmpty(writerCfg.Header)) wrtr.Write(header);
wrtr.WriteLine();
///----------------
/// Common items
///----------------
string[] leftColumn = new string[commonItems.Count];
string[] rightColumn = new string[commonItems.Count];
int cnt = 0;
foreach (var v in commonItems)
{
leftColumn[cnt] = v.Caption;
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty;
cnt++;
}
/// Determine max. left column width in characters
int maxLen = 0;
foreach (var s in leftColumn) if (s.Length > maxLen) maxLen = s.Length;
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
if (abort) return;
wrtr.Write(leftColumn[i]);
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
wrtr.WriteLine(rightColumn[i]);
}
///--------
/// Body
///--------
foreach (var wm in batch.WaterMeters)
{
WriteWM(wrtr, wm);
if (abort) return;
}
///----------
/// Footer
///----------
if (!string.IsNullOrEmpty(writerCfg.Footer)) wrtr.Write(footer);
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWM(StreamWriter wr, Results.Entities.WaterMeter wm)
{
wr.WriteLine();
/// Write water meter number and s/n
#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT
wr.Write(string.Format("Water meter {0} s/n: {1}", wm.WMPosition, wm.SerialNr));
#else
wr.Write(string.Format("{0} {1}", Strings.Water_Meter, wm.WMPosition));
if (!wm.Compound())
{
if (!string.IsNullOrEmpty(wm.SerialNr))
{
wr.Write(string.Format(", {0} {1}", Strings.SerialNr, wm.SerialNr));
}
}
else
{
if (!string.IsNullOrEmpty(wm.SerialNr))
{
wr.Write(string.Format(", {0} {1}", Strings.Main_WM_SerialNr, wm.SerialNr));
}
if (!string.IsNullOrEmpty(wm.SerialNrAux))
{
wr.Write(string.Format(", {0} {1}", Strings.Aux_WM_SerialNr, wm.SerialNrAux));
}
}
#endif
wr.WriteLine();
/// Determine column widths
int[] columnWidths = new int[testItems.Count];
int totalWidth = 0;
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
columnWidths[i] = ElSpaces(testItems[i].Caption).Length;
foreach (var mtr in wm.RegularMeterTestRslts())
{
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
string itemText = testItems[i].Print(wm, mtr.Name());
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
int len = ElSpaces(itemText).Length;
if (len > columnWidths[i]) columnWidths[i] = len;
}
}
totalWidth += columnWidths[i];
}
totalWidth += 3 * (testItems.Count - 1);
if (totalWidth < 0) totalWidth = 0;
string horizontalLine = new String('-', totalWidth);
wr.WriteLine(horizontalLine); /// Horizontal line above the header
/// Write column headers
for (int i = 0; i < testItems.Count; i++)
{
if (abort) return;
string caption = ElSpaces(testItems[i].Caption);
wr.Write(caption);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - testItems[i].Caption.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
wr.WriteLine(horizontalLine); /// Horizontal line between the header and the body
/// Write table data
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (abort) return;
if (mtr != null && mtr.IsPilotRslt() && mtr.Publish() == Config.Entities.Publish.Always)
{
for (int i = 0; i < testItems.Count; i++)
{
/// Fetch the item
string itemText = testItems[i].Print(wm, mtr.Name());
/// Strip color information
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
string itemText2 = ElSpaces(itemText);
wr.Write(itemText2);
if (i < testItems.Count - 1)
{
if (!writerCfg.EliminateSpaces)
{
wr.Write(new string(' ', columnWidths[i] - itemText.Length + 3));
}
wr.Write(separatorStr);
}
else
{
wr.WriteLine();
}
}
}
}
wr.WriteLine(horizontalLine); /// Horizontal line below the body
}
}
}
@@ -0,0 +1,74 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public Separator Separator;
public bool EliminateSpaces;
public string[] CommonItems;
public string[] SelectedItems;
public string Header;
public string Footer;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}.txt";
Separator = Separator.None;
EliminateSpaces = false;
Header = string.Empty;
Footer = string.Empty;
}
public string ToString(int i)
{
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, EliminateSpaces={7}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Separator,
EliminateSpaces);
}
}
}
@@ -0,0 +1,338 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] testItems;
string footer;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
for (Separator s = 0; s < Separator.Count; s++) separatorComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
testItems = config.SelectedItems;
footer = config.Footer;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items";
footerButton.Text = Strings.Footer;
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
cultureComboBox.Text = config.Culture.ToString();
separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
separatorComboBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
testItemsButton.Enabled = true;
footerButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (Separator i = 0; i < Separator.Count; i++)
{
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
{
config.Separator = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.EliminateSpaces != eliminateSpacesCheckBox.Checked)
{
config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.SelectedItems != testItems)
{
config.SelectedItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Footer != footer)
{
config.Footer = footer;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
@@ -0,0 +1,371 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters.OneFilePerMeter
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 28);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 31);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 6);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 49);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 52);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 49);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// separatorLabel
//
this.separatorLabel.AutoSize = true;
this.separatorLabel.Location = new System.Drawing.Point(17, 203);
this.separatorLabel.Name = "separatorLabel";
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
this.separatorLabel.TabIndex = 19;
this.separatorLabel.Text = "Separator";
//
// separatorComboBox
//
this.separatorComboBox.Enabled = false;
this.separatorComboBox.FormattingEnabled = true;
this.separatorComboBox.Location = new System.Drawing.Point(108, 200);
this.separatorComboBox.Name = "separatorComboBox";
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 20;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 297);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 24;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 116);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 138);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 113);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 135);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 70);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 70);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 73);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 157);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 160);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format";
//
// eliminateSpacesCheckBox
//
this.eliminateSpacesCheckBox.AutoSize = true;
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(108, 227);
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.eliminateSpacesCheckBox.TabIndex = 21;
this.eliminateSpacesCheckBox.Text = "No spaces";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 247);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 22;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(108, 322);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 25;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 272);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 23;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 178);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 181);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label separatorLabel;
private System.Windows.Forms.ComboBox separatorComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox eliminateSpacesCheckBox;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Xml
{
public class FactoryCompound : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Compound"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Xml.Compound", this, Config.Entities.MetersKind.Combined); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Combined;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Xml
{
public class FactoryHeatMeters : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".HeatMeters"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Xml.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.HeatMeter;
return cfg;
}
}
}
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Xml
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.Xml.Single", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
+293
View File
@@ -0,0 +1,293 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
using Config.Entities;
using TBF.Rig;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Xml
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Enhanced({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
///
/// Items to print
///
string header;
string rootTag;
string testTag;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
Results.Entities.Batch batch;
bool abort;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
/// TODO: Apply culture info
rootTag = writerCfg.RootTag;
testTag = writerCfg.TestTag;
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.TestItems); /// TestID info will be overwritten later on
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.Header = newCfg.Header;
writerCfg.RootTag = newCfg.RootTag;
writerCfg.TestTag = newCfg.TestTag;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.TestItems = newCfg.TestItems;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time, int wmPosition)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time, wmPosition);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}-{2:D2}.xml", directory, time, wmPosition);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into files</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (string.IsNullOrEmpty(destination)) return;
foreach (var wm in batch.WaterMeters)
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime, wm.WMPosition));
WriteWM(writer, wm);
log.WarnFormat("Batch {0}/watermeter {1} written by {2} to file {3}", batch.BatchNr, wm.WMPosition, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0}/watermeter {1} by {2} to file {3}", batch.BatchNr, wm.WMPosition, Name, destination);
}
finally
{
writer.Close();
}
}
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteWM(StreamWriter wr, Results.Entities.WaterMeter wm)
{
/// Header
if (!string.IsNullOrEmpty(writerCfg.Header)) wr.Write(header);
wr.WriteLine(string.Format("<{0}>", rootTag));
/// Common items 1
foreach (var v in commonItems)
{
if (abort) return;
/// Fetch the item and strip color information
string itemText = v.Print(wm);
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
wr.WriteLine(" <{0}>{1}</{0}>", v.Caption, itemText);
}
/// Test items
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (abort) return;
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
wr.WriteLine(string.Format(" <{0}>", testTag));
for (int i = 0; i < testItems.Count; i++)
{
/// Fetch the item and strip color information
string itemText = testItems[i].Print(wm, mtr.Name());
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
wr.WriteLine(" <{0}>{1}</{0}>", testItems[i].Caption, itemText);
}
wr.WriteLine(string.Format(" </{0}>", testTag));
}
}
/// Footer
wr.WriteLine(string.Format("</{0}>", rootTag));
}
}
}
@@ -0,0 +1,74 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.Xml
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public string Header;
public string RootTag;
public string TestTag;
public string[] CommonItems;
public string[] TestItems;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Program.HomeDir + "Results\\";
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}-{2:D2}.xml";
Culture = Culture.EN;
Header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
RootTag = "gwzPruefung";
TestTag = "prueflauf";
}
public string ToString(int i)
{
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Culture={6}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Culture);
}
}
}
@@ -0,0 +1,325 @@
///
/// Copyright (c) 2017-2017 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.Xml
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
public bool Compound;
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] testItems;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
testItems = config.TestItems;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
headerButton.Text = Strings.Header;
rootTagLabel.Text = "Root tag";
commonItemsButton.Text = "Common items";
testTagLabel.Text = "Test tag";
testItemsButton.Text = "Test items";
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
cultureComboBox.Text = config.Culture.ToString();
rootTagTextBox.Text = config.RootTag;
testTagTextBox.Text = config.TestTag;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
headerButton.Enabled = true;
rootTagTextBox.Enabled = true;
commonItemsButton.Enabled = true;
testTagTextBox.Enabled = true;
testItemsButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (string.IsNullOrEmpty(rootTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Root tag field is empty";
}
if (string.IsNullOrEmpty(testTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Test tag field is empty";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.RootTag != rootTagTextBox.Text)
{
config.RootTag = rootTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.TestTag != testTagTextBox.Text)
{
config.TestTag = testTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.TestItems != testItems)
{
config.TestItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
+366
View File
@@ -0,0 +1,366 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Output.FileWriters.Xml
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.cultureLabel = new System.Windows.Forms.Label();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.headerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.rootTagTextBox = new System.Windows.Forms.TextBox();
this.rootTagLabel = new System.Windows.Forms.Label();
this.testTagLabel = new System.Windows.Forms.Label();
this.testTagTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 52);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 55);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 52);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 184);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 181);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 294);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 25;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 97);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 119);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 141);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 94);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 116);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 138);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 73);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 73);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 76);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 160);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 163);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format";
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 204);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 19;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 249);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 22;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// rootTagTextBox
//
this.rootTagTextBox.Enabled = false;
this.rootTagTextBox.Location = new System.Drawing.Point(108, 228);
this.rootTagTextBox.Name = "rootTagTextBox";
this.rootTagTextBox.Size = new System.Drawing.Size(146, 20);
this.rootTagTextBox.TabIndex = 21;
//
// rootTagLabel
//
this.rootTagLabel.AutoSize = true;
this.rootTagLabel.Location = new System.Drawing.Point(17, 231);
this.rootTagLabel.Name = "rootTagLabel";
this.rootTagLabel.Size = new System.Drawing.Size(48, 13);
this.rootTagLabel.TabIndex = 20;
this.rootTagLabel.Text = "Root tag";
//
// testTagLabel
//
this.testTagLabel.AutoSize = true;
this.testTagLabel.Location = new System.Drawing.Point(17, 276);
this.testTagLabel.Name = "testTagLabel";
this.testTagLabel.Size = new System.Drawing.Size(46, 13);
this.testTagLabel.TabIndex = 23;
this.testTagLabel.Text = "Test tag";
//
// testTagTextBox
//
this.testTagTextBox.Enabled = false;
this.testTagTextBox.Location = new System.Drawing.Point(108, 273);
this.testTagTextBox.Name = "testTagTextBox";
this.testTagTextBox.Size = new System.Drawing.Size(146, 20);
this.testTagTextBox.TabIndex = 24;
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.testTagLabel);
this.Controls.Add(this.testTagTextBox);
this.Controls.Add(this.rootTagLabel);
this.Controls.Add(this.rootTagTextBox);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.TextBox rootTagTextBox;
private System.Windows.Forms.Label rootTagLabel;
private System.Windows.Forms.Label testTagLabel;
private System.Windows.Forms.TextBox testTagTextBox;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.XmlBatch
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Writer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Writer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Writer(cfg); }
public IComponentCfg DefaultConfig() { return new WriterCfg("FileWriter.XmlBatch", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
IComponentCfg cfg = ComponentCfgBase.CreateFromDbEntity(WriterCfg.Serializer, component, this);
(cfg as WriterCfg).MetersKind = Config.Entities.MetersKind.Single;
return cfg;
}
}
}
@@ -0,0 +1,316 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using log4net;
using Config.Entities;
using TBF.Rig;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.XmlBatch
{
public class Writer : ComponentBase, IOperation, GenericDevices.IResultsWriter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Writer));
public override string ToString() { return string.Format("Output.FileWriters.Enhanced({0})", Cfg.ToString(1)); }
readonly WriterCfg writerCfg;
///
/// Items to print
///
string header;
string rootTag;
string meterTag;
string testTag;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> meterItems;
IList<Results.WMeterRsltItemSpec> testItems;
Results.Entities.Batch batch;
bool abort;
public Writer() {}
public Writer(Generic.IComponentCfg cfg)
: base(cfg)
{
writerCfg = cfg as WriterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
/// TODO: Apply culture info
rootTag = writerCfg.RootTag;
meterTag = writerCfg.MeterTag;
testTag = writerCfg.TestTag;
header = string.IsNullOrEmpty(writerCfg.Header) ? string.Empty : writerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.CommonItems);
meterItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.MeterItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(writerCfg.TestItems); /// TestID info will be overwritten later on
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
WriterCfg newCfg = args.Cfg as WriterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
writerCfg.DestinationPath = newCfg.DestinationPath;
writerCfg.DestinationPath2 = newCfg.DestinationPath2;
writerCfg.YearFolders = newCfg.YearFolders;
writerCfg.MonthFolders = newCfg.MonthFolders;
writerCfg.DayFolders = newCfg.DayFolders;
writerCfg.FileNameFormat = newCfg.FileNameFormat;
writerCfg.Culture = newCfg.Culture;
writerCfg.Header = newCfg.Header;
writerCfg.RootTag = newCfg.RootTag;
writerCfg.MeterTag = newCfg.MeterTag;
writerCfg.TestTag = newCfg.TestTag;
writerCfg.CommonItems = newCfg.CommonItems;
writerCfg.MeterItems = newCfg.MeterItems;
writerCfg.TestItems = newCfg.TestItems;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Returns a file name derived from a DateTime structure.
/// Creates directories on this path as a side effect.
/// </summary>
/// <param name="time">Date and time</param>
/// <returns>File name</returns>
string GetFilename(string destinationPath, DateTime time)
{
string directory = destinationPath; /// Ends with "\\";
switch (writerCfg.YearFolders)
{
case YearFolders.FourDigit:
directory = string.Format("{0}{1:yyyy}\\", directory, time);
break;
case YearFolders.TwoDigit:
directory = string.Format("{0}{1:yy}\\", directory, time);
break;
}
switch (writerCfg.MonthFolders)
{
case MonthFolders.Name:
{
string monthStr;
switch (time.Month)
{
default:
case 1: monthStr = "January"; break;
case 2: monthStr = "February"; break;
case 3: monthStr = "March"; break;
case 4: monthStr = "April"; break;
case 5: monthStr = "May"; break;
case 6: monthStr = "June"; break;
case 7: monthStr = "July"; break;
case 8: monthStr = "August"; break;
case 9: monthStr = "September"; break;
case 10: monthStr = "October"; break;
case 11: monthStr = "November"; break;
case 12: monthStr = "December"; break;
}
directory = string.Format("{0}{1}\\", directory, monthStr);
break;
}
case MonthFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
break;
case MonthFolders.TwoDigit:
directory = string.Format("{0}{1:MM}\\", directory, time);
break;
}
switch (writerCfg.DayFolders)
{
case DayFolders.Digit:
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
break;
case DayFolders.TwoDigit:
directory = string.Format("{0}{1:dd}\\", directory, time);
break;
}
Directory.CreateDirectory(directory);
try
{
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
return directory + string.Format(writerCfg.FileNameFormat, time);
}
catch
{
return string.Format("{0}{1:yyMMdd-HHmm}.xml", directory, time);
}
}
/// <summary>
/// Writes the test cycle results into a file
/// Events:
/// Event.ResultsWritten
/// Event.Busy
/// </summary>
/// <param name="batch">Results to write into files</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (writerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(writerCfg.Culture.ToString());
}
WriteRslts(batch, writerCfg.DestinationPath);
WriteRslts(batch, writerCfg.DestinationPath2);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsWritten</returns>
public Event Run()
{
return Event.ResultsWritten;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void WriteRslts(Results.Entities.Batch batch, string destination)
{
if (string.IsNullOrEmpty(destination)) return;
if (batch.WaterMeters == null || batch.WaterMeters.Count == 0) return;
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteBatch(writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
/// <summary>
/// Write one water meter results
/// </summary>
/// <param name="wmNr">Water meter number (0-based)</param>
void WriteBatch(StreamWriter wr)
{
/// Header
if (!string.IsNullOrEmpty(writerCfg.Header)) wr.Write(header);
wr.WriteLine(string.Format("<{0}>", rootTag));
/// Common items
foreach (var v in commonItems)
{
if (abort) return;
/// Fetch the item and strip color information
string itemText = v.Print(batch.WaterMeters[0]);
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
wr.WriteLine(" <{0}>{1}</{0}>", v.Caption, itemText);
}
foreach (var wm in batch.WaterMeters)
{
wr.WriteLine(string.Format(" <{0}>", meterTag));
/// Meter items
foreach (var v in meterItems)
{
if (abort) return;
/// Fetch the item and strip color information
string itemText = v.Print(wm);
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
wr.WriteLine(" <{0}>{1}</{0}>", v.Caption, itemText);
}
/// Test items
foreach (var mtr in wm.RegularMeterTestRslts())
{
if (abort) return;
if ((mtr != null) && (mtr.Publish() == Config.Entities.Publish.Always))
{
wr.WriteLine(string.Format(" <{0}>", testTag));
for (int i = 0; i < testItems.Count; i++)
{
/// Fetch the item and strip color information
string itemText = testItems[i].Print(wm, mtr.Name());
string[] texts = itemText.Split(new char[] { '|' });
if (texts.Length == 2) { itemText = texts[0]; }
/// Print the item
wr.WriteLine(" <{0}>{1}</{0}>", testItems[i].Caption, itemText);
}
wr.WriteLine(string.Format(" </{0}>", testTag));
}
}
wr.WriteLine(string.Format(" </{0}>", meterTag));
}
/// Footer
wr.WriteLine(string.Format("</{0}>", rootTag));
}
}
}
@@ -0,0 +1,77 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.FileWriters.XmlBatch
{
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new WriterCfgCtrl(); }
public string DestinationPath; /// Directory path into which the results will be saved
public string DestinationPath2; /// Directory path into which the 2nd copy of results will be saved
public YearFolders YearFolders;
public MonthFolders MonthFolders;
public DayFolders DayFolders;
public string FileNameFormat;
public Culture Culture;
public string Header;
public string RootTag;
public string MeterTag;
public string TestTag;
public string[] CommonItems;
public string[] MeterItems;
public string[] TestItems;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
WriterCfg()
{
}
public WriterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
DestinationPath = Path.Combine(Program.HomeDir, "Results", "Xml");
DestinationPath2 = string.Empty;
YearFolders = YearFolders.FourDigit;
MonthFolders = MonthFolders.Digit;
DayFolders = DayFolders.Digit;
FileNameFormat = "{0:yyMMdd-HHmm}.xml";
Culture = Culture.EN;
Header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
RootTag = "Batch";
MeterTag = "Meter";
TestTag = "Test";
}
public string ToString(int i)
{
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Culture={6}",
Name,
DestinationPath,
YearFolders,
MonthFolders,
DayFolders,
FileNameFormat,
Culture);
}
}
}
@@ -0,0 +1,364 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.FileWriters.XmlBatch
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
public bool Compound;
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] meterItems;
string[] testItems;
public WriterCfgCtrl()
{
InitializeComponent();
Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
meterItems = config.MeterItems;
testItems = config.TestItems;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
cultureLabel.Text = "Culture";
headerButton.Text = Strings.Header;
rootTagLabel.Text = "Root tag";
commonItemsButton.Text = "Common items";
meterTagLabel.Text = "Meter tag";
meterItemsButton.Text = "Meter items";
testTagLabel.Text = "Test tag";
testItemsButton.Text = "Test items";
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
destinationTextBox.Text = config.DestinationPath;
destination2TextBox.Text = config.DestinationPath2;
yearFoldersComboBox.Text = config.YearFolders.ToString();
monthFoldersComboBox.Text = config.MonthFolders.ToString();
dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat;
cultureComboBox.Text = config.Culture.ToString();
rootTagTextBox.Text = config.RootTag;
meterTagTextBox.Text = config.MeterTag;
testTagTextBox.Text = config.TestTag;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
destination2TextBox.Enabled = true;
destination2Button.Enabled = true;
yearFoldersComboBox.Enabled = true;
monthFoldersComboBox.Enabled = true;
dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true;
cultureComboBox.Enabled = true;
headerButton.Enabled = true;
rootTagTextBox.Enabled = true;
commonItemsButton.Enabled = true;
meterTagTextBox.Enabled = true;
meterItemsButton.Enabled = true;
testTagTextBox.Enabled = true;
testItemsButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid year folders selection";
}
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid month folders selection";
}
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid day folder selection";
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid culture";
}
if (string.IsNullOrEmpty(rootTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Root tag field is empty";
}
if (string.IsNullOrEmpty(meterTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Meter tag field is empty";
}
if (string.IsNullOrEmpty(testTagTextBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Test tag field is empty";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.DestinationPath2 != destination2TextBox.Text)
{
config.DestinationPath2 = destination2TextBox.Text;
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (YearFolders i = 0; i < YearFolders.Count; i++)
{
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
{
config.YearFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
{
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
{
config.MonthFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
for (DayFolders i = 0; i < DayFolders.Count; i++)
{
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
{
config.DayFolders = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.FileNameFormat != fileNameFmtTextBox.Text)
{
config.FileNameFormat = fileNameFmtTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
if (config.Header != header)
{
config.Header = header;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.RootTag != rootTagTextBox.Text)
{
config.RootTag = rootTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.CommonItems != commonItems)
{
config.CommonItems = commonItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.MeterTag != meterTagTextBox.Text)
{
config.MeterTag = meterTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.MeterItems != meterItems)
{
config.MeterItems = meterItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.TestTag != testTagTextBox.Text)
{
config.TestTag = testTagTextBox.Text;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.TestItems != testItems)
{
config.TestItems = testItems;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Writer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void meterItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(meterItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
meterItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
@@ -0,0 +1,403 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
namespace TBF.Rig.Output.FileWriters.XmlBatch
{
partial class WriterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button();
this.cultureLabel = new System.Windows.Forms.Label();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.headerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button();
this.rootTagTextBox = new System.Windows.Forms.TextBox();
this.rootTagLabel = new System.Windows.Forms.Label();
this.testTagLabel = new System.Windows.Forms.Label();
this.testTagTextBox = new System.Windows.Forms.TextBox();
this.meterTagLabel = new System.Windows.Forms.Label();
this.meterTagTextBox = new System.Windows.Forms.TextBox();
this.meterItemsButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(17, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// destinationTextBox
//
this.destinationTextBox.Enabled = false;
this.destinationTextBox.Location = new System.Drawing.Point(108, 51);
this.destinationTextBox.Name = "destinationTextBox";
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
this.destinationTextBox.TabIndex = 4;
//
// destinationLabel
//
this.destinationLabel.AutoSize = true;
this.destinationLabel.Location = new System.Drawing.Point(17, 54);
this.destinationLabel.Name = "destinationLabel";
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
this.destinationLabel.TabIndex = 3;
this.destinationLabel.Text = "Destination";
//
// destinationButton
//
this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(269, 51);
this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5;
this.destinationButton.Text = "...";
this.destinationButton.UseVisualStyleBackColor = true;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(17, 178);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 17;
this.cultureLabel.Text = "Cullture";
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(108, 174);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(146, 21);
this.cultureComboBox.TabIndex = 18;
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(108, 325);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 25;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// yearFoldersLabel
//
this.yearFoldersLabel.AutoSize = true;
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94);
this.yearFoldersLabel.Name = "yearFoldersLabel";
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
this.yearFoldersLabel.TabIndex = 9;
this.yearFoldersLabel.Text = "Year folders";
//
// monthFoldersLabel
//
this.monthFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 115);
this.monthFoldersLabel.Name = "monthFoldersLabel";
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
this.monthFoldersLabel.TabIndex = 11;
this.monthFoldersLabel.Text = "Month folders";
//
// dayFoldersLabel
//
this.dayFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 136);
this.dayFoldersLabel.Name = "dayFoldersLabel";
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
this.dayFoldersLabel.TabIndex = 13;
this.dayFoldersLabel.Text = "Day folders";
//
// yearFoldersComboBox
//
this.yearFoldersComboBox.Enabled = false;
this.yearFoldersComboBox.FormattingEnabled = true;
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91);
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.yearFoldersComboBox.TabIndex = 10;
//
// monthFoldersComboBox
//
this.monthFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.FormattingEnabled = true;
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 112);
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.monthFoldersComboBox.TabIndex = 12;
//
// dayFoldersComboBox
//
this.dayFoldersComboBox.Enabled = false;
this.dayFoldersComboBox.FormattingEnabled = true;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 133);
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
this.dayFoldersComboBox.TabIndex = 14;
//
// destination2Button
//
this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(269, 71);
this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8;
this.destination2Button.Text = "...";
this.destination2Button.UseVisualStyleBackColor = true;
//
// destination2TextBox
//
this.destination2TextBox.Enabled = false;
this.destination2TextBox.Location = new System.Drawing.Point(108, 71);
this.destination2TextBox.Name = "destination2TextBox";
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
this.destination2TextBox.TabIndex = 7;
//
// destination2Label
//
this.destination2Label.AutoSize = true;
this.destination2Label.Location = new System.Drawing.Point(17, 74);
this.destination2Label.Name = "destination2Label";
this.destination2Label.Size = new System.Drawing.Size(69, 13);
this.destination2Label.TabIndex = 6;
this.destination2Label.Text = "Destination 2";
//
// fileNameFmtTextBox
//
this.fileNameFmtTextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 154);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
this.fileNameFmtTextBox.TabIndex = 16;
//
// fileNameFmtLabel
//
this.fileNameFmtLabel.AutoSize = true;
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 157);
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format";
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(108, 196);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 19;
this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(108, 239);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 22;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// rootTagTextBox
//
this.rootTagTextBox.Enabled = false;
this.rootTagTextBox.Location = new System.Drawing.Point(108, 219);
this.rootTagTextBox.Name = "rootTagTextBox";
this.rootTagTextBox.Size = new System.Drawing.Size(146, 20);
this.rootTagTextBox.TabIndex = 21;
//
// rootTagLabel
//
this.rootTagLabel.AutoSize = true;
this.rootTagLabel.Location = new System.Drawing.Point(17, 222);
this.rootTagLabel.Name = "rootTagLabel";
this.rootTagLabel.Size = new System.Drawing.Size(48, 13);
this.rootTagLabel.TabIndex = 20;
this.rootTagLabel.Text = "Root tag";
//
// testTagLabel
//
this.testTagLabel.AutoSize = true;
this.testTagLabel.Location = new System.Drawing.Point(17, 308);
this.testTagLabel.Name = "testTagLabel";
this.testTagLabel.Size = new System.Drawing.Size(46, 13);
this.testTagLabel.TabIndex = 23;
this.testTagLabel.Text = "Test tag";
//
// testTagTextBox
//
this.testTagTextBox.Enabled = false;
this.testTagTextBox.Location = new System.Drawing.Point(108, 305);
this.testTagTextBox.Name = "testTagTextBox";
this.testTagTextBox.Size = new System.Drawing.Size(146, 20);
this.testTagTextBox.TabIndex = 24;
//
// meterTagLabel
//
this.meterTagLabel.AutoSize = true;
this.meterTagLabel.Location = new System.Drawing.Point(17, 265);
this.meterTagLabel.Name = "meterTagLabel";
this.meterTagLabel.Size = new System.Drawing.Size(52, 13);
this.meterTagLabel.TabIndex = 26;
this.meterTagLabel.Text = "Meter tag";
//
// meterTagTextBox
//
this.meterTagTextBox.Enabled = false;
this.meterTagTextBox.Location = new System.Drawing.Point(108, 262);
this.meterTagTextBox.Name = "meterTagTextBox";
this.meterTagTextBox.Size = new System.Drawing.Size(146, 20);
this.meterTagTextBox.TabIndex = 27;
//
// meterItemsButton
//
this.meterItemsButton.Enabled = false;
this.meterItemsButton.Location = new System.Drawing.Point(108, 282);
this.meterItemsButton.Name = "meterItemsButton";
this.meterItemsButton.Size = new System.Drawing.Size(146, 23);
this.meterItemsButton.TabIndex = 28;
this.meterItemsButton.Text = "Meter items";
this.meterItemsButton.UseVisualStyleBackColor = true;
this.meterItemsButton.Click += new System.EventHandler(this.meterItemsButton_Click);
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.meterTagLabel);
this.Controls.Add(this.meterTagTextBox);
this.Controls.Add(this.meterItemsButton);
this.Controls.Add(this.testTagLabel);
this.Controls.Add(this.testTagTextBox);
this.Controls.Add(this.rootTagLabel);
this.Controls.Add(this.rootTagTextBox);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox destinationTextBox;
private System.Windows.Forms.Label destinationLabel;
private System.Windows.Forms.Button destinationButton;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label yearFoldersLabel;
private System.Windows.Forms.Label monthFoldersLabel;
private System.Windows.Forms.Label dayFoldersLabel;
private System.Windows.Forms.ComboBox yearFoldersComboBox;
private System.Windows.Forms.ComboBox monthFoldersComboBox;
private System.Windows.Forms.ComboBox dayFoldersComboBox;
private System.Windows.Forms.Button destination2Button;
private System.Windows.Forms.TextBox destination2TextBox;
private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.TextBox rootTagTextBox;
private System.Windows.Forms.Label rootTagLabel;
private System.Windows.Forms.Label testTagLabel;
private System.Windows.Forms.TextBox testTagTextBox;
private System.Windows.Forms.Label meterTagLabel;
private System.Windows.Forms.TextBox meterTagTextBox;
private System.Windows.Forms.Button meterItemsButton;
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+85
View File
@@ -0,0 +1,85 @@
namespace TBF.Rig.Output
{
partial class HeaderFooterDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.textBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(393, 169);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 34);
this.okButton.TabIndex = 1;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(484, 169);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 34);
this.cancelButton.TabIndex = 2;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// textBox
//
this.textBox.Location = new System.Drawing.Point(12, 12);
this.textBox.Multiline = true;
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(547, 142);
this.textBox.TabIndex = 0;
//
// HeaderFooterDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(571, 216);
this.Controls.Add(this.textBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Name = "HeaderFooterDlg";
this.Text = "Enter text";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.TextBox textBox;
}
}
+29
View File
@@ -0,0 +1,29 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Windows.Forms;
using TBF.Resources;
namespace TBF.Rig.Output
{
public partial class HeaderFooterDlg : Form
{
public string EditedText
{
set { textBox.Text = value; }
get { return textBox.Text; }
}
public HeaderFooterDlg()
{
InitializeComponent();
}
public HeaderFooterDlg(bool isHeader, string text)
: this()
{
Text = isHeader ? Strings.Header : Strings.Footer;
textBox.Text = text;
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.Enhanced
{
public class FactoryCompound : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Compound"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Printer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.Enhanced.Compound", this, Config.Entities.MetersKind.Combined); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.Enhanced
{
public class FactoryHeatMeters : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".HeatMeters"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Printer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.Enhanced.HeatMeters", this, Config.Entities.MetersKind.HeatMeter); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this);
}
}
}
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.Enhanced
{
public class FactorySingle : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8) + ".Single"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Printer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
public IComponentCfg DefaultConfig() { return new PrinterCfg("Printer.Enhanced.Single", this, Config.Entities.MetersKind.Single); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this);
}
}
}
+211
View File
@@ -0,0 +1,211 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Globalization;
using System.Threading;
using Results.Output.Printers.Enhanced;
using log4net;
namespace TBF.Rig.Output.Printers.Enhanced
{
public class Printer : ComponentBase, IOperation, GenericDevices.IResultsPrinter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Printer));
public override string ToString() { return string.Format("Output.Printers.Enhanced({0})", Cfg.ToString(1)); }
readonly PrinterCfg printerCfg;
public bool SupressPrinting { get { return printerCfg.SupressPrinting; } }
/// <summary> Data to print </summary>
Results.Entities.Batch batch;
///
/// Items to print
///
string header;
IList<Results.WMeterRsltItemSpec> commonItems;
IList<Results.WMeterRsltItemSpec> testItems;
string footer;
public Printer() { }
public Printer(Generic.IComponentCfg cfg)
: base(cfg)
{
printerCfg = cfg as PrinterCfg;
ApplyConfig();
log.Warn(this.ToString());
}
void ApplyConfig()
{
header = string.IsNullOrEmpty(printerCfg.Header) ? string.Empty : printerCfg.Header.Replace("~", Environment.NewLine);
commonItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.CommonItems);
testItems = Results.WMeterRsltItemSpec.FromStrArray(printerCfg.SelectedItems); /// TestID info will be overwritten later on
footer = string.IsNullOrEmpty(printerCfg.Footer) ? string.Empty : printerCfg.Footer.Replace("~", Environment.NewLine);
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
PrinterCfg newCfg = args.Cfg as PrinterCfg;
if (newCfg != null && newCfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
printerCfg.PageOrientation = newCfg.PageOrientation;
printerCfg.Template = newCfg.Template;
printerCfg.TopMargin = newCfg.TopMargin;
printerCfg.BottomMargin = newCfg.BottomMargin;
printerCfg.LeftMargin = newCfg.LeftMargin;
printerCfg.TitFntFml = newCfg.TitFntFml;
printerCfg.TitFntSz = newCfg.TitFntSz;
printerCfg.TitFntSty = newCfg.TitFntSty;
printerCfg.HdrFntFml = newCfg.HdrFntFml;
printerCfg.HdrFntSz = newCfg.HdrFntSz;
printerCfg.HdrFntSty = newCfg.HdrFntSty;
printerCfg.BodyFntFml = newCfg.BodyFntFml;
printerCfg.BodyFntSz = newCfg.BodyFntSz;
printerCfg.BodyFntSty = newCfg.BodyFntSty;
printerCfg.FooterFntFml = newCfg.FooterFntFml;
printerCfg.FooterFntSz = newCfg.FooterFntSz;
printerCfg.FooterFntSty = newCfg.FooterFntSty;
printerCfg.GoodOnly = newCfg.GoodOnly;
printerCfg.SupressPrinting = newCfg.SupressPrinting;
printerCfg.Culture = newCfg.Culture;
printerCfg.CommonItems = newCfg.CommonItems;
printerCfg.SelectedItems = newCfg.SelectedItems;
printerCfg.Header = newCfg.Header;
printerCfg.Footer = newCfg.Footer;
printerCfg.DocName = newCfg.DocName;
printerCfg.NrOfCopies = newCfg.NrOfCopies;
printerCfg.BarcodeType = newCfg.BarcodeType;
printerCfg.BarcodeWidth = newCfg.BarcodeWidth;
printerCfg.BarcodeHeight = newCfg.BarcodeHeight;
ApplyConfig();
}
}
};
}
#endregion Configuration Change Handling
/// <summary>
/// Prints the test cycle results, Events: Event.ResultsPrinted
/// </summary>
/// <param name="batch">Batch results to print</param>
/// <returns>Reference to the operation</returns>
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
{
this.batch = batch;
return this;
}
/// <summary>Start this operation</summary>
public void Start()
{
CultureInfo oriCulture = Thread.CurrentThread.CurrentCulture;
if (printerCfg.Culture != Culture.system)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(printerCfg.Culture.ToString());
}
string documentName;
try
{
if (string.IsNullOrEmpty(printerCfg.DocName)) throw (new Exception());
documentName = string.Format(printerCfg.DocName, batch.StartTime, batch.EndTime, batch.BatchNr);
}
catch
{
documentName = string.Format("{0:yyyyMMdd-HHmm}", batch.EndTime);
}
PrintResults(batch, documentName);
Thread.CurrentThread.CurrentCulture = oriCulture;
}
/// <summary>Run this operation</summary>
/// <returns>Event.ResultsPrinted</returns>
public Event Run()
{
return Event.ResultsPrinted;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
void PrintResults(Results.Entities.Batch batch, string documentName)
{
if (batch.WaterMeters.Count > 0)
{
EnhancedPrinterCfg cfg = new EnhancedPrinterCfg
{
PageOrientation = printerCfg.PageOrientation,
Template = printerCfg.Template,
TopMargin = printerCfg.TopMargin,
BottomMargin = printerCfg.BottomMargin,
LeftMargin = printerCfg.LeftMargin,
TitFntFml = printerCfg.TitFntFml,
TitFntSz = printerCfg.TitFntSz,
TitFntSty = printerCfg.TitFntSty,
HdrFntFml = printerCfg.HdrFntFml,
HdrFntSz = printerCfg.HdrFntSz,
HdrFntSty = printerCfg.HdrFntSty,
BodyFntFml = printerCfg.BodyFntFml,
BodyFntSz = printerCfg.BodyFntSz,
BodyFntSty = printerCfg.BodyFntSty,
FooterFntFml = printerCfg.FooterFntFml,
FooterFntSz = printerCfg.FooterFntSz,
FooterFntSty = printerCfg.FooterFntSty,
GoodOnly = printerCfg.GoodOnly,
SupressPrinting = printerCfg.SupressPrinting,
CultureInfo = (printerCfg.Culture == Culture.system) ? Thread.CurrentThread.CurrentCulture : new CultureInfo(printerCfg.Culture.ToString()),
Header = printerCfg.Header,
CommonItems = printerCfg.CommonItems,
TestItems = printerCfg.SelectedItems,
Footer = printerCfg.Footer,
BarcodeType = printerCfg.BarcodeType,
BarcodeWidth = printerCfg.BarcodeWidth,
BarcodeHeight = printerCfg.BarcodeHeight,
};
for (int i = 1; i <= printerCfg.NrOfCopies; i++)
{
string docName = string.Format(((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}-{1}"), documentName, i);
new Results.Output.Printers.Enhanced.EnhancedPrintDocument(batch, cfg, docName).Print();
}
}
}
}
}
@@ -0,0 +1,105 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.Enhanced
{
public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PrinterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new PrinterCfgCtrl(); }
///
/// Serialized parameters
///
public PageOrientation PageOrientation;
public string Template;
public int TopMargin;
public int BottomMargin;
public int LeftMargin;
public string TitFntFml;
public string HdrFntFml;
public string BodyFntFml;
public string FooterFntFml;
public int TitFntSz;
public int HdrFntSz;
public int BodyFntSz;
public int FooterFntSz;
public int TitFntSty;
public int HdrFntSty;
public int BodyFntSty;
public int FooterFntSty;
public bool GoodOnly;
public bool SupressPrinting; /// Bypass printing when true
public Culture Culture;
public string[] CommonItems;
public string[] SelectedItems;
public string Header; /// =Title
public string Footer;
public string DocName;
public int NrOfCopies;
public Results.Output.Printers.BarcodeType BarcodeType;
public int BarcodeWidth;
public int BarcodeHeight;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
/// Private parameterless constructor invoked by all other (public) constructors
PrinterCfg()
{
}
public PrinterCfg(string name, IComponentFactory factory, Config.Entities.MetersKind metersKind)
: this()
{
Name = name;
Factory = factory;
MetersKind = metersKind;
ParentName = string.Empty;
Template = string.Empty;
PageOrientation = PageOrientation.Portrait;
TopMargin = 100;
BottomMargin = 100;
LeftMargin = 100;
TitFntFml = "Arial";
TitFntSz = 18;
TitFntSty = 1;
HdrFntFml = "Arial";
HdrFntSz = 10;
HdrFntSty = 0;
BodyFntFml = "Arial";
BodyFntSz = 10;
BodyFntSty = 0;
FooterFntFml = "Arial";
FooterFntSz = 10;
FooterFntSty = 0;
GoodOnly = false;
SupressPrinting = false;
Header = string.Empty;
Footer = string.Empty;
DocName = string.Empty;
NrOfCopies = 1;
}
public string ToString(int i)
{
return string.Format("Name={0}, Orientation={1}, Margins T={2} B={3} L={4}, SupressPrinting={5}",
Name,
PageOrientation,
TopMargin,
BottomMargin,
LeftMargin,
SupressPrinting ? "yes" : "no"
);
}
}
}
@@ -0,0 +1,672 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
namespace TBF.Rig.Output.Printers.Enhanced
{
partial class PrinterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.supressPrintingCheckBox = new System.Windows.Forms.CheckBox();
this.orientationLabel = new System.Windows.Forms.Label();
this.orientationComboBox = new System.Windows.Forms.ComboBox();
this.topMarginTextBox = new System.Windows.Forms.TextBox();
this.topMarginLabel = new System.Windows.Forms.Label();
this.leftMarginTextBox = new System.Windows.Forms.TextBox();
this.bottomMarginTextBox = new System.Windows.Forms.TextBox();
this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label();
this.commonItemsButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button();
this.headerButton = new System.Windows.Forms.Button();
this.testItemsButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.docNameTextBox = new System.Windows.Forms.TextBox();
this.docNameLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.footerItalicCheckBox = new System.Windows.Forms.CheckBox();
this.footerBoldCheckBox = new System.Windows.Forms.CheckBox();
this.footerFontSizeTextBox = new System.Windows.Forms.TextBox();
this.footerFontFamilyComboBox = new System.Windows.Forms.ComboBox();
this.footerFontLabel = new System.Windows.Forms.Label();
this.bodyItalicCheckBox = new System.Windows.Forms.CheckBox();
this.bodyBoldCheckBox = new System.Windows.Forms.CheckBox();
this.headerItalicCheckBox = new System.Windows.Forms.CheckBox();
this.headerBoldCheckBox = new System.Windows.Forms.CheckBox();
this.titleItalicCheckBox = new System.Windows.Forms.CheckBox();
this.titleBoldCheckBox = new System.Windows.Forms.CheckBox();
this.bodyFontSizeTextBox = new System.Windows.Forms.TextBox();
this.headerFontSizeTextBox = new System.Windows.Forms.TextBox();
this.titleFontSizeTextBox = new System.Windows.Forms.TextBox();
this.bodyFontFamilyComboBox = new System.Windows.Forms.ComboBox();
this.bodyFontLabel = new System.Windows.Forms.Label();
this.headerFontFamilyComboBox = new System.Windows.Forms.ComboBox();
this.titleFontFamilyComboBox = new System.Windows.Forms.ComboBox();
this.titleFontLabel = new System.Windows.Forms.Label();
this.headerFontLabel = new System.Windows.Forms.Label();
this.templateTextBox = new System.Windows.Forms.TextBox();
this.templateLabel = new System.Windows.Forms.Label();
this.nrOfCopiesTextBox = new System.Windows.Forms.TextBox();
this.nrOfCopiesLabel = new System.Windows.Forms.Label();
this.barcodeTypeComboBox = new System.Windows.Forms.ComboBox();
this.barcodeLabel = new System.Windows.Forms.Label();
this.barcodeWidthTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.barcodeHeightTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(142, 39);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(218, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(16, 42);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(139, 16);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// supressPrintingCheckBox
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(91, 307);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 33;
this.supressPrintingCheckBox.Text = "Supress printing";
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
//
// orientationLabel
//
this.orientationLabel.AutoSize = true;
this.orientationLabel.Location = new System.Drawing.Point(16, 86);
this.orientationLabel.Name = "orientationLabel";
this.orientationLabel.Size = new System.Drawing.Size(84, 13);
this.orientationLabel.TabIndex = 5;
this.orientationLabel.Text = "Page orientation";
//
// orientationComboBox
//
this.orientationComboBox.Enabled = false;
this.orientationComboBox.FormattingEnabled = true;
this.orientationComboBox.Location = new System.Drawing.Point(142, 83);
this.orientationComboBox.Name = "orientationComboBox";
this.orientationComboBox.Size = new System.Drawing.Size(146, 21);
this.orientationComboBox.TabIndex = 6;
//
// topMarginTextBox
//
this.topMarginTextBox.Enabled = false;
this.topMarginTextBox.Location = new System.Drawing.Point(142, 106);
this.topMarginTextBox.Name = "topMarginTextBox";
this.topMarginTextBox.Size = new System.Drawing.Size(44, 20);
this.topMarginTextBox.TabIndex = 8;
//
// topMarginLabel
//
this.topMarginLabel.AutoSize = true;
this.topMarginLabel.Location = new System.Drawing.Point(16, 109);
this.topMarginLabel.Name = "topMarginLabel";
this.topMarginLabel.Size = new System.Drawing.Size(116, 13);
this.topMarginLabel.TabIndex = 7;
this.topMarginLabel.Text = "Top/bottom/left margin";
//
// leftMarginTextBox
//
this.leftMarginTextBox.Enabled = false;
this.leftMarginTextBox.Location = new System.Drawing.Point(244, 106);
this.leftMarginTextBox.Name = "leftMarginTextBox";
this.leftMarginTextBox.Size = new System.Drawing.Size(44, 20);
this.leftMarginTextBox.TabIndex = 10;
//
// bottomMarginTextBox
//
this.bottomMarginTextBox.Enabled = false;
this.bottomMarginTextBox.Location = new System.Drawing.Point(193, 106);
this.bottomMarginTextBox.Name = "bottomMarginTextBox";
this.bottomMarginTextBox.Size = new System.Drawing.Size(44, 20);
this.bottomMarginTextBox.TabIndex = 9;
//
// cultureComboBox
//
this.cultureComboBox.Enabled = false;
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(142, 215);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(218, 21);
this.cultureComboBox.TabIndex = 32;
//
// cultureLabel
//
this.cultureLabel.AutoSize = true;
this.cultureLabel.Location = new System.Drawing.Point(16, 218);
this.cultureLabel.Name = "cultureLabel";
this.cultureLabel.Size = new System.Drawing.Size(42, 13);
this.cultureLabel.TabIndex = 31;
this.cultureLabel.Text = "Cullture";
//
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(193, 259);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(167, 23);
this.commonItemsButton.TabIndex = 36;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
//
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(193, 303);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(167, 23);
this.footerButton.TabIndex = 38;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
//
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(193, 237);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(167, 23);
this.headerButton.TabIndex = 35;
this.headerButton.Text = "Title";
this.headerButton.UseVisualStyleBackColor = true;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
//
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(193, 281);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(167, 23);
this.testItemsButton.TabIndex = 37;
this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label1.Location = new System.Drawing.Point(296, 114);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 13);
this.label1.TabIndex = 41;
this.label1.Text = "Bold";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label2.Location = new System.Drawing.Point(330, 114);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(24, 13);
this.label2.TabIndex = 42;
this.label2.Text = "Ital.";
//
// docNameTextBox
//
this.docNameTextBox.Enabled = false;
this.docNameTextBox.Location = new System.Drawing.Point(193, 328);
this.docNameTextBox.Name = "docNameTextBox";
this.docNameTextBox.Size = new System.Drawing.Size(167, 20);
this.docNameTextBox.TabIndex = 40;
//
// docNameLabel
//
this.docNameLabel.AutoSize = true;
this.docNameLabel.Location = new System.Drawing.Point(16, 331);
this.docNameLabel.Name = "docNameLabel";
this.docNameLabel.Size = new System.Drawing.Size(175, 13);
this.docNameLabel.TabIndex = 39;
this.docNameLabel.Text = "Doc.name (0=start 1-end, 2=batch):";
//
// goodOnlyCheckBox
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Enabled = false;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(15, 307);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 34;
this.goodOnlyCheckBox.Text = "Good only";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
//
// footerItalicCheckBox
//
this.footerItalicCheckBox.AutoSize = true;
this.footerItalicCheckBox.Enabled = false;
this.footerItalicCheckBox.Location = new System.Drawing.Point(334, 196);
this.footerItalicCheckBox.Name = "footerItalicCheckBox";
this.footerItalicCheckBox.Size = new System.Drawing.Size(15, 14);
this.footerItalicCheckBox.TabIndex = 30;
this.footerItalicCheckBox.UseVisualStyleBackColor = true;
//
// footerBoldCheckBox
//
this.footerBoldCheckBox.AutoSize = true;
this.footerBoldCheckBox.Enabled = false;
this.footerBoldCheckBox.Location = new System.Drawing.Point(306, 196);
this.footerBoldCheckBox.Name = "footerBoldCheckBox";
this.footerBoldCheckBox.Size = new System.Drawing.Size(15, 14);
this.footerBoldCheckBox.TabIndex = 29;
this.footerBoldCheckBox.UseVisualStyleBackColor = true;
//
// footerFontSizeTextBox
//
this.footerFontSizeTextBox.Enabled = false;
this.footerFontSizeTextBox.Location = new System.Drawing.Point(258, 193);
this.footerFontSizeTextBox.Name = "footerFontSizeTextBox";
this.footerFontSizeTextBox.Size = new System.Drawing.Size(29, 20);
this.footerFontSizeTextBox.TabIndex = 28;
//
// footerFontFamilyComboBox
//
this.footerFontFamilyComboBox.Enabled = false;
this.footerFontFamilyComboBox.FormattingEnabled = true;
this.footerFontFamilyComboBox.Location = new System.Drawing.Point(142, 193);
this.footerFontFamilyComboBox.Name = "footerFontFamilyComboBox";
this.footerFontFamilyComboBox.Size = new System.Drawing.Size(110, 21);
this.footerFontFamilyComboBox.TabIndex = 27;
//
// footerFontLabel
//
this.footerFontLabel.AutoSize = true;
this.footerFontLabel.Location = new System.Drawing.Point(16, 196);
this.footerFontLabel.Name = "footerFontLabel";
this.footerFontLabel.Size = new System.Drawing.Size(107, 13);
this.footerFontLabel.TabIndex = 26;
this.footerFontLabel.Text = "Footer font/size/style";
//
// bodyItalicCheckBox
//
this.bodyItalicCheckBox.AutoSize = true;
this.bodyItalicCheckBox.Enabled = false;
this.bodyItalicCheckBox.Location = new System.Drawing.Point(334, 174);
this.bodyItalicCheckBox.Name = "bodyItalicCheckBox";
this.bodyItalicCheckBox.Size = new System.Drawing.Size(15, 14);
this.bodyItalicCheckBox.TabIndex = 25;
this.bodyItalicCheckBox.UseVisualStyleBackColor = true;
//
// bodyBoldCheckBox
//
this.bodyBoldCheckBox.AutoSize = true;
this.bodyBoldCheckBox.Enabled = false;
this.bodyBoldCheckBox.Location = new System.Drawing.Point(306, 174);
this.bodyBoldCheckBox.Name = "bodyBoldCheckBox";
this.bodyBoldCheckBox.Size = new System.Drawing.Size(15, 14);
this.bodyBoldCheckBox.TabIndex = 24;
this.bodyBoldCheckBox.UseVisualStyleBackColor = true;
//
// headerItalicCheckBox
//
this.headerItalicCheckBox.AutoSize = true;
this.headerItalicCheckBox.Enabled = false;
this.headerItalicCheckBox.Location = new System.Drawing.Point(334, 152);
this.headerItalicCheckBox.Name = "headerItalicCheckBox";
this.headerItalicCheckBox.Size = new System.Drawing.Size(15, 14);
this.headerItalicCheckBox.TabIndex = 20;
this.headerItalicCheckBox.UseVisualStyleBackColor = true;
//
// headerBoldCheckBox
//
this.headerBoldCheckBox.AutoSize = true;
this.headerBoldCheckBox.Enabled = false;
this.headerBoldCheckBox.Location = new System.Drawing.Point(306, 152);
this.headerBoldCheckBox.Name = "headerBoldCheckBox";
this.headerBoldCheckBox.Size = new System.Drawing.Size(15, 14);
this.headerBoldCheckBox.TabIndex = 19;
this.headerBoldCheckBox.UseVisualStyleBackColor = true;
//
// titleItalicCheckBox
//
this.titleItalicCheckBox.AutoSize = true;
this.titleItalicCheckBox.Enabled = false;
this.titleItalicCheckBox.Location = new System.Drawing.Point(334, 130);
this.titleItalicCheckBox.Name = "titleItalicCheckBox";
this.titleItalicCheckBox.Size = new System.Drawing.Size(15, 14);
this.titleItalicCheckBox.TabIndex = 15;
this.titleItalicCheckBox.UseVisualStyleBackColor = true;
//
// titleBoldCheckBox
//
this.titleBoldCheckBox.AutoSize = true;
this.titleBoldCheckBox.Enabled = false;
this.titleBoldCheckBox.Location = new System.Drawing.Point(306, 130);
this.titleBoldCheckBox.Name = "titleBoldCheckBox";
this.titleBoldCheckBox.Size = new System.Drawing.Size(15, 14);
this.titleBoldCheckBox.TabIndex = 14;
this.titleBoldCheckBox.UseVisualStyleBackColor = true;
//
// bodyFontSizeTextBox
//
this.bodyFontSizeTextBox.Enabled = false;
this.bodyFontSizeTextBox.Location = new System.Drawing.Point(258, 171);
this.bodyFontSizeTextBox.Name = "bodyFontSizeTextBox";
this.bodyFontSizeTextBox.Size = new System.Drawing.Size(29, 20);
this.bodyFontSizeTextBox.TabIndex = 23;
//
// headerFontSizeTextBox
//
this.headerFontSizeTextBox.Enabled = false;
this.headerFontSizeTextBox.Location = new System.Drawing.Point(258, 149);
this.headerFontSizeTextBox.Name = "headerFontSizeTextBox";
this.headerFontSizeTextBox.Size = new System.Drawing.Size(30, 20);
this.headerFontSizeTextBox.TabIndex = 18;
//
// titleFontSizeTextBox
//
this.titleFontSizeTextBox.Enabled = false;
this.titleFontSizeTextBox.Location = new System.Drawing.Point(258, 127);
this.titleFontSizeTextBox.Name = "titleFontSizeTextBox";
this.titleFontSizeTextBox.Size = new System.Drawing.Size(30, 20);
this.titleFontSizeTextBox.TabIndex = 13;
//
// bodyFontFamilyComboBox
//
this.bodyFontFamilyComboBox.Enabled = false;
this.bodyFontFamilyComboBox.FormattingEnabled = true;
this.bodyFontFamilyComboBox.Location = new System.Drawing.Point(142, 171);
this.bodyFontFamilyComboBox.Name = "bodyFontFamilyComboBox";
this.bodyFontFamilyComboBox.Size = new System.Drawing.Size(110, 21);
this.bodyFontFamilyComboBox.TabIndex = 22;
//
// bodyFontLabel
//
this.bodyFontLabel.AutoSize = true;
this.bodyFontLabel.Location = new System.Drawing.Point(16, 174);
this.bodyFontLabel.Name = "bodyFontLabel";
this.bodyFontLabel.Size = new System.Drawing.Size(101, 13);
this.bodyFontLabel.TabIndex = 21;
this.bodyFontLabel.Text = "Body font/size/style";
//
// headerFontFamilyComboBox
//
this.headerFontFamilyComboBox.Enabled = false;
this.headerFontFamilyComboBox.FormattingEnabled = true;
this.headerFontFamilyComboBox.Location = new System.Drawing.Point(142, 149);
this.headerFontFamilyComboBox.Name = "headerFontFamilyComboBox";
this.headerFontFamilyComboBox.Size = new System.Drawing.Size(110, 21);
this.headerFontFamilyComboBox.TabIndex = 17;
//
// titleFontFamilyComboBox
//
this.titleFontFamilyComboBox.Enabled = false;
this.titleFontFamilyComboBox.FormattingEnabled = true;
this.titleFontFamilyComboBox.Location = new System.Drawing.Point(142, 127);
this.titleFontFamilyComboBox.Name = "titleFontFamilyComboBox";
this.titleFontFamilyComboBox.Size = new System.Drawing.Size(110, 21);
this.titleFontFamilyComboBox.TabIndex = 12;
//
// titleFontLabel
//
this.titleFontLabel.AutoSize = true;
this.titleFontLabel.Location = new System.Drawing.Point(16, 130);
this.titleFontLabel.Name = "titleFontLabel";
this.titleFontLabel.Size = new System.Drawing.Size(97, 13);
this.titleFontLabel.TabIndex = 11;
this.titleFontLabel.Text = "Title font/size/style";
//
// headerFontLabel
//
this.headerFontLabel.AutoSize = true;
this.headerFontLabel.Location = new System.Drawing.Point(16, 152);
this.headerFontLabel.Name = "headerFontLabel";
this.headerFontLabel.Size = new System.Drawing.Size(112, 13);
this.headerFontLabel.TabIndex = 16;
this.headerFontLabel.Text = "Header font/size/style";
//
// templateTextBox
//
this.templateTextBox.Enabled = false;
this.templateTextBox.Location = new System.Drawing.Point(142, 61);
this.templateTextBox.Name = "templateTextBox";
this.templateTextBox.Size = new System.Drawing.Size(218, 20);
this.templateTextBox.TabIndex = 4;
//
// templateLabel
//
this.templateLabel.AutoSize = true;
this.templateLabel.Location = new System.Drawing.Point(16, 64);
this.templateLabel.Name = "templateLabel";
this.templateLabel.Size = new System.Drawing.Size(51, 13);
this.templateLabel.TabIndex = 3;
this.templateLabel.Text = "Template";
//
// nrOfCopiesTextBox
//
this.nrOfCopiesTextBox.Enabled = false;
this.nrOfCopiesTextBox.Location = new System.Drawing.Point(340, 83);
this.nrOfCopiesTextBox.Name = "nrOfCopiesTextBox";
this.nrOfCopiesTextBox.Size = new System.Drawing.Size(20, 20);
this.nrOfCopiesTextBox.TabIndex = 43;
//
// nrOfCopiesLabel
//
this.nrOfCopiesLabel.AutoSize = true;
this.nrOfCopiesLabel.Location = new System.Drawing.Point(291, 86);
this.nrOfCopiesLabel.Name = "nrOfCopiesLabel";
this.nrOfCopiesLabel.Size = new System.Drawing.Size(48, 13);
this.nrOfCopiesLabel.TabIndex = 44;
this.nrOfCopiesLabel.Text = "# copies";
//
// barcodeTypeComboBox
//
this.barcodeTypeComboBox.Enabled = false;
this.barcodeTypeComboBox.FormattingEnabled = true;
this.barcodeTypeComboBox.Location = new System.Drawing.Point(19, 257);
this.barcodeTypeComboBox.Name = "barcodeTypeComboBox";
this.barcodeTypeComboBox.Size = new System.Drawing.Size(167, 21);
this.barcodeTypeComboBox.TabIndex = 45;
//
// barcodeLabel
//
this.barcodeLabel.AutoSize = true;
this.barcodeLabel.Location = new System.Drawing.Point(16, 241);
this.barcodeLabel.Name = "barcodeLabel";
this.barcodeLabel.Size = new System.Drawing.Size(47, 13);
this.barcodeLabel.TabIndex = 46;
this.barcodeLabel.Text = "Barcode";
//
// barcodeWidthTextBox
//
this.barcodeWidthTextBox.Enabled = false;
this.barcodeWidthTextBox.Location = new System.Drawing.Point(79, 281);
this.barcodeWidthTextBox.Name = "barcodeWidthTextBox";
this.barcodeWidthTextBox.Size = new System.Drawing.Size(31, 20);
this.barcodeWidthTextBox.TabIndex = 14;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(42, 285);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(35, 13);
this.label5.TabIndex = 15;
this.label5.Text = "Width";
//
// barcodeHeightTextBox
//
this.barcodeHeightTextBox.Enabled = false;
this.barcodeHeightTextBox.Location = new System.Drawing.Point(156, 281);
this.barcodeHeightTextBox.Name = "barcodeHeightTextBox";
this.barcodeHeightTextBox.Size = new System.Drawing.Size(30, 20);
this.barcodeHeightTextBox.TabIndex = 17;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(116, 285);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(38, 13);
this.label6.TabIndex = 18;
this.label6.Text = "Height";
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.barcodeLabel);
this.Controls.Add(this.barcodeTypeComboBox);
this.Controls.Add(this.label6);
this.Controls.Add(this.nrOfCopiesLabel);
this.Controls.Add(this.nrOfCopiesTextBox);
this.Controls.Add(this.barcodeHeightTextBox);
this.Controls.Add(this.templateTextBox);
this.Controls.Add(this.templateLabel);
this.Controls.Add(this.label5);
this.Controls.Add(this.footerItalicCheckBox);
this.Controls.Add(this.footerBoldCheckBox);
this.Controls.Add(this.barcodeWidthTextBox);
this.Controls.Add(this.footerFontSizeTextBox);
this.Controls.Add(this.footerFontFamilyComboBox);
this.Controls.Add(this.footerFontLabel);
this.Controls.Add(this.bodyItalicCheckBox);
this.Controls.Add(this.bodyBoldCheckBox);
this.Controls.Add(this.headerItalicCheckBox);
this.Controls.Add(this.headerBoldCheckBox);
this.Controls.Add(this.titleItalicCheckBox);
this.Controls.Add(this.titleBoldCheckBox);
this.Controls.Add(this.bodyFontSizeTextBox);
this.Controls.Add(this.headerFontSizeTextBox);
this.Controls.Add(this.titleFontSizeTextBox);
this.Controls.Add(this.bodyFontFamilyComboBox);
this.Controls.Add(this.bodyFontLabel);
this.Controls.Add(this.headerFontFamilyComboBox);
this.Controls.Add(this.titleFontFamilyComboBox);
this.Controls.Add(this.titleFontLabel);
this.Controls.Add(this.headerFontLabel);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.docNameTextBox);
this.Controls.Add(this.docNameLabel);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.bottomMarginTextBox);
this.Controls.Add(this.leftMarginTextBox);
this.Controls.Add(this.topMarginTextBox);
this.Controls.Add(this.topMarginLabel);
this.Controls.Add(this.orientationComboBox);
this.Controls.Add(this.orientationLabel);
this.Controls.Add(this.supressPrintingCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.CheckBox supressPrintingCheckBox;
private System.Windows.Forms.Label orientationLabel;
private System.Windows.Forms.ComboBox orientationComboBox;
private System.Windows.Forms.TextBox topMarginTextBox;
private System.Windows.Forms.Label topMarginLabel;
private System.Windows.Forms.TextBox leftMarginTextBox;
private System.Windows.Forms.TextBox bottomMarginTextBox;
private System.Windows.Forms.ComboBox cultureComboBox;
private System.Windows.Forms.Label cultureLabel;
private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button testItemsButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox docNameTextBox;
private System.Windows.Forms.Label docNameLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
private System.Windows.Forms.CheckBox footerItalicCheckBox;
private System.Windows.Forms.CheckBox footerBoldCheckBox;
private System.Windows.Forms.TextBox footerFontSizeTextBox;
private System.Windows.Forms.ComboBox footerFontFamilyComboBox;
private System.Windows.Forms.Label footerFontLabel;
private System.Windows.Forms.CheckBox bodyItalicCheckBox;
private System.Windows.Forms.CheckBox bodyBoldCheckBox;
private System.Windows.Forms.CheckBox headerItalicCheckBox;
private System.Windows.Forms.CheckBox headerBoldCheckBox;
private System.Windows.Forms.CheckBox titleItalicCheckBox;
private System.Windows.Forms.CheckBox titleBoldCheckBox;
private System.Windows.Forms.TextBox bodyFontSizeTextBox;
private System.Windows.Forms.TextBox headerFontSizeTextBox;
private System.Windows.Forms.TextBox titleFontSizeTextBox;
private System.Windows.Forms.ComboBox bodyFontFamilyComboBox;
private System.Windows.Forms.Label bodyFontLabel;
private System.Windows.Forms.ComboBox headerFontFamilyComboBox;
private System.Windows.Forms.ComboBox titleFontFamilyComboBox;
private System.Windows.Forms.Label titleFontLabel;
private System.Windows.Forms.Label headerFontLabel;
private System.Windows.Forms.TextBox templateTextBox;
private System.Windows.Forms.Label templateLabel;
private System.Windows.Forms.TextBox nrOfCopiesTextBox;
private System.Windows.Forms.Label nrOfCopiesLabel;
private System.Windows.Forms.ComboBox barcodeTypeComboBox;
private System.Windows.Forms.Label barcodeLabel;
private System.Windows.Forms.TextBox barcodeWidthTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox barcodeHeightTextBox;
private System.Windows.Forms.Label label6;
}
}
@@ -0,0 +1,407 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Output.Printers;
using TBF.Rig.Configs;
using TBF.Rig.Generic;
using TBF.Resources;
namespace TBF.Rig.Output.Printers.Enhanced
{
public partial class PrinterCfgCtrl : ConfigCtrlUtils, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
public bool ShowMore { get { return false; } }
PrinterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PrinterCfg;
Redraw();
}
}
string header;
string[] commonItems;
string[] testItems;
string footer;
public PrinterCfgCtrl()
{
InitializeComponent();
Localize();
orientationComboBox.Items.Add(PageOrientation.Portrait.ToString());
orientationComboBox.Items.Add(PageOrientation.Landscape.ToString());
foreach (var ff in System.Drawing.FontFamily.Families)
{
titleFontFamilyComboBox.Items.Add(ff.Name);
headerFontFamilyComboBox.Items.Add(ff.Name);
bodyFontFamilyComboBox.Items.Add(ff.Name);
footerFontFamilyComboBox.Items.Add(ff.Name);
}
for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++)
{
barcodeTypeComboBox.Items.Add(bt.ToString());
}
}
private void PrinterCfgCtrl_Load(object sender, EventArgs e)
{
for (Culture s = 0; s < Culture.Count; s++) cultureComboBox.Items.Add(s.ToString());
header = config.Header;
commonItems = config.CommonItems;
testItems = config.SelectedItems;
footer = config.Footer;
Redraw();
}
void Localize()
{
nameLabel.Text = Strings.Name;
cultureLabel.Text = "Culture";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items";
footerButton.Text = Strings.Footer;
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
templateTextBox.Text = config.Template;
orientationComboBox.Text = config.PageOrientation.ToString();
topMarginTextBox.Text = config.TopMargin.ToString();
bottomMarginTextBox.Text = config.BottomMargin.ToString();
leftMarginTextBox.Text = config.LeftMargin.ToString();
titleFontFamilyComboBox.Text = config.TitFntFml;
titleFontSizeTextBox.Text = config.TitFntSz.ToString();
titleBoldCheckBox.Checked = ((config.TitFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
titleItalicCheckBox.Checked = ((config.TitFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
headerFontFamilyComboBox.Text = config.HdrFntFml;
headerFontSizeTextBox.Text = config.HdrFntSz.ToString();
headerBoldCheckBox.Checked = ((config.HdrFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
headerItalicCheckBox.Checked = ((config.HdrFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
bodyFontFamilyComboBox.Text = config.BodyFntFml;
bodyFontSizeTextBox.Text = config.BodyFntSz.ToString();
bodyBoldCheckBox.Checked = ((config.BodyFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
bodyItalicCheckBox.Checked = ((config.BodyFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
footerFontFamilyComboBox.Text = config.FooterFntFml;
footerFontSizeTextBox.Text = config.FooterFntSz.ToString();
footerBoldCheckBox.Checked = ((config.FooterFntSty & (int)System.Drawing.FontStyle.Bold) != 0);
footerItalicCheckBox.Checked = ((config.FooterFntSty & (int)System.Drawing.FontStyle.Italic) != 0);
supressPrintingCheckBox.Checked = config.SupressPrinting;
goodOnlyCheckBox.Checked = config.GoodOnly;
cultureComboBox.Text = config.Culture.ToString();
docNameTextBox.Text = config.DocName;
nrOfCopiesTextBox.Text = config.NrOfCopies.ToString();
barcodeTypeComboBox.Text = config.BarcodeType.ToString();
barcodeWidthTextBox.Text = config.BarcodeWidth.ToString();
barcodeHeightTextBox.Text = config.BarcodeHeight.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
templateTextBox.Enabled = true;
orientationComboBox.Enabled = true;
topMarginTextBox.Enabled = true;
bottomMarginTextBox.Enabled = true;
leftMarginTextBox.Enabled = true;
titleFontFamilyComboBox.Enabled = true;
titleFontSizeTextBox.Enabled = true;
titleBoldCheckBox.Enabled = true;
titleItalicCheckBox.Enabled = true;
headerFontFamilyComboBox.Enabled = true;
headerFontSizeTextBox.Enabled = true;
headerBoldCheckBox.Enabled = true;
headerItalicCheckBox.Enabled = true;
bodyFontFamilyComboBox.Enabled = true;
bodyFontSizeTextBox.Enabled = true;
bodyBoldCheckBox.Enabled = true;
bodyItalicCheckBox.Enabled = true;
footerFontFamilyComboBox.Enabled = true;
footerFontSizeTextBox.Enabled = true;
footerBoldCheckBox.Enabled = true;
footerItalicCheckBox.Enabled = true;
supressPrintingCheckBox.Enabled = true;
goodOnlyCheckBox.Enabled = true;
cultureComboBox.Enabled = true;
headerButton.Enabled = true;
commonItemsButton.Enabled = true;
testItemsButton.Enabled = true;
footerButton.Enabled = true;
docNameTextBox.Enabled = true;
nrOfCopiesTextBox.Enabled = true;
barcodeTypeComboBox.Enabled = true;
barcodeWidthTextBox.Enabled = true;
barcodeHeightTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if ((int)GetOrientation(orientationComboBox.Text) < 0)
{
message += Environment.NewLine + "Invalid 'Page orientation'";
flags |= CfgUpdateFlags.Error;
}
int dummy;
if (!int.TryParse(topMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 500)
{
message += Environment.NewLine + "'Top margin' should be between 0 and 500";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(bottomMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "'Bottom margin' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(leftMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Left margin' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(titleFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
{
message += Environment.NewLine + "Title font size' should be between 6 and 48";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(headerFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
{
message += Environment.NewLine + "Header font size' should be between 6 and 48";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(bodyFontSizeTextBox.Text, out dummy) || dummy < 6 || dummy > 48)
{
message += Environment.NewLine + "Body font size' should be between 6 and 48";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(footerFontSizeTextBox.Text, out dummy) || dummy < 4 || dummy > 48)
{
message += Environment.NewLine + "Footer font size' should be between 4 and 48";
flags |= CfgUpdateFlags.Error;
}
if (!cultureComboBox.Items.Contains(cultureComboBox.Text))
{
message += Environment.NewLine + "Invalid culture";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(nrOfCopiesTextBox.Text, out dummy) || dummy < 1 || dummy > 9)
{
message += Environment.NewLine + "'Copies' should be between 1 and 9";
flags |= CfgUpdateFlags.Error;
}
if (!barcodeTypeComboBox.Items.Contains(barcodeTypeComboBox.Text))
{
message += Environment.NewLine + "Invalid barcode type";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Barcode 'Width' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(barcodeHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Barcode 'Height' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
if (config.PageOrientation != GetOrientation(orientationComboBox.Text))
{
config.PageOrientation = GetOrientation(orientationComboBox.Text);
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
for (Culture i = 0; i < Culture.Count; i++)
{
if (i.ToString().Equals(cultureComboBox.Text) && (config.Culture != i))
{
config.Culture = i;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
flags |= UpdateDifferent(ref config.Template, templateTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.TopMargin, topMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BottomMargin, bottomMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.LeftMargin, leftMarginTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
/// Title font properties
flags |= UpdateDifferent(ref config.TitFntFml, titleFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.TitFntSz, titleFontSizeTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
int tmp = (titleBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
+ (titleItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
flags |= UpdateDifferent(ref config.TitFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
/// Header font properties
flags |= UpdateDifferent(ref config.HdrFntFml, headerFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.HdrFntSz, headerFontSizeTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
tmp = (headerBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
+ (headerItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
flags |= UpdateDifferent(ref config.HdrFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
/// Body font properties
flags |= UpdateDifferent(ref config.BodyFntFml, bodyFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BodyFntSz, int.Parse(bodyFontSizeTextBox.Text), CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
tmp = (bodyBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
+ (bodyItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
flags |= UpdateDifferent(ref config.BodyFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
/// Footer font properties
flags |= UpdateDifferent(ref config.FooterFntFml, footerFontFamilyComboBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.FooterFntSz, int.Parse(footerFontSizeTextBox.Text), CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
tmp = (footerBoldCheckBox.Checked ? (int)System.Drawing.FontStyle.Bold : 0)
+ (footerItalicCheckBox.Checked ? (int)System.Drawing.FontStyle.Italic : 0);
flags |= UpdateDifferent(ref config.FooterFntSty, tmp, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.SupressPrinting, supressPrintingCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.GoodOnly, goodOnlyCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.Header, header, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.CommonItems, commonItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.SelectedItems, testItems, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.Footer, footer, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.NrOfCopies, nrOfCopiesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
for (BarcodeType bt = BarcodeType.None; bt < BarcodeType.Count; bt++)
{
if (bt.ToString().Equals(barcodeTypeComboBox.Text))
{
config.BarcodeType = bt;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
break;
}
}
flags |= UpdateDifferent(ref config.BarcodeWidth, barcodeWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.BarcodeHeight, barcodeHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Printer.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void headerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(true, string.IsNullOrEmpty(header) ? string.Empty : header.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
header = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
private void commonItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg()
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(commonItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
commonItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void testItemsButton_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg(true)
{
MetersKind = config.MetersKind,
SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(testItems),
};
if (dlg.ShowDialog() == DialogResult.OK)
{
testItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
}
}
private void footerButton_Click(object sender, EventArgs e)
{
HeaderFooterDlg dlg = new HeaderFooterDlg(false, string.IsNullOrEmpty(footer) ? string.Empty : footer.Replace("~", Environment.NewLine));
if (dlg.ShowDialog() == DialogResult.OK)
{
footer = dlg.EditedText.Replace(Environment.NewLine, "~");
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler() { }
public void StopResponseHandler() { }
#endregion Configuration Change Handling
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+27
View File
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Output.Printers.Label
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Printer.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Printer(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Printer(cfg); }
public IComponentCfg DefaultConfig() { return new PrinterCfg(this.GetType().Namespace.Substring(15), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PrinterCfg.Serializer, component, this);
}
}
}

Some files were not shown because too many files have changed in this diff Show More