Commit aece1f17 LN

1

1 个父辈 9af14a7c
......@@ -18,54 +18,39 @@ namespace OnlineStore.Common
{
public class HttpHelper
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static bool PingURLIP(string url, int ms = 100)
{
return Post(url, paramData, Encoding.UTF8);
}
//public static bool PingURLIP(string url, int ms=100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
string[] urlArray = url.Split('/');
if (urlArray.Length > 3)
{
string ip = urlArray[2];
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
public static Operation Post(string url, Operation operation, bool simulate)
Ping pingSender = new Ping();
PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
if (reply.Status == IPStatus.Success)
{
//通
return true;
}
else
{
LogUtil.error("Ping IP " + ip + " : false");
//不通
return false;
}
}
return true;
}
public static string Post(string url, string paramData, int timeOut = 5000)
{
bool IsTimeOut = false;
return Post(url, paramData, Encoding.UTF8, timeOut, out IsTimeOut);
}
public static Operation PostOperation(string url, Operation operation, bool simulate=false )
{
try
{
////如果Op=0或者Op=5,先拼Ip,不通不发送
//if (operation.op < 0 || operation.op.Equals(5))
//{
// if (PingURLIP(url, 100).Equals(false))
// {
// return null;
// }
//}
{
if (simulate)
{//模拟服务器返回
operation.status = 200;
......@@ -112,23 +97,13 @@ namespace OnlineStore.Common
}
return null;
}
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static string LastServerMsg = "";
public static string Post(string url, string paramData, Encoding encoding)
public static string Post(string url, string paramData, Encoding encoding, int timeOut, out bool IsTimeOut)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
IsTimeOut = false;
if (isLog == 1)
{
LogUtil.info("给服务器发送数据【" + paramData + "】 ");
}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
......@@ -139,7 +114,7 @@ namespace OnlineStore.Common
try
{
var wc = new MyWebClient(5000);
var wc = new MyWebClient(timeOut);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
......@@ -147,23 +122,23 @@ namespace OnlineStore.Common
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (WebException ex)
{
IsTimeOut = true;
LogUtil.error("POST [" + url + "] WebException :" + ex.ToString(), 101);
}
catch (Exception e)
{
LogUtil.error("POST ERROR:" + e.ToString(), 1);
LogUtil.error("POST [" + url + "] ERROR:" + e.ToString(), 101);
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
//LogUtil.debug( "receive << " + result);
}
if (isLog == 1)
{
LogUtil.info("收到服务器数据【" + result + "】");
}
LastServerMsg = DateTime.Now.ToLongTimeString() + " URL:" + url + "\r\n"
+ "发送:" + paramData + "\r\n"
+ "接收:" + result + "\r\n"
;
return result;
}
......@@ -176,19 +151,19 @@ namespace OnlineStore.Common
{
try
{
LogUtil.info("HTTP GET FROM: " + url);
LogUtil.info( "HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LogUtil.info("receive << " + result);
LogUtil.info( "receive << " + result);
return result;
}
}
catch (Exception e)
{
LogUtil.error("HTTP GET ERROR:" + e.Message, 2);
LogUtil.error("HTTP GET ERROR:" + e.Message, 102);
}
return "";
}
......
......@@ -54,6 +54,8 @@ namespace OnlineStore.DUOStore
this.btnAxisOff = new System.Windows.Forms.Button();
this.btnAxisOn = new System.Windows.Forms.Button();
this.axisMoveControl1 = new OnlineStore.DUOStore.AxisMoveControl();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.groupInout.SuspendLayout();
this.SuspendLayout();
//
......@@ -64,7 +66,8 @@ namespace OnlineStore.DUOStore
//
// groupInout
//
this.groupInout.Controls.Add(this.btnSaveP);
this.groupInout.Controls.Add(this.textBox1);
this.groupInout.Controls.Add(this.button1);
this.groupInout.Controls.Add(this.txtUpdownP6);
this.groupInout.Controls.Add(this.btnUpdownP6);
this.groupInout.Controls.Add(this.txtUpdownP5);
......@@ -98,7 +101,7 @@ namespace OnlineStore.DUOStore
// btnSaveP
//
this.btnSaveP.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSaveP.Location = new System.Drawing.Point(21, 229);
this.btnSaveP.Location = new System.Drawing.Point(752, 530);
this.btnSaveP.Name = "btnSaveP";
this.btnSaveP.Size = new System.Drawing.Size(128, 39);
this.btnSaveP.TabIndex = 313;
......@@ -350,7 +353,7 @@ namespace OnlineStore.DUOStore
this.btnMiddleP1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnMiddleP1.Size = new System.Drawing.Size(193, 33);
this.btnMiddleP1.TabIndex = 301;
this.btnMiddleP1.Text = "T2_旋转轴待机点/取放料点P1:";
this.btnMiddleP1.Text = "T2_旋转轴_待机点P1:";
this.btnMiddleP1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnMiddleP1.UseVisualStyleBackColor = false;
this.btnMiddleP1.Click += new System.EventHandler(this.btnMiddleP1_Click);
......@@ -509,11 +512,45 @@ namespace OnlineStore.DUOStore
this.axisMoveControl1.Size = new System.Drawing.Size(735, 312);
this.axisMoveControl1.TabIndex = 274;
//
// textBox1
//
this.textBox1.AcceptsReturn = true;
this.textBox1.BackColor = System.Drawing.SystemColors.Window;
this.textBox1.Cursor = System.Windows.Forms.Cursors.IBeam;
this.textBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.ForeColor = System.Drawing.SystemColors.WindowText;
this.textBox1.Location = new System.Drawing.Point(228, 234);
this.textBox1.MaxLength = 20;
this.textBox1.Name = "textBox1";
this.textBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.textBox1.Size = new System.Drawing.Size(89, 23);
this.textBox1.TabIndex = 314;
this.textBox1.Text = "999999";
//
// button1
//
this.button1.AutoSize = true;
this.button1.BackColor = System.Drawing.SystemColors.Control;
this.button1.Cursor = System.Windows.Forms.Cursors.Default;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button1.Location = new System.Drawing.Point(21, 228);
this.button1.Name = "button1";
this.button1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.button1.Size = new System.Drawing.Size(193, 33);
this.button1.TabIndex = 313;
this.button1.Text = "T2_旋转轴_料串取放料点P4:";
this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button1.UseVisualStyleBackColor = false;
//
// FrmAxisMove
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(964, 630);
this.Controls.Add(this.btnSaveP);
this.Controls.Add(this.groupInout);
this.Controls.Add(this.axisMoveControl1);
this.Controls.Add(this.btnAxisOff);
......@@ -561,6 +598,8 @@ namespace OnlineStore.DUOStore
public System.Windows.Forms.Button btnUpdownP4;
public System.Windows.Forms.Button btnUpdownP2;
private System.Windows.Forms.Button btnSaveP;
public System.Windows.Forms.TextBox textBox1;
public System.Windows.Forms.Button button1;
}
}
......@@ -133,7 +133,7 @@ namespace OnlineStore.DUOStore
// lblMoveEquipInfo.Text = "";
}
//ReadPosistion();
if (BoxBean.storeRunStatus > StoreRunStatus.Wait)
if (BoxBean.runStatus > StoreRunStatus.Wait)
{
if (btnStoreStart.Enabled.Equals(true))
{
......@@ -145,7 +145,7 @@ namespace OnlineStore.DUOStore
//复位按钮状态显示
if (btnSotreReset.Enabled == false)
{
if ((BoxBean.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.storeRunStatus.Equals(StoreRunStatus.Reset))
if ((BoxBean.runStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.runStatus.Equals(StoreRunStatus.Reset))
&& BoxBean.alarmType.Equals(AlarmType.None))
{
}
......@@ -159,7 +159,7 @@ namespace OnlineStore.DUOStore
}
else
{
if ((BoxBean.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.storeRunStatus.Equals(StoreRunStatus.Reset))
if ((BoxBean.runStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.runStatus.Equals(StoreRunStatus.Reset))
&& BoxBean.alarmType.Equals(AlarmType.None))
{
if (btnStoreStart.Enabled)
......@@ -209,7 +209,7 @@ namespace OnlineStore.DUOStore
private void btnOutStore_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
......@@ -224,7 +224,7 @@ namespace OnlineStore.DUOStore
private void btnInStore_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
......@@ -522,7 +522,7 @@ namespace OnlineStore.DUOStore
private void btnStartAuTo_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
if (BoxBean.AutoInout.autoNext)
{
......@@ -575,7 +575,7 @@ namespace OnlineStore.DUOStore
{
try
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
BoxBean.StopRun();
StoreOpenStatus(false);
......@@ -593,7 +593,7 @@ namespace OnlineStore.DUOStore
private void btnSotreReset_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
this.BoxBean.Reset();
btnSotreReset.Enabled = false;
......@@ -802,7 +802,7 @@ namespace OnlineStore.DUOStore
private void btnNgPro_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
......@@ -816,7 +816,7 @@ namespace OnlineStore.DUOStore
private void btnSingleOut_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
if (BoxBean.runStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
......
......@@ -132,7 +132,7 @@ namespace OnlineStore.DUOStore
if (result.Equals(DialogResult.Yes))
{
//如果料仓还在运行状态,先关闭料仓
if (!store.storeRunStatus.Equals(StoreRunStatus.Wait))
if (!store.runStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info( "ExitApp 停止"+store.Name+"运行 ");
store.StopRun();
......@@ -141,7 +141,7 @@ namespace OnlineStore.DUOStore
{
foreach(BoxBean bean in store.BoxMap.Values)
{
if (bean.storeRunStatus.Equals(StoreRunStatus.Wait).Equals(false))
if (bean.runStatus.Equals(StoreRunStatus.Wait).Equals(false))
{
LogUtil.info( "ExitApp 停止" + bean.Name + "运行 ");
bean.StopRun();
......@@ -187,9 +187,9 @@ namespace OnlineStore.DUOStore
private void 启动所有料仓AToolStripMenuItem_Click(object sender, EventArgs e)
{
if (store.storeRunStatus != StoreRunStatus.Wait)
if (store.runStatus != StoreRunStatus.Wait)
{
MessageBox.Show(store.Name + "当前状态:" + store.storeRunStatus + ",不能启动!");
MessageBox.Show(store.Name + "当前状态:" + store.runStatus + ",不能启动!");
return;
}
LogUtil.info( "开始启动");
......@@ -203,7 +203,7 @@ namespace OnlineStore.DUOStore
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
startTimer.Enabled = false;
if (store.storeRunStatus > StoreRunStatus.Wait)
if (store.runStatus > StoreRunStatus.Wait)
{
return;
}
......@@ -253,7 +253,7 @@ namespace OnlineStore.DUOStore
{
if (store != null)
{
if (store.storeRunStatus.Equals(StoreRunStatus.Wait))
if (store.runStatus.Equals(StoreRunStatus.Wait))
{
MessageBox.Show(store.Name + "DUO料仓未启动,不需要停止");
return;
......@@ -268,7 +268,7 @@ namespace OnlineStore.DUOStore
private void 复位RToolStripMenuItem_Click(object sender, EventArgs e)
{
if (store.storeRunStatus.Equals(StoreRunStatus.Wait))
if (store.runStatus.Equals(StoreRunStatus.Wait))
{
MessageBox.Show(store.Name + "DUO料仓未启动,无法复位");
return;
......
......@@ -102,13 +102,15 @@ PRO,0,T1_提升轴上升目标点_P2,BatchAxis_P2,4000,,,,, ,,,,,,,
PRO,0,T1_提升轴P1速度,BatchAxis_P1Speed,4000,,,,,,,,,,,,
PRO,0,T1_提升轴P2速度,BatchAxis_P2Speed,500,,,,, ,,,,,,,
PRO,0,T1_提升轴高度转换系数(1mm对应的脉冲),BatchAxis_ChangeValue,11000,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,T2_旋转轴_料串取放料点P4:
PRO,0,T2_旋转轴待机点/取放料点 P1,MiddleAxis_P1,5000,,,,,,,,,,,,
PRO,0,T2_旋转轴左侧料仓取放料点_P2,MiddleAxis_P2,59000,,,,,,,,,,,,
PRO,0,T2_旋转轴右侧料仓取放料点_P3,MiddleAxis_P3,59000,,,,,,,,,,,,
PRO,0,T2_旋转轴左侧料仓取放料点_P2,MiddleAxis_P2,59002,,,,,,,,,,,,
PRO,0,T2_旋转轴右侧料仓取放料点_P3,MiddleAxis_P3,59003,,,,,,,,,,,,
PRO,0,T2_旋转轴_料串取放料点_P4,MiddleAxis_P4,59004,,,,,,,,,,,,
PRO,0,T2_旋转轴P1速度,MiddleAxis_P1Speed,500,,,,,,,,,,,,
PRO,0,T2_旋转轴P2速度,MiddleAxis_P2Speed,500,,,,,,,,,,,,
PRO,0,T2_旋转轴P3速度,MiddleAxis_P3Speed,500,,,,,,,,,,,,
PRO,0,T2_旋转轴P4速度,MiddleAxis_P4Speed,500,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,0,T3_升降轴料串取放料低点 P1,UpdownAxis_P1,5000,,,,,,,,,,,,
PRO,0,T3_升降轴料串取放料高点 P2,UpdownAxis_P2,5001,,,,,,,,,,,,
......
......@@ -99,7 +99,7 @@ namespace OnlineStore.DeviceLibrary
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraList, string deviceName, bool isSaveImg = false)
public static List<string> CameraScan(List<string> cameraList, string deviceName, int timeOut = 1500)
{
if (codeCount < 1)
{
......@@ -142,7 +142,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, codeCount, GetCodeParamFilePath(codeType), codeType);
cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, timeOut);
}
foreach (CodeInfo c in cc)
{
......
......@@ -135,11 +135,30 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
string clearMsg = "";
//判断轴是否报警
if (MoveInfo.CanWhileCount <= 3)
{
int isAlarm = ACServerManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1))
{
clearMsg = "清理报警,";
ACServerManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200);
ACServerManager.ServoOn(deviceName, axisNo);
Thread.Sleep(500);
}
}
if (String.IsNullOrEmpty(clearMsg))
{
ACServerManager.SuddenStop(axis.DeviceName, axis.GetAxisValue());
Thread.Sleep(100);
}
LogUtil.error(MoveInfo.Name + axis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.SuddenStop(axis.DeviceName, axis.GetAxisValue());
"],误差过大," + clearMsg + "重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--;
Thread.Sleep(200);
}
else
{
......@@ -253,7 +272,7 @@ namespace OnlineStore.DeviceLibrary
return true;
}
public bool AxisStopCheckMove()
public bool StopAxisCheckMove()
{
if (!(axisCheckTimer == null))
{
......@@ -274,7 +293,7 @@ namespace OnlineStore.DeviceLibrary
lastOkTime = DateTime.Now;
if (IOManager.IOValue(TargetIoType, 0).Equals(TargetIoValue))
{
AxisStopCheckMove();
StopAxisCheckMove();
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
SuddenStop();
}
......
......@@ -81,7 +81,7 @@ namespace OnlineStore.DeviceLibrary
private void IoCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//判断急停
if (storeRunStatus >= StoreRunStatus.HomeMoving)
if (runStatus >= StoreRunStatus.HomeMoving)
{
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
......@@ -133,7 +133,7 @@ namespace OnlineStore.DeviceLibrary
}
//TODO 启动时先所有轴远点返回,测试暂时关闭
storeRunStatus = StoreRunStatus.HomeMoving;
runStatus = StoreRunStatus.HomeMoving;
storeStatus = StoreStatus.ResetMove;
//启动温湿度服务器
HumitureController.Init(Config.Humiture_Port);
......@@ -170,7 +170,7 @@ namespace OnlineStore.DeviceLibrary
lastPosId = "";
lastPosIdStatus = StoreStatus.ResetMove;
AutoInout.ClearCount();
storeRunStatus = StoreRunStatus.HomeMoving;
runStatus = StoreRunStatus.HomeMoving;
MoveInfo.NewMove(MoveType.ReturnHome);
InoutStartReset();
}
......@@ -183,7 +183,7 @@ namespace OnlineStore.DeviceLibrary
{
AutoInout.StopAuto();
}
storeRunStatus = StoreRunStatus.Reset;
runStatus = StoreRunStatus.Reset;
storeStatus = StoreStatus.ResetMove;
MoveInfo.NewMove(MoveType.Reset);
......@@ -279,7 +279,7 @@ namespace OnlineStore.DeviceLibrary
serverConTimer.Enabled = false;
StopMove();
storeRunStatus = StoreRunStatus.Wait;
runStatus = StoreRunStatus.Wait;
mainTimer.Enabled = false;
TimeSpan span = DateTime.Now - StartTime;
LogInfo(",停止运行,总运行时间:" + span.ToString());
......@@ -301,7 +301,7 @@ namespace OnlineStore.DeviceLibrary
BusyMoveProcess();
ShowTimeLog("BusyMoveProcess");
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing))
else if (runStatus.Equals(StoreRunStatus.Runing))
{
ShowTimeLog("判断是否需要出入库");
AutoResetProcess();
......@@ -310,7 +310,7 @@ namespace OnlineStore.DeviceLibrary
ShowTimeLog("IOTimeOutProcess");
} //检查运动轴报警
if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) && (!isNoAirCheck))
if (runStatus > StoreRunStatus.Wait && (!isInSuddenDown) && (!isNoAirCheck))
{
ShowTimeLog("开始检测轴报警");
CheckAxisAlarm(new AxisBean[] { MiddleAxis, UpdownAxis, InoutAxis, ComAxis });
......@@ -331,7 +331,7 @@ namespace OnlineStore.DeviceLibrary
bool noInStore = true;
if (AutoInout.CurrInOutACount >= StoreManager.Config.Box_ResetACount && noInStore)
{
if (storeRunStatus < StoreRunStatus.Runing || MoveInfo.MoveType == MoveType.InStore || MoveInfo.MoveType == MoveType.OutStore)
if (runStatus < StoreRunStatus.Runing || MoveInfo.MoveType == MoveType.InStore || MoveInfo.MoveType == MoveType.OutStore)
{
// LogInfo("已经累计出入库" + AutoInout.CurrInOutACount + "次,当时当前正在忙碌中暂不复位");
}
......@@ -389,7 +389,7 @@ namespace OnlineStore.DeviceLibrary
public string GetMoveStr()
{
string msg = "";
msg += "状态: " + storeRunStatus + " " + storeStatus + "\n";
msg += "状态: " + runStatus + " " + storeStatus + "\n";
// msg += "lineS: " + storeStatus + "\n";
msg += "报警: " + alarmType + "\n";
msg += MoveInfo.MoveType + " " + MoveInfo.SLog + "\n";
......
......@@ -16,121 +16,9 @@ namespace OnlineStore.DeviceLibrary
{
public ConcurrentQueue<InOutParam> waitOutStoreList = new ConcurrentQueue<InOutParam>();
// public InOutParam waitOutStoreList = null;
#region 出入库结果验证
private void CheckWait()
{
List<WaitResultInfo> list = MoveInfo.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
string NotOkMsg = "";
if (list.Count <= 0)
{
MoveInfo.EndStepWait();
return;
}
bool isOk = true;
if (MoveInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
continue;
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(MoveInfo, wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(MoveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(AlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break;
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = StoreManager.Config.IOSingle_TimerOut;
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn) ||
MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
timeOutMs = 30000;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
timeOutMs = 40000;
}
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs && NoAlarm())
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Alarm(AlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
MoveInfo.EndStepWait();
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待" + NotOkMsg
+ "超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
int second = 10;
second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
{
second = 120;
}
else if (second < 10)
{
second = 10;
}
LogUtil.error(WarnMsg, logType + 100, second);
Alarm(AlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
}
#region 出入库结果验证
private bool AcInPosition(ConfigMoveAxis axis,int p)
{
return ACServerManager.isInPosition(axis.DeviceName, axis.GetAxisValue(), p, axis.CanErrorCountMax);
......@@ -149,10 +37,44 @@ namespace OnlineStore.DeviceLibrary
InoutAxis.AbsMove(MoveInfo, InOut_P1, Config.InOutAxis_P1_Speed);
}
}
#endregion
/// <summary>
///是否已经接收到过出库信息
///</summary>
public bool IsReviceInPosId( string posId)
{
bool isReviceInfo = false;
try
{
if (MoveInfo.MoveType.Equals(MoveType.InStore) && MoveInfo.MoveParam != null && MoveInfo.MoveParam.PosID.Equals(posId))
{
LogInfo(" IsReviceInPosId 正在入库中:" + MoveInfo.MoveParam.ToStr());
isReviceInfo = true;
}
if (!isReviceInfo &&.Count > 0)
{
//foreach (InOutParam inout in waitOutStoreList)
//{
// if (inout.PosID.Equals(posId) && (!inout.WareCode.Equals("")))
// {
// LogInfo(" IsReviceInPosId 已存在入库任务:" + inout.ToStr());
// isReviceInfo = true;
// break;
// }
//}
}
}
catch (Exception ex)
{
LogUtil.error("IsReviceInPosId【" + posId + "】出错:" + ex.ToString());
}
return isReviceInfo;
}
#endregion
#region 入库
private DateTime startInStoreTime = DateTime.Now;
public override void StartInStoreMove(InOutParam param)
......@@ -160,10 +82,10 @@ namespace OnlineStore.DeviceLibrary
startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
(!runStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动出库出错,忙碌或报警中 ,storeStatus=" + storeRunStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
LogUtil.error(Name + " 启动出库出错,忙碌或报警中 ,storeStatus=" + runStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
return;
}
......@@ -173,7 +95,7 @@ namespace OnlineStore.DeviceLibrary
return;
}
LogInfo(" 启动入库【" + param.ToStr() + "】 ");
storeRunStatus = StoreRunStatus.Busy;
runStatus = StoreRunStatus.Busy;
if (param.TargetPosition.Equals(0))
{
storeStatus = StoreStatus.InStoreExecute;
......@@ -370,10 +292,10 @@ namespace OnlineStore.DeviceLibrary
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
(!runStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + storeRunStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirCheck);
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + runStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirCheck);
return false;
}
......@@ -384,7 +306,7 @@ namespace OnlineStore.DeviceLibrary
}
storeStatus = StoreStatus.OutStoreExecute;
storeRunStatus = StoreRunStatus.Busy;
runStatus = StoreRunStatus.Busy;
MoveInfo.NewMove(MoveType.OutStore, param);
LogInfo("启动出库【" + param.ToStr() + "】 ");
//出库前shelfPosID需要固定,出库时根据rfid判断是否需要出入料架
......
......@@ -165,7 +165,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op, ID + 105);
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);
Operation resultOperation = HttpHelper.PostOperation(StoreManager.GetPostApi(server), lineOperation);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
......@@ -231,8 +231,8 @@ namespace OnlineStore.DeviceLibrary
foreach (string posId in posIdArray)
{
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
int plateW =Convert.ToInt32( plateWArray[index]);
int plateH = Convert.ToInt32(plateHArray[index]);
InOutParam inoutParam = new InOutParam(barcode, posId, plateW, plateH);
//根据发送的posId获取位置列表
......@@ -279,224 +279,7 @@ namespace OnlineStore.DeviceLibrary
}
#endregion
#region 扫码获取库位
/// <summary>
/// 数据接收
/// </summary>
/// <param name="message"></param>
private bool GetPosIdByCode()
{
// try
// {
// //string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
// string message = MoveInfo.shelfLockDatas[MoveInfo.currShelfIndex].barcode;
// 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() }, { ParamDefine.rfid, CurrShelfID }};
// 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];
// int storeId = InOutParam.GetPosStoreId(posId);
// //根据发送的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 = Config.CompAxis_P3;
// // 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;
}
/// <summary>
/// 扫码结果类型
/// </summary>
enum CodeResultType
{
NoCode,
DeviceNotOpen,
NotResponseFromServer,
WarnMsg,
NotFoundPos,
Error,
Success
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="codeResultType">扫码结果</param>
/// <returns></returns>
private bool GetPosIdByCode (int LastWidth,int LastHeight,List<string> LastScanCodes, int rfidLoc, out CodeResultType codeResultType)
{
string CurrShelfID = "";
try
{
if (LastWidth <= 0)
{
LastWidth = 7;
}
string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
codeResultType = CodeResultType.NoCode;
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
codeResultType = CodeResultType.DeviceNotOpen;
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//查询该料盘所在料仓以及仓位
bool checkRelationship = StoreManager.GetPosForPutIn(Name, Config, message, CurrShelfID, rfidLoc);
if (!checkRelationship)
{
codeResultType = CodeResultType.NotFoundPos;
return false;
}
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() }, { ParamDefine.rfid, CurrShelfID } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
codeResultType = CodeResultType.NotResponseFromServer;
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
codeResultType = CodeResultType.WarnMsg;
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];
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
codeResultType = CodeResultType.NotFoundPos;
return false;
}
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数 , 开始入库!");
int p3 = Config.CompAxis_P3;
//MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, ComTargetPosition, p3);
codeResultType = CodeResultType.Success;
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);
}
codeResultType = CodeResultType.Error;
return false;
}
#endregion
}
}
......@@ -20,8 +20,10 @@ namespace OnlineStore.DeviceLibrary
public Dictionary<int, BoxBean> BoxMap = new Dictionary<int, BoxBean>();
public Store_Config Config { get; set; }
public bool UseBuzzer = ConfigAppSettings.GetIntValue(Setting_Init.UseBuzzer).Equals(1);
public bool UseBuzzer = ConfigAppSettings.GetIntValue(Setting_Init.UseBuzzer).Equals(1);
/// <summary>
/// 取料提升机构
/// </summary>
public HoisterCylinder hoisterCylinder = new HoisterCylinder(0);
public AxisBean T1_BatchAxis = null;
public AxisBean T2_MiddleAxis = null;
......@@ -123,7 +125,7 @@ namespace OnlineStore.DeviceLibrary
else
{
LogUtil.info(Name + "开始启动 ,启动时间:" + StartTime.ToString());
storeRunStatus = StoreRunStatus.HomeMoving;
runStatus = StoreRunStatus.HomeMoving;
StartTime = DateTime.Now;
StartResetMove();
foreach (BoxBean box in this.BoxMap.Values)
......@@ -144,7 +146,7 @@ namespace OnlineStore.DeviceLibrary
//停止运动
MoveInfo.EndMove();
storeRunStatus = StoreRunStatus.Reset;
runStatus = StoreRunStatus.Reset;
StartResetMove();
......@@ -249,7 +251,7 @@ namespace OnlineStore.DeviceLibrary
string msg = "等待BOX复位完成超时";
foreach (BoxBean box in this.BoxMap.Values)
{
if ((box.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || box.storeRunStatus.Equals(StoreRunStatus.Reset)))
if ((box.runStatus.Equals(StoreRunStatus.HomeMoving) || box.runStatus.Equals(StoreRunStatus.Reset)))
//if ((box.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || box.storeRunStatus.Equals(StoreRunStatus.Reset)) && box.IsDebug.Equals(false))
{
if (box.alarmType.Equals(AlarmType.None))
......@@ -301,7 +303,7 @@ namespace OnlineStore.DeviceLibrary
{
equip.StopRun();
}
storeRunStatus = StoreRunStatus.Wait;
runStatus = StoreRunStatus.Wait;
// RFIDManager.Close();
TimeSpan span = DateTime.Now - StartTime;
LogUtil.info(Name + ",停止运行,关闭rfid,总运行时间:" + span.ToString());
......@@ -328,9 +330,9 @@ namespace OnlineStore.DeviceLibrary
{
isInOut = true;
}
if (box.storeRunStatus > runs)
if (box.runStatus > runs)
{
runs = box.storeRunStatus;
runs = box.runStatus;
}
}
......@@ -454,7 +456,7 @@ namespace OnlineStore.DeviceLibrary
try
{
DateTime time = DateTime.Now;
if (storeRunStatus.Equals(StoreRunStatus.Wait))
if (runStatus.Equals(StoreRunStatus.Wait))
{
//取新的Io状态
IO_VALUE autoSingle = IOValue(IO_Type.Reset_BTN);
......@@ -477,7 +479,7 @@ namespace OnlineStore.DeviceLibrary
lastAutoRun = autoSingle;
}
//判断急停
else if (storeRunStatus >= StoreRunStatus.HomeMoving)
else if (runStatus >= StoreRunStatus.HomeMoving)
{
//急停按钮
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
......@@ -526,14 +528,19 @@ namespace OnlineStore.DeviceLibrary
BusyMoveProcess();
ShowTimeLog("BusyMoveProcess");
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{
ShowTimeLog("AutoResetProcess");
else if (runStatus.Equals(StoreRunStatus.Runing))
{
IOTimeOutProcess();
ShowTimeLog("IOTimeOutProcess");
} //检查运动轴报警
if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) && (!isNoAirCheck))
//判断是否需要处理料架入库
StartInStoreP();
}
//检查运动轴报警
if (runStatus > StoreRunStatus.Wait && (!isInSuddenDown) && (!isNoAirCheck))
{
ShowTimeLog("开始检测轴报警");
CheckAxisAlarm(new AxisBean[] { T1_BatchAxis,T2_MiddleAxis,T3_UpdownAxis});
......@@ -559,7 +566,7 @@ namespace OnlineStore.DeviceLibrary
return num;
}
public void LineRun(StoreMoveInfo move)
public void LineRun(StoreMoveInfo move=null )
{
if (move != null)
{
......@@ -570,7 +577,7 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Line_Run, IO_VALUE.HIGH);
}
public void LineStop(StoreMoveInfo move)
public void LineStop(StoreMoveInfo move=null )
{
if (move != null)
{
......
using System;
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class DUOStoreBean
partial class DUOStoreBean
{
#region 出库
protected override bool CheckWaitResult(StoreMoveInfo moveInfo, WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W008_BatchAxis))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(T1_BatchAxis.TargetIoType).Equals(T1_BatchAxis.TargetIoValue))
{
LogUtil.debug(Name + "CheckWaitResult 检测到" + T1_BatchAxis.TargetIoType + "=" + T1_BatchAxis.TargetIoValue + ",停止运行");
T1_BatchAxis.StopAxisCheckMove();
if (ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{
T1_BatchAxis.SuddenStop();
}
return true;
}
else
{
bool isOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (isOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
T1_BatchAxis.StopAxisCheckMove();
return true;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W009_ScanCode))
{
if (LastCodeList.Count > 0)
{
return true;
}
}
return false;
}
public int CurrShelfNum = 0;
#region 料架出料
public override bool StartOutStoreMove(InOutParam param)
{
......@@ -20,12 +62,571 @@ namespace OnlineStore.DeviceLibrary
}
#endregion
#region 入库
#region 料架入料
private bool ShelfNoTray = false;
private int StartMovePosition = 0;
private int EndMovePosition = 0;
private int LastHeight = 0;
private int LastWidth = 0;
private List<string> LastCodeList = new List<string>();
private List<string> YuCodeList = new List<string>();
private bool InShelfInProcess = false;
private bool StartInStoreP()
{
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) && (!InShelfInProcess))
{
ShelfEnterProcess();
}
if (!MoveInfo.MoveType.Equals(MoveType.None))
{
return false;
}
//判断是否检测到料架
if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
StartInStoreMove(null);
}
return false;
}
private void ShelfEnterProcess()
{
//入口有料架,需要转动链条
Task.Factory.StartNew(delegate
{
InShelfInProcess = true;
try
{
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.LOW))
{
InShelfInProcess = true;
LineRun(null);
//等待进料检测信号
bool result = WaitIo(IO_Type.Line_InCheck, IO_VALUE.LOW, 10000);
}
}
catch (Exception ex)
{
}
finally
{
InShelfInProcess = false;
LineStop(null);
}
});
}
private void LI_05_WaitTime()
{
//定位工位有料架,等待1秒后再次检测
MoveInfo.NextMoveStep(StoreMoveStep.LI_05_WaitTime);
InOutStoreLog("上料区检测到料架: " + MoveInfo.SLog + ",阻挡1上升,阻挡2上升,转动流水线5秒");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.LOW);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);
LineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
private void LI_04_LineStart()
{
CurrShelfNum = GetShelfNum();
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
LI_05_WaitTime();
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_04_LineStart);
InOutStoreLog("入料检测: " + MoveInfo.SLog + " 上料等待区有料架 ,阻挡1下降500,阻挡2上升,流水线转动 ,等待料架到达上料区");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.HIGH, false, 500);//进料阻挡下降
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);//缓冲阻挡前进1000
LineRun(MoveInfo);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
else
{
if (!InShelfInProcess)
{
LineStop(null);
}
MoveEndP();
LogUtil.info(" 未检测到料架,入料结束");
}
}
public override void StartInStoreMove(InOutParam param)
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore);
MoveInfo.MoveParam = new InOutParam();
//判断是哪个工位有料架
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
LI_05_WaitTime();
}
else
{
if (T1_BatchAxis.IsInPosition(Config.BatchAxis_P1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_01_BatchAxisToP1);
InOutStoreLog("检测到料架,提升轴先返回P1");
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P1Speed);
}
}
}
protected override void InStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
if (MoveInfo.IsStep(StoreMoveStep.LI_01_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_02_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_03_LocationDown);
InOutStoreLog("入料检测:定位气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_03_LocationDown))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_04_LineStart))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_05_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_06_TopUp);
InOutStoreLog("入料检测: 顶升气缸上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_07_HoisterForward);
InOutStoreLog("入料检测:取料提升机构前进");
hoisterCylinder.StartForward(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_07_HoisterForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog("入料检测:上料轴开始慢速上升到P2点,等待检测到料盘");
BatchAxisToP2(true);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_08_AxisUpToP2))
{
LI_09_ScanCode();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_09_ScanCode))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2,旋转轴到料串位置P4");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_11_AxisToTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_12_UpdownAxisToP3);
InOutStoreLog("取料:升降轴到料串低点P1");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_12_UpdownAxisToP3))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_13_CylinderTighten);
InOutStoreLog("取料:夹爪气缸夹紧");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Clamp);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_13_CylinderTighten))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_14_UpdownToP1);
InOutStoreLog("取料:升降轴到料串高点P2");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_14_UpdownToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_15_WaitNoCheck);
InOutStoreLog("取料:等待没有提升机构料盘检测");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.BatchAxis_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_15_WaitNoCheck))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_16_BatchAxisToP2);
InOutStoreLog("取料:批量轴到P2,计算高度,");
BatchAxisToP2(false);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_16_BatchAxisToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_17_SaveSize);
InOutStoreLog("取料:记录高度尺寸");
LastWidth = GetWidth();
LastHeight = GetHeight();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_17_SaveSize))
{
LI_18_GetPosID();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_18_GetPosID))
{
if (getPosTask.IsCompleted && LastPosParam != null)
{
if (LastPosParam.InStoreNg)
{
}
MoveInfo.NextMoveStep(StoreMoveStep.LI_19_ToBoxDoor);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:获取库位号完成,升降轴到料门口高点,旋转轴到料仓门口");
T3_UpdownAxis.AbsMove(Config.updo)
ClearTimeoutAlarm("获取库位号超时");
}
else if (MoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, ID * 1000 + 30);
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_19_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_20_UpdownDown);
InOutStoreLog("料盘移栽: 升降轴到料门口低点,开始预扫码");
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_20_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_21_CylinderRelax);
InOutStoreLog("料盘移栽: 上料气缸放松");
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_21_CylinderRelax))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_22_UpdownUp);
InOutStoreLog("料盘移栽: 升降轴到料门口高点");
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_22_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_23_AxisToWait);
InOutStoreLog("料盘移栽:旋转轴返回待机点P1,升降轴到料串高点P2");
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_23_AxisToWait))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_24_ToNexTray);
InOutStoreLog("料盘移栽:判断是否还有料");
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_24_ToNexTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_06_TopUp);
InOutStoreLog("入料检测: 顶升气缸上升");
}
}
protected void ClearTimeoutAlarm(string msg)
{
if (isInSuddenDown || isNoAirCheck)
{
return;
}
if (WarnMsg.Contains(msg) && alarmType.Equals(AlarmType.IoSingleTimeOut))
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = AlarmType.None;
SetWarnMsg("");
}
}
private Task getPosTask = null;
private string lastcode = "";
private InOutParam LastPosParam = null;
private void LI_18_GetPosID()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_18_GetPosID);
InOutStoreLog("料盘移栽:从服务器获取入库库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LastPosParam = null;
string code = CodeManager.ProcessCode(LastCodeList);
lastcode = code;
getPosTask = Task.Factory.StartNew(delegate
{
//更新托盘条码信息
try
{
int count = 1;
while (MoveInfo.MoveType.Equals(MoveType.InStore))
{
//从服务器获取库位号
GetPosResult result = StoreManager.GetPosId(Name, LastCodeList, LastHeight, LastWidth, CurrShelfNum);
if (result.IsTimeOut)
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 FI_23_GetPosID 超时,等待1s后重新获取");
Thread.Sleep(1000);
}
else if (result.Result.Equals(99) || result.Result.Equals(100))
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 FI_23_GetPosID 结果【" + result.Result + "】,等待3s后重新获取");
Thread.Sleep(3000);
}
else if (!result.Msg.Equals(""))
{
LastPosParam = result.Param;
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 FI_23_GetPosID 入库NG:" + result.Msg);
break;
}
else
{
LastPosParam = result.Param;
break;
}
count++;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "【" + code + "】获取库位号报错:" + ex.ToString());
}
});
}
private void LI_11_AxisToTray()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2,旋转轴到料串位置P4");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
private void LI_09_ScanCode()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_09_ScanCode);
LastCodeList = new List<string>();
if (YuCodeList.Count > 0)
{
InOutStoreLog("入料检测:开始扫码:使用预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(YuCodeList);
YuCodeList = new List<string>();
LI_11_AxisToTray();
}
else
{
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastCodeList.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, 3000);
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:", ex);
}
}
}
private void YuScanCode()
{
//TODO 此处需要等待空托盘
if (ShelfNoTray.Equals(false))
{
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ": ,预扫码");
//还有料盘,直接扫码
YuCodeList = new List<string>();
List<string> bijiaoList = new List<string>(LastCodeList);
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
Thread.Sleep(500);
YuCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim() + "预扫码");
bool isCanUse = true;
//判断是否可用
foreach (string nC in YuCodeList)
{
foreach (string n in bijiaoList)
{
if (nC.Length > 15 && nC.Equals(n))
{
LogUtil.error(Name + "预扫码结果【" + nC + "】与上个条码【" + n + "】重复,预扫码不可用");
isCanUse = false;
break;
}
}
}
if (!isCanUse)
{
YuCodeList = new List<string>();
}
//if (!CodeManager.HasRightCode(YuCodeList.ToArray()))
//{
// YuCodeList = new List<string>();
//}
return YuCodeList;
});
}
catch (Exception ex)
{
LogUtil.error(" 为下一盘料扫码出错:", ex);
}
}
}
private void CheckHasTray()
{
if (IOValue(IO_Type.BatchAxis_Check).Equals(IO_VALUE.HIGH) && ShelfNoTray.Equals(false))
{
LI_09_ScanCode();
}
else
{
if (ShelfNoTray.Equals(false))
{
//判断当前位置是否在指定的位置
int currP = T1_BatchAxis.GetAclPosition();
int chaz = Math.Abs(currP - Config.BatchAxis_P2);
if (chaz > T1_BatchAxis.Config.CanErrorCountMax)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog(" CheckHasTray:上料轴开始慢速上升到P3点,等待检测到料盘");
ShelfNoTray = false;
BatchAxisToP2(false);
return;
}
}
//无料盘
ShelfNoTray = true;
MoveInfo.NextMoveStep(StoreMoveStep.LI_31_BatchAxisToP1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ":未检测到料盘,提升伺服到P1点");
T1_BatchAxis.SuddenStop();
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P2Speed);
}
}
private void BatchAxisToP2(bool isFirstMove = true)
{
int targetP2 = Config.BatchAxis_P2;
int targetSpeed = Config.BatchAxis_P2Speed;
if (!isFirstMove)
{
int currPosition = T1_BatchAxis.GetAclPosition();
if (currPosition != -1)
{
targetP2 = currPosition + Config.BatchAxis_ChangeValue * 80;
if (targetP2 > Config.BatchAxis_P2)
{
targetP2 = Config.BatchAxis_P2;
}
LogUtil.info(Name + " BatchAxisToP2 目标P2: " + targetP2 + "(" + currPosition + ")");
}
//targetSpeed = Config.BatchAxis_P3Speed / 2;
}
MoveInfo.TimeOutSeconds = 200;
MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = T1_BatchAxis.GetAclPosition();
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.T1_Batch_Axis, targetP2, targetSpeed));
Config.T1_Batch_Axis.TargetPosition = targetP2;
T1_BatchAxis.AbsMove(null, targetP2, targetSpeed);
//开始检测信号
T1_BatchAxis.BatchAxisStartCheck(IO_Type.BatchAxis_Check, IO_VALUE.HIGH);
}
private int GetHeight()
{
LastHeight = 0;
int AxisChangeValue = Config.BatchAxis_ChangeValue;
//计算高度
EndMovePosition = T1_BatchAxis.GetAclPosition();
bool isLast = false;
int chaz = Math.Abs(EndMovePosition - Config.BatchAxis_P2);
if (chaz < T1_BatchAxis.Config.CanErrorCountMax)
{
isLast = true;
}
float height = (float)Math.Ceiling(1F * Math.Abs(EndMovePosition - StartMovePosition) / AxisChangeValue);
string buchongStr = "";
if (isLast)
{
buchongStr = "(最后一盘料已补充5)";
height += 5;
}
//如果检测出<=15,都按照8计算
if (height <= 15)
{
LastHeight = 8;
}
else
{
List<int> heightList = new List<int> { 8, 12, 16, 20 };
heightList = (from m in heightList orderby m descending select m).ToList<int>();
float minCha = height;
foreach (int h in heightList)
{
//取差值最小的接近值
float cha = Math.Abs(h - (height - 4));
if (cha < minCha)
{
LastHeight = h;
minCha = cha;
}
}
}
if (LastHeight <= 8) { LastHeight = 8; }
string code = CodeManager.ProcessCode(LastCodeList);
string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + code + "】";
LogUtil.info(msg);
return LastHeight;
}
public int GetWidth()
{
return 7;
}
#endregion
......
......@@ -105,7 +105,7 @@ namespace OnlineStore.DeviceLibrary
{
return;
}
if (storeRunStatus < StoreRunStatus.Runing || isInSuddenDown || isNoAirCheck)
if (runStatus < StoreRunStatus.Runing || isInSuddenDown || isNoAirCheck)
{
return;
}
......@@ -136,7 +136,7 @@ namespace OnlineStore.DeviceLibrary
}
TimeSpan span = DateTime.Now - checkAlarmTime;
//在回原点,复位,出入库时,检测报警间隔减小
if ((storeRunStatus.Equals(StoreRunStatus.Runing) && span.TotalSeconds < 3) || span.TotalSeconds < 1)
if ((runStatus.Equals(StoreRunStatus.Runing) && span.TotalSeconds < 3) || span.TotalSeconds < 1)
{
return false;
}
......@@ -165,7 +165,7 @@ namespace OnlineStore.DeviceLibrary
internal void MoveEndP()
{
MoveInfo.EndMove();
storeRunStatus = StoreRunStatus.Runing;
runStatus = StoreRunStatus.Runing;
storeStatus = StoreStatus.StoreOnline;
if (alarmType.Equals(AlarmType.None))
{
......@@ -194,7 +194,10 @@ namespace OnlineStore.DeviceLibrary
{
if (wait.IsEnd)
{
continue;
if (!wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
continue;
}
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
......@@ -220,18 +223,23 @@ namespace OnlineStore.DeviceLibrary
{
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = StoreManager.Config.IOSingle_TimerOut;
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs && NoAlarm())
if (!wait.IsEnd)
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Alarm(AlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
if (wait.IoType.Equals(IO_Type.Line_BackRun) || wait.IoType.Equals(IO_Type.Line_Run))
{
isOk = false;
break;
IOMove(wait.IoType, wait.IoValue);
}
else if (span.TotalMilliseconds > timeOutMs && NoAlarm())
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Alarm(AlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
}
......@@ -239,6 +247,10 @@ namespace OnlineStore.DeviceLibrary
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else
{
wait.IsEnd = CheckWaitResult(MoveInfo, wait);
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
......@@ -279,6 +291,10 @@ namespace OnlineStore.DeviceLibrary
Alarm(AlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
}
protected virtual bool CheckWaitResult(StoreMoveInfo moveInfo, WaitResultInfo wait)
{
return false;
}
#endregion
}
......
......@@ -135,5 +135,15 @@ namespace OnlineStore.DeviceLibrary
}
return Start(IO_Type.Hoister_Forward, IO_Type.Hoister_Forward);
}
public bool IsBack()
{
if (IOManager.IOValue(IO_Type.Hoister_Back, subType).Equals(IO_VALUE.HIGH) &&
IOManager.IOValue(IO_Type.Hoister_Forward, subType).Equals(IO_VALUE.LOW))
{
return true;
}
return false;
}
}
}
......@@ -269,163 +269,8 @@ namespace OnlineStore.DeviceLibrary
path = path.Substring(0, path.Length - 1);
return path;
}
///// <summary>
///// 3 放入料架(A,B,C,D)后调用,根据返回值决定当前料架是否放满,以及后续是否还有任务
//// 地址: /rest/api/qisda/device/putShelfFinished
///// </summary>
//private static string Addr_putShelfFinished = "/rest/api/qisda/device/putShelfFinished";
//public static string PutShelfFinished(string deviceName, string barcode, string rfid, string rfidPosId, out ShelfData shelfData)
//{
// string msg = "";
// shelfData = null;
// try
// {
// Dictionary<string, string> paramMap = new Dictionary<string, string>();
// paramMap.Add("barcode", barcode); // 参数: barcode=料盘的条码
// paramMap.Add("rfid", rfid); // rfid = 料架的RFID信息
// paramMap.Add("rfidLoc", rfidPosId); // rfidLoc=料架的架位信息
// // paramMap.Add("robotIndex", "0"); // robotIndex = 机器人编号(非机器人放置时不传此参数), IP为51的机器人为1, 52的机器人为2, 53的机器人为3
// string server = GetAddr(Addr_putShelfFinished, paramMap);
// string resultStr = HttpHelper.Post(server, "");
// LogUtil.info("PutShelfFinished 【" + server + "】【" + resultStr + "】");
// // 返回: {"code": 0, "msg":"ok", "data":{"rfid":"xxx","smallEmpty":0,"bigEmpty":0, "packageEmpty":0,"cutPackageTask":0,"packageTask":10,"cutTask":10, "smallTask":5, "bigTask":5}
// ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
// if (serverResult == null)
// {
// return msg = deviceName + "PutShelfFinished【 " + barcode + "】【" + rfid + "】【" + rfidPosId + "】没有收到服务器反馈";
// }
// else if (serverResult.code.Equals(0).Equals(false))
// {
// return msg = deviceName + " PutShelfFinished【 " + barcode + "】【" + rfid + "】【" + rfidPosId + "】 :" + serverResult.msg;
// }
// //if (String.IsNullOrEmpty(serverResult.data).Equals(false))
// //{
// // shelfData = JsonHelper.DeserializeJsonToObject<ShelfData>(serverResult.data);
// //}
// shelfData = serverResult.data;
// }
// catch (Exception ex)
// {
// LogUtil.error(deviceName + " PutShelfFinished error : " + ex.ToString());
// }
// return "";
//}
/// <summary>
/// 2 料盘流转位置信息更新
/// 地址: /rest/api/qisda/device/updateLocInfo
/// </summary>
private static string Addr_updateLocInfo = "/rest/api/qisda/device/updateLocInfo";
public static string UpdateTrayLoc(string deviceName, string barcode, string locInfo, out int taskCount)
{
taskCount = 0;
string msg = "";
try
{
if (String.IsNullOrEmpty(barcode))
{
return msg;
}
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);//barcode = 料盘的条码
paramMap.Add("status", "INSHELF"); // status = 状态信息, 移栽 = MOVING, 流水线 = INLINE, 皮带线 = INBELT
paramMap.Add("locInfo", locInfo); // locInfo = 位置信息,移栽时为移栽编号,流水线时为托盘号,皮带线时为皮带线编号,机器人时为机器人编号
string server = GetAddr(Addr_updateLocInfo, paramMap);
string resultStr = HttpHelper.Post(server, "");
LogUtil.info(deviceName + " [" + locInfo + "] UpdateTrayLoc 【" + server + "】【" + resultStr + "】");
// 返回: { "code": 0, "msg":"ok", "data":""}
//[A04@1] UpdateTrayLoc 【http://10.85.160.25/myproject/rest/api/qisda/device/updateLocInfo?barcode=R006982020013134910&status=INSHELF&locInfo=A04%401】【{"code":0,"msg":"ok","data":{"taskCount":"2"}}】
ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
if (serverResult == null)
{
msg = deviceName + "UpdateTrayLoc【 " + barcode + "】【" + "INSHELF" + "】【" + locInfo + "】没有收到服务器反馈";
}
else if (serverResult.code.Equals(0))
{
if (serverResult.data != null && (String.IsNullOrEmpty(serverResult.data.taskCount).Equals(false)))
{
try
{
taskCount = Convert.ToInt32(serverResult.data.taskCount);
}
catch (Exception ex)
{
}
}
}
else
{
// code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = deviceName + " UpdateTrayLoc【 " + barcode + "】【" + "INSHELF" + "】【" + locInfo + "】 :" + "[" + serverResult.code + "]" + serverResult.msg + ",taskCount=" + taskCount;
}
if (!msg.Equals(""))
{
LogUtil.error(msg);
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " UpdateTrayLoc error " + ex.ToString());
}
return msg;
}
private static string Addr_clearPutInRfid = "/service/store/qisda/clearPutInRfid";
public static string clearPutInRfid(string deviceName, string rfid)
{
string msg = "";
try
{
if (String.IsNullOrEmpty(rfid))
{
return msg;
}
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfid", rfid);//rfid
string server = GetAddr(Addr_clearPutInRfid, paramMap);
string resultStr = HttpHelper.Post(server, "");
LogUtil.info(deviceName + "clearPutInRfid 【" + server + "】【" + resultStr + "】");
}
catch (Exception ex)
{
LogUtil.error(deviceName + " clearPutInRfid error " + ex.ToString());
}
return msg;
}
public static int GetShelfPosIndex(string shelfId, List<String> shelfPosList)
{
int loc = -1;
if (shelfPosList.Contains(shelfId))
{
loc = shelfPosList.IndexOf(shelfId) + 1;
}
else
{
try
{
loc = int.Parse(shelfId);
}
catch (Exception ex)
{
}
}
return loc;
}
internal static string GetShelfIDByLoc(int rfidLoc, List<string> shelfPosList)
{
string shelfId = "";
if (rfidLoc.Equals(-1))
{
shelfId = shelfPosList[0];
}
if (rfidLoc >= 1 && rfidLoc <= 8 && rfidLoc <= shelfPosList.Count)
{
shelfId = shelfPosList[rfidLoc - 1];
}
return shelfId;
}
public static string ProcessCode(int LastWidth, int LastHeight, List<string> LastScanCodes)
{
string message = "";
......@@ -446,96 +291,35 @@ namespace OnlineStore.DeviceLibrary
}
return message;
}
// 分盘料/紧急料放上料串或料架时调用 /rest/api/qisda/device/afterPutCut
private static string Addr_afterPutCut = "/rest/api/qisda/device/afterPutCut";
public static string afterPutCut(string deviceName, string rfid, string barcode, string cid, int rfidLoc, out TaskData afterData)
{
afterData = null;
string msg = "";
try
{
//参数:
//cid: 料仓cid,流水线可传入空
//barcode : 条码
//rfid : RFID
//rfidLoc: 料架位置,流水线可传-1
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode); // 参数: barcode=料盘的条码
paramMap.Add("rfid", rfid); // rfid = 料架的RFID信息
paramMap.Add("rfidLoc", rfidLoc.ToString()); // rfidLoc=料架的架位信息
paramMap.Add("cid", cid); // 料仓cid,流水线可传入空
string server = GetAddr(Addr_afterPutCut, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("afterPutCut " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
//> 返回:
//>>` {"code": 0, "msg":"ok", "data":{"cutPackageTask":"0","urgentPackageTask":"20","cutTask":"21","urgentTask":"22"}} `
//>>
//>> - code: 0为正常,其他为异常,
//>> - msg:消息,
//>> - data:为包装料仓的空闲仓位数(key为与客户端一致的料仓标识, value为空闲仓位)
//>> - cutPackageTask: 表示当前包装仓的分盘任务数
//>> - urgentPackageTask: 表示当前包装仓的紧急料任务数
//>> - cutTask: 表示流水线分盘任务数
//>> - urgentTask: 表示流水线紧急料任务数
AfterPutData serverResult = JsonHelper.DeserializeJsonToObject<AfterPutData>(resultStr);
if (serverResult == null)
{
return msg = deviceName + "afterPutCut【 " + barcode + "】【" + rfid + "】【" + rfidLoc + "】没有收到服务器反馈";
}
else if (serverResult.code.Equals(0).Equals(false))
{
return msg = deviceName + " afterPutCut【 " + barcode + "】【" + rfid + "】【" + rfidLoc + "】 :" + serverResult.msg;
}
afterData = serverResult.data;
return "";
}
catch (Exception ex)
{
LogUtil.error(deviceName + " " + ex.ToString());
}
return msg;
}
// 分盘料/紧急料启动时获取料架的虚拟RFID调用 地址: /rest/api/qisda/device/findTempRfid
private static string Addr_findTempRfid = "/rest/api/qisda/device/findTempRfid";
public static string findTempRfid(string deviceName, string rfid, out string tempRfid)
// 取消任务地址: /cancelPutInTask //参数: barcode
private static string Addr_cancelPutInTask = "/rest/api/qisda/device/cancelPutInTask";
public static string cancelPutInTask(string deviceName, string barcode)
{
tempRfid = "";
string msg = "";
try
{
// 参数: rfid: RFID
// 返回: "code": 0, "msg":"ok", "data":{ "tempRfid":""}
// code: 0为正常,其他为异常,
//msg: 消息,
//data: tempRfid: 表示当前料架(料串)对应的虚拟RFID
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfid", rfid); // rfid: RFID
paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_findTempRfid, paramMap);
string server = GetAddr(Addr_cancelPutInTask, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("findTempRfid " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
LogUtil.info(deviceName + "cancelPutInTask " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (data == null)
{
return msg = deviceName + "findTempRfid【 " + rfid + "】 没有收到服务器反馈";
return msg = deviceName + " cancelPutInTask【 " + barcode + "】 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = deviceName + " findTempRfid【 " + rfid + "】 :" + data.msg;
}
if (data.data != null && data.data.ContainsKey("tempRfid"))
{
tempRfid = data.data["tempRfid"];
return msg = deviceName + " cancelPutInTask【 " + barcode + "】 :" + data.msg;
}
return "";
}
catch (Exception ex)
......@@ -544,177 +328,143 @@ namespace OnlineStore.DeviceLibrary
}
return msg;
}
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string deviceName, string cid, string rfid, out List<ShelfLockData> shelfLockDatas)
private static string spiltStr = "##";
private static string Addr_PosForPutin = "/service/store/emptyPosForPutin";
public static GetPosResult GetPosId(string deviceName, List<string> codeList, int height, int width, int shelfNum)
{
string msg = "";
shelfLockDatas = null;
GetPosResult result = new GetPosResult();
try
{
string codeStr = "";
List<string> list = new List<string>();
foreach (string str in codeList)
{
if (list.Contains(str.Trim()) || String.IsNullOrEmpty(str.Trim()))
{
continue;
}
list.Add(str.Trim());
string code = "=" + width + "x" + height + "=" + str.Trim();
codeStr = codeStr + code + spiltStr;
}
codeStr = CodeManager.ReplaceCode(codeStr);
//http://localhost/myproject/service/store/emptyPosForPutin
// 参数:cids: 多个 cid
//code: 条码内容
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add(ParamDefine.rfid, rfid);
paramMap.Add("cids", Config.All_CIDs);
paramMap.Add("code", codeStr);
paramMap.Add(ParamDefine.rfid, shelfNum.ToString());
string server = GetAddr(Addr_getShelfLockInfo, paramMap);
string server = GetAddr(Addr_PosForPutin, paramMap);
DateTime startTime = DateTime.Now;
LogUtil.info(deviceName + "【" + shelfNum + "】【 " + codeStr + "】 ,获取入库库位:");
string resultStr = HttpHelper.Post(server, "");
string resultStr = HttpHelper.Post(server, "", Encoding.UTF8, 10000, out result.IsTimeOut);
LogUtil.info(deviceName + " 料架锁定状态 " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
if (serverResult == null)
LogUtil.info(deviceName + "CodeReceived " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
if (result.IsTimeOut)
{
msg = deviceName + " 没有收到服务器反馈";
LogUtil.info(msg);
return false;
return result;
}
//{"result":"0","msg":"","pos":"11#AC1_18_4_28","barcode":"R506072019102200414","cid":"line-ac-11"}
LineOperation serverResult = JsonHelper.DeserializeJsonToObject<LineOperation>(resultStr);
if (serverResult.data.Count == 0) //该料架未锁定
if (serverResult == null)
{
msg = deviceName + " 料架【" + rfid + "】 没有被锁定";
LogUtil.info(msg);
return false;
result.Msg = deviceName + " 【" + codeStr + "】结果:没有收到服务器反馈,调用 cancelPutInTask ";
cancelPutInTask(deviceName, codeStr);
result.Param = new InOutParam( codeStr, "", width,height,1, shelfNum, true, "没有收到服务器反馈");
return result;
}
else //该料架存在锁定库位的料
else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
{
shelfLockDatas = new List<ShelfLockData>();
string plates = "";
foreach (ShelfLockData item in serverResult.data)
result.Result = serverResult.result;
result.Msg = deviceName + " 【" + codeStr + "】结果:" + serverResult.msg;
result.Param = new InOutParam(codeStr, "", width, height, 1, shelfNum, true, serverResult.msg);
return result;
}
result.Result = serverResult.result;
if (!serverResult.pos.Equals(""))
{
string posId = serverResult.pos;
//根据库位号查找移栽
// 判断PosID是否已经在入库或者在排队列表中,如果已经存在,加入列表失败
result.Param = new InOutParam( serverResult.barcode, posId, width, height,0, shelfNum, false,"");
int storeId = result.Param.GetStoreId();
if (Store.BoxMap.ContainsKey(storeId))
{
LogUtil.info("锁定的CID=" + item.cid + "; 当前CID=" + cid);
if (item.cid.Equals(cid))//该料盘属于此料仓
BoxBean box = Store.BoxMap[storeId];
if (box.IsReviceInPosId( posId))
{
shelfLockDatas.Add(item);
plates += item.lockPos + "# ";
result.Param.InStoreNg = true;
result.Param.NgMsg = "入库库位重复";
result.Msg = deviceName + ("收到服务器入库命令 " + "入库库位重复: " + result.Param.ToStr() + " ,入库失败!");
return result;
}
LogUtil.info(deviceName + "收到入库命令: " + result.Param.ToStr() + " ");
}
else
{
result.Param.InStoreNg = true;
result.Param.NgMsg = "未找到料仓[" + storeId + "]";
result.Msg = deviceName + ("收到服务器入库命令 " + "未找到料仓[" + storeId + "]: " + result.Param.ToStr() + " ,入库失败!");
return result;
}
msg = deviceName + " 料架【" + rfid + "】 在该料仓锁定库位的有:【" + plates + "】";
LogUtil.info(msg);
return true;
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " ", ex);
}
return false;
return result;
}
private static string Addr_PosForPutin = "/service/store/emptyPosForPutin"; //获取当前料盘属于的料仓编号
public static bool GetPosForPutIn(string deviceName, BOX_Config boxConfig, string barcode, string rfid, int rfidLoc)
public static void SendPosToStoreCheck(string deviceName, InOutParam param)
{
string msg = "";
try
if (param == null || param.InStoreNg)
{
// http://localhost/myproject/service/store/emptyPosForPutin
// 参数:cids: 多个 cid
//code: 条码内容
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("cids", Config.All_CIDs.Replace('#', ','));
paramMap.Add("code", barcode);
paramMap.Add(ParamDefine.rfid, rfid);
paramMap.Add("rfidLoc", rfidLoc.ToString());
string server = GetAddr(Addr_PosForPutin, paramMap);
DateTime startTime = DateTime.Now;
LogUtil.info(deviceName + " 条码【 " + barcode + "】料串【" + rfid + "】,获取入库库位:");
string resultStr = HttpHelper.Post(server, "");
LogUtil.info(deviceName + "CodeReceived " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
//{"result":"0","msg":"","pos":"11#AC1_18_4_28","barcode":"R506072019102200414","cid":"line-ac-11"}
LineOperation serverResult = JsonHelper.DeserializeJsonToObject<LineOperation>(resultStr);
if (serverResult == null)
{
msg = deviceName + " 【" + barcode + "】结果:没有收到服务器反馈 ";
LogUtil.info(msg);
return false;
}
else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
{
msg = deviceName + " 【" + barcode + "】结果:" + serverResult.msg;
LogUtil.info(msg);
return false;
}
if (serverResult.cid.Equals(boxConfig.CID)) //该料盘在此料仓
{
// 仓位命名: 4D01020304
//第1和第2位表示楼层(4D)
//第3和第4位表示料仓(01) 01 - 18为流水线料仓, 19 - 24为包装料仓
//第5和第6位表示列(02)
//第7和第8位表示行(03)
//第9和第10位表示隔板位置(04)
//例如: 4D12010124 表示4楼12号料仓第1列第1行架子上的第24个隔板位置
//4D19050208 表示4楼19号料仓(包装料仓)第5列第2行架子上的第8个隔板位置
msg = deviceName + " 料盘【" + barcode + "】属于该料仓【" + boxConfig.CID + "】";
LogUtil.info(msg);
return true;
}
else
return;
}
int storeId = param.GetStoreId();
MoveEquip moveEquip = LineManager.Line.MoveEquipMap[storeId];
if (LineServer.BoxCanInStore(moveEquip.DeviceID))
{
LineServer.CheckInStorePos(storeId, param);
}
else
{
//等待3秒后重发验证
Task.Factory.StartNew(delegate
{
msg = deviceName + " 料盘【" + barcode + "】不属于该料仓【" + boxConfig.CID + "】";
LogUtil.info(msg);
return false;
}
LogUtil.error(deviceName + "[" + moveEquip.Name + " ]入库命令: " + param.ToStr() + " 给料仓发送验证失败,等待3秒后重发 ");
Thread.Sleep(3000);
LineServer.CheckInStorePos(storeId, param);
});
}
catch (Exception ex)
lock (moveEquip.waitInListLock)
{
LogUtil.error(deviceName + " ", ex);
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(deviceName + "[" + moveEquip.Name + " ]入库命令: " + param.ToStr() + "加入等待列表中!");
moveEquip.waitInStoreList.Add(param);
}
return false;
}
}
public class AfterPutData
{
//>>` {"code": 0, "msg":"ok", "data":{"cutPackageTask":"0","urgentPackageTask":"20","cutTask":"21","urgentTask":"22"}} `
//>>
//>> - code: 0为正常,其他为异常,
//>> - msg:消息,
//>> - data:为包装料仓的空闲仓位数(key为与客户端一致的料仓标识, value为空闲仓位)
//>> - cutPackageTask: 表示当前包装仓的分盘任务数
//>> - urgentPackageTask: 表示当前包装仓的紧急料任务数
//>> - cutTask: 表示流水线分盘任务数
//>> - urgentTask: 表示流水线紧急料任务数
public int code { get; set; }
public string msg { get; set; }
public TaskData data { get; set; }
}
public class TaskData
public class GetPosResult
{
public string Msg = "";
/// <summary>
/// urgentPackageTask: 表示当前包装仓的紧急料任务数
/// </summary>
public int urgentPackageTask { get; set; }
/// <summary>
/// cutPackageTask: 表示当前包装仓的分盘任务数
/// </summary>
public int cutPackageTask { get; set; }
/// <summary>
/// cutTask: 表示流水线分盘任务数
/// 99:暂时不能入库,需要重新获取库位。100:服务器需要更新,需要重新获取库位
/// </summary>
public int cutTask { get; set; }
public int Result = 0;
/// <summary>
/// urgentTask: 表示流水线紧急料任务数
/// 获取超时,需要重新获取库位
/// </summary>
public int urgentTask { get; set; }
}
public class ServerData
{
//{"code":0,"msg":"ok","data":"7"}
//返回: {"code": 0, "msg":"ok", "data":{"rfid":"xxx","smallEmpty":0,"bigEmpty":0, "packageEmpty":0,"cutPackageTask":0,"packageTask":10,"cutTask":10, "smallTask":5, "bigTask":5,"taskCount":"3"}
public int code { get; set; }
public string msg { get; set; }
public ShelfData data { get; set; }
public bool IsTimeOut = false;
public InOutParam Param = null;
}
public class RfidData
{
//{"code":0,"msg":"ok","data":"7"}
......@@ -723,103 +473,7 @@ namespace OnlineStore.DeviceLibrary
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
public class ShelfData
{
/// <summary>
/// UpdateTrayLoc后,会返回taskCount
/// </summary>
public string taskCount { get; set; }
/// <summary>
/// rfid: 当前料架的RFID
/// </summary>
public string rfid { get; set; }
/// <summary>
/// packageEmpty: 当前料架还可放置的包装料的数量(C料架和A料架有值, 其他料架为0)
/// </summary>
public int packageEmpty { get; set; }
/// <summary>
/// smallEmpty: 当前料架还可放置的小料盘(7x8)的数量(D料架, 其他料架为0)
/// </summary>
public int smallEmpty { get; set; }
/// <summary>
/// bigEmpty:当前料架还可放置的大料盘的数量(C料架, 其他料架为0)
/// </summary>
public int bigEmpty { get; set; }
/// <summary>
/// cutPackageTask:还有多少盘分盘的包装料任务(放到A料架上, 转运到分盘区)
/// </summary>
public int cutPackageTask { get; set; }
/// <summary>
/// packageTask:还有多少盘包装料任务(放到A料架上, 并转运到包装线, 最终到C料架)
/// </summary>
public int packageTask { get; set; }
/// <summary>
/// cutTask: 还有多少盘分盘料任务(放置到料串B上, 转运到分盘区)
/// </summary>
public int cutTask { get; set; }
/// <summary>
/// smallTask: 还有多少盘小料任务(放置到双层线的D料架上)
/// </summary>
public int smallTask { get; set; }
/// <summary>
/// bigTask: 还有多少盘大料任务(放置到C料架上)
/// </summary>
public int bigTask { get; set; }
// rfid: 当前料架的RFID
// packageEmpty: 当前料架还可放置的包装料的数量(C料架和A料架有值, 其他料架为0)
// smallEmpty: 当前料架还可放置的小料盘(7x8)的数量(D料架, 其他料架为0)
// bigEmpty:当前料架还可放置的大料盘的数量(C料架, 其他料架为0)
// cutPackageTask:还有多少盘分盘的包装料任务(放到A料架上, 转运到分盘区)
// packageTask:还有多少盘包装料任务(放到A料架上, 并转运到包装线, 最终到C料架)
// cutTask: 还有多少盘分盘料任务(放置到料串B上, 转运到分盘区)
// smallTask: 还有多少盘小料任务(放置到双层线的D料架上)
// bigTask: 还有多少盘大料任务(放置到C料架上)
}
public class ShelfLockInfo
{
//返回: {"code":0,"msg":"ok","data":
//[{"barcode":"S20052301213","cid":"packing-20","rfid":"A12","rfidLoc":"3","lockPos":"4D2001AA0006","lockPosId":"1231"}]}
/// <summary>
/// 返回码,0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public List<ShelfLockData> data { get; set; }
}
public class ShelfLockData
{
/// <summary>
/// 库位中料盘的条码
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 库位中料盘的锁定库位对应的料仓编
/// </summary>
public string cid { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
/// <summary>
/// 料架的库位
/// </summary>
public int rfidLoc { get; set; }
/// <summary>
/// 库位中料盘的锁定库位
/// </summary>
public string lockPos { get; set; }
}
}
public class LineOperation
{
// //{"result":"0","msg":"","pos":"11#AC1_18_4_28","barcode":"R506072019102200414","cid":"line-ac-11"}
......
......@@ -12,7 +12,7 @@ namespace OnlineStore.DeviceLibrary
{
public class InOutParam
{
public InOutParam(string wareNo = "", string posId = "", string platew = "", string plateh = "", int targetP = 0)
public InOutParam(string wareNo = "", string posId = "", int platew = 0, int plateh = 0, int targetP = 0,int shefNum,bool IsNg=false,string ngMsg="" )
{
WareCode = wareNo;
PosID = posId;
......@@ -20,6 +20,9 @@ namespace OnlineStore.DeviceLibrary
this.PlateW = platew;
this.PlateH = plateh;
this.TargetPosition = targetP;
this.shelfNum = shefNum;
this.InStoreNg = IsNg;
this.NgMsg = ngMsg;
}
public InOutParam(string wareNo, string posId, LineMoveP linePosition, int targetP = 0)
{
......@@ -47,11 +50,25 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 料盘高度
/// </summary>
public string PlateH { get; set; }
public int PlateH { get; set; }
/// <summary>
/// 料盘宽度
/// </summary>
public string PlateW { get; set; }
public int PlateW { get; set; }
/// <summary>
/// 是否是入料NG料
/// </summary>
public bool InStoreNg = false;
/// <summary>
/// 入料NG消息
/// </summary>
public string NgMsg = "";
/// <summary>
/// 料架编号
/// </summary>
public int shelfNum = 0;
/// <summary>
/// 出入库目标位置,
/// 0=出库表示批量出料,入库表示目标库位
......
......@@ -8,7 +8,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
......@@ -223,7 +223,7 @@ namespace OnlineStore.DeviceLibrary
isInit = true;
}
}
public StoreRunStatus storeRunStatus
public StoreRunStatus runStatus
{
get
{
......@@ -261,7 +261,7 @@ namespace OnlineStore.DeviceLibrary
{
string sta = "运行中";
string aa = "";
switch (storeRunStatus)
switch (runStatus)
{
case StoreRunStatus.Busy:
sta = "忙碌";
......@@ -279,7 +279,7 @@ namespace OnlineStore.DeviceLibrary
sta = "等待启动";
break;
}
if (storeRunStatus > StoreRunStatus.Wait)
if (runStatus > StoreRunStatus.Wait)
{
//"0":"急停中", "1":"设备联机", "2":"故障中", "3":"入库执行中", "4":"出库执行中", 5":"料盘入仓位完成", "6":"料盘出仓位完成", 7":"设备调试中",
switch (storeStatus)
......@@ -344,14 +344,38 @@ namespace OnlineStore.DeviceLibrary
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
}
public void IOMove(string IoType, IO_VALUE value, bool isCheck = false)
//public void IOMove(string IoType, IO_VALUE value, bool isCheck = false)
//{
// if (isCheck && (IOValue(IoType).Equals(value)))
// {
// return;
// }
// IOManager.IOMove(IoType, value, baseConfig.Id);
//}
public void IOMove(string IoType, IO_VALUE value, bool isCheck = false, int msTime = 0)
{
if (isCheck && (IOValue(IoType).Equals(value)))
if (msTime <= 0)
{
return;
if (isCheck && (IOValue(IoType).Equals(value)))
{
return;
}
IOManager.IOMove(IoType, value, baseConfig.Id);
}
IOManager.IOMove(IoType, value, baseConfig.Id);
}
else
{
Task.Factory.StartNew(delegate
{
IOManager.IOMove(IoType, value, baseConfig.Id);
Thread.Sleep(msTime);
IO_VALUE tValue = value.Equals(IO_VALUE.HIGH) ? IO_VALUE.LOW : IO_VALUE.HIGH;
LogUtil.info(Name + "定时回写IO: [" + IoType + "]=[" + value + "],[" + baseConfig.Id + "],msTime=" + msTime);
IOManager.IOMove(IoType, tValue, baseConfig.Id);
});
}
}
public IO_VALUE IOValue(string IoType)
{
return IOManager.IOValue(IoType, baseConfig.Id);
......@@ -369,13 +393,27 @@ namespace OnlineStore.DeviceLibrary
protected void InOutStoreLog(string msg)
{
string type = "";
if (MoveInfo.MoveType.Equals(MoveType.OutStore))
if (ID > 0)
{
type = "出库";
if (MoveInfo.MoveType.Equals(MoveType.OutStore))
{
type = "出库";
}
else if (MoveInfo.MoveType.Equals(MoveType.InStore))
{
type = "入库";
}
}
else if (MoveInfo.MoveType.Equals(MoveType.InStore))
else
{
type = "入库";
if (MoveInfo.MoveType.Equals(MoveType.OutStore))
{
type = "出料";
}
else if (MoveInfo.MoveType.Equals(MoveType.InStore))
{
type = "入料";
}
}
string posId = MoveInfo.MoveParam != null ? "["+MoveInfo.MoveParam.PosID+"]" : "";
......
......@@ -115,6 +115,7 @@ namespace OnlineStore.DeviceLibrary
/// 无操作,等待状态
/// </summary>
Wait = 0,
#region 料仓复位 011 开始
/// <summary>
......@@ -325,271 +326,142 @@ namespace OnlineStore.DeviceLibrary
#region 入料装置入料处理,2001 开始
//线体入口料串检测到料架
// 链条转动到线体上料等待区检测
//提升伺服先上升到待机点,SL1升降盘定位气缸1后退,定位气缸下降,料架才能进入上料工位
//料架进入上料工位后,定位气缸先上升
//提升伺服下降到P2
////升降盘定位气缸前进
//提升伺服缓慢上升,绝对位置=P1,若上升到P1么有X105,那么没有料盘
// 检测到X105信号,提升伺服停止
// 上料横移机构取料
// 上料横移机构下降
// 上料横移机构夹紧
// 上料横移机构上升
// 提升伺服开始缓慢上升到位
// 计算高度,宽度并记录
// 上料横移机构到放料端
//等待拦截到托盘,并顶升上升,定位上升
// 上料横移机构下降
// 移栽伺服下降到对应盘高位置
//上料气缸放松
// 移栽伺服上升,
// 上料横移机构上升
/// <summary>
/// 提升轴先返回P1
///入料检测: 提升轴先返回P1
/// </summary>
LI_00_BatchAxisToP1 = 2001,
LI_01_BatchAxisToP1 = 2001,
/// <summary>
/// 入料流程:升降盘定位气缸后退
/// 入料检测:取料提升机构后退端
/// </summary>
LI_01_TrayLocation_After,
LI_02_HoisterBack,
/// <summary>
/// 入料流程:定位气缸下降
/// 入料检测:定位气缸下降
/// </summary>
LI_02_LocationCylinder_Down,
LI_03_LocationDown,
/// <summary>
/// 入口流水线转动,等待入料检测信号消失
/// 入料检测,转动料架,等待条件到达停止
/// </summary>
LI_03_LineStart,
LI_04_LineStart,
/// <summary>
/// 入口流水线转动,等待定位工位信号稳定1
/// 入料检测:流水线上料区检测到料架,流水线再正传五
/// </summary>
LI_04_WaitTime,
LI_05_WaitTime,
/// <summary>
///入料检测: 工位检测信号,定位气缸上升
///入料检测: 顶升气缸上升
/// </summary>
LI_05_LocationCylinder_Up,
LI_06_TopUp,
/// <summary>
/// 入料检测:提升轴下降到位P2
/// </summary>
LI_06_BatchAxisToP2,
/// <summary>
/// 入料检测:升降盘定位气缸第一次前进
/// </summary>
LI_07_TrayLocation_Before,
/// <summary>
/// 入料检测:升降盘定位气缸第一次后退
/// </summary>
LI_08_TrayLocation_Back,
/// <summary>
/// 入料检测:升降盘定位气缸前进
/// </summary>
LI_09_TrayLocation_Before,
/// <summary>
/// 入料检测:上料轴开始慢速上升到P3点,等待检测到料盘
/// 入料检测:取料提升机构前进
/// </summary>
LI_10_AxisUpMove,
LI_07_HoisterForward,
/// <summary>
/// 入料取料:横移机构先上升
/// 入料检测:上料轴开始慢速上升到P2点,等待检测到料盘
/// </summary>
LI_11_CylinderUp,
LI_08_AxisUpToP2,
/// <summary>
/// 入料取料:上料机构到放料端
/// </summary>
LI_12_CylinderGive,
/// <summary>
/// 入料检测到料盘:扫码
/// 入料检测:扫码
/// </summary>
LI_13_ScanCode,
LI_09_ScanCode,
/// <summary>
/// 料盘移栽:有料盘:上料横移机构取料
/// 入料检测:有料盘:升降轴到料串高点P2,旋转轴到料串位置P4
/// </summary>
LI_14_CylinderTake,
LI_11_AxisToTray,
/// <summary>
/// 料盘移栽:升降轴到P3
/// 取料:升降轴到料串低点P1
/// </summary>
LI_15_UpdownAxisToP3,
LI_12_UpdownAxisToP3,
/// <summary>
/// 料盘移栽:上料横移机构夹紧
/// </summary>
LI_16_CylinderTighten,
/// <summary>
/// 料盘移栽:升降伺服到P1点
/// </summary>
LI_17_UpdownAxisToP1,
/// <summary>
/// 料盘移栽:等待没有伺服料盘检测信号
/// 取料:夹爪气缸夹紧
/// </summary>
LI_18_WaitNoLocationCheck,
LI_13_CylinderTighten,
/// <summary>
/// 料盘移栽:批量轴到P3点,检测是否有料盘
/// 取料:升降轴到料串高点P2
/// </summary>
LI_19_BatchAxisToP3,
LI_14_UpdownToP1,
/// <summary>
/// 料盘移栽:记录高度尺寸
/// 取料:等待没有提升机构料盘检测
/// </summary>
LI_20_SaveSize,
LI_15_WaitNoCheck,
/// <summary>
/// 料盘移栽: 上料横移气缸放料SOL
/// 取料:批量轴到P2,计算高度,
/// </summary>
LI_21_CylinderGive,
LI_16_BatchAxisToP2,
/// <summary>
/// 提升轴下降到料盘不溢出的位置
/// 取料:记录高度尺寸
/// </summary>
LI_22_BatchAxisDown,
LI_17_SaveSize,
/// <summary>
/// 料盘移栽:从服务器获取入库库位号
/// </summary>
LI_23_GetPosID,
LI_18_GetPosID,
/// <summary>
/// 料盘移栽:等待空托盘到达,移栽伺服下降到P2,并预扫码
/// 料盘移栽:获取库位号完成,升降轴到料门口高点,旋转轴到料仓门口
/// </summary>
LI_24_WaitTray,
LI_19_ToBoxDoor,
/// <summary>
/// 料盘移栽: 上料机构下降
/// 料盘移栽: 升降轴到料门口低点,开始预扫码
/// </summary>
LI_25_CylinderDown,
LI_20_UpdownDown,
/// <summary>
/// 料盘移栽: 上料气缸放松
/// </summary>
LI_26_CylinderRelax,
LI_21_CylinderRelax,
/// <summary>
/// 料盘移栽: 上料横移机构上升
/// 料盘移栽: 升降轴到料门口高点
/// </summary>
LI_27_WaitCylinderUp,
LI_22_UpdownUp,
/// <summary>
/// 料盘移栽:上料横移机构上升,定位或者顶升可以先下降
/// 料盘移栽:旋转轴返回待机点P1,升降轴到料串高点P2
/// </summary>
LI_28_CylinderUp,
LI_23_AxisToWait,
/// <summary>
/// 料盘移栽:升降伺服到P1点
/// 料盘移栽:判断是否还有料
/// </summary>
LI_29_UpDownAxisToP1,
LI_24_ToNexTray,
/// <summary>
/// 上料完成,未检测到料盘,提升伺服到P2点
/// </summary>
LI_31_BatchAxisToP2 = 11031,
/// <summary>
/// 上料完成,升降盘定位气缸后退
/// </summary>
LI_32_TrayLocationCylinder_After = 11032,
/// <summary>
/// 上料完成,提升伺服到P1点
/// </summary>
LI_33_BatchAxisToP1 = 11033,
/// <summary>
/// 上料完成,等待出料线体无料架
/// 送出料架,未检测到料盘,提升伺服到P1点
/// </summary>
LI_34_OutCheck = 11034,
LI_31_BatchAxisToP1 = 2031,
/// <summary>
/// 上料完成,出口顶升气缸上升
/// 送出料架,升降盘定位气缸后退
/// </summary>
LI_35_OutTopCylinder_Up = 11035,
LI_32_HoisterBack,
/// <summary>
///上料完成, 线体横移电机运转,等待料架到达出口
/// </summary>
LI_36_SideWayLineRun = 11036,
/// <summary>
///上料完成,等待料架到达出口
/// 送出料架,顶升气缸下降
/// </summary>
LI_37_WaitShelfGo = 11307,
LI_33_TopCylinderDown,
/// <summary>
///上料完成, 料架到达出口,线体横移电机停止
/// </summary>
LI_38_LineStop,
/// <summary>
///上料完成, 料架到达出口,出口顶升下降,定位气缸下降,
/// 送出料架,上料阻挡下降1秒,流水线开始转动
/// </summary>
LI_39_TopDown,
LI_34_WorkStopDown = 11034,
/// <summary>
///上料完成, 出口线体运转,料架到达出口处, 通知AGV取空料架
/// 送出料架,等待上料无料架
/// </summary>
LI_39_OutLineRun,
LI_35_WaitShelfGo = 11035,
/// <summary>
///上料完成, AGV到达,继续转动出口线体,送走出料料架,
///送出料架, 流水线再转动3秒,
/// </summary>
LI_40_OutLineRun,
/// <summary>
///上料完成, 料架送出,
/// </summary>
LI_41_OutLineRun,
LI_36_LineRun,
#endregion
#region 把料架送出步骤 4000开始
/// <summary>
/// 送出空料架:顶升气缸下降
/// </summary>
BS_01_TopDown = 4001,
/// <summary>
/// 送出空料架:定位气缸下降
/// </summary>
BS_02_LocatinDown = 4002,
/// <summary>
/// 通知AGV准备空车
/// </summary>
BS_03_WaitEmptyAgv = 4003,
/// <summary>
/// 送出空料架:打开仓门
/// </summary>
BS_04_DoorOpen = 4004,
/// <summary>
/// 送出空料架:等待agvReady
/// </summary>
BS_05_WaitReady = 4005,
/// <summary>
/// 送出空料架:线体反转
/// </summary>
BS_06_LineBackRun = 4006,
/// <summary>
/// 送出空料架:等待取料工位无信号
/// </summary>
BS_07_WaitShelfOut = 4007,
/// <summary>
/// 送出空料架:等待取料工位无信号,入料口有信号
/// </summary>
BS_08_WaitLineIn = 4008,
/// <summary>
/// 送出空料架:再转动3000时间
/// </summary>
BS_09_WaitTime = 4009,
/// <summary>
/// 送出空料架:等待AGV离开后关闭仓门
/// </summary>
BS_10_WaitAGVLeave = 4010,
/// <summary>
/// 送出空料架:关闭仓门
/// </summary>
BS_11_CloseDoor = 4011,
#endregion
}
......
......@@ -183,10 +183,10 @@ namespace OnlineStore.DeviceLibrary
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitComAxis(ConfigMoveAxis axis, int targetPosition, int targetSpeed)
public static WaitResultInfo WaitBatchAxisMove(ConfigMoveAxis axis, int targetPosition, int targetSpeed)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W008_Compress;
wait.WaitType = WaitEnum.W008_BatchAxis;
wait.AxisInfo = axis;
wait.IsHomeMove = false;
wait.TargetPosition = targetPosition;
......@@ -194,7 +194,7 @@ namespace OnlineStore.DeviceLibrary
return wait;
}
internal static WaitResultInfo WaitCode()
internal static WaitResultInfo WaitScanCode()
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W009_ScanCode;
......@@ -251,9 +251,9 @@ namespace OnlineStore.DeviceLibrary
{
return "料盘高度【" + TargetPosition + "】 ";
}
else if (WaitType.Equals(WaitEnum.W008_Compress))
else if (WaitType.Equals(WaitEnum.W008_BatchAxis))
{
return "压紧轴压紧到位";
return "批量轴上升到上料点";
}
else if (WaitType.Equals(WaitEnum.W009_ScanCode))
{
......@@ -319,8 +319,7 @@ namespace OnlineStore.DeviceLibrary
public bool IsEnd { get; set; }
public int AgvAction = 0;
}
internal class WaitEnum
{
......@@ -353,9 +352,9 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
internal static int W007_ReelHeight = 7;
/// <summary>
/// 压紧轴压紧到位
/// 批量轴上升到上料点
/// </summary>
internal static int W008_Compress = 8;
internal static int W008_BatchAxis = 8;
/// <summary>
/// 扫码完成
/// </summary>
......
......@@ -167,6 +167,11 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("MiddleAxis_P3")]
public int MiddleAxis_P3 { get; set; }
/// <summary>
/// PRO,0,T2_旋转轴_料串取放料点_P4,MiddleAxis_P4,59004
/// </summary>
[ConfigProAttribute("MiddleAxis_P4")]
public int MiddleAxis_P4 { get; set; }
/// <summary>
/// PRO,0,T2_旋转轴P1速度,MiddleAxis_P1Speed,500
/// </summary>
[ConfigProAttribute("MiddleAxis_P1Speed")]
......@@ -180,7 +185,12 @@ namespace OnlineStore.LoadCSVLibrary
/// PRO,0,T2_旋转轴P3速度,MiddleAxis_P3Speed,500
/// </summary>
[ConfigProAttribute("MiddleAxis_P3Speed")]
public int MiddleAxis_P3Speed { get; set; }
public int MiddleAxis_P3Speed { get; set; }
/// <summary>
/// PRO,0,T2_旋转轴P4速度,MiddleAxis_P4Speed,500
/// </summary>
[ConfigProAttribute("MiddleAxis_P4Speed")]
public int MiddleAxis_P4Speed { get; set; }
/// <summary>
/// PRO,0,T3_升降轴料串取放料低点 P1,UpdownAxis_P1,5000
/// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!