Events, EventViewer, Common prjs, UI.EventLogs, UI.Calendar, EventTriggers, GetCalendarEvents() in WT/I.

This commit is contained in:
Milan Hanajik
2020-04-21 10:46:42 +02:00
parent 66631855bb
commit b1d692230e
161 changed files with 13377 additions and 933 deletions
@@ -11,6 +11,7 @@ using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.BenchControl.MettlerToledo.Standard
{
@@ -20,7 +21,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale, GenericDevices.IHasCalendarEvents
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -109,6 +110,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
{
base.Initalize();
if (balanceCfg.CalibValidDate != DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired));
}
msrmntState = MsrmntState.Failed; /// Data not valid yet
MsrmntTime = 0;
@@ -120,9 +126,39 @@ namespace TBF.BenchControl.MettlerToledo.Standard
serialPort.Handshake = balanceCfg.Handshake;
serialPort.Open();
log.FatalFormat("Successfully initialized device {0}", ToString());
log.FatalFormat("Successfully initialized device {0}", Name);
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = balanceCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
/// 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("dd.MM.yyyy"))));
if ((calibrationDue != DateTime.MinValue) && (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("dd.MM.yyyy")),
false));
}
if ((calibrationDue != DateTime.MinValue) && (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("dd.MM.yyyy")),
true));
}
return calendarEvents;
}
public override bool IsEmpty()
{
return DrainValve.State ? (mass <= balanceCfg.Empty) : (mass <= balanceCfg.EmptyUp);