FileDriver.MemoryReader.FindPosition(DeviceAddress)

Here are the examples of the csharp api class FileDriver.MemoryReader.FindPosition(DeviceAddress) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

13 Examples 7

1. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public byte[] ReadBytes(DeviceAddress address, ushort size)
        {
            byte[] bytes = new byte[size];
            try
            {
                int result = accessor.ReadArray(FindPosition(address), bytes, 0, size);
                return bytes;
            }
            catch { return null; }
        }

2. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<int> ReadInt32(DeviceAddress address)
        {
            try
            {
                return new ItemData<int>(accessor.ReadInt32(FindPosition(address)), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<int>(0, 0, QUALITIES.QUALITY_BAD); }
        }

3. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<short> ReadInt16(DeviceAddress address)
        {
            try
            {
                return new ItemData<short>(accessor.ReadInt16(FindPosition(address)), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<short>(0, 0, QUALITIES.QUALITY_BAD); }
        }

4. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<byte> ReadByte(DeviceAddress address)
        {
            try
            {
                return new ItemData<byte>(accessor.ReadByte(FindPosition(address)), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<byte>(0, 0, QUALITIES.QUALITY_BAD); }
        }

5. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<float> ReadFloat(DeviceAddress address)
        {
            try
            {
                return new ItemData<float>(accessor.ReadSingle(FindPosition(address)), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<float>(0f, 0, QUALITIES.QUALITY_BAD); }
        }

6. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<bool> ReadBit(DeviceAddress address)
        {
            try
            {
                return new ItemData<bool>(accessor.ReadBoolean(FindPosition(address)), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<bool>(false, 0, QUALITIES.QUALITY_BAD); }
        }

7. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteBytes(DeviceAddress address, byte[] bit)
        {
            try
            {
                accessor.WriteArray(FindPosition(address), bit, 0, bit.Length);
                return 0;
            }
            catch { return -1; }
        }

8. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteBit(DeviceAddress address, bool bit)
        {
            try
            {
                accessor.Write(FindPosition(address), bit);
                return 0;
            }
            catch { return -1; }
        }

9. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteBits(DeviceAddress address, byte bits)
        {
            try
            {
                accessor.Write(FindPosition(address), bits);
                return 0;
            }
            catch { return -1; }
        }

10. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteInt16(DeviceAddress address, short value)
        {
            try
            {
                accessor.Write(FindPosition(address), value);
                return 0;
            }
            catch { return -1; }
        }

11. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteInt32(DeviceAddress address, int value)
        {
            try
            {
                accessor.Write(FindPosition(address), value);
                return 0;
            }
            catch { return -1; }
        }

12. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public int WriteFloat(DeviceAddress address, float value)
        {
            try
            {
                accessor.Write(FindPosition(address), value);
                return 0;
            }
            catch { return -1; }
        }

13. Example

Project: SharpSCADA
Source File: MemoryDriver.cs
public ItemData<string> ReadString(DeviceAddress address, ushort size)
        {
            try
            {
                byte[] bytes = new byte[size];
                int result = accessor.ReadArray(FindPosition(address), bytes, 0, bytes.Length);
                return new ItemData<string>(Encoding.ASCII.GetString(bytes), 0, QUALITIES.QUALITY_GOOD);
            }
            catch { return new ItemData<string>(null, 0, QUALITIES.QUALITY_BAD); }
        }