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

initparam 添加 数据库保存月数

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