KupaKuper_DeviceSever 2.3.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package KupaKuper_DeviceSever --version 2.3.2
                    
NuGet\Install-Package KupaKuper_DeviceSever -Version 2.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KupaKuper_DeviceSever" Version="2.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KupaKuper_DeviceSever" Version="2.3.2" />
                    
Directory.Packages.props
<PackageReference Include="KupaKuper_DeviceSever" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KupaKuper_DeviceSever --version 2.3.2
                    
#r "nuget: KupaKuper_DeviceSever, 2.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KupaKuper_DeviceSever@2.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KupaKuper_DeviceSever&version=2.3.2
                    
Install as a Cake Addin
#tool nuget:?package=KupaKuper_DeviceSever&version=2.3.2
                    
Install as a Cake Tool

IDeviceSystems 接口

接口概述

IDeviceSystems 接口定义了设备系统的核心功能,包括设备配置管理、消息通知、弹窗交互等。它作为设备系统与外部交互的桥梁,提供了统一的接口来处理设备连接状态变化、消息显示和用户交互等功能。

  • 依赖注入 :
services.AddMyServerServices();

命名空间

namespace KupaKuper_DeviceSever.Server

接口成员

属性

DeviceCores
DeviceCores? DeviceCores { get; set; }
  • 描述 :获取或设置设备配置文件,包含配置信息、配置信息语言包以及自动通讯和变量信息请求功能。
  • 返回值 : DeviceCores 类型的对象,可为 null。
AlarmPageName
string? AlarmPageName { get; set; }
  • 描述 :报警页面的名称,用于报警消息的跳转。
  • 返回值 :字符串,可为 null。
CurrentShowPopup
Dictionary<string, (string, KeyVar, Device)> CurrentShowPopup { get; 
set; }
  • 描述 :当前正在显示的弹窗集合。
  • 返回值 :字典,键为弹窗标识符,值为包含标题、键变量和设备信息的元组。

事件

ConnectChanged
event Action<bool>? ConnectChanged;
  • 描述 :连接状态发生变化时触发。
  • 参数 : bool 类型,表示新的连接状态( true 表示已连接, false 表示断开连接)。
ShowError
event Action<string, string, string?>? ShowError;
  • 描述 :显示错误消息的委托。
  • 参数 :
    • 第一个参数 string :消息发送人。
    • 第二个参数 string :消息内容。
    • 第三个参数 string? :消息溯源页面名称,可为 null。
ShowInfo
event Action<string, string, string?>? ShowInfo;
  • 描述 :显示提示消息的委托。
  • 参数 :与 ShowError 相同。
ShowWarning
event Action<string, string, string?>? ShowWarning;
  • 描述 :显示警告消息的委托。
  • 参数 :与 ShowError 相同。
ShowSuccess
event Action<string, string, string?>? ShowSuccess;
  • 描述 :显示成功消息的委托。
  • 参数 :与 ShowError 相同。
ShowDisplay
event Action<string, string, Action<bool>?>? ShowDisplay;
  • 描述 :显示确认型消息弹窗的委托。
  • 参数 :
    • 第一个参数 string :消息发送人。
    • 第二个参数 string :消息内容。
    • 第三个参数 Action:执行的方法,接收一个 bool 参数,可为 null。
ShowConfirmation
event Action<string, string, Action<bool>?>? 
#### ShowConfirmation;
  • 描述 :显示判断型消息弹窗的委托。
  • 参数 :与 ShowDisplay 相同。
ShowInput
event Action<string, string, Action<string>?>? ShowInput;
  • 描述 :显示输入型消息弹窗的委托。
  • 参数 :
    • 第一个参数 string :消息发送人。
    • 第二个参数 string :消息内容。
    • 第三个参数 Action :执行的方法,接收一个 string 参数,可为 null。
