360 lines
8.9 KiB
C#
360 lines
8.9 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
|
|
using XylemCommonUiLegacyGenCtl.DataPackage;
|
|
|
|
namespace XylemCommonUiLegacyGenCtl
|
|
{
|
|
[Guid("870BA78D-F176-4125-9125-F3FD3A496423"),
|
|
ComVisible(true),
|
|
ClassInterface(ClassInterfaceType.None),
|
|
ComSourceInterfaces(typeof(ITstCont))]
|
|
public class TstContHlp : ITstCont
|
|
{
|
|
private TestSetupContainer testSetup;
|
|
public TstContHlp()
|
|
{
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
public void Init()
|
|
{
|
|
testSetup = new TestSetupContainer();
|
|
}
|
|
|
|
|
|
public dynamic GetContainer()
|
|
{
|
|
return testSetup;
|
|
}
|
|
|
|
public bool GetAllChanelsRequired()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
return testSetup.AllChanelsRequired;
|
|
}
|
|
|
|
public void SetTestRun(int v)
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.TestRunNumber = v;
|
|
}
|
|
|
|
|
|
public int GetDelayInSBeforStart()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return testSetup.DelayInSBeforStart;
|
|
}
|
|
|
|
|
|
public int GetMetersize()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
return MeterSizeConverter.ConvertToOrder(testSetup.MeterSize);
|
|
}
|
|
|
|
|
|
public bool GetProductionMode()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return testSetup.ProductionMode;
|
|
}
|
|
|
|
public bool GetWatingForDecision()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return testSetup.WatingForDecision;
|
|
}
|
|
|
|
public bool GetTempSouceFlansch()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return testSetup.TempSouce == Enums.TempSouceType.TempFlansh;
|
|
}
|
|
|
|
public bool GetTempSouceSPS()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return testSetup.TempSouce == Enums.TempSouceType.PtOverSps;
|
|
}
|
|
|
|
public bool GetTempSouceManually()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return testSetup.TempSouce == Enums.TempSouceType.ManualInput;
|
|
}
|
|
|
|
|
|
public void SetAllChanelsRequired(bool v)
|
|
{
|
|
|
|
HanldWrongInput();
|
|
testSetup.AllChanelsRequired = v;
|
|
|
|
}
|
|
|
|
|
|
public void SetDelayInSBeforStart(int v)
|
|
{
|
|
|
|
HanldWrongInput();
|
|
testSetup.DelayInSBeforStart = v;
|
|
}
|
|
|
|
public void SetMetersize(int v)
|
|
{
|
|
|
|
HanldWrongInput();
|
|
testSetup.MeterSize = MeterSizeConverter.ConvertToMeter(v);
|
|
}
|
|
|
|
|
|
public void SetProductionMode(bool v)
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.ProductionMode = v;
|
|
}
|
|
|
|
public void SetWatingForDecision(bool v)
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.WatingForDecision = v;
|
|
}
|
|
|
|
public void SetTempSouceFlansch()
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.TempSouce = Enums.TempSouceType.TempFlansh;
|
|
}
|
|
|
|
public void SetTempSouceManually()
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.TempSouce = Enums.TempSouceType.ManualInput;
|
|
}
|
|
|
|
|
|
|
|
public void SetTempSouceSPS()
|
|
{
|
|
HanldWrongInput();
|
|
testSetup.TempSouce = Enums.TempSouceType.PtOverSps;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region MeterStuff
|
|
|
|
|
|
public void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel,bool eRegister,bool ReversFlow)
|
|
{
|
|
HanldWrongInputMeters(Slot);
|
|
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
testSetup.meterTestSettings[Slot - 1] = new MeterTestSettings();
|
|
}
|
|
|
|
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
//System.Windows.Forms.MessageBox.Show("new testresults from setmetertestsettings");
|
|
testSetup.meterTestResults[Slot - 1] = new MeterTestResults();
|
|
}
|
|
|
|
testSetup.meterTestSettings[Slot - 1].Slot = Slot;
|
|
testSetup.meterTestSettings[Slot - 1].SerialNr = SerialNr;
|
|
testSetup.meterTestSettings[Slot - 1].FlowAdjustment = FlowAdjustment;
|
|
testSetup.meterTestSettings[Slot - 1].FlowAdjustmentTarget = Convert.ToDecimal(FlowAdjustmentTarget);
|
|
testSetup.meterTestSettings[Slot - 1].PreAdjustment = PreAdjustment;
|
|
testSetup.meterTestSettings[Slot - 1].FlowTesting = FlowTesting;
|
|
if (MagFlux)
|
|
{
|
|
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux;
|
|
}
|
|
if (Cordonel)
|
|
{
|
|
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.Cordonel;
|
|
}
|
|
if (eRegister)
|
|
{
|
|
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.eRegister;
|
|
}
|
|
|
|
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyForward = true;
|
|
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyRevers = false;
|
|
|
|
if (ReversFlow)
|
|
{
|
|
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyForward = false;
|
|
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyRevers = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool GetPreAdjustment(int Slot)
|
|
{
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
return false;
|
|
}
|
|
return testSetup.meterTestSettings[Slot - 1].PreAdjustment;
|
|
}
|
|
|
|
|
|
public bool GetFlowAdjustment(int Slot)
|
|
{
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
return false;
|
|
}
|
|
return testSetup.meterTestSettings[Slot - 1].FlowAdjustment;
|
|
}
|
|
|
|
public double GetFlowAdjustmentTarget(int Slot)
|
|
{
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return Convert.ToDouble(testSetup.meterTestSettings[Slot - 1].FlowAdjustmentTarget);
|
|
}
|
|
|
|
public bool GetFlowTesting(int Slot)
|
|
{
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
return true;
|
|
}
|
|
return testSetup.meterTestSettings[Slot - 1].FlowTesting;
|
|
}
|
|
|
|
public string GetMeterSerialNr(int Slot)
|
|
{
|
|
if (testSetup.meterTestSettings[Slot - 1] == null)
|
|
{
|
|
return "";
|
|
}
|
|
return testSetup.meterTestSettings[Slot - 1].SerialNr;
|
|
}
|
|
|
|
|
|
public bool GetAnyMeterFlowAdjustment()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (testSetup.meterTestSettings == null)
|
|
{
|
|
return false;
|
|
}
|
|
return testSetup.meterTestSettings.Any(x => x.FlowAdjustment);
|
|
}
|
|
|
|
public bool GetAnyMeterFlowTesting()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (testSetup.meterTestSettings == null)
|
|
{
|
|
|
|
|
|
|
|
|
|
return false;
|
|
}
|
|
return testSetup.meterTestSettings.Any(x => x.FlowTesting);
|
|
}
|
|
|
|
public bool GetAnyMeterPreAdjustment()
|
|
{
|
|
if (testSetup == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (testSetup.meterTestSettings == null)
|
|
{
|
|
return false;
|
|
}
|
|
return testSetup.meterTestSettings.Any(x => x.PreAdjustment);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region internalStuff
|
|
|
|
|
|
|
|
|
|
private void HanldWrongInput()
|
|
{
|
|
|
|
if (testSetup == null)
|
|
{
|
|
testSetup = new TestSetupContainer();
|
|
}
|
|
}
|
|
|
|
private void HanldWrongInputMeters(int Slot)
|
|
{
|
|
|
|
HanldWrongInput();
|
|
if (testSetup.meterTestSettings == null)
|
|
{
|
|
testSetup.meterTestSettings = new MeterTestSettings[12];
|
|
}
|
|
if (Slot < 0 || Slot > 13)
|
|
{
|
|
throw new Exception("Ungültiger Einbauplatz");
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|