89 lines
2.5 KiB
C#
89 lines
2.5 KiB
C#
///
|
|
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Drawing;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.Modbus.QuidoRS
|
|
{
|
|
public class ShowBenchWaitingOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ShowBenchWaitingOp));
|
|
public override string ToString() { return string.Format("ShowBenchWaitingOp(.)"); }
|
|
|
|
const ushort BenchReadyValue = 0x01;
|
|
const ushort BenchWaitingValue = 0x06;
|
|
const ushort BenchConfirmedValue = 0x02;
|
|
|
|
/// Set by the constructor
|
|
readonly QuidoRS quidoRS;
|
|
|
|
|
|
|
|
bool confirmed = false;
|
|
///
|
|
ConfirmationForm confirmationForm;
|
|
///
|
|
delegate void MessageBoxFormDlgt(ShowBenchWaitingOp myRef);
|
|
///
|
|
void OpenFormDlg(ShowBenchWaitingOp myRef)
|
|
{
|
|
myRef.confirmationForm = new ConfirmationForm(Strings.Mute_alarm, Color.Yellow);
|
|
confirmationForm.Show();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Events: Event.None
|
|
/// </summary>
|
|
/// <param name="quidoRS">Pressure meter reference</param>
|
|
public ShowBenchWaitingOp(QuidoRS quidoRS)
|
|
{
|
|
if (quidoRS == null) throw new ArgumentNullException("quidoRS");
|
|
this.quidoRS = quidoRS;
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
log.WarnFormat("ShowBenchWaitingOp.Start()");
|
|
quidoRS.SetOutputs(BenchWaitingValue);
|
|
confirmed = false;
|
|
Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this);
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
public Event Run()
|
|
{
|
|
if (confirmed || confirmationForm.Completed)
|
|
{
|
|
log.WarnFormat("ShowBenchWaitingOp.Run() --> Confirmed");
|
|
quidoRS.SetOutputs(BenchConfirmedValue);
|
|
|
|
confirmed = true;
|
|
confirmationForm = null;
|
|
}
|
|
|
|
return Event.None;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
log.WarnFormat("ShowBenchWaitingOp.Stop()");
|
|
quidoRS.SetOutputs(BenchReadyValue);
|
|
|
|
if (confirmationForm != null)
|
|
{
|
|
confirmationForm.OnCloseThisForm(this, null);
|
|
confirmationForm = null;
|
|
}
|
|
}
|
|
}
|
|
}
|