KeytalkClientLibCore 1.0.6-dev00000000
dotnet add package KeytalkClientLibCore --version 1.0.6-dev00000000
NuGet\Install-Package KeytalkClientLibCore -Version 1.0.6-dev00000000
<PackageReference Include="KeytalkClientLibCore" Version="1.0.6-dev00000000" />
<PackageVersion Include="KeytalkClientLibCore" Version="1.0.6-dev00000000" />
<PackageReference Include="KeytalkClientLibCore" />
paket add KeytalkClientLibCore --version 1.0.6-dev00000000
#r "nuget: KeytalkClientLibCore, 1.0.6-dev00000000"
#:package KeytalkClientLibCore@1.0.6-dev00000000
#addin nuget:?package=KeytalkClientLibCore&version=1.0.6-dev00000000&prerelease
#tool nuget:?package=KeytalkClientLibCore&version=1.0.6-dev00000000&prerelease
KeytalkClientLibCore
.NET Standard 2
This library implements the client side for Keytalk communication.
Keytalk currently uses two different protocols, one binary on TCP port 5558, one HTTP/HTTPS based.
The binary client implementation (tcpClient / ClientSession)
- Do not use the binary implementation.
- sourcecode compatible with the code used inside Keytalk for communication between Keytalk instances.
- This means that compability with .NET Compact framework (a very old framework).
- Does not support alarm blocking
- Does not support trend download
- Has a ClientSession implementation that handles reconnection for you.
- Each instance uses two threads (synchronous tcp communication).
The HTTP/HTTPS client implementation (KeytalkHTTP2api)
- based on the async/await pattern.
- ThreadingContext is captured for subscribe callbacks
- Does not yet have a ClientSession implementation that handles reconnection for you.
- Does not yet support trend download (only available in nodeJS)
- Subscribe handles has a .Task which can be awaited for the first value/exception.
- Multiple subscribe/request on same tag is handled efficently.
KeyTalkHTTP2api
Main class used for communication.
Subscription is used with anonymous functions. Take care to watch for errors on the KeytalkValue as exceptions will not be raised for these functions.
KeytalkValue
KeytalkValue is a struct holding a Keytalk compatible value or error.
Properties
/// <summary>
/// Keytalk internal type. When writing values the right type must be used.
/// </summary>
public KeyTyp aTyp;
/// <summary>
/// Value represented as an object
/// </summary>
public object v;
/// <summary>
/// Error result
/// </summary>
public string err;
/// <summary>
/// Is the result an error?
/// </summary>
/// <returns>true if error, false if ther is a value</returns>
public bool IsError { get { return !string.IsNullOrEmpty(err); } }
Many basic types are implicity converted to KeytalkValue (automaticly).
- bool
- DateTime
- TimeSpan
- double, float
- short, int, long, sbyte, ushort, uint, ulong, byte
- string
keytalkClient.WriteValue(tag,15); // 15 will be converted to KeytalkValue (with KeyTyp.tint32)
You can explicity cast a KeyTalkValue to any of the above, when explicit you need to tell C# what you want.
bool b = (bool)keytalkValue;
If the cast is not possible an exception will be raised. You need to use the exacly correct type corresponding to type used in the keytalk database.
There is also a nullable cast for all the types.
bool b = (bool?)keytalkValue;
Download resources
It is allowed to reuse the internal HttpClient.
Some resources checks security and requries a session. Set the session id as in this example.
var req=await comm.HttpClient.GetAsync($"{comm.BaseAddress}statefile?sid={comm.Sid}");
if (!req.IsSuccessStatusCode)
Console.WriteLine("stateFile failed");
else
Console.WriteLine(await req.Content.ReadAsStringAsync());
Use .BaseAddress as it is updated to reflect any HTTP move, often http-->https.
Some of the resources that requires a session
- statefile
- clientstoragefile
- enginetostring
- activesubs
Some of the resources that does not require any session
- systeminfo
- log
- All files i www folder
Some resources that does not currently require any session, but probably will in the future
- graf.xml
- blocks.xml
- alarms.xml
- reports/xxx
- loggs/xxx
- dok/xxx
Special attributes
!attribListJson
{
fullId :string;
className: string;
childrenCount: number;
area: string;
b: number;
attributes: {
name:string;
type:string;
valid:boolean;
area:string;
b:number;
flags_noSave?:boolean;
flags_noWrite?:boolean;
flags_big?:boolean;
flags_notInMem?:boolean;
flags_proxy?:boolean;
value:string;
}[];
}
!childrenListJson
{
name: string;
className: string;
childrenCount: number;
area: string;
b: number;
}[]
!childrenList
Tab sepearated list of children
!attribList
Tab sepearated list of attributes
!className
!securityIndex
!securityB
@flag_ATTRIBUT
@type_ATTRIBUT
@securityIndex_ATTRIBUT
@securityB_ATTRIBUT
@childrenList_ATTRIBUT
@childrenListJson_idregex@classregex
nytt 2020
@securityIndex_idregex@classregex
nytt 2020
MetaDataManager
MetDataManager is a class that can be used to request additional information about tags. Reuse your instance, it caches the information for you.
var met = new KeyTalkClientLibCore.HTTP2.MetaDataManager.MetDataManager(comm);
var metData = await met.getMetaDataForTag("tagname");
TwincatHelper
TwincatHelper can be used to easiler find twincattags based on it's location and metadata.
var tch = new KeyTalkClientLibCore.HTTP2.TwincatHelper.TwincatHelper(comm);
foreach (var tcId in await tch.getTwincatDevices()) {
Console.WriteLine(tcId);
var (tags, root) = await tch.GetTagsForTwincatDevice(tcId);
foreach (var tag in tags) {
Console.WriteLine(" "+tag.tag);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.6-dev00000000 | 61 | 9/1/2026 |
| 1.0.5-dev00000000 | 144 | 2/18/2025 |
| 1.0.4-dev00000000 | 103 | 6/24/2024 |
| 1.0.3-dev00000000 | 123 | 6/18/2024 |