using FLY.Thick.BlowingScan.Common;
using FLY.Thick.BlowingScan.IService;
using FLY.Thick.BlowingScan.OBJ_INTERFACE;
using FObjBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Thick.BlowingScan.Server.OBJProxy
{
///
///
///
public class BlowingProfile_OBJProxy: FObj
{
#region 延时推送 MARKNO
const int MARKNO_PUSH_PARAMS = 1;
#endregion
IBlowingProfileService mProfile;
///
///
///
///
///
///
public BlowingProfile_OBJProxy(int objsys_idx,UInt32 id, IBlowingProfileService profile)
: base(objsys_idx)
{
ID = id;
mProfile = profile;
mProfile.Param.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mProfile_PropertyChanged);
}
void mProfile_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate ()
{
byte[] buf;
GetValue(null, ID, BLOWING_PROFILE_OBJ_INTERFACE.GET_PARAMS, out buf);
CurrObjSys.PushObjInfoEx(
this, BLOWING_PROFILE_OBJ_INTERFACE.PUSH_PARAMS,
buf);
}), this, MARKNO_PUSH_PARAMS);
}
///
///
///
///
///
///
///
public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata)
{
infodata = null;
switch (memid)
{
case BLOWING_PROFILE_OBJ_INTERFACE.GET_PARAMS:
{
string json = JsonConvert.SerializeObject(mProfile.Param);
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 BLOWING_PROFILE_OBJ_INTERFACE.SET_PARAMS:
{
string json = Misc.Converter.BytesToString(infodata);
BlowingProfileParam p = JsonConvert.DeserializeObject(json);
mProfile.Param.Copy(p);
mProfile.Apply();
}
break;
}
}
///
///
///
///
///
///
///
///
public override void CallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] infodata)
{
switch (funcid)
{
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_GETLIST:
{
mProfile.GetList(
new AsyncCBHandler(delegate (object AsyncState, object retdata)
{
ConnContext context = (ConnContext)AsyncState;
string json = JsonConvert.SerializeObject(retdata);
CurrObjSys.PushCallFunctionEx(
context.from,
context.srcid,
ID,
context.magic,
BLOWING_PROFILE_OBJ_INTERFACE.CALL_GETLIST,
Misc.Converter.StringToBytes(json));
}), new ConnContext(from, srcid, magic));
}
break;
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_DEL:
{
string json = Misc.Converter.BytesToString(infodata);
string p = JsonConvert.DeserializeObject(json);
mProfile.Del(p);
}
break;
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_READ:
{
string json = Misc.Converter.BytesToString(infodata);
string p = JsonConvert.DeserializeObject(json);
mProfile.Read(
p,
new AsyncCBHandler(delegate (object AsyncState, object retdata)
{
ConnContext context = (ConnContext)AsyncState;
json = JsonConvert.SerializeObject(retdata);
CurrObjSys.PushCallFunctionEx(
context.from,
context.srcid,
ID,
context.magic,
BLOWING_PROFILE_OBJ_INTERFACE.CALL_READ,
Misc.Converter.StringToBytes(json));
}), new ConnContext(from, srcid, magic));
}
break;
}
}
}
}