using PlcCom;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;

public delegate void UserOperateControlHandler(IPlcBindableComponent plcBindableComponent,OperationType operationType, Node node,object oldValue, object newValue);

public delegate void RegisterValueChangedHandler(IPlcBindableComponent plcBindableComponent, Node node, object state);

public delegate void UpdateComponentStateFailedHandler(IPlcBindableComponent plcBindableComponent, Node node, object state, string errMessage);

public delegate void WriteRegisterFailedHandler(IPlcBindableComponent plcBindableComponent, Node node, uint errorCode);
public delegate void ReadRegisterFailedHandler(IPlcBindableComponent plcBindableComponent, Node node, uint errorCode);


public interface IPlcBindableComponent
{
    IPlcComProtocol Protocol { get; set; }
}
public interface IPlcUiControl
{
    Node InvisibilityTriggerNode { get; set; }
    bool ValueForInvisibility { get; set; }
    bool Invisibility { get; set; }

    Node DisabilityTriggerNode { get; set; }
    bool ValueForDisability { get; set; }
    bool Disability { get; set; }
}


public interface IPlcInputComponent
{
    event UserOperateControlHandler OnUserSettedValue;
    event WriteRegisterFailedHandler OnWriteRegisterFailed;
}

public interface ISingleInputComponent : IPlcBindableComponent, IPlcInputComponent
{
    Node WriteNode { get; set; }
    void WriteValue(object value);
}
public interface IPlcMultiInputComponent : IPlcBindableComponent, IPlcInputComponent
{
    List<Node> WriteNodes { get; set; }
}
public interface IPlcOutputComponent
{
    event RegisterValueChangedHandler OnPLCRegisterValueChanged;
    event ReadRegisterFailedHandler OnReadRegisterFailed;
    event UpdateComponentStateFailedHandler OnUpdateComponentStateFailed;
}
public interface ISingleOutputComponent : IPlcBindableComponent, IPlcOutputComponent
{
    Node ReadNode { get; set; }
    object Read();
    void UpdateValue(object value);
}
public interface IMultiOutputComponent : IPlcBindableComponent, IPlcOutputComponent
{
    bool BackgroundRefreshEnable { get; set; }
    List<Node> ReadNodes { get; set; }
    List<object> Read();
    int ReadInterval { get; set; }
    void UpdateValues(List<Node> nodes, List<object> values);
    List<Node> RemoveInvalidNodes();
}
public interface IPlcBindableButton
{
    bool NeedUserEnsure { get; set; }
}
public interface IPlcBindableNumber
{
    int IntegerDigits { get; set; }
    int DecimalPlaces { get; set; }
    double Gain { get; set; }
}

