Commit 1fb8f362 刘韬

1

1 个父辈 6aa01049
...@@ -9,14 +9,37 @@ namespace OnlineStore ...@@ -9,14 +9,37 @@ namespace OnlineStore
public enum Runtime_StepE public enum Runtime_StepE
{ {
None, None,
/// <summary>
/// 准备放入扫码贴标区
/// </summary>
InToLabel, InToLabel,
/// <summary>
/// 进入扫码贴标区
/// </summary>
LabelProcess, LabelProcess,
/// <summary>
/// 标签已打印
/// </summary>
Printed, Printed,
/// <summary>
/// 标签已获取
/// </summary>
LabelGot, LabelGot,
/// <summary>
/// 标签中
/// </summary>
LabelPaste, LabelPaste,
/// <summary>
/// 标签完成
/// </summary>
LabelPasteFinish,
/// <summary>
/// 正在进入库位
/// </summary>
InToStore, InToStore,
/// <summary>
/// 正在出库
/// </summary>
Out Out
} }
} }
...@@ -66,11 +66,11 @@ namespace OnlineStore.Common ...@@ -66,11 +66,11 @@ namespace OnlineStore.Common
/// =4时扫码入库 /// =4时扫码入库
/// =5时服务器发送预警温度 /// =5时服务器发送预警温度
/// </summary> /// </summary>
private Dictionary<string, string> _data = new Dictionary<string, string>(); //private Dictionary<string, string> _data = new Dictionary<string, string>();
public Dictionary<string, string> data public Dictionary<string, object> data
{ {
get { return _data; } get;
set { _data = value; } set;
} }
/// <summary> /// <summary>
/// 整体料仓状态 /// 整体料仓状态
...@@ -295,9 +295,9 @@ namespace OnlineStore.Common ...@@ -295,9 +295,9 @@ namespace OnlineStore.Common
public static string outDoorStatus= "outDoorStatus"; public static string outDoorStatus= "outDoorStatus";
public static string open= "open"; public static string open= "open";
public static string close= "close"; public static string close= "close";
public static string openInLock; public static string openInLock= "openInLock";
public static string closeInLock; public static string closeInLock = "closeInLock";
public static string closeOutLock; public static string closeOutLock = "closeOutLock";
public static string openOutLock; public static string openOutLock = "openOutLock";
} }
} }
...@@ -148,8 +148,8 @@ namespace DeviceLibrary ...@@ -148,8 +148,8 @@ namespace DeviceLibrary
else if (len < 0) else if (len < 0)
{ {
TurnToEnd(true, true).Wait(); TurnToEnd(true, true).Wait();
Task.Delay(500).Wait(); //Task.Delay(500).Wait();
TurnToEnd(false, false).Wait(); //TurnToEnd(false, false).Wait();
} }
}); });
...@@ -189,6 +189,42 @@ namespace DeviceLibrary ...@@ -189,6 +189,42 @@ namespace DeviceLibrary
TurnToEnd(false).Wait(); TurnToEnd(false).Wait();
}); });
} }
public void TurnDouble()
{
TurnWork = Task.Run(() =>
{
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
moveInfo.log($"急停未解除");
return;
}
if (!axisBean.IsServeoOn)
axisBean.Open(true, out string msg);
var len = (int)(StrokeLength / 90 * 45);
if (len > 0)
{
TurnToEnd(false).Wait();
}
RobotManage.mainMachine.CylinderMove(null, IO_Type.Tin_Dock_Rotate_Release, IO_Type.Tin_Dock_Rotate_Clamp, IO_VALUE.HIGH);
while (!IOManager.IOValue(IO_Type.Tin_Dock_Rotate_Clamp).Equals(IO_VALUE.HIGH))
{
Task.Delay(100).Wait();
}
TurnToEnd(true, true).Wait();
TurnToEnd(false, false).Wait();
TurnToEnd(true, true).Wait();
RobotManage.mainMachine.CylinderMove(null, IO_Type.Tin_Dock_Rotate_Release, IO_Type.Tin_Dock_Rotate_Clamp, IO_VALUE.LOW);
while (!IOManager.IOValue(IO_Type.Tin_Dock_Rotate_Release).Equals(IO_VALUE.HIGH))
{
Task.Delay(100).Wait();
}
TurnToEnd(false).Wait();
});
}
public void TurnRound2() public void TurnRound2()
{ {
TurnWork = Task.Run(() => TurnWork = Task.Run(() =>
......
...@@ -15,7 +15,7 @@ namespace DeviceLibrary ...@@ -15,7 +15,7 @@ namespace DeviceLibrary
string Port; string Port;
public PrinterHelper() { public PrinterHelper() {
print = new Asa.PrintLabel(Application.StartupPath + "\\Label"); print = new Asa.PrintLabel(Application.StartupPath + "\\Label",300);
} }
...@@ -48,9 +48,10 @@ namespace DeviceLibrary ...@@ -48,9 +48,10 @@ namespace DeviceLibrary
{ {
string labelname = Setting_Init.Printer_Labelname; string labelname = Setting_Init.Printer_Labelname;
Dictionary<string, string> data = new Dictionary<string, string>(); Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("RI", reel.ReeID); data.Add("PN", reel.PN);
//data.Add("PN", reel.PN); data.Add("LOT", reel.LOT);
//data.Add("QTY", reel.QTY.ToString()); data.Add("EXP", reel.EXP);
data.Add("SN", reel.SN);
data.Add("datetime", DateTime.Now.ToString()); data.Add("datetime", DateTime.Now.ToString());
LogUtil.info($"打印标签:{reel.ToDetailStr()}"); LogUtil.info($"打印标签:{reel.ToDetailStr()}");
var result = Print(labelname, data, out string msg); var result = Print(labelname, data, out string msg);
......
...@@ -101,17 +101,8 @@ namespace DeviceLibrary ...@@ -101,17 +101,8 @@ namespace DeviceLibrary
var code = ProcessCode(codelist, reel.PlateW, reel.PlateH); var code = ProcessCode(codelist, reel.PlateW, reel.PlateH);
Operation operation = getLineBoxStatus(); Operation operation = getLineBoxStatus();
operation.op = 1; operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } }; operation.data = new Dictionary<string, object>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
operation.data.Add("singleIn", "false");
if (reel.PlateH == 100 && Setting_Init.Device_SingleInSingleOut)
{
//singleIn 单盘入库
operation.data.Add("singleIn", "true");
}
else
{
operation.data.Add("singleIn", "false");
}
int retrytimes = 0; int retrytimes = 0;
retry: retry:
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000, printlog); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000, printlog);
...@@ -143,12 +134,12 @@ namespace DeviceLibrary ...@@ -143,12 +134,12 @@ namespace DeviceLibrary
if (resultOperation == null) if (resultOperation == null)
{ {
LogUtil.info($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}"); LogUtil.error($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}");
return false; return false;
} }
if (operation.seq != resultOperation.seq) if (operation.seq != resultOperation.seq)
{ {
LogUtil.info($"SendStoreState seq error,posid:{posid}, storeStatus:{storeStatus}"); LogUtil.error($"SendStoreState seq error,posid:{posid}, storeStatus:{storeStatus}");
return false; return false;
} }
...@@ -205,6 +196,8 @@ namespace DeviceLibrary ...@@ -205,6 +196,8 @@ namespace DeviceLibrary
lineOperation.data = GetBtnStatus(); lineOperation.data = GetBtnStatus();
lineOperation.data.Add("inArea", CameraPointTest.inArea);
lineOperation.data.Add("outArea", CameraPointTest.outArea);
lineOperation.status = (int)storeStatus; lineOperation.status = (int)storeStatus;
//判断如果是等待料盘拿走超时,状态改为4Warning //判断如果是等待料盘拿走超时,状态改为4Warning
...@@ -324,7 +317,7 @@ namespace DeviceLibrary ...@@ -324,7 +317,7 @@ namespace DeviceLibrary
{ {
var barcode = ""; var barcode = "";
if (resultOperation.data.ContainsKey("code")) if (resultOperation.data.ContainsKey("code"))
barcode = resultOperation.data["code"]; barcode = resultOperation.data["code"].ToString();
ReviceInStoreProcess(barcode, resultOperation); ReviceInStoreProcess(barcode, resultOperation);
} }
else if (resultOperation.op.Equals(2)) else if (resultOperation.op.Equals(2))
...@@ -339,11 +332,11 @@ namespace DeviceLibrary ...@@ -339,11 +332,11 @@ namespace DeviceLibrary
if (resultOperation.data != null) if (resultOperation.data != null)
{ {
string result = ""; string result = "";
Dictionary<string, string> dataMap = resultOperation.data; Dictionary<string, object> dataMap = resultOperation.data;
if (dataMap.ContainsKey(ParamDefine.queueTaskCount)) if (dataMap.ContainsKey(ParamDefine.queueTaskCount))
{ {
var s = dataMap[ParamDefine.queueTaskCount]; var s = dataMap[ParamDefine.queueTaskCount].ToString();
if (int.TryParse(s, out int c)) if (int.TryParse(s, out int c))
{ {
queueTaskCount = c; queueTaskCount = c;
...@@ -395,9 +388,9 @@ namespace DeviceLibrary ...@@ -395,9 +388,9 @@ namespace DeviceLibrary
} }
public Dictionary<string, string> GetBtnStatus() public Dictionary<string, object> GetBtnStatus()
{ {
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, object> map = new Dictionary<string, object>();
map.Add(ParamDefine.inDoorStatus, ParamDefine.disable); map.Add(ParamDefine.inDoorStatus, ParamDefine.disable);
map.Add(ParamDefine.outDoorStatus, ParamDefine.disable); map.Add(ParamDefine.outDoorStatus, ParamDefine.disable);
...@@ -444,12 +437,12 @@ namespace DeviceLibrary ...@@ -444,12 +437,12 @@ namespace DeviceLibrary
/// <param name="resultOperation"></param> /// <param name="resultOperation"></param>
private void ReviceInStoreProcess(string message, Operation resultOperation) private void ReviceInStoreProcess(string message, Operation resultOperation)
{ {
Dictionary<string, string> data = resultOperation.data; Dictionary<string, object> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW)) if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{ {
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度, //服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置 //postId格式BoxId#位置
string posId = data[ParamDefine.posId]; string posId = data[ParamDefine.posId].ToString();
//int storeId = int.Parse(posArray[0]); //int storeId = int.Parse(posArray[0]);
//根据发送的posId获取位置列表 //根据发送的posId获取位置列表
...@@ -462,35 +455,23 @@ namespace DeviceLibrary ...@@ -462,35 +455,23 @@ namespace DeviceLibrary
LogUtil.info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】"); LogUtil.info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return; return;
} }
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
if (RobotManage.mainMachine.IsInStoreReady) WarnMsg = "";
{ JobInfo inStoreJob = new JobInfo(message, posId);
WarnMsg = ""; RobotManage.mainMachine.LabelingMoveInfo.MoveParam.PosID = inStoreJob.PosId;
JobInfo inStoreJob = new JobInfo(message, posId); //如果当前正在出入库中,需要记录下来,等待空闲时执行
RobotManage.mainMachine.StartInStore(inStoreJob); LogUtil.info(StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
}
else
{
SendStoreState("", StoreStatus.InStoreError);
}
} }
else if (RobotManage.mainMachine.LabelingMoveInfo.MoveStep == MoveStep.InWaitServerCallback) else
{ {
string msg = resultOperation.msg; string msg = resultOperation.msg;
SendStoreState("", StoreStatus.InStoreError); SendStoreState("", StoreStatus.InStoreError);
RobotManage.mainMachine.LabelingMoveInfo.MoveParam.IsNg = true; RobotManage.mainMachine.LabelingMoveInfo.MoveParam.IsNg = true;
RobotManage.mainMachine.LabelingMoveInfo.MoveParam.NgMsg = msg; RobotManage.mainMachine.LabelingMoveInfo.MoveParam.NgMsg = msg;
RobotManage.mainMachine.LabelingMoveInfo.NextMoveStep(MoveStep.WaitInStore); RobotManage.mainMachine.LabelingMoveInfo.MoveParam.PosID = "NG";
//RobotManage.mainMachine.NGPuted(msg);
LogUtil.info("服务器没有正确返回库位. msg=" + msg); LogUtil.info("服务器没有正确返回库位. msg=" + msg);
} }
else
{
}
} }
public float Max_Humidity; public float Max_Humidity;
...@@ -503,11 +484,11 @@ namespace DeviceLibrary ...@@ -503,11 +484,11 @@ namespace DeviceLibrary
{ {
if (resultOperation.data == null) if (resultOperation.data == null)
return; return;
Dictionary<string, string> data = resultOperation.data; Dictionary<string, object> data = resultOperation.data;
if (data.ContainsKey(ParamDefine.maxHumidity) && data.ContainsKey(ParamDefine.maxTemperature)) if (data.ContainsKey(ParamDefine.maxHumidity) && data.ContainsKey(ParamDefine.maxTemperature))
{ {
string maxHumidity = data[ParamDefine.maxHumidity]; string maxHumidity = data[ParamDefine.maxHumidity].ToString();
string maxTemp = data[ParamDefine.maxTemperature]; string maxTemp = data[ParamDefine.maxTemperature].ToString();
LogUtil.info("收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp); LogUtil.info("收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try try
...@@ -529,15 +510,15 @@ namespace DeviceLibrary ...@@ -529,15 +510,15 @@ namespace DeviceLibrary
private void ReviceOutStoreProcess(Operation resultOperation) private void ReviceOutStoreProcess(Operation resultOperation)
{ {
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data; Dictionary<string, object> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW)) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{ {
string posIdStr = data[ParamDefine.posId]; string posIdStr = data[ParamDefine.posId].ToString();
string plateWStr = data[ParamDefine.plateW]; string plateWStr = data[ParamDefine.plateW].ToString();
string plateHStr = data[ParamDefine.plateH]; string plateHStr = data[ParamDefine.plateH].ToString();
string singleOut = data[ParamDefine.singleOut]; string singleOut = data[ParamDefine.singleOut].ToString();
string code = ""; object code = "";
if (!data.TryGetValue("code", out code)) if (!data.TryGetValue("code", out code))
data.TryGetValue(ParamDefine.barcode, out code); data.TryGetValue(ParamDefine.barcode, out code);
LogUtil.info("收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr + ",singleOut=" + singleOut + ",code=" + code); LogUtil.info("收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr + ",singleOut=" + singleOut + ",code=" + code);
...@@ -565,7 +546,7 @@ namespace DeviceLibrary ...@@ -565,7 +546,7 @@ namespace DeviceLibrary
} }
else else
{ {
RobotManage.mainMachine.AddOutStoreTask(code, posId); RobotManage.mainMachine.AddOutStoreTask(code.ToString(), posId);
} }
} }
TimeSpan span = DateTime.Now - time; TimeSpan span = DateTime.Now - time;
......
...@@ -177,8 +177,11 @@ namespace DeviceLibrary ...@@ -177,8 +177,11 @@ namespace DeviceLibrary
case MoveStep.StoreTS08: case MoveStep.StoreTS08:
MoveInfo.NextMoveStep(MoveStep.StoreTS09); MoveInfo.NextMoveStep(MoveStep.StoreTS09);
RobotManage.mainMachine.CylinderMove(MoveInfo, IO_Type.Taking_Release, IO_Type.Taking_Clamp, IO_VALUE.HIGH); RobotManage.mainMachine.CylinderMove(MoveInfo, IO_Type.Taking_Release, IO_Type.Taking_Clamp, IO_VALUE.HIGH);
if (storeMoveType== StoreMoveType.InStore) Setting_Init.Runtime_Posid = To.posid;
if (storeMoveType== StoreMoveType.InStore && To.posid==MainMachine.LabelP)
Setting_Init.Runtime_Step = Runtime_StepE.InToLabel; Setting_Init.Runtime_Step = Runtime_StepE.InToLabel;
if (storeMoveType == StoreMoveType.InStore && To.posid != MainMachine.LabelP)
Setting_Init.Runtime_Step = Runtime_StepE.InToStore;
else if (storeMoveType == StoreMoveType.OutStore) else if (storeMoveType == StoreMoveType.OutStore)
Setting_Init.Runtime_Step = Runtime_StepE.Out; Setting_Init.Runtime_Step = Runtime_StepE.Out;
......
...@@ -13,9 +13,15 @@ using System.Threading.Tasks; ...@@ -13,9 +13,15 @@ using System.Threading.Tasks;
namespace DeviceLibrary namespace DeviceLibrary
{ {
[Serializable]
public enum TestStorePointPort { public enum TestStorePointPort {
入口, 出口, 上层左侧, 上层右侧, 下层左侧, 下层右侧,贴标 入口, 出口, 上层左侧, 上层右侧, 下层左侧, 下层右侧,贴标
} }
[Serializable]
public class tstoredata {
public string name="";
public List<int> Value = new List<int>();
}
public class CameraPointTest public class CameraPointTest
{ {
static CameraData CameraData; static CameraData CameraData;
...@@ -24,9 +30,26 @@ namespace DeviceLibrary ...@@ -24,9 +30,26 @@ namespace DeviceLibrary
{ {
var fd = File.ReadAllText("Config\\CameraPointTest.json"); var fd = File.ReadAllText("Config\\CameraPointTest.json");
CameraData = JsonConvert.DeserializeObject<CameraData>(fd); CameraData = JsonConvert.DeserializeObject<CameraData>(fd);
for (int i = 0; i < 5; i++)
{
inArea.Add(new tstoredata());
inArea[i].name = "L" + ((char)(0x41 + i)).ToString();
for (int j = 0; j < 4; j++)
{
inArea[i].Value.Add(-1);
}
}
for (int i = 0; i < 5; i++)
{
outArea.Add(new tstoredata());
outArea[i].name = "U" + ((char)(0x41 + i)).ToString();
outArea[i].Value.Add(-1);
}
} }
public static event EventHandler<Bitmap> TestStorePointEvent; public static event EventHandler<Bitmap> TestStorePointEvent;
public static List<tstoredata> inArea = new List<tstoredata>();
public static List<tstoredata> outArea = new List<tstoredata>();
public static List<string> GetThingStoreName(TestStorePointPort tp,bool TestHas=true) { public static List<string> GetThingStoreName(TestStorePointPort tp,bool TestHas=true) {
//var tl = Test(tp); //var tl = Test(tp);
try try
...@@ -39,10 +62,24 @@ namespace DeviceLibrary ...@@ -39,10 +62,24 @@ namespace DeviceLibrary
case TestStorePointPort.入口: case TestStorePointPort.入口:
startindex = RobotManage.AllPositionMapNumList.IndexOf("LA1"); startindex = RobotManage.AllPositionMapNumList.IndexOf("LA1");
haslistindex = TestStorePoint(RobotManage.CameraA.GetImage(0), TestStorePointPort.入口); haslistindex = TestStorePoint(RobotManage.CameraA.GetImage(0), TestStorePointPort.入口);
int index = 0;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 4; j++)
{
inArea[i].Value[j]=haslistindex[index];
index++;
}
}
break; break;
case TestStorePointPort.出口: case TestStorePointPort.出口:
startindex = RobotManage.AllPositionMapNumList.IndexOf("UA1"); startindex = RobotManage.AllPositionMapNumList.IndexOf("UA1");
haslistindex = TestStorePoint(RobotManage.CameraA.GetImage(1), TestStorePointPort.出口); haslistindex = TestStorePoint(RobotManage.CameraA.GetImage(1), TestStorePointPort.出口);
index = 0;
for (int i = 0; i < 5; i++)
{
outArea[i].Value[0]=haslistindex[index];
index++;
}
break; break;
case TestStorePointPort.上层左侧: case TestStorePointPort.上层左侧:
startindex = RobotManage.AllPositionMapNumList.IndexOf("LA1"); startindex = RobotManage.AllPositionMapNumList.IndexOf("LA1");
...@@ -206,42 +243,59 @@ namespace DeviceLibrary ...@@ -206,42 +243,59 @@ namespace DeviceLibrary
return StorePoint; return StorePoint;
} }
public static int ScanRectangle() { public static bool ScanRectangle() {
var r = CameraData[TestStorePointPort.贴标.ToString()].ObjectPoint; var r = CameraData[TestStorePointPort.贴标.ToString()].PointList;
Point Start = r[0]; Point Start = r[0];
Point End = r[1]; Point End = r[1];
int width = Start.X = End.X; int width = End.X - Start.X;
int height = Start.Y = End.Y; int height = End.Y - Start.Y;
LogUtil.info($"开始扫描绿色区域:{Start},{width}x{height}"); LogUtil.info($"开始扫描绿色区域:{Start},{width}x{height}");
var bmp = Camera._cam.GrabOneImage(CodeManager.hikNameList[0], PixelType.RGB8); var bmp = Camera._cam.GrabOneImage(CodeManager.hikNameList[0], PixelType.RGB8);
var bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); //var bmp = new Bitmap("Image_20221208134139341.bmp");
List<Rectangle> RectScanList = new List<Rectangle>(); var bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat);
int RectScanindex = 0;
int HeightCount = 0; int HeightCount = 0;
int errlinecount = 0;
try { try {
for (int i = 0; i < height; i++) for (int i = 0; i < height; i++)
{ {
int linecount = 0; int linecount = 0;
for (int j = 0; j < width; j++) for (int j = 0; j < width; j++)
{ {
var x = Start.X + j; var x = Start.X+ j;
var y = Start.Y + i; var y = Start.Y + height - i;
var addr = y * bd.Stride + x * 4; var addr = y * bd.Stride + x * 3;
var cr = Marshal.ReadByte(bd.Scan0, addr + 2); var cr = Marshal.ReadByte(bd.Scan0, addr + 2);
var cg = Marshal.ReadByte(bd.Scan0, addr + 1); var cg = Marshal.ReadByte(bd.Scan0, addr + 1);
var cb = Marshal.ReadByte(bd.Scan0, addr); var cb = Marshal.ReadByte(bd.Scan0, addr);
var hh = ColorHelper.RgbToHsv(new ColorRGB(cr, cg, cb)); var hh = ColorHelper.RgbToHsv(new ColorRGB(cr, cg, cb));
var s = hh.S; var s = hh.S;
var h = hh.H; var h = hh.H;
var has = s > 15 && h > 80 && h < 150; var has = s > 15 && h > 90 && h < 150;
if (has) linecount++;//本行绿色计数 if (has)
{
linecount++;//本行绿色计数
Marshal.WriteByte(bd.Scan0, addr + 2, 0xFF);
Marshal.WriteByte(bd.Scan0, addr + 1, 0);
Marshal.WriteByte(bd.Scan0, addr, 0);
}
} }
if (linecount < width * 0.9) if (linecount < width * 0.6)
{ {
return HeightCount; errlinecount++;
HeightCount = 0;
if (errlinecount > 60)
{
return false;
}
//return HeightCount;
} }
else { else {
HeightCount++; HeightCount++;
if (HeightCount > 50) {
return true;
}
} }
} }
} }
...@@ -252,8 +306,9 @@ namespace DeviceLibrary ...@@ -252,8 +306,9 @@ namespace DeviceLibrary
finally finally
{ {
bmp.UnlockBits(bd); bmp.UnlockBits(bd);
} bmp.Save("\\Image\\LabelDebug\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-"+ errlinecount +"-"+ HeightCount + ".bmp");
return HeightCount; }
return false;
} }
} }
public class CameraData : Dictionary<string, CameraPointData> { } public class CameraData : Dictionary<string, CameraPointData> { }
......
...@@ -367,7 +367,8 @@ namespace DeviceLibrary ...@@ -367,7 +367,8 @@ namespace DeviceLibrary
ResetBtn, ResetBtn,
RunBtn, RunBtn,
SuddenStop, SuddenStop,
X09_Clear X09_Clear,
LabelInPaste
} }
public class IdWorker public class IdWorker
{ {
......
...@@ -52,6 +52,9 @@ namespace DeviceLibrary ...@@ -52,6 +52,9 @@ namespace DeviceLibrary
/// 物料编码 /// 物料编码
/// </summary> /// </summary>
public string PN { get; set; } public string PN { get; set; }
public string LOT { get; set; }
public string EXP { get; set; }
public string SN { get; set; }
/// <summary> /// <summary>
/// 数量 /// 数量
/// </summary> /// </summary>
...@@ -99,7 +102,7 @@ namespace DeviceLibrary ...@@ -99,7 +102,7 @@ namespace DeviceLibrary
} }
public string ToDetailStr() public string ToDetailStr()
{ {
return $"{DateTime.Now:HH:mm:ss},{ReeID},{PN},{NgMsg},{WareCode}"; return $"{DateTime.Now:HH:mm:ss},{SN},{LOT},{EXP},{PN},{NgMsg},{WareCode}";
} }
} }
[Serializable] [Serializable]
......
...@@ -274,6 +274,17 @@ namespace DeviceLibrary ...@@ -274,6 +274,17 @@ namespace DeviceLibrary
Msg.add(crc.GetString("Res0095","出料抽屉没有关闭"), MsgLevel.alarm); Msg.add(crc.GetString("Res0095","出料抽屉没有关闭"), MsgLevel.alarm);
return; return;
} }
if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW))
{
if (Setting_Init.Runtime_Step >= Runtime_StepE.Printed && Setting_Init.Runtime_Step < Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid);
//LabelingMoveInfo.NextMoveStep(MoveStep.Labeling01);
//StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
Msg.add("重置前物料正在贴标,无法继续,请手动处理", MsgLevel.warning, ErrInfo.LabelInPaste);
RobotManage.UserPause("重置前物料正在贴标,无法继续,请手动处理");
}
}
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01); ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01);
ResetMoveInfo.log("锁定抽屉"); ResetMoveInfo.log("锁定抽屉");
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH); IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
......
...@@ -32,72 +32,7 @@ namespace DeviceLibrary ...@@ -32,72 +32,7 @@ namespace DeviceLibrary
HEND_HomeReset, HEND_HomeReset,
StringLoad_01,
StringLoad_01a,
StringLoad_02,
StringLoad_02a,
StringLoad_02b,
StringLoad_03,
StringLoad_04,
StringLoad_05,
StringLoad_06,
StringLoad_07,
StringReadyGet,
StringReelGet,
StringReelGetFail,
StringReelGetFail_02,
StringReadyPut,
StringReelPut,
StringReelPut_01,
StringReelPut_02,
StringReelPut_03,
StringReelPut_04,
StringOut_01,
StringOut_02,
StringOut_03,
StringOut_Released,
StringOut_05,
StringOut_06,
StringOut_07,
ReelClamp_01,
ReelClamp_02,
ReelClamp_03,
ReelClamp_04,
ReelClamp_05,
ReelClamp_WaitGaugeHeight,
ReelClamp_GetHeight,
ReelClamp_06,
ReelClamp_07,
ReelClamp_08,
ReelClamp_09,
ReelClamp_10,
ReelClamp_11,
InWaitServerCallback,
WaitInStore,
ReelTaked,
NGOUT_00,
NGOUT_01,
NGOUT_02,
NGOUT_03,
NGOUT_04,
NGOUT_05,
NGOUT_06,
NGOUT_07,
NGOUT_08,
NGOUT_09,
NGOUT_10,
NGOUT_11,
SingleIn,
SingleIn_01,
SingleIn_02,
SingleInReady,
SingleInRun,
SingleInRun_01,
SingleInRun_02,
SingleInRun_03,
SingleInRun_04,
SingleInRun_05,
OutBoxPutOn, OutBoxPutOn,
Out01, Out01,
...@@ -184,6 +119,7 @@ namespace DeviceLibrary ...@@ -184,6 +119,7 @@ namespace DeviceLibrary
Labeling07, Labeling07,
Labeling08, Labeling08,
Labeling09, Labeling09,
WaitInStore,
Labeling10, Labeling10,
Labeling11, Labeling11,
Labeling12, Labeling12,
......
...@@ -397,7 +397,21 @@ namespace TheMachine ...@@ -397,7 +397,21 @@ namespace TheMachine
{ {
btn_IgnoreX09.Visible = false; btn_IgnoreX09.Visible = false;
} }
else if (msg.errInfo == ErrInfo.LabelInPaste)
{
if (FrmAlarm.ShowAlarmDialog("贴标区内可能有物料未完成贴标,请手动取出") == DialogResult.OK)
{
LogUtil.info("用户确认已处理");
Setting_Init.Runtime_Step = Runtime_StepE.None;
RobotManage.UserPause(false);
}
else {
btn_stop_Click(this, EventArgs.Empty);
LogUtil.info("用户取消处理,系统停止");
}
}
} }
this.ResumeLayout(true); this.ResumeLayout(true);
} }
......

