This commit is contained in:
Đăng Nguyễn
2025-11-04 10:57:41 +07:00
parent 70e27da4a2
commit 73038de662
12 changed files with 226 additions and 84 deletions

View File

@@ -63,8 +63,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
if (config.IsActive) await RobotConfiguration.LoadRobotPlcConfigAsync();
return new(true, "PLC configuration updated successfully.");
}
catch (Exception ex)
@@ -158,8 +156,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
await RobotConfiguration.LoadRobotPlcConfigAsync();
return new(true, $"PLC configuration {config.ConfigName} activated successfully.");
}
catch (Exception ex)
@@ -238,8 +234,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
if (config.IsActive) await RobotConfiguration.LoadVDA5050ConfigAsync();
return new(true, "VDA5050 configuration updated successfully.");
}
catch (Exception ex)
@@ -353,8 +347,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
await RobotConfiguration.LoadVDA5050ConfigAsync();
return new(true, $"VDA5050 configuration {config.ConfigName} activated successfully.");
}
catch (Exception ex)
@@ -417,8 +409,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
if (config.IsActive) await RobotConfiguration.LoadRobotConfigAsync();
return new(true, "Robot configuration updated successfully.");
}
catch (Exception ex)
@@ -516,8 +506,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
await RobotConfiguration.LoadRobotConfigAsync();
return new(true, $"Robot configuration {config.ConfigName} activated successfully.");
}
catch (Exception ex)
@@ -580,8 +568,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
if (config.IsActive) await RobotConfiguration.LoadRobotSimulationConfigAsync();
return new(true, "Simulation configuration updated successfully.");
}
catch (Exception ex)
@@ -679,8 +665,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
await RobotConfiguration.LoadRobotSimulationConfigAsync();
return new(true, $"Simulation configuration {config.ConfigName} activated successfully.");
}
catch (Exception ex)
@@ -746,8 +730,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
if (config.IsActive) await RobotConfiguration.LoadRobotSafetyConfigAsync();
return new(true, "Safety configuration updated successfully.");
}
catch (Exception ex)
@@ -849,8 +831,6 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
config.UpdatedAt = DateTime.Now;
await AppDb.SaveChangesAsync();
await RobotConfiguration.LoadRobotSafetyConfigAsync();
return new(true, $"Safety configuration {config.ConfigName} activated successfully.");
}
catch (Exception ex)
@@ -859,4 +839,20 @@ public class RobotConfigsController(Services.Logger<RobotConfigsController> Logg
return new(false, "An error occurred while updating the active Safety configuration.");
}
}
[HttpPost]
[Route("load")]
public async Task<MessageResult> LoadConfig()
{
try
{
//await RobotConfiguration.LoadVDA5050ConfigAsync();
return new(true, "Robot configuration loaded successfully.");
}
catch (Exception ex)
{
Logger.Error($"Error in Load Robot Config: {ex.Message}");
return new(false, "An error occurred while loading the Robot configuration.");
}
}
}