ShowChoose
event Action<string, string, List<string>, Action<string>?>? ShowChoose;
  • 描述 :显示选择型弹窗的委托。
  • 参数 :
    • 第一个参数 string :消息发送人。
    • 第二个参数 string :消息内容。
    • 第三个参数 List :选择项列表。
    • 第四个参数 Action? :执行的方法,接收一个 string 参数,可为 null。
CleanModal
event Action? CleanModal;
  • 描述 :清除弹窗的委托。无参数。
PopupsInstance
event Action<string, KeyVar, Device>? PopupsInstance;
  • 描述 :弹窗触发初始化配置的委托。
  • 参数 :
    • 第一个参数 string :弹窗标识符。
    • 第二个参数 KeyVar :键变量。
    • 第三个参数 Device :设备信息。
ShowAlarmCornerMarkers
event Action<int>? ShowAlarmCornerMarkers;
  • 描述 :显示报警消息角标的委托。
  • 参数 : int 类型,表示角标显示的数量。
ShowAlarmPopup
event Action<string, string, string?>? ShowAlarmPopup;
  • 描述 :设备报警触发的消息的委托。
  • 参数 :与 ShowError 相同。

方法

RequestToSendError
void RequestToSendError(string requestDeviecName, string message, 
string? errorViewName = null);
  • 描述 :请求给所有注册过错误消息的客户端发送错误信息。
  • 参数 :
    • requestDeviecName :请求设备名称。
    • message :错误消息内容。
    • errorViewName :错误视图名称,可为 null。
RequestToSendInfo
void RequestToSendInfo(string requestDeviecName, string message, 
string? errorViewName = null);
  • 描述 :请求给所有注册过提示消息的客户端发送提示信息。
  • 参数 :与 RequestToSendError 相同。
RequestToSendWarning
void RequestToSendWarning(string requestDeviecName, string message, 
string? errorViewName = null);
  • 描述 :请求给所有注册过警告消息的客户端发送警告信息。
  • 参数 :与 RequestToSendError 相同。
RequestToSendSuccess
void RequestToSendSuccess(string requestDeviecName, string message, 
string? errorViewName = null);
  • 描述 :请求给所有注册过成功消息的客户端发送成功信息。
  • 参数 :与 RequestToSendError 相同。
RequestToSetAlarmCornerMarkers
void RequestToSetAlarmCornerMarkers(int n);
  • 描述 :请求给所有注册过报警角标显示的客户端发送角标显示数量。
  • 参数 : n 表示角标显示的数量。
RequestToSendDisplay
void RequestToSendDisplay(string titl, string message, Action<bool> 
EndVoid);
  • 描述 :请求给所有注册过确认型弹窗的客户端发送弹窗消息。
  • 参数 :
    • titl :弹窗标题。
    • message :弹窗消息内容。
    • EndVoid :弹窗关闭后执行的方法,接收一个 bool 参数。
RequestToSendConfirmation
void RequestToSendConfirmation(string titl, string message, 
Action<bool> EndVoid);
  • 描述 :请求给所有注册过判断型弹窗的客户端发送弹窗消息。
  • 参数 :与 RequestToSendDisplay 相同。
RequestToSendInput
void RequestToSendInput(string titl, string message, Action<string> 
EndVoid);
  • 描述 :请求给所有注册过输入型弹窗的客户端发送弹窗消息。
  • 参数 :
    • titl :弹窗标题。
    • message :弹窗消息内容。
    • EndVoid :用户输入后执行的方法,接收一个 string 参数。
RequestToSendChoose
void RequestToSendChoose(string titl, string message, List<string> 
chooseData, Action<string> EndVoid);
  • 描述 :请求给所有注册过选择型弹窗的客户端发送弹窗消息。
  • 参数 :
    • titl :弹窗标题。
    • message :弹窗消息内容。
    • chooseData :选择项列表。
    • EndVoid :用户选择后执行的方法,接收一个 string 参数。

使用示例

实现接口

