96 lines
4.8 KiB
C#
96 lines
4.8 KiB
C#
///
|
|
/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using Common;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.Rig.DataContainer.iPerlBenchInfo
|
|
{
|
|
/// <summary>
|
|
/// Holds information identifying the test bench.
|
|
/// </summary>
|
|
public class Component : ComponentBase, GenericDevices.IBenchInfo, GenericDevices.IHasCalendarEvents
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
|
|
|
readonly ComponentCfg myCfg;
|
|
|
|
public string TestBenchName { get { return myCfg.TestBenchName; } }
|
|
public int TestBenchId { get { return myCfg.TestBenchId; } }
|
|
public string Address1 { get { return myCfg.Address1; } }
|
|
public string Address2 { get { return myCfg.Address2; } }
|
|
public string Address3 { get { return myCfg.Address3; } }
|
|
public string Address4 { get { return myCfg.Address4; } }
|
|
public string Address5 { get { return myCfg.Address5; } }
|
|
public int WaterMetersCount { get { return myCfg.WaterMetersCount; } }
|
|
public int LinesCount { get { return myCfg.LinesCount; } }
|
|
public int CompoundMetersCount { get { return myCfg.CompoundMetersCount; } }
|
|
public Unit VolumeUnit { get { return myCfg.VolumeUnit; } }
|
|
public Unit FlowUnit { get { return myCfg.FlowUnit; } }
|
|
public bool IsFromToInPct { get { return myCfg.IsFromToInPct; } }
|
|
public Unit MassUnit { get { return myCfg.MassUnit; } }
|
|
public Unit TempUnit { get { return myCfg.TempUnit; } }
|
|
public Unit PressUnit { get { return myCfg.PressUnit; } }
|
|
public Unit LengthUnit { get { return myCfg.LenghtUnit; } }
|
|
public Unit ElectricUnit { get { return myCfg.ElectricUnit; } }
|
|
public Side Side { get { return myCfg.Side; } }
|
|
public int MaxTestIndex { get { return myCfg.MaxTestIndex; } } /// (MaxPruefindex % 100) value when to reject water meters completely if they are NOK
|
|
|
|
public ICollection<ProcedureSelection> Sources
|
|
{
|
|
get { return new ProcedureSelection[] { myCfg.Source1, myCfg.Source2, myCfg.Source3, myCfg.Source4 }; }
|
|
}
|
|
|
|
|
|
public Component() { }
|
|
|
|
public Component(Generic.IComponentCfg cfg)
|
|
: base(cfg)
|
|
{
|
|
myCfg = cfg as ComponentCfg;
|
|
log.Warn(this.ToString());
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
SharedDatabase.EventsDB.SetBenchName(myCfg.TestBenchName);
|
|
}
|
|
|
|
|
|
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
|
|
{
|
|
DateTime calibrationDue = myCfg.CalibValidDate;
|
|
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
|
|
|
|
if (calibrationDue > TBF.UI.Constants.MinDate)
|
|
{
|
|
/// Calibration due date calendar event
|
|
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
|
|
string.Format(Strings.Calibration_due_date_is_0,
|
|
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
|
|
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
|
|
{
|
|
/// Weekly reminders (last 5 weeks)
|
|
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
|
|
string.Format(Strings.Calibration_due_date_is_0,
|
|
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
|
|
false));
|
|
}
|
|
if (DateTime.Now.Date <= calibrationDue.Date)
|
|
{
|
|
/// Daily reminders (last 5 days)
|
|
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
|
|
string.Format(Strings.Calibration_due_date_is_0,
|
|
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
|
|
true));
|
|
}
|
|
}
|
|
return calendarEvents;
|
|
}
|
|
}
|
|
}
|