init commit

This commit is contained in:
zhaowei.huang
2026-06-14 11:19:15 +08:00
parent e79a3815a5
commit c8e540d272
174 changed files with 60830 additions and 39 deletions
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class ChargingSetting
{
// 充电电量下限,表示设备充电时最低的电量限制
public int CarMinBattery { get; set; }
// 充电电量上限,表示设备充电时最高的电量限制
public int CarMaxBattery { get; set; }
// 充电安全电量,表示设备充电时的安全电量阈值,低于此值可能会影响设备的正常使用
public int CarIdleChargeBattery { get; set; }
// 充电电量时长,表示设备充电所需的时间长度
public int CarIdleSecond { get; set; }
// 允许任务打断的充电电量下限,表示在执行某些任务时,设备可以容忍的最低电量限制
public int TaskAvailableBattery { get; set; }
// 闲时充电,表示设备在空闲状态下是否进行充电
public bool IsChargingDuringIdleTime { get; set; }
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class EnvelopeSetting
{
public string Name { get; set; }
public string Description { get; set; }
public string Value { get; set; }
}
}
+76
View File
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
/// <summary>
/// 任务类别
/// </summary>
public enum TaskKind
{
Loop,
BranchPoint,
JoinPoint
}
/// <summary>
/// 任务启动类型:API/PLC/按钮盒/自动循环
/// </summary>
public enum TaskStartType
{
Api,
Plc,
ButtonBox,
AutoLoop,
Charge
}
public class LoopTask
{
/// <summary>
/// 任务唯一标识ID(自增)
/// </summary>
public int Id { get; set; } = 0;
/// <summary>
/// 任务类别(枚举:循环/分流点/汇合点)
/// </summary>
public TaskKind Kind { get; set; } = TaskKind.Loop;
/// <summary>
/// 当前点 ID(整数)
/// </summary>
public int CurrentStationId { get; set; } = -1;
/// <summary>
/// 目标点 ID(整数)
/// </summary>
public int TargetStationId { get; set; } = -1;
/// <summary>
/// 流量控制(整数,可代表信号级别或策略编号)
/// </summary>
public int TrafficControl { get; set; } = 0;
/// <summary>
/// 优先级(整数)
/// </summary>
public int Priority { get; set; } = 1;
/// <summary>
/// 是否为途径点(布尔)
/// </summary>
public bool IsViaPoint { get; set; } = false;
/// <summary>
/// 启动类型(枚举:Api/Plc/ButtonBox/AutoLoop
/// </summary>
public TaskStartType StartType { get; set; } = TaskStartType.AutoLoop;
public string[] tags = Array.Empty<string>();
}
}
+241
View File
@@ -0,0 +1,241 @@
using SimpleCore.PropType;
using SimpleCore;
using System.Collections.Generic;
using System.Dynamic;
using SimpleLite.CADTools;
using SimpleLite.Props;
using SimpleLite.UI;
using System.Numerics;
using System.Drawing;
using System;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using SimpleLite.RCS;
using SimpleLite.RCS.CarTypes;
namespace StandardScene.Model
{
public class Map
{
public List<ExpandoObject> Sites { get; set; }
public List<ExpandoObject> Tracks { get; set; }
public List<ExpandoObject> CircularArcTracks { get; set; }
public List<ExpandoObject> BezierTracks { get; set; }
public static Map GetMap()
{
var map = new Map
{
Sites = new List<ExpandoObject>()
};
Site[] allSites = SimpleLib.GetAllSites();
foreach (var site in allSites)
{
dynamic theSite = new ExpandoObject();
theSite.Id = ((Prop)site).id;
theSite.Name = ((Prop)site).name;
theSite.X = site.x;
theSite.Y = site.y;
theSite.Fields = new Dictionary<string, string>();
foreach (var kv in site.fields)
{
theSite.Fields.Add(kv.Key, kv.Value);
}
theSite.Type = theSite.Fields.ContainsKey("Standby") ? "standby" : theSite.Fields.ContainsKey("Charge") ? "charge" : theSite.Fields.ContainsKey("Shelf") ? "shelf" : "default";
map.Sites.Add(theSite);
}
map.Tracks = new List<ExpandoObject>();
map.CircularArcTracks = new List<ExpandoObject>();
map.BezierTracks = new List<ExpandoObject>();
var allTracks = SimpleLib.GetAllTracks();
foreach (var track in allTracks)
{
switch (track)
{
case UITrack uiTrack:
{
dynamic theTrack = new ExpandoObject();
theTrack.Id = uiTrack.id;
theTrack.A = uiTrack.siteA;
theTrack.B = uiTrack.siteB;
theTrack.Fields = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> kv in uiTrack.fields)
{
theTrack.Fields.Add(kv.Key, kv.Value);
}
theTrack.Direction = uiTrack.direction switch
{
1 => "a2b",
2 => "b2a",
_ => "both"
};
theTrack.Type = 0;
map.Tracks.Add(theTrack);
break;
}
case UICircularArcTrack circularArcTrack:
{
dynamic theTrack = new ExpandoObject();
theTrack.Id = circularArcTrack.id;
theTrack.A = circularArcTrack.siteA;
theTrack.B = circularArcTrack.siteB;
theTrack.Fields = new Dictionary<string, string>();
foreach (var kv in circularArcTrack.fields)
{
theTrack.Fields.Add(kv.Key, kv.Value);
}
theTrack.Direction = circularArcTrack.direction switch
{
1 => "a2b",
2 => "b2a",
_ => "both"
};
//添加原点坐标、半径、开始角度、结束角度
theTrack.Type = 1;
theTrack.CenterX = circularArcTrack.Arc.Center.X;
theTrack.CenterY = circularArcTrack.Arc.Center.Y;
theTrack.Radius = circularArcTrack.Arc.Radius;
theTrack.AngleStart = circularArcTrack.Arc.AngleStart;
theTrack.AngleEnd = circularArcTrack.Arc.AngleEnd;
//获取圆弧的控制点
var controlPoint = ArcHelper.CalculateControlPoint(
circularArcTrack.Arc.PointStart.X, circularArcTrack.Arc.PointStart.Y,
circularArcTrack.Arc.PointEnd.X, circularArcTrack.Arc.PointEnd.Y,
circularArcTrack.Arc.Center.X, circularArcTrack.Arc.Center.Y,
circularArcTrack.Arc.Radius,
circularArcTrack.Arc.AngleStart, circularArcTrack.Arc.AngleEnd);
theTrack.ControlPointsX = controlPoint.X;
theTrack.ControlPointsY = controlPoint.Y;
map.CircularArcTracks.Add(theTrack);
break;
}
case UIBezierTrack bezierTrack:
{
dynamic theTrack = new ExpandoObject();
theTrack.Id = bezierTrack.id;
theTrack.A = bezierTrack.siteA;
theTrack.B = bezierTrack.siteB;
theTrack.Fields = new Dictionary<string, string>();
foreach (var kv in bezierTrack.fields)
{
theTrack.Fields.Add(kv.Key, kv.Value);
}
theTrack.Direction = bezierTrack.direction switch
{
1 => "a2b",
2 => "b2a",
_ => "both"
};
//根据typeInfo获取控制点个数
theTrack.Type = 2;
var array = bezierTrack.typeInfo.Split(',');
var num = int.Parse(array[1]);//获取控制点的个数(包括起点和终点)
var list = new List<Vector2>();
for (var i = 0; i < num; i++)
{
//只记录中间的控制点
if (i <= 0 || i >= num - 1) continue;
float x = float.Parse(array[2 + i * 2]);
float y = float.Parse(array[3 + i * 2]);
list.Add(new Vector2(x, y));
}
theTrack.controlPoints = list;
map.BezierTracks.Add(theTrack);
break;
}
default:
break;
}
}
return map;
}
}
public class ArcHelper
{
/// <summary>
/// 获取圆弧控制点
/// </summary>
/// <returns></returns>
public static PointF CalculateControlPoint(float pointStartX, float pointStartY, float pointEndX, float pointEndY, float centerX, float centerY, float radius, float angleStart, float angleEnd)
{
PointF center = new PointF(centerX, centerY);
double startAngle = angleStart * 3.14159 / 180.0;
double endAngel = angleEnd * 3.14159 / 180.0;
if (angleStart > angleEnd)//如果起始角度小于结束角度就加上360度
{
endAngel += 2 * 3.14159;
}
PointF midPoint = new PointF(
(float)(center.X + radius * Math.Cos((startAngle + endAngel) / 2)),
(float)(center.Y + radius * Math.Sin((startAngle + endAngel) / 2)));
return midPoint;
}
}
public class LidarMap
{
public string LidarMapsBase64 { get; set; }
public float DistanceX { get; set; }
public float DistanceY { get; set; }
public float Ratio { get; set; }
private static readonly HttpClient hc = new HttpClient();
public static async Task<LidarMap> GetLidarMap()
{
var par = JsonConvert.DeserializeAnonymousType(await hc.GetStringAsync($"http://127.0.0.1:4321/getMapParameters"),
new { up = 0f, down = 0f, left = 0f, right = 0f, pt = 0 });
var lengthWidthRatio =Math.Abs((par.right - par.left) / (par.up - par.down));
var height = 1024;var width = 1024;
if (lengthWidthRatio > 1)
{
height = (int)(1024 / lengthWidthRatio);
}
else
{
width = (int)(1024 * lengthWidthRatio);
}
var mapBmp= new Bitmap((await hc.GetStreamAsync($"http://127.0.0.1:4321/getMapPng?width={width}&height={height}")));
for(int x =0;x<mapBmp.Width;x++)
{
for (int y = 0; y < mapBmp.Height; y++)
{
Color pixColor = mapBmp.GetPixel(x, y);
if (pixColor.R != 255 || pixColor.G != 255 || pixColor.B != 255)
{
mapBmp.SetPixel(x, y, Color.FromArgb(0,pixColor));
}
else
{
mapBmp.SetPixel(x,y,Color.Black);
}
}
}
return new LidarMap
{
LidarMapsBase64 = "data:image/png;base64," + BitmapToBase64(mapBmp, ImageFormat.Png),
DistanceX = par.left,
DistanceY = par.up,
Ratio = lengthWidthRatio > 1?Math.Abs(par.left-par.right)/1024: Math.Abs(par.up - par.down)/1024,
};
}
static string BitmapToBase64(Bitmap bmp, ImageFormat format)
{
using MemoryStream ms = new MemoryStream();
bmp.Save(ms, format); // 保存格式可以是Png, Jpeg等
byte[] imageBytes = ms.ToArray();
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
}
+226
View File
@@ -0,0 +1,226 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class MapStructure
{
public FassMap Map { get; set; }
public List<FassNode> Nodes { get; set; }
public List<Edge> Edges { get; set; }
public List<object> Zones { get; set; }
public List<object> Tags { get; set; }
}
public class FassMap
{
public int Index { get; set; }
public string Id { get; set; }
public string Kind { get; set; }
public string Type { get; set; }
public Base Base { get; set; }
public Image Image { get; set; }
public List<object> Extends { get; set; }
}
public class Base
{
public bool Visible { get; set; }
public Size Size { get; set; }
public double GlobalAlpha { get; set; }
public int LineWidth { get; set; }
public List<int> LineDash { get; set; }
public string StrokeStyle { get; set; }
public string FillStyle { get; set; }
public Center Center { get; set; }
}
public class Size
{
public double W { get; set; }
public double H { get; set; }
}
public class Center
{
public double X { get; set; }
public double Y { get; set; }
}
public class Image
{
public bool Visible { get; set; }
public double GlobalAlpha { get; set; }
public string Src { get; set; }
public bool Origin { get; set; }
public bool Manual { get; set; }
public ManualPoint ManualPoint { get; set; }
public ManualSize ManualSize { get; set; }
}
public class ManualPoint
{
public double X { get; set; }
public double Y { get; set; }
}
public class ManualSize
{
public double W { get; set; }
public double H { get; set; }
}
public class FassNode
{
public int Index { get; set; }
public string Id { get; set; }
public string Kind { get; set; }
public string Type { get; set; }
public NodeBase Base { get; set; }
public Code Code { get; set; }
public Name Name { get; set; }
public Image Image { get; set; }
public Lock Lock { get; set; }
public Data Data { get; set; }
public List<object> Extends { get; set; }
}
public class NodeBase
{
public bool Visible { get; set; }
public Point Point { get; set; }
public Size Size { get; set; }
public double GlobalAlpha { get; set; }
public int LineWidth { get; set; }
public List<int> LineDash { get; set; }
public string StrokeStyle { get; set; }
public string FillStyle { get; set; }
public Center Center { get; set; }
}
public class Point
{
public double X { get; set; }
public double Y { get; set; }
}
public class Code
{
public bool Visible { get; set; }
public double GlobalAlpha { get; set; }
public string Font { get; set; }
public string FillStyle { get; set; }
public string Text { get; set; }
}
public class Name
{
public bool Visible { get; set; }
public double GlobalAlpha { get; set; }
public string Font { get; set; }
public string FillStyle { get; set; }
public string Text { get; set; }
}
public class Lock
{
public bool Enable { get; set; }
}
public class Data
{
public string NodeId { get; set; }
public int SequenceId { get; set; }
public string NodeDescription { get; set; }
public bool Released { get; set; }
public NodePosition NodePosition { get; set; }
public List<FassAction> Actions { get; set; }
}
public class NodePosition
{
public double X { get; set; }
public double Y { get; set; }
public string MapId { get; set; }
}
public class FassAction
{
public bool Action0 { get; set; }
public string ActionId { get; set; }
public List<FassActionParameter> ActionParameters { get; set; }
public string ActionType { get; set; }
public string BlockingType { get; set; }
public int SortNumber { get; set; }
}
public class FassActionParameter
{
public bool Parameter0 { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}
public class Edge
{
public int Index { get; set; }
public string Id { get; set; }
public string Kind { get; set; }
public string Type { get; set; }
public EdgeBase Base { get; set; }
public Code Code { get; set; }
public Name Name { get; set; }
public Lock Lock { get; set; }
public EdgeData Data { get; set; }
public List<object> Extends { get; set; }
}
public class EdgeBase
{
public bool Visible { get; set; }
public Point Point { get; set; }
public Size Size { get; set; }
public double GlobalAlpha { get; set; }
public int LineWidth { get; set; }
public List<int> LineDash { get; set; }
public string StrokeStyle { get; set; }
public string FillStyle { get; set; }
public Center Center { get; set; }
public bool IsOneway { get; set; }
public double Width { get; set; }
public Node StartNode { get; set; }
public Node EndNode { get; set; }
}
public class EdgeData
{
public string EdgeId { get; set; }
public int SequenceId { get; set; }
public string EdgeDescription { get; set; }
public bool Released { get; set; }
public string StartNodeId { get; set; }
public string EndNodeId { get; set; }
public double MaxSpeed { get; set; }
public double MaxHeight { get; set; }
public double MinHeight { get; set; }
public double Orientation { get; set; }
public string OrientationType { get; set; }
public string Direction { get; set; }
public bool RotationAllowed { get; set; }
public double MaxRotationSpeed { get; set; }
public double Length { get; set; }
public Trajectory Trajectory { get; set; }
public List<object> Actions { get; set; }
}
public class Trajectory
{
public double Degree { get; set; }
public List<int> KnotVector { get; set; }
public List<object> ControlPoints { get; set; }
}
}
+48
View File
@@ -0,0 +1,48 @@
using System;
namespace StandardScene.Model
{
public class MissionState
{
public string MissionId { get; set; }
public string CarCode {get; set; }
public DateTime TriggerTime { get; set; }
public enum MissionStateEnum
{
/// <summary>
/// 创建任务。
/// </summary>
Created = 1,
/// <summary>
/// 子任务启动。
/// </summary>
Started = 2,
/// <summary>
/// 子任务完成。
/// </summary>
Finished = 3,
/// <summary>
/// 子任务失败。
/// </summary>
Failed = 4,
/// <summary>
/// 子任务的取货完成,发生在Started之后。
/// </summary>
Fetched = 5,
/// <summary>
/// 子任务的放货完成,发生在Started之后。
/// </summary>
Put = 6
}
public MissionStateEnum State { get; set; }
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class PlanRulesSetting
{
public string Name { get; set; }
public string Description { get; set; }
public string Value { get; set; }
public string NodeId { get; set; }
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class SimpleConfig
{
public string Autoload { get; set; }
public int Port { get; set; }
public string Ip { get; set; }
public bool AllowMultiple { get; set; }
}
}
+124
View File
@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class Configuration
{
public Conf conf { get; set; }
public Dictionary<string, SimpleMission> Missions { get; set; }
public Dictionary<string, SimpleMap> Maps { get; set; }
public Dictionary<string, SimpleSite> Sites { get; set; }
public Dictionary<string, Track> Tracks { get; set; }
public Dictionary<string, object> Cars { get; set; } // Assuming Cars is an empty object
public Dictionary<string, object> PrologScripts { get; set; } // Assuming PrologScripts is an empty object
public Configuration()
{
// Initialize Conf with default values
conf = new Conf
{
PRICE_RANGE = 10000.0,
fields = new Dictionary<string, object>(),
Car_UpdateInterval = 300,
Search_AllowDestOnRoute = false,
Search_RouteOnDestClearance = 0,
Search_MaxVisitPerSite = 1,
Search_MaxDupVisit = 1,
Search_MaxKeepResult = 16,
Traffic_MaxHoldingLocks = 3,
Traffic_DeadLockSearchDepth = 0,
DebugTypes = "S",
Auto_Reprogram = false
};
Missions = new Dictionary<string, SimpleMission>();
Maps = new Dictionary<string, SimpleMap>();
Sites = new Dictionary<string, SimpleSite>();
Tracks = new Dictionary<string, Track>();
Cars = new Dictionary<string, object>();
PrologScripts = new Dictionary<string, object>();
}
}
public class Conf
{
public double PRICE_RANGE { get; set; }
public Dictionary<string, object> fields { get; set; } // Assuming fields is an empty object
public int Car_UpdateInterval { get; set; }
public bool Search_AllowDestOnRoute { get; set; }
public int Search_RouteOnDestClearance { get; set; }
public int Search_MaxVisitPerSite { get; set; }
public int Search_MaxDupVisit { get; set; }
public int Search_MaxKeepResult { get; set; }
public int Traffic_MaxHoldingLocks { get; set; }
public int Traffic_DeadLockSearchDepth { get; set; }
public string DebugTypes { get; set; }
public bool Auto_Reprogram { get; set; }
}
public class SimpleMission
{
public string type { get; set; }
public MissionOptions options { get; set; }
}
public class MissionOptions
{
public bool autoStart { get; set; }
public int id { get; set; }
public string layerName { get; set; }
public string name { get; set; }
public Dictionary<string, object> fields { get; set; } // Assuming fields is an empty object
}
public class SimpleMap
{
public string type { get; set; }
public MapOptions options { get; set; }
}
public class MapOptions
{
public string filename { get; set; }
public int id { get; set; }
public string layerName { get; set; }
public string name { get; set; }
public Dictionary<string, object> fields { get; set; } // Assuming fields is an empty object
}
public class SimpleSite
{
public string color { get; set; }
public string displaySetting { get; set; }
public double x { get; set; }
public double y { get; set; }
public int id { get; set; }
public string layerName { get; set; }
public string name { get; set; }
public Dictionary<string, string> fields { get; set; }
public List<object> mustFree { get; set; } // Assuming mustFree is an empty array
}
public class Track
{
public string displaySetting { get; set; }
public int siteA { get; set; }
public int siteB { get; set; }
public int direction { get; set; }
public int id { get; set; }
public string layerName { get; set; }
public string name { get; set; }
public Dictionary<string, string> fields { get; set; }
public int _siteA { get; set; }
public int _siteB { get; set; }
public string typeInfo { get; set; }
// public Dictionary<string, object> fields { get; set; }
}
}
+262
View File
@@ -0,0 +1,262 @@
using SimpleLite.RCS;
using SimpleLite.RCS.CarTypes;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StandardScene.Model
{
public class TaskRequest
{
public string CarCode { get; set; }
public string CarType { get; set; }
public string TaskCode { get; set; }
public string MissionType { get; set; }
public string TaskType { get; set; }
public string Material { get; set; }
public ContainerSize ContainerSize { get; set; }
public List<Node> Nodes { get; set; }
public int priority { get; set; }
}
public class ContainerSize
{
public double Length { get; set; }
public double Width { get; set; }
public double Height { get; set; }
}
public class Node
{
public int Code { get; set; }
//public List<Action> Actions { get; set; }
}
public class Action
{
public string Code { get; set; }
public string ActionType { get; set; }
public string BlockingType { get; set; }
public List<ActionParameter> Parameters { get; set; }
}
public class ActionParameter
{
public string Key { get; set; }
public string Value { get; set; }
}
public class BaseRespose<T>
{
public bool Success { get; set; }
public int Code { get; set; } = 200;
public string Message { get; set; }
public T Data { get; set; }
}
public class BaseRespose
{
public bool Success { get; set; } = true;
public int Code { get; set; } = 200;
public string Message { get; set; }
}
public class CarInfo
{
public string Code { get; set; }
public string Name { get; set; }
public double Voltage { get; set; }
public string Address { get; set; }
public string Speed { get; set; }
public int siteId { get; set; }
}
public class CarStateInfo
{
public string Code { get; set; }
public string Name { get; set; }
public string CurrState { get; set; }
public bool IsOnline { get; set; } = false;
public double Battery { get; set; }
public double ElectricCurrent { get; set; }
public double Voltage { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Theta { get; set; }
public double Speed { get; set; }
public int Load { get; set; }
public string CurrNodeCode { get; set; }
public string StartNodeCode { get; set; }
public string EndNodeCode { get; set; }
public string CurrEdgeCode { get; set; } = "";
public string StartEdgeCode { get; set; } = "";
public string EndEdgeCode { get; set; } = "";
public List<int> HoldingLocks { get; set; }
public List<int> PendingLocks { get; set; }
public List<BlockedByItem> BlockedBy { get; set; }
public string BlockingTime { get; set; } = "";
public string TrafficMessage { get; set; } = "";
public int AquiringLock { get; set; } = -1;
public bool StopAccept { get; set; } = false;
public List<CarAlarm> Alarms { get; set; }
public List<TaskInfo> Tasks { get; set; }
public List<TaskAction> Actions { get; set; }
}
public class BlockedByItem
{
public string CarCode { get; set; }
public int Type { get; set; }
}
public class CarAlarm
{
public string Code { get; set; }
public string Name { get; set; }
}
public class TaskInfo
{
public string Code { get; set; }
public string State { get; set; }
public List<ResponseNode> Nodes { get; set; }
}
public class TaskAction
{
public string Code { get; set; }
public string ActionType { get; set; }
public string BlockingType { get; set; }
public string State { get; set; }
}
public class ResponseNode
{
public string Code { get; set; }
//public List<TaskAction> Actions { get; set; }
}
public class TaskCancel
{
public string TaskCode { get; set; }
public string MissionType { get; set; }
public string TaskStatus { get; set; }
}
public class TaskRecord
{
public string TaskId { get; set; }
public string Name { get; set; }
public string CarId { get; set; }
public string CarName { get; set; }
public string SrcSiteId { get; set; }
public string DestSiteId { get; set; }
public int Priority { get; set; } = 0;
public string State { get; set; }
public DateTime? StartTime { get; set; }
public DateTime? EndTime { get; set; }
public DateTime Created { get; set; }
}
public class CarBaseInfo
{
public string Code { get; set; }
public string Name { get; set; }
public string CarType { get; set; }
public double Length { get; set; }
public double Width { get; set; }
public string CurrNodeCode { get; set; }
public string CurrState { get; set; }
public double Battery { get; set; }
public string Address { get; set; }
public double Speed { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Theta { get; set; }
public double Voltage { get; set; }
public double ElectricCurrent { get; set; }
public bool IsOnline { get; set; } = false;
public Dictionary<string, string> Additional { get; set; }
public CarBaseInfo()
{
Additional = new Dictionary<string, string>();
}
public static CarBaseInfo FromCar(Car car)
{
var info = new CarBaseInfo()
{
Code = car.id.ToString(),
Name = car.name,
Address = car.address.Equals("/") ? "127.0.0.1" : car.address,
CurrNodeCode = car.status.holdingLocks.FirstOrDefault().ToString(),
X = car.x,
Y = car.y,
Theta = car.th,
Speed = car.speed
};
//info.Length = car.latestShape.lx;
//info.Width = car.latestShape.ly;
info.CarType = car.fields.ContainsKey("CarType") ? car.fields["CarType"] : "Car";
info.Battery = car.status.enums.ContainsKey("Soc") ? int.Parse(car.status.enums["Soc"]) : 100;
info.Voltage = car.status.enums.ContainsKey("Voltage") ? double.Parse(car.status.enums["Voltage"]) : 0;
info.ElectricCurrent = car.status.enums.ContainsKey("ElectricCurrent") ? double.Parse(car.status.enums["ElectricCurrent"]) : 0;
var isOnline = false;
string carState = SwitchCarState(car, ref isOnline);
info.IsOnline = isOnline;
info.CurrState = carState;
return info;
}
public static string SwitchCarState(Car car, ref bool isOnline)
{
string state = "Stopping";
if (car.GetLastSite() == -1)
{
isOnline = false;
return state;
}
if (Commons.GetVehicleStatus(car)!= VehicleStatus.Offline)
{
if (Commons.GetVehicleStatus(car) is VehicleStatus.Normal or VehicleStatus.NeedInit)
state = "Stopping"; //Idle
var lp = car.status.programs.latest;
if (lp != null)
{
if (
lp.status.state >= SimpleCore.Compiler.CarProgram.StatusEnum.Programming
&& lp.status.state <= SimpleCore.Compiler.CarProgram.StatusEnum.Running
)
{
state = "Running"; //Executing
}
}
//存在报警信息
if (car.status.enums.ContainsKey("AlarmInfo"))
{
if (!string.IsNullOrEmpty(car.status.enums["AlarmInfo"]))
{
state = "Faulting"; //Malfunction
}
}
if (car.tags.Contains("charging"))
state = "Charging";
isOnline = true;
}
else
{
isOnline = false;
}
return state;
}
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public class TrafficControlSetting
{
public string Name { get; set; }
public string Description { get; set; }
public string Value { get; set; }
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StandardScene.Model
{
public enum VehicleStatus
{
Unknown = 0,
Normal = 1,
NeedInit = 2,
Offline = 3,
}
}