Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename enabled to isarConnected #1489

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
SerialNumber = "GetNextRun",
RobotType = RobotType.Robot,
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallationCode = installationCode,
Expand Down Expand Up @@ -506,7 +506,7 @@ public async Task GetNextRun()
SerialNumber = "GetNextRun",
RobotType = RobotType.Robot,
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
Expand Down Expand Up @@ -689,7 +689,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
SerialNumber = "GetNextRun",
RobotType = RobotType.Robot,
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallationCode = otherInstallation.InstallationCode,
Expand Down Expand Up @@ -757,7 +757,7 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
SerialNumber = "GetMissionFailsIfRobotIsNotInSameDeckAsMission",
RobotType = RobotType.Robot,
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
Expand Down
2 changes: 1 addition & 1 deletion backend/api.test/Client/RobotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
SerialNumber = "GetNextRun",
RobotType = RobotType.Robot,
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallationCode = wrongInstallation.InstallationCode,
Expand Down
2 changes: 1 addition & 1 deletion backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task<Robot> NewRobot(RobotStatus status, Installation installation,
VideoStreams = new List<CreateVideoStreamQuery>(),
Host = "localhost",
Port = 3000,
Enabled = true,
IsarConnected = true,
Status = status
};

Expand Down
2 changes: 1 addition & 1 deletion backend/api.test/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task Create()
RobotType = RobotType.Robot,
Host = "",
Port = 1,
Enabled = true,
IsarConnected = true,
Status = RobotStatus.Available
};

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/Models/CreateRobotQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct CreateRobotQuery

public int Port { get; set; }

public bool Enabled { get; set; }
public bool IsarConnected { get; set; }

public RobotStatus Status { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions backend/api/Controllers/Models/RobotResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class RobotResponse

public int Port { get; set; }

public bool Enabled { get; set; }
public bool IsarConnected { get; set; }

public bool MissionQueueFrozen { get; set; }

Expand Down Expand Up @@ -59,7 +59,7 @@ public RobotResponse(Robot robot)
VideoStreams = robot.VideoStreams;
Host = robot.Host;
Port = robot.Port;
Enabled = robot.Enabled;
IsarConnected = robot.IsarConnected;
MissionQueueFrozen = robot.MissionQueueFrozen;
Status = robot.Status;
Pose = robot.Pose;
Expand Down
8 changes: 4 additions & 4 deletions backend/api/Controllers/RobotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public async Task<ActionResult> StopMission([FromRoute] string robotId)
{
const string Message = "Error connecting to ISAR while stopping mission";
logger.LogError(e, "{Message}", Message);
await robotService.SetRobotOffline(robot.Id);
await robotService.SetRobotToIsarDisconnected(robot.Id);
return StatusCode(StatusCodes.Status502BadGateway, Message);
}
catch (MissionException e)
Expand Down Expand Up @@ -487,7 +487,7 @@ public async Task<ActionResult> PauseMission([FromRoute] string robotId)
{
const string Message = "Error connecting to ISAR while pausing mission";
logger.LogError(e, "{Message}", Message);
await robotService.SetRobotOffline(robot.Id);
await robotService.SetRobotToIsarDisconnected(robot.Id);
return StatusCode(StatusCodes.Status502BadGateway, Message);
}
catch (MissionException e)
Expand Down Expand Up @@ -537,7 +537,7 @@ public async Task<ActionResult> ResumeMission([FromRoute] string robotId)
{
const string Message = "Error connecting to ISAR while resuming mission";
logger.LogError(e, "{Message}", Message);
await robotService.SetRobotOffline(robot.Id);
await robotService.SetRobotToIsarDisconnected(robot.Id);
return StatusCode(StatusCodes.Status502BadGateway, Message);
}
catch (MissionException e)
Expand Down Expand Up @@ -595,7 +595,7 @@ [FromRoute] string armPosition
{
string errorMessage = $"Error connecting to ISAR at {robot.IsarUri}";
logger.LogError(e, "{Message}", errorMessage);
await robotService.SetRobotOffline(robot.Id);
await robotService.SetRobotToIsarDisconnected(robot.Id);
return StatusCode(StatusCodes.Status502BadGateway, errorMessage);
}
catch (MissionException e)
Expand Down
6 changes: 3 additions & 3 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private static List<Robot> GetRobots()
Name = "R2-D2",
SerialNumber = "D2",
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
Expand All @@ -298,7 +298,7 @@ private static List<Robot> GetRobots()
IsarId = "c68b679d-308b-460f-9fe0-87eaadbd1234",
SerialNumber = "SS79",
Status = RobotStatus.Busy,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
Expand All @@ -312,7 +312,7 @@ private static List<Robot> GetRobots()
IsarId = "c68b679d-308b-460f-9fe0-87eaadbd5678",
SerialNumber = "Earth616",
Status = RobotStatus.Available,
Enabled = true,
IsarConnected = true,
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
Expand Down
6 changes: 3 additions & 3 deletions backend/api/Database/Models/Robot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Robot()
Name = "defaultId";
SerialNumber = "defaultSerialNumber";
Status = RobotStatus.Offline;
Enabled = false;
IsarConnected = false;
Host = "localhost";
Port = 3000;
Pose = new Pose();
Expand Down Expand Up @@ -41,7 +41,7 @@ public Robot(CreateRobotQuery createQuery, Installation installation, Area? area
VideoStreams = videoStreams;
Host = createQuery.Host;
Port = createQuery.Port;
Enabled = createQuery.Enabled;
IsarConnected = createQuery.IsarConnected;
Status = createQuery.Status;
Pose = new Pose();
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public bool IsRobotBatteryLevelHighEnoughToStartMissions()
public int Port { get; set; }

[Required]
public bool Enabled { get; set; }
public bool IsarConnected { get; set; }

[Required]
public bool MissionQueueFrozen { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions backend/api/EventHandlers/IsarConnectionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private async void OnIsarRobotHeartbeat(object? sender, MqttReceivedArgs mqttArg

_isarConnectionTimers[robot.IsarId].Reset();

if (robot.Enabled) { return; }
await RobotService.UpdateRobotEnabled(robot.Id, true);
if (robot.IsarConnected) { return; }
await RobotService.UpdateRobotIsarConnected(robot.Id, true);
}

private void AddTimerForRobot(IsarRobotHeartbeatMessage isarRobotHeartbeat, Robot robot)
Expand Down Expand Up @@ -136,7 +136,7 @@ private async void OnTimeoutEvent(IsarRobotHeartbeatMessage robotHeartbeatMessag
try
{
await RobotService.UpdateRobotStatus(robot.Id, RobotStatus.Offline);
await RobotService.UpdateRobotEnabled(robot.Id, false);
await RobotService.UpdateRobotIsarConnected(robot.Id, false);
await RobotService.UpdateCurrentMissionId(robot.Id, null);
}
catch (RobotNotFoundException) { return; }
Expand Down
2 changes: 1 addition & 1 deletion backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private async void OnIsarRobotInfo(object? sender, MqttReceivedArgs mqttArgs)
Host = isarRobotInfo.Host,
Port = isarRobotInfo.Port,
Status = RobotStatus.Available,
Enabled = true
IsarConnected = true
};

var newRobot = await robotService.CreateFromQuery(robotQuery);
Expand Down
Loading
Loading