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
{
///
/// 硬件配置参数
///
public class InitParam : IInitParamService, INotifyPropertyChanged
{
#region 属性,成员变量的代理
///
/// 扫描架长
///
public int PosLength { get; set; } = 8900;
///
/// 从 flyad7 获取的
///
public int PosOfGrid { get; set; } = 10;
///
/// timeGridAdv 使能
///
public bool IsTimeGridAdvEnabled { get; set; }
///
/// 自动归原点间距
///
public int AutoOrgInterval { get; set; } = 10;
///
/// 线速度来源
///
public FilmVSRC FilmVSrc { get; set; } = FilmVSRC.ROUND;
///
/// 最小线速度 m/min
///
public int FilmVThreshold { get; set; } = 5;
///
/// 编码器2 mm/pulse
///
public double Encoder2_mmpp { get; set; } = 0.1;
///
/// //1圈多少mm
///
public double MmOfR { get; set; } = 376.8;
///
/// 编码器1 mm/pulse
///
public double Encoder1_mmpp { get; set; } = 0.0943;
///
/// 设置的速度,与 实际速度比例
///
public double Speed1Scale { get; set; } = 1;
///
/// 扫描时速度
///
public UInt32 VScan { get; set; } = 8000;
///
/// 调试时速度,向前走,向后走
///
public UInt32 VJOG { get; set; } = 5000;
///
/// 精确速度 Velocity Of Accuracy 如: 机架修正, 样品取样, 机架信息获取
///
public UInt32 VAccuracy { get; set; } = 3000;
///
/// 开始速度 Start Velocity
///
public UInt32 SVelocity { get; set; } = 500;
///
/// 加速时间
///
public UInt32 ATime { get; set; } = 200;
///
/// 减速时间
///
public UInt32 DTime { get; set; } = 200;
///
/// 归0速度1
///
public UInt32 HVelocity1 { get; set; } = 5000;
///
/// 归0速度2
///
public UInt32 HVelocity2 { get; set; } = 1000;
///
/// 数据有效源
///
public DATAVALIDSRC DataValidSrc { get; set; } = DATAVALIDSRC.VALID;
///
/// 当数据有效状态改变,自动按F1,F3
///
public bool AutoF1F3 { get; set; }
///
/// 当数据有效状态 无效->有效 ,等待多久重新扫描 ,单位s
///
public int ReStartDelay { get; set; } = 5;
///
/// 有按样标定硬件
///
public bool HasProfileSample { get; set; }
///
/// 有小托辊
///
public bool HasHold { get; set; } = true;
///
/// 有打孔设备
///
public bool HasPunch { get; set; } = false;
///
/// 有纵向光纤传感器
///
public bool HasVSign { get; set; } = false;
///
/// 有横向光纤传感器
///
public bool HasHSign { get; set; } = false;
///
/// 纵向光纤传感器 与 探头纵向偏移,单位mm
/// X光在光纤传感器的后面,VSignOffset为正
///
public int VSignOffset { get; set; } = 50;
///
/// 打孔设备与探头中心偏移,单位mm
///
public int PunchOffset { get; set; } = 120;
///
/// 有机架修正功能
///
public bool HasScanCorr { get; set; } = true;
#endregion
private string param_path = "initparam.json";
///
///
///
public InitParam()
{
}
///
///
///
///
public InitParam(string param_path)
{
if (!string.IsNullOrEmpty(param_path))
this.param_path = param_path;
Load();
}
///
/// 加载
///
///
public bool Load()
{
//return Misc.SaveToXmlHepler.Load(param_path, this);
if (!File.Exists(param_path))
{
return false;
}
try
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
}
catch
{
return false;
}
return true;
}
///
/// 保存
///
public void Save()
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(param_path, json);
}
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
#endregion
///
/// 应用
///
public void Apply()
{
Save();
}
}
}