mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2025-12-17 08:56:49 +08:00
Updated Home (markdown)
16
Home.md
16
Home.md
@@ -301,8 +301,8 @@ public void Plc.ReadMultibleVars(List<DataItem> dataItems);
|
||||
|
||||
Example: this method reads several variables from a data block
|
||||
|
||||
define the data items first
|
||||
```csharp
|
||||
// define the data items first
|
||||
private static DataItem varBit = new DataItem()
|
||||
{
|
||||
DataType = DataType.DataBlock,
|
||||
@@ -368,19 +368,23 @@ private static DataItem varDateTime = new DataItem()
|
||||
StartByteAdr = 138,
|
||||
Value = new object()
|
||||
};
|
||||
|
||||
// define a list where the DataItems will be stored in
|
||||
```
|
||||
Then define a list where the DataItems will be stored in
|
||||
```csharp
|
||||
private static List<DataItem> dataItemsRead = new List<DataItem>();
|
||||
|
||||
// add the DataItems to the list
|
||||
```
|
||||
add the data items to the list
|
||||
```csharp
|
||||
dataItemsRead.Add(varBit);
|
||||
dataItemsRead.Add(varByteArray);
|
||||
dataItemsRead.Add(varInt);
|
||||
dataItemsRead.Add(varReal);
|
||||
dataItemsRead.Add(varString);
|
||||
dataItemsRead.Add(varDateTime);
|
||||
```
|
||||
|
||||
// open the connection to the plc
|
||||
open the connection to the plc and read the items at once
|
||||
```csharp
|
||||
myPLC.Open();
|
||||
|
||||
// read the list of variables
|
||||
|
||||
Reference in New Issue
Block a user