修改全流程等

master
zby 3 months ago
parent cacf63a312
commit 53c75f1c14

@ -58,6 +58,7 @@ public class InfoEnum
[Info("前进","前进")] advance,//34
[Info("后退", "后退")] Backoff,
[Info("停好了", "停好了")] Itparked,
[Info("退出重新停车", "退出重新停车")] upcar,
}

@ -103,11 +103,11 @@ public class RfidApi
Log.Info("RfidApi ReadRfid");
string readUrl = BASE_URL + "/Api/BeginRead";
// string readUrl = BASE_URL + "/Api/BeginRead";
string url = BASE_URL + "/Api/ReadRfidData";
try
{
var vBeginRead = await _httpClient.GetStringAsync(readUrl);
// var vBeginRead = await _httpClient.GetStringAsync(readUrl);
string s = await _httpClient.GetStringAsync(url);
Log.Info($"ReadRfid resp={s}");
if (s != String.Empty)

@ -91,12 +91,22 @@ public class CarCtrlState : IState
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrUnLockCar);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrUnLockCar.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>();
if (b == 0) {
SoundClient.SoundPlay(SoundEnum.music48);
}, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError;
if (b == 0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music104);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music105);
Thread.Sleep(3000);
b = 1;
}
}, false, () => { machine.ExceptionReason = ExceptionReason.UnLockCarError; }
}
, 10, InvokeStatus.None);
}
}

@ -7,6 +7,7 @@ using Entity.Dto;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Configuration;
using log4net;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Model;
@ -161,6 +162,7 @@ public class CarPrepareState : IState
/// <returns></returns>
public InvokeStatus CheckTBoxConnectFlag(SwappingStateMachine machine)
{
int t = 0;
return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled,
() => machine.BoxConnectFlag, () =>
{
@ -172,15 +174,30 @@ public class CarPrepareState : IState
}
}, () =>
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music43);
if (t==0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music102);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music103);
Thread.Sleep(3000);
}
//machine.ExceptionReason = ExceptionReason.ConnTBoxError;
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
}, false, () =>
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address03"));
SoundClient.SoundPlay(SoundEnum.music43);
if (t == 0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music102);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music103);
Thread.Sleep(3000);
}
//machine.ExceptionReason = ExceptionReason.ConnTBoxError;
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed());
@ -239,6 +256,7 @@ public class CarPrepareState : IState
/// <returns></returns>
public InvokeStatus CheckTBoxVelLocalFlag(SwappingStateMachine machine)
{
int q = 0;
return Invoker.Invoke("check TBox VelLocal", 1000, 20, machine.IsCanceled,
() => machine.BoxLocalCheckFlag, () =>
{
@ -247,12 +265,22 @@ public class CarPrepareState : IState
if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelVin.Trim()))
{
machine.BoxLocalCheckFlag = true;
machine.BoxCarInfoModel = tBoxCarInfoModel;
}
}, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; }, true, () =>
{
machine.ExceptionReason = ExceptionReason.LocalCheckVarError;
if (q == 0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music108);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music109);
Thread.Sleep(3000);
q = 1;
}
}
, 3, InvokeStatus.TimeOut);
}
@ -304,6 +332,7 @@ public class CarPrepareState : IState
/// <param name="machine"></param>
public InvokeStatus SelectPack(SwappingStateMachine machine)
{
int e = 0;
SwapAmtOrder? swapAmtOrder = _CommonMgr.QueryAmtOrder(machine);
@ -327,8 +356,18 @@ public class CarPrepareState : IState
LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorSelectPack.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music49);
if (e==0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music106);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music107);
Thread.Sleep(3000);
e = 1;
}
// _log.Info($"SelectPack error CanSwap={machine.SwapOrderBatteryInfo.CanSwap}");
@ -346,7 +385,12 @@ public class CarPrepareState : IState
machine.ExceptionReason = ExceptionReason.SelectPackError;
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address09"));
SoundClient.SoundPlay(SoundEnum.music49);
if (e == 0)
{
SoundClient.SoundPlay(SoundEnum.music49);
e = 1;
}
// SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorSelectPack);
}
, false, () => { }, 10, InvokeStatus.None);

