mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2025-12-17 17:06:50 +08:00
Updated Home (markdown)
44
Home.md
44
Home.md
@@ -21,7 +21,7 @@ To create an instance of the driver you need to use this constructor:
|
||||
```csharp
|
||||
public Plc(CpuType cpu, string ip, Int16 rack, Int16 slot)
|
||||
```
|
||||
* Cpu: this specify what CPU you are connecting to. The supported CPU are:
|
||||
* **cpu**: this specify what CPU you are connecting to. The supported CPU are:
|
||||
```csharp
|
||||
public enum CpuType {
|
||||
S7200 = 0,
|
||||
@@ -31,9 +31,9 @@ public enum CpuType {
|
||||
S71500 = 40,
|
||||
}
|
||||
```
|
||||
* Ip: specify the IP address of the CPU or of the external Ethernet card
|
||||
* Rack: this contains the rack of the plc, that you can find in hardware configuration in Step7
|
||||
* Slot: this is the slot of the CPU, that you can find in hardware configuration in Step7
|
||||
* **ip**: specify the IP address of the CPU or of the external Ethernet card
|
||||
* **rack**: this contains the rack of the plc, that you can find in hardware configuration in Step7
|
||||
* **slot**: this is the slot of the CPU, that you can find in hardware configuration in Step7
|
||||
|
||||
Example:
|
||||
|
||||
@@ -109,7 +109,7 @@ public void WriteBytes(DataType dataType, int db, int startByteAdr, byte[] value
|
||||
```
|
||||
This reads all the bytes you specify from a given memory location. This method handles multiple requests automatically in case the number of bytes exceeds the maximum bytes that can be transferred in a single request.
|
||||
|
||||
* dataType: you have to specify the memory location with the enum DataType
|
||||
* **dataType**: you have to specify the memory location with the enum DataType
|
||||
```csharp
|
||||
public enum DataType
|
||||
{
|
||||
@@ -121,10 +121,10 @@ public enum DataType
|
||||
Counter = 28
|
||||
}
|
||||
```
|
||||
* db: the address of the dataType, for example if you want to read DB1, this field is “1”; if you want to read T45, this field is 45.
|
||||
* startByteAdr: the address of the first byte that you want to read, for example if you want to read DB1.DBW200, this is 200.
|
||||
* count: contains how many bytes you want to read.
|
||||
* Value[]: array of bytes to be written to the plc.
|
||||
* **db**: the address of the dataType, for example if you want to read DB1, this field is “1”; if you want to read T45, this field is 45.
|
||||
* **startByteAdr**: the address of the first byte that you want to read, for example if you want to read DB1.DBW200, this is 200.
|
||||
* **count**: contains how many bytes you want to read.
|
||||
* **value[ ]**: array of bytes to be written to the plc.
|
||||
|
||||
Example:
|
||||
This method reads the first 200 bytes of DB1:
|
||||
@@ -140,7 +140,7 @@ public object Read(DataType dataType, int db, int startByteAdr, VarType varType,
|
||||
|
||||
public void Write(DataType dataType, int db, int startByteAdr, object value)
|
||||
```
|
||||
* dataType: you have to specify the memory location with the enum DataType
|
||||
* **dataType**: you have to specify the memory location with the enum DataType
|
||||
```csharp
|
||||
public enum DataType
|
||||
{
|
||||
@@ -152,9 +152,9 @@ public enum DataType
|
||||
Counter = 28
|
||||
}
|
||||
```
|
||||
* db: the address of the dataType, for example if you want to read DB1, this field is “1”; if you want to read T45, this field is 45.
|
||||
* startByteAdr: the address of the first byte that you want to read, for example if you want to read DB1.DBW200, this is 200.
|
||||
* varType: specify the data that you want to get your bytes converted.
|
||||
* **db**: the address of the dataType, for example if you want to read DB1, this field is “1”; if you want to read T45, this field is 45.
|
||||
* **startByteAdr**: the address of the first byte that you want to read, for example if you want to read DB1.DBW200, this is 200.
|
||||
* **varType**: specify the data that you want to get your bytes converted.
|
||||
```csharp
|
||||
public enum VarType
|
||||
{
|
||||
@@ -171,8 +171,8 @@ public enum VarType
|
||||
Counter
|
||||
}
|
||||
```
|
||||
* count: contains how many variables you want to read.
|
||||
* Value: array of values to be written to the plc. It can be a single value or an array, just remember that the type is unique (for example array of double, array of int, array of shorts, etc..)
|
||||
* **count**: contains how many variables you want to read.
|
||||
* **value**: array of values to be written to the plc. It can be a single value or an array, just remember that the type is unique (for example array of double, array of int, array of shorts, etc..)
|
||||
|
||||
Example:
|
||||
This method reads the first 20 DWords of DB1:
|
||||
@@ -189,7 +189,7 @@ public object Read(string variable)
|
||||
public void Write(string variable, object value)
|
||||
```
|
||||
|
||||
* variable: specify the variable to read by using strings like “DB1.DBW20”, “T45”, “C21”, “DB1.DBD400”, etc.
|
||||
* **variable**: specify the variable to read by using strings like “DB1.DBW20”, “T45”, “C21”, “DB1.DBD400”, etc.
|
||||
|
||||
Example:
|
||||
This reads the variable DB1.DBW0. The result must be cast to ushort to get the correct 16-bit format in C#.
|
||||
@@ -205,9 +205,9 @@ public object ReadStruct(Type structType, int db, int startByteAdr = 0)
|
||||
|
||||
public void WriteStruct(object structValue, int db, int startByteAdr = 0)
|
||||
```
|
||||
* structType: Type of the struct to be read, for example: typeOf(MyStruct))
|
||||
* db: index of the DB to read
|
||||
* startByteAdr: specified the first address of the byte to read (the default is zero).
|
||||
* **structType**: Type of the struct to be read, for example: typeOf(MyStruct))
|
||||
* **db**: index of the DB to read
|
||||
* **startByteAdr**: specified the first address of the byte to read (the default is zero).
|
||||
|
||||
Example:
|
||||
Define a DataBlock in the plc like:
|
||||
@@ -248,9 +248,9 @@ public void ReadClass(object sourceClass, int db, int startByteAdr = 0)
|
||||
|
||||
public void WriteClass(object classValue, int db, int startByteAdr = 0)
|
||||
```
|
||||
* sourceClass: instance of the class that you want to assign the values
|
||||
* db: index of the DB to read
|
||||
* startByteAdr: specified the first address of the byte to read (the default is zero).
|
||||
* **sourceClass**: instance of the class that you want to assign the values
|
||||
* **db**: index of the DB to read
|
||||
* **startByteAdr**: specified the first address of the byte to read (the default is zero).
|
||||
Example:
|
||||
Define a DataBlock in the plc like:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user