Commit b07881a1 LN

1

1 个父辈 5f25134d
......@@ -19,6 +19,8 @@
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnNGlineStop = new System.Windows.Forms.Button();
this.btnNgLine = new System.Windows.Forms.Button();
this.btnDoorStop = new System.Windows.Forms.Button();
this.btnBlow = new System.Windows.Forms.Button();
this.btnStoreOn = new System.Windows.Forms.Button();
......@@ -48,8 +50,7 @@
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.btnNGlineStop = new System.Windows.Forms.Button();
this.btnNgLine = new System.Windows.Forms.Button();
this.btnLineBack = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
......@@ -75,6 +76,7 @@
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.btnLineBack);
this.groupBox1.Controls.Add(this.btnNGlineStop);
this.groupBox1.Controls.Add(this.btnNgLine);
this.groupBox1.Controls.Add(this.btnDoorStop);
......@@ -110,6 +112,30 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DO写入";
//
// btnNGlineStop
//
this.btnNGlineStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNGlineStop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNGlineStop.Location = new System.Drawing.Point(175, 210);
this.btnNGlineStop.Name = "btnNGlineStop";
this.btnNGlineStop.Size = new System.Drawing.Size(125, 34);
this.btnNGlineStop.TabIndex = 298;
this.btnNGlineStop.Text = "NG线体停止";
this.btnNGlineStop.UseVisualStyleBackColor = false;
this.btnNGlineStop.Click += new System.EventHandler(this.btnNGlineStop_Click);
//
// btnNgLine
//
this.btnNgLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNgLine.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNgLine.Location = new System.Drawing.Point(12, 210);
this.btnNgLine.Name = "btnNgLine";
this.btnNgLine.Size = new System.Drawing.Size(125, 34);
this.btnNgLine.TabIndex = 297;
this.btnNgLine.Text = "NG线体运转";
this.btnNgLine.UseVisualStyleBackColor = false;
this.btnNgLine.Click += new System.EventHandler(this.btnNgLine_Click);
//
// btnDoorStop
//
this.btnDoorStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
......@@ -150,11 +176,11 @@
//
this.btnStopMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnStopMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnStopMove.Location = new System.Drawing.Point(175, 429);
this.btnStopMove.Location = new System.Drawing.Point(208, 428);
this.btnStopMove.Name = "btnStopMove";
this.btnStopMove.Size = new System.Drawing.Size(125, 34);
this.btnStopMove.Size = new System.Drawing.Size(92, 34);
this.btnStopMove.TabIndex = 292;
this.btnStopMove.Text = "线体停止转动";
this.btnStopMove.Text = "线体停止";
this.btnStopMove.UseVisualStyleBackColor = false;
this.btnStopMove.Click += new System.EventHandler(this.btnStopMove_Click);
//
......@@ -162,9 +188,9 @@
//
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button4.Location = new System.Drawing.Point(12, 429);
this.button4.Location = new System.Drawing.Point(12, 428);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(125, 34);
this.button4.Size = new System.Drawing.Size(92, 34);
this.button4.TabIndex = 291;
this.button4.Text = "线体正转";
this.button4.UseVisualStyleBackColor = false;
......@@ -463,29 +489,17 @@
this.tableLayoutPanel1.Size = new System.Drawing.Size(218, 570);
this.tableLayoutPanel1.TabIndex = 102;
//
// btnNGlineStop
// btnLineBack
//
this.btnNGlineStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNGlineStop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNGlineStop.Location = new System.Drawing.Point(175, 210);
this.btnNGlineStop.Name = "btnNGlineStop";
this.btnNGlineStop.Size = new System.Drawing.Size(125, 34);
this.btnNGlineStop.TabIndex = 298;
this.btnNGlineStop.Text = "NG线体停止";
this.btnNGlineStop.UseVisualStyleBackColor = false;
this.btnNGlineStop.Click += new System.EventHandler(this.btnNGlineStop_Click);
//
// btnNgLine
//
this.btnNgLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNgLine.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNgLine.Location = new System.Drawing.Point(12, 210);
this.btnNgLine.Name = "btnNgLine";
this.btnNgLine.Size = new System.Drawing.Size(125, 34);
this.btnNgLine.TabIndex = 297;
this.btnNgLine.Text = "NG线体运转";
this.btnNgLine.UseVisualStyleBackColor = false;
this.btnNgLine.Click += new System.EventHandler(this.btnNgLine_Click);
this.btnLineBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLineBack.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLineBack.Location = new System.Drawing.Point(110, 428);
this.btnLineBack.Name = "btnLineBack";
this.btnLineBack.Size = new System.Drawing.Size(92, 34);
this.btnLineBack.TabIndex = 299;
this.btnLineBack.Text = "线体反转";
this.btnLineBack.UseVisualStyleBackColor = false;
this.btnLineBack.Click += new System.EventHandler(this.btnLineBack_Click);
//
// FrmIOStatus
//
......@@ -547,6 +561,7 @@
private System.Windows.Forms.Button btnDoorStop;
private System.Windows.Forms.Button btnNGlineStop;
private System.Windows.Forms.Button btnNgLine;
private System.Windows.Forms.Button btnLineBack;
}
}
......@@ -296,13 +296,15 @@ namespace OnlineStore.ACPackingStore
private void button4_Click(object sender, EventArgs e)
{
BtnMove(button4, "线体正转", "线体反转", IO_Type.Line_Run, IO_Type.Line_BackRun);
//BtnMove(button4, "线体正转", "线体反转", IO_Type.Line_Run, IO_Type.Line_BackRun);
boxBean.LineRun();
}
private void btnStopMove_Click(object sender, EventArgs e)
{
boxBean.IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
boxBean.IOMove(IO_Type.Line_BackRun, IO_VALUE.LOW);
//boxBean.IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
//boxBean.IOMove(IO_Type.Line_BackRun, IO_VALUE.LOW);
boxBean.LineStop();
}
private void btnStoreOn_Click(object sender, EventArgs e)
......@@ -358,5 +360,10 @@ namespace OnlineStore.ACPackingStore
{
boxBean.IOMove(IO_Type.NGLine_Run, IO_VALUE.LOW);
}
private void btnLineBack_Click(object sender, EventArgs e)
{
boxBean.LineBackRun();
}
}
}
......@@ -798,6 +798,7 @@ namespace OnlineStore.DeviceLibrary
//判断报警状态
return isInAlarm;
}
/// <summary>
/// 停止所有运行
/// </summary>
......@@ -827,258 +828,7 @@ namespace OnlineStore.DeviceLibrary
WarnMsg = "";
}
}
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string CodeMsg = "";
private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
if (isInProcess)
{
return;
}
isInProcess = true;
//HumitureController.QueryData();
humBean.HumidityProcess(this);
if (StoreManager.IsConnectServer)
{
try
{
SendLineStatus();
}
catch (Exception ex)
{
LogUtil.error(Name + "定时SendLineStatus出错:" + ex.ToString());
}
}
isInProcess = false;
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
lineOperation.status = (int)StoreStatus.Warning;
lineOperation.msg = WarnMsg;
}
lineOperation.status = (int)StoreStatus.StoreOnline;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = 1;
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
if (WarnMsg.Equals(""))
{
boxStatus.msg = CodeMsg;
lineOperation.msg = CodeMsg;
}
CodeMsg = "";
//WarnMsg = "";
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
}
else if (!lastPosId.Equals(""))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
boxStatus.status = (int)lastPosIdStatus;
if (lastPosId != "")
{
LogUtil.info("给服务器发送出入库完成消息:" + Name + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
}
lastPosId = "";
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
HumitureParam param = humBean.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
lineOperation.boxStatus.Add(1, boxStatus);
if (!alarmType.Equals(StoreAlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
return lineOperation;
}
public void SendLineStatus()
{
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (humBean.NeedGetTem())
{
lineOperation.op = 5;
LogInfo("没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op);
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
// ReviceInStoreProcess("", resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
char splitChar = '|';
string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);
bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
bool cutReel = FormUtil.GetBoolData(data, ParamDefine.cutReel);
bool smallReel = FormUtil.GetBoolData(data, ParamDefine.smallReel);
string rfid = data.ContainsKey(ParamDefine.rfid) ? data[ParamDefine.rfid] : "";
int rfidLoc = FormUtil.GetIntData(data, ParamDefine.rfidLoc);
string barcode = data.ContainsKey(ParamDefine.barcode) ? data[ParamDefine.barcode] : "";
//urgentReel: true 表示紧急料,需要出到料串上
//cutReel: true 表示分盘料,需要出到料串上
//smallReel: true 小料(7x8),放置到小料架上
//rfid: 分配的料架RFID
//rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
string dataStr = JsonHelper.SerializeObject(data);
LogUtil.info("收到服务器出库消息:【" + dataStr + "】");
int index = -1;
foreach (string posId in posIdArray)
{
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
string[] posArray = posId.Split('#');
//if (posArray.Length != 2)
//{
// WarnMsg = Name + "出库格式错误:库位号【" + posId + "】";
// LogUtil.error(Name + "收到服务器出库命令:库位号【" + posId + "】格式错误");
// continue;
//}
InOutParam inoutParam = new InOutParam(barcode, posId, "", plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = Name + "未找到库位:【" + inoutParam.ToStr() + "】";
LogUtil.error(WarnMsg);
continue;
}
try
{
//判断是否接收过此库位的出库信息
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveParam.PosID.Equals(posId))
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,正在【" + posId + "】出库中");
continue;
}
//判断排队列表中是否已存在
List<InOutParam> reviceList = new List<InOutParam>(waitOutStoreList);
reviceList = (from m in reviceList where m.PosID.Equals(posId) select m).ToList<InOutParam>();
if (reviceList.Count > 0)
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,排队列表中已存在【" + reviceList[0].ToStr() + "】");
continue;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "验证出库【" + inoutParam.ToStr() + "】是否重复出错:" + ex.ToString());
}
string shelfPosID = "";
if (inoutParam.rfidLoc > 0 && ShelfPosList.Count >= inoutParam.rfidLoc)
{
shelfPosID = ShelfPosList[inoutParam.rfidLoc - 1];
inoutParam.NeedEnterShelf = false;
inoutParam.NeedOutShelf = false;
inoutParam.ShelfPosID = shelfPosID;
}
else
{
bool hasShelf = EmprtShelfList.TryDequeue(out shelfPosID);
if (hasShelf)
{
inoutParam.NeedEnterShelf = false;
inoutParam.NeedOutShelf = false;
inoutParam.ShelfPosID = shelfPosID;
}
else
{
inoutParam.NeedEnterShelf = true;
inoutParam.NeedOutShelf = false;
LogInfo(Name + "执行出库【" + inoutParam.ToStr() + "】,没有空料架,需要使用新料架");
}
}
StartExecuctOut(inoutParam);
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogInfo(Name + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
#endregion
public void LineRun()
{
IOMove(IO_Type.Line_BackRun, IO_VALUE.LOW);
......
......@@ -277,10 +277,11 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_02_DoorOpen);
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Close, IO_Type.EntranceDoor_Open);
DoorBean.StartOpen(MoveInfo);
}
}
private void UpdateShelfId()
{
//读取RFID
......@@ -631,359 +632,6 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 扫码获取库位
private string ProcessCode()
{
string message = "";
string spiltStr = "##";
string codeSize = LastWidth + "x" + LastHeight;
foreach (string str in LastScanCodes)
{
if (str.Trim().Equals(""))
{
continue;
}
string code = "=1+0x0-" + codeSize + "=" + str.Trim();
if (!String.IsNullOrEmpty(code))
{
message = message + code + spiltStr;
}
}
return message;
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
private bool GetPosIdByCode()
{
try
{
string message = ProcessCode();
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
string plateW = data[ParamDefine.plateW];
string plateH = data[ParamDefine.plateH];
string[] posArray = posId.Split('#');
if (!(posArray.Length == 2))
{
WarnMsg = Name + "入库库位格式错误:二维码【" + message + "】库位【" + posId + "】";
LogUtil.error(Name + "服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
return false;
}
int storeId = int.Parse(posArray[0]);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return false;
}
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数 , 开始入库!");
int p3 = ComTargetPosition+ Config.CompAxis_P3_P2_Value;
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, ComTargetPosition,p3);
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
return false;
}
#endregion
#region 料架进出料仓处理:出入库模块共用
private void BI_04_WaitTakeSingle(string moveName)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_04_WaitTakeSingle);
InOutStoreLog(moveName + MoveInfo.SLog + " 线体正转,等待LineIn_Check=Low, 信号LineTake_Check=High");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
}
private void ShelfEnterProcess()
{
string moveName = "料架入库";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "空料架进入";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_01_ReadyShelf))
{
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else
{
// MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,小车已到达,打开入料口移门");
MoveInfo.NextMoveStep(StoreMoveStep.BI_02_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_02_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_03_LineRun);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,线体正转,等待LineIn_Check信号");
AgvClient.MayEnter(Config.AgvNodeName);
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
BI_04_WaitTakeSingle(moveName);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_05_LineStop);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.FinishEnter,取料位检测到信号,停止线体正转");
LineStop();
AgvClient.FinishEnter(Config.AgvNodeName);
if (!instoreShelf)
{
EmprtShelfList = new System.Collections.Concurrent.ConcurrentQueue<string>(ShelfPosList);
if (MoveInfo.MoveParam.ShelfPosID.Equals(""))
{
string shelfPosId = "";
bool result = EmprtShelfList.TryDequeue(out shelfPosId);
if (result)
{
MoveInfo.MoveParam.UpdateShelfPosId(shelfPosId);
InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,设置料架位置:" + MoveInfo.MoveParam.ShelfPosID);
}
else
{
waitOutStoreList.Enqueue(MoveInfo.MoveParam);
InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,获取料架位置失败!结束出库,并将" + MoveInfo.MoveParam.ToStr() + "放入等待列表");
MoveEndToRuningStatus();
}
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_05_LineStop))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
InOutStoreLog(moveName + MoveInfo.SLog + "入料口移门关闭");
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Open, IO_Type.EntranceDoor_Close);
DoorBean.StartClose(MoveInfo);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_06_DoorClose))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_07_LineRun);
InOutStoreLog(moveName + MoveInfo.SLog + "继续转动1500");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_07_LineRun))
{
LineStop();
MoveInfo.NextMoveStep(StoreMoveStep.BI_08_LocationUp);
InOutStoreLog(moveName + MoveInfo.SLog + "线体停止转动,定位装置上升,读取料架编号");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
UpdateShelfId();
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进入库位中, 进出轴至P3(库位取放料点) ");
ACAxisMove(Config.InOut_Axis, MoveInfo.MoveParam.MoveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_08_LocationUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_09_TopCylinderUp);
InOutStoreLog(moveName + MoveInfo.SLog + "顶升装置上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 拿起物品,升降轴至P6(库位出料缓冲点),压紧轴至P2(压紧点) ");
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_09_TopCylinderUp))
{
if (instoreShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog(moveName + MoveInfo.SLog + "开始循环从第一个空位逐个取料盘,扫码入库");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_06_BagDeviceBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子从库位返回,进出轴至P1(待机点) ");
//ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
//把库位的物品放到取到叉子上之后是出仓完成
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.OutStoreBoxEnd;
}
}
}
private void StartShelfOut()
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_01_TopCylinder_Down);
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
InOutStoreLog("送出出库料架:顶升气缸下降");
}
else
{
InOutStoreLog("送出空料架:顶升气缸下降");
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private void ShelfOutProcess()
{
string moveName = "送出空料架";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "送出出库料架";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_01_TopCylinder_Down))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_02_LocatinCylinder_Down);
InOutStoreLog(moveName + MoveInfo.SLog + " :定位气缸下降");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_02_LocatinCylinder_Down))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_03_DoorOpen);
InOutStoreLog(moveName + MoveInfo.SLog + ":打开仓门,调用AgvClient.ReadyEmpty,等待Agv小车到达");
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Close, IO_Type.EntranceDoor_Open);
DoorBean.StartOpen(MoveInfo);
AgvClient.ReadyEmpty(Config.AgvNodeName);
//等待小车到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.Arrive));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_LineBack);
if (instoreShelf)
{
InOutStoreLog(moveName + MoveInfo.SLog + ":调用AgvClient.SendRFID【" + LastShelfData.ToData() + "】,调用AgvClient.MayOut,线体开始反转");
//TODO AGV到达,发送料架信息,是否需要重新读取?
AgvClient.SendRFID(Config.AgvNodeName, LastShelfData.ToData());
}
else
{
InOutStoreLog(moveName + MoveInfo.SLog + ": 调用AgvClient.MayOut,线体开始反转");
}
AgvClient.MayOut(Config.AgvNodeName);
LineBackRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_04_LineBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_05_WaitInLineSingle);
InOutStoreLog(moveName + MoveInfo.SLog + ":等待取料工位无信号,入料口有信号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_05_WaitInLineSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_WaitTime);
InOutStoreLog(moveName + MoveInfo.SLog + ":再转动300时间,同时等待收到FinishOut");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
//等到小车离开
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.FinishOut));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_06_WaitTime))
{
//结束
MoveEndToRuningStatus();
EmprtShelfList = new ConcurrentQueue<string>();
InOutStoreLog(moveName + MoveInfo.SLog + ":停止转动,料架入料结束");
LineStop();
}
}
#endregion
#region 压紧轴压紧处理
private System.Timers.Timer axisCheckTimer = null;
......@@ -1267,55 +915,5 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region AGV
internal bool ProcessAGVAction(string name, Asa.Actions action)
{
string logN = name + "收到调度【" + name + "】=【" + action + "】";
//状态处理
if (action.Equals(Asa.Actions.Usable))
{
//判断入口是否可用:入口无料架,缓冲工位无料架,不在入料架处理中
bool usable = (storeRunStatus.Equals(StoreRunStatus.Runing) &&
waitOutStoreList.Count<=0&&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
alarmType.Equals(StoreAlarmType.None)
&& IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW)
&& IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW));
LogUtil.info(logN + ":" + usable);
return usable;
}
else if (action.Equals(Asa.Actions.Arrive))
{
//出库处理中不处理
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
return true;
}
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW))
{
LogUtil.info(logN + " ,未检测到:LineIn_Check,不处理");
return false;
}
//小车到达,开始处理
if (storeRunStatus.Equals(StoreRunStatus.Runing) &&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
StartShelfInStore();
return true;
}
}
else
{
LogUtil.info(name + logN + " ,未找到相关处理");
}
return false;
}
#endregion
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class AC_BOX_Bean
{
#region 料架进出料仓处理:出入库模块共用
private void BI_04_WaitTakeSingle(string moveName)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_04_WaitTakeSingle);
InOutStoreLog(moveName + MoveInfo.SLog + " 线体正转,等待LineIn_Check=Low, 信号LineTake_Check=High");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
}
private void ShelfEnterProcess()
{
string moveName = "料架入库";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "空料架进入";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_01_ReadyShelf))
{
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else
{
// MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,小车已到达,打开入料口移门");
MoveInfo.NextMoveStep(StoreMoveStep.BI_02_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_02_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_03_LineRun);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,线体正转,等待LineIn_Check信号");
AgvClient.MayEnter(Config.AgvNodeName);
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
BI_04_WaitTakeSingle(moveName);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_05_LineStop);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.FinishEnter,取料位检测到信号,停止线体正转");
LineStop();
AgvClient.FinishEnter(Config.AgvNodeName);
if (!instoreShelf)
{
EmprtShelfList = new System.Collections.Concurrent.ConcurrentQueue<string>(ShelfPosList);
if (MoveInfo.MoveParam.ShelfPosID.Equals(""))
{
string shelfPosId = "";
bool result = EmprtShelfList.TryDequeue(out shelfPosId);
if (result)
{
MoveInfo.MoveParam.UpdateShelfPosId(shelfPosId);
InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,设置料架位置:" + MoveInfo.MoveParam.ShelfPosID);
}
else
{
waitOutStoreList.Enqueue(MoveInfo.MoveParam);
InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,获取料架位置失败!结束出库,并将" + MoveInfo.MoveParam.ToStr() + "放入等待列表");
MoveEndToRuningStatus();
}
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_05_LineStop))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
InOutStoreLog(moveName + MoveInfo.SLog + "入料口移门关闭");
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Open, IO_Type.EntranceDoor_Close);
DoorBean.StartClose(MoveInfo);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_06_DoorClose))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_07_LineRun);
InOutStoreLog(moveName + MoveInfo.SLog + "继续转动1500");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_07_LineRun))
{
LineStop();
MoveInfo.NextMoveStep(StoreMoveStep.BI_08_LocationUp);
InOutStoreLog(moveName + MoveInfo.SLog + "线体停止转动,定位装置上升,读取料架编号");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
UpdateShelfId();
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进入库位中, 进出轴至P3(库位取放料点) ");
ACAxisMove(Config.InOut_Axis, MoveInfo.MoveParam.MoveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_08_LocationUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_09_TopCylinderUp);
InOutStoreLog(moveName + MoveInfo.SLog + "顶升装置上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 拿起物品,升降轴至P6(库位出料缓冲点),压紧轴至P2(压紧点) ");
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_09_TopCylinderUp))
{
if (instoreShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog(moveName + MoveInfo.SLog + "开始循环从第一个空位逐个取料盘,扫码入库");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_06_BagDeviceBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子从库位返回,进出轴至P1(待机点) ");
//ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
//把库位的物品放到取到叉子上之后是出仓完成
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.OutStoreBoxEnd;
}
}
}
private void StartShelfOut()
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_01_TopCylinder_Down);
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
InOutStoreLog("送出出库料架:顶升气缸下降");
}
else
{
InOutStoreLog("送出空料架:顶升气缸下降");
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private void ShelfOutProcess()
{
string moveName = "送出空料架";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "送出出库料架";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_01_TopCylinder_Down))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_02_LocatinCylinder_Down);
InOutStoreLog(moveName + MoveInfo.SLog + " :定位气缸下降");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_02_LocatinCylinder_Down))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_03_DoorOpen);
InOutStoreLog(moveName + MoveInfo.SLog + ":打开入料口移门");
DoorBean.StartOpen(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_ReadyEmpty);
InOutStoreLog(moveName + MoveInfo.SLog + ":调用AgvClient.ReadyEmpty,等待Agv小车到达");
AgvClient.ReadyEmpty(Config.AgvNodeName);
//等待小车到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.Arrive));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_04_ReadyEmpty))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_05_LineBackRun);
if (instoreShelf)
{
InOutStoreLog(moveName + MoveInfo.SLog + ":调用AgvClient.SendRFID【" + LastShelfData.ToData() + "】,调用AgvClient.MayOut,线体开始反转");
//TODO AGV到达,发送料架信息,是否需要重新读取?
AgvClient.SendRFID(Config.AgvNodeName, LastShelfData.ToData());
}
else
{
InOutStoreLog(moveName + MoveInfo.SLog + ": 调用AgvClient.MayOut,线体开始反转");
}
AgvClient.MayOut(Config.AgvNodeName);
LineBackRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_05_LineBackRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_WaitInLineSingle);
InOutStoreLog(moveName + MoveInfo.SLog + ":等待取料工位无信号,入料口有信号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_06_WaitInLineSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_07_WaitTime);
InOutStoreLog(moveName + MoveInfo.SLog + ":再转动3000时间,同时等待收到FinishOut");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
//等到小车离开
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.FinishOut));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_07_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_08_WaitAGVLeave);
InOutStoreLog(moveName + MoveInfo.SLog + ": ,同时等待 AGV离开,最多等待5000");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.FinishOut));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitAGVLeave))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_09_CloseDoor);
InOutStoreLog(moveName + MoveInfo.SLog + ":停止线体转动,关闭仓门");
LineStop();
DoorBean.StartClose(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_09_CloseDoor))
{
//结束
MoveEndToRuningStatus();
EmprtShelfList = new ConcurrentQueue<string>();
InOutStoreLog(moveName + MoveInfo.SLog + ":停止转动,送出料架结束");
}
}
#endregion
#region AGV
internal bool ProcessAGVAction(string name, Asa.Actions action)
{
string logN = name + "收到调度【" + name + "】=【" + action + "】";
//状态处理
if (action.Equals(Asa.Actions.Usable))
{
//判断入口是否可用:入口无料架,缓冲工位无料架,不在入料架处理中
bool usable = (storeRunStatus.Equals(StoreRunStatus.Runing) &&
waitOutStoreList.Count <= 0 &&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
alarmType.Equals(StoreAlarmType.None)
&& IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW)
&& IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW));
LogUtil.info(logN + ":" + usable);
return usable;
}
else if (action.Equals(Asa.Actions.Arrive))
{
//出库处理中不处理
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
return true;
}
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW))
{
LogUtil.info(logN + " ,未检测到:LineIn_Check,不处理");
return false;
}
//小车到达,开始处理
if (storeRunStatus.Equals(StoreRunStatus.Runing) &&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
StartShelfInStore();
return true;
}
}
else
{
LogUtil.info(name + logN + " ,未找到相关处理");
}
return false;
}
#endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string CodeMsg = "";
private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
if (isInProcess)
{
return;
}
isInProcess = true;
//HumitureController.QueryData();
humBean.HumidityProcess(this);
if (StoreManager.IsConnectServer)
{
try
{
SendLineStatus();
}
catch (Exception ex)
{
LogUtil.error(Name + "定时SendLineStatus出错:" + ex.ToString());
}
}
isInProcess = false;
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
lineOperation.status = (int)StoreStatus.Warning;
lineOperation.msg = WarnMsg;
}
lineOperation.status = (int)StoreStatus.StoreOnline;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = 1;
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
if (WarnMsg.Equals(""))
{
boxStatus.msg = CodeMsg;
lineOperation.msg = CodeMsg;
}
CodeMsg = "";
//WarnMsg = "";
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
}
else if (!lastPosId.Equals(""))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
boxStatus.status = (int)lastPosIdStatus;
if (lastPosId != "")
{
LogUtil.info("给服务器发送出入库完成消息:" + Name + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
}
lastPosId = "";
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
HumitureParam param = humBean.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
lineOperation.boxStatus.Add(1, boxStatus);
if (!alarmType.Equals(StoreAlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
return lineOperation;
}
public void SendLineStatus()
{
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (humBean.NeedGetTem())
{
lineOperation.op = 5;
LogInfo("没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op);
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
// ReviceInStoreProcess("", resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
char splitChar = '|';
string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);
bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
bool cutReel = FormUtil.GetBoolData(data, ParamDefine.cutReel);
bool smallReel = FormUtil.GetBoolData(data, ParamDefine.smallReel);
string rfid = data.ContainsKey(ParamDefine.rfid) ? data[ParamDefine.rfid] : "";
int rfidLoc = FormUtil.GetIntData(data, ParamDefine.rfidLoc);
string barcode = data.ContainsKey(ParamDefine.barcode) ? data[ParamDefine.barcode] : "";
//urgentReel: true 表示紧急料,需要出到料串上
//cutReel: true 表示分盘料,需要出到料串上
//smallReel: true 小料(7x8),放置到小料架上
//rfid: 分配的料架RFID
//rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
string dataStr = JsonHelper.SerializeObject(data);
LogUtil.info("收到服务器出库消息:【" + dataStr + "】");
int index = -1;
foreach (string posId in posIdArray)
{
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
string[] posArray = posId.Split('#');
//if (posArray.Length != 2)
//{
// WarnMsg = Name + "出库格式错误:库位号【" + posId + "】";
// LogUtil.error(Name + "收到服务器出库命令:库位号【" + posId + "】格式错误");
// continue;
//}
InOutParam inoutParam = new InOutParam(barcode, posId, "", plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = Name + "未找到库位:【" + inoutParam.ToStr() + "】";
LogUtil.error(WarnMsg);
continue;
}
try
{
//判断是否接收过此库位的出库信息
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveParam.PosID.Equals(posId))
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,正在【" + posId + "】出库中");
continue;
}
//判断排队列表中是否已存在
List<InOutParam> reviceList = new List<InOutParam>(waitOutStoreList);
reviceList = (from m in reviceList where m.PosID.Equals(posId) select m).ToList<InOutParam>();
if (reviceList.Count > 0)
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,排队列表中已存在【" + reviceList[0].ToStr() + "】");
continue;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "验证出库【" + inoutParam.ToStr() + "】是否重复出错:" + ex.ToString());
}
string shelfPosID = "";
if (inoutParam.rfidLoc > 0 && ShelfPosList.Count >= inoutParam.rfidLoc)
{
shelfPosID = ShelfPosList[inoutParam.rfidLoc - 1];
inoutParam.NeedEnterShelf = false;
inoutParam.NeedOutShelf = false;
inoutParam.ShelfPosID = shelfPosID;
}
else
{
bool hasShelf = EmprtShelfList.TryDequeue(out shelfPosID);
if (hasShelf)
{
inoutParam.NeedEnterShelf = false;
inoutParam.NeedOutShelf = false;
inoutParam.ShelfPosID = shelfPosID;
}
else
{
inoutParam.NeedEnterShelf = true;
inoutParam.NeedOutShelf = false;
LogInfo(Name + "执行出库【" + inoutParam.ToStr() + "】,没有空料架,需要使用新料架");
}
}
StartExecuctOut(inoutParam);
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogInfo(Name + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
#endregion
#region 扫码获取库位
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
private bool GetPosIdByCode()
{
try
{
string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
string plateW = data[ParamDefine.plateW];
string plateH = data[ParamDefine.plateH];
string[] posArray = posId.Split('#');
if (!(posArray.Length == 2))
{
WarnMsg = Name + "入库库位格式错误:二维码【" + message + "】库位【" + posId + "】";
LogUtil.error(Name + "服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
return false;
}
int storeId = int.Parse(posArray[0]);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return false;
}
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数 , 开始入库!");
int p3 = ComTargetPosition + Config.CompAxis_P3_P2_Value;
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, ComTargetPosition, p3);
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
return false;
}
#endregion
}
}
......@@ -18,13 +18,11 @@ namespace OnlineStore.DeviceLibrary
/// 流水线自动料仓-流水线类
/// </summary>
public partial class PackingStoreBean : KTK_Store
{
{
/// <summary>
/// 灯闪烁定时器
/// </summary>
private System.Timers.Timer ledProcessTimer = null;
private System.Timers.Timer ledProcessTimer = null;
public Dictionary<int, AC_BOX_Config> BoxConfigMap { get; set; }
public Dictionary<int, AC_BOX_Bean> BoxMap = new Dictionary<int, AC_BOX_Bean>();
......@@ -62,12 +60,10 @@ namespace OnlineStore.DeviceLibrary
//增加站号名称
AgvClient.NodeList.Add(config.AgvNodeName);
AddDeviceName(ioList, config.DIODeviceNameList);
BoxMap.Add(config.DeviceID, equip);
BoxConfigMap.Add(config.DeviceID, config);
rfidList.Add(config.RFID_IP);
}
IOManager.Init();
......@@ -86,14 +82,11 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
mainTimer.Enabled = true;
mainTimer.Enabled = true;
canStart = true;
});
}
private void AddDeviceName(List<string> targetList, List<string> list)
{
foreach (string str in list)
......@@ -106,21 +99,16 @@ namespace OnlineStore.DeviceLibrary
}
public void InitTimer()
{
ledProcessTimer = new System.Timers.Timer();
ledProcessTimer.Interval = 1000;
ledProcessTimer.Elapsed += LedProcess;
ledProcessTimer.AutoReset = true;
ledProcessTimer.Enabled = false;
ledProcessTimer.Enabled = false;
}
private void IoCheckTimerProcess(object sender, ElapsedEventArgs e)
{
{
}
#endregion
public override bool StartRun(bool isDebug = false)
......@@ -204,8 +192,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(Name + "收到复位信号," + equip.Name + " 正常无报警,不需要复位");
}
}
}
}
mainTimer.Enabled = true;
}
......@@ -250,10 +237,8 @@ namespace OnlineStore.DeviceLibrary
if (box.storeRunStatus > runs)
{
runs = box.storeRunStatus;
}
}
}
}
//黄灯
if (runs.Equals(StoreRunStatus.HomeMoving) || runs.Equals(StoreRunStatus.Reset))
......@@ -267,24 +252,18 @@ namespace OnlineStore.DeviceLibrary
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
}
}
else
{
if (IsDoValue(IO_Type.RunSign_HddLed, IO_VALUE.HIGH))
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
}
}
if (alarmType.Equals(StoreAlarmType.None).Equals(false) || isNoAirCheck || isInSuddenDown )
{
isNeedAlarmLed = true;
}
}
//忙碌中,判断是否有移栽在出入库执行,绿灯闪烁
if (isInOut)
{
......@@ -331,64 +310,16 @@ namespace OnlineStore.DeviceLibrary
{
return IOValue(ioType).Equals(ioValue);
}
#endregion
#endregion
/// <summary>
/// 定时处理,监听信号,监听IO
/// </summary>
protected override void timersTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//try
//{
// DateTime time = DateTime.Now;
// if (storeRunStatus.Equals(StoreRunStatus.Wait))
// {
// //取新的Io状态
// IO_VALUE fuweiValue = IOValue(IO_Type.Reset_BTN);
// IO_VALUE lastFuwei = DILastValueMap[IO_Type.Reset_BTN];
// addLastDI(IO_Type.Reset_BTN, fuweiValue);
// bool isAutoStart = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun) == 1;
// //收到复位信号后启动
// if (isAutoStart && fuweiValue.Equals(IO_VALUE.HIGH) && lastFuwei.Equals(IO_VALUE.LOW))
// {
// //没有启动时收到复位按钮,相当于启动按钮
// LogUtil.info( Name + "没有启动时收到复位按钮,相当于启动按钮,开始调用启动方法!");
// bool isOk = StartRun();
// if (!isOk)
// {
// LogUtil.error("启动失败,等待下次启动");
// mainTimer.Enabled = true;
// }
// }
// return;
// }
// //判断急停
// else if (this.storeRunStatus >= StoreRunStatus.HomeMoving)
// {
// foreach (AC_BOX_Bean box in this.BoxMap.Values)
// {
// if (!box.IsDebug)
// {
// box.TimerProcess();
// }
// }
// }
//}
//catch (Exception ex)
//{
// LogUtil.error(Name + "主定时器出错:" + ex.ToString());
//}
//Thread.Sleep(1);
BusyMoveProcess();
}
{
BusyMoveProcess();
}
public override void StopMove()
{
{
foreach (AC_BOX_Bean equip in this.BoxMap.Values)
{
// if (!equip.IsDebug)
......@@ -396,8 +327,7 @@ namespace OnlineStore.DeviceLibrary
equip.StopMove();
}
}
MoveInfo.EndMove();
MoveInfo.EndMove();
}
protected override void ResetProcess()
......
......@@ -323,6 +323,26 @@ namespace OnlineStore.DeviceLibrary
}
return "";
}
public static string ProcessCode(int LastWidth,int LastHeight,List<string> LastScanCodes)
{
string message = "";
string spiltStr = "##";
string codeSize = LastWidth + "x" + LastHeight;
foreach (string str in LastScanCodes)
{
if (str.Trim().Equals(""))
{
continue;
}
string code = "=1+0x0-" + codeSize + "=" + str.Trim();
if (!String.IsNullOrEmpty(code))
{
message = message + code + spiltStr;
}
}
return message;
}
}
public class ServerData
{
......
......@@ -68,6 +68,7 @@
<ItemGroup>
<Compile Include="ACPackingStore\AC_BOX_Bean.cs" />
<Compile Include="ACPackingStore\AC_BOX_Bean_Partial.cs" />
<Compile Include="ACPackingStore\AC_BOX_Bean_Shelf.cs" />
<Compile Include="ACPackingStore\EnteryDoorBean.cs" />
<Compile Include="ACPackingStore\HumitureBean.cs" />
<Compile Include="ACPackingStore\PackingStoreBean.cs" />
......
......@@ -423,17 +423,29 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
BS_03_DoorOpen = 4003,
/// <summary>
/// 通知AGV准备空车
/// </summary>
BS_04_ReadyEmpty=4004,
/// <summary>
/// 送出空料架:线体反转
/// </summary>
BS_04_LineBack= 4004,
BS_05_LineBackRun= 4005,
/// <summary>
/// 送出空料架:等待取料工位无信号,入料口有信号
/// </summary>
BS_05_WaitInLineSingle = 4005,
BS_06_WaitInLineSingle = 4006,
/// <summary>
/// 送出空料架:再转动3000时间
/// </summary>
BS_07_WaitTime = 4007,
/// <summary>
/// 送出空料架:等待AGV离开后关闭仓门
/// </summary>
BS_08_WaitAGVLeave = 4008,
/// <summary>
/// 送出空料架:再转动300时间
/// 送出空料架:关闭仓门
/// </summary>
BS_06_WaitTime = 4006,
BS_09_CloseDoor = 4009,
///// <summary>
///// 送出空料架:停止转动
///// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!