|
1 | 1 | using System.Collections.Generic;
|
2 | 2 | using System.ComponentModel;
|
3 | 3 | using DataService;
|
| 4 | +using System; |
4 | 5 |
|
5 | 6 | namespace FileDriver
|
6 | 7 | {
|
@@ -184,37 +185,93 @@ public int WriteBytes(DeviceAddress address, byte[] bit)
|
184 | 185 |
|
185 | 186 | public int WriteBit(DeviceAddress address, bool bit)
|
186 | 187 | {
|
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; |
188 | 197 | }
|
189 | 198 |
|
190 | 199 | public int WriteBits(DeviceAddress address, byte bits)
|
191 | 200 | {
|
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; |
193 | 210 | }
|
194 | 211 |
|
195 | 212 | public int WriteInt16(DeviceAddress address, short value)
|
196 | 213 | {
|
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; |
198 | 223 | }
|
199 | 224 |
|
200 | 225 | public int WriteUInt16(DeviceAddress address, ushort value)
|
201 | 226 | {
|
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; |
203 | 236 | }
|
204 | 237 |
|
205 | 238 | public int WriteUInt32(DeviceAddress address, uint value)
|
206 | 239 | {
|
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; |
208 | 249 | }
|
209 | 250 |
|
210 | 251 | public int WriteInt32(DeviceAddress address, int value)
|
211 | 252 | {
|
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; |
213 | 262 | }
|
214 | 263 |
|
215 | 264 | public int WriteFloat(DeviceAddress address, float value)
|
216 | 265 | {
|
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; |
218 | 275 | }
|
219 | 276 |
|
220 | 277 | public int WriteString(DeviceAddress address, string str)
|
|
0 commit comments