Deleted unnecessary project

This commit is contained in:
KharchenkoVV 2021-05-11 15:36:16 +05:00
parent 7d8974a8e5
commit e1a72db780
6 changed files with 1 additions and 298 deletions

View File

@ -13,9 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp1", "ConsoleApp1\
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsbCloudDb", "AsbCloudDb\AsbCloudDb.csproj", "{40FBD29B-724B-4496-B5D9-1A5D14102456}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsbCloudDb", "AsbCloudDb\AsbCloudDb.csproj", "{40FBD29B-724B-4496-B5D9-1A5D14102456}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SaubPanelOnlineSender", "SaubPanelOnlineSender\SaubPanelOnlineSender.csproj", "{B156D582-4D32-4368-A103-687D15B9846C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SyncDicts", "SyncDicts\SyncDicts.csproj", "{39DA5EFF-D018-45AE-B0A0-A241B488660F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyncDicts", "SyncDicts\SyncDicts.csproj", "{39DA5EFF-D018-45AE-B0A0-A241B488660F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -43,10 +41,6 @@ Global
{40FBD29B-724B-4496-B5D9-1A5D14102456}.Debug|Any CPU.Build.0 = Debug|Any CPU {40FBD29B-724B-4496-B5D9-1A5D14102456}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40FBD29B-724B-4496-B5D9-1A5D14102456}.Release|Any CPU.ActiveCfg = Release|Any CPU {40FBD29B-724B-4496-B5D9-1A5D14102456}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40FBD29B-724B-4496-B5D9-1A5D14102456}.Release|Any CPU.Build.0 = Release|Any CPU {40FBD29B-724B-4496-B5D9-1A5D14102456}.Release|Any CPU.Build.0 = Release|Any CPU
{B156D582-4D32-4368-A103-687D15B9846C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B156D582-4D32-4368-A103-687D15B9846C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B156D582-4D32-4368-A103-687D15B9846C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B156D582-4D32-4368-A103-687D15B9846C}.Release|Any CPU.Build.0 = Release|Any CPU
{39DA5EFF-D018-45AE-B0A0-A241B488660F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {39DA5EFF-D018-45AE-B0A0-A241B488660F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39DA5EFF-D018-45AE-B0A0-A241B488660F}.Debug|Any CPU.Build.0 = Debug|Any CPU {39DA5EFF-D018-45AE-B0A0-A241B488660F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39DA5EFF-D018-45AE-B0A0-A241B488660F}.Release|Any CPU.ActiveCfg = Release|Any CPU {39DA5EFF-D018-45AE-B0A0-A241B488660F}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -1,51 +0,0 @@
using AsbCloudApp.Data;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace SaubPanelOnlineSender
{
public class CloudDataSender
{
public CloudDataSender() { }
public string OnlineUrl => "http://localhost:5000/api/telemetry/0A:00:27:00:11:12/data";
public void Send(DataSaubBaseDto data)
{
var request = MakeRequest();
using var streamWriter = request.GetRequestStream();
var requestBodyJson = MakeRequestBody(data);
var dataBytes = Encoding.UTF8.GetBytes(requestBodyJson);
streamWriter.Write(dataBytes, 0, dataBytes.Length);
var response = request.GetResponse();
streamWriter.Close();
}
private HttpWebRequest MakeRequest()
{
var request = WebRequest.CreateHttp(OnlineUrl);
request.Method = "POST";
request.Timeout = 4900;
request.ContentType = "application/json";
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
request.ServicePoint.Expect100Continue = false;
return request;
}
private string MakeRequestBody(DataSaubBaseDto dataSaub)
{
var telemetry = new TelemetryDataDto
{
Date = DateTime.Now,
DataSaub = new List<DataSaubBaseDto> { dataSaub },
HmiVersion = "3.1",
UserName = "online sender",
};
return Newtonsoft.Json.JsonConvert.SerializeObject(telemetry);
}
}
}

View File

@ -1,138 +0,0 @@
using AsbCloudApp.Data;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace SaubPanelOnlineSender
{
public enum DbPlayerServiceState
{
Unaviable,
Stopped,
Paused,
Working
}
public class DbPlayerService
{
public DbPlayerServiceState State
{
get => state;
private set
{
if (state == value)
return;
state = value;
OnStateUpdate?.Invoke(this, EventArgs.Empty);
}
}
public DateTime LastSentDate { get; private set; }
public EventHandler<double> OnProcessUpdate;
public EventHandler<Exception> OnError;
public EventHandler OnStateUpdate;
private CancellationTokenSource cancellationTokenSource;
private DbPlayerServiceState state;
private static readonly Random rnd = new Random((int)DateTime.Now.Ticks);
public void Start()
{
State = DbPlayerServiceState.Working;
cancellationTokenSource = new CancellationTokenSource();
//dataSender = new ModbusDataSender(Host);
Task.Run(async () => await Work(cancellationTokenSource.Token));
}
public void Pause()
{
State = State == DbPlayerServiceState.Paused
? DbPlayerServiceState.Working
: DbPlayerServiceState.Paused;
}
public void Stop()
{
State = DbPlayerServiceState.Stopped;
cancellationTokenSource.Cancel();
}
async Task Work(CancellationToken token)
{
var period = TimeSpan.FromSeconds(1);
DateTime nextTime;
var dataSender = new CloudDataSender();
while (!token.IsCancellationRequested)
{
nextTime = DateTime.Now + period;
if ((State != DbPlayerServiceState.Working)
&& ((State != DbPlayerServiceState.Paused)))
break;
if (State == DbPlayerServiceState.Paused)
{
await Task.Delay(100, token).ConfigureAwait(false);
continue;
}
if (State == DbPlayerServiceState.Working)
{
try
{
dataSender.Send(MakeDataSaubBaseDto());
}
catch (Exception ex)
{
OnError?.Invoke(this, ex);
}
OnProcessUpdate?.Invoke(this, 0);
}
var waitTime = nextTime - DateTime.Now;
if (waitTime.TotalMilliseconds > 0)
await Task.Delay(waitTime, token).ConfigureAwait(false);
}
Stop();
}
private static DataSaubBaseDto MakeDataSaubBaseDto()
{
return new DataSaubBaseDto
{
Date = DateTime.Now,
AxialLoad = rnd.NextDouble() * 100d,
AxialLoadLimitMax = rnd.NextDouble() * 100d,
AxialLoadSp = rnd.NextDouble() * 100d,
BitDepth = rnd.NextDouble() * 100d,
BlockPosition = rnd.NextDouble() * 100d,
BlockSpeed = rnd.NextDouble() * 100d,
WellDepth = rnd.NextDouble() * 100d,
BlockSpeedSp = rnd.NextDouble() * 100d,
Flow = rnd.NextDouble() * 100d,
FlowDeltaLimitMax = rnd.NextDouble() * 100d,
FlowIdle = rnd.NextDouble() * 100d,
HookWeight = rnd.NextDouble() * 100d,
HookWeightIdle = rnd.NextDouble() * 100d,
HookWeightLimitMax = rnd.NextDouble() * 100d,
HookWeightLimitMin = rnd.NextDouble() * 100d,
Mode = 1,
Pressure = rnd.NextDouble() * 100d,
PressureDeltaLimitMax = rnd.NextDouble() * 100d,
PressureIdle = rnd.NextDouble() * 100d,
PressureSp = rnd.NextDouble() * 100d,
RotorSpeed = rnd.NextDouble() * 100d,
RotorTorque = rnd.NextDouble() * 100d,
RotorTorqueIdle = rnd.NextDouble() * 100d,
RotorTorqueLimitMax = rnd.NextDouble() * 100d,
RotorTorqueSp = rnd.NextDouble() * 100d,
};
}
}
}

View File

@ -1,88 +0,0 @@
using System;
using System.Threading;
namespace SaubPanelOnlineSender
{
class Program
{
static void Main(/*string[] args*/)
{
Console.Write("player starting\n");
Console.Write("press `Esc` or `Q` to quit\n");
Console.Write("press `p` to pause/unpause\n");
Console.Write("press `s` to stop/start\n");
var playerService = new DbPlayerService();
playerService.OnProcessUpdate =
(s, a) => Console.Write($"Sent: {playerService.LastSentDate:G}\n");
playerService.OnStateUpdate =
(s, a) => Console.Write($"\nState: {playerService.State}\n");
playerService.OnError =
(s, a) =>
{
var color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.Write($"ERROR: {a.Message}");
Console.ForegroundColor = color;
Console.Write("\n");
};
playerService.Start();
if (Console.IsInputRedirected)
{
while (true)
Thread.Sleep(1000);
}
else
{
while (true)
{
if (Console.KeyAvailable)
{
var key = Console.ReadKey().Key;
if ((key == ConsoleKey.Escape) ||
(key == ConsoleKey.Q))
break;
if (key == ConsoleKey.P)
{
switch (playerService.State)
{
case DbPlayerServiceState.Paused:
case DbPlayerServiceState.Working:
playerService.Pause();
break;
case DbPlayerServiceState.Unaviable:
case DbPlayerServiceState.Stopped:
default:
break;
}
}
if (key == ConsoleKey.S)
{
switch (playerService.State)
{
case DbPlayerServiceState.Working:
playerService.Stop();
break;
case DbPlayerServiceState.Stopped:
playerService.Start();
break;
case DbPlayerServiceState.Unaviable:
case DbPlayerServiceState.Paused:
default:
break;
}
}
}
Thread.Sleep(200);
}
}
playerService.Stop();
}
}
}

View File

@ -1,2 +0,0 @@
* Назначение
проект предназначен для иммитации работы панели САУБ для НОВОГО облака.

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AsbCloudApp\AsbCloudApp.csproj" />
</ItemGroup>
</Project>