Browse Source

change log mode.send all the string log message to NLog console.

gsp 3 years ago
parent
commit
90eb891558

+ 2 - 3
Bin/x64/Debug/Resources/XMLData/AppResource_EN.xml

@@ -158,7 +158,7 @@
 	  <Control name="RSGrayVal" text="GrayValue" />
 	  <Control name="mouseMatter" text="MouseMatter" />
 	  <Control name="ribbonOrbMenuItem5" text="Copy" />
-	  <Control name="frmReportApp" text="ReportApp" />
+	
 	  <Control name="ribbonOrbMenuItem_Extremum" text="Extremum analysis" />
 	  <Control name="message1" text="Now there are open measurement results files which will not be saved after new projects are built. Are you sure to build a new one?" />
 	  <Control name="AnalysisDiagram" text="Analysis diagram" />
@@ -921,8 +921,7 @@
 	  <Control name="TSGrayVal" text="GrayVal" />
 	  <Control name="STSemCoordinate" text="SemCoordinate" />
 	  <Control name="ribbonButton3" text="Reset" />
-	  <Control name="ribbonButton1" text="Open" />
-	  <Control name="OTSIncAMeasureAppForm" text="SampleMeasurement" />
+	  <Control name="ribbonButton1" text="Open" />	
 	  <Control name="m_SamplespaceWindowName" text="SampleStage" />
 	  <Control name="m_MeasureStauWindowName" text="MeasurementState" />
 	  <Control name="m_MeasureRetWindowName" text="MeasurementResult" />

+ 2 - 2
Bin/x64/Debug/Resources/XMLData/AppResource_ZH.xml

@@ -158,7 +158,7 @@
 	  <Control name="RSGrayVal" text="灰度值" />
 	  <Control name="mouseMatter" text="鼠标点的物质" />
 	  <Control name="ribbonOrbMenuItem5" text="复制" />
-	  <Control name="frmReportApp" text="报告程序" />
+	
 	  <Control name="ribbonOrbMenuItem_Extremum" text="极值分析法 " />
 	  <Control name="message1" text="现已经有打开的测量结果文件新建项目后将不保存,是否确定新建?" />
 	  <Control name="AnalysisDiagram" text="分析图" />
@@ -919,7 +919,7 @@
 	  <Control name="STSemCoordinate" text="SEM坐标" />
 	  <Control name="ribbonButton3" text="复位" />
 	  <Control name="ribbonButton1" text="打开" />
-	  <Control name="OTSIncAMeasureAppForm" text="样品测量程序" />
+	
 	  <Control name="m_SamplespaceWindowName" text="样品台" />
 	  <Control name="m_MeasureStauWindowName" text="测量状态" />
 	  <Control name="m_MeasureRetWindowName" text="测量结果" />

+ 2 - 2
OTSCPP/OTSClassifyEngine/CurveCompareEngine/OTSSTDLibFileMgr.cpp

@@ -70,7 +70,7 @@ namespace OTSClassifyEngine
 		// program manager param file exists?
 		if (!COTSFileSys::Exists(m_strPathName))
 		{
-			LogErrorTrace(__FILE__, __LINE__, _T("GenerateSTDLib: there is no STD lib file."));
+			LogErrorTrace(__FILE__, __LINE__, _T("GenerateSTDLib: there is no STD lib file."+ m_strPathName));
 			return FALSE;
 		}
 		
@@ -93,7 +93,7 @@ namespace OTSClassifyEngine
 
 		if (!COTSFileSys::Exists(m_strPathName))
 		{
-			LogErrorTrace(__FILE__, __LINE__, _T("GenerateSTDLib: there is no STD lib file."));
+			LogErrorTrace(__FILE__, __LINE__, _T("GenerateSTDLib: there is no STD lib file."+ m_strPathName));
 			return FALSE;
 		}
 		if (!CreateSTDLibFile())

+ 27 - 4
OTSCPP/OTSClassifyEngine/InclutionClassifyEngine.cpp

@@ -9,9 +9,20 @@ namespace OTSClassifyEngine
 bool InclutionClassifyEngine::Init()
 {
 	CSTDFileMgrPtr stdfile = CSTDFileMgrPtr(new CSTDFileMgr());
-	stdfile->Load();
+	if (!stdfile->Load())
+	{
+		return false;
+	}
 	myStd = stdfile-> GenerateSTDLib(IDENTIFY_KIND::ALL);
-	return true;
+	if (myStd!=nullptr) 
+	{
+		return true;
+	}
+	else
+	{
+		return false;
+	}
+	
 }
 
 
