using FestoDebugger.Beckoff;
using FestoDebugger.Models;
using FestoDebugger.Service;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 FestoDebugger.UserControls
{
///
/// FestoControl.xaml 的交互逻辑
///
public partial class FestoControl : UserControl
{
public FestoControl()
{
InitializeComponent();
}
public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
"ModuleName", typeof(string), typeof(FestoControl),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
///
/// 信号名称
///
public string ModuleName
{
get
{
return (string)this.GetValue(ModuleNameProperty);
}
set
{
this.SetValue(ModuleNameProperty, value);
}
}
public static readonly DependencyProperty SignalOnProperty = DependencyProperty.Register(
"SignalOn", typeof(bool), typeof(FestoControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
///
/// WaferPresent
///
public bool SignalOn
{
get
{
return (bool)this.GetValue(SignalOnProperty);
}
set
{
this.SetValue(SignalOnProperty, value);
}
}
public static readonly DependencyProperty ModuleDataProperty = DependencyProperty.Register(
"ModuleData", typeof(SignalModuleData), typeof(FestoControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));
///
/// WaferPresent
///
public SignalModuleData ModuleData
{
get
{
return (SignalModuleData)this.GetValue(ModuleDataProperty);
}
set
{
this.SetValue(ModuleDataProperty, value);
}
}
private void On_Click(object sender, RoutedEventArgs e)
{
object[] paramater = new object[] { $"{ModuleData.ModuleName}",true };
BeckhoffIOManager.Instance.WriteDoOperation(" ", paramater);
}
private void Off_Click(object sender, RoutedEventArgs e)
{
object[] paramater = new object[] { $"{ModuleData.ModuleName}", false };
BeckhoffIOManager.Instance.WriteDoOperation(" ", paramater);
}
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != null)
{
SignalModuleData newValue = (SignalModuleData)e.NewValue;
d.SetValue(SignalOnProperty, newValue.SignalOn);
}
}
}
}