IbcPanel.xaml.cs 5.7 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4
using FLY.Integrated.Client;
using FLY.Integrated.IService;
using MultiLayout.UiModule;
using System;
5 6 7 8 9 10 11 12 13 14 15 16 17
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;
潘栩锋's avatar
潘栩锋 committed
18
using Unity;
19

潘栩锋's avatar
潘栩锋 committed
20
namespace FLY.Integrated.UI.Client.UiModule
21 22
{
    /// <summary>
潘栩锋's avatar
潘栩锋 committed
23
    /// UcIbcPanel.xaml 的交互逻辑
24
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
25
    public partial class IbcPanel : UserControl
26
    {
潘栩锋's avatar
潘栩锋 committed
27 28
        IUnityContainer container;
        IIntegratedSystemService integratedSystemService;
潘栩锋's avatar
潘栩锋 committed
29 30
        FLY.OBJComponents.Client.SetPLCUpdatePlan setPlan;

潘栩锋's avatar
潘栩锋 committed
31
        public IbcPanel()
32 33 34
        {
            InitializeComponent();
        }
潘栩锋's avatar
潘栩锋 committed
35

潘栩锋's avatar
潘栩锋 committed
36 37 38 39
        [InjectionMethod]
        public void Init(
            IUnityContainer container,
            IIntegratedSystemService integratedSystemService)
潘栩锋's avatar
潘栩锋 committed
40
        {
潘栩锋's avatar
潘栩锋 committed
41 42 43
            this.container = container;
            this.integratedSystemService = integratedSystemService;
            this.DataContext = integratedSystemService.Ibc;
潘栩锋's avatar
潘栩锋 committed
44 45 46

            //注册属性更新计划
            setPlan = new FLY.OBJComponents.Client.SetPLCUpdatePlan(
潘栩锋's avatar
潘栩锋 committed
47 48
                integratedSystemService.PLCos,
                integratedSystemService.Ibc,
潘栩锋's avatar
潘栩锋 committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
                new string[] {
                    "InletAirFreq",
                    "InletAirFreqSet",
                    "IsInletAirOn",

                    "OutletAirFreq",
                    "OutletAirFreqSet",
                    "IsOutletAirOn",
                    "IsOutletAirFreqChanged",

                    "ExCoolFreq",
                    "ExCoolFreqSet",
                    "IsExCoolOn",

                    "FilmWidth",
                    "FilmWidthSet",
                    "IsFilmWidthChanged",
                    "ErrorCorrection",

                    "IsIBCAuto"
            });


潘栩锋's avatar
潘栩锋 committed
72
            integratedSystemService.Ibc.PropertyChanged += IbcData_PropertyChanged;
潘栩锋's avatar
潘栩锋 committed
73 74 75 76
        }

        private async void IbcData_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
77 78
            if ((integratedSystemService is IntegratedSystemServiceClient) &&
                ((integratedSystemService as IntegratedSystemServiceClient).IsInPushValue)) {
潘栩锋's avatar
潘栩锋 committed
79
                return;
潘栩锋's avatar
潘栩锋 committed
80
            }
潘栩锋's avatar
潘栩锋 committed
81 82 83
            if (e.PropertyName == "FilmWidthSet")
            {
                await Task.Delay(1000);//1s后触发通知
潘栩锋's avatar
潘栩锋 committed
84
                integratedSystemService.Ibc.IsFilmWidthChanged = true;
潘栩锋's avatar
潘栩锋 committed
85 86 87 88
            }
            else if (e.PropertyName == "OutletAirFreqSet")
            {
                await Task.Delay(1000);//1s后触发通知
潘栩锋's avatar
潘栩锋 committed
89
                integratedSystemService.Ibc.IsOutletAirFreqChanged = true;
潘栩锋's avatar
潘栩锋 committed
90 91 92 93 94 95
            }
        }

        private void btnK123Click(object sender, RoutedEventArgs e)
        {
            WdK123 w = new WdK123();
潘栩锋's avatar
潘栩锋 committed
96
            container.BuildUp(w);
潘栩锋's avatar
潘栩锋 committed
97 98 99 100 101 102
            w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            w.ShowDialog();
        }

        private void btnOutletAirPlusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
103 104
            if (integratedSystemService.Ibc.OutletAirFreqSet < 49.9)
                integratedSystemService.Ibc.OutletAirFreqSet += 0.1f;
潘栩锋's avatar
潘栩锋 committed
105 106 107
        }
        private void btnOutletAirMinusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
108 109
            if (integratedSystemService.Ibc.OutletAirFreqSet > 0.1)
                integratedSystemService.Ibc.OutletAirFreqSet -= 0.1f;
潘栩锋's avatar
潘栩锋 committed
110 111 112
        }
        private void btnInletAirPlusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
113 114
            if (integratedSystemService.Ibc.InletAirFreqSet < 49.9)
                integratedSystemService.Ibc.InletAirFreqSet += 0.1f;
潘栩锋's avatar
潘栩锋 committed
115 116 117 118
        }

        private void btnInletAirMinusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
119 120
            if (integratedSystemService.Ibc.InletAirFreqSet > 0.1)
                integratedSystemService.Ibc.InletAirFreqSet -= 0.1f;
潘栩锋's avatar
潘栩锋 committed
121 122 123 124
        }

        private void btnExCoolPlusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
125 126
            if (integratedSystemService.Ibc.ExCoolFreqSet < 49.9)
                integratedSystemService.Ibc.ExCoolFreqSet += 0.1f;
潘栩锋's avatar
潘栩锋 committed
127 128 129 130
        }

        private void btnExCoolMinusClick(object sender, RoutedEventArgs e)
        {
潘栩锋's avatar
潘栩锋 committed
131 132
            if (integratedSystemService.Ibc.ExCoolFreqSet > 0.1)
                integratedSystemService.Ibc.ExCoolFreqSet -= 0.1f;
潘栩锋's avatar
潘栩锋 committed
133 134 135
        }
    }

潘栩锋's avatar
潘栩锋 committed
136
    public class UiModule2_IbcPanel : IUiModule2
潘栩锋's avatar
潘栩锋 committed
137 138 139 140 141
    {
        /// <summary>
        /// 控件标题
        /// 它的值取决于culture
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
142 143 144
        public string Title => "综合.IBC调节";
        public ComponentType Type => ComponentType.Graph;
        public bool IsUnique => true;
潘栩锋's avatar
潘栩锋 committed
145 146 147 148 149 150 151

        /// <summary>
        /// 控件
        /// 创建时,需要给它唯一ID,让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
152
        public FrameworkElement GetComponent(int id, IUnityContainer container)
潘栩锋's avatar
潘栩锋 committed
153
        {
潘栩锋's avatar
潘栩锋 committed
154
            return container.Resolve<IbcPanel>();
潘栩锋's avatar
潘栩锋 committed
155 156 157 158 159 160 161 162
        }

        /// <summary>
        /// 控件缩略图,用于编辑界面时,大致看看
        /// 创建时,需要给它唯一ID,让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
163
        public FrameworkElement GetThumbnail()
潘栩锋's avatar
潘栩锋 committed
164 165 166 167 168 169 170 171 172 173 174 175
        {
            return new System.Windows.Controls.Grid();
        }


        /// <summary>
        /// 给出全部控件ID, 控件自行删除没有的参数
        /// </summary>
        /// <param name="IDs"></param>
        public void MatchParam(int[] IDs)
        {
        }
176 177
    }
}