using FLY.Thick.Base.OBJ_INTERFACE; using FLY.Thick.Blowing.IService; using FLY.Thick.Blowing.OBJ_INTERFACE; using FObjBase; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FLY.Thick.Blowing.Server.OBJProxy { public class BlowingDetect_OBJProxy: FObj { #region 延时推送 MARKNO const int MARKNO_PUSH_PARAMS = 1; const int MARKNO_PUSH_STATUS = 2; #endregion IBlowingDetect mRenZiJia; public BlowingDetect_OBJProxy(int objsys_idx,UInt32 id, IBlowingDetect renzijia) : base(objsys_idx) { ID = id; mRenZiJia = renzijia; mRenZiJia.PropertyChanged += mRenZiJiaFix_PropertyChanged; } void mRenZiJiaFix_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if ((e.PropertyName == "RAngle") || (e.PropertyName == "DefaultRPeriod") || (e.PropertyName == "RollPerimeter") || (e.PropertyName == "FilmLength") || (e.PropertyName == "SolveCnt") || (e.PropertyName == "AccDecTime") || (e.PropertyName == "LimitSignTime") || (e.PropertyName == "IsSign0Double") || (e.PropertyName == "IsSign1Double") || (e.PropertyName == "SignType") || (e.PropertyName == "IsSignFilter")|| (e.PropertyName == "Is3D") ) { FObjBase.PollModule.Current.Poll_JustOnce( new PollModule.PollHandler(delegate () { byte[] buf; GetValue(null, 0, BLOWING_DETECT_OBJ_INTERFACE.GET_PARAMS, out buf); CurrObjSys.PushObjInfoEx( this, BLOWING_DETECT_OBJ_INTERFACE.PUSH_PARAMS, buf); }), this, MARKNO_PUSH_PARAMS); } else if ( (e.PropertyName == "Angle") || (e.PropertyName == "Direction") || (e.PropertyName == "RotationCnt") || (e.PropertyName == "LastLimitNo") || (e.PropertyName == "PastTime") || (e.PropertyName == "FilmVelocity") || (e.PropertyName == "RenZiJiaPeriod") ) { FObjBase.PollModule.Current.Poll_JustOnce( new PollModule.PollHandler(delegate () { byte[] buf; GetValue(null, 0, BLOWING_DETECT_OBJ_INTERFACE.GET_STATE, out buf); CurrObjSys.PushObjInfoEx( this, BLOWING_DETECT_OBJ_INTERFACE.PUSH_STATE, buf); }), this, MARKNO_PUSH_STATUS); } } public override void CallFunction(IFConn from, uint srcid, UInt32 magic, ushort funcid, byte[] infodata) { switch (funcid) { case BLOWING_DETECT_OBJ_INTERFACE.CALL_GETSIGNLIST: { mRenZiJia.GetSignList( 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_DETECT_OBJ_INTERFACE.CALL_GETSIGNLIST, Misc.Converter.StringToBytes(json)); }), new ConnContext(from, srcid, magic)); } break; case BLOWING_DETECT_OBJ_INTERFACE.CALL_GETROLLIST: { string json2 = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject(json2); mRenZiJia.GetRollList(p.begin, 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_DETECT_OBJ_INTERFACE.CALL_GETROLLIST, Misc.Converter.StringToBytes(json)); }), new ConnContext(from, srcid, magic)); } break; case BLOWING_DETECT_OBJ_INTERFACE.CALL_GETLIMITLIST: { string json2 = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject(json2); mRenZiJia.GetLimitList(p.begin, 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_DETECT_OBJ_INTERFACE.CALL_GETLIMITLIST, Misc.Converter.StringToBytes(json)); }), new ConnContext(from, srcid, magic)); } break; case BLOWING_DETECT_OBJ_INTERFACE.CALL_GET_FL_3D: { mRenZiJia.GetFilmLength3D( 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_DETECT_OBJ_INTERFACE.CALL_GET_FL_3D, Misc.Converter.StringToBytes(json)); }), new ConnContext(from, srcid, magic)); } break; case BLOWING_DETECT_OBJ_INTERFACE.CALL_SET_FL_3D: { string json = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject>(json); mRenZiJia.SetFilmLength3D(p); } break; } } public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata) { switch (memid) { case BLOWING_DETECT_OBJ_INTERFACE.GET_PARAMS: { BLOWING_DETECT_OBJ_INTERFACE.Pack_Params p = new BLOWING_DETECT_OBJ_INTERFACE.Pack_Params() { rangle = mRenZiJia.RAngle, period = mRenZiJia.DefaultRPeriod, rollPerimeter = mRenZiJia.RollPerimeter, filmLength = mRenZiJia.FilmLength, accDecTime = mRenZiJia.AccDecTime, limitSignTime = mRenZiJia.LimitSignTime, isSign0Double = mRenZiJia.IsSign0Double, isSign1Double = mRenZiJia.IsSign1Double, signType = mRenZiJia.SignType, isSignFilter = mRenZiJia.IsSignFilter, isLackSignMode = mRenZiJia.IsLackSignMode, is3D = mRenZiJia.Is3D }; string json = Newtonsoft.Json.JsonConvert.SerializeObject(p); infodata = Misc.Converter.StringToBytes(json); } break; case BLOWING_DETECT_OBJ_INTERFACE.GET_STATE: { BLOWING_DETECT_OBJ_INTERFACE.Pack_CurrState p = new BLOWING_DETECT_OBJ_INTERFACE.Pack_CurrState() { limitno = mRenZiJia.LastLimitNo, pasttime = mRenZiJia.PastTime, rotationCnt = mRenZiJia.RotationCnt, filmvelocity = mRenZiJia.FilmVelocity, direction = mRenZiJia.Direction, angle = mRenZiJia.Angle, period = mRenZiJia.RenZiJiaPeriod, swapCoolTime = mRenZiJia.SwapCoolTime, BufTotalTime = mRenZiJia.BufTotalTime }; 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 BLOWING_DETECT_OBJ_INTERFACE.SET_PARAMS: { string json = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject< BLOWING_DETECT_OBJ_INTERFACE.Pack_Params>(json); mRenZiJia.RAngle = p.rangle; mRenZiJia.DefaultRPeriod = p.period; mRenZiJia.RollPerimeter = p.rollPerimeter; mRenZiJia.FilmLength = p.filmLength; mRenZiJia.AccDecTime = p.accDecTime; mRenZiJia.LimitSignTime = p.limitSignTime; mRenZiJia.IsSign0Double = p.isSign0Double; mRenZiJia.IsSign1Double = p.isSign1Double; mRenZiJia.SignType = p.signType; mRenZiJia.IsSignFilter = p.isSignFilter; mRenZiJia.IsLackSignMode = p.isLackSignMode; mRenZiJia.Is3D = p.is3D; mRenZiJia.Apply(); } break; } } } }