PLC现场调试更改

master
CZ 2 days ago
parent 48957e1a9e
commit af052fe1cc

@ -4,6 +4,7 @@ using Service.Charger.Client;
using Service.Mgr;
using Service.Padar.Client;
using Service.PlcAfrica.Client;
using Service.PlcAfrica.Msg;
namespace Service.Execute.Api;
@ -81,9 +82,9 @@ public class PlcApi
if (PlcAfricaMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo)))
{
Log.Info($"PlcApi StartSwapping done");
return PlcAfricaMgr.StartSwap();
return PlcAfricaMgr.StartSwap();
}
return false;
return PlcAfricaMgr.StationCommandFeedback();
}
/// <summary>

@ -256,7 +256,7 @@ public class DoSwappingState : IState
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,
() => machine.FinishNewBatteryFlag, () =>
{
if (PlcApi.ReadAction()==44 || PlcApi.RobotWorkFinish() || PlcApi.RobotReady())
if (PlcApi.ReadAction()==44 && (PlcApi.RobotWorkFinish() || PlcApi.RobotReady()))
{
machine.FinishNewBatteryFlag = true;
machine.BusinessSwappingForCloudState =

@ -11,7 +11,7 @@ public class FireClient: ModbusTcpMaster
public FireClient()
{
ReadAction = BatchRead;
Ip = "192.168.3.100";
Ip = "192.168.3.210";
Port = 23;
Duration = 1000;
AutoReConnect = true;

@ -177,7 +177,7 @@ public class LedClient
private static readonly ILog Log = LogManager.GetLogger(typeof(LedClient));
private static Socket? _socket;
private static string _ip = "192.168.3.79";
private static string _ip = "192.168.3.212";
// private static string _ip = "127.0.0.1";
private static int _port = 10000;

@ -0,0 +1,68 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Service.PlcAfrica.Client;
using Service.PlcAfrica.Msg;
namespace Service.MyTask;
[Scope]
public class PlcHeartTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger("PlcHeart");
private volatile bool _stop;
public string Name()
{
return "PlcHeartTask";
}
public int Interval()
{
return 1000 * 1;
}
private static bool heart = false;
public void Handle()
{
Log.Info("Plc Start write heart");
if (PlcAfricaMgr.PlcAfricaClient != null && PlcAfricaMgr.PlcAfricaClient.Connected)
{
heart = !heart;
PlcAfricaMsg writeHostToPlc = new PlcAfricaMsg();
writeHostToPlc.Heart.Value = (ushort)(heart ? 1 : 0);
Log.Info("Plc Start write heart write begin");
bool write0 = PlcAfricaMgr.PlcAfricaClient.WriteValue(writeHostToPlc.Heart);
Log.Info($"write return {write0}");
if (!write0)
{
Log.Info("Plc Start write heart write timeout");
}
else
{
Log.Info("Plc Start write heart write success");
}
}
else
Log.Info("Plc Start write heart fail");
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -21,8 +21,8 @@ public class PadarMgr
{
PadarClient client = AppInfo.Container.Resolve<PadarClient>();
client.AutoReconnect = true;
//client.InitBootstrap("192.168.3.55", int.Parse("2048"));
client.InitBootstrap("192.168.3.52", int.Parse("2048"), 10,0, 0);
//client.InitBootstrap("192.168.3.55", int.Parse("2048"));
client.InitBootstrap("192.168.3.199", int.Parse("2048"), 10,0, 0);
Task.Run(() =>
{
client.Connect();

@ -40,8 +40,7 @@ namespace Service.PlcAfrica.Client
ModbusDecoder.Decode<PlcAfricaMsg>(bytes01, PlcAfricaMgr.PlcAfricaMsg,
EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
var vv= PlcAfricaMgr.PlcAfricaMsg.PowerChangeMode.Value;
}
return resul;

@ -65,7 +65,7 @@ namespace Service.PlcAfrica.Client
public static bool StartSwap()
{
if (PlcAfricaClient == null)
if (PlcAfricaClient != null)
{
PlcAfricaMsg.OperationInstruction.Value = 2;
PlcAfricaClient!.WriteValue(PlcAfricaMsg.OperationInstruction);
@ -77,6 +77,11 @@ namespace Service.PlcAfrica.Client
return false;
}
public static bool StationCommandFeedback()
{
return PlcAfricaMsg.StationCommandFeedback.Value == 2;
}
/// <summary>
/// 操作指令
/// </summary>
@ -179,7 +184,7 @@ namespace Service.PlcAfrica.Client
{
InBinNo = inBinNo,
OutBinNo = outBinNo,
OutBinNo = inBinNo,//outBinNo,
};
byte[] encode = ModelConvert.Encode(distributeTask);
@ -195,7 +200,7 @@ namespace Service.PlcAfrica.Client
}
//需要将数据转换成byte数组
OperateResult operateResult = PlcAfricaClient.Write("x=16;111", encode);
OperateResult operateResult = PlcAfricaClient.Write("x=16;7008", encode);
return operateResult.IsSuccess;
}

Loading…
Cancel
Save