Files
ThingsGateway/src/ThingsGateway.ScriptDebug/Test/TestExexcuteExpressions.cs
2025-09-18 17:54:29 +08:00

46 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//using System.Text;
//using ThingsGateway.Gateway.Application;
//public class TestExexcuteExpressions : IExexcuteExpressions
//{
// public TouchSocket.Core.ILog Logger { get; set; }
// public async System.Threading.Tasks.Task<NodeOutput> ExecuteAsync(NodeInput input, System.Threading.CancellationToken cancellationToken)
// {
// //想上传mqtt可以自己写mqtt上传代码或者通过mqtt插件的公开方法上传
// //直接获取mqttclient插件类型的第一个设备
// var mqttClient = GlobalData.ReadOnlyChannels.FirstOrDefault(a => a.Value.PluginName == "ThingsGateway.Plugin.Mqtt.MqttClient").Value?.ReadDeviceRuntimes?.FirstOrDefault().Value?.Driver as ThingsGateway.Plugin.Mqtt.MqttClient;
// if (mqttClient == null)
// throw new("mqttClient NOT FOUND");
// TopicArray topicArray = new()
// {
// Topic = "test",
// Payload = Encoding.UTF8.GetBytes("test")
// };
// var result = await mqttClient.MqttUpAsync(topicArray, default).ConfigureAwait(false);// 主题 和 负载
// if (!result.IsSuccess)
// throw new(result.ErrorMessage);
// return new NodeOutput() { Value = result };
// //通过设备名称找出mqttClient插件
// //var mqttClient = GlobalData.ReadOnlyDevices.FirstOrDefault(a => a.Value.Name == "mqttDevice1").Value?.Driver as ThingsGateway.Plugin.Mqtt.MqttClient;
// //if (mqttClient == null)
// // throw new("mqttClient NOT FOUND");
// //TopicArray topicArray = new()
// //{
// // Topic = "test",
// // Payload = Encoding.UTF8.GetBytes("test")
// //};
// //var result = await mqttClient.MqttUpAsync(topicArray, default).ConfigureAwait(false);// 主题 和 负载
// //if (!result.IsSuccess)
// // throw new(result.ErrorMessage);
// //return new NodeOutput() { Value = result };
// }
//}