PgInitparam.xaml.cs 11.3 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1
using FLY.Thick.Base.Common;
潘栩锋's avatar
潘栩锋 committed
2 3
using FLY.Thick.Base.IService;
using GalaSoft.MvvmLight.Command;
潘栩锋's avatar
潘栩锋 committed
4 5 6 7
using System;
using System.ComponentModel;
using System.Windows.Controls;
using Unity;
潘栩锋's avatar
潘栩锋 committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21

namespace FLY.Thick.Base.UI
{
    /// <summary>
    /// Page_Initparam.xaml 的交互逻辑
    /// </summary>
    public partial class PgInitparam : Page
    {
        PgInitParamVm viewModel;
        public PgInitparam()
        {
            InitializeComponent();
        }
        [InjectionMethod]
潘栩锋's avatar
潘栩锋 committed
22
        public void Init(IInitParamService initParamService)
潘栩锋's avatar
潘栩锋 committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
        {
            viewModel = new PgInitParamVm();
            viewModel.Init(initParamService);
            this.DataContext = viewModel;
        }
    }
    public class PgInitParamVm : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        #region 参数
        /// <summary>
        /// 扫描架长
        /// </summary>
        public int PosLength { get; set; }

        public bool IsTimeGridAdvEnabled { get; set; }
        /// <summary>
        /// 自动归原点间距,次数
        /// </summary>
        public int AutoOrgInterval { get; set; }


        /// <summary>
        /// 编码器1 mm/pulse
        /// </summary>
        public double Encoder1_mmpp { get; set; }

        /// <summary>
        /// 设置的速度,与 实际速度比例 Speed1 = VScan*Speed1Scale
        /// </summary>
        public double Speed1Scale { get; set; }

        /// <summary>
        /// 线速度来源
        /// </summary>
        public FilmVSRC FilmVSrc { get; set; }

        /// <summary>
        /// 最小线速度 m/min
        /// </summary>
        public int FilmVThreshold { get; set; }
        /// <summary>
        /// 线速度:编码器2 mm/pulse
        /// </summary>
        public double Encoder2_mmpp { get; set; }

        /// <summary>
        /// 线速度:1圈多少mm
        /// </summary>
        public double MmOfR { get; set; }



        /// <summary>
        /// 数据有效源
        /// </summary>
        public DATAVALIDSRC DataValidSrc { get; set; }



        /// <summary>
        /// 当数据有效状态改变,自动按F1,F3
        /// </summary>
        public bool AutoF1F3 { get; set; }

        /// <summary>
        /// 当数据有效状态  无效->有效 ,等待多久重新扫描 ,单位s
        /// </summary>
        public int ReStartDelay { get; set; }

        /// <summary>
        /// 有按样标定硬件
        /// </summary>
        public bool HasProfileSample { get; set; }

        /// <summary>
        /// 有小托辊
        /// </summary>
        public bool HasHold { get; set; }
潘栩锋's avatar
潘栩锋 committed
103 104 105
        /// <summary>
        /// 打孔器偏移量
        /// </summary>
106
        public int PunchOffset { get; set; }
潘栩锋's avatar
潘栩锋 committed
107 108 109
        /// <summary>
        /// 有打孔器
        /// </summary>
110
        public bool HasPunch { get; set; }
潘栩锋's avatar
潘栩锋 committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

        /// <summary>
        /// 有纵向光纤传感器
        /// </summary>
        public bool HasVSign { get; set; }

        /// <summary>
        /// 纵向光纤传感器与X光偏移 mm
        /// </summary>
        public int VSignOffset { get; set; }

        /// <summary>
        /// 有横向光纤传感器
        /// </summary>
        public bool HasHSign { get; set; }
        /// <summary>
        /// 有机架修正功能
        /// </summary>
        public bool HasScanCorr { get; set; }
潘栩锋's avatar
潘栩锋 committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
        #region 速度

        /// <summary>
        /// 扫描时速度 Velocity Of Scan 
        /// </summary>
        public UInt32 VScan { get; set; }
        /// <summary>
        /// 调试时速度,向前走,向后走 Velocity Of JOG
        /// </summary>
        public UInt32 VJOG { get; set; }
        /// <summary>
        /// 精确速度 Velocity Of Accuracy  如: 机架修正, 样品取样, 机架信息获取
        /// </summary>
        public UInt32 VAccuracy { set; get; }
        /// <summary>
        /// 开始速度 Start Velocity
        /// </summary>
        public UInt32 SVelocity { set; get; }
        /// <summary>
        /// 加速时间
        /// </summary>
        public UInt32 ATime { set; get; }
        /// <summary>
        /// 减速时间
        /// </summary>
        public UInt32 DTime { set; get; }
        /// <summary>
        /// 归0速度1
        /// </summary>
        public UInt32 HVelocity1 { set; get; }
        /// <summary>
        /// 归0速度2
        /// </summary>
        public UInt32 HVelocity2 { set; get; }

        #endregion

        /// <summary>
        /// 数据库保存的月数
        /// </summary>
        public int DBKeepMonth { get; set; }
        /// <summary>
        /// 数据库路径
        /// </summary>
        public string DbPath { get; set; }
        #endregion

