init commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using LessokajiWeaverUtilities.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using SimpleLite.RCS;
|
||||
using SimpleLite.RCS.CarTypes;
|
||||
using SimpleCore;
|
||||
using SimpleCore.Compiler;
|
||||
using SimpleCore.PropType;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StandardScene.CarTypes
|
||||
{
|
||||
[CarType(Name = "锂电双举升")]
|
||||
[I18N.DocumentTranslation(Name = "Dual Lift Car", locale = "en")]
|
||||
public class DualLiftingCar : GhostCar
|
||||
{
|
||||
public static async Task<DualLiftingCar> Create()
|
||||
{
|
||||
var car = new DualLiftingCar()
|
||||
{
|
||||
lstatus = "连接中",
|
||||
address = "127.0.0.1",
|
||||
name = "锂电双举升"
|
||||
};
|
||||
return car;
|
||||
}
|
||||
public override string SetDisplayInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var str = $"{name}({id})\n";
|
||||
status.enums.TryGetValue("ChassisMode", out var manual);
|
||||
var ms = manual == "0" ? "自动" : "手动";
|
||||
status.enums.TryGetValue("Soc", out var soc);
|
||||
str = $"{str}{ms}|soc:{soc}";
|
||||
var alarmStr = Commons.GetCarStatus(this, "AlarmInfo");
|
||||
if (alarmStr != "")
|
||||
str = $"{str}|{alarmStr}";
|
||||
if (status.enums.TryGetValue("ElectricCurrent", out var electricCurrent) &&
|
||||
!string.IsNullOrEmpty(electricCurrent))
|
||||
{
|
||||
var charging = float.Parse(electricCurrent) * 0.01f > 0 ? "充电中" : "未充电";
|
||||
str = $"{str}|charge:{charging}";
|
||||
}
|
||||
|
||||
var thresSpeed = Commons.CarValue(this, "ThresSpeed");
|
||||
str = $"{str}{((thresSpeed <= 0) ? "|避障触发" : "")}";
|
||||
return str;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
return "bad car";
|
||||
}
|
||||
}
|
||||
|
||||
[MethodMember(Name = "进入小车远程", Description = "进入小车远程桌面")]
|
||||
[I18N.DocumentTranslation(Name = "Open remote desktop", Description = "Open the car's remote desktop", locale = "en")]
|
||||
public void Mstsc()
|
||||
{
|
||||
var ip = this.address;
|
||||
// 启动mstsc并传递IP地址
|
||||
Process.Start(
|
||||
new ProcessStartInfo
|
||||
{
|
||||
FileName = "mstsc",
|
||||
Arguments = $"/v:{ip}",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private bool _running;
|
||||
[MethodMember(Name = "测试")]
|
||||
[I18N.DocumentTranslation(Name = "Start test", locale = "en")]
|
||||
public async void Test()
|
||||
{
|
||||
_running = true;
|
||||
var siteA = SimpleLib.GetAllSites().First(s => s.name == "A");
|
||||
var siteB = SimpleLib.GetAllSites().First(s => s.name == "B");
|
||||
while (_running)
|
||||
{
|
||||
var planA = new SegmentPlan() { usingCar = this };
|
||||
planA.FindRoute(SimpleLib.GetSite(GetLastSite()), siteA);
|
||||
await planA.Compile("A").Queue();
|
||||
var planB = new SegmentPlan(){usingCar = this };
|
||||
planB.FindRoute(siteA, siteB);
|
||||
await planB.Compile("B").Queue();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodMember(Name = "停止测试")]
|
||||
[I18N.DocumentTranslation(Name = "Stop test", locale = "en")]
|
||||
public void Stop()
|
||||
{
|
||||
_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user