Commit a63a8a86 几米阳光

增加自动出入库功能

1 个父辈 4ec0cea8
......@@ -192,7 +192,7 @@ namespace OnlineStore.AutoInOutStore
}
preOpen = isOpen;
btnOutStore.Enabled = isOpen;
//btnOutStore.Enabled = isOpen;
//btnInStore.Enabled = isOpen;
//btnAxisAMove.Enabled = isOpen;
......@@ -235,6 +235,14 @@ namespace OnlineStore.AutoInOutStore
cmbHomeType.SelectedIndex = 1;
timer1.Start();
store.ResetEvent += Store_ResetEvent;
cmbJianGe.Items.Clear();
for(int i = 0; i <= 20; i++)
{
cmbJianGe.Items.Add(i.ToString());
}
cmbJianGe.SelectedIndex = 0;
DebugStatus(false);
}
private void Store_ResetEvent()
......@@ -326,10 +334,10 @@ namespace OnlineStore.AutoInOutStore
if (store.autoNext)
{
string msg = store.autoMsg;
lblMsg.Text = msg;
if (btnStartAuTo.Text.Equals(StartAuto))
groupAuto.Text = msg;
if (btnStart.Text.Equals(StartAuto))
{
btnStartAuTo.Text = StopAuto;
btnStart.Text = StopAuto;
}
try
{
......@@ -345,18 +353,17 @@ namespace OnlineStore.AutoInOutStore
}
else
{
// lblMsg.Text = "没有开启自动出入库";
if (btnStartAuTo.Text.Equals(StopAuto))
{
btnStartAuTo.Text =StartAuto;
}
groupAuto.Text = "自动出入库操作";
btnStart.Text = StartAuto;
}
}
else
{
groupAuto.Text = StartAuto;
lblThisSta.Text = WaitStart;
//lblWarnMsg.Text = "";
btnStartAuTo.Text =StartAuto;
btnStart.Text =StartAuto;
lblDoorStatus.Text =ResourceCulture.GetString(ResourceCulture.NoDoorStatus, "仓门状态未知");
}
}catch(Exception ex)
......@@ -993,45 +1000,6 @@ namespace OnlineStore.AutoInOutStore
FormManager.ShowAxisDebug(store);
}
private void btnStartAuTo_Click(object sender, EventArgs e)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.CanotSingleInStore,"此设备不支持单个入库"), ResourceCulture.GetString(ResourceCulture.MsgTitle,"提示"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
if (store.storeRunStatus >= StoreRunStatus.HomeMoving)
{
if (store.autoNext)
{
store.autoNext = false;
btnStartAuTo.Text = StartAuto;
}
else
{
DialogResult res = MessageBox.Show(StartAuto+"?", ResourceCulture.GetString(ResourceCulture.MsgTitle,"提示"), MessageBoxButtons.YesNo);
if (res.Equals(DialogResult.Yes))
{
store.autoNext = true;
int jiange = FormUtil.GetIntValue(txtJiange);
store.autoJiange = jiange;
if (cmbPosition.SelectedIndex >= 0)
{
int currIndex = cmbPosition.SelectedIndex;
store.autoPositionIndex = currIndex;
string poText = cmbPosition.Text;
store.autoMsg = "自动出库:" + poText;
LogUtil.info(LOGGER, store.StoreName + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!");
//store.StartOutStoreMove(new InOutStoreParam("", poText));
store.StartInStoreMove(new InOutStoreParam("", poText), false);
}
btnStartAuTo.Text = StopAuto;
}
}
}
else
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.PleaseStartStore, "请先启动料仓!"));
}
}
private void 轴卡点动ToolStripMenuItem_Click(object sender, EventArgs e)
{
button1_Click(null, null);
......@@ -1313,16 +1281,11 @@ namespace OnlineStore.AutoInOutStore
{
this.timer1.Enabled = false;
}
if (this.停止ToolStripMenuItem.Enabled)
{
stop_button_Click(null, null);
}
LogUtil.info("ExitApp:停止料仓运行");
store.Exit();
LogUtil.info("ExitApp:料仓已停止,关闭所有DO");
IOManager.instance.CloseAllDO();
ACServerManager.CloseAllPort();
StoreOpenStatus(false);
LogUtil.info("ExitApp:关闭所有DO完成,端口所有IO连接");
LogUtil.info("ExitApp: 端口所有IO连接");
IOManager.instance.CloseAllConnection();
//KNDAIManager.CloseAllConnection();
//WCFControl.CloseWCF();
......@@ -1351,7 +1314,6 @@ namespace OnlineStore.AutoInOutStore
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
this.Hide();
DebugStatus(false);
}
private void FrmStoreBox_FormClosed(object sender, FormClosedEventArgs e)
{
......@@ -1520,7 +1482,7 @@ namespace OnlineStore.AutoInOutStore
{
ACServerManager.ServoOff(store.Config.Batch_Axis.DeviceName, store.Config.Batch_Axis.GetAxisValue());
//关闭串口,等下次重新打开
ACServerManager.ColsePort(store.Config.Batch_Axis.DeviceName);
//ACServerManager.ColsePort(store.Config.Batch_Axis.DeviceName);
Thread.Sleep(100);
IOManager.IOMove(IO_Type.Run_Sign, IO_VALUE.LOW);
......@@ -1700,11 +1662,71 @@ namespace OnlineStore.AutoInOutStore
groupAxis.Enabled = status;
groupComAxis.Enabled = status;
groupInout.Enabled = status;
if ( store.autoNext)
{
groupAuto.Enabled = true;
cmbJianGe.Enabled = false;
}
else
{
groupAuto.Enabled = status;
}
}
private void btnClearBuzzer_Click(object sender, EventArgs e)
{
IOManager.IOMove(IO_Type.Buzzer_Sign, IO_VALUE.LOW);
}
private void btnStart_Click(object sender, EventArgs e)
{
if (store.storeRunStatus >= StoreRunStatus.HomeMoving )
{
if (store.autoNext)
{
store.autoNext = false;
btnStart.Text = StartAuto;
}
else
{
DialogResult res = MessageBox.Show("确定开始自动出入库?", "提示", MessageBoxButtons.YesNo);
if (res.Equals(DialogResult.Yes))
{
store.autoNext = true;
int jiange = cmbJianGe.SelectedIndex;
store.autoJiange = jiange;
if (cmbPosition.SelectedIndex >= 0)
{
int currIndex = cmbPosition.SelectedIndex;
store.autoPositionIndex = currIndex;
store.AutoStartIndex = currIndex;
string poText = cmbPosition.Text;
ConfigAppSettings.SaveValue(Setting_Init.DebugPosId, poText);
store.autoMsg = "自动入库:" + poText;
string msg = AutomaticBaiting.doStartBatchIn();
if (msg.Equals(""))
{
btnStart.Text = StopAuto;
LogUtil.info(LOGGER, store.StoreName + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!");
}
else
{
MessageBox.Show(msg);
store.autoNext = false;
btnStart.Text = StartAuto;
LogUtil.info(LOGGER, store.StoreName + "自动出入库失败【"+msg+"】,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!");
}
DebugStatus(false);
}
}
}
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
}
}
......@@ -149,6 +149,9 @@ PRO,最后一盘料需要补充的高度,LastTrayAddHeight,10,,,,,,,,,
新料仓修改:增加一对门锁气缸输入信号
蜂鸣器和报警灯分开处理。
20190428
增加自动出入库功能。
......
......@@ -119,8 +119,19 @@ namespace OnlineStore.DeviceLibrary
{
serialBeanMap.Remove(portName);
}
LogUtil.info("ACServerManager 关闭串口【" + portName + "】 ");
}
public static void CloseAllPort()
{
List<string> kes = new List<string>(serialBeanMap.Keys);
foreach (string key in kes)
{
ColsePort(key);
}
}
/// <summary>
/// 是否成功打开伺服
/// </summary>
......
......@@ -22,7 +22,7 @@ namespace OnlineStore.DeviceLibrary
{
checkTimer = new System.Timers.Timer();
checkTimer.AutoReset = true;
checkTimer.Interval += 50;
checkTimer.Interval += 49;
checkTimer.Elapsed += CheckTimer_Elapsed;
checkTimer.Enabled = false;
}
......@@ -40,6 +40,7 @@ namespace OnlineStore.DeviceLibrary
return true;
}
private static bool IsInProcess = false;
private static DateTime preTime = DateTime.Now;
private static void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (IsInProcess) { return; }
......@@ -50,11 +51,15 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("批量上料轴,检测到【" + TargetIoType + "】信号,可以停止运动");
result = true;
}
//else if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1))
//{
// LogUtil.info("批量上料轴,检测到正极限信号,可以停止运动");
// result = true;
//}
TimeSpan span = DateTime.Now - preTime;
if (span.TotalMilliseconds > 100)
{
if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1))
{
LogUtil.info("批量上料轴,检测到正极限信号,可以停止运动");
result = true;
}
}
if (result)
{
//AutoAxisIsMove = 0;
......@@ -62,6 +67,7 @@ namespace OnlineStore.DeviceLibrary
ACServerManager.SuddenStop(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue());
StopCheck();
}
preTime = DateTime.Now;
IsInProcess = false;
}
}
......
......@@ -711,13 +711,15 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.info(StoreName + "关闭刹车,关闭伺服");
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
LogUtil.debug(StoreName + "关闭刹车完成,开始关闭伺服");
foreach (ConfigMoveAxis axis in moveAxisList)
{
LogUtil.debug(StoreName + " 开始关闭伺服 " +axis.DisplayStr);
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
//关闭串口,等下次重新打开
ACServerManager.ColsePort(axis.DeviceName);
}
Thread.Sleep(100);
LogUtil.debug(StoreName + "关闭伺服完成,开始关闭Run_Sign");
IOManager.IOMove(IO_Type.Run_Sign, IO_VALUE.LOW);
}
......@@ -778,11 +780,11 @@ namespace OnlineStore.DeviceLibrary
}
public void Exit()
{
if (!storeRunStatus.Equals(StoreRunStatus.Wait))
mainTimer.Enabled = false;
if (storeRunStatus > StoreRunStatus.Wait)
{
StopRun();
}
mainTimer.Enabled = false;
}
public override void Alarm(StoreAlarmType alarmType, string alarmDetial, string alarmMsg, StoreMoveType storeMoveType)
{
......@@ -1124,20 +1126,18 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(LOGGER, "IOTimeOutProcess出错:" + ex.ToString());
}
}
//private DateTime preProTime = DateTime.Now;
/// <summary>
/// 超过配置次数时需要复位
/// </summary>
private DateTime preProTime = DateTime.Now;
private void AutoResetProcess()
{
try
{
//TimeSpan span = DateTime.Now - preProTime;
//if (span.TotalSeconds < 1)
//{
// return;
//}
//preProTime = DateTime.Now;
TimeSpan span = DateTime.Now - preProTime;
if (span.TotalSeconds < 10)
{
return;
}
preProTime = DateTime.Now;
if (CurrInOutACount >= this.Config.Box_ResetACount)
{
if (storeRunStatus < StoreRunStatus.Runing || StoreMove.MoveType == StoreMoveType.InStore || StoreMove.MoveType == StoreMoveType.OutStore)
......@@ -1287,6 +1287,8 @@ namespace OnlineStore.DeviceLibrary
IOManager.IOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW);
}
}
MeteringSignal.StopCheck();
AutomaticBaiting.StopMove();
if (IsCloseAxis)
{
CloseAllAxis();
......@@ -1295,8 +1297,6 @@ namespace OnlineStore.DeviceLibrary
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.LOW);
AutomaticBaiting.StopMove();
MeteringSignal.StopCheck();
isInPro = false;
}
......
......@@ -24,8 +24,12 @@ namespace OnlineStore.DeviceLibrary
/// 自动出入库间隔
/// </summary>
public int autoJiange = 3;
public int AutoStartIndex = 0;
public int autoPositionIndex = 0;
public string autoMsg = "";
private static StoreMoveType lastMoveType = StoreMoveType.None;
#endregion
#region 出入库参数
......@@ -308,6 +312,7 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
StoreMove.NewMove(StoreMoveType.InStore, param);
lastMoveType = StoreMoveType.InStore;
StoreMove.IsBatchInOutStore = IsBatchWork;
StoreMove.IsNeedInStore = isNeedInStore;
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
......@@ -624,6 +629,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + logMsg);
storeRunStatus = StoreRunStatus.Busy;
StoreMove.NewMove(StoreMoveType.OutStore, param);
lastMoveType = StoreMoveType.OutStore;
StoreMove.IsBatchInOutStore = IsBatchWork;
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
{
......@@ -1005,78 +1011,30 @@ namespace OnlineStore.DeviceLibrary
}
if (storeMoveType.Equals(StoreMoveType.InStore))
{
int newIndex = autoPositionIndex - 1;
if (autoJiange == 0)
{
newIndex = autoPositionIndex;
}
if (newIndex < 0)
{
autoNext = false;
autoMsg = "自动出入库结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
}
else
{
autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex];
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
Reset(false);
autoMsg = "自动出库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "", posid));
}
else if (CurrInOutCount >= Config.Box_ResetMCount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX旋转轴,先把出库信息存入排队列表中");
//ResetMiddleAxis(false);
autoMsg = "自动出库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "", posid));
}
else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid);
autoMsg = "自动出库:" + posid;
StartOutStoreMove(new InOutStoreParam("", posid), false);
}
}
autoMsg = "自动入库:" + posid;
//自动出入口,入库结束把出库加入队列
FixtureCodeInfo currInOutFixture = new FixtureCodeInfo(0, "", posid);
AddWaitOutInfo(currInOutFixture);
LogUtil.info("自动出入口,入库结束,将库位号【"+ posid + "】加入出库等待中");
}
else if (storeMoveType.Equals(StoreMoveType.OutStore))
{
int newIndex = autoPositionIndex - autoJiange;
if (newIndex < 0)
{
autoNext = false;
autoMsg = "自动出入库结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
newIndex = AutoStartIndex;
}
else
{
autoPositionIndex = newIndex;
string posid = PositionNumList[newIndex];
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
Reset(false);
autoMsg = "自动入库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "AAAA", posid));
}
else if (CurrInOutCount >= Config.Box_ResetMCount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX旋转轴,先把出库信息存入排队列表中");
//ResetMiddleAxis(false);
ConfigAppSettings.SaveValue(Setting_Init.DebugPosId, posid);
//开始自动入库
autoMsg = "自动入库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "AAAA", posid ));
}
else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid);
autoMsg = "自动入库:" + posid;
StartInStoreMove(new InOutStoreParam("AAAA", posid), false);
}
string msg = AutomaticBaiting.doStartBatchIn();
LogUtil.info("自动出入库:库位号【"+posid+"】,开始入库"+msg);
}
}
}
......
......@@ -275,7 +275,7 @@ namespace OnlineStore.DeviceLibrary
}
LastCodeList = hasList;
LastCode = message;
if (LastCode.Equals("")&&StoreManager.Store.IsDebug)
if (LastCode.Equals("") && (StoreManager.Store.IsDebug || StoreManager.Store.autoNext))
{
LastCode = "NoCode";
LogUtil.info(Name + "模拟二维码:NoCode");
......@@ -331,41 +331,50 @@ namespace OnlineStore.DeviceLibrary
{
try
{
message = ScanCodeManager.ReplaceCode(message);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "没有收到二维码信息,请重新放入料盘";
LogUtil.info(Name + "没有收到二维码信息,请重新放入料盘");
return;
}
if (StoreManager.Store.storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info(Name + "收到二维码【 " + message + "】,设备未启动,不需要发送服务器");
return;
}
if (StoreManager.Store.IsDebug)
if (StoreManager.Store.IsDebug || StoreManager.Store.autoNext)
{
string posId = ConfigAppSettings.GetValue(Setting_Init.DebugPosId);
if (!posId.Equals(""))
{
LogUtil.info(Name + "调试模式,模拟库位号【" + posId + "】");
string type = StoreManager.Store.autoNext ? "自动出入库" : "入库模拟调试";
LogUtil.info(Name + type + " ,模拟库位号【" + posId + "】");
if (StoreManager.Store.CanStarInOut())
{
LastPosId = posId;
InOutStoreParam param = new InOutStoreParam(message, posId, LastHeight, LastWidth);
bool result = StoreManager.Store.StartInStoreMove(param, true);
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(Name + " 入库调试模拟:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
LogUtil.info(Name + type + " :库位号【" + posId + "】二维码【" + message + "】 开始入库!");
}
else
{
LogUtil.info(Name + " 入库调试模拟:库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!");
LogUtil.info(Name + type + " :库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!");
}
//清理库位号,防止重复入库
if (StoreManager.Store.autoNext)
{
ConfigAppSettings.SaveValue(Setting_Init.DebugPosId, "");
}
return;
}
}
else
{
message = ScanCodeManager.ReplaceCode(message);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "没有收到二维码信息,请重新放入料盘";
LogUtil.info(Name + "没有收到二维码信息,请重新放入料盘");
return;
}
if (StoreManager.Store.storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info(Name + "收到二维码【 " + message + "】,设备未启动,不需要发送服务器");
return;
}
//开启服务器日志
//HttpHelper.isLog = 1;
LogUtil.info(Name + "收到二维码【 " + message + "】,发送给服务器获取入库PosID");
......@@ -413,7 +422,7 @@ namespace OnlineStore.DeviceLibrary
string[] posArray = posId.Split('#');
if (!(posArray.Length == 2))
{
WarnMsg = Name+ ResourceControl.GetString(ResourceControl.InStoreError, "入库库位格式错误:") + "【" + message + "】【" + posId + "】";
WarnMsg = Name + ResourceControl.GetString(ResourceControl.InStoreError, "入库库位格式错误:") + "【" + message + "】【" + posId + "】";
LogUtil.error("服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
LogUtil.info("服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
return;
......@@ -449,6 +458,7 @@ namespace OnlineStore.DeviceLibrary
}
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + ex.StackTrace);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!