first commit -push
This commit is contained in:
3
RobotNet.Script.Shares/CreateModel.cs
Normal file
3
RobotNet.Script.Shares/CreateModel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record CreateModel(string Path, string Name);
|
||||
23
RobotNet.Script.Shares/Dashboard/DailyMissionDto.cs
Normal file
23
RobotNet.Script.Shares/Dashboard/DailyMissionDto.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RobotNet.Script.Shares.Dashboard;
|
||||
|
||||
public class DailyMissionDto
|
||||
{
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Completed { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Error { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Total { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int CompletedRate { get; set; }
|
||||
[Range(0, double.MaxValue)]
|
||||
public double TaktTimeMin { get; set; }
|
||||
[Range(0, double.MaxValue)]
|
||||
public double TaktTimeAverage { get; set; }
|
||||
[Range(0, double.MaxValue)]
|
||||
public double TaktTimeMax { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int RobotOnline { get; set; }
|
||||
}
|
||||
14
RobotNet.Script.Shares/Dashboard/DailyPerformanceDto.cs
Normal file
14
RobotNet.Script.Shares/Dashboard/DailyPerformanceDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RobotNet.Script.Shares.Dashboard;
|
||||
|
||||
public class DailyPerformanceDto
|
||||
{
|
||||
public string Label { get; set; } = string.Empty;
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Completed { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Error { get; set; }
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Other { get; set; }
|
||||
}
|
||||
11
RobotNet.Script.Shares/Dashboard/DashboardDto.cs
Normal file
11
RobotNet.Script.Shares/Dashboard/DashboardDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace RobotNet.Script.Shares.Dashboard;
|
||||
|
||||
public class DashboardDto
|
||||
{
|
||||
public string TimeUpdate { get; set; } = DateTime.Now.ToString("dd/MM/yyy HH:mm:ss");
|
||||
public DailyMissionDto DailyMission { get; set; } = new ();
|
||||
public DailyPerformanceDto TodayPerformance { get; set; } = new();
|
||||
public DailyPerformanceDto ThisWeekPerformance { get; set; } = new();
|
||||
public TaktTimeMissionDto[] TaktTimeMissions { get; set; } = [];
|
||||
public DailyPerformanceDto[] TotalMissionPerformance { get; set; } = [];
|
||||
}
|
||||
14
RobotNet.Script.Shares/Dashboard/TaktTimeMissionDto.cs
Normal file
14
RobotNet.Script.Shares/Dashboard/TaktTimeMissionDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RobotNet.Script.Shares.Dashboard;
|
||||
|
||||
public class TaktTimeMissionDto
|
||||
{
|
||||
public string Label { get; set; } = string.Empty;
|
||||
[Range(0, double.MaxValue)]
|
||||
public double Min { get; set; }
|
||||
[Range(0, double.MaxValue)]
|
||||
public double Max { get; set; }
|
||||
[Range(0, double.MaxValue)]
|
||||
public double Average { get; set; }
|
||||
}
|
||||
16
RobotNet.Script.Shares/IRobotNetGlobals.cs
Normal file
16
RobotNet.Script.Shares/IRobotNetGlobals.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public interface IRobotNetGlobals
|
||||
{
|
||||
Guid CurrentMissionId { get; }
|
||||
RobotNet.Script.ILogger Logger { get; }
|
||||
RobotNet.Script.IRobotManager RobotManager { get; }
|
||||
RobotNet.Script.IMapManager MapManager { get; }
|
||||
RobotNet.Script.IUnixDevice UnixDevice { get; }
|
||||
RobotNet.Script.IConnectionManager ConnectionManager { get; }
|
||||
Task<Guid> CreateMission(string name);
|
||||
Task<Guid> CreateMission(string name, params object[] parameters);
|
||||
bool CancelMission(Guid missionId, string reason);
|
||||
bool EnableTask(string name);
|
||||
bool DisableTask(string name);
|
||||
}
|
||||
3
RobotNet.Script.Shares/InstanceMissionCreateModel.cs
Normal file
3
RobotNet.Script.Shares/InstanceMissionCreateModel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record InstanceMissionCreateModel(string Name, IDictionary<string, string> Parameters);
|
||||
11
RobotNet.Script.Shares/InstanceMissionDto.cs
Normal file
11
RobotNet.Script.Shares/InstanceMissionDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public class InstanceMissionDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string MissionName { get; set; } = "";
|
||||
public string Parameters { get; set; } = "{}";
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public MissionStatus Status { get; set; }
|
||||
public string? Log { get; set; }
|
||||
}
|
||||
14
RobotNet.Script.Shares/MissionStatus.cs
Normal file
14
RobotNet.Script.Shares/MissionStatus.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public enum MissionStatus
|
||||
{
|
||||
Idle = 0,
|
||||
Running,
|
||||
Canceling,
|
||||
Pausing,
|
||||
Paused,
|
||||
Resuming,
|
||||
Canceled,
|
||||
Completed,
|
||||
Error,
|
||||
}
|
||||
29
RobotNet.Script.Shares/ProcessorRequest.cs
Normal file
29
RobotNet.Script.Shares/ProcessorRequest.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public enum ProcessorRequest
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Build,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Run,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Stop,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Reset,
|
||||
}
|
||||
44
RobotNet.Script.Shares/ProcessorState.cs
Normal file
44
RobotNet.Script.Shares/ProcessorState.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public enum ProcessorState
|
||||
{
|
||||
/// <summary>
|
||||
/// The processor is idle and not currently processing any scripts.
|
||||
/// </summary>
|
||||
Idle,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Building,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Ready,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Starting,
|
||||
|
||||
/// <summary>
|
||||
/// The processor is currently running a script.
|
||||
/// </summary>
|
||||
Running,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Stopping,
|
||||
|
||||
/// <summary>
|
||||
/// The processor encountered an error while running a script.
|
||||
/// </summary>
|
||||
Error,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
BuildError,
|
||||
}
|
||||
3
RobotNet.Script.Shares/RenameModel.cs
Normal file
3
RobotNet.Script.Shares/RenameModel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record RenameModel(string Path, string NewName);
|
||||
14
RobotNet.Script.Shares/RobotNet.Script.Shares.csproj
Normal file
14
RobotNet.Script.Shares/RobotNet.Script.Shares.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RobotNet.Script\RobotNet.Script.csproj" />
|
||||
<ProjectReference Include="..\RobotNet.Shares\RobotNet.Shares.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
93
RobotNet.Script.Shares/ScriptExtensions.cs
Normal file
93
RobotNet.Script.Shares/ScriptExtensions.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public static class ScriptExtensions
|
||||
{
|
||||
private static readonly string PreCode;
|
||||
|
||||
static ScriptExtensions()
|
||||
{
|
||||
var preCode = "";
|
||||
|
||||
var glovalType = typeof(IRobotNetGlobals);
|
||||
|
||||
var properties = glovalType.GetProperties();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
preCode = string.Join(Environment.NewLine, preCode, ToDeclarationString(property));
|
||||
}
|
||||
|
||||
|
||||
var fields = glovalType.GetFields();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
preCode = string.Join(Environment.NewLine, preCode, ToDeclarationString(field));
|
||||
}
|
||||
|
||||
var methods = glovalType.GetMethods();
|
||||
foreach (var method in methods)
|
||||
{
|
||||
if (method.Name.StartsWith("get_") || method.Name.StartsWith("set_")) continue;
|
||||
|
||||
preCode = string.Join(Environment.NewLine, preCode, ToMethodString(method));
|
||||
}
|
||||
|
||||
PreCode = preCode;
|
||||
}
|
||||
|
||||
private static string ToDeclarationString(PropertyInfo property)
|
||||
{
|
||||
if (property.CanRead)
|
||||
{
|
||||
return $"{property.PropertyType.FullName} {property.Name} {{ get; {(property.CanWrite ? "set; " : "")}}}";
|
||||
}
|
||||
else if (property.CanWrite)
|
||||
{
|
||||
return $"{property.PropertyType.FullName} {property.Name} {{ set => throw new System.NotImplementedException(); }}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static string ToDeclarationString(FieldInfo field)
|
||||
{
|
||||
return $"{field.FieldType.FullName} {field.Name};";
|
||||
}
|
||||
|
||||
private static string ToMethodString(MethodInfo method)
|
||||
{
|
||||
return $"{ToTypeString(method.ReturnType)} {method.Name}({string.Join(',', method.GetParameters().Select(ToParameterString))}) => throw new System.NotImplementedException();";
|
||||
}
|
||||
|
||||
private static string ToParameterString(ParameterInfo parameter)
|
||||
{
|
||||
var defaultValue = "";
|
||||
if (parameter.HasDefaultValue)
|
||||
{
|
||||
if (parameter.DefaultValue != null)
|
||||
{
|
||||
if (parameter.ParameterType.IsEnum)
|
||||
{
|
||||
defaultValue = $" = {parameter.ParameterType.FullName}.{parameter.DefaultValue}";
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue = $" = {parameter.DefaultValue}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue = " = null";
|
||||
}
|
||||
}
|
||||
return $"{parameter.ParameterType.FullName} {parameter.Name}{defaultValue}";
|
||||
}
|
||||
|
||||
private static string ToTypeString(Type type)
|
||||
{
|
||||
return type == typeof(void) ? "void" : type.FullName ?? type.Name;
|
||||
}
|
||||
}
|
||||
3
RobotNet.Script.Shares/ScriptFile.cs
Normal file
3
RobotNet.Script.Shares/ScriptFile.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record ScriptFile(string Name, string Code);
|
||||
3
RobotNet.Script.Shares/ScriptFolder.cs
Normal file
3
RobotNet.Script.Shares/ScriptFolder.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record ScriptFolder(string Name, IEnumerable<ScriptFolder> Folders, IEnumerable<ScriptFile> Files);
|
||||
4
RobotNet.Script.Shares/ScriptMissionDto.cs
Normal file
4
RobotNet.Script.Shares/ScriptMissionDto.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record ScriptMissionParameterDto(string Name, string Type, string? Default);
|
||||
public record ScriptMissionDto (string Name, IEnumerable<ScriptMissionParameterDto> Parameters, string Code);
|
||||
3
RobotNet.Script.Shares/ScriptTaskDto.cs
Normal file
3
RobotNet.Script.Shares/ScriptTaskDto.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record ScriptTaskDto(string Name, int Interval, string Code);
|
||||
3
RobotNet.Script.Shares/ScriptVariableDto.cs
Normal file
3
RobotNet.Script.Shares/ScriptVariableDto.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record ScriptVariableDto(string Name, string TypeName, string Value);
|
||||
3
RobotNet.Script.Shares/UpdateModel.cs
Normal file
3
RobotNet.Script.Shares/UpdateModel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record UpdateModel(string Path, string Code);
|
||||
3
RobotNet.Script.Shares/UpdateVariableModel.cs
Normal file
3
RobotNet.Script.Shares/UpdateVariableModel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace RobotNet.Script.Shares;
|
||||
|
||||
public record UpdateVariableModel(string Name, string Value);
|
||||
Reference in New Issue
Block a user