@@ -31,8 +42,20 @@ bool InclutionClassifyEngine::Classify(COTSParticlePtr particle, int SteelTech,
 	auto result = COTSClassifyEng::ClassifyXray(myStd, (OTSDATA::STEEL_TECHNOLOGY)SteelTech, xray->GetElementQuantifyData(), Id, grpId);
 
 
-	
-	if (grpId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
+	if (grpId == (int)OTS_PARTICLE_TYPE::INVALID)
+	{
+		particle->SetType(OTS_PARTICLE_TYPE::INVALID);
+		particle->TypeName("Invalid");
+		particle->TypeColor("#000000");
+		particle->SetGroupId(grpId);
+		std::string grpName;
+		std::string grpColor;
+		COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
+		particle->SetGroupName(grpName);
+		particle->SetGroupColor(grpColor);
+
+	}
+	else if (grpId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
 	{
 		particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
 		particle->TypeName("Not Identified");

+ 20 - 6
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp

@@ -21,10 +21,12 @@ namespace OTSClassifyEngine
 	//Dispose ClassifyXray
 	BOOL COTSClassifyEng::ClassifyXray(CInclutionSTDDataPtr a_pPartSTDData, STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElementChemistries, int& a_nIncId, int& a_GrpId)
 	{
+		
 		// safety check
 		ASSERT(a_pPartSTDData);
 		if (!a_pPartSTDData)
 		{
+			/*SendLogMessageToNlog("begin to classify particles", (int)PostLogLevel::warn);*/
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: invalid CPartSTDDataPtr."));
 			return FALSE;
 		}
@@ -39,9 +41,9 @@ namespace OTSClassifyEngine
 		if (!IsAnValidIncXRay(a_listElementChemistries, listElChemsInc, listElChemsIncNoFe, dMolarSum, dMolarSumNoFe, incId, notIncId))
 		{
 		
-				a_nIncId =(int) incId;//invalid particle
-				a_GrpId = (int)incId;
-			return TRUE;
+			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::failed to call IsAnValidIncXRay"));
+				
+			return FALSE;
 		}
 		if (incId == OTS_PARTCLE_TYPE::ISNOT_INCLUTION)// this is not an inclution particle,but we can identify.
 		{
@@ -50,6 +52,13 @@ namespace OTSClassifyEngine
 			return TRUE;
 
 		}
+		if (incId == OTS_PARTCLE_TYPE::INVALID)// this is not an valid inclution particle.
+		{
+			a_nIncId = (int)OTS_PARTCLE_TYPE::INVALID;
+			a_GrpId = (int)OTS_PARTCLE_TYPE::INVALID;
+			return TRUE;
+
+		}
 		
 
 		// system STD classification
@@ -240,7 +249,7 @@ namespace OTSClassifyEngine
 		if (a_dMolarSumNoFe < MIN_ELEMENT_SUM)
 		{
 			a_nIncId = OTS_PARTICLE_TYPE::INVALID;
-			return FALSE;
+			return TRUE;
 		}
 
 		if (dSumKeyElementsMolar > INC_KEY_ELEMENT_TOTAL_100 && dSumSubElementsMolar > INC_SUB_ELEMENT_TOTAL_100)
@@ -251,7 +260,7 @@ namespace OTSClassifyEngine
 		else
 		{
 			a_nIncId = OTS_PARTICLE_TYPE::INVALID;
-			return FALSE;
+			return TRUE;
 		}
 	}
 
@@ -402,10 +411,15 @@ namespace OTSClassifyEngine
 
 	BOOL COTSClassifyEng::GetGroupNameAndColorById(int grpId,std::string& grpName,std::string& grpColor)
 	{
+		if (grpId == (int)OTS_PARTICLE_TYPE::INVALID)
+		{
+			grpName = "Invalid";
+			grpColor = "#000000";
+		}
 		if (grpId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
 		{
 			grpName = "Not Identified";
-			grpColor = "#E6E6FA";
+			grpColor = "#000000";
 		}
 		if (grpId == (int)OTS_PARTICLE_TYPE::ISNOT_INCLUTION)
 		{

+ 13 - 2
OTSCPP/OTSClassifyEngine/ParticleClassifyEngine.cpp

@@ -85,7 +85,10 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 				
 				particle->SetClassifyId((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
 				particle->TypeName("Not Identified");
-
+				particle->TypeColor("#000000");
+				particle->SetGroupId((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
+				particle->SetGroupName("Not Identified");
+				particle->SetGroupColor("#000000");
 				continue;
 			}
 
@@ -100,6 +103,10 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 				{
 					particle->SetClassifyId((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
 					particle->TypeName("Not Identified");
+					particle->TypeColor("#000000");
+					particle->SetGroupId((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
+					particle->SetGroupName("Not Identified");
+					particle->SetGroupColor("#000000");
 					bMatch = false;
 					break;
 				}
@@ -212,6 +219,10 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 		}
 		particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
 		particle->TypeName("Not Identified");
+		particle->TypeColor("#000000");
+		particle->SetGroupId((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
+		particle->SetGroupName("Not Identified");
+		particle->SetGroupColor("#000000");
 		return true;
 	}
 	else if(particle != nullptr && xray == nullptr)
@@ -283,7 +294,7 @@ bool ParticleClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray
 		particle->TypeName("Not Identified");
 		particle->TypeColor("#000000");
 		particle->SetGroupId((int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
-		particle->SetGroupColor("#E6E6FA");
+		particle->SetGroupColor("#000000");
 		particle->SetGroupName("Not Identified");
 		return true;
 	}

+ 82 - 14
OTSCPP/OTSLog/COTSUtilityDllFunExport.cpp

@@ -8,7 +8,7 @@
 #include "CLogFile.h"
 
 #define LOGINFO_SWITCH
-
+static PostLogMsg postlog;
 std::string  getFormattedStr( const char *strFormat, va_list arglist)
 {
 	CString str;
@@ -45,7 +45,7 @@ void  InitLogFile(LPCTSTR lpLogName)
 			CString csLogPath = GetLogPathName();
 			if (!Exists(csLogPath))
 			{
-				csLogPath = ".\\Log\\SysMgrApp";
+				csLogPath = ".\\Log";
 				csLogPath += lpLogName;
 				g_LpLogFile = new class CCLogFile(csLogPath);
 			}
@@ -66,48 +66,59 @@ void  InitLogFile(LPCTSTR lpLogName)
 
 void  LogTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...)
 {
-	if (NULL == g_LpLogFile)
+	/*if (NULL == g_LpLogFile)
 	{
 		InitLogFile(g_csLogName);
-	}
+	}*/
 	std::string strLog;
 	va_list arglist;
 	va_start(arglist, lpTraceLog);
 	strLog = getFormattedStr( lpTraceLog, arglist);
 	va_end(arglist);
-
+	
 
 	LPCTSTR szFileName = ::PathFindFileName(szFile);
 
-	g_LpLogFile->TraceProgress(szFileName, lLine, (LPCSTR)strLog.c_str());
+	
+    CString str;
+	str.Format("%s(%ld) ", szFileName, lLine);
+	str.Append((LPCTSTR)strLog.c_str());
+    SendLogMessageToNlog(str, (int)PostLogLevel::info);
+
+	//g_LpLogFile->TraceProgress(szFileName, lLine, (LPCSTR)strLog.c_str());
 }
 
 void  LogInfoTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...)
 {
 #ifdef LOGINFO_SWITCH
-	if (NULL == g_LpLogFile)
+	/*if (NULL == g_LpLogFile)
 	{
 		InitLogFile(g_csLogName);
-	}
+	}*/
 	std::string strLog;
 	va_list arglist;
 	va_start(arglist, lpTraceLog);
 	strLog = getFormattedStr( lpTraceLog, arglist);
 	va_end(arglist);
-
+	SendLogMessageToNlog((LPCSTR)strLog.c_str(), (int)PostLogLevel::info);
 	LPCTSTR szFileName = ::PathFindFileName(szFile);
 
+	CString str;
+	str.Format("%s(%ld) ", szFileName, lLine);
+	str.Append((LPCTSTR)strLog.c_str());
+
+	SendLogMessageToNlog(str, (int)PostLogLevel::info);
 
-	g_LpLogFile->TraceProgress(szFileName, lLine, (LPCSTR)strLog.c_str());
+	//g_LpLogFile->TraceProgress(szFileName, lLine, (LPCSTR)strLog.c_str());
 #endif
 }
 
 void  LogErrorTrace(LPCTSTR szFile, long lLine, LPCTSTR lpErrorTrace, ...)
 {
-	if (NULL == g_LpLogFile)
+	/*if (NULL == g_LpLogFile)
 	{
 		InitLogFile(g_csLogName);
-	}
+	}*/
 	std::string strLog;
 	va_list arglist;
 	va_start(arglist, lpErrorTrace);
@@ -117,8 +128,12 @@ void  LogErrorTrace(LPCTSTR szFile, long lLine, LPCTSTR lpErrorTrace, ...)
 
 	LPCTSTR szFileName = ::PathFindFileName(szFile);
 
+	CString str;
+	str.Format("%s(%ld) ", szFileName, lLine);
+	str.Append((LPCTSTR)strLog.c_str());
 
-	g_LpLogFile->TraceError(szFileName, lLine, (LPCSTR)strLog.c_str());
+	SendLogMessageToNlog(str, (int)PostLogLevel::error);
+	//g_LpLogFile->TraceError(szFileName, lLine, (LPCSTR)strLog.c_str());
 }
 
 void  LogBinaryTrace(LPCTSTR szHead, BYTE * pbyData, UINT nLen)
@@ -149,9 +164,62 @@ void  EndLogFile()
 		delete g_LpLogFile;
 		g_LpLogFile = NULL;
 	}
-
+	
 	
 }
+bool SendLogMessageToNlog(LPCTSTR Msg, int postLogLevel)
+{
 
+	static HWND m_hWnd;
+	if (m_hWnd == NULL)
+	{
+		HWND hd = GetDesktopWindow();        //得到桌面窗口
+		     hd = GetWindow(hd, GW_CHILD);        //得到屏幕上第一个子窗口
+		     char s[200] = { 0 };
+		     int num = 1;
+		     while (hd != NULL)                    //循环得到所有的子窗口
+		     {
+		       memset(s, 0, 200);
+		       GetWindowText(hd, s, 200);
+			   CString winTxt(s);
+			   if (winTxt.Find(_T("OTSMeasureApp"))>-1)
+			   {
+				   m_hWnd = hd;
+				   break;
+			   }
+		       hd = GetNextWindow(hd, GW_HWNDNEXT);
+		     }
+
+	}
+
+
+	//HWND m_hWnd = ::FindWindow(NULL, _T("样品测量程序(Inclusion)"));
+
+	if (NULL == m_hWnd)
+	{
+		LogErrorTrace(__FILE__, __LINE__, _T("(PostMessageToMeasureApp) FindWindow(NULL, m_MAppFormName=%s) failed"), "Log");
+		return false;
+	}
+	CString msg = Msg;
+	/*PostLogMsg postlog;*/
+	memset(&postlog, 0, sizeof(PostLogMsg));
+	postlog.logLevel = postLogLevel;
+	int l = msg.GetLength();
+
+	if (l > 200)
+	{
+		l = 200;
+	}
+	for (int i = 0; i < l; i++)
+	{
+		postlog.logMsg[i] = msg.GetAt(i);
+	}
+
+
+	::SendMessage(m_hWnd, 0x400+101, 0, (LPARAM)&postlog);
+
+	return true;
+
+}
 
 

+ 17 - 0
OTSCPP/OTSLog/COTSUtilityDllFunExport.h

@@ -1,7 +1,23 @@
 #pragma once
 #include <wtypes.h>
+ struct PostLogMsg
+{
+	int logLevel;
+	char logMsg[200];
 
 
+};
+ enum PostLogLevel
+{
+	trace = 1,
+	debug = 2,
+	info = 3,
+	warn = 4,
+	error = 5,
+	fatal = 6
+
+};
+
 extern "C" __declspec(dllexport) void InitLogFile(LPCTSTR lpLogName);     // 由APP加载DLL成功后设置路径,设置Log文件保存的路径,如 "C:\\OPTON\\APP"      (APP为保存的log名字
 extern "C" __declspec(dllexport) void LogTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...);       //记录日志
 extern "C" __declspec(dllexport) void LogInfoTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...);       //记录日志
@@ -9,4 +25,5 @@ extern "C" __declspec(dllexport) void LogErrorTrace(LPCTSTR szFile, long lLine,
 extern "C"  __declspec(dllexport) void LogBinaryTrace(LPCTSTR szHead, BYTE* pbyData, UINT nLen);  //记录二进制数据 日志
 extern "C"  __declspec(dllexport) void WaitingTime(int iMilliseconds);                    //等待 iMilliseconds ms
 extern "C"  __declspec(dllexport) void EndLogFile();      //释放DLL  
+extern "C"  __declspec(dllexport) bool SendLogMessageToNlog(LPCTSTR Msg, int postLogLevel);
 

+ 7 - 7
OTSIncAMeasureApp/0-OTSModel/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -280,7 +280,7 @@ namespace OTSModelSharp
             }
             catch (Exception e)
             {
-                log.Info(" classify failed. " + e.Message);
+                log.Info("merged parts classify failed. " + e.Message);
             }
 
         }
@@ -299,13 +299,13 @@ namespace OTSModelSharp
                     engine.Classify(particle);
                 }
 
-                    if (particle.GetType() ==(int) OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
-                    {
-                        IClassifyEngine engine;
-                        engine = m_classifyEngine.GetIncClassifyEngine();
-                        engine.ClassifyIncA(particle, steelTech);
+                if (particle.GetType() ==(int) OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
+                {
+                    IClassifyEngine engine;
+                    engine = m_classifyEngine.GetIncClassifyEngine();
+                    engine.ClassifyIncA(particle, steelTech);
 
-                    }
+                }
 
             }
             else            

+ 0 - 1
OTSIncAMeasureApp/9-OTSRibbon/OTSRibbonFun.cs

@@ -127,7 +127,6 @@ namespace OTSMeasureApp
         {
             m_MeasureAppForm.rbPanelSample.Enabled = bRibStstu;
             m_MeasureAppForm.rbPanelFunction.Enabled = bRibStstu;
-            //    m_MeasureAppForm.rbMenu.Tabs[0].Panels[0].Items[0] = true;
             m_MeasureAppForm.rbMenu.Tabs[0].Panels[0].Enabled = bRibStstu;    //Menu中的基本功能中的文件  rbMenu.Tabs[0]=基本功能; rbMenu.Tabs[0].Panels[0]=文件
             m_MeasureAppForm.rbMenu.Tabs[1].Panels[0].Enabled = bRibStstu;    //Menu中的视图功能中的视图  rbMenu.Tabs[1]=视图功能; rbMenu.Tabs[1].Panels[0]=视图
                                                                           //     m_MeasureAppForm.rbNew.Enabled = false;

+ 23 - 23
OTSIncAMeasureApp/OTSIncAMeasureAppForm.Designer.cs

@@ -60,6 +60,7 @@
             this.rbAbout = new System.Windows.Forms.RibbonOrbMenuItem();
             this.rbExitApp = new System.Windows.Forms.RibbonOrbMenuItem();
             this.rbSelectDlg = new System.Windows.Forms.RibbonOrbOptionButton();
+            this.ribbonOrbRecentItem1 = new System.Windows.Forms.RibbonOrbRecentItem();
             this.rbTabHome = new System.Windows.Forms.RibbonTab();
             this.rbPanelFile = new System.Windows.Forms.RibbonPanel();
             this.rbPanelSample = new System.Windows.Forms.RibbonPanel();
@@ -95,7 +96,6 @@
             this.dockPanel = new OTS.WinFormsUI.Docking.DockPanel();
             this.ribbonButton3 = new System.Windows.Forms.RibbonButton();
             this.ribbonButton1 = new System.Windows.Forms.RibbonButton();
-            this.ribbonOrbRecentItem1 = new System.Windows.Forms.RibbonOrbRecentItem();
             this.statusStrip1.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -354,6 +354,21 @@
             this.rbSelectDlg.ToolTipTitle = null;
             this.rbSelectDlg.Click += new System.EventHandler(this.rbSelectDlg_Click);
             // 
+            // ribbonOrbRecentItem1
+            // 
+            this.ribbonOrbRecentItem1.AltKey = null;
+            this.ribbonOrbRecentItem1.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
+            this.ribbonOrbRecentItem1.DropDownArrowSize = new System.Drawing.Size(5, 3);
+            this.ribbonOrbRecentItem1.Image = ((System.Drawing.Image)(resources.GetObject("ribbonOrbRecentItem1.Image")));
+            this.ribbonOrbRecentItem1.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribbonOrbRecentItem1.SmallImage")));
+            this.ribbonOrbRecentItem1.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
+            this.ribbonOrbRecentItem1.Tag = null;
+            this.ribbonOrbRecentItem1.Text = "特殊颗粒识别设置";
+            this.ribbonOrbRecentItem1.ToolTip = null;
+            this.ribbonOrbRecentItem1.ToolTipImage = null;
+            this.ribbonOrbRecentItem1.ToolTipTitle = null;
+            this.ribbonOrbRecentItem1.Click += new System.EventHandler(this.ribbonOrbRecentItem1_Click);
+            // 
             // rbTabHome
             // 
             this.rbTabHome.Panels.Add(this.rbPanelFile);
@@ -739,11 +754,11 @@
             this.TSGrayVal,
             this.STSemCoordinate,
             this.toolStripStatusLabel1});
-            this.statusStrip1.Location = new System.Drawing.Point(0, 1010);
+            this.statusStrip1.Location = new System.Drawing.Point(0, 671);
             this.statusStrip1.Name = "statusStrip1";
             this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 14, 0);
             this.statusStrip1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
-            this.statusStrip1.Size = new System.Drawing.Size(1924, 35);
+            this.statusStrip1.Size = new System.Drawing.Size(1277, 26);
             this.statusStrip1.TabIndex = 2;
             this.statusStrip1.Text = "statusStrip1";
             // 
@@ -751,20 +766,20 @@
             // 
             this.TSGrayVal.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
             this.TSGrayVal.Name = "TSGrayVal";
-            this.TSGrayVal.Size = new System.Drawing.Size(68, 28);
+            this.TSGrayVal.Size = new System.Drawing.Size(48, 21);
             this.TSGrayVal.Text = "灰度值";
             // 
             // STSemCoordinate
             // 
             this.STSemCoordinate.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
             this.STSemCoordinate.Name = "STSemCoordinate";
-            this.STSemCoordinate.Size = new System.Drawing.Size(88, 28);
+            this.STSemCoordinate.Size = new System.Drawing.Size(62, 21);
             this.STSemCoordinate.Text = "SEM坐标";
             // 
             // toolStripStatusLabel1
             // 
             this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
-            this.toolStripStatusLabel1.Size = new System.Drawing.Size(77, 28);
+            this.toolStripStatusLabel1.Size = new System.Drawing.Size(54, 21);
             this.toolStripStatusLabel1.Text = "IsReady";
             this.toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
             this.toolStripStatusLabel1.Visible = false;
@@ -781,7 +796,7 @@
             this.dockPanel.Location = new System.Drawing.Point(0, 130);
             this.dockPanel.Margin = new System.Windows.Forms.Padding(6);
             this.dockPanel.Name = "dockPanel";
-            this.dockPanel.Size = new System.Drawing.Size(1924, 880);
+            this.dockPanel.Size = new System.Drawing.Size(1277, 541);
             dockPanelGradient1.EndColor = System.Drawing.SystemColors.ControlLight;
             dockPanelGradient1.StartColor = System.Drawing.SystemColors.ControlLight;
             autoHideStripSkin1.DockStripGradient = dockPanelGradient1;
@@ -858,21 +873,6 @@
             // 
             // OTSIncAMeasureAppForm
             // 
-            this.ribbonOrbRecentItem1.AltKey = null;
-            this.ribbonOrbRecentItem1.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
-            this.ribbonOrbRecentItem1.DropDownArrowSize = new System.Drawing.Size(5, 3);
-            this.ribbonOrbRecentItem1.Image = ((System.Drawing.Image)(resources.GetObject("ribbonOrbRecentItem1.Image")));
-            this.ribbonOrbRecentItem1.SmallImage = ((System.Drawing.Image)(resources.GetObject("ribbonOrbRecentItem1.SmallImage")));
-            this.ribbonOrbRecentItem1.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
-            this.ribbonOrbRecentItem1.Tag = null;
-            this.ribbonOrbRecentItem1.Text = "特殊颗粒识别设置";
-            this.ribbonOrbRecentItem1.ToolTip = null;
-            this.ribbonOrbRecentItem1.ToolTipImage = null;
-            this.ribbonOrbRecentItem1.ToolTipTitle = null;
-            this.ribbonOrbRecentItem1.Click += new System.EventHandler(this.ribbonOrbRecentItem1_Click);
-            // 
-            // OTSIncAMeasureAppForm
-            // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1277, 697);
@@ -887,7 +887,7 @@
             this.MinimumSize = new System.Drawing.Size(682, 509);
             this.Name = "OTSIncAMeasureAppForm";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
-            this.Text = "样品测量程序";
+            this.Text = "OTSMeasureApp";
             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OTSIncAMeasureAppForm_FormClosing);
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OTSIncAMeasureAppForm_FormClosed);

+ 79 - 5
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -61,8 +61,10 @@ namespace OTSMeasureApp
 
         // 初始化日志类
         NLog.Logger log ;
-      
 
+        private PostLogMsg m_LogMsg;
+        public const int MsgID = 0x0464;
+        public const int LogMsgID = 0x0465;
 
 
         //  Control m_ControlWindow = null;
@@ -108,10 +110,6 @@ namespace OTSMeasureApp
            
 
 
-            //初始化日志文件名称       
-       
-
-
             // 初始化Docpanle
             m_SolutionWindows = new OTSSolutionWindow(this);
             m_SPropertyWindows = new OTSPropertyWindow(this);
@@ -1251,5 +1249,81 @@ namespace OTSMeasureApp
             System.Diagnostics.Process.Start("notepad.exe", CSpecialGrayRangeParam.GetParamFileFullName());
           
         }
+        protected override void DefWndProc(ref Message m)
+        {
+            switch (m.Msg)
+            {
+                case MsgID:
+
+                    //MSTMsg = new STMrsSampleRetThreadMsg();
+                    //MSTMsg.STMThreadStu.cMsrStartTime = new char[(int)MEMORY_SIZE.TIME_SIZE];
+                    //MSTMsg.STMThreadStu.cMsrEndTime = new char[(int)MEMORY_SIZE.TIME_SIZE];
+                    //MSTMsg.STMSampleRetData.BSEData.FieldPos = new Point();
+                    //MSTMsg.STMSampleRetData.SFieldata.FieldPos = new Point();
+                    //MSTMsg.STMSampleRetData.StartMsrField.FieldPos = new Point();
+                    //MSTMsg.STMSampleStu.cMsrSName = new char[(int)MEMORY_SIZE.SAMPLE_NAME_SIZE];
+                    //MSTMsg = (STMrsSampleRetThreadMsg)Marshal.PtrToStructure(m.LParam, typeof(STMrsSampleRetThreadMsg));
+                    ////以下为实时接收图片数据,因为图片传出来的只是指针,所以必须立即接收,否则指针指向的数据就会被析构。
+                    //Byte[] bBSEData;
+                    //int iHeight, iWidth;
+                    //iHeight = MSTMsg.STMSampleRetData.BSEData.iBSEDataHeight;
+                    //iWidth = MSTMsg.STMSampleRetData.BSEData.iBSEDataWidth;
+                    //if (iHeight > 0 && iWidth > 0)
+                    //{
+                    //    bBSEData = new Byte[iHeight * iWidth];
+                    //    Marshal.Copy(MSTMsg.STMSampleRetData.BSEData.pData, bBSEData, 0, iHeight * iWidth);
+                    //    MSTMsg.gbseData = bBSEData;
+
+                    //}
+
+                    ////申请
+                    //shareRes.mutex.WaitOne();
+                    //m_MSTMsg.Add(MSTMsg);
+
+                    //  释放
+                    //shareRes.mutex.ReleaseMutex();
+                    break;
+                case LogMsgID:
+                    m_LogMsg = new PostLogMsg();
+
+                    m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
+                    var log = NLog.LogManager.GetCurrentClassLogger();
+                    string s = GetString(m_LogMsg.logMessage);
+                    switch (m_LogMsg.logLevel)
+                    {
+                        case 1:
+                            log.Trace(s);
+                            break;
+                        case 2:
+                            log.Debug(s);
+                            break;
+                        case 3:
+                            log.Info(s);
+                            break;
+                        case 4:
+                            log.Warn(s);
+                            break;
+                        case 5:
+                            log.Error(s);
+                            break;
+                        case 6:
+                            log.Fatal(s);
+                            break;
+                    }
+
+                    break;
+                default:
+                    base.DefWndProc(ref m);
+                    break;
+            }
+        }
+        private string GetString(char[] csStr)
+        {
+            int ilen = csStr.Length;
+            string csName = new string(csStr);                //MSTMsg.STMSampleStu.cSName
+            csName.IndexOf('\0');
+            csName = csName.Substring(0, csName.IndexOf('\0'));
+            return csName;
+        }
     }
 }

+ 8 - 10
OTSIncAMeasureApp/OTSIncAMeasureAppForm.resx

@@ -154,21 +154,19 @@
         JQAAFiUBSVIk8AAAABNJREFUOE9jGAWjYBSMAjBgYAAABBAAAadEfGMAAAAASUVORK5CYII=
 </value>
   </data>
-
   <data name="ribbonOrbRecentItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
-        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAaSURBVFhH7cEBAQAAAIIg/69uSEAAAADAuRoQIAABnXhJ
-        QwAAAABJRU5ErkJggg==
-    </value>
+        iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+        wwAADsMBx2+oZAAAABpJREFUWEftwQEBAAAAgiD/r25IQAAAAMC5GhAgAAGdeElDAAAAAElFTkSuQmCC
+</value>
   </data>
   <data name="ribbonOrbRecentItem1.SmallImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
-        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAATSURBVDhPYxgFo2AUjAIwYGAAAAQQAAGnRHxjAAAAAElF
-        TkSuQmCC
-    </value>
-  </data>  <data name="rbCircleCenter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+        wwAADsMBx2+oZAAAABNJREFUOE9jGAWjYBSMAjBgYAAABBAAAadEfGMAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="rbCircleCenter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAW
         JQAAFiUBSVIk8AAAABpJREFUWEftwQEBAAAAgiD/r25IQAAAAMC5GhAgAAGdeElDAAAAAElFTkSuQmCC

+ 1 - 1
OTSIncAMeasureApp/OTSMeasureOutputNlog.cs

@@ -14,7 +14,7 @@ namespace OTSMeasureApp
     public struct PostLogMsg
     {
         public int logLevel;//1 trace 2 debug 3info 4 warn 5 error 6 fatal
-        [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)100)]
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)200)]
         public char[] logMessage;
     };
   

