Skip to content

Commit e8d092a

Browse files
authored
Database hotfix (#19)
* Added Emergency Stop Controller. Base structure. Needs function setup. * redis imports removed from Program.cs Emergency Stop Edited README appended * minimal changes to Emergency Stop Controller swagger comments removed from Program.cs
1 parent 7c3ef4b commit e8d092a

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using StackExchange.Redis;
3+
4+
namespace Database.Controllers;
5+
6+
[ApiController]
7+
[Route("api/EmergencyStop")]
8+
9+
// // Name file endpoint name + Controller
10+
public class EmergencyStopController : ControllerBase
11+
{
12+
13+
[HttpPost(Name = "PostEmergencyStop")]
14+
public async Task PostEmergencyStop(){
15+
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("local:redis:6379");
16+
IDatabase gcs = redis.GetDatabase();
17+
gcs.StringSet("EmergencyStop", "true");
18+
}
19+
20+
21+
// [HttpGet]
22+
23+
// [HttpPost]
24+
}

Program.cs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
using NRedisStack;
2-
using NRedisStack.RedisStackCommands;
3-
using NRedisStack.Search;
4-
using NRedisStack.Search.Aggregation;
5-
using NRedisStack.Search.Literals.Enums;
61
using StackExchange.Redis;
72

8-
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379");
9-
10-
var db = redis.GetDatabase();
11-
var ft = db.FT();
12-
var json = db.JSON();
13-
14-
var UGV_tel = new {
15-
xPos = 69.6969,
16-
yPos = 120.473,
17-
manual = false,
18-
misc = "etc"
19-
};
20-
213

224
//json.Set("UGV_[timestamp]", "$", UGV_tel);
235
//Console.WriteLine(json.Get("UGV_[timestamp]")); // prints json
@@ -27,9 +9,8 @@
279
// Add services to the container.
2810

2911
builder.Services.AddControllers();
30-
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
12+
3113
builder.Services.AddEndpointsApiExplorer();
32-
//builder.Services.AddSwaggerGen();
3314

3415
var app = builder.Build();
3516

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ This is the primary codebase for the GCS database and its API.
2222
10. Open Redis Commander and log in to access DB on the browser
2323
10a. The Login Information for Redis Commander to see database information is under `.env`
2424
11. You should now see the string with the last number sent using the js script
25+
26+
For Docket Setup:
27+
1. create .env file if it doesn't alrady exist.
28+
2. enter the following line into the CLI: docker-compose up --detach
29+
3. dotnet run
30+
4. Open Redis Commander and log in

0 commit comments

Comments
 (0)