114 lines
3.9 KiB
C#
114 lines
3.9 KiB
C#
![]() |
//using System;
|
|||
|
//using System.Threading.Tasks;
|
|||
|
//using System.Timers;
|
|||
|
//using WebSocket.Model;
|
|||
|
//using Yunda.ISAS.MongoDB.Entities.DataMonitoring;
|
|||
|
|
|||
|
//namespace Yunda.ISAS.DataMonitoringServer.DataAnalysis
|
|||
|
//{
|
|||
|
// public class TestTask
|
|||
|
// {
|
|||
|
// private TestTask()
|
|||
|
// {
|
|||
|
// }
|
|||
|
|
|||
|
// public static TestTask Insatnce { get; } = new TestTask();
|
|||
|
// /// <summary>
|
|||
|
// /// 日志输出时间
|
|||
|
// /// </summary>
|
|||
|
|
|||
|
// //public event LogMessageDelegate LogMessageEvent;
|
|||
|
|
|||
|
// /// <summary>
|
|||
|
// /// 分析定时器
|
|||
|
// /// </summary>
|
|||
|
// private Timer _timer;
|
|||
|
|
|||
|
// private double _testInterval = 5000;
|
|||
|
|
|||
|
// public void TestStart()
|
|||
|
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// if (_timer == null)
|
|||
|
// {
|
|||
|
// _timer = new Timer();
|
|||
|
// _timer.Interval = _testInterval;
|
|||
|
// _timer.Elapsed += TestTimer_Elapsed;
|
|||
|
// }
|
|||
|
// _timer.Start();
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// //LogMessageEvent?.Invoke(new LogMessageEventArgs(ex.Message));
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// public void TestStop()
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// if (_timer == null) return;
|
|||
|
// _timer.Stop();
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// //LogMessageEvent?.Invoke(new LogMessageEventArgs(ex.Message));
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// private void TestTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// TestAlarm();
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// //LogMessageEvent?.Invoke(new LogMessageEventArgs(ex.Message));
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// private async void TestAlarm()
|
|||
|
// {
|
|||
|
// await Task.Run(() =>
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// Random ran = new Random();
|
|||
|
// int alarmLevel = ran.Next(1, 10);
|
|||
|
// //保存报警至MongoDB
|
|||
|
// TeleAlarmResult telemeteringAlarmResult = new TeleAlarmResult()
|
|||
|
// {
|
|||
|
// AlarmStrategyId = Guid.NewGuid(),
|
|||
|
// AlarmLevel = alarmLevel,
|
|||
|
// AlarmName = "报警" + alarmLevel,
|
|||
|
// TelemeteringAlarmTime = DateTime.Now,
|
|||
|
// EquipmentInfoName = "测试风机设备1",//EquipmentInfoId
|
|||
|
// EquipmentInfoId = Guid.Parse("08d7e827-e4a0-4ca7-8bfc-14503c1741d6"),//EquipmentInfoId
|
|||
|
// ResultValue = float.Parse(ran.NextDouble().ToString("f2")),
|
|||
|
// ConfigurationId = Guid.Parse("08d7e9ab-be92-4d67-82e0-3db9e8b9cabb"),
|
|||
|
// TelemeteringName = "遥测测试温度",
|
|||
|
// //TransformerSubstationId = MonitoringDataService.ServiceConfig.DefaultConfig.SubstationId,
|
|||
|
// //SubstationName = MonitoringDataService.ServiceConfig.DefaultConfig.SubstationName,
|
|||
|
// };
|
|||
|
// MonitoringDataService.SingleInstance.Repository.TelemeteringAlarmResultRepository.InsertOne(telemeteringAlarmResult);
|
|||
|
// //发送报警至客户端
|
|||
|
// MessageModel messageModel = new MessageModel()
|
|||
|
// {
|
|||
|
// Content = telemeteringAlarmResult,
|
|||
|
// GroupType = GroupTypeEnum.All,
|
|||
|
// MessageType = MessgeTypeEnum.Alarm,
|
|||
|
// };
|
|||
|
|
|||
|
// MonitoringDataService.SingleInstance.SendMsg(messageModel);
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// //LogMessageEvent?.Invoke(new LogMessageEventArgs(ex.Message));
|
|||
|
// }
|
|||
|
// }).ConfigureAwait(false);
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|