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

Remove unused video stream object #1869

Merged
merged 3 commits into from
Dec 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
1 change: 0 additions & 1 deletion backend/api.test/Client/RobotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = wrongArea.Name,
VideoStreams = []
};

string robotUrl = "/robots";
Expand Down
1 change: 0 additions & 1 deletion backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public async Task<Robot> NewRobot(RobotStatus status, Installation installation,
SerialNumber = "0001",
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = area?.Name,
VideoStreams = [],
Documentation = [],
Host = "localhost",
Port = 3000,
Expand Down
10 changes: 0 additions & 10 deletions backend/api.test/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ public async Task Create()

var robotsBefore = await robotService.ReadAll(readOnly: true);
int nRobotsBefore = robotsBefore.Count();
var videoStreamQuery = new CreateVideoStreamQuery
{
Name = "Front Camera",
Url = "localhost:5000",
Type = "mjpeg"
};
var documentationQuery = new CreateDocumentationQuery
{
Name = "Some document",
Expand All @@ -108,10 +102,6 @@ public async Task Create()
Name = "",
IsarId = "",
SerialNumber = "",
VideoStreams =
[
videoStreamQuery
],
Documentation =
[
documentationQuery
Expand Down
4 changes: 2 additions & 2 deletions backend/api/Controllers/DeckController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public async Task<ActionResult<IList<DeckResponse>>> GetDecks()
}

/// <summary>
/// List all decks in the Flotilla database
/// List all decks in the specified installation
/// </summary>
/// <remarks>
/// <para> This query gets all decks </para>
/// <para> This query gets all decks in specified installation</para>
/// </remarks>
[HttpGet("installation/{installationCode}")]
[Authorize(Roles = Role.Any)]
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/InspectionFindingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<ActionResult<InspectionFinding>> AddFinding([FromBody] Inspect
}

/// <summary>
/// Get the full inspection against an isarTaskId
/// Get the full inspection for specified isarTaskId
/// </summary>
/// <remarks>
/// </remarks>
Expand Down
2 changes: 0 additions & 2 deletions backend/api/Controllers/Models/CreateRobotQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public struct CreateRobotQuery

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

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

public string Host { get; set; }

public int Port { get; set; }
Expand Down
16 changes: 0 additions & 16 deletions backend/api/Controllers/Models/CreateVideoStreamQuery.cs

This file was deleted.

3 changes: 0 additions & 3 deletions backend/api/Controllers/Models/RobotResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class RobotResponse

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

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

public string Host { get; set; }

public int Port { get; set; }
Expand Down Expand Up @@ -63,7 +61,6 @@ public RobotResponse(Robot robot)
BatteryLevel = robot.BatteryLevel;
PressureLevel = robot.PressureLevel;
Documentation = robot.Documentation;
VideoStreams = robot.VideoStreams;
Host = robot.Host;
Port = robot.Port;
IsarConnected = robot.IsarConnected;
Expand Down
78 changes: 0 additions & 78 deletions backend/api/Controllers/RobotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,84 +373,6 @@ [FromBody] RobotStatus robotStatus
}
}

