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
160
161
162
163
164
165
166
167
168
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;
}
}
}
}