public class DeviceSystems : IDeviceSystems
{
    // 实现接口的所有成员
    public DeviceCores? DeviceCores { get; set; }
    public event Action<bool>? ConnectChanged;
    // ... 其他成员的实现 ...
}

订阅事件

var deviceSystems = new DeviceSystems();
deviceSystems.ConnectChanged += OnConnectChanged;
deviceSystems.ShowError += OnShowError;

private void OnConnectChanged(bool isConnected)
{
    // 处理连接状态变化
    Console.WriteLine($"连接状态: {isConnected}");
}

private void OnShowError(string sender, string message, string? 
viewName)
{
    // 显示错误消息
    Console.WriteLine($"错误 [{sender}]: {message} (视图: {viewName ?? "
    未知"})");
}

发送消息

// 发送错误消息
deviceSystems.RequestToSendError("Device1", "连接失败", "HomeView");

// 发送成功消息
deviceSystems.RequestToSendSuccess("Device1", "操作成功完成", 
"SettingsView");

// 显示确认弹窗
deviceSystems.RequestToSendConfirmation(
    "确认操作", 
    "您确定要执行此操作吗?", 
    result => 
    {
        if (result) 
        {
            // 用户确认
            Console.WriteLine("用户确认了操作");
        } 
        else 
        {
            // 用户取消
            Console.WriteLine("用户取消了操作");
        }
    }
);

IDeviceCores接口

接口概述

IDeviceCore 接口是设备核心功能的抽象定义,提供了设备配置管理、系统状态监控、数据读写请求以及事件通知等功能。该接口作为设备系统与外部交互的桥梁,规范了设备通信、状态更新和数据交换的标准操作。

命名空间

namespace KupaKuper_HMI_Device.IDevice

接口成员

功能配置

DeviceSetting
DeviceSetting DeviceSetting { get; set; }
  • 描述 :获取或设置设备的功能配置信息。
  • 类型 : DeviceSetting
  • 访问权限 :读/写

系统信息

Connected
bool Connected { get; }
  • 描述 :获取设备的连接状态。
  • 返回值 : bool , true 表示已连接, false 表示未连接。
  • 访问权限 :只读
DeviceConfig
GetConfig DeviceConfig { get; }
  • 描述 :获取设备的配置文件信息。
  • 返回值 : GetConfig 类型的配置对象。
  • 访问权限 :只读
Ethernet
BaseEthernet? Ethernet { get; }
  • 描述 :获取设备的通讯类实例。
  • 返回值 : BaseEthernet 类型的通讯对象,可为 null。
  • 访问权限 :只读
DeviceSystemMode
SystemConfig? DeviceSystemMode { get; }
  • 描述 :获取设备的系统控制信息。
  • 返回值 : SystemConfig 类型的系统配置对象,可为 null。
  • 访问权限 :只读
CurrentAlarmModes
ObservableCollection<Alarm> CurrentAlarmModes { get; }
  • 描述 :获取当前设备的报警信息列表。
  • 返回值 : ObservableCollection<Alarm> 类型的报警集合。
  • 访问权限 :只读
AxesName
List<string> AxesName { get; }
  • 描述 :获取设备所有轴的名称列表。
  • 返回值 : List<string> 类型的轴名称集合。
  • 访问权限 :只读
AxesModes
Dictionary<string, ObservableCollection<Axis>> AxesModes { get; }
  • 描述 :获取设备所有轴的状态数据。
  • 返回值 :字典,键为轴名称,值为对应轴的状态集合。
  • 访问权限 :只读
CylindersName
List<string> CylindersName { get; }
  • 描述 :获取设备所有气缸组的名称列表。
  • 返回值 : List<string> 类型的气缸组名称集合。
  • 访问权限 :只读
CylinderModes
Dictionary<string, ObservableCollection<Cylinder>> CylinderModes { 
get; }
  • 描述 :获取设备所有气缸的状态数据。
  • 返回值 :字典,键为气缸组名称,值为对应气缸组的状态集合。
  • 访问权限 :只读