+ 13 - 13
OTSIncAReportApp/1-UI/frmReportApp.Designer.cs

@@ -183,7 +183,7 @@
             // 
             this.ribbon1.Font = new System.Drawing.Font("微软雅黑", 9F);
             this.ribbon1.Location = new System.Drawing.Point(0, 0);
-            this.ribbon1.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
+            this.ribbon1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.ribbon1.Minimized = false;
             this.ribbon1.Name = "ribbon1";
             // 
@@ -209,7 +209,7 @@
             this.ribbon1.QuickAcessToolbar.ToolTip = null;
             this.ribbon1.QuickAcessToolbar.ToolTipImage = null;
             this.ribbon1.QuickAcessToolbar.ToolTipTitle = null;
-            this.ribbon1.Size = new System.Drawing.Size(1701, 130);
+            this.ribbon1.Size = new System.Drawing.Size(1276, 130);
             this.ribbon1.TabIndex = 0;
             this.ribbon1.Tabs.Add(this.ribbonTab1);
             this.ribbon1.Tabs.Add(this.rbMenu);
@@ -518,11 +518,11 @@
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.RSGrayVal,
             this.mouseMatter});
-            this.statusStrip1.Location = new System.Drawing.Point(0, 835);
+            this.statusStrip1.Location = new System.Drawing.Point(0, 666);
             this.statusStrip1.Name = "statusStrip1";
