using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model
{

    /// <summary>
    /// 店铺设备
    /// </summary>
    public class DeviceConfigModelJson : ObservableObject
    {
        /// <summary>
        /// 店铺名称
        /// </summary>
        public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } }
        private string _mShopName = string.Empty;

        /// <summary>
        /// 店铺ID
        /// </summary>
        public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
        private string _mShopId = string.Empty;

        /// <summary>
        /// 设备集合
        /// </summary>
        public ObservableCollection<DeviceModel> deviceModels { get; set; } = new ObservableCollection<DeviceModel>();
    }

    /// <summary>
    /// 启动模块
    /// </summary>
    public class DeviceModel : ObservableObject
    {
        /// <summary>
        /// 设备名称
        /// </summary>
        public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
        private string _mDeviceName = string.Empty;

        /// <summary>
        /// 启动设备模块
        /// </summary>
        public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } }
        private string _mDeviceModule = string.Empty;

        public string DeviceNamespace { get; set; }


        public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
        private string _mId = string.Empty;


        /// <summary>
        /// 设备ID
        /// </summary>
        public string DeviceId { get { return _mDeviceId; } set { _mDeviceId = value; OnPropertyChanged(); } }
        private string _mDeviceId = string.Empty;

        /// <summary>
        /// 通讯模块
        /// </summary>
        public ObservableCollection<CommunicationModel> communicationDevcies { get; set; } = new ObservableCollection<CommunicationModel>();

    }

    /// <summary>
    /// 通讯模块
    /// </summary>
    public class CommunicationModel : ObservableObject
    {
        /// <summary>
        /// 通讯启动模块
        /// </summary>
        public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } }
        private string _mCommunicationModule = string.Empty;

        public string CommunicationNamespace { get; set; }

        public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } }
        private string _mCommunicationName = string.Empty;

        public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } }
        private string _mDeviceModelId = string.Empty;

        public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } }
        private CommunicationPar _mcommunicationPar = new CommunicationPar();

        public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>();

    }

    /// <summary>
    /// 通讯参数
    /// </summary>
    public class CommunicationPar : ObservableObject
    {
        /// <summary>
        /// 选择网口通讯
        /// </summary>
        public bool IsNetworkPort { get { return _mIsNetworkPort; } set { _mIsNetworkPort = value; OnPropertyChanged(); } }
        private bool _mIsNetworkPort = false;

        /// <summary>
        /// 选择串口通讯
        /// </summary>
        public bool IsSerialPort { get { return _mIsSerialPort; } set { _mIsSerialPort = value; OnPropertyChanged(); } }
        private bool _mIsSerialPort = true;

        /// <summary>
        /// IP地址
        /// </summary>
        public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } }
        private string _mIPAddress;

        /// <summary>
        /// IP 端口号
        /// </summary>
        public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } }
        private int _mIPPort;

        /// <summary>
        /// ip 串口 站号
        /// </summary>
        public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } }
        private int _mStationNo;


        /// <summary>
        /// 串口单口号
        /// </summary>
        public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } }
        private string _mSerialPort;

        /// <summary>
        /// 波特率
        /// </summary>
        public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } }
        private int _mBaudRate;

        /// <summary>
        /// 数据位
        /// </summary>
        public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } }
        private int _mDataBits = 8;

        /// <summary>
        /// 停止位
        /// </summary>
        public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } }
        private string _mStopBits = "1";

        /// <summary>
        /// 校验位
        /// </summary>
        public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } }
        private string _mParity;

        //public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>();
    }

    public class Variable : ObservableObject
    {
        public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
        private int _mId;


        public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } }
        private string _mAddress;


        public int ReadLeng { get { return _mReadLeng; } set { _mReadLeng = value; OnPropertyChanged(); } }
        private int _mReadLeng;


    }
}


