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.Curves.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Curves_CollectionChanged); 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: { CURVE_OBJ_INTERFACE.Pack_CurveList p = new CURVE_OBJ_INTERFACE.Pack_CurveList() { correctway = mCurveService.CorrectWay, flag = mCurveService.Flag, list = mCurveService.Curves.ToArray() }; infodata = p.ToBytes(); } 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: { CURVE_OBJ_INTERFACE.Pack_CurveList p = new CURVE_OBJ_INTERFACE.Pack_CurveList(); if (p.TryParse(infodata)) { mCurveService.CorrectWay = p.correctway; mCurveService.Flag = p.flag; mCurveService.Curves.Clear(); for (int i = 0; i < p.list.Count(); i++) { mCurveService.Curves.Add(p.list[i]); } mCurveService.Apply(); } } break; } } } }