Commit 67761f20 张东亮

添加库位调试界面

1 个父辈 f465e1c4
......@@ -53,7 +53,7 @@ namespace OnlineStore.ACSquareStore
HideForm();
this.Opacity = 1;
cmbHumpPort.Items.Clear();
foreach(string str in store.Config.GetHumpPortList())
foreach (string str in store.Config.GetHumpPortList())
{
cmbHumpPort.Items.Add(str);
}
......@@ -63,9 +63,68 @@ namespace OnlineStore.ACSquareStore
}
chbUseTrayCheck.Checked = StoreManager.UseShelfCheck;
// txtTempPort.Text = store.Config.Humiture_Port;
InitPosDebugBox();
LoadOk = true;
}
#region 库位调试
void InitPosDebugBox()
{
store.InOutEndEvent += Store_InOutEndEvent;
lblOk.Text = store.posDebug.Ok.ToString();
lblTotal.Text = store.posDebug.Total.ToString();
for (int i = 1; i <= store.posDebug.GetCols(); i++)
{
dataGridView1.Columns.Add("Col_" + i, "Col_" + i);
dataGridView2.Columns.Add("Col_" + i, "Col_" + i);
}
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
dataGridView1.Columns[i].Width = 64;
dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
for (int i = 0; i < dataGridView2.Columns.Count; i++)
{
dataGridView2.Columns[i].Width = 64;
dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
for (int i = 0; i < store.posDebug.GetRows(); i++)
{
dataGridView1.Rows.Add();
dataGridView2.Rows.Add();
}
foreach (var item in store.posDebug.LPos)
{
dataGridView1.Rows[item.Row - 1].Cells[item.Col - 1].Value = item.PosName;
dataGridView1.Rows[item.Row - 1].Cells[item.Col - 1].Tag = item.PosId;
dataGridView1.Rows[item.Row - 1].Cells[item.Col - 1].Style = GetStyle(item.PosId);
}
foreach (var item in store.posDebug.RPos)
{
dataGridView2.Rows[item.Row - 1].Cells[item.Col - 1].Value = item.PosName;
dataGridView2.Rows[item.Row - 1].Cells[item.Col - 1].Tag = item.PosId;
dataGridView2.Rows[item.Row - 1].Cells[item.Col - 1].Style = GetStyle(item.PosId);
}
}
private void Store_InOutEndEvent(string posId, StoreMoveType movetype, bool isLast)
{
if (store.posDebug.Exist(posId, out PosPos posPos, out int dir))
{
if (dir == 0)
{
var cells = dataGridView1.Rows[posPos.Row - 1].Cells[posPos.Col - 1];
cells.Style = GetStyle(posId);
}
else
{
var cells = dataGridView2.Rows[posPos.Row - 1].Cells[posPos.Col - 1];
cells.Style = GetStyle(posId);
}
}
lblOk.Text = store.posDebug.Ok.ToString();
lblTotal.Text = store.posDebug.Total.ToString();
}
#endregion
private void LoadStore()
{
this.store = StoreManager.InitStore();
......@@ -424,7 +483,7 @@ namespace OnlineStore.ACSquareStore
ktk.InOut_P4 = FormUtil.GetIntValue(txtInOutP4);
ktk.Middle_P1 = FormUtil.GetIntValue(txtMiddleP1);
ktk.Middle_P2 = FormUtil.GetIntValue(txtMiddleP2);
ktk.MiddleAxis_Safe_Position= FormUtil.GetIntValue(txtMiddleSafe);
ktk.MiddleAxis_Safe_Position = FormUtil.GetIntValue(txtMiddleSafe);
ktk.UpDown_P1 = FormUtil.GetIntValue(txtUpDownP1);
ktk.UpDown_P2 = FormUtil.GetIntValue(txtUpDownP2);
ktk.UpDown_P3 = FormUtil.GetIntValue(txtUpDownP3);
......@@ -451,17 +510,7 @@ namespace OnlineStore.ACSquareStore
if (cmbPosition.SelectedIndex >= 0)
{
string selectPositionNum = cmbPosition.Text;
ACSquareSPosition ktkPosition = CSVPositionReader<ACSquareSPosition>.GetPositon(selectPositionNum);
if (ktkPosition != null)
{
txtMiddleP2.Text = ktkPosition.MiddleAxis_P2.ToString();
txtUpDownP3.Text = ktkPosition.UpDownAxis_IH_P3.ToString();
txtUpDownP4.Text = ktkPosition.UpDownAxis_IL_P4.ToString();
txtUpDownP5.Text = ktkPosition.UpDownAxis_OH_P5.ToString();
txtUpDownP6.Text = ktkPosition.UpDownAxis_OL_P6.ToString();
txtInOutP4.Text = ktkPosition.InOutAxis_P4.ToString();
}
SetData(selectPositionNum);
}
}
private void cmbAxisList_SelectedIndexChanged(object sender, EventArgs e)
......@@ -853,6 +902,15 @@ namespace OnlineStore.ACSquareStore
//store.StartOutStoreMove(new InOutStoreParam("", poText));
InOutPosInfo pos = new InOutPosInfo("AUTOINOUT", poText);
pos.ShelfType = store.autoShelfType;
store.posDebug.Start();
foreach (var item in store.posDebug.LPos)
{
dataGridView1.Rows[item.Row - 1].Cells[item.Col - 1].Style = dgv_none;
}
foreach (var item in store.posDebug.RPos)
{
dataGridView2.Rows[item.Row - 1].Cells[item.Col - 1].Style = dgv_none;
}
store.StartInStoreMove(new InOutParam(pos));
}
btnStartAuTo.Text = "停止自动出入库";
......@@ -1123,7 +1181,7 @@ namespace OnlineStore.ACSquareStore
ExitApp();
}
}
private void UpdateBtnEn( )
private void UpdateBtnEn()
{
string port = cmbHumpPort.Text;
if (HumitureController.IsRun(port))
......@@ -1191,6 +1249,7 @@ namespace OnlineStore.ACSquareStore
groupAxis.Enabled = status;
//groupComAxis.Enabled = status;
groupInout.Enabled = status;
tabControl_Pos.Enabled = status;
}
private void btnDebug_Click(object sender, EventArgs e)
......@@ -1275,12 +1334,12 @@ namespace OnlineStore.ACSquareStore
{
btnTempInit.Enabled = true;
btnTempClose.Enabled = false ;
btnTempClose.Enabled = false;
}
}
protected void BtnMove(Button btn, string defaultText, string targetText, string ioHighType)
{
LogUtil.info( "点击【" + btn.Text + "】 ");
LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
IOManager.IOMove(ioHighType, IO_VALUE.HIGH);
......@@ -1340,5 +1399,42 @@ namespace OnlineStore.ACSquareStore
AxisABSMove(store.Config.Middle_Axis, value, store.Config.MiddleAxis_P1_Speed);
}
}
#region 库位调试
/// <summary>
/// 更新界面轴的库位位置数据
/// </summary>
/// <param name="posId"></param>
private void SetData(string posId)
{
ACSquareSPosition ktkPosition = CSVPositionReader<ACSquareSPosition>.GetPositon(posId);
if (ktkPosition != null)
{
txtMiddleP2.Text = ktkPosition.MiddleAxis_P2.ToString();
txtUpDownP3.Text = ktkPosition.UpDownAxis_IH_P3.ToString();
txtUpDownP4.Text = ktkPosition.UpDownAxis_IL_P4.ToString();
txtUpDownP5.Text = ktkPosition.UpDownAxis_OH_P5.ToString();
txtUpDownP6.Text = ktkPosition.UpDownAxis_OL_P6.ToString();
txtInOutP4.Text = ktkPosition.InOutAxis_P4.ToString();
}
}
static Font font = new Font("宋体", 10);
DataGridViewCellStyle dgv_ok = new DataGridViewCellStyle() { BackColor = Color.LightGreen, Font = font };
DataGridViewCellStyle dgv_oin = new DataGridViewCellStyle() { BackColor = Color.LightGray, Font = font };
DataGridViewCellStyle dgv_oout = new DataGridViewCellStyle() { BackColor = Color.LightSeaGreen, Font = font };
DataGridViewCellStyle dgv_none = new DataGridViewCellStyle() { BackColor = Color.White, Font = font };
DataGridViewCellStyle GetStyle(string posid)
{
if (store.posDebug.Exist(posid, out PosPos posPos))
{
if (posPos.PosState.InStoreCheck == 1 && posPos.PosState.OutStoreCheck == 1)
return dgv_ok;
else if (posPos.PosState.InStoreCheck == 1)
return dgv_oin;
else if (posPos.PosState.OutStoreCheck == 1)
return dgv_oout;
}
return dgv_none;
}
#endregion
}
}
......@@ -1260,7 +1260,7 @@
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>56</value>
<value>52</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
......
......@@ -53,6 +53,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="acSquareStore\PosDebug.cs" />
<Compile Include="acSquareStore\ShelfMoveBean.cs" />
<Compile Include="acSquareStore\Square_BoxBean.cs" />
<Compile Include="acSquareStore\Square_BoxBean_Partial.cs" />
......
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class PosDebug
{
static string filePath = $"{Application.StartupPath}//StoreConfig//pos_debug.json";
static object locker = new object();
/// <summary>
/// 左侧库位结果表
/// </summary>
public List<PosPos> LPos { get; set; }
/// <summary>
/// 右侧库位结果表
/// </summary>
public List<PosPos> RPos { get; set; }
public int Total { get; set; }
public int Ok { get; set; }
public void Start()
{
Total++;
ClearPosState();
}
public int GetRows()
{
return LPos.Select(s=>s.Row).Max();
}
public int GetCols()
{
return LPos.Select(s => s.Col).Max();
}
public bool Exist(string posId,out PosPos posPos)
{
posPos = null;
int idx = LPos.FindIndex(s => s.PosId.Equals(posId));
if (idx == -1)
{
idx = RPos.FindIndex(s => s.PosId.Equals(posId));
if (idx == -1)
return false;
else
{
posPos = RPos[idx];
}
}
else
{
posPos = LPos[idx];
}
return true;
}
/// <summary>
///
/// </summary>
/// <param name="posId"></param>
/// <param name="posPos"></param>
/// <param name="dir">0:左侧</param>
/// <returns></returns>
public bool Exist(string posId, out PosPos posPos,out int dir)
{
posPos = null;
dir = 0;
int idx = LPos.FindIndex(s => s.PosId.Equals(posId));
if (idx == -1)
{
idx = RPos.FindIndex(s => s.PosId.Equals(posId));
if (idx == -1)
return false;
else
{
posPos = RPos[idx];
dir = 1;
}
}
else
{
posPos = LPos[idx];
}
return true;
}
void SetPosState(string posId,StoreMoveType moveType)
{
int idx = LPos.FindIndex(s=>s.PosId.Equals(posId));
if(idx == -1)
{
idx= RPos.FindIndex(s=>s.PosId.Equals(posId));
if(idx != -1)
{
if (moveType.Equals(StoreMoveType.InStore))
{
RPos[idx].PosState.InStoreCheck = 1;
}
else if (moveType.Equals(StoreMoveType.OutStore))
{
RPos[idx].PosState.OutStoreCheck = 1;
}
}
}
else
{
if (moveType.Equals(StoreMoveType.InStore))
{
LPos[idx].PosState.InStoreCheck = 1;
}
else if (moveType.Equals(StoreMoveType.OutStore))
{
LPos[idx].PosState.OutStoreCheck = 1;
}
}
}
public void AddResult(string posId, StoreMoveType movetype, bool isLast)
{
if (Monitor.TryEnter(locker, 500))
{
try
{
if (isLast)
Ok++;
SetPosState(posId, movetype);
File.WriteAllText(filePath, JsonHelper.SerializeObject(this));
}
finally
{
Monitor.Exit(locker);
}
}
}
private void ClearPosState()
{
foreach (var item in LPos)
{
item.PosState.InStoreCheck = 0;
item.PosState.OutStoreCheck = 0;
}
foreach (var item in RPos)
{
item.PosState.InStoreCheck = 0;
item.PosState.OutStoreCheck = 0;
}
}
public static PosDebug Init(List<string> posNumList)
{
PosDebug posDebug;
if (File.Exists(filePath))
{
string txt = File.ReadAllText(filePath);
posDebug = JsonHelper.DeserializeJsonToObject<PosDebug>(txt);
if (posDebug != null)
return posDebug;
}
posDebug = new PosDebug();
posDebug.LPos = new List<PosPos>();
posDebug.RPos = new List<PosPos>();
for (int i = 0; i < posNumList.Count; i++)
{
//AC1#R1_1_11
//AC1#L1_1_11
string pos = posNumList[i];
string[] dir = pos.Split('#');
if (dir[1].StartsWith("L"))
{
posDebug.LPos.Add(new PosPos { PosId = pos, Index = i });
}
else
{
posDebug.RPos.Add(new PosPos { PosId = pos, Index = i });
}
}
return posDebug;
}
}
//AC1#L1_1_11
public class PosPos
{
/// <summary>
/// 库位ID
/// </summary>
public string PosId { get; set; }
/// <summary>
/// 库位名
/// </summary>
public string PosName { get { return PosId.Split('#')[1]; } }
/// <summary>
/// 所在库位列表的索引
/// </summary>
public int Index { get; set; }
/// <summary>
/// 库位所在层
/// </summary>
public int Row { get { return int.Parse(PosId.Split('#')[1].Split('_')[2]); } }
/// <summary>
/// 库位所在列
/// </summary>
public int Col { get { return int.Parse(PosId.Split('#')[1].Split('_')[0].Substring(1)); } }
public PosState PosState { get; set; } = new PosState();
}
/// <summary>
/// 库位状态
/// </summary>
public class PosState
{
public int InStoreCheck = 0;
public int OutStoreCheck = 0;
}
}
......@@ -95,6 +95,7 @@ namespace OnlineStore.DeviceLibrary
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
posDebug = PosDebug.Init(PositionNumList);
}
private void IoCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
......
......@@ -478,7 +478,7 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.Runing;
//设备连接,入库后,BOX恢复原始状态
storeStatus = StoreStatus.StoreOnline;
InOutEndProcess(StoreMoveType.InStore);
InOutEndProcess(StoreMoveType.InStore, posId);
}
else
{
......@@ -736,7 +736,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + " 【" + posId + "】 整个出库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!", storeMoveColor);
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
InOutEndProcess(StoreMoveType.OutStore);
InOutEndProcess(StoreMoveType.OutStore,posId);
}
else
{
......@@ -758,7 +758,7 @@ namespace OnlineStore.DeviceLibrary
}
}
private string autoInoutCode = "AUTOINOUT";
private void InOutEndProcess(StoreMoveType storeMoveType)
private void InOutEndProcess(StoreMoveType storeMoveType,string posId)
{
try
{
......@@ -772,7 +772,7 @@ namespace OnlineStore.DeviceLibrary
if (storeMoveType.Equals(StoreMoveType.InStore))
{
int newIndex = autoPositionIndex;
if (newIndex < 0)
if (newIndex >= PositionNumList.Count)
{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
{
......@@ -788,6 +788,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
InOutEnd(posId, storeMoveType, false);
autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex];
InOutPosInfo inoutinfo = new InOutPosInfo(autoInoutCode, posid);
......@@ -817,12 +818,13 @@ namespace OnlineStore.DeviceLibrary
}
else if (storeMoveType.Equals(StoreMoveType.OutStore))
{
int newIndex = autoPositionIndex - autoJiange;
if (newIndex < 0)
int newIndex = autoPositionIndex + autoJiange;
if (newIndex >= PositionNumList.Count)
{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
{
newIndex = AutoStartIndex;
InOutEnd(posId, storeMoveType, true);
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
}
else
......@@ -834,26 +836,27 @@ namespace OnlineStore.DeviceLibrary
}
else
{
InOutEnd(posId, storeMoveType, false);
autoPositionIndex = newIndex;
string posid = PositionNumList[newIndex];
InOutPosInfo inoutinfo = new InOutPosInfo(autoInoutCode, posid);
inoutinfo.ShelfType = autoShelfType;
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
Reset(false);
autoMsg = "自动入库:" + posid;
AddWaitOutInfo(inoutinfo);
}
else if (CurrInOutCount >= Config.Box_ResetMCount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX前后轴,先把出库信息存入排队列表中");
//ResetMiddleAxis(false);
autoMsg = "自动入库:" + posid;
AddWaitOutInfo(inoutinfo);
}
else
//if (CurrInOutACount >= Config.Box_ResetACount)
//{
// LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
// Reset(false);
// autoMsg = "自动入库:" + posid;
// AddWaitOutInfo(inoutinfo);
//}
//else if (CurrInOutCount >= Config.Box_ResetMCount)
//{
// LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX前后轴,先把出库信息存入排队列表中");
// //ResetMiddleAxis(false);
// autoMsg = "自动入库:" + posid;
// AddWaitOutInfo(inoutinfo);
//}
//else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid);
autoMsg = "自动入库:" + posid;
......@@ -867,7 +870,16 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(LOGGER, ex.ToString());
}
}
#region 库位调试
public delegate void InOutEndEventHandler(string posId, StoreMoveType movetype,bool isLast);
public event InOutEndEventHandler InOutEndEvent;
public PosDebug posDebug;
private void InOutEnd(string posId, StoreMoveType movetype, bool isLast)
{
posDebug.AddResult(posId, movetype, isLast);
InOutEndEvent?.Invoke(posId, movetype, isLast);
}
#endregion
private void InStoreLog(string msg)
{
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PosInfo.PosId : "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!