1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using FLY.Thick.Blowing.Common;
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.Client
{
public class BlowingFixProfileServiceClient : FObj, IBlowingFixProfileService
{
IFConn mConn;
UInt32 mServerID;
public BlowingFixProfileServiceClient(UInt32 id)
{
mServerID = id;
}
#region IProfileService 接口
BlowingFixProfileParam param = new BlowingFixProfileParam();
public BlowingFixProfileParam Param
{
get
{
return param;
}
}
/// <summary>
/// 应用 & 保存
/// </summary>
public void Apply()
{
string json = JsonConvert.SerializeObject(Param);
CurrObjSys.SetValueEx(mConn, mServerID, ID,
BLOWINGFIX_PROFILE_OBJ_INTERFACE.SET_PARAMS,
Misc.Converter.StringToBytes(json));
}
/// <summary>
/// 获取产品列表, 返回类型为 List<string>
/// </summary>
/// <param name="AsyncDelegate"></param>
/// <param name="AsyncState"></param>
public void GetList(AsyncCBHandler AsyncDelegate, object AsyncState)
{
CurrObjSys.CallFunctionEx(mConn, mServerID, ID,
BLOWINGFIX_PROFILE_OBJ_INTERFACE.CALL_GETLIST,
null,
AsyncDelegate, AsyncState);
}
/// <summary>
/// 删除指定产品
/// </summary>
/// <param name="productname"></param>
public void Del(string productname)
{
string json = JsonConvert.SerializeObject(productname);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID,
BLOWINGFIX_PROFILE_OBJ_INTERFACE.CALL_DEL, Misc.Converter.StringToBytes(json));
}
/// <summary>
/// 读取指定产品,返回类型为 ProfileParam
/// </summary>
/// <param name="productname"></param>
/// <param name="AsyncDelegate"></param>
/// <param name="AsyncState"></param>
public void Read(string productname, AsyncCBHandler AsyncDelegate, object AsyncState)
{
string json = JsonConvert.SerializeObject(productname);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID,
BLOWINGFIX_PROFILE_OBJ_INTERFACE.CALL_READ,
Misc.Converter.StringToBytes(json),
AsyncDelegate, AsyncState);
}
#endregion
public override void Dispose()
{
CurrObjSys.ObjRemove(
this, mConn);
}
public override void ConnectNotify(IFConn from)
{
mConn = from;
if (from.IsConnected)
{
//获取所有数据,设置推送
CurrObjSys.GetValueEx(
mConn, mServerID, ID,
BLOWINGFIX_PROFILE_OBJ_INTERFACE.GET_PARAMS);
CurrObjSys.SenseConfigEx(
mConn, mServerID, ID,
0xffffffff,
SENSE_CONFIG.ADD);
}
}
public override void PushGetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
switch (memid)
{
case BLOWINGFIX_PROFILE_OBJ_INTERFACE.GET_PARAMS:
{
string json = Misc.Converter.BytesToString(infodata);
BlowingFixProfileParam p = JsonConvert.DeserializeObject<BlowingFixProfileParam>(json);
Misc.PropertiesManager.CopyTo(p, Param);
}
break;
}
}
public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
{
PushGetValue(from, srcid, infoid, infodata);
}
public override void PushCallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] retdata, object AsyncDelegate, object AsyncState)
{
switch (funcid)
{
case BLOWINGFIX_PROFILE_OBJ_INTERFACE.CALL_GETLIST:
{
string json = Misc.Converter.BytesToString(retdata);
List<string> p = JsonConvert.DeserializeObject<List<string>>(json);
((AsyncCBHandler)AsyncDelegate)(AsyncState, p);
}
break;
case BLOWINGFIX_PROFILE_OBJ_INTERFACE.CALL_READ:
{
string json = Misc.Converter.BytesToString(retdata);
BlowingFixProfileParam p = JsonConvert.DeserializeObject<BlowingFixProfileParam>(json);
((AsyncCBHandler)AsyncDelegate)(AsyncState, p);
}
break;
}
}
}
}