IoModes
Dictionary<string, ObservableCollection<Io>> IoModes { get; }
  • 描述 :获取设备所有 IO 点的状态数据。
  • 返回值 :字典,键为 IO 类型,值为对应 IO 点的状态集合。
  • 访问权限 :只读
ParametersName
List<string> ParametersName { get; }
  • 描述 :获取设备所有参数组的名称列表。
  • 返回值 : List<string> 类型的参数组名称集合。
  • 访问权限 :只读
ParameterModes
Dictionary<string, ObservableCollection<Parameter>> ParameterModes { 
get; }
  • 描述 :获取设备所有参数的状态数据。
  • 返回值 :字典,键为参数组名称,值为对应参数组的状态集合。
  • 访问权限 :只读
KeyValueModes
Dictionary<string, KeyVar> KeyValueModes { get; }
  • 描述 :获取设备所有常驻变量的状态数据。
  • 返回值 :字典,键为变量名称,值为 KeyVar 类型的变量对象。
  • 访问权限 :只读

事件委托

AlarmTrigger
event Action<string, Alarm>? AlarmTrigger;
  • 描述 :当系统读取到新的报警信息时触发。
  • 参数 :
    • 第一个参数 string :触发报警的设备标识。
    • 第二个参数 Alarm :报警信息对象。
EtherConnectChanged
event Action<bool>? EtherConnectChanged;
  • 描述 :当设备连接状态发生变化时触发。
  • 参数 : bool 类型,表示新的连接状态( true 表示已连接, false 表示断开连接)。
DeviceModeChanged
event Action? DeviceModeChanged;
  • 描述 :当设备状态发生变化时触发。无参数。
Error
event Action<string, string>? Error;
  • 描述 :当系统执行过程中发生错误时触发,用于显示错误信息。
  • 参数 :
    • 第一个参数 string :错误来源。
    • 第二个参数 string :错误消息内容。

读取请求

RequestUpdataIo
void RequestUpdataIo(string RequestId, string IoType, Action? IsUpdata 
= null);
  • 描述 :请求开启更新指定类型的 IO 数据。
  • 参数 :
    • RequestId :客户端的识别 ID,随机生成即可。
    • IoType :IO 类型(如 "input"、"output")。
    • IsUpdata :更新完成后的回调函数,可为 null。
RequestUpdataAxis
void RequestUpdataAxis(string RequestId, string AxisName, Action? 
IsUpdata = null);
  • 描述 :请求开启更新指定轴的状态数据。
  • 参数 :
    • RequestId :客户端的识别 ID,随机生成即可。
    • AxisName :轴的名称,必须存在于 AxesName 列表中。
    • IsUpdata :更新完成后的回调函数,可为 null。
RequestUpdataCylinders
void RequestUpdataCylinders(string RequestId, string Cylinders, Action? 
IsUpdata = null);
  • 描述 :请求开启更新指定气缸组的状态数据。
  • 参数 :
    • RequestId :客户端的识别 ID,随机生成即可。
    • Cylinders :气缸组的名称,必须存在于 CylindersName 列表中。
    • IsUpdata :更新完成后的回调函数,可为 null。
RequestUpdataParameters
void RequestUpdataParameters(string RequestId, string Parameters, 
Action? IsUpdata = null);
  • 描述 :请求开启更新指定参数组的状态数据。
  • 参数 :
    • RequestId :客户端的识别 ID,随机生成即可。
    • Parameters :参数组的名称,必须存在于 ParametersName 列表中。
    • IsUpdata :更新完成后的回调函数,可为 null。
RemoveUpdataIo
void RemoveUpdataIo(string RequestId, string IoType, Action? IsUpdata = 
null);
  • 描述 :请求关闭指定类型 IO 数据的更新。
  • 参数 :
    • RequestId :客户端的识别 ID,必须与开启更新时使用的 ID 对应。
    • IoType :IO 类型(如 "input"、"output")。
    • IsUpdata :关闭更新后的回调函数,可为 null。