-            this.statusStrip1.Padding = new System.Windows.Forms.Padding(12, 0, 2, 0);
+            this.statusStrip1.Padding = new System.Windows.Forms.Padding(9, 0, 2, 0);
             this.statusStrip1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
-            this.statusStrip1.Size = new System.Drawing.Size(1701, 30);
+            this.statusStrip1.Size = new System.Drawing.Size(1276, 26);
             this.statusStrip1.TabIndex = 4;
             this.statusStrip1.Text = "statusStrip1";
             // 
@@ -530,14 +530,14 @@
             // 
             this.RSGrayVal.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
             this.RSGrayVal.Name = "RSGrayVal";
-            this.RSGrayVal.Size = new System.Drawing.Size(58, 24);
+            this.RSGrayVal.Size = new System.Drawing.Size(48, 21);
             this.RSGrayVal.Text = "灰度值";
             // 
             // mouseMatter
             // 
             this.mouseMatter.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
             this.mouseMatter.Name = "mouseMatter";
-            this.mouseMatter.Size = new System.Drawing.Size(103, 24);
+            this.mouseMatter.Size = new System.Drawing.Size(84, 21);
             this.mouseMatter.Text = "鼠标点的物质";
             // 
             // DockWindowPanel
@@ -546,9 +546,9 @@
             this.DockWindowPanel.Dock = System.Windows.Forms.DockStyle.Fill;
             this.DockWindowPanel.DockBackColor = System.Drawing.SystemColors.Control;
             this.DockWindowPanel.Location = new System.Drawing.Point(0, 130);
-            this.DockWindowPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.DockWindowPanel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.DockWindowPanel.Name = "DockWindowPanel";
-            this.DockWindowPanel.Size = new System.Drawing.Size(1701, 705);
+            this.DockWindowPanel.Size = new System.Drawing.Size(1276, 536);
             dockPanelGradient1.EndColor = System.Drawing.SystemColors.ControlLight;
             dockPanelGradient1.StartColor = System.Drawing.SystemColors.ControlLight;
             autoHideStripSkin1.DockStripGradient = dockPanelGradient1;
@@ -639,17 +639,17 @@
             // 
             // frmReportApp
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1701, 865);
+            this.ClientSize = new System.Drawing.Size(1276, 692);
             this.Controls.Add(this.DockWindowPanel);
             this.Controls.Add(this.statusStrip1);
             this.Controls.Add(this.ribbon1);
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.IsMdiContainer = true;
-            this.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
+            this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.Name = "frmReportApp";
-            this.Text = "报告程序";
+            this.Text = "OTSReportApp";
             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmReportApp_FormClosing);
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmReportApp_FormClosed);