using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.Client
{
public class GageInfoServiceClient : FObjServiceClient, IGageInfoService
{
public GageInfoServiceClient(UInt32 serviceId) : base(serviceId) { }
public GageInfoServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
#region IGageInfoService 接口
private bool dataok=false;
///
/// 数据好了!!!!
/// 当 flyad7 的poslen, posOfGrid 发生变化时,DataOK = false, 需要重新记录。
///
public bool DataOK
{
get { return dataok; }
set
{
if (dataok != value)
{
dataok = value;
NotifyPropertyChanged("DataOK");
}
}
}
private int poslen=9000;
///
/// 机架总长,脉冲
///
public int PosLen
{
get { return poslen; }
set
{
if (poslen != value)
{
poslen = value;
}
}
}
private int posofgrid=10;
///
/// 1个grid = N个pos
///
public int PosOfGrid
{
get { return posofgrid; }
set
{
if (posofgrid != value)
{
posofgrid = value;
NotifyPropertyChanged("PosOfGrid");
}
}
}
private List forwdata = new List();
public List ForwData
{
get { return forwdata; }
}
private List backwdata = new List();
public List BackwData
{
get { return backwdata; }
}
protected int progress;
///
/// 0~100
///
public int Progress
{
get
{
return progress;
}
set
{
if (progress != value)
{
progress = value;
NotifyPropertyChanged("Progress");
}
}
}
private bool isRunning = false;
///
/// 正在机架修正中
///
public bool IsRunning
{
get
{
return isRunning;
}
set
{
if (isRunning != value)
{
isRunning = value;
NotifyPropertyChanged("IsRunning");
}
}
}
///
/// 数据录制,记下来回扫描的AD值数组
///
public bool Start()
{
CurrObjSys.CallFunctionEx(
mConn, mServerID, ID,
GAGEINFO_OBJ_INTERFACE.CALL_START,
null);
return true;
}
public void Stop()
{
CurrObjSys.CallFunctionEx(
mConn, mServerID, ID,
GAGEINFO_OBJ_INTERFACE.CALL_STOP,
null);
}
#endregion
public override void ConnectNotify(IFConn from)
{
base.ConnectNotify(from);
if (from.IsConnected)
{
//获取所有数据,设置推送
CurrObjSys.GetValueEx(
mConn, mServerID, ID,
GAGEINFO_OBJ_INTERFACE.GET_STATE);
CurrObjSys.GetValueEx(
mConn, mServerID, ID,
GAGEINFO_OBJ_INTERFACE.GET_DATA);
CurrObjSys.SenseConfigEx(
mConn, mServerID, ID,
0xffffffff, SENSE_CONFIG.ADD);
}
}
public override void PushGetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
switch (memid)
{
case GAGEINFO_OBJ_INTERFACE.GET_STATE:
{
GAGEINFO_OBJ_INTERFACE.Pack_State p = new GAGEINFO_OBJ_INTERFACE.Pack_State();
if (!p.TryParse(infodata))
return;
Progress = p.progress;
DataOK = p.dataOk;
IsRunning = p.ing;
} break;
case GAGEINFO_OBJ_INTERFACE.GET_DATA:
{
GAGEINFO_OBJ_INTERFACE.Pack_Data p = new GAGEINFO_OBJ_INTERFACE.Pack_Data();
if (!p.TryParse(infodata))
return;
PosOfGrid = p.posOfGrid;
PosLen = p.posLen;
ForwData.Clear();
if(p.forwData!=null)
ForwData.AddRange(p.forwData);
BackwData.Clear();
if(p.backwData!=null)
BackwData.AddRange(p.backwData);
NotifyPropertyChanged("Data");
} break;
}
}
public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
{
PushGetValue(from, srcid, infoid, infodata);
}
}
}