@ -147,13 +147,7 @@ public class DoSwappingState : IState
return SwappingStateMachine.ReturnWithInvokeErr(beginRadar, ExceptionReason.None);
}
//车辆离开
var adjustCarByRadar = AdjustCarByRadar(machine);
machine.Reset();
if (InvokeStatus.Done != adjustCarByRadar)
{
return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None);
}
@ -207,29 +201,7 @@ public class DoSwappingState : IState
//}
public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine)
{
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled,
() =>
{
//新增小步
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
machine);
var carState = PadarMgr._PadarClient?.CarState;
return carState.HasValue && (carState.Value == 1 || carState.Value == 2 || carState.Value == 3 || carState.Value == 4 || carState.Value == 5);
},
() =>
{
switch (PadarMgr._PadarClient?.CarState)
{
case 6:
_log.Info("车辆未驶离");
break;
}
});
}
/// <summary>
/// 下发plc启动换电
@ -247,17 +219,7 @@ public class DoSwappingState : IState
{
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
machine.SwapOrderBatteryInfo.UpBinInfo.No);
if (c==0)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag,
machine);
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music91);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music90);
}
//查詢當前任務狀態是否被更改
if (startSwapping)
@ -321,6 +283,7 @@ public class DoSwappingState : IState
if(i==0)
{
SoundClient = AppInfo.Container.Resolve<SoundClient>();
SoundClient.SoundPlay(SoundEnum.music51);
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack);
i = 1;
@ -441,16 +404,14 @@ public class DoSwappingState : IState
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address19"));
if (v == 0)
{
SoundClient.SoundPlay(SoundEnum.music76);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music77);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
machine);
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
machine);
SoundClient.SoundPlay(SoundEnum.music77);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music76);
v = 1;
}
//断连Tbox

