using System; using System.Collections.Generic; using System.Linq; using System.Text; using FObjBase; using FLY.Thick.Blowing.OBJ_INTERFACE; using FLY.Thick.Blowing.Server; using FLY.Thick.Blowing.IService; using Newtonsoft.Json; namespace FLY.Thick.Blowing.Server.OBJProxy { public class BlowingFix_OBJProxy : Blowing_OBJProxy { #region 延时推送 MARKNO const int MARKNO_PUSH_PARAMSEXT = 2; const int MARKNO_PUSH_STATUS = 2; const int MARKNO_PUSH_R = 3; const int MARKNO_PUSH_EPC = 4; const int MARKNO_PUSH_EPCSTATE = 5; const int MARKNO_PUSH_SIGNBM = 9; #endregion IBlowingFixService mRenZiJia; public BlowingFix_OBJProxy(int objsys_idx, UInt32 id, IBlowingFixService renzijia) :base(objsys_idx, id, renzijia) { mRenZiJia = renzijia; mRenZiJia.PropertyChanged += mRenZiJiaFix_PropertyChanged; } void mRenZiJiaFix_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if ( (e.PropertyName == "EPCType") || (e.PropertyName == "SampleConsume") || (e.PropertyName == "SampleInterval") || (e.PropertyName == "BackEdgeWait") || (e.PropertyName == "IsBtnSelfHold") ) { FObjBase.PollModule.Current.Poll_JustOnce( new PollModule.PollHandler(delegate() { byte[] buf; GetValue(null, 0, BLOWINGFIX_OBJ_INTERFACE.GET_EPC, out buf); CurrObjSys.PushObjInfoEx( this, BLOWINGFIX_OBJ_INTERFACE.PUSH_EPC, buf); }), this, MARKNO_PUSH_EPC); } else if ( (e.PropertyName == "SampleTimer") || (e.PropertyName == "EPCIsRunning") || (e.PropertyName == "SampleAD") ) { FObjBase.PollModule.Current.Poll_JustOnce( new PollModule.PollHandler(delegate() { byte[] buf; GetValue(null, 0, BLOWINGFIX_OBJ_INTERFACE.GET_EPCSTATE, out buf); CurrObjSys.PushObjInfoEx( this, BLOWINGFIX_OBJ_INTERFACE.PUSH_EPCSTATE, buf); }), this, MARKNO_PUSH_EPCSTATE); } } public override void CallFunction(IFConn from, uint srcid,UInt32 magic, ushort funcid, byte[] infodata) { switch (funcid) { case BLOWINGFIX_OBJ_INTERFACE.CALL_EPCSTART: { mRenZiJia.EPCStart(); }break; case BLOWINGFIX_OBJ_INTERFACE.CALL_EPCSTOP: { mRenZiJia.EPCStop(); } break; case BLOWINGFIX_OBJ_INTERFACE.CALL_GETADLIST: { string json = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject<GetADListRequest>(json); mRenZiJia.GetADList(p.begin, new AsyncCBHandler(delegate (object AsyncState, object retdata) { ConnContext context = (ConnContext)AsyncState; string json2 = JsonConvert.SerializeObject(retdata); CurrObjSys.PushCallFunctionEx( context.from, context.srcid, ID, context.magic, BLOWINGFIX_OBJ_INTERFACE.CALL_GETADLIST, Misc.Converter.StringToBytes(json2)); }), new ConnContext(from, srcid, magic)); }break; } } public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata) { base.GetValue(from, srcid, memid,out infodata); if (infodata != null) return; switch (memid) { case BLOWINGFIX_OBJ_INTERFACE.GET_EPC: { IBlowingFixService renzijiafix = mRenZiJia; BLOWINGFIX_OBJ_INTERFACE.Pack_EPC p = new BLOWINGFIX_OBJ_INTERFACE.Pack_EPC() { epctype = renzijiafix.EPCType, sampleconsume = renzijiafix.SampleConsume, sampleinterval = renzijiafix.SampleInterval, backedgewait = renzijiafix.BackEdgeWait, isBtnSelfHold = renzijiafix.IsBtnSelfHold }; string json = JsonConvert.SerializeObject(p); infodata = Misc.Converter.StringToBytes(json); }break; case BLOWINGFIX_OBJ_INTERFACE.GET_EPCSTATE: { IBlowingFixService renzijiafix = mRenZiJia; BLOWINGFIX_OBJ_INTERFACE.Pack_EPCState p = new BLOWINGFIX_OBJ_INTERFACE.Pack_EPCState() { sampletimer = renzijiafix.SampleTimer, isrunning = renzijiafix.EPCIsRunning, samplead = renzijiafix.SampleAD }; string 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) { base.SetValue(from, srcid, memid, infodata); switch (memid) { case BLOWINGFIX_OBJ_INTERFACE.SET_EPC: { string json = Misc.Converter.BytesToString(infodata); var p = JsonConvert.DeserializeObject<BLOWINGFIX_OBJ_INTERFACE.Pack_EPC>(json); mRenZiJia.EPCType = p.epctype; mRenZiJia.SampleConsume = p.sampleconsume; mRenZiJia.SampleInterval = p.sampleinterval; mRenZiJia.BackEdgeWait = p.backedgewait; mRenZiJia.IsBtnSelfHold = p.isBtnSelfHold; mRenZiJia.Apply(); }break; } } } }