namespace TheMachine
{
partial class FrmAlarm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn_ok = new System.Windows.Forms.Button();
this.btn_cancel = new System.Windows.Forms.Button();
this.lbl_info = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btn_ok
//
this.btn_ok.Location = new System.Drawing.Point(493, 374);
this.btn_ok.Name = "btn_ok";
this.btn_ok.Size = new System.Drawing.Size(232, 54);
this.btn_ok.TabIndex = 0;
this.btn_ok.Text = "已处理完毕,继续运行";
this.btn_ok.UseVisualStyleBackColor = true;
this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
//
// btn_cancel
//
this.btn_cancel.Location = new System.Drawing.Point(12, 374);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(232, 54);
this.btn_cancel.TabIndex = 1;
this.btn_cancel.Text = "暂不处理,停止运行";
this.btn_cancel.UseVisualStyleBackColor = true;
this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
//
// lbl_info
//
this.lbl_info.Font = new System.Drawing.Font("Arial", 42F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_info.ForeColor = System.Drawing.Color.Red;
this.lbl_info.Location = new System.Drawing.Point(12, 39);
this.lbl_info.Name = "lbl_info";
this.lbl_info.Size = new System.Drawing.Size(713, 261);
this.lbl_info.TabIndex = 2;
this.lbl_info.Text = "123123123123";
this.lbl_info.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// FrmAlarm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(770, 459);
this.ControlBox = false;
this.Controls.Add(this.lbl_info);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_ok);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmAlarm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FrmAlarm";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btn_ok;
private System.Windows.Forms.Button btn_cancel;
public System.Windows.Forms.Label lbl_info;
}
}
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public partial class FrmAlarm : Form
{
public FrmAlarm()
{
InitializeComponent();
}
public static DialogResult ShowAlarmDialog(string info) {
FrmAlarm frmAlarm = new FrmAlarm();
frmAlarm.lbl_info.Text = info;
return frmAlarm.ShowDialog();
}
private void btn_cancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void btn_ok_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
...@@ -25,6 +25,7 @@ namespace TheMachine ...@@ -25,6 +25,7 @@ namespace TheMachine
static void Main() static void Main()
{ {
CameraPointTest.Init(); CameraPointTest.Init();
//CameraPointTest.ScanRectangle();
//var bmpfile = @"D:\rick\vs\SO20031_TinStorage\料架照片\106_监控点1_106_20221125194616_31932401.bmp"; //var bmpfile = @"D:\rick\vs\SO20031_TinStorage\料架照片\106_监控点1_106_20221125194616_31932401.bmp";
//var bmp = new Bitmap(bmpfile); //var bmp = new Bitmap(bmpfile);
//var r = Common.CalcStoreBMP(bmp,4, 5); //var r = Common.CalcStoreBMP(bmp,4, 5);
......
...@@ -96,6 +96,12 @@ ...@@ -96,6 +96,12 @@
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmAlarm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmAlarm.Designer.cs">
<DependentUpon>FrmAlarm.cs</DependentUpon>
</Compile>
<Compile Include="IOControls.cs"> <Compile Include="IOControls.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -175,6 +181,7 @@ ...@@ -175,6 +181,7 @@
</Compile> </Compile>
<EmbeddedResource Include="AboutBox1.resx"> <EmbeddedResource Include="AboutBox1.resx">
<DependentUpon>AboutBox1.cs</DependentUpon> <DependentUpon>AboutBox1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="AxisControl.resx"> <EmbeddedResource Include="AxisControl.resx">
<DependentUpon>AxisControl.cs</DependentUpon> <DependentUpon>AxisControl.cs</DependentUpon>
...@@ -183,6 +190,9 @@ ...@@ -183,6 +190,9 @@
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmAlarm.resx">
<DependentUpon>FrmAlarm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="IOControls.resx"> <EmbeddedResource Include="IOControls.resx">
<DependentUpon>IOControls.cs</DependentUpon> <DependentUpon>IOControls.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!