using FLY.OBJComponents.Client;
using FLY.Winder.Common;
using FLY.Winder.IService;
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 Unity;
namespace FLY.Winder.UI.Client.UiModule
{
///
/// MainPanel.xaml 的交互逻辑
///
public partial class MainPanel2 : UserControl
{
IUnityContainer container;
IWinderSystemService winderSystem;
SetPLCUpdatePlan setPlan_accessory;
SetPLCUpdatePlan[] setPlan_winders = new SetPLCUpdatePlan[2];
public MainPanel2()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IWinderSystemService winderSystem)
{
this.container = container;
this.winderSystem = winderSystem;
this.DataContext = winderSystem;
grid_winder.DataContext = winderSystem;
//注册属性更新计划
setPlan_accessory = new SetPLCUpdatePlan(
winderSystem.PLCos,
winderSystem.Accessory,
new string[] {
nameof(WinderAccessory.VelocitySet),
nameof(WinderAccessory.IsVelocityChanged),
nameof(WinderAccessory.Velocity),
nameof(WinderAccessory.RotaryFreqSet),
nameof(WinderAccessory.IsRotaryFreqChanged),
nameof(WinderAccessory.RotaryCurrent),
nameof(WinderAccessory.RotaryFreq),
nameof(WinderAccessory.IsRotaryOn),
nameof(WinderAccessory.IsRotaryOrg),
nameof(WinderAccessory.IsRotaryForw),
nameof(WinderAccessory.IsRotaryBackw),
nameof(WinderAccessory.IsRotaryForwLimit),
nameof(WinderAccessory.IsRotaryForwTurn),
nameof(WinderAccessory.IsRotaryOrgSign),
nameof(WinderAccessory.IsRotaryBackwLimit),
nameof(WinderAccessory.IsRotaryBackwTurn),
nameof(WinderAccessory.Traction1Current),
nameof(WinderAccessory.IsTraction1On),
nameof(WinderAccessory.IsTraction2Manual),
nameof(WinderAccessory.Traction2TensionKgSet),
nameof(WinderAccessory.Traction2TensionKg),
nameof(WinderAccessory.Traction2Current),
nameof(WinderAccessory.IsTraction2Manual),
nameof(WinderAccessory.IsTraction2On)
});
for (int i = 0; i < 2; i++)
{
setPlan_winders[i] = new SetPLCUpdatePlan(
winderSystem.PLCos,
winderSystem.Items[i],
new string[] {
nameof(WinderInsideOutside.MeasureLenSet),
nameof(WinderInsideOutside.MeasurePreWarning),
nameof(WinderInsideOutside.MeasureLen),
nameof(WinderInsideOutside.MeasureStop),
nameof(WinderInsideOutside.TensionKgSet),
nameof(WinderInsideOutside.TensionKg),
nameof(WinderInsideOutside.Current),
nameof(WinderInsideOutside.IsManual),
nameof(WinderInsideOutside.IsOn)
});
}
}
private void button_v_set_Click(object sender, RoutedEventArgs e)
{
WdSetValue w = new WdSetValue();
w.Init(winderSystem.Accessory.VelocitySet, 200, 1, 0.1f, "速度设置", "m/min");
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
winderSystem.Accessory.VelocitySet = w.Value;
//它需要脉冲信号
winderSystem.Accessory.IsVelocityChanged = false;
winderSystem.Accessory.IsVelocityChanged = true;
winderSystem.Accessory.IsVelocityChanged = false;
}
}
private void button_manual_Click(object sender, RoutedEventArgs e)
{
var w = container.Resolve();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.ShowDialog();
}
private void button_freq_Click(object sender, RoutedEventArgs e)
{
WdSetValue w = new WdSetValue();
w.Init(winderSystem.Accessory.RotaryFreqSet, 50, 0.1f, 0.1f, "旋转频率", "Hz");
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
winderSystem.Accessory.RotaryFreqSet = w.Value;
//它需要上升沿信号
winderSystem.Accessory.IsRotaryFreqChanged = false;
winderSystem.Accessory.IsRotaryFreqChanged = true;
}
}
private void button_measure_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
WinderInsideOutside item = (WinderInsideOutside)(button.Tag);
WdMeasure w = new WdMeasure();
w.Init((int)(item.MeasureLenSet), (int)(item.MeasurePreWarning));
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
item.MeasureLenSet = w.viewmodel.MeasureLenSet;
item.MeasurePreWarning = w.viewmodel.MeasurePreWarning;
}
}
}
}