Ver código fonte

添加项目文件。

林豪 左 2 anos atrás
pai
commit
35740ffa12

+ 25 - 0
测试.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32328.378
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "测试", "测试\测试.csproj", "{AB613AE6-A420-490E-8C84-D80C7341ECFC}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{AB613AE6-A420-490E-8C84-D80C7341ECFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{AB613AE6-A420-490E-8C84-D80C7341ECFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{AB613AE6-A420-490E-8C84-D80C7341ECFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{AB613AE6-A420-490E-8C84-D80C7341ECFC}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {402CA053-9520-4A49-B686-C1B1620F6423}
+	EndGlobalSection
+EndGlobal

+ 10 - 0
测试/Program.cs

@@ -0,0 +1,10 @@
+using 测试;
+
+IHost host = Host.CreateDefaultBuilder(args)
+    .ConfigureServices(services =>
+    {
+        services.AddHostedService<Worker>();
+    })
+    .Build();
+
+await host.RunAsync();

+ 11 - 0
测试/Properties/launchSettings.json

@@ -0,0 +1,11 @@
+{
+  "profiles": {
+    "测试": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "environmentVariables": {
+        "DOTNET_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 90 - 0
测试/Worker.cs

@@ -0,0 +1,90 @@
+using System.Text;
+
+namespace 测试
+{
+    public class Worker : BackgroundService
+    {
+        private readonly ILogger<Worker> _logger;
+
+        public Worker(ILogger<Worker> logger)
+        {
+            _logger = logger;
+        }
+
+        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+        {
+            var a = (693631 - 789931) % 1567770;
+            var c = ((10 - 20) + 100) % 100;
+            var b = (789931 - 693631 + 1567770) % 1567770;
+            var d = (20 - 50 + 100) % 100;
+            var aa = new byte[4] { 73, 41, 87, 96 };
+            var bb = new byte[4] { 96, 87, 41, 73 };
+            var e = BitConverter.ToSingle(bb, 0);
+            while (!stoppingToken.IsCancellationRequested)
+            {
+                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
+                await Task.Delay(1000, stoppingToken);
+            }
+        }
+
+        /// <summary>
+        /// 将字节转换成2进制的单精度浮点数
+        /// </summary>
+        /// <param name="ByteData"></param>
+        /// <returns></returns>
+        public float GetToTwo(byte[] ByteData)
+        {
+            try
+            {
+                int Length = ByteData.Length;
+                string Result = string.Empty;
+                for (int j = 0; j < Length; j++)
+                {
+                    string hexString = ByteData[j].ToString("X2");
+                    hexString = hexString.Replace(" ", "");
+                    if ((hexString.Length % 2) != 0)
+                    {
+                        hexString = hexString.PadRight(hexString.Length + 1);
+                    }
+                    StringBuilder builder = new StringBuilder();
+                    int len = hexString.Length / 2;
+                    for (int i = 0; i < len; i++)
+                    {
+                        string hex = hexString.Substring(i * 2, 2).Trim();
+                        int a = Convert.ToInt32(hex, 16);
+                        string str = Convert.ToString(a, 2).PadLeft(8, '0');
+                        builder = builder.Append(str);
+                    }
+                    Result += builder.ToString();
+                };
+                var b = Result;
+                var c = Convert.ToInt32(Result, 2);
+                return Convert.ToInt32(Result, 2);
+            }
+            catch (Exception ex)
+            {
+                return 400;
+            }
+        }
+
+        public static bool[] Conve(byte[] byt)
+        {
+            int len = byt.Length;
+            bool[] newBit = new bool[len * 4];
+            int MidByt;
+            for (int i = 0; i < len; i++)
+            {
+                MidByt = byt[i];
+                for (int j = 0; j < 4; j++)
+                {
+                    newBit[i * 4 + j] = System.Convert.ToBoolean(MidByt % 2);
+                    MidByt = MidByt / 2;
+                }
+            }
+            foreach (bool a in newBit)
+            {
+            }
+            return newBit;
+        }
+    }
+}

+ 8 - 0
测试/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  }
+}

+ 8 - 0
测试/appsettings.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  }
+}

+ 13 - 0
测试/测试.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk.Worker">
+
+  <PropertyGroup>
+    <TargetFramework>net6.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <UserSecretsId>dotnet-测试-822B07B9-4328-4544-A8A2-1ABB22891172</UserSecretsId>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
+  </ItemGroup>
+</Project>