Skip to content

Commit

Permalink
Merge pull request #88 from 5G-ERA/AL/EndpointsDashboard_Middleware
Browse files Browse the repository at this point in the history
Al/endpoints dashboard middleware
  • Loading branch information
Artonus authored Jan 18, 2023
2 parents 1954271 + 3726dfa commit 161782f
Show file tree
Hide file tree
Showing 26 changed files with 1,508 additions and 148 deletions.
10 changes: 10 additions & 0 deletions src/Common/ExtensionMethods/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ public static string SanitizeAsK8SYaml(this string str)
{
return str.Replace("\\n", "\n");
}

public static string TrimSuffix(this string s, string suffix)
{
if (s.EndsWith(suffix))
{
return s.Substring(0, s.Length - suffix.Length);
}

return s;
}
}
6 changes: 6 additions & 0 deletions src/Common/Models/GraphEntityModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public GraphEntityModel(Guid id, RedisDbIndexEnum dbIndex)
Id = id;
Type = dbIndex.ToString().ToUpper();
}
public GraphEntityModel(Guid id, string name, string type)
{
Id = id;
Name = name;
Type = type;
}

public GraphEntityModel(Guid id, string name, Type type)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Common/Models/InstanceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class InstanceModel : BaseModel
[JsonPropertyName("MinimumNumCores")]
public int MinimumNumCores { get; set; } // Compulsory field

[JsonPropertyName("OnboardedTime")]
public DateTime OnboardedTime { get; set; } // Compulsory field

/// <summary>
/// Onboarding validation of the instance data object.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Common/Models/RobotModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public class RobotModel : BaseModel
[JsonPropertyName("LastUpdatedTime")]
public DateTime LastUpdatedTime { get; set; }

[JsonPropertyName("OnboardedTime")]
public DateTime OnboardedTime { get; set; }

/// <summary>
/// Onboarding validation of the robot data object.
/// </summary>
Expand Down Expand Up @@ -191,4 +194,5 @@ public RosTopicModel GetTopicModelFromRobot(string topicName)
{
return GetAllRobotTopics().Where(t => t.Name == topicName).FirstOrDefault();
}

}
21 changes: 16 additions & 5 deletions src/Common/Models/TaskPlannerInputModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using System.Text.Json.Serialization;

namespace Middleware.Common.Models
{
Expand All @@ -8,8 +9,10 @@ public class TaskPlannerInputModel
public Guid RobotId { get; set; }

[JsonPropertyName("LockResourceReUse")]
public bool LockResourceReUse { get; set; }

public bool LockResourceReUse { get; set; } //TODO: check only the instances that are avialable in the local middleware
/// <summary>
/// only change the instance placement in the existing plan during a replan
/// </summary>
[JsonPropertyName("ReplanActionPlannerLocked")]
public bool ReplanActionPlannerLocked { get; set; }

Expand All @@ -18,11 +21,19 @@ public class TaskPlannerInputModel

[JsonPropertyName("TaskDescription")]
public String TaskDescription { get; set; }


/// <summary>
/// Use the hardcoded action plan if true, use the semantic planning if false
/// </summary>
[JsonPropertyName("ContextKnown")]
public bool ContextKnown { get; set; }
public bool ContextKnown { get; set; } = true;

[JsonPropertyName("Questions")]
public List<DialogueModel> Questions { get; set; }

public bool IsValid()
{
return RobotId != Guid.Empty && Id != Guid.Empty;
}
}
}
2 changes: 2 additions & 0 deletions src/Common/Repositories/Abstract/IBaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ public interface IBaseRepository<T> where T : class
Task<bool> DeleteGraphModelAsync(GraphEntityModel model);

Task<bool> DeleteRelationAsync(RelationModel relation);

Task<Dictionary<string, List<RedisGraphResult>>> GetAllRelations();
}
13 changes: 13 additions & 0 deletions src/Common/Repositories/BaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,19 @@ public virtual async Task<bool> AddGraphAsync(GraphEntityModel model)
return resultSet != null && resultSet.Metrics.NodesCreated == 1;
}

/// <summary>
/// Return all RelationModels to recreate the graph.
/// </summary>
/// <returns></returns>
public virtual async Task<Dictionary<string, List<RedisGraphResult>>> GetAllRelations()
{
string query = "MATCH (n) OPTIONAL MATCH (n)-[r]-(m) RETURN n, type(r) as r, m";
ResultSet resultSet = await RedisGraph.Query(GraphName, query);

return resultSet?.Results;

}

/// <summary>
/// Creating a new relation between two models
/// </summary>
Expand Down
57 changes: 50 additions & 7 deletions src/Orchestrator/OrchestratorSpec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@
"RobotId": {
"type": "string",
"format": "uuid"
},
"TaskStartedAt": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
Expand All @@ -1044,14 +1048,14 @@
"type": "string",
"nullable": true
},
"dof": {
"number": {
"type": "integer",
"format": "int32"
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ROSNodeModel"
"type": "string"
},
"nullable": true
}
Expand All @@ -1073,6 +1077,10 @@
"type": "string",
"format": "date-time",
"readOnly": true
},
"isError": {
"type": "boolean",
"readOnly": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1212,6 +1220,10 @@
"MinimumNumCores": {
"type": "integer",
"format": "int32"
},
"OnboardedTime": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1367,6 +1379,30 @@
"type": "string",
"nullable": true
},
"RosVersion": {
"type": "integer",
"format": "int32"
},
"RosDistro": {
"type": "string",
"nullable": true
},
"MaximumPayload": {
"type": "integer",
"format": "int64"
},
"MaximumTranslationalVelocity": {
"type": "integer",
"format": "int64"
},
"MaximumRotationalVelocity": {
"type": "integer",
"format": "int64"
},
"RobotWeight": {
"type": "integer",
"format": "int64"
},
"ROSRepo": {
"type": "string",
"format": "uri",
Expand Down Expand Up @@ -1396,7 +1432,7 @@
"type": "string",
"nullable": true
},
"CurrentTaskID": {
"currentTaskId": {
"type": "string",
"format": "uuid"
},
Expand Down Expand Up @@ -1452,10 +1488,6 @@
"type": "integer",
"format": "int64"
},
"VirtualRam": {
"type": "integer",
"format": "int64"
},
"StorageDisk": {
"type": "integer",
"format": "int64"
Expand All @@ -1470,6 +1502,14 @@
"$ref": "#/components/schemas/DialogueModel"
},
"nullable": true
},
"LastUpdatedTime": {
"type": "string",
"format": "date-time"
},
"OnboardedTime": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1575,6 +1615,9 @@
"description": {
"type": "string",
"nullable": true
},
"enabled": {
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
Loading

0 comments on commit 161782f

Please sign in to comment.