/// <summary> /// Syncroniously writes specified data to specified address of work memory /// </summary> /// <param name="startAddress">Address to start write to</param> /// <param name="data">Data to write</param> public void WriteWork(ushort startAddress, byte bitAddress, ushort[] data) { var sid = IncrementSid(); var cmd = FinsDriver.WriteWorkCommand(new Header(sid, true), startAddress, bitAddress, data); Write(sid, cmd); }
/// <summary> /// Writes specified data to specified address of data memory without /// </summary> /// <param name="startAddress">Address to start to read from</param> /// <param name="count">Number of ushorts to read</param> public void WriteDataNoResponse(ushort startAddress, byte bitAddress, ushort[] data, byte memoryAreaCode) { var sid = IncrementSid(); var cmd = FinsDriver.WriteDataCommand(new Header(sid, false), memoryAreaCode, startAddress, bitAddress, data); _udpClient.SendAsync(cmd, cmd.Length); }
/// <summary> /// Asynchronously writes specified data to specified address of data memory /// </summary> /// <param name="startAddress">Address to start to write to</param> /// <param name="data">Data to write</param> public async Task WriteDataAsync(ushort startAddress, byte bitAddress, ushort[] data, byte memoryAreaCode) { var sid = IncrementSid(); var cmd = FinsDriver.WriteDataCommand(new Header(sid, true), memoryAreaCode, startAddress, bitAddress, data); _responses[sid].RecType = RecDataType._uint16; await CommandAsync(sid, cmd); }
public async Task <float[]> ReadBigFloatDataAsync(ushort startAddress, byte bitAddress, ushort count, byte memoryAreaCode) { var sid = IncrementSid(); var cmd = FinsDriver.ReadDataCommand(new Header(sid, true), memoryAreaCode, startAddress, bitAddress, count); _responses[sid].RecType = RecDataType.Big_float; return((await CommandAsync(sid, cmd)).FloatData); }
/// <summary> /// Syncroniously reads specified number of ushorts starting from specified address in work memory /// </summary> /// <param name="startAddress">Address to start to read from</param> /// <param name="count">Number of ushorts to read</param> /// <returns>Read data</returns> public ushort[] ReadWork(ushort startAddress, byte bitAddress, ushort count) { var sid = IncrementSid(); var cmd = FinsDriver.ReadWorkCommand(new Header(sid, true), startAddress, bitAddress, count); _responses[sid].RecType = RecDataType._uint16; return(Read(sid, cmd).Data); }
public float[] ReadDOFloatData(ushort startAddress, byte bitAddress, ushort count, byte memoryAreaCode) { var sid = IncrementSid(); var cmd = FinsDriver.ReadDataCommand(new Header(sid, true), memoryAreaCode, startAddress, bitAddress, count); _responses[sid].RecType = RecDataType.DO_float; return(Read(sid, cmd).FloatData); }
public bool WriteBitData(ushort startAddress, byte bitAddress, byte[] data, byte memoryAreaCode) { try { var sid = IncrementSid(); var cmd = FinsDriver.WriteBitDataCommand(new Header(sid, true), memoryAreaCode, startAddress, bitAddress, data); Write(sid, cmd); return(true); } catch (TimeoutException) { return(false); } catch (Exception ex) { LogUtil.LogError(ex); return(false); } }
private void ReadWorker() { try { while (true) { var task = _udpClient.ReceiveAsync(); task.Wait(_cancellationToken); if (task.IsFaulted) { throw new AggregateException(task.Exception); } FinsDriver.ProcessResponse(task.Result, _responses); } } catch (OperationCanceledException) { } }