added enums and methods overloads for S7Wordlength and S7Area

fix #11
This commit is contained in:
Federico Barresi
2020-06-05 17:19:30 +02:00
parent aa992fe51b
commit 470f736079
6 changed files with 66 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
#pragma warning disable 618
namespace Sharp7
{

12
Sharp7/S7Area.cs Normal file
View File

@@ -0,0 +1,12 @@
namespace Sharp7
{
public enum S7Area
{
PE = 0x81,
PA = 0x82,
MK = 0x83,
DB = 0x84,
CT = 0x1C,
TM = 0x1D,
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
#pragma warning disable 618
namespace Sharp7
{
@@ -819,6 +820,15 @@ namespace Sharp7
#region [Data I/O main functions]
public int ReadArea(S7Area Area, int DBNumber, int Start, int Amount, S7WordLength WordLen, byte[] Buffer)
{
return ReadArea((int)Area, DBNumber, Start, Amount, (int)WordLen, Buffer);
}
public int ReadArea(S7Area Area, int DBNumber, int Start, int Amount, S7WordLength WordLen, byte[] Buffer, ref int BytesRead)
{
return ReadArea((int)Area, DBNumber, Start, Amount, (int)WordLen, Buffer, ref BytesRead);
}
public int ReadArea(int Area, int DBNumber, int Start, int Amount, int WordLen, byte[] Buffer)
{
int BytesRead = 0;
@@ -934,6 +944,16 @@ namespace Sharp7
return _LastError;
}
public int WriteArea(S7Area Area, int DBNumber, int Start, int Amount, S7WordLength WordLen, byte[] Buffer)
{
int BytesWritten = 0;
return WriteArea((int) Area, DBNumber, Start, Amount, (int) WordLen, Buffer, ref BytesWritten);
}
public int WriteArea(S7Area Area, int DBNumber, int Start, int Amount, S7WordLength WordLen, byte[] Buffer, ref int BytesWritten)
{
return WriteArea((int) Area, DBNumber, Start, Amount, (int) WordLen, Buffer, ref BytesWritten);
}
public int WriteArea(int Area, int DBNumber, int Start, int Amount, int WordLen, byte[] Buffer)
{
int BytesWritten = 0;

View File

@@ -81,23 +81,23 @@ namespace Sharp7
public const Int32 p_u32_RecoveryTime = 14; // Not applicable here
public const Int32 p_u32_KeepAliveTime = 15; // Not applicable here
// Area ID
public const byte S7AreaPE = 0x81;
public const byte S7AreaPA = 0x82;
public const byte S7AreaMK = 0x83;
public const byte S7AreaDB = 0x84;
public const byte S7AreaCT = 0x1C;
public const byte S7AreaTM = 0x1D;
[Obsolete("Use enum S7Area.PE instead")]public const byte S7AreaPE = 0x81;
[Obsolete("Use enum S7Area.PA instead")]public const byte S7AreaPA = 0x82;
[Obsolete("Use enum S7Area.MK instead")]public const byte S7AreaMK = 0x83;
[Obsolete("Use enum S7Area.DB instead")]public const byte S7AreaDB = 0x84;
[Obsolete("Use enum S7Area.CT instead")]public const byte S7AreaCT = 0x1C;
[Obsolete("Use enum S7Area.TM instead")]public const byte S7AreaTM = 0x1D;
// Word Length
public const int S7WLBit = 0x01;
public const int S7WLByte = 0x02;
public const int S7WLChar = 0x03;
public const int S7WLWord = 0x04;
public const int S7WLInt = 0x05;
public const int S7WLDWord = 0x06;
public const int S7WLDInt = 0x07;
public const int S7WLReal = 0x08;
public const int S7WLCounter = 0x1C;
public const int S7WLTimer = 0x1D;
[Obsolete("Use enum S7WordLength.Bit instead")]public const int S7WLBit = 0x01;
[Obsolete("Use enum S7WordLength.Byte instead")]public const int S7WLByte = 0x02;
[Obsolete("Use enum S7WordLength.Char instead")]public const int S7WLChar = 0x03;
[Obsolete("Use enum S7WordLength.Word instead")]public const int S7WLWord = 0x04;
[Obsolete("Use enum S7WordLength.Int instead")]public const int S7WLInt = 0x05;
[Obsolete("Use enum S7WordLength.DWord instead")]public const int S7WLDWord = 0x06;
[Obsolete("Use enum S7WordLength.DInt instead")]public const int S7WLDInt = 0x07;
[Obsolete("Use enum S7WordLength.Real instead")]public const int S7WLReal = 0x08;
[Obsolete("Use enum S7WordLength.Counter instead")]public const int S7WLCounter = 0x1C;
[Obsolete("Use enum S7WordLength.Timer instead")]public const int S7WLTimer = 0x1D;
// PLC Status
public const int S7CpuStatusUnknown = 0x00;
public const int S7CpuStatusRun = 0x08;

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
#pragma warning disable 618
namespace Sharp7
{

16
Sharp7/S7WordLength.cs Normal file
View File

@@ -0,0 +1,16 @@
namespace Sharp7
{
public enum S7WordLength
{
Bit = 0x01,
Byte = 0x02,
Char = 0x03,
Word = 0x04,
Int = 0x05,
DWord = 0x06,
DInt = 0x07,
Real = 0x08,
Counter = 0x1C,
Timer = 0x1D,
}
}