using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FLY.ModbusModule;


namespace WpfApplication_ModbusServer
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        ServerTCP mModbusServer;
        PLCRegister mPLCRegs;

        public MainWindow()
        {
            InitializeComponent();

            FObjBase.PollModule.Current.Start();


            mPLCRegs = new PLCRegister(24, 150);
            mPLCRegs.RegChanged += new PLCRegister.RegChangedEventHandler(mPLCRegs_RegChanged);

            mModbusServer = new ServerTCP(mPLCRegs);

            mPLCRegs.SetInt16(0x1, 0x1234);
            mPLCRegs.SetInt16(0x3, 0x1234);
            
        }

        void mPLCRegs_RegChanged(object sender, PLCRegister.RegChangedEventArgs e)
        {
            //var propertyName = from _r in rpn where _r.type == e.RegType && e.IsCover(_r.addr) select _r.propertyName;
            //if (propertyName.Count() > 0)
            //{
            //    foreach (var n in propertyName)
            //        NotifyPropertyChanged(n);
            //}
        }
    }
}
