Commit c0ea1ea8 几米阳光

增加与服务器通信模块

1 个父辈 97edbb72
......@@ -299,7 +299,7 @@ namespace OnlineStore.AutoInOutStore
private void btnDOpen_Click(object sender, EventArgs e)
{
if (AutomaticBaiting.CanOpenBatchDoor())
if (AutomaticBaiting.CanOpenBatchDoor()|| StoreManager.Store.storeRunStatus.Equals(StoreRunStatus.Wait))
{
AutomaticBaiting.BatchDoorOpen(false);
}
......
......@@ -179,10 +179,9 @@ namespace OnlineStore.AutoInOutStore
return;
}
BatchInoutStatus();
//HumitureServer.RandomData(store.Config.GetTempAddrList());
lblTemp.Text = store.currTempStr;
//验证运动是否完成
//CheckWait();
//忙碌状态不读取状态
if (!store.storeRunStatus.Equals(StoreRunStatus.Busy))
{
......@@ -296,74 +295,30 @@ namespace OnlineStore.AutoInOutStore
private void BatchInoutStatus()
{
if (AutomaticBaiting.IsWaitTragGo && (AutomaticBaiting.IsGetTrayGo.Equals(false)))
{
btnWaitTrgGo.Visible = true;
lblWaitTragGo.Visible = true;
btnBatchInStore.Enabled = false;
btnBatchInStore.Enabled = false;
btnOpenDoor.Enabled = false;
btnCloseDoor.Enabled = false;
}
else
{
btnWaitTrgGo.Visible = false;
lblWaitTragGo.Visible = false;
Dictionary<string, string> map = AutomaticBaiting.GetBtnStatus();
btnWaitTrgGo.Visible = map[ParamDefine.confirmReelOut].Equals(ParamDefine.enable);
lblWaitTragGo.Visible = map[ParamDefine.confirmReelOut].Equals(ParamDefine.enable);
btnOpenDoor.Enabled = map[ParamDefine.openLock].Equals(ParamDefine.enable);
btnBatchInStore.Enabled = map[ParamDefine.startBatchIn].Equals(ParamDefine.enable);
btnGetOutTray.Enabled = map[ParamDefine.takeOutReel].Equals(ParamDefine.enable);
btnCloseDoor.Enabled = map[ParamDefine.closeLock].Equals(ParamDefine.enable);
if (AutomaticBaiting.DoorStatus.Equals(2))
{
lblDoorStatus.Text = "仓门状态:关闭";
UpdateFormDoorStats(false);
}
else
{
lblDoorStatus.Text = "仓门状态:打开";
UpdateFormDoorStats(true);
}
}
lblOutInfo.Visible = !lblWaitTragGo.Visible;
lblOutInfo.Text = "批量出入库信息: 入库:" + AutomaticBaiting.BatchInStoreCount + "盘共" + AutomaticBaiting.BatchInStoreHeight + "mm," +
"出库: " + AutomaticBaiting.BatchOutStoreCount + "盘共" + AutomaticBaiting.BatchOutStoreHeight + "mm";
if (HumitureController.IsRun)
{
btnSelTemp.Enabled = true;
btnTempClose.Enabled = true;
btnTempInit.Enabled = false;
}
else
{
btnSelTemp.Enabled = false;
btnTempClose.Enabled = false;
btnTempInit.Enabled = true;
}
}
private void UpdateFormDoorStats(bool dooIsOpen)
{
btnCloseDoor.Enabled = dooIsOpen;
btnBatchInStore.Enabled = dooIsOpen;
if (dooIsOpen.Equals(false))
{
if (AutomaticBaiting.BatchOutStoreCount > 0)
{
btnGetOutTray.Enabled = true;
btnOpenDoor.Enabled = false;
}
else
{
btnGetOutTray.Enabled = false;
btnOpenDoor.Enabled = true;
}
}
else
{
btnOpenDoor.Enabled = !dooIsOpen;
btnGetOutTray.Enabled = !dooIsOpen;
}
btnBatchReset.Enabled = !dooIsOpen;
bool isRun = HumitureController.IsRun;
btnSelTemp.Enabled = isRun;
btnTempClose.Enabled = isRun;
btnTempInit.Enabled = !isRun;
}
private void ReadPosistion()
......@@ -1569,9 +1524,7 @@ namespace OnlineStore.AutoInOutStore
DialogResult result = MessageBox.Show("已经将料盘手动拿出?", "确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result.Equals(DialogResult.Yes))
{
LogUtil.info("已确认料盘已手动拿出");
AutomaticBaiting.IsWaitTragGo = false;
AutomaticBaiting.IsGetTrayGo = true;
AutomaticBaiting.doConfirmReelGo();
}
}
......@@ -1585,62 +1538,81 @@ namespace OnlineStore.AutoInOutStore
}
private void BtnOpenDoor_Click(object sender, EventArgs e)
{
if (AutomaticBaiting.CanOpenBatchDoor())
{
AutomaticBaiting.BatchDoorOpen(false);
AutomaticBaiting.IsNeedStartInout = false;
}
else
//if (AutomaticBaiting.CanOpenBatchDoor())
//{
// AutomaticBaiting.BatchDoorOpen(false);
// AutomaticBaiting.IsNeedStartInout = false;
//}
//else
//{
// MessageBox.Show("忙碌中,无法打开门锁");
//}
string msg = AutomaticBaiting.doOpenDoor();
if (!msg.Equals(""))
{
MessageBox.Show("忙碌中,无法打开门锁");
MessageBox.Show(msg);
}
}
private void btnBatchInStore_Click(object sender, EventArgs e)
{
if (!AutomaticBaiting.DoorIsClose())
{
MessageBox.Show("请先关闭门锁");
return;
}
if (KND.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
string msg = AutomaticBaiting.doStartBatchIn();
if (!msg.Equals(""))
{
MessageBox.Show("叉子料盘检测有料,请检查后再入库");
return;
MessageBox.Show(msg);
}
//if (!AutomaticBaiting.DoorIsClose())
//{
// MessageBox.Show("请先关闭门锁");
// return;
//}
//if (KND.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
//{
// MessageBox.Show("叉子料盘检测有料,请检查后再入库");
// return;
//}
AutomaticBaiting.BatchDoorClose(false);
AutomaticBaiting.Reset(true);
//AutomaticBaiting.BatchDoorClose(false);
//AutomaticBaiting.Reset(true);
}
private void btnStartBatchInStore_Click(object sender, EventArgs e)
{
if (!AutomaticBaiting.DoorIsClose())
string msg = AutomaticBaiting.doCloseDoor();
if (!msg.Equals(""))
{
MessageBox.Show("请先关闭门锁");
return;
MessageBox.Show(msg);
}
AutomaticBaiting.BatchDoorClose(false);
AutomaticBaiting.Reset(false);
//if (!AutomaticBaiting.DoorIsClose())
//{
// MessageBox.Show("请先关闭门锁");
// return;
//}
//AutomaticBaiting.BatchDoorClose(false);
//AutomaticBaiting.Reset(false);
}
private void btnGetOutTray_Click(object sender, EventArgs e)
{
if (AutomaticBaiting.CanOpenBatchDoor())
{
if (AutomaticBaiting.BatchOutStoreCount > 0 && AutomaticBaiting.BatchOutStoreHeight > 0)
{
AutomaticBaiting.BatchDoorOpen(false);
}
else
{
MessageBox.Show("未出库,无料盘可取");
}
}
else
string msg = AutomaticBaiting.doTakeReel();
if (!msg.Equals(""))
{
MessageBox.Show("忙碌中,无法打开门锁");
MessageBox.Show(msg);
}
//if (AutomaticBaiting.CanOpenBatchDoor())
//{
// if (AutomaticBaiting.BatchOutStoreCount > 0 && AutomaticBaiting.BatchOutStoreHeight > 0)
// {
// AutomaticBaiting.BatchDoorOpen(false);
// }
// else
// {
// MessageBox.Show("未出库,无料盘可取");
// }
//}
//else
//{
// MessageBox.Show("忙碌中,无法打开门锁");
//}
}
private void btnBatchOutEnd_Click(object sender, EventArgs e)
......
......@@ -204,5 +204,31 @@ namespace OnlineStore.Common
/// 是否是单个出库,true表示单个出库,其他都是批量出库
/// </summary>
public static string singleOut = "singleOut";
/// <summary>
/// 打开门锁动作
/// </summary>
public static string openLock = "openLock";
/// <summary>
/// 批量出入库动作
/// </summary>
public static string startBatchIn = "startBatchIn";
/// <summary>
/// 关闭门锁
/// </summary>
public static string closeLock = "closeLock";
/// <summary>
/// 取出出库料盘动作
/// </summary>
public static string takeOutReel = "takeOutReel";
/// <summary>
/// 门口料盘已取出
/// </summary>
public static string confirmReelOut = "confirmReelOut";
public static string doit = "doit";
public static string enable = "enable";
public static string disable = "disable";
}
}
......@@ -189,15 +189,12 @@ namespace OnlineStore.DeviceLibrary
return false;
}
}
//if (UseBatchInout)
//{
string canStart = AutomaticBaiting.CanStart();
if (!canStart.Equals(""))
{
LogUtil.info(StoreName + canStart);
return false;
}
//}
autoNext = false;
mainTimer.Enabled = false;
alarmType = StoreAlarmType.None;
......@@ -215,10 +212,8 @@ namespace OnlineStore.DeviceLibrary
{
return false;
}
//if (UseBatchInout)
{
AutomaticBaiting.Reset(false );
}
AutomaticBaiting.Reset(false);
//TODO 启动时先所有轴远点返回,测试暂时关闭
storeRunStatus = StoreRunStatus.HomeMoving;
HumitureController.Init(Config.Humiture_Port);
......@@ -1505,6 +1500,7 @@ namespace OnlineStore.DeviceLibrary
{
lineOperation.alarmList.Add(alarmInfo);
}
lineOperation.data = AutomaticBaiting.GetBtnStatus();
return lineOperation;
}
......@@ -1538,12 +1534,68 @@ namespace OnlineStore.DeviceLibrary
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op != 2))
if (resultOperation == null )
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(2))
{
doOutStore(resultOperation);
}
else if (resultOperation.data != null)
{
string result = "";
Dictionary<string, string> dataMap = resultOperation.data;
//string reviceData = "";
//foreach(string key in dataMap.Keys)
//{
// reviceData += "["+key+"="+dataMap[key]+"]";
//}
//if (ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open).Equals(1))
//{
// LogUtil.info(StoreName + "收到服务器Data:"+ reviceData);
//}
if (dataMap.ContainsKey(ParamDefine.openLock) && dataMap[ParamDefine.openLock].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + "收到服务器命令:openLock=doit");
result = AutomaticBaiting.doOpenDoor();
}
else if (dataMap.ContainsKey(ParamDefine.startBatchIn) && dataMap[ParamDefine.startBatchIn].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + "收到服务器命令:startBatchIn=doit");
result = AutomaticBaiting.doStartBatchIn();
}
else if (dataMap.ContainsKey(ParamDefine.takeOutReel) && dataMap[ParamDefine.takeOutReel].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + "收到服务器命令:takeOutReel=doit");
result = AutomaticBaiting.doTakeReel();
}
else if (dataMap.ContainsKey(ParamDefine.closeLock) && dataMap[ParamDefine.closeLock].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + "收到服务器命令:closeLock=doit");
result = AutomaticBaiting.doCloseDoor();
}
else if (dataMap.ContainsKey(ParamDefine.confirmReelOut) && dataMap[ParamDefine.confirmReelOut].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + "收到服务器命令:confirmReelOut=doit");
AutomaticBaiting.doConfirmReelGo();
}
if (!result.Equals(""))
{
LogUtil.info(StoreName + "收到服务器命令:doit执行失败:"+result);
CodeOrInoutMsg = result;
}
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 100)
{
LogUtil.info(StoreName + "SendLineStatus 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
private void doOutStore(Operation resultOperation)
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
......@@ -1553,7 +1605,7 @@ namespace OnlineStore.DeviceLibrary
string plateHStr = data[ParamDefine.plateH];
string singleOut = data[ParamDefine.singleOut];
LogUtil.info(LOGGER, "收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr+",singleOut="+singleOut);
LogUtil.info(LOGGER, "收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr + ",singleOut=" + singleOut);
char splitChar = '|';
string[] posIdArray = posIdStr.Split(splitChar);
string[] plateWArray = plateWStr.Split(splitChar);
......@@ -1563,8 +1615,10 @@ namespace OnlineStore.DeviceLibrary
foreach (string posId in posIdArray)
{
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
try
{
int plateW = Convert.ToInt32(plateWArray[index]);
int plateH = Convert.ToInt32(plateHArray[index]);
bool isSingleOut = singleOutArray[index].ToLower().Equals("true");
string[] posArray = posId.Split('#');
if (posArray.Length != 2)
......@@ -1588,21 +1642,20 @@ namespace OnlineStore.DeviceLibrary
{
if (CanStarInOut())
{
StartOutStoreMove(new InOutStoreParam("", posId), !isSingleOut);
StartOutStoreMove(new InOutStoreParam("", posId,plateH,plateW), !isSingleOut);
}
else
{
LogUtil.error(LOGGER, "收到服务器出库命令:出库【" + posId + "】失败,当前在忙碌中");
}
}
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
}catch(Exception ex)
{
LogUtil.info(StoreName + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
LogUtil.error(StoreName + "解析服务发送的出库【" + posId + "】出错" + ex.StackTrace);
}
}
}
}
#endregion
......
......@@ -320,6 +320,7 @@ namespace OnlineStore.DeviceLibrary
}
return msg;
}
//=1+0x0-13x24=201810220856;025;5N02018101;121;700012865;92498;1800;##
private static void GetInStorePosId(string message)
{
try
......@@ -343,8 +344,6 @@ namespace OnlineStore.DeviceLibrary
string posId = ConfigAppSettings.GetValue(Setting_Init.DebugPosId);
if (!posId.Equals(""))
{
//"1#AC2_2_1_1";
LogUtil.info(Name + "调试模式,模拟库位号【" + posId + "】");
if (StoreManager.Store.CanStarInOut())
{
......@@ -367,7 +366,14 @@ namespace OnlineStore.DeviceLibrary
//发送扫码内容到服务器进行入库操作
Operation operation = StoreManager.Store.getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", StoreManager.Store.StoreID.ToString() } };
if (operation.data == null)
{
operation.data = new Dictionary<string, string>();
}
operation.data.Add("code", message);
operation.data.Add("boxId", StoreManager.Store.StoreID.ToString());
//{ { "code", message }, { "boxId", StoreManager.Store.StoreID.ToString() } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
......@@ -440,5 +446,105 @@ namespace OnlineStore.DeviceLibrary
}
public static Dictionary<string, string> GetBtnStatus()
{
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add(ParamDefine.openLock, ParamDefine.disable);
map.Add(ParamDefine.startBatchIn, ParamDefine.disable);
map.Add(ParamDefine.closeLock, ParamDefine.disable);
map.Add(ParamDefine.takeOutReel, ParamDefine.disable);
map.Add(ParamDefine.confirmReelOut, ParamDefine.disable);
if (AutomaticBaiting.IsWaitTragGo && (AutomaticBaiting.IsGetTrayGo.Equals(false)))
{
map[ParamDefine.confirmReelOut] = ParamDefine.enable;
}
else if (AutomaticBaiting.CanOpenBatchDoor())
{
if (AutomaticBaiting.DoorStatus.Equals(2))
{
if (AutomaticBaiting.BatchOutStoreCount > 0)
{
map[ParamDefine.takeOutReel] = ParamDefine.enable;
}
else
{
map[ParamDefine.openLock] = ParamDefine.enable;
}
}
else
{
map[ParamDefine.closeLock] = ParamDefine.enable;
map[ParamDefine.startBatchIn] = ParamDefine.enable;
}
}
return map;
}
public static string doOpenDoor()
{
if (AutomaticBaiting.CanOpenBatchDoor())
{
AutomaticBaiting.BatchDoorOpen(false);
AutomaticBaiting.IsNeedStartInout = false;
return "";
}
else
{
return "忙碌中,无法打开门锁";
}
}
public static string doStartBatchIn()
{
if (!AutomaticBaiting.DoorIsClose())
{
return "批量入库失败:请先关闭上料机构";
}
if (KND.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
return "批量入库失败:叉子料盘检测有料,请检查后再入库";
}
AutomaticBaiting.BatchDoorClose(false);
AutomaticBaiting.Reset(true);
return "";
}
public static string doTakeReel()
{
if (AutomaticBaiting.CanOpenBatchDoor())
{
if (AutomaticBaiting.BatchOutStoreCount > 0 && AutomaticBaiting.BatchOutStoreHeight > 0)
{
AutomaticBaiting.BatchDoorOpen(false);
return "";
}
else
{
return ("取出料盘失败:无料盘可取");
}
}
else
{
return ("取出料盘失败:忙碌中,无法打开门锁");
}
}
public static string doCloseDoor()
{
if (!AutomaticBaiting.DoorIsClose())
{
return ("锁门失败:请先关闭上料机构");
}
AutomaticBaiting.BatchDoorClose(false);
AutomaticBaiting.Reset(false);
return "";
}
public static bool doConfirmReelGo()
{
LogUtil.info("已确认料盘已手动拿出");
AutomaticBaiting.IsWaitTragGo = false;
AutomaticBaiting.IsGetTrayGo = true;
return true;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!