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.Core.Commands;
using Tango.BL.Entities;
using Tango.SharedUI.Helpers;
using System.Collections.ObjectModel;
namespace Tango.MachineStudio.Technician.TechItems
{
///
/// Represents a PID controller item.
///
///
[TechItem(12, false)]
public class PidItem : TechItem
{
private static List _pidConfigurations;
///
/// Gets or sets the pid configurations.
///
public static List PidConfigurations
{
get { return _pidConfigurations; }
set { _pidConfigurations = value; }
}
static PidItem()
{
PidConfigurations = new List();
foreach (var pidType in BL.ObservablesStaticCollections.Instance.HardwarePidControlTypes)
{
PidConfigurations.Add(new HardwarePidControl() { HardwarePidControlType = pidType });
}
}
private HardwarePidControlType _hardwarePidType;
///
/// Gets or sets the type of the hardware pid.
///
[XmlIgnore]
public HardwarePidControlType HardwarePidType
{
get { return _hardwarePidType; }
set
{
_hardwarePidType = value; RaisePropertyChangedAuto(); TechName = _hardwarePidType != null ? _hardwarePidType.Description : null; ItemGuid = value != null ? value.Guid : null;
if (_hardwarePidType != null)
{
HardwarePid = PidConfigurations.SingleOrDefault(x => x.HardwarePidControlType == _hardwarePidType);
}
}
}
private HardwarePidControl _hardwarePid;
///
/// Gets or sets the hardware pid.
///
[XmlIgnore]
public HardwarePidControl HardwarePid
{
get { return _hardwarePid; }
set { _hardwarePid = value; RaisePropertyChangedAuto(); }
}
///
/// Initializes a new instance of the class.
///
public PidItem() : base()
{
Name = "PID";
Description = "PID Controller";
Image = ResourceHelper.GetImageFromResources("Images/function.png");
Color = Colors.White;
HardwarePid = new HardwarePidControl();
}
///
/// Initializes a new instance of the class.
///
/// Type of the pid.
public PidItem(HardwarePidControlType pidType) : this()
{
HardwarePidType = pidType;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
PidItem cloned = base.Clone() as PidItem;
cloned.HardwarePidType = HardwarePidType;
return cloned;
}
}
}