Application settings change
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Config": {
|
||||
"Modbus.Net": {
|
||||
"ModbusPort": "502"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,13 @@ namespace MachineJob
|
||||
{
|
||||
public class DatabaseWriteContext : DbContext
|
||||
{
|
||||
static readonly string connectionString = new ConfigurationBuilder().AddJsonFile($"appsettings.json").Build().GetConnectionString("DatabaseWriteConnectionString")!;
|
||||
private static readonly IConfigurationRoot configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
|
||||
.Build();
|
||||
|
||||
private static readonly string connectionString = configuration.GetConnectionString("DatabaseWriteConnectionString")!;
|
||||
|
||||
public DbSet<DatabaseWriteEntity> DatabaseWrites { get; set; }
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace MachineJob.Service
|
||||
new AddressUnit() { Area = "DB1", Address = 18, DataType = typeof(short), Id = "10", Name = "Test10" }
|
||||
};
|
||||
|
||||
IMachine<string> machine = new ModbusMachine<string, string>("ModbusMachine1", ModbusType.Tcp, "192.168.0.161", _addresses, true, 1, 2, Endian.BigEndianLsb);
|
||||
IMachine<string> machine2 = new SiemensMachine<string, string>("SiemensMachine1", SiemensType.Tcp, "192.168.0.161", SiemensMachineModel.S7_1200, _addresses2, true, 1, 2);
|
||||
IMachine<string> machine = new ModbusMachine<string, string>("ModbusMachine1", ModbusType.Tcp, null, _addresses, true, 1, 2, Endian.BigEndianLsb);
|
||||
IMachine<string> machine2 = new SiemensMachine<string, string>("SiemensMachine1", SiemensType.Tcp, null, SiemensMachineModel.S7_1200, _addresses2, true, 1, 2);
|
||||
|
||||
await MachineJobSchedulerCreator.CreateScheduler("Trigger1", -1, 10).Result.From(machine.Id, machine, MachineDataType.Name).Result.Query(machine.Id + ".ConsoleQuery", QueryConsole).Result.To(machine.Id + ".To", machine).Result.Deal(machine.Id + ".Deal", OnSuccess, OnFailure).Result.Run();
|
||||
Thread.Sleep(5000);
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
"ConnectionStrings": {
|
||||
"DatabaseWriteConnectionString": "Server=localhost; User ID=root; Password=123456; Database=modbusnettest;"
|
||||
},
|
||||
"Config": {
|
||||
"FetchSleepTime": "100"
|
||||
"Modbus.Net": {
|
||||
"FetchSleepTime": "100",
|
||||
"IP": "192.168.8.210",
|
||||
"IPConnectionTimeout": "5000",
|
||||
"ModbusPort": "502",
|
||||
"SiemensPort": "102"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user