Commit 0b64f6ef authored by 潘栩锋's avatar 潘栩锋 🚴

优化 FObject.Reflect_SeviceClient Call -> Call2 , 自动获取调用它的函数名。

parent 9f2fb05b
...@@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq; ...@@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
...@@ -373,13 +374,14 @@ namespace FObjBase.Reflect ...@@ -373,13 +374,14 @@ namespace FObjBase.Reflect
} }
protected void Call(string methodName, object parameters, AsyncCBHandler asyncDelegate, object asyncContext) void Call(string methodName, object parameters, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
var rData = new Reflect_OBJ_INTERFACE.ReflectData() var rData = new Reflect_OBJ_INTERFACE.ReflectData()
{ {
name = methodName, name = methodName,
data = parameters==null?null:JObject.FromObject(parameters) data = parameters==null?null:JObject.FromObject(parameters)
}; };
string json = JsonConvert.SerializeObject(rData); string json = JsonConvert.SerializeObject(rData);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID, CurrObjSys.CallFunctionEx(mConn, mServerID, ID,
...@@ -387,13 +389,42 @@ namespace FObjBase.Reflect ...@@ -387,13 +389,42 @@ namespace FObjBase.Reflect
Misc.Converter.StringToBytes(json), Misc.Converter.StringToBytes(json),
asyncDelegate, asyncContext); asyncDelegate, asyncContext);
} }
protected void Call(string methodName, object parameters) { void Call(string methodName, object parameters) {
Call(methodName, parameters, null, null); Call(methodName, parameters, null, null);
} }
protected void Call(string methodName) void Call(string methodName)
{ {
Call(methodName, null, null, null); Call(methodName, null, null, null);
} }
protected void Call2(object parameters, AsyncCBHandler asyncDelegate, object asyncContext)
{
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
var frame = st.GetFrame(2);
var method = frame.GetMethod();
string methodName = method.Name;
Call(methodName, parameters, asyncDelegate, asyncContext);
}
protected void Call2(object parameters)
{
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
var frame = st.GetFrame(2);
var method = frame.GetMethod();
string methodName = method.Name;
Call(methodName, parameters);
}
protected void Call2()
{
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
var frame = st.GetFrame(2);
var method = frame.GetMethod();
string methodName = method.Name;
Call(methodName);
}
#endregion #endregion
} }
} }
...@@ -107,11 +107,11 @@ namespace FLY.Thick.Base.Client ...@@ -107,11 +107,11 @@ namespace FLY.Thick.Base.Client
public void GetView(AsyncCBHandler asyncDelegate, object asyncContext) public void GetView(AsyncCBHandler asyncDelegate, object asyncContext)
{ {
Call("GetView", null, asyncDelegate, asyncContext); Call2(null, asyncDelegate, asyncContext);
} }
public void Apply() public void Apply()
{ {
Call("Apply"); Call2();
} }
} }
} }
...@@ -106,7 +106,7 @@ namespace FLY.Thick.Base.Client ...@@ -106,7 +106,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPosition">极片位置m</param> /// <param name="filmPosition">极片位置m</param>
public void ResetCore(double filmPosition) public void ResetCore(double filmPosition)
{ {
Call("ResetCore", new { filmPosition }); Call2(new { filmPosition });
} }
/// <summary> /// <summary>
/// 改变逻辑偏移量,从而设置膜位置为某值 /// 改变逻辑偏移量,从而设置膜位置为某值
...@@ -114,7 +114,7 @@ namespace FLY.Thick.Base.Client ...@@ -114,7 +114,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPosition"></param> /// <param name="filmPosition"></param>
public void ResetOffset(double filmPosition) public void ResetOffset(double filmPosition)
{ {
Call("ResetOffset", new { filmPosition }); Call2(new { filmPosition });
} }
/// <summary> /// <summary>
...@@ -123,14 +123,14 @@ namespace FLY.Thick.Base.Client ...@@ -123,14 +123,14 @@ namespace FLY.Thick.Base.Client
/// <param name="filmOffset"></param> /// <param name="filmOffset"></param>
public void SetOffset(double filmOffset) public void SetOffset(double filmOffset)
{ {
Call("SetOffset", new { filmOffset }); Call2(new { filmOffset });
} }
/// <summary> /// <summary>
/// 把膜位置设置为 -VDistanceWithHeader /// 把膜位置设置为 -VDistanceWithHeader
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {
Call("Reset"); Call2();
} }
...@@ -141,7 +141,7 @@ namespace FLY.Thick.Base.Client ...@@ -141,7 +141,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPos">极片位置m</param> /// <param name="filmPos">极片位置m</param>
public void SetFilmPosAt01(double filmPos) public void SetFilmPosAt01(double filmPos)
{ {
Call("SetFilmPosAt01", new { filmPos }); Call2(new { filmPos });
} }
/// <summary> /// <summary>
...@@ -149,7 +149,7 @@ namespace FLY.Thick.Base.Client ...@@ -149,7 +149,7 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public void Stop() public void Stop()
{ {
Call("Stop"); Call2();
} }
/// <summary> /// <summary>
...@@ -157,12 +157,12 @@ namespace FLY.Thick.Base.Client ...@@ -157,12 +157,12 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public void Start() public void Start()
{ {
Call("Start"); Call2();
} }
public void Apply() public void Apply()
{ {
Call("Apply"); Call2();
} }
} }
......
...@@ -55,11 +55,11 @@ namespace FLY.Thick.Base.Client ...@@ -55,11 +55,11 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public void StartMeasure() public void StartMeasure()
{ {
Call("StartMeasure"); Call2();
} }
public void Stop() public void Stop()
{ {
Call("Stop"); Call2();
} }
} }
......
...@@ -191,7 +191,7 @@ namespace FLY.Thick.Base.Client ...@@ -191,7 +191,7 @@ namespace FLY.Thick.Base.Client
public void Apply() public void Apply()
{ {
Call("Apply"); Call2();
} }
} }
......
...@@ -32,7 +32,7 @@ namespace FLY.Thick.Base.Client ...@@ -32,7 +32,7 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
public void StartP1() public void StartP1()
{ {
Call("StartP1"); Call2();
} }
/// <summary> /// <summary>
/// ///
...@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.Client ...@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.Client
/// <param name="mode"></param> /// <param name="mode"></param>
public void StartP2(STARTP2_MODE mode) public void StartP2(STARTP2_MODE mode)
{ {
Call("StartP2",new { mode }); Call2(new { mode });
} }
/// <summary> /// <summary>
/// ///
...@@ -48,7 +48,7 @@ namespace FLY.Thick.Base.Client ...@@ -48,7 +48,7 @@ namespace FLY.Thick.Base.Client
/// <param name="targetpos"></param> /// <param name="targetpos"></param>
public void RunTo(int targetpos) public void RunTo(int targetpos)
{ {
Call("RunTo", new { targetpos }); Call2(new { targetpos });
} }
#region IFObj 成员 #region IFObj 成员
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment