using GeneralData;
using System.Xml.Serialization;

namespace HardwareData;

public class ChannelData
{
    public byte Mini8Index { get; set; }
    public byte ChannelIndex { get; set; }
    public string? Name { get; set; }

    public ChannelMode ChannelMode { get; set; }

    [XmlIgnore]
    public DateTime CollectTime { get; set; }

    [XmlIgnore]
    public float Caps { get; set; }
    [XmlIgnore]
    public float Floor { get; set; }
    [XmlIgnore]
    public float CapsWarning { get; set; }
    [XmlIgnore]
    public float FloorWarning { get; set; }

    [XmlIgnore]
    public float PV { get; set; }
    [XmlIgnore]
    public float WorkingOutput { get; set; }

    [XmlIgnore]
    public AutoTuneStatus AutoTuneStatus { get; set; }

    [XmlIgnore]
    public float AutoTune_P { get; set; }
    [XmlIgnore]
    public float AutoTune_I { get; set; }
    [XmlIgnore]
    public float AutoTune_D { get; set; }

    [XmlIgnore]
    public TcBorken SensorBreakAlarm { get; set; }

    [XmlIgnore]
    public float SetPoint { get; set; }

    [XmlIgnore]
    public ActiveTuneSet ActiveTuneSet { get; set; }

    [XmlIgnore]
    public float Running_P { get; set; }
    [XmlIgnore]
    public float Running_I { get; set; }
    [XmlIgnore]
    public float Running_D { get; set; }

    [XmlIgnore]
    public Inhibit Inhibit { get; set; }


    [XmlIgnore]
    public float SetpointUpRate { get; set; }
    [XmlIgnore]
    public float SetpointDownRate { get; set; }
}

public interface IChannelAddress<T_AddressType>
{
    public byte Mini8Index { get; set; }
    public byte ChannelIndex { get; set; }

    public T_AddressType PV { get; set; }

    public T_AddressType WorkingOutput { get; set; }
    public T_AddressType AutoTuneStatus { get; set; }

    public T_AddressType AutoTune_P { get; set; }
    public T_AddressType AutoTune_I { get; set; }
    public T_AddressType AutoTune_D { get; set; }

    public T_AddressType SensorBreakAlarm1 { get; set; }
    public T_AddressType SensorBreakAlarm2 { get; set; }

    public T_AddressType SetPoint { get; set; }

    public T_AddressType ActiveTuneSet { get; set; }

    public T_AddressType Running_P { get; set; }
    public T_AddressType Running_I { get; set; }
    public T_AddressType Running_D { get; set; }

    public T_AddressType Inhibit { get; set; }

    public T_AddressType ActiveAutoTune { get; set; }

    public T_AddressType SetpointUpRate { get; set; }
    public T_AddressType SetpointDownRate { get; set; }

    public T_AddressType Caps { get; set; }
    public T_AddressType Floor { get; set; }
    public T_AddressType CapsWarning { get; set; }
    public T_AddressType FloorWarning { get; set; }
}

public class ChannelAddress : IChannelAddress<ushort>
{
    public byte Mini8Index { get; set; }
    public byte ChannelIndex { get; set; }

    public ushort PV { get; set; }

    public ushort WorkingOutput { get; set; }
    public ushort AutoTuneStatus { get; set; }

    public ushort AutoTune_P { get; set; }
    public ushort AutoTune_I { get; set; }
    public ushort AutoTune_D { get; set; }

    public ushort SensorBreakAlarm1 { get; set; }
    public ushort SensorBreakAlarm2 { get; set; }

    public ushort SetPoint { get; set; }

    public ushort ActiveTuneSet { get; set; }

    public ushort Running_P { get; set; }
    public ushort Running_I { get; set; }
    public ushort Running_D { get; set; }

    public ushort Inhibit { get; set; }

    public ushort ActiveAutoTune { get; set; }

    public ushort SetpointUpRate { get; set; }
    public ushort SetpointDownRate { get; set; }

    public ushort Caps { get; set; }
    public ushort Floor { get; set; }
    public ushort CapsWarning { get; set; }
    public ushort FloorWarning { get; set; }
}

public class ChannelAddressPLC : IChannelAddress<string?>
{
    public byte Mini8Index { get; set; }
    public byte ChannelIndex { get; set; }
    public string? PV { get; set; }
    public string? WorkingOutput { get; set; }
    public string? AutoTuneStatus { get; set; }
    public string? AutoTune_P { get; set; }
    public string? AutoTune_I { get; set; }
    public string? AutoTune_D { get; set; }
    public string? SensorBreakAlarm1 { get; set; }
    public string? SensorBreakAlarm2 { get; set; }
    public string? SetPoint { get; set; }
    public string? ActiveTuneSet { get; set; }
    public string? Running_P { get; set; }
    public string? Running_I { get; set; }
    public string? Running_D { get; set; }
    public string? Inhibit { get; set; }
    public string? ActiveAutoTune { get; set; }
    public string? SetpointUpRate { get; set; }
    public string? SetpointDownRate { get; set; }
    public string? Caps { get; set; }
    public string? Floor { get; set; }
    public string? CapsWarning { get; set; }
    public string? FloorWarning { get; set; }
}