Commit 05c38db6 刘韬

agv接入

1 个父辈 39de335a
......@@ -108,6 +108,8 @@ namespace OnlineStore.Common
public static string AgvServerPort = "AgvServerPort";
public static string code_block_size_list = "code_block_size_list";
public static string InstoreEndSendShelf = "InstoreEndSendShelf";
public static string OutstoreEndSendShelf= "OutstoreEndSendShelf";
public static string LastOutShelfType= "LastOutShelfType";
}
}
......@@ -56,9 +56,12 @@
<add key="CurrShelfNum" value="-1"/>
<!--当前料架信息-料架类型,0=空料架,1=入库料架,2=出库料架-->
<add key="CurrShelfType" value="-1"/>
<add key="LastOutShelfType" value="1"/>
<add key="HasT4Axis" value="true"/>
<add key="AgvServerIp" value="192.168.11.11"/>
<add key="Code_Block_Size_List" value="17,19"/>
<add key="InstoreEndSendShelf" value="1" />
<add key="OutstoreEndSendShelf" value="1" />
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -61,9 +61,11 @@ namespace OnlineStore.DUOStore
//store.UseBuzzer = chbUseBuzzer.Checked;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
chbAutoRun.Checked = (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1));
chbInstoreEnd.Checked = (ConfigAppSettings.GetIntValue(Setting_Init.InstoreEndSendShelf).Equals(1));
chbOutstoreEnd.Checked = (ConfigAppSettings.GetIntValue(Setting_Init.OutstoreEndSendShelf).Equals(1));
LoadListView();
chbInstoreEnd.Checked = store.InstoreEndSendShelf;
chbOutstoreEnd.Checked = store.OutstoreEndSendShelf;
store.InstoreEndSendShelf=chbInstoreEnd.Checked;
store.OutstoreEndSendShelf=chbOutstoreEnd.Checked;
LoadOk = true;
//LogUtil.logBox = this.logBox;
store.BoxMap[1].camera_event += FrmStore_camera_event;
......@@ -719,7 +721,7 @@ namespace OnlineStore.DUOStore
{
return;
}
ConfigAppSettings.SaveValue(Setting_Init.InstoreEndSendShelf, chbInstoreEnd.Checked?1:0);
store.InstoreEndSendShelf = chbInstoreEnd.Checked;
LogUtil.info(store.Name + " 切换 入库完成送出料架=" + store.InstoreEndSendShelf);
}
......@@ -734,7 +736,7 @@ namespace OnlineStore.DUOStore
{
return;
}
ConfigAppSettings.SaveValue(Setting_Init.OutstoreEndSendShelf, chbOutstoreEnd.Checked ? 1 : 0);
store.OutstoreEndSendShelf = chbOutstoreEnd.Checked;
LogUtil.info(store.Name + " 切换 入库完成送出料架=" + store.OutstoreEndSendShelf);
......
......@@ -14,6 +14,7 @@ namespace OnlineStore.DUOStore
{
static class Program
{
#region 方法四:使用的Win32函数的声明
/// <summary>
......@@ -56,6 +57,7 @@ namespace OnlineStore.DUOStore
//string path = @"http://localhost:4090/rest/api/v1/station/status";
//HttpHelper.PostOperation(path, new Operation());
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
......
......@@ -14,6 +14,7 @@ namespace OnlineStore.DeviceLibrary
private static int ServerPort = ConfigAppSettings.GetIntValue(Setting_Init.AgvServerPort);
private static Agv.AgvClient agvClient;
public static Dictionary<string, Agv.ClientAction> actionMap = new Dictionary<string, Agv.ClientAction>();
public static Dictionary<string, Agv.ClientShelf> shelfMap = new Dictionary<string, Agv.ClientShelf>();
public static List<string> NodeList = new List<string>();
private static bool isInit = false;
public static void Init()
......@@ -25,19 +26,23 @@ namespace OnlineStore.DeviceLibrary
isInit = true;
agvClient = new Agv.AgvClient();
agvClient.Received += AgvClient_Received;
NodeList.Add(StoreManager.Config.AgvInName);
NodeList.Add(StoreManager.Config.AgvOutName);
agvClient.Connected += AgvClient_Connected;
//NodeList.Add(StoreManager.Config.AgvInName);
//NodeList.Add(StoreManager.Config.AgvOutName);
}
actionMap = new Dictionary<string, Agv.ClientAction>();
shelfMap = new Dictionary<string, Agv.ClientShelf>();
foreach (string key in NodeList)
{
actionMap.Add(key, Agv.ClientAction.None);
shelfMap.Add(key, Agv.ClientShelf.None);
}
agvClient.Connect(ServerIp, ServerPort);
foreach (string str in NodeList)
foreach (string id in NodeList)
{
SetStatus(str,"");
LogUtil.info("agv init ,SetStatus[" + str + "]=none ");
//SetStatus(id, "");
agvClient.SetStatus(id);
LogUtil.info("agv init ,SetStatus[" + id + "]=none ");
}
SetCancelState(false);
}
......@@ -49,7 +54,7 @@ namespace OnlineStore.DeviceLibrary
private static void AgvClient_Connected(bool status)
{
LogUtil.info($"AgvClient_Connected:{status}");
//LogUtil.info($"AgvClient_Connected:{status}");
}
private static void AgvClient_Received(Node node)
......@@ -70,7 +75,7 @@ namespace OnlineStore.DeviceLibrary
{
agvClient.CancelState = cancel;
}
public static void SetStatus(string id, string shelfId, ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.Low, bool isMust = false)
public static void SetStatus(string id, string shelfId, ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.Low, ClientShelf clientShelf=ClientShelf.Empty)
{
if (agvClient == null)
return;
......@@ -84,9 +89,10 @@ namespace OnlineStore.DeviceLibrary
}
}
agvClient.SetStatus(id, "", shelfId, action, level);
agvClient.SetStatus(id, "", shelfId, action, level, clientShelf);
UpdateAction(id, action);
LogUtil.info("AgvClient SetStatus id:" + id + ",shelfId:" + shelfId + ",action:" + action.ToString() + ",level:" + level.ToString());
UpdateShelf(id, clientShelf);
LogUtil.info("AgvClient SetStatus id:" + id + ",shelfId:" + shelfId + ",action:" + action.ToString() + ",level:" + level.ToString() + ",clientShelf:" + clientShelf.ToString());
}
......@@ -129,29 +135,29 @@ namespace OnlineStore.DeviceLibrary
public static bool SetToNone(string id, string shelfId = "")
{
Agv.ClientAction currA = GetAction(id);
if (currA.Equals(Agv.ClientAction.None) || currA.Equals(Agv.ClientAction.NeedLeave) || currA.Equals(Agv.ClientAction.NeedEnter))
{
//if (currA.Equals(Agv.ClientAction.None) || currA.Equals(Agv.ClientAction.NeedLeave) || currA.Equals(Agv.ClientAction.NeedEnter))
//{
SetStatus(id, shelfId, Agv.ClientAction.None);
return true;
//}
// return false;
}
return false;
}
public static bool NeedEnter(string id, string shelfId)
public static bool NeedEnter(string id, string shelfId, ClientShelf clientShelf)
{
Agv.ClientAction currA = GetAction(id);
if (currA.Equals(Agv.ClientAction.None) || currA.Equals(Agv.ClientAction.NeedLeave) || currA.Equals(Agv.ClientAction.NeedEnter))
if (currA.Equals(Agv.ClientAction.None) || currA.Equals(Agv.ClientAction.NeedEnter))
{
SetStatus(id, shelfId, Agv.ClientAction.NeedEnter);
SetStatus(id, shelfId, Agv.ClientAction.NeedEnter,ClientLevel.High, clientShelf);
return true;
}
return false;
}
public static bool NeedLeave(string id, string shelfId)
public static bool NeedLeave(string id, string shelfId,ClientShelf clientShelf)
{
Agv.ClientAction currA = GetAction(id);
if (currA.Equals(Agv.ClientAction.None) || currA.Equals(Agv.ClientAction.NeedLeave) || currA.Equals(Agv.ClientAction.NeedEnter))
{
SetStatus(id, shelfId, Agv.ClientAction.NeedLeave);
SetStatus(id, shelfId, Agv.ClientAction.NeedLeave,ClientLevel.High, clientShelf);
return true;
}
return false;
......@@ -165,6 +171,14 @@ namespace OnlineStore.DeviceLibrary
}
return Agv.ClientAction.None;
}
public static Agv.ClientShelf GetShelf(string NodeName)
{
if (shelfMap.ContainsKey(NodeName))
{
return shelfMap[NodeName];
}
return Agv.ClientShelf.None;
}
public static void UpdateAction(string name, Agv.ClientAction action)
{
if (actionMap.ContainsKey(name))
......@@ -176,6 +190,17 @@ namespace OnlineStore.DeviceLibrary
actionMap.Add(name, action);
}
}
public static void UpdateShelf(string name, Agv.ClientShelf action)
{
if (shelfMap.ContainsKey(name))
{
shelfMap[name] = action;
}
else
{
shelfMap.Add(name, action);
}
}
public static void Dispose()
{
try
......
......@@ -94,6 +94,7 @@
<Compile Include="device\IO\HCIOManager.cs" />
<Compile Include="device\RFIDManagercs.cs" />
<Compile Include="duoStore\BoxBean_Camera.cs" />
<Compile Include="duoStore\DUOStoreBean_LineRunMonitor.cs" />
<Compile Include="duoStore\DUOStoreBean_RaiseStation.cs" />
<Compile Include="duoStore\AxisBean.cs" />
<Compile Include="duoStore\BoxBean.cs" />
......
......@@ -64,7 +64,7 @@ namespace OnlineStore.DeviceLibrary
if (String.IsNullOrEmpty(ip).Equals(false))
{
string outValue = readAll.Read(ip);
System.Threading.Thread.Sleep(300);
if (isClear)
{
readAll.Clear(ip);
......
......@@ -265,6 +265,23 @@ namespace OnlineStore.DeviceLibrary
HuichuanLibrary.HCBoardManager.SetAxBacklash(MiddleAxis.Config.GetAxisValue(),Config.MiddleAxis_Reverse_Offset, MiddleAxis.Config.HomeLowSpeed,-1);
LogInfo(MoveInfo.MoveType + ": 完成");
MoveEndP();
if (IOValue(IO_Type.InDoor_Check).Equals(IO_VALUE.HIGH) && IsDebug.Equals(false))
{
LogInfo("发现入口有无信息料");
InOutParam inOutParam = new InOutParam(MoveType.InStore);
inOutParam.InStoreNg = true;
inOutParam.TargetPosition = 1;
inOutParam.moveType = MoveType.InStore;
inOutParam.PlateH = 56;
StoreManager.LoadInoutParam(inOutParam, MoveType.InStore, true, this);
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, inOutParam);
MoveInfo.NextMoveStep(StoreMoveStep.SI_01_InoutToP1);
}
break;
default: break;
}
......
......@@ -79,12 +79,12 @@ namespace OnlineStore.DeviceLibrary
(!runStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动库出错,忙碌或报警中 ,storeStatus=" + runStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
LogUtil.error(Name + " 启动库出错,忙碌或报警中 ,storeStatus=" + runStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
return false;
}
if (IOValue(IO_Type.InDoor_Check).Equals(IO_VALUE.LOW))
if (!AutoInout.autoNext && IOValue(IO_Type.InDoor_Check).Equals(IO_VALUE.LOW))
{
LogUtil.error(Name + " 启动库出错,入口没有检测到料盘, 任务取消");
LogUtil.error(Name + " 启动库出错,入口没有检测到料盘, 任务取消");
StoreManager.cancelPutInTask(Name, param.WareCode);
return true;
}
......@@ -549,11 +549,19 @@ namespace OnlineStore.DeviceLibrary
#endregion
else if (MoveInfo.IsStep(StoreMoveStep.SO_07_FixtureCheck))
{
bool waitLeftStore = false;
if (StoreManager.Store.HasT4Axis && ID == 2 && StoreManager.Store.MoveInfo.MoveParam!=null && StoreManager.Store.MoveInfo.MoveParam.TargetBox==1)
{
if (StoreManager.Store.MoveInfo.MoveStep >= StoreMoveStep.LO_11_BatchAxisDown && StoreManager.Store.MoveInfo.MoveStep <= StoreMoveStep.LO_16_MiddleToP1)
waitLeftStore = true;
}
if (!waitLeftStore) {
MoveInfo.NextMoveStep(StoreMoveStep.SO_08_InoutToP2);
InOutStoreLog(outType + "进出轴到P2 [" + moveP.InOut_P2 + "]");
InoutAxis.AbsMove(MoveInfo, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
ClearTimeoutAlarm("进出轴可以到P2");
}
}
else if (MoveInfo.IsStep(StoreMoveStep.SO_08_InoutToP2))
{
......
......@@ -253,7 +253,7 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
public string LastVisualRfid = "";
//public string LastVisualRfid = "";
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
......@@ -265,13 +265,13 @@ namespace OnlineStore.DeviceLibrary
string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);
if (string.IsNullOrEmpty(LastVisualRfid))
if (string.IsNullOrEmpty(StoreManager.LastVisualRfid))
{
LastVisualRfid = data[ParamDefine.rfid];
StoreManager.LastVisualRfid = data[ParamDefine.rfid];
}
else if (LastVisualRfid != data[ParamDefine.rfid])
else if (StoreManager.LastVisualRfid != data[ParamDefine.rfid])
{
LogUtil.error(Name + $" 上一个工单还未结束LastVisualRfid={LastVisualRfid}, CurrentVisualRfid={data[ParamDefine.rfid]}");
LogUtil.error(Name + $" 上一个工单还未结束LastVisualRfid={StoreManager.LastVisualRfid}, CurrentVisualRfid={data[ParamDefine.rfid]}");
return;
}
bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
......
......@@ -98,7 +98,6 @@ namespace OnlineStore.DeviceLibrary
AgvClient.NodeList.Add(Config.AgvInName);
AgvClient.NodeList.Add(Config.AgvOutName);
IOManager.Init();
CodeManager.LoadConfig();
......@@ -108,12 +107,10 @@ namespace OnlineStore.DeviceLibrary
HasT4Axis = Convert.ToBoolean(ConfigAppSettings.GetValue(Setting_Init.HasT4Axis));
Task.Factory.StartNew(delegate
{
RFIDManager.Open();
IOManager.instance.ConnectionIOList(ioList);
AxisManager.Init();
//AgvClient.Init();
AgvClient.Init();
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
......@@ -186,6 +183,7 @@ namespace OnlineStore.DeviceLibrary
}
LogUtil.info(Name + "开始启动 ,启动时间:" + StartTime.ToString());
IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
RFIDManager.Open();
runStatus = StoreRunStatus.HomeMoving;
StartTime = DateTime.Now;
StartResetMove();
......@@ -279,8 +277,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StoreMoveStep.LR_02_LineRun);
LogUtil.info(Name + "复位 " + MoveInfo.MoveStep + " :流水线转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH, false, 5000);
LineRun("reset", 5);
}
else if (MoveInfo.IsStep(StoreMoveStep.LR_02_LineRun))
......@@ -396,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
T4_InOut_Axis.SuddenStop();
CloseAllAxis();
LineStop();
LineStop("n");
}
public override void StopRun()
{
......@@ -725,11 +722,11 @@ namespace OnlineStore.DeviceLibrary
{
LowProcess = true;
LogUtil.info(Name + "从料架堆积处放一个料架到后端");
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH, false, 30000);
LineRun("shelfout", 30);
//IOMove(IO_Type.Line_Stop3_Buffer, IO_VALUE.HIGH, false, 2000);
if (WaitIo(IO_Type.Line_OutCheck, IO_VALUE.HIGH, 30000, "堆积处放料架到后端"))
{
LineStop();
LineStop("shelfout");
}
LowProcess = false;
});
......@@ -747,7 +744,7 @@ namespace OnlineStore.DeviceLibrary
}
public void OneShelfOutProcess()
{
try
/*try
{
if (IOValue(IO_Type.Line_OutCheck).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.Line_Run).Equals(IO_VALUE.LOW) &&
......@@ -778,20 +775,55 @@ namespace OnlineStore.DeviceLibrary
catch (Exception ex)
{
LogUtil.error(Name + " OneShelfOutProcess 出错:" + ex.ToString());
}*/
//左侧下层需要放个料架
Task.Run(() =>
{
LogUtil.info(Name + "Agv送出一个料架");
LineRun("agvout", 30);
IOMove(IO_Type.Line_Stop4_Out, IO_VALUE.HIGH, false, 1000);
if (WaitIo(IO_Type.Line_OutCheck, IO_VALUE.LOW, 30000, "送出一个料架"))
{
LineRun("agvout",15);
Task.Delay(5*1000);
AgvClient.SetStatus(StoreManager.Config.AgvOutName, "", Agv.ClientAction.FinishLeave);
_ = Task.Run(() => {
Task.Delay(2000);
AgvClient.SetStatus(StoreManager.Config.AgvInName, "", Agv.ClientAction.None);
});
}
});
}
#endregion
Agv.ClientShelf AgvNeedInshelf = Agv.ClientShelf.None;
Agv.ClientShelf AgvNeedOutshelf = Agv.ClientShelf.None;
void IOMinoitor() {
if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW) && AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.None)
if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW) && AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.None
&& MoveInfo.MoveType.Equals(MoveType.None) && BoxMap[1].waitOutStoreList.Count==0 && BoxMap[2].waitOutStoreList.Count == 0)
{
AgvClient.NeedEnter(Config.AgvInName,"");
AgvNeedInshelf = Agv.ClientShelf.Full;
AgvClient.NeedEnter(Config.AgvInName,"", AgvNeedInshelf);
LogUtil.info(Name + "IOMinoitor AgvClient.NeedEnter" + Config.AgvInName+ ",AgvNeedInshelf:" + AgvNeedInshelf);
//AgvNeedInshelf = Agv.ClientShelf.None;
}
if (IOValue(IO_Type.Line_OutCheck).Equals(IO_VALUE.HIGH) && AgvClient.GetAction(Config.AgvOutName) == Agv.ClientAction.None)
{
var rfiddevice = RFIDManager.GetShelfId(Config.Out_Rfid_IP);
var rfid = rfiddevice.NumStr();
AgvClient.NeedLeave(Config.AgvOutName, rfid);
if (AgvNeedOutshelf == Agv.ClientShelf.None) {
if (ConfigAppSettings.GetIntValue(Setting_Init.LastOutShelfType) == 1)
AgvNeedOutshelf = Agv.ClientShelf.Full;
else
AgvNeedOutshelf = Agv.ClientShelf.Empty;
}
AgvClient.NeedLeave(Config.AgvOutName, rfid, AgvNeedOutshelf);
LogUtil.info(Name + $"AgvClient.NeedLeave:{Config.AgvOutName},rfid:{rfid},AgvNeedOutshelf:{AgvNeedOutshelf}");
AgvNeedOutshelf = Agv.ClientShelf.None;
}
else if (IOValue(IO_Type.Line_OutCheck).Equals(IO_VALUE.LOW) && AgvClient.GetAction(Config.AgvOutName) != Agv.ClientAction.MayLeave && AgvClient.GetAction(Config.AgvOutName) != Agv.ClientAction.None) {
AgvClient.SetToNone(Config.AgvOutName);
LogUtil.info(Name + $"AgvClient.SetToNone:{Config.AgvOutName}");
}
}
......@@ -800,7 +832,7 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.Line_OutCheck).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH, false, 4000);
LineRun("releashelf", 4);
IOMove(IO_Type.Line_Stop4_Out, IO_VALUE.HIGH, false, 1000);
LogUtil.info(Name + "料串手动出库,放行区放行");
return true;
......@@ -812,7 +844,7 @@ namespace OnlineStore.DeviceLibrary
&& IOValue(IO_Type.TopCylinder_Down).Equals(IO_VALUE.HIGH)
)
{
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH, false, 3000);
LineRun("releashelf", 4);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 2000);
LogUtil.info(Name + "料串手动出库, 工作区放行");
return true;
......@@ -839,7 +871,7 @@ namespace OnlineStore.DeviceLibrary
{
move.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_Run, IO_VALUE.HIGH));
}
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH);
LineRun("n", 999);
}
public void LineStop(StoreMoveInfo move=null )
......@@ -848,7 +880,7 @@ namespace OnlineStore.DeviceLibrary
{
move.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_Run, IO_VALUE.LOW));
}
IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
LineStop("n");
}
public void OpenGate(StoreMoveInfo move = null) {
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace OnlineStore.DeviceLibrary
{
partial class DUOStoreBean
{
Timer lineTimer = null;
Dictionary<string, DateTime> linrunlist = new Dictionary<string, DateTime>();
void LineInit() {
if (lineTimer == null) {
lineTimer = new Timer(300);
lineTimer.Elapsed += LineTimer_Elapsed;
lineTimer.Start();
GC.KeepAlive(lineTimer);
}
}
private void LineTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (canStopLine(out _))
IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
}
/// <summary>
/// 控制线体运转
/// </summary>
/// <param name="id">需求方标识</param>
/// <param name="seconds">秒数</param>
void LineRun(string id, int seconds) {
LineInit();
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH);
lock (linrunlist)
{
if (!string.IsNullOrEmpty(id) && seconds > 0)
{
if (linrunlist.ContainsKey(id))
linrunlist[id] = DateTime.Now.AddSeconds(seconds);
else
{
linrunlist.Add(id, DateTime.Now.AddSeconds(seconds));
}
LogUtil.info(Name + $" {id} 请求链条运行 {seconds}秒.");
}
}
}
void LineStop(string id = "") {
lock (linrunlist)
{
if (!string.IsNullOrEmpty(id))
{
if (linrunlist.ContainsKey(id))
linrunlist.Remove(id);
LogUtil.info(Name + $" {id} 请求立刻停止线体.");
}
}
if (!canStopLine(out string msg))
LogUtil.info(Name + $" {Name}");
// IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
}
bool canStopLine(out string msg)
{
msg = "";
bool canStop = true;
lock (linrunlist)
{
foreach (var x in linrunlist.ToList()) {
if (x.Value > DateTime.Now)
{
canStop = false;
msg = Name + $" {x.Key} 不允许停止线体 需求停止时间 {x.Value.ToString()}.";
//LogUtil.info(Name + $" {x.Key} 不允许停止线体 需求停止时间 {x.Value.ToString()}.");
}
else {
LogUtil.info(Name + $" {x.Key} 请求时间已过期,删除.");
linrunlist.Remove(x.Key);
}
}
}
return canStop;
}
}
}
......@@ -113,6 +113,14 @@ namespace OnlineStore.DeviceLibrary
}
}
}
if (IsStart && IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW) && (AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.None || AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.NeedEnter) && AgvClient.GetShelf(Config.AgvInName) != Agv.ClientShelf.Empty)
{
AgvNeedInshelf= Agv.ClientShelf.Empty;
AgvClient.SetToNone(Config.AgvInName);
AgvClient.NeedEnter(Config.AgvInName, "", AgvNeedInshelf);
LogUtil.info(Name + "CanOut AgvClient.NeedEnter" + Config.AgvInName + ",AgvNeedInshelf:" + AgvNeedInshelf);
//AgvNeedInshelf = Agv.ClientShelf.None;
}
return false;
}
......@@ -173,6 +181,8 @@ namespace OnlineStore.DeviceLibrary
//可以开始出库啦
MoveInfo.NextMoveStep(StoreMoveStep.LO_11_BatchAxisDown);
int height = outParam.PlateH + 4;
if (outParam.PlateH >= 24)
height += 6;
int targetPosition = T1_BatchAxis.GetAclPosition() - height * Config.BatchAxis_ChangeValue;
if (targetPosition < Config.BatchAxis_P1)
{
......@@ -238,7 +248,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
InOutStoreLog("料架出库:料架准备完成,等待料盘出库");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
T1_BatchAxis.AbsMove(MoveInfo, T1_BatchAxis.GetAclPosition() - Config.BatchAxis_ChangeValue * 10, Config.BatchAxis_P1Speed);
T1_BatchAxis.AbsMove(MoveInfo, T1_BatchAxis.GetAclPosition() - Config.BatchAxis_ChangeValue * 40, Config.BatchAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_09_WaitOut))
{
......@@ -249,15 +259,15 @@ namespace OnlineStore.DeviceLibrary
//}
//else
{
if (StoreManager.unfinishedTaskCount(Name, CurrShelfNum) > 0)
if (outStoreCount ==0 || StoreManager.unfinishedTaskCount(Name, CurrShelfNum) > 0)
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
}
else {
InOutStoreLog("料架出库:工单已结束,已出库盘数[" + outStoreCount + "],开始送出料架");
StoreManager.Store.BoxMap[1].LastVisualRfid = "";
StoreManager.Store.BoxMap[2].LastVisualRfid = "";
StoreManager.LastVisualRfid = "";
outStoreCount = 0;
LO_31_BatchAxisToP1();
}
//InOutStoreLog(" 等待料盘出库");
......@@ -422,14 +432,11 @@ namespace OnlineStore.DeviceLibrary
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
int currPositon = T1_BatchAxis.GetAclPosition();
int tp = currPositon - Config.BatchAxis_ChangeValue * 40;
int tp = currPositon - Config.BatchAxis_ChangeValue * 80;
if (tp <= Config.BatchAxis_P1)
{
LO_31_BatchAxisToP1(" 提升轴位置:" + currPositon + ",料架已满,需要送出料架");
}
else if (OutstoreEndSendShelf)
{
LO_31_BatchAxisToP1(" 提升轴位置:" + currPositon + ",OutstoreEndSendShelf=true,需要送出料架");
}
else
{
......@@ -471,31 +478,35 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsStep(StoreMoveStep.LO_33_TopCylinderDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_34_WorkStopDown);
InOutStoreLog("送出料架:上料阻挡下降1秒,流水线开始转动");
InOutStoreLog("送出料架:流水线开始转动");
UpdateShelfNum(CurrShelfNum, -1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
ConfigAppSettings.SaveValue(Setting_Init.LastOutShelfType, 1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 1500);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_34_WorkStopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_35_WaitShelfGo);
InOutStoreLog("送出料架:等待上料无料架");
InOutStoreLog("送出料架:上料阻挡下降2秒,等待上料无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WaitCheck, IO_VALUE.LOW));
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 2000);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_36_LineRun);
InOutStoreLog("送出料架:流水线再转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3500));
LineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_OutCheck, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
//var rfiddevice = RFIDManager.GetShelfId(Config.Out_Rfid_IP);
//var rfid = rfiddevice.NumStr();
AgvNeedOutshelf = Agv.ClientShelf.Full;
InOutStoreLog($"送出料架:流水线停止转动 AgvNeedOutshelf:{AgvNeedOutshelf}");
LineStop(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_37_LineStop))
......@@ -558,6 +569,10 @@ namespace OnlineStore.DeviceLibrary
bool result = await ShelfEnterProcess();
if (result) {
AgvClient.SetStatus(StoreManager.Config.AgvInName, "", Agv.ClientAction.FinishEnter);
_=Task.Run(() => {
Task.Delay(2000);
AgvClient.SetStatus(StoreManager.Config.AgvInName, "", Agv.ClientAction.None);
});
}
}
private Task<bool> ShelfEnterProcess()
......@@ -574,7 +589,7 @@ namespace OnlineStore.DeviceLibrary
LineRun(null);
//等待进料检测信号
//bool result = WaitIo(IO_Type.Line_InCheck, IO_VALUE.LOW, 10000);
result = WaitIo(IO_Type.Line_WaitCheck, IO_VALUE.HIGH, 10000);
result = WaitIo(IO_Type.Line_WaitCheck, IO_VALUE.HIGH, 50000);
}
catch (Exception ex)
{
......@@ -583,7 +598,7 @@ namespace OnlineStore.DeviceLibrary
finally
{
InShelfInProcess = false;
LineStop(null);
LineStop("n");
}
return result;
}));
......@@ -624,7 +639,7 @@ namespace OnlineStore.DeviceLibrary
{
if (!InShelfInProcess)
{
LineStop(null);
LineStop("n");
}
MoveEndP();
......@@ -670,7 +685,6 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
LI_31_BatchAxisToP1();
}
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
......@@ -874,6 +888,8 @@ namespace OnlineStore.DeviceLibrary
if (HasT4Axis) {
if (LastWidth >= 13)
box = 2;
else
box = 1;
}
LastPosParam.TargetBox = box;
LastPosParam.TargetPosition = 1;
......@@ -1074,6 +1090,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown_3))
{
InOutStation_Stop(1000);
/*
InOutStoreLog($"送出料架:BoxMap[1]={BoxMap[1].storeStatus},BoxMap[2]={BoxMap[2].storeStatus}");
//如果有等待出库的料先出库
if (BoxMap[1].storeStatus == StoreStatus.OutStoreExecute || BoxMap[1].storeStatus == StoreStatus.OutStoreBoxEnd
......@@ -1089,11 +1106,12 @@ namespace OnlineStore.DeviceLibrary
}
}
//判断是否需要送出料架,如果入口和等待区无料架,暂不送出
else if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || InstoreEndSendShelf)
else */if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || InstoreEndSendShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_34_WorkStopDown);
InOutStoreLog("送出料架[" + InstoreEndSendShelf + "]:上料阻挡下降1秒,流水线开始转动");
UpdateShelfNum(CurrShelfNum, -1);
ConfigAppSettings.SaveValue(Setting_Init.LastOutShelfType,0);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 2000);
......@@ -1125,6 +1143,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StoreMoveStep.LI_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
LineStop(MoveInfo);
AgvNeedOutshelf = Agv.ClientShelf.Empty;
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_37_LineStop))
{
......@@ -1230,7 +1249,7 @@ namespace OnlineStore.DeviceLibrary
InOutStoreLog("料盘移栽 :开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitScanCode());
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
try
{
scanTask = Task.Factory.StartNew(delegate
......@@ -1260,6 +1279,7 @@ namespace OnlineStore.DeviceLibrary
if (ShelfNoTray.Equals(false))
{
InOutStoreLog("料盘移栽 : ,预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
//还有料盘,直接扫码
YuCodeList = new List<string>();
List<string> bijiaoList = new List<string>(LastCodeList);
......@@ -1328,7 +1348,7 @@ namespace OnlineStore.DeviceLibrary
//无料盘
ShelfNoTray = true;
UpdateShelfNum(CurrShelfNum, 0);
InOutStoreLog($"检测料架为空:BoxMap[1]={BoxMap[1].storeStatus},BoxMap[2]={BoxMap[2].storeStatus}");
InOutStoreLog($"检测料架为空:BoxMap[1]={BoxMap[1].waitOutStoreList.Count},BoxMap[2]={BoxMap[2].waitOutStoreList.Count}");
//如果有等待出库的料先出库
if (BoxMap[1].waitOutStoreList.Count>0 || BoxMap[2].waitOutStoreList.Count > 0)
{
......
......@@ -20,6 +20,9 @@ namespace OnlineStore.DeviceLibrary
public static Dictionary<int, BaseConfig> allConfigMap = null;
private static bool isInit = false;
public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals("");
public static string LastVisualRfid = "";
public StoreManager()
{
}
......@@ -105,6 +108,7 @@ namespace OnlineStore.DeviceLibrary
CSVPositionReader<ACBoxPosition>.AddCSVFile(positionConfigFile);
}
CSVPositionReader<ACBoxPosition>.AddCSVFile(Path.Combine(appPath, @"StoreConfig\FixPositions.csv"));
AgvClient.Init();
LogUtil.info("加载料仓完成!");
}
......@@ -513,7 +517,7 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error(deviceName + " " + ex.ToString());
}
return 99999;
return 0;
}
//public static void SendPosToStoreCheck(string deviceName, InOutParam param)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!