Skip to content

Commit 256fa65

Browse files
committed
update tagdriver
1 parent 36097d6 commit 256fa65

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

SCADA/Example/BatchCoreTest.exe

0 Bytes
Binary file not shown.

SCADA/Example/CoreTest.exe

0 Bytes
Binary file not shown.

SCADA/Program/FileDriver/TagDriver.cs

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.ComponentModel;
33
using DataService;
4+
using System;
45

56
namespace FileDriver
67
{
@@ -184,37 +185,93 @@ public int WriteBytes(DeviceAddress address, byte[] bit)
184185

185186
public int WriteBit(DeviceAddress address, bool bit)
186187
{
187-
return 0;
188+
var tag = _parent[(short)address.CacheIndex];
189+
if (tag != null)
190+
{
191+
Storage v = tag.Value;
192+
v.Boolean = bit;
193+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
194+
return 0;
195+
}
196+
return -1;
188197
}
189198

190199
public int WriteBits(DeviceAddress address, byte bits)
191200
{
192-
return 0;
201+
var tag = _parent[(short)address.CacheIndex];
202+
if (tag != null)
203+
{
204+
Storage v = tag.Value;
205+
v.Byte = bits;
206+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
207+
return 0;
208+
}
209+
return -1;
193210
}
194211

195212
public int WriteInt16(DeviceAddress address, short value)
196213
{
197-
return 0;
214+
var tag = _parent[(short)address.CacheIndex];
215+
if (tag != null)
216+
{
217+
Storage v = tag.Value;
218+
v.Int16 = value;
219+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
220+
return 0;
221+
}
222+
return -1;
198223
}
199224

200225
public int WriteUInt16(DeviceAddress address, ushort value)
201226
{
202-
return 0;
227+
var tag = _parent[(short)address.CacheIndex];
228+
if (tag != null)
229+
{
230+
Storage v = tag.Value;
231+
v.Word = value;
232+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
233+
return 0;
234+
}
235+
return -1;
203236
}
204237

205238
public int WriteUInt32(DeviceAddress address, uint value)
206239
{
207-
return 0;
240+
var tag = _parent[(short)address.CacheIndex];
241+
if (tag != null)
242+
{
243+
Storage v = tag.Value;
244+
v.DWord = value;
245+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
246+
return 0;
247+
}
248+
return -1;
208249
}
209250

210251
public int WriteInt32(DeviceAddress address, int value)
211252
{
212-
return 0;
253+
var tag = _parent[(short)address.CacheIndex];
254+
if (tag != null)
255+
{
256+
Storage v = tag.Value;
257+
v.Int32 = value;
258+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
259+
return 0;
260+
}
261+
return -1;
213262
}
214263

215264
public int WriteFloat(DeviceAddress address, float value)
216265
{
217-
return 0;
266+
var tag = _parent[(short)address.CacheIndex];
267+
if (tag != null)
268+
{
269+
Storage v = tag.Value;
270+
v.Single = value;
271+
tag.Update(v, DateTime.Now, QUALITIES.QUALITY_GOOD);
272+
return 0;
273+
}
274+
return -1;
218275
}
219276

220277
public int WriteString(DeviceAddress address, string str)

SCADA/dll/FileDriver.dll

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)