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

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

parent 9f2fb05b
......@@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
......@@ -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()
{
name = methodName,
data = parameters==null?null:JObject.FromObject(parameters)
};
string json = JsonConvert.SerializeObject(rData);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID,
......@@ -387,13 +389,42 @@ namespace FObjBase.Reflect
Misc.Converter.StringToBytes(json),
asyncDelegate, asyncContext);
}
protected void Call(string methodName, object parameters) {
void Call(string methodName, object parameters) {
Call(methodName, parameters, null, null);
}
protected void Call(string methodName)
void Call(string methodName)
{
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
}
}
......@@ -107,11 +107,11 @@ namespace FLY.Thick.Base.Client
public void GetView(AsyncCBHandler asyncDelegate, object asyncContext)
{
Call("GetView", null, asyncDelegate, asyncContext);
Call2(null, asyncDelegate, asyncContext);
}
public void Apply()
{
Call("Apply");
Call2();
}
}
}
......@@ -106,7 +106,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPosition">极片位置m</param>
public void ResetCore(double filmPosition)
{
Call("ResetCore", new { filmPosition });
Call2(new { filmPosition });
}
/// <summary>
/// 改变逻辑偏移量,从而设置膜位置为某值
......@@ -114,7 +114,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPosition"></param>
public void ResetOffset(double filmPosition)
{
Call("ResetOffset", new { filmPosition });
Call2(new { filmPosition });
}
/// <summary>
......@@ -123,14 +123,14 @@ namespace FLY.Thick.Base.Client
/// <param name="filmOffset"></param>
public void SetOffset(double filmOffset)
{
Call("SetOffset", new { filmOffset });
Call2(new { filmOffset });
}
/// <summary>
/// 把膜位置设置为 -VDistanceWithHeader
/// </summary>
public void Reset()
{
Call("Reset");
Call2();
}
......@@ -141,7 +141,7 @@ namespace FLY.Thick.Base.Client
/// <param name="filmPos">极片位置m</param>
public void SetFilmPosAt01(double filmPos)
{
Call("SetFilmPosAt01", new { filmPos });
Call2(new { filmPos });
}
/// <summary>
......@@ -149,7 +149,7 @@ namespace FLY.Thick.Base.Client
/// </summary>
public void Stop()
{
Call("Stop");
Call2();
}
/// <summary>
......@@ -157,12 +157,12 @@ namespace FLY.Thick.Base.Client
/// </summary>
public void Start()
{
Call("Start");
Call2();
}
public void Apply()
{
Call("Apply");
Call2();
}
}
......
......@@ -55,11 +55,11 @@ namespace FLY.Thick.Base.Client
/// </summary>
public void StartMeasure()
{
Call("StartMeasure");
Call2();
}
public void Stop()
{
Call("Stop");
Call2();
}
}
......
......@@ -191,7 +191,7 @@ namespace FLY.Thick.Base.Client
public void Apply()
{
Call("Apply");
Call2();
}
}
......
......@@ -32,7 +32,7 @@ namespace FLY.Thick.Base.Client
/// </summary>
public void StartP1()
{
Call("StartP1");
Call2();
}
/// <summary>
///
......@@ -40,7 +40,7 @@ namespace FLY.Thick.Base.Client
/// <param name="mode"></param>
public void StartP2(STARTP2_MODE mode)
{
Call("StartP2",new { mode });
Call2(new { mode });
}
/// <summary>
///
......@@ -48,7 +48,7 @@ namespace FLY.Thick.Base.Client
/// <param name="targetpos"></param>
public void RunTo(int targetpos)
{
Call("RunTo", new { targetpos });
Call2(new { targetpos });
}
#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