125 lines
3.7 KiB
C#
125 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
|
|
|
namespace ProductionUiCordonel.Data
|
|
{
|
|
public class PickingItemCheckReturn
|
|
{
|
|
public bool? Result;
|
|
public string Msg;
|
|
}
|
|
|
|
public abstract class PickingResultBaseData : IPickingResultData
|
|
{
|
|
public string Ident { get; set; }
|
|
|
|
public int Index { get; set; }
|
|
|
|
public string CheckText { get; set; }
|
|
|
|
public string CurrentValueText { get; set; }
|
|
|
|
public bool? Result { get; set; }
|
|
|
|
public bool HasError { get; set; }
|
|
|
|
public System.Windows.Media.Brush ResultColor { get { return getColorFromResult(); } }
|
|
public abstract Func<PickingItemCheckReturn> Action { get; }
|
|
|
|
private System.Windows.Media.Brush getColorFromResult()
|
|
{
|
|
var converter = new System.Windows.Media.BrushConverter();
|
|
var brush = (System.Windows.Media.Brush)converter.ConvertFromString("#000000");
|
|
|
|
if (Result.HasValue) // && a.Result.Value ))
|
|
{
|
|
if (!Result.Value)
|
|
{
|
|
brush = (System.Windows.Media.Brush)converter.ConvertFromString("#FF8000");
|
|
}
|
|
else
|
|
{
|
|
brush = (System.Windows.Media.Brush)converter.ConvertFromString("#419C14");
|
|
}
|
|
|
|
}
|
|
return brush;
|
|
}
|
|
|
|
}
|
|
public interface IPickingResultData
|
|
{
|
|
string Ident { get; set; }
|
|
|
|
int Index { get; set; }
|
|
string CheckText { get; set; }
|
|
|
|
string CurrentValueText { get; set; }
|
|
|
|
bool? Result { get; set; }
|
|
|
|
bool HasError { get; set; }
|
|
|
|
System.Windows.Media.Brush ResultColor { get; }
|
|
|
|
Func<PickingItemCheckReturn> Action { get; }
|
|
}
|
|
public class PickingResultRegisterData : PickingResultBaseData
|
|
{
|
|
public string RegisterIdent { get; set; }
|
|
|
|
public GenesisMeter ReadMeter { get; set; }
|
|
|
|
public object CompareObject { get; set; }
|
|
|
|
public override Func<PickingItemCheckReturn> Action { get { return staticReadAndCompareAction(); } }
|
|
|
|
public Func<PickingItemCheckReturn> staticReadAndCompareAction()
|
|
{
|
|
return delegate ()
|
|
{
|
|
var retComp = new PickingItemCheckReturn();
|
|
retComp.Result = null;
|
|
retComp.Msg = "-";
|
|
if (ReadMeter != null && ReadMeter.IsLoggedOn)
|
|
{
|
|
var r = ReadMeter.ReadRegister(RegisterIdent);
|
|
|
|
if (CompareObject is UInt32 intNumber)
|
|
{
|
|
retComp.Result = intNumber.Equals(RegisterConverter.ConvertTo<UInt32>(r));
|
|
retComp.Msg = intNumber.ToString();
|
|
}
|
|
else if (CompareObject is Boolean boolCompare)
|
|
{
|
|
retComp.Result = boolCompare.Equals(RegisterConverter.ConvertTo<bool>(r));
|
|
retComp.Msg = boolCompare.ToString();
|
|
}
|
|
|
|
}
|
|
|
|
return retComp;
|
|
};
|
|
}
|
|
}
|
|
|
|
public class PickingResultCustomCheckData : PickingResultBaseData
|
|
{
|
|
|
|
public PickingResultCustomCheckData(Func<PickingItemCheckReturn> action)
|
|
{
|
|
_action = action;
|
|
}
|
|
|
|
public readonly Func<PickingItemCheckReturn> _action;
|
|
public override Func<PickingItemCheckReturn> Action { get { return _action; } }
|
|
|
|
}
|
|
|
|
}
|