        #region Command
        public RelayCommand ApplyCmd { get; }
        public RelayCommand SelectDbPathCmd { get; }
        #endregion


        IInitParamService initParamService;

        public PgInitParamVm()
        {
            ApplyCmd = new RelayCommand(Apply);
            SelectDbPathCmd = new RelayCommand(SelectDbPath);
        }


        public void Init(IInitParamService initParamService)
        {
            this.initParamService = initParamService;

潘栩锋's avatar
潘栩锋 committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.PosLength), this, nameof(PosLength));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.IsTimeGridAdvEnabled), this, nameof(IsTimeGridAdvEnabled));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.AutoOrgInterval), this, nameof(AutoOrgInterval));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Encoder1_mmpp), this, nameof(Encoder1_mmpp));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Speed1Scale), this, nameof(Speed1Scale));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.FilmVSrc), this, nameof(FilmVSrc));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.FilmVThreshold), this, nameof(FilmVThreshold));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Encoder2_mmpp), this, nameof(Encoder2_mmpp));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.MmOfR), this, nameof(MmOfR));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DataValidSrc), this, nameof(DataValidSrc));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.AutoF1F3), this, nameof(AutoF1F3));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.ReStartDelay), this, nameof(ReStartDelay));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasProfileSample), this, nameof(HasProfileSample));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasHold), this, nameof(HasHold));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VScan), this, nameof(VScan));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VJOG), this, nameof(VJOG));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VAccuracy), this, nameof(VAccuracy));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.SVelocity), this, nameof(SVelocity));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.ATime), this, nameof(ATime));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DTime), this, nameof(DTime));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity1), this, nameof(HVelocity1));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity2), this, nameof(HVelocity2));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DBKeepMonth), this, nameof(DBKeepMonth));
219
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DbDirPath), this, nameof(DbPath));
220 221 222

            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.PunchOffset), this, nameof(PunchOffset));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasPunch), this, nameof(HasPunch));
潘栩锋's avatar
潘栩锋 committed
223

潘栩锋's avatar
潘栩锋 committed
224 225 226 227 228
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VSignOffset), this, nameof(VSignOffset));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasVSign), this, nameof(HasVSign));

            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasHSign), this, nameof(HasHSign));
            Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasScanCorr), this, nameof(HasScanCorr));
潘栩锋's avatar
潘栩锋 committed
229 230
        }

潘栩锋's avatar
潘栩锋 committed
231
        private void Apply()
潘栩锋's avatar
潘栩锋 committed
232 233 234 235
        {
            if (!WdPassword.Authorize("InitParam"))
                return;

潘栩锋's avatar
潘栩锋 committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
            initParamService.PosLength = this.PosLength;
            initParamService.IsTimeGridAdvEnabled = this.IsTimeGridAdvEnabled;
            initParamService.AutoOrgInterval = this.AutoOrgInterval;
            initParamService.Encoder1_mmpp = this.Encoder1_mmpp;
            initParamService.Speed1Scale = this.Speed1Scale;
            initParamService.FilmVSrc = this.FilmVSrc;
            initParamService.FilmVThreshold = this.FilmVThreshold;
            initParamService.Encoder2_mmpp = this.Encoder2_mmpp;
            initParamService.MmOfR = this.MmOfR;
            initParamService.DataValidSrc = this.DataValidSrc;
            initParamService.AutoF1F3 = this.AutoF1F3;
            initParamService.ReStartDelay = this.ReStartDelay;
            initParamService.HasProfileSample = this.HasProfileSample;
            initParamService.HasHold = this.HasHold;
            initParamService.VScan = this.VScan;
            initParamService.VJOG = this.VJOG;
            initParamService.VAccuracy = this.VAccuracy;
            initParamService.SVelocity = this.SVelocity;
            initParamService.ATime = this.ATime;
            initParamService.DTime = this.DTime;
            initParamService.HVelocity1 = this.HVelocity1;
            initParamService.HVelocity2 = this.HVelocity2;
            initParamService.DBKeepMonth = this.DBKeepMonth;
259
            initParamService.DbDirPath = this.DbPath;
260 261 262 263

            initParamService.HasPunch = this.HasPunch;
            initParamService.PunchOffset = this.PunchOffset;

潘栩锋's avatar
潘栩锋 committed
264 265 266 267 268
            initParamService.HasVSign = this.HasVSign;
            initParamService.VSignOffset = this.VSignOffset;

            initParamService.HasHSign = this.HasHSign;
            initParamService.HasScanCorr = this.HasScanCorr;
潘栩锋's avatar
潘栩锋 committed
269 270 271 272
            initParamService.Apply();
            FLY.ControlLibrary.Window_Tip.Show("应用成功",
                null,
                TimeSpan.FromSeconds(2));
潘栩锋's avatar
潘栩锋 committed
273

潘栩锋's avatar
潘栩锋 committed
274 275 276 277 278
        }

        private void SelectDbPath()
        {

279 280 281
            System.Windows.Forms.FolderBrowserDialog open = new System.Windows.Forms.FolderBrowserDialog();
            
            open.SelectedPath = DbPath;
潘栩锋's avatar
潘栩锋 committed
282 283 284

            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
285
                DbPath = open.SelectedPath;
潘栩锋's avatar
潘栩锋 committed
286 287 288 289
            }
        }
    }
}