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
158
159
using FLY.Thick.BlowingScan.Common;
using FLY.Thick.BlowingScan.IService;
using FLY.Thick.BlowingScan.OBJ_INTERFACE;
using FObjBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Thick.BlowingScan.Server.OBJProxy
{
/// <summary>
///
/// </summary>
public class BlowingProfile_OBJProxy: FObj
{
#region 延时推送 MARKNO
const int MARKNO_PUSH_PARAMS = 1;
#endregion
IBlowingProfileService mProfile;
/// <summary>
///
/// </summary>
/// <param name="objsys_idx"></param>
/// <param name="id"></param>
/// <param name="profile"></param>
public BlowingProfile_OBJProxy(int objsys_idx,UInt32 id, IBlowingProfileService profile)
: base(objsys_idx)
{
ID = id;
mProfile = profile;
mProfile.Param.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mProfile_PropertyChanged);
}
void mProfile_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate ()
{
byte[] buf;
GetValue(null, ID, BLOWING_PROFILE_OBJ_INTERFACE.GET_PARAMS, out buf);
CurrObjSys.PushObjInfoEx(
this, BLOWING_PROFILE_OBJ_INTERFACE.PUSH_PARAMS,
buf);
}), this, MARKNO_PUSH_PARAMS);
}
/// <summary>
///
/// </summary>
/// <param name="from"></param>
/// <param name="srcid"></param>
/// <param name="memid"></param>
/// <param name="infodata"></param>
public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata)
{
infodata = null;
switch (memid)
{
case BLOWING_PROFILE_OBJ_INTERFACE.GET_PARAMS:
{
string json = JsonConvert.SerializeObject(mProfile.Param);
infodata = Misc.Converter.StringToBytes(json);
}
break;
default:
infodata = null;
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="from"></param>
/// <param name="srcid"></param>
/// <param name="memid"></param>
/// <param name="infodata"></param>
public override void SetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
switch (memid)
{
case BLOWING_PROFILE_OBJ_INTERFACE.SET_PARAMS:
{
string json = Misc.Converter.BytesToString(infodata);
BlowingProfileParam p = JsonConvert.DeserializeObject<BlowingProfileParam>(json);
mProfile.Param.Copy(p);
mProfile.Apply();
}
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="from"></param>
/// <param name="srcid"></param>
/// <param name="magic"></param>
/// <param name="funcid"></param>
/// <param name="infodata"></param>
public override void CallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] infodata)
{
switch (funcid)
{
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_GETLIST:
{
mProfile.GetList(
new AsyncCBHandler(delegate (object AsyncState, object retdata)
{
ConnContext context = (ConnContext)AsyncState;
string json = JsonConvert.SerializeObject(retdata);
CurrObjSys.PushCallFunctionEx(
context.from,
context.srcid,
ID,
context.magic,
BLOWING_PROFILE_OBJ_INTERFACE.CALL_GETLIST,
Misc.Converter.StringToBytes(json));
}), new ConnContext(from, srcid, magic));
}
break;
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_DEL:
{
string json = Misc.Converter.BytesToString(infodata);
string p = JsonConvert.DeserializeObject<string>(json);
mProfile.Del(p);
}
break;
case BLOWING_PROFILE_OBJ_INTERFACE.CALL_READ:
{
string json = Misc.Converter.BytesToString(infodata);
string p = JsonConvert.DeserializeObject<string>(json);
mProfile.Read(
p,
new AsyncCBHandler(delegate (object AsyncState, object retdata)
{
ConnContext context = (ConnContext)AsyncState;
json = JsonConvert.SerializeObject(retdata);
CurrObjSys.PushCallFunctionEx(
context.from,
context.srcid,
ID,
context.magic,
BLOWING_PROFILE_OBJ_INTERFACE.CALL_READ,
Misc.Converter.StringToBytes(json));
}), new ConnContext(from, srcid, magic));
}
break;
}
}
}
}