Refactorization : BenchControl -> Rig
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.Rig.Modbus.QuidoRS
|
||||
{
|
||||
public class ShowBenchErrorOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ShowBenchErrorOp));
|
||||
public override string ToString() { return string.Format("ShowBenchErrorOp(.)"); }
|
||||
|
||||
const ushort BenchReadyValue = 0x01;
|
||||
const ushort BenchErrorValue = 0x06;
|
||||
const ushort BenchConfirmedValue = 0x02;
|
||||
|
||||
/// Set by the constructor
|
||||
readonly QuidoRS quidoRS;
|
||||
|
||||
|
||||
|
||||
bool confirmed = false;
|
||||
///
|
||||
ConfirmationForm confirmationForm;
|
||||
///
|
||||
delegate void MessageBoxFormDlgt(ShowBenchErrorOp myRef);
|
||||
///
|
||||
void OpenFormDlg(ShowBenchErrorOp 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 ShowBenchErrorOp(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("ShowBenchErrorOp.Start()");
|
||||
quidoRS.SetOutputs(BenchErrorValue);
|
||||
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("ShowBenchErrorOp.Stop()");
|
||||
quidoRS.SetOutputs(BenchReadyValue);
|
||||
|
||||
if (confirmationForm != null)
|
||||
{
|
||||
confirmationForm.OnCloseThisForm(this, null);
|
||||
confirmationForm = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user