Compare commits
No commits in common. "43dd5a32e482eead49443863b480c890f4799a72" and "3be81cf517d4dca323011974c485a00affcb5d66" have entirely different histories.
43dd5a32e4
...
3be81cf517
@ -97,9 +97,6 @@ namespace YunDa.Server.ISMSTcp
|
|||||||
|
|
||||||
// 注册 WebApi 配置类
|
// 注册 WebApi 配置类
|
||||||
services.Configure<WebApiSettings>(context.Configuration.GetSection("WebApi"));
|
services.Configure<WebApiSettings>(context.Configuration.GetSection("WebApi"));
|
||||||
|
|
||||||
// 注册 ThingApiService配置
|
|
||||||
services.Configure<ThingApiServiceSettings>(context.Configuration.GetSection("ThingApiService"));
|
|
||||||
})
|
})
|
||||||
.UseSerilog()
|
.UseSerilog()
|
||||||
.UseConsoleLifetime();
|
.UseConsoleLifetime();
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System;
|
using System;
|
||||||
@ -31,15 +30,6 @@ using static System.Net.Mime.MediaTypeNames;
|
|||||||
|
|
||||||
namespace YunDa.Server.ISMSTcp.Services
|
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 class ThingDeviceStatusModel
|
||||||
{
|
{
|
||||||
public string TwinID { get; set; } = string.Empty;
|
public string TwinID { get; set; } = string.Empty;
|
||||||
@ -633,31 +623,16 @@ namespace YunDa.Server.ISMSTcp.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
//推送全体性能数据
|
//推送全体性能数据
|
||||||
|
|
||||||
private int _updateAllSimDatasCnt = 0;
|
|
||||||
private async Task UpdateAllSimDatas()
|
private async Task UpdateAllSimDatas()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*******************推送遥测全体性能数据/*******************/
|
/*******************推送遥测全体性能数据/*******************/
|
||||||
var telemeteringModels = await _telemeteringModelListRedis.HashSetGetAllAsync(_telemeteringModelListRediskey);
|
var telemeteringModels = await _telemeteringModelListRedis.HashSetGetAllAsync(_telemeteringModelListRediskey);
|
||||||
|
await UpdateYCSimDatasStatus(telemeteringModels);
|
||||||
|
|
||||||
|
|
||||||
/*******************推送遥信全体性能数据/*******************/
|
/*******************推送遥信全体性能数据/*******************/
|
||||||
var telesignalisationModels = await _telesignalisationModelListRedis.HashSetGetAllAsync(_telesignalisationModelListRediskey);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//推送遥测性能数据
|
//推送遥测性能数据
|
||||||
@ -1238,36 +1213,14 @@ namespace YunDa.Server.ISMSTcp.Services
|
|||||||
private DateTime _apiTokenTime = DateTime.MinValue;
|
private DateTime _apiTokenTime = DateTime.MinValue;
|
||||||
private readonly SemaphoreSlim _apiTokenSemaphore = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _apiTokenSemaphore = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
private readonly ThingApiServiceSettings _thingApiServiceSettings;
|
|
||||||
|
|
||||||
|
|
||||||
public ThingApiService(
|
public ThingApiService(
|
||||||
ILogger<ThingApiService> logger,
|
ILogger<ThingApiService> logger)
|
||||||
IOptions<ThingApiServiceSettings> thingApiServiceSettings)
|
|
||||||
{
|
{
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_deviceStatusChannel = Channel.CreateUnbounded<List<ThingDeviceStatusModel>>();
|
_deviceStatusChannel = Channel.CreateUnbounded<List<ThingDeviceStatusModel>>();
|
||||||
_alarmDataChannel = Channel.CreateUnbounded<List<TingAlarmPushDataModel>>();
|
_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();
|
StartPushDeviceStatus();
|
||||||
|
|
||||||
StarPushAlarmStatus();
|
StarPushAlarmStatus();
|
||||||
|
|||||||
@ -375,19 +375,7 @@ namespace YunDa.Server.ISMSTcp.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string valStr = "不定";
|
_zzDataCacheContainer.Write(id, value, timestamp, "");
|
||||||
switch((int)value)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
valStr = "报警";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
valStr = "正常";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_zzDataCacheContainer.Write(id, value, timestamp, "", valStr);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -272,14 +272,14 @@ namespace YunDa.Server.ISMSTcp.Services
|
|||||||
{
|
{
|
||||||
string cmd = "CallVAByStat|B001";
|
string cmd = "CallVAByStat|B001";
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
var sendResult = await _zTcpService.SendTcpMessageAsync(cmd, CancellationToken.None);
|
var sendResult = await _zTcpService.SendTcpMessageAsync(cmd, CancellationToken.None);
|
||||||
if (sendResult.Success)
|
if (sendResult.Success)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await Task.Delay(2000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,12 +52,6 @@
|
|||||||
"EnableCors": true,
|
"EnableCors": true,
|
||||||
"AllowedOrigins": ["*"]
|
"AllowedOrigins": ["*"]
|
||||||
},
|
},
|
||||||
"ThingApiService":{
|
|
||||||
"ApiServerUrl": "http://192.168.81.22",
|
|
||||||
"LoginCode": "admin",
|
|
||||||
"LoginKey": "Thing@123",
|
|
||||||
"EsAuthorization": "admin:uino",
|
|
||||||
},
|
|
||||||
"CommunicationFramework": {
|
"CommunicationFramework": {
|
||||||
"Port": 7110,
|
"Port": 7110,
|
||||||
"WorkerThreads": 4,
|
"WorkerThreads": 4,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user