Skip to content

Commit

Permalink
doc: clarify progress parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbesler committed Jun 17, 2022
1 parent 5f151b1 commit 7bfc9d1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,25 @@ await client.WriteJson("GVL.JsonDutVariable", json);

### Options
#### Progress indication
For lengthy operations, a progress indiciator can be used to give some feedback about how many variables have already been read or written, respectively.
For lengthy operations, a progress indiciator can be used to give some feedback about the current progress. By passing a `Progress<int>` object as parameter to `ReadJson` or `WriteJson` it is possible to count the total number of primitive types (INT, DINT, REAL, ...) that were read or written to the PLC, respectively.

```csharp
int objects = 0;
var progress = new Progress<int>();
progress.ProgressChanged += (sender, args) => { objects++; Console.CursorLeft = 0; Console.Write(objects); };

Console.WriteLine("Primitives read from PLC");
await client.ReadJson("GVL.JsonDutVariable", progress: progress);

Console.WriteLine("\nPrimitives written to PLC");
await client.WriteJson("GVL.JsonDutVariable", json, progress: progress);
```

#### Enumeration stringify
Values of enumerations are by default started as integer values. However, sometimes it is beneficial to store said values as strings. This can be achieved by
the `stringify` parameter.
Values of enumerations are by default started as integer values. However, sometimes it is beneficial to store said values as strings. This can be achieved by the `stringify` parameter.

```csharp
await client.ReadJson("GVL.JsonDutVariable", stringifyEnums: true);
await client.ReadJson("GVL.JsonDutVariable", force: true, stringifyEnums: true);
```


Expand Down

0 comments on commit 7bfc9d1

Please sign in to comment.