using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.IService;
using Newtonsoft.Json;
using FLY.OBJComponents.Client;
namespace FLY.Thick.Base.Client
{
///
/// 动态数据服务 客户端代理
///
public class DynAreaServiceClient : FObjServiceClient, IDynAreaService
{
///
/// 动态数据
///
public DynArea DynArea { get; } = new DynArea();
///
/// 动态数据服务 构造
///
/// 服务id
public DynAreaServiceClient(UInt32 serviceId) : base(serviceId) { }
///
/// 动态数据服务 构造
///
/// 服务id
/// 连接器
public DynAreaServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
#region IFObj 成员
///
/// 连接通知
///
///
public override void ConnectNotify(IFConn from)
{
base.ConnectNotify(from);
DynArea.ServerIsConnected = from.IsConnected;
if (from.IsConnected)
{
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_ADPOS);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_SCANINFO);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_CONTROLLER_STATE);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_PROFILE);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_BOLTMAP);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_SYSTEM);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_IO);
CurrObjSys.GetValueEx(mConn, mServerID, ID, DYNAREA_OBJ_INTERFACE.GET_POSITION2);
CurrObjSys.SenseConfigEx(mConn, mServerID, ID,0xffffffff, SENSE_CONFIG.ADD);
}
}
///
///
///
///
///
///
///
public override void PushGetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
PushInfo(from,srcid,memid,infodata);
}
///
///
///
///
///
///
///
public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
{
switch (infoid)
{
case DYNAREA_OBJ_INTERFACE.PUSH_ADPOS:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_SCANINFO:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_PROFILE:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_SYSTEM:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_BOLTMAP:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_IO:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_CONTROLLER_STATE:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
} break;
case DYNAREA_OBJ_INTERFACE.PUSH_POSITION2:
{
string json = Misc.Converter.BytesToString(infodata);
JsonConvert.PopulateObject(json, DynArea);
}
break;
}
}
#endregion
}
}