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

删除 没用文件

parent eaf0704a
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace FLY.Thick.Base.Common
{
//格式
//时间, 报警码, 总长0, 留白0, 总长1, 留白1, 总长2, 留白2
//2016-12-30 12:20:30, 0, 300.1, 18.1, 700.1, 18.1, 400.5, 18.1
//2016-12-30 12:20:30, 0, 299.8, 18.0, 700.5, 18.1, 401.0, 17.7
public class FlyData_CoatingSegmentHistory : FLY.Thick.RemoteHistory.IFlyData, INotifyPropertyChanged
{
private DateTime time;
public DateTime Time
{
get {
return time;
}
set
{
time = value;
NotifyPropertyChanged("Time");
}
}
int errno;
/// <summary>
/// 报警码, 0 没错误, 1总长报警,2留白报警,3数量错
/// </summary>
public int Errno
{
get
{
return errno;
}
set
{
errno = value;
NotifyPropertyChanged("Errno");
}
}
int partcount = 1;
/// <summary>
/// 段数,prfile设定,不是测的!!!
/// </summary>
public int PartCount
{
get {
return partcount;
}
set
{
if (partcount != value)
{
partcount = value;
NotifyPropertyChanged("PartCount");
}
}
}
ObservableCollection<CoatingSegmentPart> coatingPart = new ObservableCollection<CoatingSegmentPart>();
public ObservableCollection<CoatingSegmentPart> CoatingPart
{
get
{
return coatingPart;
}
}
public string GetHeader()
{
string str = "时间,报警码";
for (int i = 0; i < PartCount; i++)
{
str += ",总长" + i.ToString();
str += ",留白" + i.ToString();
}
return str;
}
public override string ToString()
{
string str;
str = Time.ToString("yyyy/MM/dd HH:mm:ss") + "," + Errno.ToString();
for (int i = 0; i < PartCount; i++)
{
if (i < CoatingPart.Count)
{
str += "," + CoatingPart[i].Total.ToString("F1");
str += "," + CoatingPart[i].Distance.ToString("F1");
}
else
{
str += ",,";
}
}
return str;
}
public bool TryParse(string header_str, string str)
{
CoatingPart.Clear();
int idx = 0;
//通过header_str, 解析PartCount
string[] items_header = header_str.Split(new char[] { ',' });
if (items_header.Length < 4)
return false;
//看最后一个 是“留白x”
Regex r = new Regex(@"留白\d+");
Match m = r.Match(items_header.Last());
if (!m.Success)
return false;
r = new Regex(@"\d+");
PartCount = int.Parse(r.Match(m.Value).Value) + 1;
//正文
string[] items = str.Split(new char[] { ',' });
if (items.Length < (2 + PartCount * 2))
return false;
DateTime dt;
int numi;
double numd;
if (!DateTime.TryParse(items[idx], out dt))
return false;
idx++;
Time = dt;
if (!int.TryParse(items[idx], out numi))
return false;
idx++;
Errno = numi;
for (int i = 0; i < PartCount; i++)
{
if (string.IsNullOrWhiteSpace(items[idx]))
{
idx += 2;
}
CoatingSegmentPart cp = new CoatingSegmentPart();
if (!double.TryParse(items[idx], out numd))
return false;
idx++;
cp.Total = numd;
if (!double.TryParse(items[idx], out numd))
return false;
idx++;
cp.Distance = numd;
CoatingPart.Add(cp);
}
return true;
}
/// <summary>
/// 最少12个字节转换
/// </summary>
/// <param name="value">需要转换的字符串</param>
/// <param name="offset">在字符串的偏移</param>
/// <param name="count">转换的字符数</param>
/// <returns></returns>
public bool TryParse(byte[] value, int offset, out int count)
{
int idx = offset;
count = 8 + 4 + 4 + 4;
if (value.Length - offset < count)
return false;
CoatingPart.Clear();
Time = new DateTime(BitConverter.ToInt64(value, idx));
idx += 8;
Errno = BitConverter.ToInt32(value, idx);
idx += 4;
PartCount = BitConverter.ToInt32(value, idx);
idx += 4;
int c = BitConverter.ToInt32(value, idx);
idx += 4;
count += c * 16;
if (value.Length - offset < count)
return false;
for (int i = 0; i < c; i++)
{
CoatingSegmentPart p = new CoatingSegmentPart();
p.TryParse(value, idx);
idx += 16;
CoatingPart.Add(p);
}
return true;
}
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(Time.Ticks));
buf.AddRange(BitConverter.GetBytes(Errno));
buf.AddRange(BitConverter.GetBytes(PartCount));
int cnt = (PartCount < CoatingPart.Count) ? PartCount : CoatingPart.Count;
buf.AddRange(BitConverter.GetBytes(cnt));
for (int i = 0; i < cnt; i++)
buf.AddRange(CoatingPart[i].ToByte());
return buf.ToArray();
}
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyname)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname));
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLY.Thick.RemoteHistory;
namespace FLY.Thick.Base.Common
{
public class FlyData_ScanHistory:IFlyData
{
public DateTime Time { get; set; }
public int[] SampleAD=new int[3];
public double Comp;
public int Shift;
public int Target;
public int Alarm;
public bool Valid;
public int BoltCnt;
public int BoltNo1st;
public int[] Data;
public int Avg;//平均值
#region IFlyData 成员
public string GetHeader()
{
string header = "时间,温修AD,样品1AD,样品2AD,斜率补偿,平移补偿,目标值,公差,有效";
for (int i = 0; i < BoltCnt; i++)
{
header += "," + (BoltNo1st + i).ToString();
}
header += ",平均值";
return header;
}
public override string ToString()
{
string str;
str = Time.ToString() ;
for (int i = 0; i < 3; i++)
str += "," + SampleAD[i].ToString();
str += "," + Comp.ToString("F2");
str += "," + (Shift/100.0).ToString("F2");
str += "," + (Target/100.0).ToString("F2");
str += "," + (Alarm/100.0).ToString("F2");
str += "," + Valid.ToString();
int sum = 0;
int cnt = 0;
for (int i = 0; i < BoltCnt && i<Data.Count(); i++)
{
int thick = Data[i];
str += ",";
if (Misc.MyBase.ISVALIDATA(thick))
{
str += (thick / 100.0).ToString("F2");
sum+=thick;
cnt++;
}
}
str += ",";
if (cnt > 0)
str += (sum / cnt / 100.0).ToString("F2");
return str;
}
public bool TryParse(string header, string str)
{
string[] items = header.Split(new char[] { ',' });
if (items.Length < 9)
return false;
int boltno1st;
if (int.TryParse(items[9], out boltno1st))
BoltNo1st = boltno1st;
else
return false;
BoltCnt = items.Length - 9 - 1;
items = str.Split(new char[] { ',' });
if ((items.Length-9-1) !=BoltCnt)
return false;
DateTime dt;
int _i;
double d;
bool b;
if (DateTime.TryParse(items[0], out dt))
Time = dt;
else
return false;
for (int i = 0; i < 3; i++)
{
if (int.TryParse(items[1 + i], out _i))
SampleAD[i] = _i;
else
return false;
}
if (double.TryParse(items[4], out d))
Comp = d;
else
return false;
if (double.TryParse(items[5], out d))
Shift = (int)d*100;
else
return false;
if (double.TryParse(items[6], out d))
Target = (int)d * 100;
else
return false;
if (double.TryParse(items[7], out d))
Alarm = (int)d * 100;
else
return false;
if (bool.TryParse(items[8], out b))
Valid = b;
else
return false;
Data = new int[BoltCnt];
for (int i = 0; i < BoltCnt; i++)
{
string s = items[9 + i];
if (string.IsNullOrEmpty(s))
{
Data[i] = Misc.MyBase.NULL_VALUE;
}
else
{
if (double.TryParse(s, out d))
Data[i] = (int)(d * 100);
else
return false;
}
}
{
string s = items[9 + BoltCnt];
if (string.IsNullOrEmpty(s))
{
Avg = Misc.MyBase.NULL_VALUE;
}
else
{
if (double.TryParse(s, out d))
Avg = (int)d * 100;
else
return false;
}
}
return true;
}
#endregion
}
}
......@@ -24,135 +24,5 @@ namespace FLY.Thick.Base.Common
/// </summary>
ONCE
}
public class FlyData_WarningHistory : IFlyData
{
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 分类
/// </summary>
public byte ErrType { get; set; }
/// <summary>
/// 出错码
/// </summary>
public byte ErrCode { get; set; }
/// <summary>
/// 出错状态
/// </summary>
public ERR_STATE State { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
public FlyData_WarningHistory Clone()
{
return new FlyData_WarningHistory()
{
Time = Time,
ErrType = ErrType,
ErrCode = ErrCode,
State = State,
Description = Description
};
}
public string GetHeader()
{
string header = "时间,分类,出错码,状态,描述";
return header;
}
public bool TryParse(string header, string str)
{
string[] items = str.Split(new char[] { ',' });
if (items.Length != 5)
return false;
DateTime dt;
if (DateTime.TryParse(items[0], out dt))
Time = dt;
else
return false;
byte a,b;
if (byte.TryParse(items[1], out a))
ErrType = a;
else
return false;
if (byte.TryParse(items[2], out b))
ErrCode= b;
else
return false;
ERR_STATE state;
if (Enum.TryParse<ERR_STATE>(items[3], out state))
State = state;
else
return false;
Description = items[4];
return true;
}
public override string ToString()
{
string str;
str = Time.ToString();
str += "," + ErrType.ToString();
str += "," + ErrCode.ToString();
str += "," + State.ToString();
str += "," + Description.ToString();
return str;
}
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(Time.Ticks));
buf.Add(ErrType);
buf.Add(ErrCode);
buf.AddRange(BitConverter.GetBytes((int)State));
byte[] bs = Misc.Converter.StringToBytes(Description);
int len;
if (bs == null)
len = 0;
else
len = bs.Length;
buf.AddRange(BitConverter.GetBytes(len));
if(len>0)
buf.AddRange(bs);
return buf.ToArray();
}
public bool TryParse(byte[] value, int index, out int cnt)// ref int idx)
{
cnt = 8 + 1 + 1 + 4+4;
if (value.Length-index < cnt)
return false;
int idx = index;
Time = new DateTime(BitConverter.ToInt64(value, idx));
idx += 8;
ErrType = value[idx];
idx++;
ErrCode = value[idx];
idx++;
State = (ERR_STATE)BitConverter.ToInt32(value, idx);
idx += 4;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += len;
if (value.Length-index < cnt)
return false;
if (len == 0)
Description = "";
else
{
Description = Misc.Converter.BytesToString(value, idx, len);
}
idx += len;
return true;
}
}
}
......@@ -72,8 +72,6 @@
<Compile Include="Common\ERRNO.cs" />
<Compile Include="Common\FlyADIODefine.cs" />
<Compile Include="Common\FlyAD_Common.cs" />
<Compile Include="Common\FlyData_CoatingSegmentHistory.cs" />
<Compile Include="Common\FlyData_ScanHistory.cs" />
<Compile Include="Common\FlyData_WarningHistory.cs" />
<Compile Include="Common\PasswordCommon.cs" />
<Compile Include="Common\ProfileParam.cs" />
......@@ -92,14 +90,11 @@
<Compile Include="IService\IRejectService.cs" />
<Compile Include="IService\IScanCorrService.cs" />
<Compile Include="IService\ITDGageService.cs" />
<Compile Include="OBJ_INTERFACE\COATINGSEGMENT_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\CURVE_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\FIX_OBJ_INTERFACEC.cs" />
<Compile Include="OBJ_INTERFACE\GETSAMPLE_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\PROFILE_OBJ_INTERFACE.cs" />
<Compile Include="OBJ_INTERFACE\SCANCORR_OBJ_INTERFACE.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server.OBJProxy\Curve_OBJProxy.cs" />
<Compile Include="Server.OBJProxy\Fix_OBJProxy.cs" />
<Compile Include="Server.OBJProxy\Gage_ObjProxy.cs" />
<Compile Include="Server.OBJProxy\GetSample_OBJProxy.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class COATINGSEGMENT_OBJ_INTERFACE
{
#region Pack
public class Pack_Params : IPack
{
public bool enable;
public bool enSave;
public int saveCnt;
public int recentCnt;
public int inIdxOfVSide;
public double warningtol_total;
public double warningtol_distance;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(enable));
buf.AddRange(BitConverter.GetBytes(enSave));
buf.AddRange(BitConverter.GetBytes(saveCnt));
buf.AddRange(BitConverter.GetBytes(recentCnt));
buf.AddRange(BitConverter.GetBytes(inIdxOfVSide));
buf.AddRange(BitConverter.GetBytes(warningtol_total));
buf.AddRange(BitConverter.GetBytes(warningtol_distance));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
if (value.Length < (1 * 2 + 4 * 3 + 8 * 2))
return false;
int idx = 0;
enable = BitConverter.ToBoolean(value, idx);
idx++;
enSave = BitConverter.ToBoolean(value, idx);
idx++;
saveCnt = BitConverter.ToInt32(value, idx);
idx += 4;
recentCnt = BitConverter.ToInt32(value, idx);
idx += 4;
inIdxOfVSide = BitConverter.ToInt32(value, idx);
idx += 4;
warningtol_total = BitConverter.ToDouble(value, idx);
idx += 8;
warningtol_distance = BitConverter.ToDouble(value, idx);
idx += 8;
return true;
}
#endregion
}
public class Pack_Recent : IPack
{
public FlyData_CoatingSegmentHistory[] data;
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(data.Count()));
for (int i = 0; i < data.Count(); i++)
{
buf.AddRange(data[i].ToBytes());
}
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
int cnt = 4;
if (value.Length < cnt)
return false;
int idx = 0;
int length = BitConverter.ToInt32(value, idx);
idx += 4;
data = new FlyData_CoatingSegmentHistory[length];
for (int i = 0; i < length; i++)
{
data[i] = new FlyData_CoatingSegmentHistory();
int count;
if (!data[i].TryParse(value, idx, out count))
return false;
idx += count;
cnt += count;
}
return true;
}
}
#endregion
#region GetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 GET_PARAMS = 0;
/// <summary>
/// CoatingSegmentProfile
/// </summary>
public const UInt16 GET_PROFILE = 1;
/// <summary>
/// FlyData_CoatingSegmentHistory
/// </summary>
public const UInt16 GET_LAST = 2;
#endregion
#region SetValue
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 SET_PARAMS = 0;
/// <summary>
/// CoatingSegmentProfile
/// </summary>
public const UInt16 SET_PROFILE = 1;
#endregion
#region PushMsg
/// <summary>
/// Pack_Params
/// </summary>
public const UInt16 PUSH_PARAMS = 0;
/// <summary>
/// CoatingSegmentProfile
/// </summary>
public const UInt16 PUSH_PROFILE = 1;
/// <summary>
/// FlyData_CoatingSegmentHistory
/// </summary>
public const UInt16 PUSH_LAST = 2;
#endregion
#region CallFunction
/// <summary>
/// request:null
/// reponse:Pack_Recent
/// </summary>
public const UInt16 CALL_GETRECENT = 1;
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
namespace FLY.Thick.Base.OBJ_INTERFACE
{
public class PROFILE_OBJ_INTERFACE
{
#region Pack
public class Pack_StringList : IPack
{
public List<string> list;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
byte[] bs;
buf.AddRange(BitConverter.GetBytes(list.Count()));
for (int i = 0; i < list.Count(); i++)
{
bs = Misc.Converter.StringToBytes(list[i]);
buf.AddRange(BitConverter.GetBytes(bs.Count()));
buf.AddRange(bs);
}
return buf.ToArray();
}
/// <summary>
/// 返回由字节数组中指定位置的9个字节转换来的数据。
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool TryParse(byte[] value)
{
int cnt = 4;
if (value.Length < cnt)
return false;
int idx = 0;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += len * 4;
if (value.Length < cnt)
return false;
if (list == null)
list = new List<string>();
list.Clear();
for (int i = 0; i < len; i++)
{
int l = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += l;
if (value.Length < cnt)
return false;
string s = Misc.Converter.BytesToString(value, idx, l);
idx += l;
list.Add(s);
}
return true;
}
#endregion
}
public class Pack_String
{
public string data;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
if (data != null)
{
byte[] bs = Misc.Converter.StringToBytes(data);
buf.AddRange(BitConverter.GetBytes(bs.Length));
buf.AddRange(bs);
}
else
{
buf.AddRange(BitConverter.GetBytes(0));
}
return buf.ToArray();
}
/// <summary>
/// 返回由字节数组中指定位置的9个字节转换来的数据。
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool TryParse(byte[] value, int index, int count)
{
int cnt = 4;
if (value.Length < cnt)
return false;
int idx = 0;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += len;
if (value.Length < cnt)
return false;
if (len <= 0)
data = null;
else
{
data = Misc.Converter.BytesToString(value, idx, len);
idx += len;
}
return true;
}
public bool TryParse(byte[] value)
{
return TryParse(value, 0, value.Length);
}
#endregion
}
#endregion
#region GetValue
/// <summary>
/// ProfileParam
/// </summary>
public const UInt16 GET_PARAMS = 0;
#endregion
#region SetValue
/// <summary>
/// ProfileParam
/// </summary>
public const UInt16 SET_PARAMS = 0;
#endregion
#region PushMsg
/// <summary>
/// ProfileParam
/// </summary>
public const UInt16 PUSH_PARAMS = 0;
#endregion
#region CallFunction
/// <summary>
/// request:null ;
/// reponse:Pack_StringList
/// </summary>
public const UInt16 CALL_GETLIST = 0;
/// <summary>
/// request:Pack_String ;
/// reponse:null
/// </summary>
public const UInt16 CALL_DEL = 1;
/// <summary>
/// request:Pack_String ;
/// reponse:ProfileParam
/// </summary>
public const UInt16 CALL_READ = 2;
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.IService;
namespace FLY.Thick.Base.Server.OBJProxy
{
public class Curve_OBJProxy : FObj
{
#region 延时推送 MARKNO
const int MARKNO_PUSH_CURVELIST = 1;
#endregion
ICurveService mCurveService;
public Curve_OBJProxy(int objsys_idx, UInt32 id, ICurveService CurveService) :base(objsys_idx)
{
ID = id;
mCurveService = CurveService;
mCurveService.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mCurveService_PropertyChanged);
}
void mCurveService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate()
{
byte[] buf;
GetValue(null, 0, CURVE_OBJ_INTERFACE.GET_CURVELIST, out buf);
CurrObjSys.PushObjInfoEx(
this, CURVE_OBJ_INTERFACE.PUSH_CURVELIST,
buf);
}), this, MARKNO_PUSH_CURVELIST);
}
void Curves_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate()
{
byte[] buf;
GetValue(null, 0, CURVE_OBJ_INTERFACE.GET_CURVELIST, out buf);
CurrObjSys.PushObjInfoEx(
this, CURVE_OBJ_INTERFACE.PUSH_CURVELIST,
buf);
}), this, MARKNO_PUSH_CURVELIST);
}
public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata)
{
switch (memid)
{
case CURVE_OBJ_INTERFACE.GET_CURVELIST:
{
var p = new CURVE_OBJ_INTERFACE.Pack_CurveList()
{
correctway = mCurveService.CorrectWay,
flag = mCurveService.Flag,
list = mCurveService.Curves
};
string json = Newtonsoft.Json.JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break;
default:
infodata = null;
break;
}
}
public override void SetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
switch (memid)
{
case CURVE_OBJ_INTERFACE.SET_CURVELIST:
{
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<CURVE_OBJ_INTERFACE.Pack_CurveList>(json);
mCurveService.CorrectWay = p.correctway;
mCurveService.Flag = p.flag;
mCurveService.Curves = p.list;
mCurveService.Apply();
} break;
}
}
}
}
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