/// <summary>
/// Get video streams for a given robot
/// </summary>
/// <remarks>
/// <para> Retrieves the video streams available for the given robot </para>
/// </remarks>
[HttpGet]
[Authorize(Roles = Role.User)]
[Route("{robotId}/video-streams/")]
[ProducesResponseType(typeof(IList<VideoStream>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<IList<VideoStream>>> GetVideoStreams([FromRoute] string robotId)
{
var robot = await robotService.ReadById(robotId, readOnly: true);
if (robot == null)
{
logger.LogWarning("Could not find robot with id={Id}", robotId);
return NotFound();
}

return Ok(robot.VideoStreams);
}

/// <summary>
/// Add a video stream to a given robot
/// </summary>
/// <remarks>
/// <para> Adds a provided video stream to the given robot </para>
/// </remarks>
[HttpPost]
[Authorize(Roles = Role.Admin)]
[Route("{robotId}/video-streams/")]
[ProducesResponseType(typeof(RobotResponse), StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<RobotResponse>> CreateVideoStream(
[FromRoute] string robotId,
[FromBody] VideoStream videoStream
)
{
var robot = await robotService.ReadById(robotId, readOnly: true);
if (robot == null)
{
logger.LogWarning("Could not find robot with id={Id}", robotId);
return NotFound();
}

robot.VideoStreams.Add(videoStream);

try
{
var updatedRobot = await robotService.Update(robot);
var robotResponse = new RobotResponse(updatedRobot);

return CreatedAtAction(
nameof(GetVideoStreams),
new
{
robotId = updatedRobot.Id
},
robotResponse
);
}
catch (Exception ex)
{
logger.LogError(ex, "Error adding video stream to robot");
throw;
}
}


/// <summary>
/// Stops the current mission on a robot
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion backend/api/Database/Context/FlotillaDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<MissionRun>().OwnsOne(m => m.Map).OwnsOne(b => b.Boundary);
modelBuilder.Entity<Robot>().OwnsOne(r => r.Pose).OwnsOne(p => p.Orientation);
modelBuilder.Entity<Robot>().OwnsOne(r => r.Pose).OwnsOne(p => p.Position);
modelBuilder.Entity<Robot>().OwnsMany(r => r.VideoStreams);

modelBuilder.Entity<DefaultLocalizationPose>().OwnsOne(d => d.Pose, poseBuilder =>
{
Expand Down
13 changes: 0 additions & 13 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ public static class InitDb
private static readonly List<MissionRun> missionRuns = GetMissionRuns();
private static readonly List<AccessRole> accessRoles = GetAccessRoles();

private static VideoStream VideoStream =>
new()
{
Name = "Front camera",
Url = "http://localhost:5000/stream?topic=/camera/rgb/image_raw",
Type = "mjpeg"
};

private static List<Inspection> GetInspections()
{
var inspection1 = new Inspection
Expand Down Expand Up @@ -313,7 +305,6 @@ private static List<Robot> GetRobots()
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = [],
Documentation = [],
Pose = new Pose()
};
Expand All @@ -327,7 +318,6 @@ private static List<Robot> GetRobots()
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = [],
Documentation = [],
Pose = new Pose()
};
Expand All @@ -341,7 +331,6 @@ private static List<Robot> GetRobots()
Host = "localhost",
Port = 3000,
CurrentInstallation = installations[0],
VideoStreams = [],
Documentation = [],
Pose = new Pose()
};
Expand Down Expand Up @@ -692,8 +681,6 @@ public static void PopulateDb(FlotillaDbContext context)
context.AddRange(inspections);
context.AddRange(installations);
AddRobotModelsToContext(context);
foreach (var robot in robots)
robot.VideoStreams.Add(VideoStream);
context.SaveChanges();
var models = context.RobotModels.AsTracking().AsEnumerable().ToList();
robots[0].Model = models.Find(model => model.Type == RobotType.TaurobInspector)!;
Expand Down
16 changes: 0 additions & 16 deletions backend/api/Database/Models/Robot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class Robot
public Robot()
{
Documentation = [];
VideoStreams = [];
IsarId = "defaultIsarId";
Name = "defaultId";
SerialNumber = "defaultSerialNumber";
Expand All @@ -23,18 +22,6 @@ public Robot()

public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel model, Area? area = null)
{
var videoStreams = new List<VideoStream>();
foreach (var videoStreamQuery in createQuery.VideoStreams)
{
var videoStream = new VideoStream
{
Name = videoStreamQuery.Name,
Url = videoStreamQuery.Url,
Type = videoStreamQuery.Type
};
videoStreams.Add(videoStream);
}

var documentation = new List<DocumentInfo>();
foreach (var documentQuery in createQuery.Documentation)
{
Expand All @@ -52,7 +39,6 @@ public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel
CurrentInstallation = installation;
CurrentArea = area;
Documentation = documentation;
VideoStreams = videoStreams;
Host = createQuery.Host;
Port = createQuery.Port;
IsarConnected = true;
Expand Down Expand Up @@ -117,8 +103,6 @@ public bool IsRobotReadyToStartMissions()

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

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

[Required]
[MaxLength(200)]
public string Host { get; set; }
Expand Down
71 changes: 0 additions & 71 deletions backend/api/Database/Models/VideoStream.cs

This file was deleted.

Loading
Loading