@ -177,8 +177,7 @@ public class StationReadyState : IState
/// <returns></returns>
public InvokeStatus ControlRadar(SwappingStateMachine machine, byte flag)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine);
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => PadarMgr._PadarClient?.CarState > 0,
() => { PadarMgr._PadarClient?.PadarControl(flag); });
@ -189,6 +188,7 @@ public class StationReadyState : IState
public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine)
{
int che = 0;
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled,
() =>
@ -197,6 +197,8 @@ public class StationReadyState : IState
if (PadarMgr._PadarClient?.CarState==6)
{
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine);
LedClient.SendMsgByKey(InfoEnum.SwapInfo.Backoff.GetLed());
}
@ -214,6 +216,16 @@ public class StationReadyState : IState
break;
case 3:
_log.Info("radar 角度偏移过大");
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address25"));
if (che == 0)
{
LedClient.SendMsgByKey(InfoEnum.SwapInfo.upcar.GetLed());
SoundClient.SoundPlay(SoundEnum.music100);
Thread.Sleep(3000);
SoundClient.SoundPlay(SoundEnum.music101);
che = 1;
}
break;
case 4:
_log.Info("radar 车辆靠后");
@ -290,10 +302,12 @@ public class StationReadyState : IState
private InvokeStatus ReadRfid(SwappingStateMachine machine)
{
int e = 0;
//开始读rifd
return Invoker.Invoke("read rfid", 3000, 20, machine.IsCanceled,
() => machine.RfidReadFlag, () =>
() => machine.RfidReadFlag,() =>
{
Task<RfidReadModel?> rfidReadModel = RfidApi.ReadRfid();
rfidReadModel.Wait();
var machineRfidReadModel = rfidReadModel.Result;
@ -333,7 +347,12 @@ public class StationReadyState : IState
machine.LedTool!.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
SoundClient = AppInfo.Container.Resolve<SoundClient>();
//SoundClient.SoundPlay(AppSettingsHelper.GetContent("SoundAddr", "Address02"));
SoundClient.SoundPlay(SoundEnum.music42);
if (e == 0)
{
SoundClient.SoundPlay(SoundEnum.music42);
e = 1;
}
//SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorReadRfid);
//LedClient.SendMsgByKey(InfoEnum.SwapInfo.ErrorReadRfid.GetLed());
}, false, () => { machine.ExceptionReason = ExceptionReason.ReadRfidError; }, 10,

@ -57,16 +57,16 @@ public class SwapDoneState : IState
});
if (machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success)
{
//上传云平台换电状态
// machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.SwapDoneWithVel;
// CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
}
//if (machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success)
//{
// //上传云平台换电状态
// // machine.BusinessSwappingForCloudState = InfoEnum.BusinessSwappingForCloudState.SwapDoneWithVel;
// // CloudApi.SendStateLog(machine.SwapOrder, machine.BusinessSwappingForCloudState);
//}
////云平台没有匹配的失败状态
////车辆上锁 ,提示请驶离
//InvokeStatus lockCar = LockCar(machine);
InvokeStatus lockCar = LockCar(machine);
//if (lockCar != InvokeStatus.Done)
//{
@ -75,18 +75,30 @@ public class SwapDoneState : IState
LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarLeave.GetLed());
//车辆离开
var adjustCarByRadar = AdjustCarByRadar(machine);
machine.Reset();
if (InvokeStatus.Done != adjustCarByRadar)
{
return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None);
}
//出口雷达监测
//InvokeStatus existRadar = ExistRadar(machine);
//if (existRadar != InvokeStatus.Done)
//{
// return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None);
//}
////关闭雷达
//var closeRadar = ControlRadar(machine, 0);
//if (InvokeStatus.Done != closeRadar)
//{
// return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None);
//}
//InvokeStatus existRadar = ExistRadar(machine);
//if (existRadar != InvokeStatus.Done)
//{
// return SwappingStateMachine.ReturnWithInvokeErr(existRadar, ExceptionReason.None);
//}
////关闭雷达
//var closeRadar = ControlRadar(machine, 0);
//if (InvokeStatus.Done != closeRadar)
//{
// return SwappingStateMachine.ReturnWithInvokeErr(closeRadar, ExceptionReason.None);
//}
@ -114,6 +126,32 @@ public class SwapDoneState : IState
});
}
public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine)
{
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled,
() =>
{
//新增小步
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag,
machine);
var carState = PadarMgr._PadarClient?.CarState;
return carState.HasValue && (carState.Value == 1 || carState.Value == 2 || carState.Value == 3 || carState.Value == 4 || carState.Value == 5);
},
() =>
{
switch (PadarMgr._PadarClient?.CarState)
{
case 6:
_log.Info("车辆未驶离");
break;
}
});
}
/// <summary>
/// 车辆上锁
/// </summary>

