Add more params to appsettings.json

This commit is contained in:
luosheng
2023-03-21 14:49:00 +08:00
parent b3035d14a9
commit c89869086b
47 changed files with 431 additions and 503 deletions

View File

@@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Modbus.Net\Modbus.Net.Modbus\Modbus.Net.Modbus.csproj" />
<ProjectReference Include="..\..\Modbus.Net\Modbus.Net.Siemens\Modbus.Net.Siemens.csproj" />
<ProjectReference Include="..\..\Modbus.Net\Modbus.Net\Modbus.Net.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,141 +0,0 @@
using Microsoft.Extensions.Logging;
using Modbus.Net;
using Modbus.Net.Modbus;
using Serilog;
using System;
using System.Collections.Generic;
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console()
.CreateLogger();
var loggerFactory = new LoggerFactory()
.AddSerilog(Log.Logger);
LogProvider.SetLogProvider(loggerFactory);
ModbusMachine<int, string> machine = new ModbusMachine<int, string>(1, ModbusType.Rtu, "COM1",
new List<AddressUnit>()
{
new AddressUnit()
{
Id = "1",
Area = "4X",
Address = 1,
Name = "test 1",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "2",
Area = "4X",
Address = 2,
Name = "test 2",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "3",
Area = "4X",
Address = 3,
Name = "test 3",
DataType = typeof(ushort)
},
}, true, 2, 1);
ModbusMachine<int, string> machine2 = new ModbusMachine<int, string>(2, ModbusType.Rtu, "COM1",
new List<AddressUnit>()
{
new AddressUnit()
{
Id = "1",
Area = "4X",
Address = 11,
Name = "test 1",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "2",
Area = "4X",
Address = 12,
Name = "test 2",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "3",
Area = "4X",
Address = 13,
Name = "test 3",
DataType = typeof(ushort)
},
}, true, 3, 1);
ModbusMachine<int, string> machine3 = new ModbusMachine<int, string>(3, ModbusType.Rtu, "COM1",
new List<AddressUnit>()
{
new AddressUnit()
{
Id = "1",
Area = "4X",
Address = 21,
Name = "test 1",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "2",
Area = "4X",
Address = 22,
Name = "test 2",
DataType = typeof(ushort)
},
new AddressUnit()
{
Id = "3",
Area = "4X",
Address = 23,
Name = "test 3",
DataType = typeof(ushort)
},
}, true, 4, 1);
Random r = new Random();
await MachineJobSchedulerCreator.CreateScheduler("Trigger1", -1, 10).Result.Apply(machine.Id + ".Apply", null, MachineDataType.Address).Result.Query(machine.Id + ".Query", returnDef =>
{
return new Dictionary<string, double>() {{
"4X 1.0", r.Next() % 65536
},
{
"4X 2.0", r.Next() % 65536
},
{
"4X 3.0", r.Next() % 65536
}
};
}).Result.To(machine.Id + ".To", machine).Result.Deal().Result.Run();
await MachineJobSchedulerCreator.CreateScheduler("Trigger2", -1, 10).Result.Apply(machine2.Id + ".Apply", null, MachineDataType.Address).Result.Query(machine2.Id + ".Query", returnDef =>
{
return new Dictionary<string, double>() {{
"4X 1.0", r.Next() % 65536
},
{
"4X 2.0", r.Next() % 65536
},
{
"4X 3.0", r.Next() % 65536
}
};
}).Result.To(machine2.Id + ".To", machine2).Result.Deal().Result.Run();
await MachineJobSchedulerCreator.CreateScheduler("Trigger3", -1, 10).Result.Apply(machine3.Id + ".Apply", null, MachineDataType.Address).Result.Query(machine3.Id + ".Query", returnDef =>
{
return new Dictionary<string, double>() {{
"4X 1.0", r.Next() % 65536
},
{
"4X 2.0", r.Next() % 65536
},
{
"4X 3.0", r.Next() % 65536
}
};
}).Result.To(machine3.Id + ".To", machine3).Result.Deal().Result.Run();
Console.ReadLine();

View File

@@ -1,8 +0,0 @@
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}

View File

@@ -4,7 +4,6 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>