mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Projektdateien hinzufügen.
This commit is contained in:
12
Examples/Examples.csproj
Normal file
12
Examples/Examples.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MewtocolNet\MewtocolNet.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
39
Examples/Program.cs
Normal file
39
Examples/Program.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using MewtocolNet;
|
||||
|
||||
namespace Examples {
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
|
||||
Console.WriteLine("Starting test");
|
||||
|
||||
Task.Factory.StartNew(async () => {
|
||||
|
||||
MewtocolInterface interf = new MewtocolInterface("10.237.191.3");
|
||||
|
||||
interf.AddRegister<short>("Cooler Status",1204);
|
||||
interf.AddRegister<string>(1101, 4);
|
||||
|
||||
interf.RegisterChanged += (o) => {
|
||||
Console.WriteLine($"DT{o.MemoryAdress} {(o.Name != null ? $"({o.Name}) " : "")}changed to {o.GetValueString()}");
|
||||
};
|
||||
|
||||
await interf.ConnectAsync(
|
||||
(plcinf) => {
|
||||
|
||||
Console.WriteLine("Connected to PLC:\n" + plcinf.ToString());
|
||||
},
|
||||
() => {
|
||||
Console.WriteLine("Failed connection");
|
||||
}
|
||||
).AttachContinousReader(50);
|
||||
|
||||
|
||||
});
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user