@ -1,6 +1,7 @@
using System.Net.Sockets;
using HybirdFrameworkCore.Utils;
using log4net;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
namespace Service.Led;
@ -91,7 +92,8 @@ public class LedClient
{"前进",new byte[]{0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x0C,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x4D,0x75,0x6B,0x61,0x00,0x00,0x0D,0x0A, }},
{"后退",new byte[]{ 0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x0E,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x4D,0x75,0x6E,0x64,0x75,0x72,0x00,0x00,0x0D,0x0A, }},
{"停好了",new byte[]{ 0x55,0xAA,0x00,0x00,0x01,0x01,0x00,0xD9,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,0x00,0x25,0x64,0x69,0x73,0x70,0x30,0x3B,0x3A,0x49,0x74,0x75,0x20,0x64,0x69,0x70,0x61,0x72,0x6B,0x69,0x72,0x00,0x00,0x0D,0x0A,}},
{"退出重新停车",new byte[]{ 0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x21, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3B, 0x3A, 0x4B, 0x65, 0x6C, 0x75, 0x61, 0x72, 0x20, 0x64, 0x61, 0x6E, 0x20, 0x70, 0x61, 0x72, 0x6B, 0x69, 0x72, 0x20, 0x6B, 0x65, 0x6D, 0x62, 0x61, 0x6C, 0x69, 0x00, 0x00, 0x0D, 0x0A, }},
};
#endregion
@ -105,10 +107,17 @@ public class LedClient
{
_ip = ip;
_port = port;
Connect();
InitClient();
// Connect();
return _socket.Connected;
}
public static void InitClient()
{
Task.Run(Connect);
}
private static void Connect()
{
Log.Info($"begin connect {_ip}:{_port}");
@ -120,7 +129,8 @@ public class LedClient
public static bool InnerSend(byte[] bytes)
{
Connect();
InitClient();
// Connect();
if (_socket?.Connected ?? true)
{
_socket?.Send(bytes);

@ -44,7 +44,7 @@ public class BatteryStatusReportedReqHandler : SimpleChannelInboundHandler<Batte
Exists = 0,
ChargeStatus=2,
BatteryNo = "-1",
Soc = (decimal)-1,
Soc = (decimal)-1,
Soe = (decimal)-1,
Soh = (decimal)-1,
},

@ -39,5 +39,6 @@ public class SummaryFailuresReqHandler : SimpleChannelInboundHandler<SummaryFail
ClientMgr.PlcClient.Auto = msg.T3 == 1;
ClientMgr.PlcClient.Remote = msg.T3 == 1;
ClientMgr.PlcClient.Init = msg.T6 == 1;
}
}

@ -193,6 +193,17 @@ public enum SoundEnum
music91,//[Info("换电开始印尼")] ErrStartSwap,
music92,//[Info(" 解锁成功中")] ErrStartSwap,
music93,//[Info(" 解锁成功印尼")] ErrStartSwap,
music100,//[Info(" 车辆停放不到位印尼")] ErrStartSwap,
music101,//[Info(" 车辆停放不到位")] ErrStartSwap,
music102,//[Info(" 正在等待车辆连接印尼")] ErrStartSwap,
music103,//[Info(" 正在等待车辆连接")] ErrStartSwap,
music104,//[Info(" 解锁失败印尼")] ErrStartSwap,
music105,//[Info(" 解锁失败")] ErrStartSwap,
music106,//[Info(" 选包失败印尼")] ErrStartSwap,
music107,//[Info(" 选包失败")] ErrStartSwap,
music108,//[Info(" 车辆验证失败印尼")] ErrStartSwap,
music109,//[Info(" 车辆验证失败")] ErrStartSwap,
/*

@ -21,12 +21,15 @@ public class UpsClient: ModbusTcpMaster
public EquipAlarmDefineRepository _equipAlarmDefineRepository=AppInfo.Container.Resolve<EquipAlarmDefineRepository>();
public EquipAlarmRecordRepository _equipAlarmRecordRepository=AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
public EquipAlarmProcessRecordRepository _equipAlarmProcessRecordRepository=AppInfo.Container.Resolve<EquipAlarmProcessRecordRepository>();
public UpsClient()
{
ReadAction = BatchRead;
Ip = "192.168.3.100";
Port = 23;
Port = 44;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;

@ -186,6 +186,7 @@ if (AppSettingsHelper.GetBool("padar", "enable"))
}
if (AppSettingsHelper.GetBool("led", "enable"))
{
LedClient.Init(AppSettingsHelper.GetContent("led", "ip"), Convert.ToInt32(AppSettingsHelper.GetContent("led", "port")));
@ -204,6 +205,9 @@ if (AppSettingsHelper.GetBool("swap", "enable"))
AppInfo.Container = app.Services.GetAutofacRoot();
//ClientMgr.InitClient();
//UpsMgr.UpsInit();
//ups
if (AppSettingsHelper.GetBool("ups", "enable"))
{

@ -143,7 +143,7 @@
"Enabled": false
},
"led": {
"enable": true,
"enable": false,
"ip": "192.168.3.79",
"port": 10000
}

Loading…
Cancel
Save