using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;

namespace CCDCountWpf.WpfPage
{
    /// <summary>
    /// PlcOperationPage.xaml 的交互逻辑
    /// </summary>
    public partial class PlcOperationPage : Page
    {
        public PlcOperationPage()
        {
            InitializeComponent();
            this.Width = Double.NaN;
            this.Height = Double.NaN;
            DataContext = PlcSettingMessageBus.PlcMessageShowBindage;
        }

        /// <summary>
        /// 开始按钮按下事件
        /// </summary>
        private void InitiateBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineRunToTrue();
        }

        /// <summary>
        /// 开始按钮抬起事件
        /// </summary>
        private void InitiateBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //pLCManagement.InitiateToFalse();
        }

        /// <summary>
        /// 停止按钮按下事件
        /// </summary>
        private void StopBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineStopToTrue();
        }

        /// <summary>
        /// 停止按钮抬起事件
        /// </summary>
        private void StopBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //pLCManagement.StopToFalse();
        }
        private void Valve1Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(0);
        }

        private void Valve2Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(1);
        }

        private void Valve3Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(2);
        }

        private void Valve4Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(3);
        }

        private void Valve5Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(4);
        }

        private void Valve6Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(5);
        }

        private void Valve7Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(6);
        }

        private void Valve8Jog_Click(object sender, RoutedEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchValveManualControl(7);
        }

        private void ScrewHomeBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ScrewHomeToTrue();
        }

        private void ScrewJogFwdBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ScrewJogFwdToTrue();
        }

        private void ScrewJogFwdBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ScrewJogFwdToFalse();
        }

        private void ScrewJogRevBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ScrewJogRevToTrue();
        }

        private void ScrewJogRevBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ScrewJogRevToFalse();
        }

        private void FillingValveManualOpenBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveManualOpenToTrue();
        }

        private void FillingValveManualCloseBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveManualCloseToTrue();
        }

        private void FillingValveManualCacheBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveManualCache();
        }

        private void FillingValveJogFwdBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveJogFwdToTrue();
        }

        private void FillingValveJogFwdBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveJogFwdToFalse();
        }

        private void FillingValveJogRevBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveJogRevToTrue();
        }

        private void FillingValveJogRevBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveJogRevToFalse();
        }

        private void FillingValveHomeBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveHomeToTrue();
        }

        private void BeltsJogBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.BeltsJogToTrue();
        }

        private void BeltsJogBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.BeltsJogToFalse();
        }

        private void ShakeTableJogBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ShakeTableJogToTrue();
        }

        private void ShakeTableJogBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.ShakeTableJogToFalse();
        }

        private void MachineManualUpBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineManualUpToTrue();
        }

        private void MachineManualUpBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineManualUpToFalse();
        }

        private void MachineManualDownBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineManualDownToTrue();
        }

        private void MachineManualDownBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.MachineManualDownToFalse();
        }

        private void FunnelValveManualControlBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchFunnelValveManualControl();
        }

        private void MachineManualBeltsBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchMachineManualControl();
        }

        private void MachineAirLockValveBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchMachineAirLockValve();
        }

        private void FillingValveManualOpenBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveManualOpenToFalse();
        }

        private void FillingValveManualCloseBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.FillingValveManualCloseToFalse();
        }

        private void DataResetBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.DataResetToTrue();
        }

        private void DataResetBtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.DataResetToFalse();
        }

        private void ShakeTable_TestBtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PlcSettingMessageBus.pLCManagement.SwitchShakeTable_Test();
        }
    }
}
