using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Serialization;
using Tango.BL.Entities;
using Tango.SharedUI.Helpers;
namespace Tango.MachineStudio.Technician.TechItems
{
///
/// Represents a digital output pin item.
///
///
[TechItem(1, true)]
public class DigitalOutItem : TechItem
{
///
/// Occurs when the user has changed the current value.
///
public event EventHandler ValueChanged;
private TechIo _techIo;
///
/// Gets or sets the db tech item.
///
[XmlIgnore]
public TechIo TechIo
{
get { return _techIo; }
set { _techIo = value; RaisePropertyChangedAuto(); TechName = _techIo != null ? _techIo.InterfaceName : null; ItemGuid = value != null ? value.Guid : null; }
}
private bool _value;
///
/// Gets or sets a value indicating whether this is on.
///
[XmlIgnore]
public bool Value
{
get { return _value; }
set { _value = value; RaisePropertyChangedAuto(); ValueChanged?.Invoke(this, value); }
}
private bool _effectiveValue;
///
/// Gets or sets the effective value received from the embedded device.
///
[XmlIgnore]
public bool EffectiveValue
{
get { return _effectiveValue; }
set
{
if (_effectiveValue != value)
{
_effectiveValue = value;
RaisePropertyChangedAuto();
_value = value;
RaisePropertyChanged(nameof(Value));
}
}
}
///
/// Initializes a new instance of the class.
///
public DigitalOutItem() : base()
{
Name = "Digital Output Interface";
Description = "Digital Output Interface Controller";
Image = ResourceHelper.GetImageFromResources("Images/binary.png");
Color = Colors.White;
}
///
/// Initializes a new instance of the class.
///
/// The db tech item.
public DigitalOutItem(TechIo techIo) : this()
{
TechIo = techIo;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
DigitalOutItem cloned = base.Clone() as DigitalOutItem;
cloned.TechIo = TechIo;
return cloned;
}
}
}