Skip to content

Commit

Permalink
Merge pull request #30 from ChrisPulman/AddCpuInfoAddSingle
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Aug 21, 2023
2 parents dfd2846 + 3cce938 commit 6f334cd
Show file tree
Hide file tree
Showing 25 changed files with 633 additions and 273 deletions.
Binary file added Docs/78028908_SIMATIC_Comm_DOKU_v23_e.pdf
Binary file not shown.
Binary file not shown.
Binary file added Docs/t-bausteine_e.pdf
Binary file not shown.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
![License](https://img.shields.io/github/license/ChrisPulman/S7PlcRx.svg) [![Build](https://github.com/ChrisPulman/S7PlcRx/actions/workflows/BuildOnly.yml/badge.svg)](https://github.com/ChrisPulman/S7PlcRx/actions/workflows/BuildOnly.yml) ![Nuget](https://img.shields.io/nuget/dt/S7PlcRx?color=pink&style=plastic) [![NuGet](https://img.shields.io/nuget/v/S7PlcRx.svg?style=plastic)](https://www.nuget.org/packages/S7PlcRx)

![Alt](https://repobeats.axiom.co/api/embed/48a23aed3690ef69ed277b96f2154062dd436af2.svg "Repobeats analytics image")

<p align="left">
<a href="https://github.com/ChrisPulman/S7PlcRx">
<img alt="S7PlcRx" src="https://github.com/ChrisPulman/S7PlcRx/blob/main/Images/S7PlcRx.png" width="200"/>
<img alt="S7PlcRx" src="./Images/S7PlcRx.png" width="200"/>
</a>
</p>

Expand Down Expand Up @@ -64,3 +66,34 @@ plc?.GetTag("Tag0")?.SetTagPollIng(true);
```csharp
plc.Value<double>("Tag0", 1.0);
```

#### Read PLC CPU Info
```csharp
var cpuInfo = await plc.CpuInfo();
```

This returns a `CpuInfo` string Array with the following values:
AS Name, Module Name, Copyright, Serial Number, Module Type Name, Order Code, Version.

#### Supported Data Types

- Bool
- Byte
- Int
- DInt
- Real
- LReal
- String
- Word
- DWord

Further types will be added in the future.

#### Supported PLCs

- Logo-0BA8
- S7-200
- S7-300
- S7-400
- S7-1200
- S7-1500
2 changes: 1 addition & 1 deletion Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.1.4",
"version": "1.2.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/main$"
Expand Down
2 changes: 1 addition & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ partial class Build : NukeBuild
}

PackagesDirectory.CreateOrCleanDirectory();
await this.UpdateVisualStudio();
////await this.UpdateVisualStudio();
await this.InstallDotNetSdk("3.1.x", "5.x.x", "6.x.x", "7.x.x");
});

Expand Down
15 changes: 11 additions & 4 deletions src/S7PlcRx.TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@
.AddUpdateTagItem<byte[]>(PlcData, "DB100.DBB0", 64).SetTagPollIng(false)
.AddUpdateTagItem<byte[]>(TestItems, "DB101.DBB0", 520).SetTagPollIng(false)
.AddUpdateTagItem<byte[]>(TagNames1, "DB102.DBB0", 4096).SetTagPollIng(false)
.AddUpdateTagItem<double[]>(TagValues, "DB103.DBD4", 98).SetTagPollIng(false);
.AddUpdateTagItem<float[]>(TagValues, "DB103.DBD4", 98).SetTagPollIng(false);

plc.IsConnected
.Where(x => x)
.Take(1)
.Subscribe(_ =>
.Subscribe(async _ =>
{
Console.WriteLine("Connected");
var info = await plc.GetCpuInfo();
foreach (var item in info)
{
Console.WriteLine(item);
}

await Task.Delay(2000);
plc.IsPaused.Subscribe(x => Console.WriteLine($"Paused: {x}"));
var setupComplete = false;
plc.Observe<byte>(StartLogging)
Expand Down Expand Up @@ -58,13 +65,13 @@
plc?.GetTag(TagValues).SetTagPollIng(true);
setupComplete = true;
});
plc.Observe<double[]>(TagValues)
plc.Observe<float[]>(TagValues)
.Where(_ => setupComplete)
.Subscribe(values =>
{
try
{
var tagValues = values?.Take(14).Select(Convert.ToSingle).ToArray();
var tagValues = values?.Take(14).ToArray();
Console.WriteLine($"TagValues: {string.Join(", ", tagValues!)}");
}
catch (Exception ex)
Expand Down
22 changes: 8 additions & 14 deletions src/S7PlcRx/Core/PLCRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@ namespace S7PlcRx.Core;
/// <summary>
/// PLC Request.
/// </summary>
internal class PLCRequest
/// <remarks>
/// Initializes a new instance of the <see cref="PLCRequest"/> class.
/// </remarks>
/// <param name="request">The request.</param>
/// <param name="tag">The tag.</param>
internal class PLCRequest(PLCRequestType request, Tag? tag)
{
/// <summary>
/// Initializes a new instance of the <see cref="PLCRequest"/> class.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="tag">The tag.</param>
public PLCRequest(PLCRequestType request, Tag? tag)
{
Request = request;
Tag = tag;
}

/// <summary>
/// Gets the request.
/// </summary>
/// <value>The request.</value>
public PLCRequestType Request { get; }
public PLCRequestType Request { get; } = request;

/// <summary>
/// Gets the tag.
/// </summary>
/// <value>The tag.</value>
public Tag? Tag { get; }
public Tag? Tag { get; } = tag;
}
Loading

0 comments on commit 6f334cd

Please sign in to comment.