Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename enabled to isarConnected
Browse files Browse the repository at this point in the history
Eddasol committed Mar 22, 2024
1 parent 06d10c7 commit 94154d9
Showing 18 changed files with 1,413 additions and 40 deletions.
8 changes: 4 additions & 4 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
@@ -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,
@@ -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,
@@ -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,
@@ -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,
2 changes: 1 addition & 1 deletion backend/api.test/Client/RobotTests.cs
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
@@ -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
};

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

2 changes: 1 addition & 1 deletion backend/api/Controllers/Models/CreateRobotQuery.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
4 changes: 2 additions & 2 deletions backend/api/Controllers/Models/RobotResponse.cs
Original file line number Diff line number Diff line change
@@ -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; }

@@ -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;
8 changes: 4 additions & 4 deletions backend/api/Controllers/RobotController.cs
Original file line number Diff line number Diff line change
@@ -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)
@@ -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)
@@ -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)
@@ -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)
6 changes: 3 additions & 3 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
@@ -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],
@@ -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],
@@ -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],
6 changes: 3 additions & 3 deletions backend/api/Database/Models/Robot.cs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public Robot()
Name = "defaultId";
SerialNumber = "defaultSerialNumber";
Status = RobotStatus.Offline;
Enabled = false;
IsarConnected = false;
Host = "localhost";
Port = 3000;
Pose = new Pose();
@@ -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();
}
@@ -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; }
6 changes: 3 additions & 3 deletions backend/api/EventHandlers/IsarConnectionEventHandler.cs
Original file line number Diff line number Diff line change
@@ -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)
@@ -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; }
2 changes: 1 addition & 1 deletion backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
@@ -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);
Loading

0 comments on commit 94154d9

Please sign in to comment.