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

Add link to robot documentation from robot page #1725

Merged
merged 3 commits into from
Sep 13, 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
12 changes: 8 additions & 4 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
CurrentInstallationCode = installationCode,
CurrentAreaName = null,
RobotCapabilities = [],
VideoStreams = new List<CreateVideoStreamQuery>()
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};

string robotUrl = "/robots";
Expand Down Expand Up @@ -547,7 +548,8 @@ public async Task GetNextRun()
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = areaName,
RobotCapabilities = [],
VideoStreams = new List<CreateVideoStreamQuery>()
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};

string robotUrl = "/robots";
Expand Down Expand Up @@ -729,7 +731,8 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
CurrentInstallationCode = otherInstallation.InstallationCode,
CurrentAreaName = null,
RobotCapabilities = [],
VideoStreams = new List<CreateVideoStreamQuery>()
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};

string robotUrl = "/robots";
Expand Down Expand Up @@ -800,7 +803,8 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = area1.AreaName,
RobotCapabilities = [],
VideoStreams = new List<CreateVideoStreamQuery>()
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};

string robotUrl = "/robots";
Expand Down
1 change: 1 addition & 0 deletions backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public async Task<Robot> NewRobot(RobotStatus status, Installation installation,
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = area?.Name,
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>(),
Host = "localhost",
Port = 3000,
Status = status,
Expand Down
9 changes: 9 additions & 0 deletions backend/api.test/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public async Task Create()
Url = "localhost:5000",
Type = "mjpeg"
};
var documentationQuery = new CreateDocumentationQuery
{
Name = "Some document",
Url = "someURL",
};
var robotQuery = new CreateRobotQuery
{
Name = "",
Expand All @@ -103,6 +108,10 @@ public async Task Create()
{
videoStreamQuery
},
Documentation = new List<CreateDocumentationQuery>
{
documentationQuery
},
CurrentInstallationCode = installation.InstallationCode,
RobotType = RobotType.Robot,
Host = "",
Expand Down
13 changes: 13 additions & 0 deletions backend/api/Controllers/Models/CreateDocumentationQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;

namespace Api.Controllers.Models
{
public struct CreateDocumentationQuery
{
[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("url")]
public string Url { get; set; }
}
}
2 changes: 2 additions & 0 deletions backend/api/Controllers/Models/CreateRobotQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public struct CreateRobotQuery

public string? CurrentAreaName { get; set; }

public IList<CreateDocumentationQuery> Documentation { get; set; }

public IList<CreateVideoStreamQuery> VideoStreams { get; set; }

public string Host { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions backend/api/Controllers/Models/RobotResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class RobotResponse

public float? PressureLevel { get; set; }

public IList<DocumentInfo> Documentation { get; set; }

public IList<VideoStream> VideoStreams { get; set; }

public string Host { get; set; }
Expand Down Expand Up @@ -60,6 +62,7 @@ public RobotResponse(Robot robot)
CurrentArea = robot.CurrentArea != null ? new AreaResponse(robot.CurrentArea) : null;
BatteryLevel = robot.BatteryLevel;
PressureLevel = robot.PressureLevel;
Documentation = robot.Documentation;
VideoStreams = robot.VideoStreams;
Host = robot.Host;
Port = robot.Port;
Expand Down
3 changes: 3 additions & 0 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ private static List<Robot> GetRobots()
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = new List<VideoStream>(),
Documentation = new List<DocumentInfo>(),
Pose = new Pose()
};

Expand All @@ -299,6 +300,7 @@ private static List<Robot> GetRobots()
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = new List<VideoStream>(),
Documentation = new List<DocumentInfo>(),
Pose = new Pose()
};

Expand All @@ -312,6 +314,7 @@ private static List<Robot> GetRobots()
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = new List<VideoStream>(),
Documentation = new List<DocumentInfo>(),
Pose = new Pose()
};

Expand Down
23 changes: 23 additions & 0 deletions backend/api/Database/Models/DocumentInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

#pragma warning disable CS8618
namespace Api.Database.Models
{
[Owned]
public class DocumentInfo
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }

[Required]
[MaxLength(200)]
public string Name { get; set; }

[Required]
[MaxLength(200)]
public string Url { get; set; }
}
}
15 changes: 15 additions & 0 deletions backend/api/Database/Models/Robot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Robot
{
public Robot()
{
Documentation = new List<DocumentInfo>();
VideoStreams = new List<VideoStream>();
IsarId = "defaultIsarId";
Name = "defaultId";
Expand All @@ -34,11 +35,23 @@ public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel
videoStreams.Add(videoStream);
}

var documentation = new List<DocumentInfo>();
foreach (var documentQuery in createQuery.Documentation)
{
var document = new DocumentInfo
{
Name = documentQuery.Name,
Url = documentQuery.Url
};
documentation.Add(document);
}

IsarId = createQuery.IsarId;
Name = createQuery.Name;
SerialNumber = createQuery.SerialNumber;
CurrentInstallation = installation;
CurrentArea = area;
Documentation = documentation;
VideoStreams = videoStreams;
Host = createQuery.Host;
Port = createQuery.Port;
Expand Down Expand Up @@ -95,6 +108,8 @@ public bool IsRobotBatteryTooLow()
return Model.BatteryWarningThreshold >= BatteryLevel;
}

public IList<DocumentInfo> Documentation { get; set; }

public IList<VideoStream> VideoStreams { get; set; }

[Required]
Expand Down
1 change: 1 addition & 0 deletions backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private async void OnIsarRobotInfo(object? sender, MqttReceivedArgs mqttArgs)
RobotType = isarRobotInfo.RobotType,
SerialNumber = isarRobotInfo.SerialNumber,
CurrentInstallationCode = installation.InstallationCode,
Documentation = isarRobotInfo.DocumentationQueries,
VideoStreams = isarRobotInfo.VideoStreamQueries,
Host = isarRobotInfo.Host,
Port = isarRobotInfo.Port,
Expand Down
3 changes: 3 additions & 0 deletions backend/api/MQTT/MessageModels/IsarRobotInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class IsarRobotInfoMessage : MqttMessage
[JsonPropertyName("robot_asset")]
public string CurrentInstallation { get; set; }

[JsonPropertyName("documentation")]
public List<CreateDocumentationQuery> DocumentationQueries { get; set; }

[JsonPropertyName("video_streams")]
public List<CreateVideoStreamQuery> VideoStreamQueries { get; set; }

Expand Down
Loading
Loading