连接三维信息增加文本配置

This commit is contained in:
qsp89 2025-11-21 10:24:04 +08:00
parent 8a4fceebc0
commit d490f510dc
5 changed files with 74 additions and 6 deletions

View File

@ -97,6 +97,9 @@ namespace YunDa.Server.ISMSTcp
// 注册 WebApi 配置类
services.Configure<WebApiSettings>(context.Configuration.GetSection("WebApi"));
// 注册 ThingApiService配置
services.Configure<ThingApiServiceSettings>(context.Configuration.GetSection("ThingApiService"));
})
.UseSerilog()
.UseConsoleLifetime();

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
@ -30,6 +31,15 @@ using static System.Net.Mime.MediaTypeNames;
namespace YunDa.Server.ISMSTcp.Services
{
//ThingApiService配置
public class ThingApiServiceSettings
{
public string ApiServerUrl { get; set; } = string.Empty;
public string LoginCode { get; set; } = string.Empty;
public string LoginKey { get; set; } = string.Empty;
public string EsAuthorization { get; set; } = string.Empty;
}
public class ThingDeviceStatusModel
{
public string TwinID { get; set; } = string.Empty;
@ -623,16 +633,31 @@ namespace YunDa.Server.ISMSTcp.Services
}
//推送全体性能数据
private int _updateAllSimDatasCnt = 0;
private async Task UpdateAllSimDatas()
{
/*******************推送遥测全体性能数据/*******************/
var telemeteringModels = await _telemeteringModelListRedis.HashSetGetAllAsync(_telemeteringModelListRediskey);
await UpdateYCSimDatasStatus(telemeteringModels);
/*******************推送遥信全体性能数据/*******************/
var telesignalisationModels = await _telesignalisationModelListRedis.HashSetGetAllAsync(_telesignalisationModelListRediskey);
await UpdateYXSimDatasStatus(telesignalisationModels);
if(_updateAllSimDatasCnt == 0)
{
await UpdateThingYCStatus(telemeteringModels);
await UpdateThingYXStatus(telesignalisationModels);
}
else
{
await UpdateYCSimDatasStatus(telemeteringModels);
await UpdateYXSimDatasStatus(telesignalisationModels);
}
++_updateAllSimDatasCnt;
}
//推送遥测性能数据
@ -1213,14 +1238,36 @@ namespace YunDa.Server.ISMSTcp.Services
private DateTime _apiTokenTime = DateTime.MinValue;
private readonly SemaphoreSlim _apiTokenSemaphore = new SemaphoreSlim(1, 1);
private readonly ThingApiServiceSettings _thingApiServiceSettings;
public ThingApiService(
ILogger<ThingApiService> logger)
ILogger<ThingApiService> logger,
IOptions<ThingApiServiceSettings> thingApiServiceSettings)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_deviceStatusChannel = Channel.CreateUnbounded<List<ThingDeviceStatusModel>>();
_alarmDataChannel = Channel.CreateUnbounded<List<TingAlarmPushDataModel>>();
_thingApiServiceSettings = thingApiServiceSettings.Value;
if (!string.IsNullOrWhiteSpace(_thingApiServiceSettings.ApiServerUrl))
_apiServerUrl = _thingApiServiceSettings.ApiServerUrl;
if (!string.IsNullOrWhiteSpace(_thingApiServiceSettings.LoginCode))
_loginCode = _thingApiServiceSettings.LoginCode;
if (!string.IsNullOrWhiteSpace(_thingApiServiceSettings.LoginKey))
_loginKey = _thingApiServiceSettings.LoginKey;
if (!string.IsNullOrWhiteSpace(_thingApiServiceSettings.EsAuthorization))
_esAuthorization = _thingApiServiceSettings.EsAuthorization;
System.Console.WriteLine($"ThingApiService Url: {_apiServerUrl}");
StartPushDeviceStatus();
StarPushAlarmStatus();

View File

@ -375,7 +375,19 @@ namespace YunDa.Server.ISMSTcp.Services
{
try
{
_zzDataCacheContainer.Write(id, value, timestamp, "");
string valStr = "不定";
switch((int)value)
{
case 0:
valStr = "报警";
break;
case 1:
valStr = "正常";
break;
}
_zzDataCacheContainer.Write(id, value, timestamp, "", valStr);
}
catch (Exception ex)
{

View File

@ -272,14 +272,14 @@ namespace YunDa.Server.ISMSTcp.Services
{
string cmd = "CallVAByStat|B001";
for (int i = 0; i < 3; i++)
for (int i = 0; i < 5; i++)
{
var sendResult = await _zTcpService.SendTcpMessageAsync(cmd, CancellationToken.None);
if (sendResult.Success)
{
break;
}
await Task.Delay(1000);
await Task.Delay(2000);
}
}
}

View File

@ -52,6 +52,12 @@
"EnableCors": true,
"AllowedOrigins": ["*"]
},
"ThingApiService":{
"ApiServerUrl": "http://192.168.81.22",
"LoginCode": "admin",
"LoginKey": "Thing@123",
"EsAuthorization": "admin:uino",
},
"CommunicationFramework": {
"Port": 7110,
"WorkerThreads": 4,