Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Syncroniously writes specified data to specified address of data memory
        /// </summary>
        /// <param name="startAddress">Address to start write to</param>
        /// <param name="data">Data to write</param>
        public bool WriteData(ushort startAddress, byte bitAddress, ushort[] data, byte memoryAreaCode)
        {
            try
            {
                var sid = IncrementSid();
                var cmd = FinsDriver.WriteDataCommand(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);
            }
        }