RemoveUpdataAxis
void RemoveUpdataAxis(string RequestId, string AxisName, Action? 
IsUpdata = null);
  • 描述 :请求关闭指定轴状态数据的更新。
  • 参数 :
    • RequestId :客户端的识别 ID,必须与开启更新时使用的 ID 对应。
    • AxisName :轴的名称,必须存在于 AxesName 列表中。
    • IsUpdata :关闭更新后的回调函数,可为 null。
RemoveUpdataCylinders
void RemoveUpdataCylinders(string RequestId, string Cylinders, Action? 
IsUpdata = null);
  • 描述 :请求关闭指定气缸组状态数据的更新。
  • 参数 :
    • RequestId :客户端的识别 ID,必须与开启更新时使用的 ID 对应。
    • Cylinders :气缸组的名称,必须存在于 CylindersName 列表中。
    • IsUpdata :关闭更新后的回调函数,可为 null。
RemoveUpdataParameters
void RemoveUpdataParameters(string RequestId, string Parameters, 
Action? IsUpdata = null);
  • 描述 :请求关闭指定参数组状态数据的更新。
  • 参数 :
    • RequestId :客户端的识别 ID,必须与开启更新时使用的 ID 对应。
    • Parameters :参数组的名称,必须存在于 ParametersName 列表中。
    • IsUpdata :关闭更新后的回调函数,可为 null。
RequestUpataAll
void RequestUpataAll(string RequestId);
  • 描述 :请求开启所有数据的读取更新。
  • 参数 : RequestId :客户端的识别 ID,随机生成即可。
RemoveUpdataAll
void RemoveUpdataAll(string RequestId);
  • 描述 :请求关闭所有数据的读取更新。
  • 参数 : RequestId :客户端的识别 ID,必须与开启更新时使用的 ID 对应。
ReadAlarmLogAsync
Task<string[]?> ReadAlarmLogAsync(string laguage, DateTime dateTime);
  • 描述 :异步获取指定语言和日期的报警日志记录数据。
  • 参数 :
    • laguage :语言标识。
    • dateTime :目标日期时间。
  • 返回值 : Task<string[]?> ,异步操作的结果,包含报警日志记录的字符串数组,可为 null。

其他方法

GetT
bool GetT(VarMode mode, string? text, out dynamic value);
  • 描述 :将指定的 VarMode 类型的文本值转换为对应的数据类型。
  • 参数 :
    • mode :变量模式,指定要转换的目标数据类型。
    • text :要转换的文本值,可为 null。
    • value :输出参数,转换后的动态类型值。
  • 返回值 : bool ,表示转换是否成功。
AddDeviceLogItem
void AddDeviceLogItem(string logMessage);
  • 描述 :向设备日志队列中添加一条日志记录。
  • 参数 : logMessage :日志消息内容。
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.7.2 168 3/21/2026 2.7.2 is deprecated because it is no longer maintained.
2.7.1 140 3/21/2026
2.7.0-beta 131 3/16/2026
2.6.0 139 3/15/2026
2.5.3 135 3/5/2026
2.5.2 139 2/28/2026
2.5.1 141 2/3/2026
2.4.1 164 9/27/2025
2.3.3 191 9/27/2025 2.3.3 is deprecated because it has critical bugs.
2.3.2 252 9/4/2025
2.3.1 261 9/3/2025
2.3.0 215 9/2/2025
2.2.2 218 9/1/2025
2.2.1 291 8/28/2025
2.2.0 288 8/27/2025
2.1.0 207 8/22/2025
2.0.1-bate 225 8/20/2025
2.0.0-bate 164 8/16/2025
1.1.2-bate 124 8/2/2025
1.1.1-bate 145 8/2/2025
Loading failed