InitParam.cs 6.03 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13
using System;
using System.Collections.Generic;
using System.Text;
using Misc;
using System.Net;
using System.IO;
using System.ComponentModel;
using System.Xml.Linq;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;

namespace FLY.Thick.Base.Server
{
潘栩锋's avatar
潘栩锋 committed
14 15 16
    /// <summary>
    /// 硬件配置参数
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
17
    public class InitParam : IInitParamService, INotifyPropertyChanged
潘栩锋's avatar
潘栩锋 committed
18 19 20 21 22
    {
        #region 属性,成员变量的代理
        /// <summary>
        /// 扫描架长
        /// </summary>
23 24
        public int PosLength { get; set; } = 8900;

潘栩锋's avatar
潘栩锋 committed
25 26 27
        /// <summary>
        /// 从 flyad7 获取的
        /// </summary>
28
        public int PosOfGrid { get; set; } = 10;
潘栩锋's avatar
潘栩锋 committed
29 30 31 32 33 34

        /// <summary>
        /// timeGridAdv 使能
        /// </summary>
        public bool IsTimeGridAdvEnabled { get; set; }

35
       
潘栩锋's avatar
潘栩锋 committed
36 37 38
        /// <summary>
        /// 自动归原点间距
        /// </summary>
39
        public int AutoOrgInterval { get; set; } = 10;
潘栩锋's avatar
潘栩锋 committed
40

41

潘栩锋's avatar
潘栩锋 committed
42 43 44 45

        /// <summary>
        /// 线速度来源
        /// </summary>
46
        public FilmVSRC FilmVSrc { get; set; } = FilmVSRC.ROUND;
潘栩锋's avatar
潘栩锋 committed
47

潘栩锋's avatar
潘栩锋 committed
48 49 50
        /// <summary>
        /// 最小线速度 m/min
        /// </summary>
51 52
        public int FilmVThreshold { get; set; } = 5;

潘栩锋's avatar
潘栩锋 committed
53 54 55 56 57 58



        /// <summary>
        /// 编码器2 mm/pulse
        /// </summary>
59
        public double Encoder2_mmpp { get; set; } = 0.1;
潘栩锋's avatar
潘栩锋 committed
60

潘栩锋's avatar
潘栩锋 committed
61

潘栩锋's avatar
潘栩锋 committed
62 63 64
        /// <summary>
        /// //1圈多少mm
        /// </summary>
65
        public double MmOfR { get; set; } = 376.8;
潘栩锋's avatar
潘栩锋 committed
66 67 68 69

        /// <summary>
        /// 编码器1 mm/pulse
        /// </summary>
70
        public double Encoder1_mmpp { get; set; } = 0.0943;
潘栩锋's avatar
潘栩锋 committed
71 72 73 74 75 76 77




        /// <summary>
        /// 设置的速度,与 实际速度比例
        /// </summary>
78
        public double Speed1Scale { get; set; } = 1;
潘栩锋's avatar
潘栩锋 committed
79 80 81 82 83


        /// <summary>
        /// 扫描时速度
        /// </summary>
84 85 86
        public UInt32 VScan { get; set; } = 8000;


潘栩锋's avatar
潘栩锋 committed
87 88 89 90

        /// <summary>
        /// 调试时速度,向前走,向后走
        /// </summary>
91
        public UInt32 VJOG { get; set; } = 5000;
潘栩锋's avatar
潘栩锋 committed
92 93 94 95

        /// <summary>
        /// 精确速度 Velocity Of Accuracy  如: 机架修正, 样品取样, 机架信息获取
        /// </summary>
96
        public UInt32 VAccuracy { get; set; } = 3000;
潘栩锋's avatar
潘栩锋 committed
97

潘栩锋's avatar
潘栩锋 committed
98

潘栩锋's avatar
潘栩锋 committed
99 100 101
        /// <summary>
        /// 开始速度 Start Velocity
        /// </summary>
102
        public UInt32 SVelocity { get; set; } = 500;
潘栩锋's avatar
潘栩锋 committed
103

潘栩锋's avatar
潘栩锋 committed
104 105 106
        /// <summary>
        /// 加速时间
        /// </summary>
107
        public UInt32 ATime { get; set; } = 200;
潘栩锋's avatar
潘栩锋 committed
108

潘栩锋's avatar
潘栩锋 committed
109 110 111
        /// <summary>
        /// 减速时间
        /// </summary>
112
        public UInt32 DTime { get; set; } = 200;
潘栩锋's avatar
潘栩锋 committed
113

潘栩锋's avatar
潘栩锋 committed
114 115 116
        /// <summary>
        /// 归0速度1
        /// </summary>
117
        public UInt32 HVelocity1 { get; set; } = 5000;
潘栩锋's avatar
潘栩锋 committed
118

潘栩锋's avatar
潘栩锋 committed
119 120 121
        /// <summary>
        /// 归0速度2
        /// </summary>
122
        public UInt32 HVelocity2 { get; set; } = 1000;
潘栩锋's avatar
潘栩锋 committed
123 124 125 126 127 128 129




        /// <summary>
        /// 数据有效源
        /// </summary>
130
        public DATAVALIDSRC DataValidSrc { get; set; } = DATAVALIDSRC.VALID;
潘栩锋's avatar
潘栩锋 committed
131 132 133 134

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

潘栩锋's avatar
潘栩锋 committed
137 138 139 140

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


潘栩锋's avatar
潘栩锋 committed
144 145 146 147

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

潘栩锋's avatar
潘栩锋 committed
150 151 152 153

        /// <summary>
        /// 有小托辊
        /// </summary>
154 155
        public bool HasHold { get; set; } = true;

156 157 158 159 160
        /// <summary>
        /// 有打孔设备
        /// </summary>
        public bool HasPunch { get; set; } = false;

161 162 163 164 165
        /// <summary>
        /// 有纵向光纤传感器
        /// </summary>
        public bool HasVSign { get; set; } = false;

潘栩锋's avatar
潘栩锋 committed
166 167 168 169 170 171 172 173 174 175 176
        /// <summary>
        /// 有横向光纤传感器
        /// </summary>
        public bool HasHSign { get; set; } = false;


        /// <summary>
        /// 纵向光纤传感器 与 探头纵向偏移,单位mm
        /// X光在光纤传感器的后面,VSignOffset为正
        /// </summary>
        public int VSignOffset { get; set; } = 50;
177 178 179 180
        /// <summary>
        /// 打孔设备与探头中心偏移,单位mm
        /// </summary>
        public int PunchOffset { get; set; } = 120;
潘栩锋's avatar
潘栩锋 committed
181 182 183 184 185 186 187


        /// <summary>
        /// 有机架修正功能
        /// </summary>
        public bool HasScanCorr { get; set; } = true;

潘栩锋's avatar
潘栩锋 committed
188 189
        #endregion

潘栩锋's avatar
潘栩锋 committed
190 191 192 193
        private string param_path = "initparam.json";
        /// <summary>
        /// 
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
194 195 196 197
        public InitParam()
        {

        }
潘栩锋's avatar
潘栩锋 committed
198 199 200 201
        /// <summary>
        /// 
        /// </summary>
        /// <param name="param_path"></param>
潘栩锋's avatar
潘栩锋 committed
202 203 204 205 206 207 208
        public InitParam(string param_path)
        {
            if (!string.IsNullOrEmpty(param_path))
                this.param_path = param_path;

            Load();
        }
潘栩锋's avatar
潘栩锋 committed
209 210 211 212
        /// <summary>
        /// 加载
        /// </summary>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
213
        public bool Load()
潘栩锋's avatar
潘栩锋 committed
214
        {
潘栩锋's avatar
潘栩锋 committed
215
            //return Misc.SaveToXmlHepler.Load(param_path, this);
潘栩锋's avatar
潘栩锋 committed
216
            if (!File.Exists(param_path))
潘栩锋's avatar
潘栩锋 committed
217 218 219 220 221 222 223 224
            {
                return false;
            }
            try
            {
                string json = File.ReadAllText(param_path);
                Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
            }
潘栩锋's avatar
潘栩锋 committed
225 226
            catch
            {
潘栩锋's avatar
潘栩锋 committed
227 228 229
                return false;
            }
            return true;
潘栩锋's avatar
潘栩锋 committed
230
        }
潘栩锋's avatar
潘栩锋 committed
231 232 233
        /// <summary>
        /// 保存
        /// </summary>
234
        public void Save()
潘栩锋's avatar
潘栩锋 committed
235
        {
236
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
潘栩锋's avatar
潘栩锋 committed
237
            File.WriteAllText(param_path, json);
潘栩锋's avatar
潘栩锋 committed
238 239 240 241
        }


        #region INotifyPropertyChanged 成员
242

潘栩锋's avatar
潘栩锋 committed
243 244 245 246
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

潘栩锋's avatar
潘栩锋 committed
247 248 249
        /// <summary>
        /// 应用
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
250 251 252 253 254
        public void Apply()
        {
            Save();
        }
    }
潘栩锋's avatar
潘栩锋 committed
255 256


潘栩锋's avatar
潘栩锋 committed
257
}