Commit a9967594 authored by 潘栩锋's avatar 潘栩锋 🚴

initparam 添加 数据库保存月数

parent 6f4472f1
...@@ -7,6 +7,8 @@ using FObjBase; ...@@ -7,6 +7,8 @@ using FObjBase;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE; using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using Newtonsoft.Json;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
public class InitParamServiceClient : FObj, IInitParamService public class InitParamServiceClient : FObj, IInitParamService
...@@ -165,6 +167,10 @@ namespace FLY.Thick.Base.Client ...@@ -165,6 +167,10 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public bool HasHold { get; set; } public bool HasHold { get; set; }
/// <summary>
/// 数据库保存的月数
/// </summary>
public int DBKeepMonth { get; set; }
#endregion #endregion
#region INotifyPropertyChanged 成员 #region INotifyPropertyChanged 成员
...@@ -204,15 +210,16 @@ namespace FLY.Thick.Base.Client ...@@ -204,15 +210,16 @@ namespace FLY.Thick.Base.Client
hvelocity2 = HVelocity2, hvelocity2 = HVelocity2,
hasProfileSample = HasProfileSample, hasProfileSample = HasProfileSample,
hasHold = HasHold hasHold = HasHold,
dBKeepMonth = DBKeepMonth
}; };
string json = JsonConvert.SerializeObject(p);
//获取所有数据,设置推送 //获取所有数据,设置推送
CurrObjSys.SetValueEx( CurrObjSys.SetValueEx(
mConn, mServerID, ID, mConn, mServerID, ID,
INITPARAM_OBJ_INTERFACE.SET_PARAMS, INITPARAM_OBJ_INTERFACE.SET_PARAMS,
p.ToBytes()); Misc.Converter.StringToBytes(json));
} }
public override void Dispose() public override void Dispose()
{ {
...@@ -238,9 +245,9 @@ namespace FLY.Thick.Base.Client ...@@ -238,9 +245,9 @@ namespace FLY.Thick.Base.Client
{ {
case INITPARAM_OBJ_INTERFACE.GET_PARAMS: case INITPARAM_OBJ_INTERFACE.GET_PARAMS:
{ {
INITPARAM_OBJ_INTERFACE.Pack_Params p = new INITPARAM_OBJ_INTERFACE.Pack_Params(); string json = Misc.Converter.BytesToString(infodata);
if (!p.TryParse(infodata))
return; var p = JsonConvert.DeserializeObject<INITPARAM_OBJ_INTERFACE.Pack_Params>(json);
PosLength = p.poslength; PosLength = p.poslength;
AutoOrgInterval = p.auto_org_interval; AutoOrgInterval = p.auto_org_interval;
...@@ -272,6 +279,7 @@ namespace FLY.Thick.Base.Client ...@@ -272,6 +279,7 @@ namespace FLY.Thick.Base.Client
HasProfileSample = p.hasProfileSample; HasProfileSample = p.hasProfileSample;
HasHold = p.hasHold; HasHold = p.hasHold;
DBKeepMonth = p.dBKeepMonth;
} break; } break;
} }
......
...@@ -122,6 +122,11 @@ namespace FLY.Thick.Base.IService ...@@ -122,6 +122,11 @@ namespace FLY.Thick.Base.IService
#endregion #endregion
/// <summary>
/// 数据库保存的月数
/// </summary>
int DBKeepMonth { get; set; }
void Apply(); void Apply();
} }
......
...@@ -10,7 +10,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -10,7 +10,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public class INITPARAM_OBJ_INTERFACE public class INITPARAM_OBJ_INTERFACE
{ {
#region Pack #region Pack
public class Pack_Params : IPack public class Pack_Params
{ {
public int poslength; public int poslength;
...@@ -47,131 +47,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -47,131 +47,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
public bool hasProfileSample; public bool hasProfileSample;
public bool hasHold; public bool hasHold;
public int dBKeepMonth;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(poslength));
buf.AddRange(BitConverter.GetBytes(adlag));
buf.AddRange(BitConverter.GetBytes(auto_org_interval));
buf.AddRange(BitConverter.GetBytes(posOfGrid));
buf.AddRange(BitConverter.GetBytes(encoder1_mmpp));
buf.AddRange(BitConverter.GetBytes(speed1scale));
buf.AddRange(BitConverter.GetBytes((int)filmVSrc));
buf.AddRange(BitConverter.GetBytes(filmVThreshold));
buf.AddRange(BitConverter.GetBytes(encoder2_mmpp));
buf.AddRange(BitConverter.GetBytes(encoder2_comp));
buf.AddRange(BitConverter.GetBytes(mmOfR));
buf.AddRange(BitConverter.GetBytes((int)data_valid_src));
buf.AddRange(BitConverter.GetBytes(autof1f3));
buf.AddRange(BitConverter.GetBytes(restartDelay));
buf.AddRange(BitConverter.GetBytes(vscan));
buf.AddRange(BitConverter.GetBytes(vjog));
buf.AddRange(BitConverter.GetBytes(vaccuracy));
buf.AddRange(BitConverter.GetBytes(svelocity));
buf.AddRange(BitConverter.GetBytes(atime));
buf.AddRange(BitConverter.GetBytes(dtime));
buf.AddRange(BitConverter.GetBytes(hvelocity1));
buf.AddRange(BitConverter.GetBytes(hvelocity2));
buf.AddRange(BitConverter.GetBytes(hasProfileSample));
buf.AddRange(BitConverter.GetBytes(hasHold));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
int cnt = 4 * 4 + 8 * 2;
if (value.Length <cnt)
return false;
int idx = 0;
poslength = BitConverter.ToInt32(value, idx);
idx += 4;
adlag = BitConverter.ToInt32(value, idx);
idx += 4;
auto_org_interval = BitConverter.ToInt32(value, idx);
idx += 4;
posOfGrid = BitConverter.ToInt32(value, idx);
idx += 4;
encoder1_mmpp = BitConverter.ToDouble(value, idx);
idx += 8;
speed1scale = BitConverter.ToDouble(value, idx);
idx += 8;
cnt += 4 + 4 + 8 + 4 + 8 + 4;
if (value.Length < cnt)
return false;
filmVSrc = (FilmVSRC)BitConverter.ToInt32(value, idx);
idx += 4;
filmVThreshold = BitConverter.ToInt32(value, idx);
idx += 4;
encoder2_mmpp = BitConverter.ToDouble(value, idx);
idx += 8;
encoder2_comp = BitConverter.ToSingle(value, idx);
idx += 4;
mmOfR = BitConverter.ToDouble(value, idx);
idx += 8;
data_valid_src = (DATAVALIDSRC)BitConverter.ToInt32(value, idx);
idx += 4;
cnt += 1 + 4;
if (value.Length < cnt)
return false;
autof1f3 = BitConverter.ToBoolean(value, idx);
idx++;
restartDelay = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += 4 * 8;
if (value.Length < cnt)
return false;
vscan = BitConverter.ToUInt32(value, idx);
idx += 4;
vjog = BitConverter.ToUInt32(value, idx);
idx += 4;
vaccuracy = BitConverter.ToUInt32(value, idx);
idx += 4;
svelocity = BitConverter.ToUInt32(value, idx);
idx += 4;
atime = BitConverter.ToUInt32(value, idx);
idx += 4;
dtime = BitConverter.ToUInt32(value, idx);
idx += 4;
hvelocity1 = BitConverter.ToUInt32(value, idx);
idx += 4;
hvelocity2 = BitConverter.ToUInt32(value, idx);
idx += 4;
cnt += 2;
if (value.Length < cnt)
return false;
hasProfileSample = BitConverter.ToBoolean(value, idx);
idx++;
hasHold = BitConverter.ToBoolean(value, idx);
idx++;
return true;
}
#endregion
} }
#endregion #endregion
......
...@@ -6,6 +6,7 @@ using FObjBase; ...@@ -6,6 +6,7 @@ using FObjBase;
using FLY.Thick.Base.OBJ_INTERFACE; using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using Newtonsoft.Json;
namespace FLY.Thick.Base.Server.OBJProxy namespace FLY.Thick.Base.Server.OBJProxy
{ {
...@@ -74,9 +75,11 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -74,9 +75,11 @@ namespace FLY.Thick.Base.Server.OBJProxy
hasProfileSample = mInitparam.HasProfileSample, hasProfileSample = mInitparam.HasProfileSample,
hasHold = mInitparam.HasHold hasHold = mInitparam.HasHold,
dBKeepMonth = mInitparam.DBKeepMonth
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
default: default:
infodata = null; infodata = null;
...@@ -89,9 +92,9 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -89,9 +92,9 @@ namespace FLY.Thick.Base.Server.OBJProxy
{ {
case INITPARAM_OBJ_INTERFACE.SET_PARAMS: case INITPARAM_OBJ_INTERFACE.SET_PARAMS:
{ {
INITPARAM_OBJ_INTERFACE.Pack_Params p = new INITPARAM_OBJ_INTERFACE.Pack_Params(); string json = Misc.Converter.BytesToString(infodata);
if (!p.TryParse(infodata))
break; var p = JsonConvert.DeserializeObject<INITPARAM_OBJ_INTERFACE.Pack_Params>(json);
mInitparam.PosLength = p.poslength; mInitparam.PosLength = p.poslength;
mInitparam.ADLag = p.adlag; mInitparam.ADLag = p.adlag;
...@@ -118,6 +121,7 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -118,6 +121,7 @@ namespace FLY.Thick.Base.Server.OBJProxy
mInitparam.HasProfileSample = p.hasProfileSample; mInitparam.HasProfileSample = p.hasProfileSample;
mInitparam.HasHold = p.hasHold; mInitparam.HasHold = p.hasHold;
mInitparam.DBKeepMonth = p.dBKeepMonth;
mInitparam.Apply(); mInitparam.Apply();
} break; } break;
} }
......
...@@ -15,430 +15,151 @@ namespace FLY.Thick.Base.Server ...@@ -15,430 +15,151 @@ namespace FLY.Thick.Base.Server
public class InitParam: IInitParamService, INotifyPropertyChanged, Misc.ISaveToXml public class InitParam: IInitParamService, INotifyPropertyChanged, Misc.ISaveToXml
{ {
#region 属性,成员变量的代理 #region 属性,成员变量的代理
private int poslen = 8900;//扫描架长
/// <summary> /// <summary>
/// 扫描架长 /// 扫描架长
/// </summary> /// </summary>
public int PosLength public int PosLength { get; set; } = 8900;
{
get { return poslen; }
set
{
poslen = value;
NotifyPropertyChanged("PosLength");
}
}
private int posofgrid = 10;
/// <summary> /// <summary>
/// 从 flyad7 获取的 /// 从 flyad7 获取的
/// </summary> /// </summary>
public int PosOfGrid public int PosOfGrid { get; set; } = 10;
{
get { return posofgrid; }
set
{
if (posofgrid != value)
{
posofgrid = value;
NotifyPropertyChanged("PosOfGrid");
}
}
}
private int adlag = 0;
/// <summary> /// <summary>
/// ad 滞后量 ms /// ad 滞后量 ms
/// </summary> /// </summary>
public int ADLag public int ADLag { get; set; }
{
get { return adlag; }
set
{
if (adlag != value)
{
adlag = value;
NotifyPropertyChanged("ADLag");
}
}
}
private int autoOriginInterval=10;//自动归原点的间隔
/// <summary> /// <summary>
/// 自动归原点间距 /// 自动归原点间距
/// </summary> /// </summary>
public int AutoOrgInterval public int AutoOrgInterval { get; set; } = 10;
{
get { return autoOriginInterval; }
set
{
if (autoOriginInterval != value)
{
autoOriginInterval = value;
NotifyPropertyChanged("AutoOrgInterval");
}
}
}
private FilmVSRC filmVSrc = FilmVSRC.ROUND;
/// <summary> /// <summary>
/// 线速度来源 /// 线速度来源
/// </summary> /// </summary>
public FilmVSRC FilmVSrc public FilmVSRC FilmVSrc { get; set; } = FilmVSRC.ROUND;
{
get {
return filmVSrc;
}
set {
if (filmVSrc != value)
{
filmVSrc = value;
NotifyPropertyChanged("FilmVSrc");
}
}
}
private int filmVThreshold = 5;
/// <summary> /// <summary>
/// 最小线速度 m/min /// 最小线速度 m/min
/// </summary> /// </summary>
public int FilmVThreshold public int FilmVThreshold { get; set; } = 5;
{
get {
return filmVThreshold;
}
set {
if (filmVThreshold != value)
{
filmVThreshold = value;
NotifyPropertyChanged("FilmVThreshold");
}
}
}
private double _encoder2_mmpp=0.1;
/// <summary> /// <summary>
/// 编码器2 mm/pulse /// 编码器2 mm/pulse
/// </summary> /// </summary>
public double Encoder2_mmpp public double Encoder2_mmpp { get; set; } = 0.1;
{
get { return _encoder2_mmpp; }
set
{
if (_encoder2_mmpp != value)
{
_encoder2_mmpp = value;
NotifyPropertyChanged("Encoder2_mmpp");
}
}
}
private float _encoder2_comp = 1;
/// <summary> /// <summary>
/// 编码器2 放大 /// 编码器2 放大
/// </summary> /// </summary>
public float Encoder2_comp public float Encoder2_comp { get; set; } = 1;
{
get { return _encoder2_comp; }
set
{
if (_encoder2_comp != value)
{
_encoder2_comp = value;
NotifyPropertyChanged("Encoder2_comp");
}
}
}
private double mmOfR=314;
/// <summary> /// <summary>
/// //1圈多少mm /// //1圈多少mm
/// </summary> /// </summary>
public double MmOfR { public double MmOfR { get; set; } = 376.8;
get
{
return mmOfR;
}
set
{
if (mmOfR != value)
{
mmOfR = value;
NotifyPropertyChanged("MmOfR");
}
}
}
private double _encoder1_mmpp=0.1;
/// <summary> /// <summary>
/// 编码器1 mm/pulse /// 编码器1 mm/pulse
/// </summary> /// </summary>
public double Encoder1_mmpp public double Encoder1_mmpp { get; set; } = 0.1;
{
get { return _encoder1_mmpp; }
set
{
if (_encoder1_mmpp != value)
{
_encoder1_mmpp = value;
NotifyPropertyChanged("Encoder1_mmpp");
}
}
}
private double speed1Scale=1;
/// <summary> /// <summary>
/// 设置的速度,与 实际速度比例 /// 设置的速度,与 实际速度比例
/// </summary> /// </summary>
public double Speed1Scale public double Speed1Scale { get; set; } = 1;
{
get { return speed1Scale; }
set
{
if (speed1Scale != value)
{
speed1Scale = value;
NotifyPropertyChanged("Speed1Scale");
}
}
}
private UInt32 velocity_scan = 8000;
/// <summary> /// <summary>
/// 扫描时速度 /// 扫描时速度
/// </summary> /// </summary>
public UInt32 VScan public UInt32 VScan { get; set; } = 8000;
{
get { return velocity_scan; }
set
{
if (velocity_scan != value)
{
velocity_scan = value;
NotifyPropertyChanged("VScan");
}
}
}
private UInt32 velocity_jog = 5000;
/// <summary> /// <summary>
/// 调试时速度,向前走,向后走 /// 调试时速度,向前走,向后走
/// </summary> /// </summary>
public UInt32 VJOG public UInt32 VJOG { get; set; } = 5000;
{
get { return velocity_jog; }
set
{
if (velocity_jog != value)
{
velocity_jog = value;
NotifyPropertyChanged("VJOG");
}
}
}
private UInt32 velocity_accuracy = 3000;
/// <summary> /// <summary>
/// 精确速度 Velocity Of Accuracy 如: 机架修正, 样品取样, 机架信息获取 /// 精确速度 Velocity Of Accuracy 如: 机架修正, 样品取样, 机架信息获取
/// </summary> /// </summary>
public UInt32 VAccuracy public UInt32 VAccuracy { get; set; } = 3000;
{
get {
return velocity_accuracy;
}
set {
if (velocity_accuracy != value)
{
velocity_accuracy = value;
NotifyPropertyChanged("VAccuracy");
}
}
}
private UInt32 sv=500;
/// <summary> /// <summary>
/// 开始速度 Start Velocity /// 开始速度 Start Velocity
/// </summary> /// </summary>
public UInt32 SVelocity public UInt32 SVelocity { get; set; } = 500;
{
get { return sv; }
set
{
if (sv != value)
{
sv = value;
NotifyPropertyChanged("SVelocity");
}
}
}
private UInt32 atime=200;
/// <summary> /// <summary>
/// 加速时间 /// 加速时间
/// </summary> /// </summary>
public UInt32 ATime public UInt32 ATime { get; set; } = 200;
{
get { return atime; }
set
{
if (atime != value)
{
atime = value;
NotifyPropertyChanged("ATime");
}
}
}
private UInt32 dtime=200;
/// <summary> /// <summary>
/// 减速时间 /// 减速时间
/// </summary> /// </summary>
public UInt32 DTime public UInt32 DTime { get; set; } = 200;
{
get { return dtime; }
set
{
if (dtime != value)
{
dtime = value;
NotifyPropertyChanged("DTime");
}
}
}
private UInt32 hv1=5000;
/// <summary> /// <summary>
/// 归0速度1 /// 归0速度1
/// </summary> /// </summary>
public UInt32 HVelocity1 public UInt32 HVelocity1 { get; set; } = 5000;
{
get { return hv1; }
set
{
if (hv1 != value)
{
hv1 = value;
NotifyPropertyChanged("HVelocity1");
}
}
}
private UInt32 hv2=1000;
/// <summary> /// <summary>
/// 归0速度2 /// 归0速度2
/// </summary> /// </summary>
public UInt32 HVelocity2 public UInt32 HVelocity2 { get; set; } = 1000;
{
get { return hv2; }
set
{
if (hv2 != value)
{
hv2 = value;
NotifyPropertyChanged("HVelocity2");
}
}
}
private DATAVALIDSRC dataValidSrc= DATAVALIDSRC.VALID;
/// <summary> /// <summary>
/// 数据有效源 /// 数据有效源
/// </summary> /// </summary>
public DATAVALIDSRC DataValidSrc public DATAVALIDSRC DataValidSrc { get; set; } = DATAVALIDSRC.VALID;
{
get { return dataValidSrc; }
set
{
if (dataValidSrc != value)
{
dataValidSrc = value;
NotifyPropertyChanged("DataValidSrc");
}
}
}
private bool autof1f3 = false;
/// <summary> /// <summary>
/// 当数据有效状态改变,自动按F1,F3 /// 当数据有效状态改变,自动按F1,F3
/// </summary> /// </summary>
public bool AutoF1F3 public bool AutoF1F3 { get; set; }
{
get { return autof1f3; }
set
{
if (autof1f3 != value)
{
autof1f3 = value;
NotifyPropertyChanged("AutoF1F3");
}
}
}
private int restartdelay = 5;
/// <summary> /// <summary>
/// 当数据有效状态 无效->有效 ,等待多久重新扫描 ,单位s /// 当数据有效状态 无效->有效 ,等待多久重新扫描 ,单位s
/// </summary> /// </summary>
public int ReStartDelay public int ReStartDelay { get; set; } = 5;
{
get { return restartdelay; }
set
{
if (restartdelay != value)
{
restartdelay = value;
NotifyPropertyChanged("ReStartDelay");
}
}
}
private bool hasProfileSample = false;
/// <summary> /// <summary>
/// 有按样标定硬件 /// 有按样标定硬件
/// </summary> /// </summary>
public bool HasProfileSample public bool HasProfileSample { get; set; }
{
get {
return hasProfileSample;
}
set {
if (hasProfileSample != value)
{
hasProfileSample = value;
NotifyPropertyChanged("HasProfileSample");
}
}
}
private bool hashold = true;
/// <summary> /// <summary>
/// 有小托辊 /// 有小托辊
/// </summary> /// </summary>
public bool HasHold public bool HasHold { get; set; } = true;
{
get /// <summary>
{ /// 数据库保存的月数
return hashold; /// </summary>
} public int DBKeepMonth { get; set; }
set
{
if (hashold != value)
{
hashold = value;
NotifyPropertyChanged("HasHold");
}
}
}
#endregion #endregion
private string param_path = "initparam.xml"; private string param_path = "initparam.xml";
...@@ -465,11 +186,7 @@ namespace FLY.Thick.Base.Server ...@@ -465,11 +186,7 @@ namespace FLY.Thick.Base.Server
#region INotifyPropertyChanged 成员 #region INotifyPropertyChanged 成员
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
#endregion #endregion
...@@ -500,7 +217,8 @@ namespace FLY.Thick.Base.Server ...@@ -500,7 +217,8 @@ namespace FLY.Thick.Base.Server
"ReStartDelay", "ReStartDelay",
"HasProfileSample", "HasProfileSample",
"HasHold" "HasHold",
"DBKeepMonth"
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment