Commit 8953068c 张东亮

HY11不放行托盘、扫码异常退出

1 个父辈 ca66a198
......@@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using OnlineStore.DeviceLibrary;
using System.IO;
namespace OnlineStore.AssemblyLine
{
......@@ -54,7 +55,7 @@ namespace OnlineStore.AssemblyLine
[STAThread]
static void Main(string[] Args)
{
//string code = " (X: 380,Y: 148) L00000000000WG9D19055;E20191230 0180;B7H.10618.5B1008082019123004000;R0080820191230E9600";
//string r = CodeManager.ReplaceCode(code);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
......@@ -114,7 +115,7 @@ namespace OnlineStore.AssemblyLine
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
LogUnhandledException("CurrentDomain_UnhandledException", e.ToString() +""+e.ExceptionObject.ToString()+" ");
LogUnhandledException("CurrentDomain_UnhandledException", e.ToString() + "" + e.ExceptionObject.ToString() + " ");
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
......@@ -125,13 +126,117 @@ namespace OnlineStore.AssemblyLine
static void LogUnhandledException(string type, string exceptionobj)
{
//这里可以进一步地写日志
string dir = Application.StartupPath + "\\ErrorDump\\";
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
string formTitle = ConfigAppSettings.GetValue(Setting_Init.App_Title);
MiniDump.Write(dir + DateTime.Now.ToString("yyyyMMddHHmmss") + $"-{formTitle}.dmp");
LogUtil.error("【" + type + "】" + exceptionobj);
MessageBox.Show(exceptionobj, type);
LogUtil.error("【" + type + "】" + exceptionobj);
}
#region dump
public sealed class MiniDump
{
[Flags]
public enum DumpType : uint
{
// From dbghelp.h:
MiniDumpNormal = 0x00000000,
MiniDumpWithDataSegs = 0x00000001,
MiniDumpWithFullMemory = 0x00000002,
MiniDumpWithHandleData = 0x00000004,
MiniDumpFilterMemory = 0x00000008,
MiniDumpScanMemory = 0x00000010,
MiniDumpWithUnloadedModules = 0x00000020,
MiniDumpWithIndirectlyReferencedMemory = 0x00000040,
MiniDumpFilterModulePaths = 0x00000080,
MiniDumpWithProcessThreadData = 0x00000100,
MiniDumpWithPrivateReadWriteMemory = 0x00000200,
MiniDumpWithoutOptionalData = 0x00000400,
MiniDumpWithFullMemoryInfo = 0x00000800,
MiniDumpWithThreadInfo = 0x00001000,
MiniDumpWithCodeSegs = 0x00002000,
MiniDumpWithoutAuxiliaryState = 0x00004000,
MiniDumpWithFullAuxiliaryState = 0x00008000,
MiniDumpWithPrivateWriteCopyMemory = 0x00010000,
MiniDumpIgnoreInaccessibleMemory = 0x00020000,
MiniDumpValidTypeFlags = 0x0003ffff,
};
//typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
// DWORD ThreadId;
// PEXCEPTION_POINTERS ExceptionPointers;
// BOOL ClientPointers;
//} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
[StructLayout(LayoutKind.Sequential, Pack = 4)] // Pack=4 is important! So it works also for x64!
struct MiniDumpExceptionInformation
{
public uint ThreadId;
public IntPtr ExceptioonPointers;
[MarshalAs(UnmanagedType.Bool)]
public bool ClientPointers;
}
//BOOL
//WINAPI
//MiniDumpWriteDump(
// __in HANDLE hProcess,
// __in DWORD ProcessId,
// __in HANDLE hFile,
// __in MINIDUMP_TYPE DumpType,
// __in_opt PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
// __in_opt PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
// __in_opt PMINIDUMP_CALLBACK_INFORMATION CallbackParam
// );
[DllImport("dbghelp.dll",
EntryPoint = "MiniDumpWriteDump",
CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Unicode,
ExactSpelling = true, SetLastError = true)]
static extern bool MiniDumpWriteDump(
IntPtr hProcess,
uint processId,
IntPtr hFile,
uint dumpType,
ref MiniDumpExceptionInformation expParam,
IntPtr userStreamParam,
IntPtr callbackParam);
[DllImport("kernel32.dll", EntryPoint = "GetCurrentThreadId", ExactSpelling = true)]
static extern uint GetCurrentThreadId();
static void Test()
[DllImport("kernel32.dll", EntryPoint = "GetCurrentProcess", ExactSpelling = true)]
static extern IntPtr GetCurrentProcess();
[DllImport("kernel32.dll", EntryPoint = "GetCurrentProcessId", ExactSpelling = true)]
static extern uint GetCurrentProcessId();
public static bool Write(string fileName)
{
return Write(fileName, DumpType.MiniDumpWithFullMemory);
}
public static bool Write(string fileName, DumpType dumpType)
{
using (var fs = new System.IO.FileStream(fileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.None))
{
MiniDumpExceptionInformation exp;
exp.ThreadId = GetCurrentThreadId();
exp.ClientPointers = false;
exp.ExceptioonPointers = System.Runtime.InteropServices.Marshal.GetExceptionPointers();
bool bRet = MiniDumpWriteDump(
GetCurrentProcess(),
GetCurrentProcessId(),
fs.SafeFileHandle.DangerousGetHandle(),
(uint)dumpType,
ref exp,
IntPtr.Zero,
IntPtr.Zero);
return bRet;
}
}
}
#endregion
static void Test()
{
string s = "http://192.168.101.11/myproject/rest/api/qisda/device/getSize?robotIndex=2&barcode=L165K001877%3bE20200329+0730%3bBQT001200218504192020032915000%3bR04192020042451762%23%230201X104K100CT%2f15000%2f165K001877%2f20200329%23%23";
......@@ -145,7 +250,7 @@ namespace OnlineStore.AssemblyLine
// string param = JsonHelper.SerializeObject(value);
s = "http://192.168.101.11/myproject/service/store/emptyPosForPutin?cids=line-ac-01%2cline-ac-02%2cline-ac-03%2cline-ac-04%2cline-ac-05%2cline-ac-06%2cline-ac-07%2cline-ac-08%2cline-ac-09%2cline-ac-10%2cline-ac-11%2cline-ac-12%2cline-ac-13%2cline-ac-14%2cline-ac-15%2cline-ac-16%2cline-ac-17%2cline-ac-18&code=%3d7x8%3dL0000000IA0106D25D015%3bE20200106+0730%3bB7H.10524.5C1035042020010604000+%3bR035042020010600208%23%23&rfid=B16";
string result = HttpHelper.Post(s, "");
s = "http://192.168.101.11/myproject/rest/api/qisda/device/getSize?robotIndex=2&barcode=L165K001877%3bE20200329+0730%3bBQT001200218504192020032915000%3bR04192020042451762%23%230201X104K100CT%2f15000%2f165K001877%2f20200329%23%23";
s = "http://192.168.101.11/myproject/rest/api/qisda/device/getSize?robotIndex=2&barcode=L165K001877%3bE20200329+0730%3bBQT001200218504192020032915000%3bR04192020042451762%23%230201X104K100CT%2f15000%2f165K001877%2f20200329%23%23";
result = HttpHelper.Post(s, "");
return;
}
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......
......@@ -185,7 +185,7 @@ namespace OnlineStore.DeviceLibrary
private Stopwatch olcheckWatch = new Stopwatch();
private object lockObj = "";
private bool preTrayIsC1Line = false;
private bool preTrayIsC1Line = false;
private void stopWatchCheck()
{
......@@ -260,7 +260,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
bool check2IsOk = CheckStopWatch(trayCheckLowWait, TrayWaitTime, false)||String.IsNullOrEmpty(RFIDIP);
bool check2IsOk = CheckStopWatch(trayCheckLowWait, TrayWaitTime, false) || String.IsNullOrEmpty(RFIDIP);
if (preTrayIsC1Line && Config.IsOutLineOut && IOValue(IO_Type.HY_OL_Tray_Check).Equals(IO_VALUE.HIGH))
{
StopDownCount = 0;
......@@ -272,7 +272,7 @@ namespace OnlineStore.DeviceLibrary
if (CheckStopWatch(frontTrayCheckWait, TrayWaitTime, false) && check2IsOk)
{
StopDownCount = 0;
preTrayIsC1Line = true;
preTrayIsC1Line = true;
//托盘在前阻挡处
frontTrayCheckWait.Stop();
trayCheckLowWait.Stop();
......@@ -336,7 +336,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_OL_Tray_Check, IO_VALUE.HIGH));
}
}
internal void HY03_FrontStopUp(int timeout= 20000,bool frontStopUp=true)
internal void HY03_FrontStopUp(int timeout = 20000, bool frontStopUp = true)
{
frontTrayCheckWait.Stop();
trayCheckLowWait.Stop();
......@@ -349,22 +349,22 @@ namespace OnlineStore.DeviceLibrary
CheckAndMove(IO_Type.HY_FrontStopDown, IO_VALUE.LOW);
}
else
{
CheckLog("托盘阻挡" + MoveInfo.SLog + " 前阻挡检测信号灭,等待托盘检测信号");
{
CheckLog("托盘阻挡" + MoveInfo.SLog + " 前阻挡检测信号灭,等待托盘检测信号");
}
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_TrayCheck, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(timeout));
}
private int StopDownCount = 0;
private void EndOrReStopDown(string msg )
private void EndOrReStopDown(string msg)
{
if (StopDownCount == 0)
{
LogInfo(SecondMoveInfo.SLog + msg + ",暂不结束,重新下降一次前阻挡");
//阻挡重新下降一次
StopDownCount++;
MoveInfo.NextMoveStep(LineMoveStep.HY02_FrontStopDown);
if (DeviceID.Equals(219))
{
......@@ -384,7 +384,7 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.HY_OL_StopDown, IO_VALUE.LOW);
}
else
{
{
LogInfo(MoveInfo.SLog + msg);
MoveEndS();
}
......@@ -402,14 +402,14 @@ namespace OnlineStore.DeviceLibrary
#region 托盘检测处理
if (MoveInfo.IsStep(LineMoveStep.HY02_FrontStopDown))
{
{
//如果此步骤持续还不到一秒,是信号闪烁,暂不处理
//if (MoveInfo.StepSpan().TotalSeconds < 1)
//{
// return;
//}
if (IOValue(IO_Type.HY_TrayCheck).Equals(IO_VALUE.HIGH))
if (IOValue(IO_Type.HY_TrayCheck).Equals(IO_VALUE.HIGH))
{
HY03_FrontStopUp();
}
......@@ -797,12 +797,14 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.HY75_OL_StopDown);
CheckLog("托盘阻挡" + MoveInfo.SLog + " 等待出料线托盘检测无信号");
IOMove(IO_Type.HY_OL_StopDown, IO_VALUE.HIGH, 1200);
IOMove(IO_Type.HY_OL_StopDown, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1200));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_OL_Tray_Check, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(LineMoveStep.HY75_OL_StopDown))
{
MoveInfo.NextMoveStep(LineMoveStep.HY76_OL_WaitTray);
IOMove(IO_Type.HY_OL_StopDown, IO_VALUE.LOW);
CheckLog("托盘阻挡" + MoveInfo.SLog + " 等待托盘到达信号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_OL_Tray_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_TrayCheck, IO_VALUE.HIGH));
......@@ -911,7 +913,7 @@ namespace OnlineStore.DeviceLibrary
private int hyIndex = 0;
private void HY11_TopUpToHY()
{
HY_C1Line hyout =(HY_C1Line) GetHyOutEquip();
HY_C1Line hyout = (HY_C1Line)GetHyOutEquip();
if (hyout.HYOut51_WaitFree())
{
MoveInfo.NextMoveStep(LineMoveStep.HY13_WaitHY2Ready);
......@@ -944,7 +946,7 @@ namespace OnlineStore.DeviceLibrary
if (Config.IsSideWayIn && trayNum > 0)
{
//出口启动才能横移
HYEquipBase hyE= GetHyOutEquip();
HYEquipBase hyE = GetHyOutEquip();
if (hyE == null || hyE.runStatus <= LineRunStatus.Wait)
{
return false;
......@@ -996,14 +998,14 @@ namespace OnlineStore.DeviceLibrary
{
//非 1,2,3,4,5,13,14,15,16的入库料需要横移
if (tray.IsFull)
{
{
//NG料需要横移
if (tray.InoutPar.IsNG)
{
return true;
}
if (tray.InOrOutStore.Equals(1))
{
{
int storeId = tray.InoutPar.GetStoreId();
List<int> instoreId = new List<int> { 1, 2, 3, 4, 5, 13, 14, 15, 16 };
if (!instoreId.Contains(storeId))
......@@ -1140,12 +1142,12 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(Name+"TrayNeed 出错:" + ex.ToString());
LogUtil.error(Name + "TrayNeed 出错:" + ex.ToString());
}
return false;
}
private int pandianliao = 0;
private int PreIsToOutCount = 0;
private int PreIsToOutCount = 0;
private bool TrayNeedToOutLine(int trayNum)
{
try
......@@ -1372,7 +1374,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(Name+"TrayNeedToOutLine 出错:" + ex.ToString());
LogUtil.error(Name + "TrayNeedToOutLine 出错:" + ex.ToString());
}
return false;
}
......@@ -1426,7 +1428,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.debug("进仓05托盘离开," + Name + "开始等待托盘检测信号 HY03_FrontStopUp");
HY03_FrontStopUp(60000);
return true;
}
}
}
}
catch (Exception ex)
......
......@@ -140,30 +140,30 @@ namespace OnlineStore.DeviceLibrary
string r = "";
bool eyemNoCode = false;
Task eyemtask = Task.Factory.StartNew(delegate {
List<CodeInfo> tlci = EyemDecode.ModelDecoder(ref bmp);
foreach (CodeInfo code in tlci)
{
LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
string str = CodeManager.ReplaceCode(code.CodeStr);
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##eyem|" + code.CodeType + "|" + str;
if (!findRightCode)
{
findRightCode = HasRightCode(str);
}
}
}
});
//最多等待60秒
bool taskResult = eyemtask.Wait(60000);
if (!taskResult)
{
LogUtil.error(deviceName + " 【" + cameraName + "】eyem扫码超时");
eyemNoCode = true;
}
//Task eyemtask = Task.Factory.StartNew(delegate {
// List<CodeInfo> tlci = EyemDecode.ModelDecoder(ref bmp);
// foreach (CodeInfo code in tlci)
// {
// LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
// string str = CodeManager.ReplaceCode(code.CodeStr);
// if (!codeList.Contains(str))
// {
// codeList.Add(str);
// r = r + "##eyem|" + code.CodeType + "|" + str;
// if (!findRightCode)
// {
// findRightCode = HasRightCode(str);
// }
// }
// }
//});
////最多等待60秒
//bool taskResult = eyemtask.Wait(60000);
//if (!taskResult)
//{
// LogUtil.error(deviceName + " 【" + cameraName + "】eyem扫码超时");
// eyemNoCode = true;
//}
if (!isPreScan)
{
if (!findRightCode)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!