parent
							
								
									f17a8ae83e
								
							
						
					
					
						commit
						a151bd378b
					
				|  | @ -822,7 +822,6 @@ namespace ITC81DB_0H.Controls | |||
|                 switch (temp) | ||||
|                 { | ||||
|                     case Define.E_MenuBottomConfiguration.SerialCOM1: | ||||
|                         this.ParentForm.ParentForm.CloseSerialCOM1(); | ||||
|                         this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged); | ||||
|                         this.comboBoxSerialBaudRate.SelectedIndex = 4; | ||||
|                         this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged); | ||||
|  |  | |||
|  | @ -25,6 +25,9 @@ namespace ITC81DB_0H | |||
|     #region CommunicationCommand | ||||
|     public class CommunicationCommand | ||||
|     { | ||||
|         // 운전데이터 Respone | ||||
|         public static readonly string StartDataCMD = "Sr0"; | ||||
| 
 | ||||
|         // 불량알람(레벨) | ||||
|         public static readonly string AlarmNgLevel = "Caa00"; | ||||
|         // 불량알람 해지 | ||||
|  | @ -1554,6 +1557,60 @@ namespace ITC81DB_0H | |||
|     } | ||||
|     #endregion | ||||
| 
 | ||||
|     #region CommunicationRespone | ||||
|     public class CommunicationRespone | ||||
|     { | ||||
|         #region Field | ||||
|         private bool m_IsFirst; | ||||
| 
 | ||||
|         private string m_TransactionID; | ||||
|         private string m_TransferCount; | ||||
|         #endregion | ||||
| 
 | ||||
|         #region Constructor | ||||
|         public CommunicationRespone() | ||||
|         { | ||||
|             this.Initialization(); | ||||
|         } | ||||
|         #endregion | ||||
| 
 | ||||
|         #region Property | ||||
|         public bool IsFirst | ||||
|         { | ||||
|             get { return this.m_IsFirst; } | ||||
|             set { this.m_IsFirst = value; } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Data ID (0~9) | ||||
|         /// </summary> | ||||
|         public string TransactionID | ||||
|         { | ||||
|             get { return this.m_TransactionID; } | ||||
|             set { this.m_TransactionID = value; } | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 재전송 CNT (0~9) | ||||
|         /// </summary> | ||||
|         public string TransferCount | ||||
|         { | ||||
|             get { return this.m_TransferCount; } | ||||
|             set { this.m_TransferCount = value; } | ||||
|         } | ||||
|         #endregion | ||||
| 
 | ||||
|         #region Method | ||||
|         public void Initialization() | ||||
|         { | ||||
|             this.IsFirst = false; | ||||
| 
 | ||||
|             this.TransactionID = "a"; | ||||
|             this.TransferCount = "a"; | ||||
|         } | ||||
|         #endregion | ||||
|     } | ||||
|     #endregion | ||||
| 
 | ||||
|     public class AlarmList | ||||
|     { | ||||
|         #region Field | ||||
|  |  | |||
|  | @ -46,6 +46,8 @@ | |||
|             this.timerEthernetPing = new System.Windows.Forms.Timer(); | ||||
|             this.smartTimerLogout = new SmartX.SmartTimer(this.components); | ||||
|             this.timerUserList = new System.Windows.Forms.Timer(); | ||||
|             this.smartThreadSerialPort2OverRun = new SmartX.SmartThread(this.components); | ||||
|             this.smartThreadSerialPort2Read = new SmartX.SmartThread(this.components); | ||||
|             ((System.ComponentModel.ISupportInitialize)(this.smartForm)).BeginInit(); | ||||
|             this.SuspendLayout(); | ||||
|             //  | ||||
|  | @ -95,6 +97,7 @@ | |||
|             this.smartSerialPort2.STXCodes = null; | ||||
|             this.smartSerialPort2.TailErrorCodeOffset = 0; | ||||
|             this.smartSerialPort2.OnReadQueueEvent += new SmartX.SmartSerialPort.ReceiveDataHandler(this.smartSerialPort2_OnReadQueueEvent); | ||||
|             this.smartSerialPort2.OnPortError += new SmartX.SmartSerialPort.PortErrorHandler(this.smartSerialSerialPort2_OnPortError); | ||||
|             //  | ||||
|             // smartSerialPort1 | ||||
|             //  | ||||
|  | @ -209,6 +212,16 @@ | |||
|             this.timerUserList.Interval = 1000; | ||||
|             this.timerUserList.Tick += new System.EventHandler(this.timerUserList_Tick); | ||||
|             //  | ||||
|             // smartThreadSerialPort2OverRun | ||||
|             //  | ||||
|             this.smartThreadSerialPort2OverRun.Priority = System.Threading.ThreadPriority.Normal; | ||||
|             this.smartThreadSerialPort2OverRun.UIThreadFunction += new SmartX.SmartThread.UIThreadHandler(this.smartThreadSerialPort2Read_UIThreadFunction); | ||||
|             //  | ||||
|             // smartThreadSerialPort2Read | ||||
|             //  | ||||
|             this.smartThreadSerialPort2Read.Priority = System.Threading.ThreadPriority.Normal; | ||||
|             this.smartThreadSerialPort2Read.UIThreadFunction += new SmartX.SmartThread.UIThreadHandler(this.smartThreadSerialPort2Read_UIThreadFunction); | ||||
|             //  | ||||
|             // FormMain | ||||
|             //  | ||||
|             this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); | ||||
|  | @ -242,6 +255,8 @@ | |||
|         private System.Windows.Forms.Timer timerEthernetPing; | ||||
|         private SmartX.SmartTimer smartTimerLogout; | ||||
|         private System.Windows.Forms.Timer timerUserList; | ||||
|         private SmartX.SmartThread smartThreadSerialPort2OverRun; | ||||
|         private SmartX.SmartThread smartThreadSerialPort2Read; | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  |  | |||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								|  | @ -165,6 +165,12 @@ | |||
|   <metadata name="timerUserList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||||
|     <value>710, 57</value> | ||||
|   </metadata> | ||||
|   <metadata name="smartThreadSerialPort2OverRun.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||||
|     <value>34, 95</value> | ||||
|   </metadata> | ||||
|   <metadata name="smartThreadSerialPort2Read.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||||
|     <value>264, 95</value> | ||||
|   </metadata> | ||||
|   <metadata name="$this.FormFactorShadowProperty" xml:space="preserve"> | ||||
|     <value>WEBPAD</value> | ||||
|   </metadata> | ||||
|  | @ -172,6 +178,6 @@ | |||
|     <value>False</value> | ||||
|   </metadata> | ||||
|   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||||
|     <value>92</value> | ||||
|     <value>118</value> | ||||
|   </metadata> | ||||
| </root> | ||||
|  | @ -66,6 +66,9 @@ | |||
|             this.labelUserID = new SmartX.SmartLabel(); | ||||
|             this.labelUserLevel = new SmartX.SmartLabel(); | ||||
|             this.labelAlarmWindow = new SmartX.SmartLabel(); | ||||
|             this.labelMissingCount = new SmartX.SmartLabel(); | ||||
|             this.labelBufferCNT = new SmartX.SmartLabel(); | ||||
|             this.labelOverrun = new SmartX.SmartLabel(); | ||||
|             ((System.ComponentModel.ISupportInitialize)(this.smartForm1)).BeginInit(); | ||||
|             this.panel1.SuspendLayout(); | ||||
|             this.SuspendLayout(); | ||||
|  | @ -118,7 +121,7 @@ | |||
|             //  | ||||
|             // buttonExit | ||||
|             //  | ||||
|             this.buttonExit.Location = new System.Drawing.Point(327, 0); | ||||
|             this.buttonExit.Location = new System.Drawing.Point(726, 457); | ||||
|             this.buttonExit.Name = "buttonExit"; | ||||
|             this.buttonExit.Size = new System.Drawing.Size(56, 20); | ||||
|             this.buttonExit.TabIndex = 4; | ||||
|  | @ -666,18 +669,19 @@ | |||
|             this.labelBarcode.ForeColor = System.Drawing.Color.White; | ||||
|             this.labelBarcode.InitVisible = true; | ||||
|             this.labelBarcode.LineSpacing = 0F; | ||||
|             this.labelBarcode.Location = new System.Drawing.Point(389, 0); | ||||
|             this.labelBarcode.Location = new System.Drawing.Point(79, 26); | ||||
|             this.labelBarcode.Name = "labelBarcode"; | ||||
|             this.labelBarcode.Size = new System.Drawing.Size(132, 20); | ||||
|             this.labelBarcode.Size = new System.Drawing.Size(286, 30); | ||||
|             this.labelBarcode.TabIndex = 547; | ||||
|             this.labelBarcode.Text = "2234567890"; | ||||
|             this.labelBarcode.TextHAlign = SmartX.SmartLabel.TextHorAlign.Left; | ||||
|             this.labelBarcode.TextVAlign = SmartX.SmartLabel.TextVerAlign.Top; | ||||
|             this.labelBarcode.TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; | ||||
|             this.labelBarcode.Visible = false; | ||||
|             this.labelBarcode.Wordwrap = false; | ||||
|             //  | ||||
|             // buttonMemory | ||||
|             //  | ||||
|             this.buttonMemory.Location = new System.Drawing.Point(265, 0); | ||||
|             this.buttonMemory.Location = new System.Drawing.Point(726, 431); | ||||
|             this.buttonMemory.Name = "buttonMemory"; | ||||
|             this.buttonMemory.Size = new System.Drawing.Size(56, 20); | ||||
|             this.buttonMemory.TabIndex = 547; | ||||
|  | @ -864,12 +868,78 @@ | |||
|             this.labelAlarmWindow.Wordwrap = false; | ||||
|             this.labelAlarmWindow.Click += new System.EventHandler(this.labelAlarmWindow_Click); | ||||
|             //  | ||||
|             // labelMissingCount | ||||
|             //  | ||||
|             this.labelMissingCount.BackColor = System.Drawing.Color.Silver; | ||||
|             this.labelMissingCount.BackPictureBox = this.smartForm1; | ||||
|             this.labelMissingCount.BackPictureBox1 = null; | ||||
|             this.labelMissingCount.BackPictureBox2 = null; | ||||
|             this.labelMissingCount.BorderColor = System.Drawing.Color.Black; | ||||
|             this.labelMissingCount.BorderStyle = System.Windows.Forms.BorderStyle.None; | ||||
|             this.labelMissingCount.ForeColor = System.Drawing.Color.Silver; | ||||
|             this.labelMissingCount.InitVisible = true; | ||||
|             this.labelMissingCount.LineSpacing = 0F; | ||||
|             this.labelMissingCount.Location = new System.Drawing.Point(471, 0); | ||||
|             this.labelMissingCount.Name = "labelMissingCount"; | ||||
|             this.labelMissingCount.Size = new System.Drawing.Size(50, 20); | ||||
|             this.labelMissingCount.TabIndex = 605; | ||||
|             this.labelMissingCount.Text = "0"; | ||||
|             this.labelMissingCount.TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle; | ||||
|             this.labelMissingCount.TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; | ||||
|             this.labelMissingCount.Visible = false; | ||||
|             this.labelMissingCount.Wordwrap = false; | ||||
|             //  | ||||
|             // labelBufferCNT | ||||
|             //  | ||||
|             this.labelBufferCNT.BackColor = System.Drawing.Color.Silver; | ||||
|             this.labelBufferCNT.BackPictureBox = this.smartForm1; | ||||
|             this.labelBufferCNT.BackPictureBox1 = null; | ||||
|             this.labelBufferCNT.BackPictureBox2 = null; | ||||
|             this.labelBufferCNT.BorderColor = System.Drawing.Color.Black; | ||||
|             this.labelBufferCNT.BorderStyle = System.Windows.Forms.BorderStyle.None; | ||||
|             this.labelBufferCNT.ForeColor = System.Drawing.Color.Silver; | ||||
|             this.labelBufferCNT.InitVisible = true; | ||||
|             this.labelBufferCNT.LineSpacing = 0F; | ||||
|             this.labelBufferCNT.Location = new System.Drawing.Point(415, 0); | ||||
|             this.labelBufferCNT.Name = "labelBufferCNT"; | ||||
|             this.labelBufferCNT.Size = new System.Drawing.Size(50, 20); | ||||
|             this.labelBufferCNT.TabIndex = 604; | ||||
|             this.labelBufferCNT.Text = "0"; | ||||
|             this.labelBufferCNT.TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle; | ||||
|             this.labelBufferCNT.TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; | ||||
|             this.labelBufferCNT.Visible = false; | ||||
|             this.labelBufferCNT.Wordwrap = false; | ||||
|             //  | ||||
|             // labelOverrun | ||||
|             //  | ||||
|             this.labelOverrun.BackColor = System.Drawing.Color.Silver; | ||||
|             this.labelOverrun.BackPictureBox = this.smartForm1; | ||||
|             this.labelOverrun.BackPictureBox1 = null; | ||||
|             this.labelOverrun.BackPictureBox2 = null; | ||||
|             this.labelOverrun.BorderColor = System.Drawing.Color.Black; | ||||
|             this.labelOverrun.BorderStyle = System.Windows.Forms.BorderStyle.None; | ||||
|             this.labelOverrun.ForeColor = System.Drawing.Color.Silver; | ||||
|             this.labelOverrun.InitVisible = true; | ||||
|             this.labelOverrun.LineSpacing = 0F; | ||||
|             this.labelOverrun.Location = new System.Drawing.Point(359, 0); | ||||
|             this.labelOverrun.Name = "labelOverrun"; | ||||
|             this.labelOverrun.Size = new System.Drawing.Size(50, 20); | ||||
|             this.labelOverrun.TabIndex = 603; | ||||
|             this.labelOverrun.Text = "0"; | ||||
|             this.labelOverrun.TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle; | ||||
|             this.labelOverrun.TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; | ||||
|             this.labelOverrun.Visible = false; | ||||
|             this.labelOverrun.Wordwrap = false; | ||||
|             //  | ||||
|             // FormMainDisplay | ||||
|             //  | ||||
|             this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); | ||||
|             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; | ||||
|             this.AutoScroll = true; | ||||
|             this.ClientSize = new System.Drawing.Size(800, 600); | ||||
|             this.Controls.Add(this.labelMissingCount); | ||||
|             this.Controls.Add(this.labelBufferCNT); | ||||
|             this.Controls.Add(this.labelOverrun); | ||||
|             this.Controls.Add(this.labelAlarmWindow); | ||||
|             this.Controls.Add(this.labelExpireOfPassword); | ||||
|             this.Controls.Add(this.labelUserID); | ||||
|  | @ -942,5 +1012,8 @@ | |||
|         private SmartX.SmartLabel labelUserID; | ||||
|         private SmartX.SmartLabel labelUserLevel; | ||||
|         private SmartX.SmartLabel labelAlarmWindow; | ||||
|         public SmartX.SmartLabel labelMissingCount; | ||||
|         public SmartX.SmartLabel labelBufferCNT; | ||||
|         public SmartX.SmartLabel labelOverrun; | ||||
|     } | ||||
| } | ||||
|  | @ -248,11 +248,31 @@ namespace ITC81DB_0H.Forms | |||
|         { | ||||
|             if (visible == false) | ||||
|             { | ||||
|                 this.labelBarcode.Visible = false; | ||||
|                 if (this.ParentForm.SystemConfig2.Barcode != 0) | ||||
|                     this.labelBarcode.Visible = false; | ||||
|                 //this.labelComRetry.Visible = false; | ||||
|                 //this.labelComRetry3th.Visible = false; | ||||
|                 this.labelOverrun.Visible = false; | ||||
|                 this.labelBufferCNT.Visible = false; | ||||
|                 this.labelMissingCount.Visible = false; | ||||
| 
 | ||||
|                 //this.labelBARCD.Visible = false; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 this.labelBarcode.Visible = true; | ||||
|                 if (this.ParentForm.SystemConfig2.Barcode != 0) | ||||
|                 { | ||||
|                     this.labelBarcode.Text = ""; | ||||
|                     this.labelBarcode.Visible = true; | ||||
|                 } | ||||
|                 //this.labelComRetry.Visible = true; | ||||
|                 //this.labelComRetry3th.Visible = true; | ||||
|                 this.labelOverrun.Visible = true; | ||||
|                 this.labelBufferCNT.Visible = true; | ||||
|                 this.labelMissingCount.Visible = true; | ||||
| 
 | ||||
|                 //this.labelBARCD.Text = ""; | ||||
|                 //this.labelBARCD.Visible = true; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -386,6 +406,7 @@ namespace ITC81DB_0H.Forms | |||
|         } | ||||
|         public void Clear() | ||||
|         { | ||||
|             this.ParentForm.MissingCommIDCount = 0; | ||||
|             this.ParentForm.ClearQueue(); | ||||
| 
 | ||||
|             this.ClearCurrentData(); | ||||
|  | @ -1018,6 +1039,12 @@ namespace ITC81DB_0H.Forms | |||
|         { | ||||
|             UserManager.UserManager_AutoLogoutTimeoutReset(); | ||||
|         } | ||||
| 
 | ||||
|         public void UpdateDisplayOverRun(string value) | ||||
|         { | ||||
|             this.labelOverrun.Text = value; | ||||
|         } | ||||
| 
 | ||||
|         private bool UI_Invoke(ThreadStart invoker) | ||||
|         { | ||||
|             try | ||||
|  | @ -1802,10 +1829,7 @@ namespace ITC81DB_0H.Forms | |||
|             if (this.ParentForm.SystemConfig3.IsPart11 == true) | ||||
|                 this.Part11AutomaticLogoutReset(); | ||||
| 
 | ||||
|             if (this.ParentForm.SystemConfig1.IsLogin == false) | ||||
|             { | ||||
|                 this.ParentForm.ChildFormMenu.DisplayHiddenMenu(this.ParentForm.CurrentSystemStatus.CurrentDisplay, this.ParentForm.SystemConfig1); | ||||
|             } | ||||
|             this.ParentForm.ChildFormMenu.DisplayHiddenMenu(this.ParentForm.CurrentSystemStatus.CurrentDisplay, this.ParentForm.SystemConfig1); | ||||
|         } | ||||
|         private void buttonMenu_Click(object sender, EventArgs e) | ||||
|         { | ||||
|  | @ -1908,7 +1932,7 @@ namespace ITC81DB_0H.Forms | |||
| 
 | ||||
|         private void buttonExit_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.ParentForm.CloseSmartUartLink(); | ||||
|             this.ParentForm.CloseSmartSerialPort2(); | ||||
|             this.ParentForm.smartFileCommunicationLog.Close(); | ||||
|             this.ParentForm.smartFileCheckLog.Close(); | ||||
|             this.ParentForm.Close(); | ||||
|  |  | |||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								|  | @ -779,6 +779,9 @@ | |||
|       <DependentUpon>Resources.resx</DependentUpon> | ||||
|       <DesignTime>True</DesignTime> | ||||
|     </Compile> | ||||
|     <Compile Include="SerialManager\SerialManager.cs" /> | ||||
|     <Compile Include="SerialManager\SerialManager.Define.cs" /> | ||||
|     <Compile Include="SerialManager\SerialManager.Structure.cs" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Content Include="Version.txt" /> | ||||
|  |  | |||
|  | @ -0,0 +1,69 @@ | |||
| using System; | ||||
| using System.Linq; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel; | ||||
| using System.Data; | ||||
| using System.Drawing; | ||||
| using System.Text; | ||||
| using System.Windows.Forms; | ||||
| using System.Runtime.InteropServices; | ||||
| 
 | ||||
| namespace ITC81DB_0H.SerialManager | ||||
| { | ||||
|     public partial class SerialMgrComm | ||||
|     { | ||||
|         private const string PathDll = "SD Card\\Run\\DllSerialMgr.dll"; | ||||
| 
 | ||||
|         public delegate void fnSerialVersionCB(StringBuilder pVersion); | ||||
|         public static fnSerialVersionCB fnSerialVersionCallback; | ||||
| 
 | ||||
|         public delegate void fnSerialMgrDebugCB(int level, StringBuilder pMessage); | ||||
|         public static fnSerialMgrDebugCB fnSerialMgrDebugCallback; | ||||
| 
 | ||||
|         public delegate void fnSerialMgrPortConnectCB(StringBuilder commPort, int status, int errDetail); | ||||
|         public static fnSerialMgrPortConnectCB fnSerialMgrPortConnectCallback; | ||||
| 
 | ||||
|         public delegate void fnSerialMgrRcvPacketCB(StringBuilder commPort, IntPtr pData, int length); | ||||
|         public static fnSerialMgrRcvPacketCB fnSerialMgrRcvPacketCallback; | ||||
| 
 | ||||
|         public delegate void fnSerialMgrRcvErrPacketCB(StringBuilder commPort, IntPtr pData, int length); | ||||
|         public static fnSerialMgrRcvErrPacketCB fnSerialMgrRcvErrPacketCallback; | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Register_DebugCB(fnSerialMgrDebugCB func); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Register_ConnectCB(fnSerialMgrPortConnectCB func); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Register_VersionCB(fnSerialVersionCB func); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Register_RcvPacketCB(fnSerialMgrRcvPacketCB func); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Register_RcvErrPacketCB(fnSerialMgrRcvErrPacketCB func); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_HelloWorld(); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Getversion(); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Activation(); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern void DLL_SerialMgr_Deactivation(); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern int DLL_SerialMgr_PortOpen(IntPtr commPort, int BaudRate, int StopBit, int Parity, int DataBit); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern int DLL_SerialMgr_PortClose(IntPtr commPort); | ||||
| 
 | ||||
|         [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)] | ||||
|         public static extern int DLL_SerialMgr_PortSendMsg(IntPtr commPort, IntPtr pData, int Length); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,41 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Runtime.InteropServices; | ||||
| using System.Text; | ||||
| using System.Threading; | ||||
| 
 | ||||
| namespace ITC81DB_0H.SerialManager | ||||
| { | ||||
|     public partial class SerialMgrComm | ||||
|     { | ||||
|         //fnSerialMgrDebugCB | ||||
|         public const int SERIALMGR_DBG_NORMAL = 0x0001; | ||||
|         public const int SERIALMGR_DBG_THREAD = 0x0002; | ||||
|         public const int SERIALMGR_DBG_LIST = 0x0004; | ||||
|         public const int SERIALMGR_DBG_PORT = 0x0008; | ||||
| 
 | ||||
| 
 | ||||
|         // fnSerialMgrConnectCB : status | ||||
|         public const int SERIAL_STATUS_DISCONNECT = 0x00; | ||||
|         public const int SERIAL_STATUS_CONNECT = 0x01; | ||||
|         public const int SERIAL_STATUS_ERROR = 0x02; | ||||
| 
 | ||||
|         public const int MAX_COMMPORT_SIZE = 10; | ||||
| 
 | ||||
|         // fnSerialMgrConnectCB : errDetail | ||||
|         public enum serial_error_detail_e | ||||
|         { | ||||
| 	        SERIAL_ERR_NONE	= 0x00,  | ||||
| 	        SERIAL_ERR_CREATE,  | ||||
| 	        SERIAL_ERR_PARAMETER,  | ||||
| 	        SERIAL_ERR_TIMEOUT,  | ||||
| 	        SERIAL_ERR_WRITE, | ||||
| 	        SERIAL_ERR_READ,  | ||||
| 	        SERIAL_ERR_MAX | ||||
|         }; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,274 @@ | |||
| #define CONSOLE_DBUGGING | ||||
| 
 | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Runtime.InteropServices; | ||||
| using System.Text; | ||||
| using System.Threading; | ||||
| using System.Collections; | ||||
| 
 | ||||
| namespace ITC81DB_0H.SerialManager | ||||
| { | ||||
|     public partial class SerialMgrComm | ||||
|     { | ||||
|         public delegate void ObjectEventHandler(object data); | ||||
|         public static event ObjectEventHandler SerialPortMessageReceive; | ||||
|         public static event ObjectEventHandler SerialPortErrMessageReceive; | ||||
| 
 | ||||
|         public static void IntializeSerialManager() | ||||
|         { | ||||
|             //Console.Write("Initialize Serial Manager \n"); | ||||
| 
 | ||||
|             // Register Callback | ||||
|             fnSerialMgrDebugCallback = serialDebugCallback; | ||||
|             DLL_SerialMgr_Register_DebugCB(fnSerialMgrDebugCallback); | ||||
| 
 | ||||
|             fnSerialMgrPortConnectCallback = serialPortConnectCallback; | ||||
|             DLL_SerialMgr_Register_ConnectCB(fnSerialMgrPortConnectCallback); | ||||
| 
 | ||||
|             fnSerialVersionCallback = serialVersionCallback; | ||||
|             DLL_SerialMgr_Register_VersionCB(fnSerialVersionCallback); | ||||
| 
 | ||||
|             fnSerialMgrRcvPacketCallback = serialRcvPacketMsgCallback; | ||||
|             DLL_SerialMgr_Register_RcvPacketCB(fnSerialMgrRcvPacketCallback); | ||||
| 
 | ||||
|             fnSerialMgrRcvErrPacketCallback = serialRcvErrPacketMsgCallback; | ||||
|             DLL_SerialMgr_Register_RcvErrPacketCB(fnSerialMgrRcvErrPacketCallback); | ||||
| 
 | ||||
|             // test | ||||
|             //DLL_SerialMgr_HelloWorld(); | ||||
| 
 | ||||
|             // get the lib version  | ||||
|             DLL_SerialMgr_Getversion(); | ||||
| 
 | ||||
|             // activate the dll thread  | ||||
|             DLL_SerialMgr_Activation(); | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         #region DLL_CALLBACK | ||||
|         private static void serialVersionCallback(StringBuilder versionInfo) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 //Console.Write("\n-------------------------------\n"); | ||||
|                 //Console.Write("lib version = " + versionInfo + "\n"); | ||||
|                 //Console.Write("-------------------------------\n"); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 throw (e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         private static void serialPortConnectCallback(StringBuilder commPort, int status, int errDetail) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 //Console.Write(commPort + ": status = " + status.ToString() +" , detail = " + errDetail.ToString() + "\n"); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 throw (e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         private static void serialDebugCallback(int type, StringBuilder pMessage) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 //Console.Write(pMessage); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 throw (e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // https://stackoverflow.com/questions/22938756/how-to-marshal-c-array-to-c-sharp-via-intptr | ||||
|         public static void serialRcvPacketMsgCallback(StringBuilder commPort, IntPtr pData, int length) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 if (commPort.Length == 0) | ||||
|                     return; | ||||
| 
 | ||||
|                 if ( (pData == IntPtr.Zero) || (length == 0) ) | ||||
|                     return; | ||||
| 
 | ||||
|                 byte[] data = new byte[length]; | ||||
|                 Marshal.Copy(pData, data, 0, (int)length); | ||||
| 
 | ||||
|                 string sdata = Encoding.Default.GetString(data, 0, data.Length); | ||||
| 
 | ||||
|                 if (SerialPortMessageReceive != null) | ||||
|                     SerialPortMessageReceive(sdata); | ||||
| 
 | ||||
| #if TEST_CB | ||||
|                 String commPortStr = commPort.ToString(); | ||||
| 
 | ||||
|                 serialPortMessageByte(commPortStr, data, length); | ||||
| #endif | ||||
|                   | ||||
| 
 | ||||
|                 //Console.Write("comm port : " + commPort + ", length = " + length.ToString() + "\n"); | ||||
| #if TEST_DEBUG | ||||
|                 // https://stackoverflow.com/questions/1342922/console-writeline-as-hexadecimal | ||||
|                 int index = 0; | ||||
|                 foreach (byte temp in data) | ||||
|                 { | ||||
|                     Console.Write(temp.ToString("X2") + " "); | ||||
|                     index++; | ||||
| 
 | ||||
|                     if (index % 16 == 0) Console.Write("\n"); | ||||
|                 } | ||||
| 
 | ||||
|                 Console.Write("\n"); | ||||
| #endif | ||||
| 
 | ||||
|                 //data = null; | ||||
| 
 | ||||
|                 //GC.Collect(); | ||||
|                 //GC.WaitForPendingFinalizers(); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 throw (e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public static void serialRcvErrPacketMsgCallback(StringBuilder commPort, IntPtr pData, int length) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 if (commPort.Length == 0) | ||||
|                     return; | ||||
| 
 | ||||
|                 if ((pData == IntPtr.Zero) || (length == 0)) | ||||
|                     return; | ||||
| 
 | ||||
|                 byte[] data = new byte[length]; | ||||
|                 Marshal.Copy(pData, data, 0, (int)length); | ||||
| 
 | ||||
|                 string sdata = Encoding.Default.GetString(data, 0, data.Length); | ||||
| 
 | ||||
|                 if (SerialPortErrMessageReceive != null) | ||||
|                     SerialPortErrMessageReceive(sdata); | ||||
| 
 | ||||
|                 //String commPortStr = commPort.ToString(); | ||||
|                 //serialPortMessageByte(commPortStr, data, length); | ||||
| 
 | ||||
|                 //Console.Write("Err : comm port : " + commPort + ", length = " + length.ToString() + "\n"); | ||||
| 
 | ||||
| #if (TEST_DEBUG1) | ||||
|                 // https://stackoverflow.com/questions/1342922/console-writeline-as-hexadecimal | ||||
|                 int index = 0; | ||||
|                 foreach (byte temp in data) | ||||
|                 { | ||||
|                     Console.Write(temp.ToString("X2") + " "); | ||||
|                     index++; | ||||
| 
 | ||||
|                     if (index == 5) break; | ||||
| 
 | ||||
|                     if (index % 16 == 0) Console.Write("\n"); | ||||
|                 } | ||||
| 
 | ||||
|                 Console.Write("\n"); | ||||
| #endif | ||||
| 
 | ||||
|                 // https://dhshin94.tistory.com/135 | ||||
|                 //data = null; | ||||
| 
 | ||||
|                 //GC.Collect(); | ||||
|                 //GC.WaitForPendingFinalizers(); | ||||
| 
 | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 throw (e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         #endregion  // DLL_CALLBACK | ||||
| 
 | ||||
|         #region DLL_COMMAND | ||||
| 
 | ||||
|         public static void serialPortOpen(String commPort, int BaudRate, int stopBit, int parity, int dataBit) | ||||
|         { | ||||
|             IntPtr pCommPort = Marshal.StringToBSTR(commPort.ToString()); | ||||
| 
 | ||||
|             DLL_SerialMgr_PortOpen(pCommPort, BaudRate, stopBit, parity, dataBit); | ||||
|         } | ||||
| 
 | ||||
|         public static void serialPortClose(String commPort) | ||||
|         { | ||||
|             IntPtr pCommPort = Marshal.StringToBSTR(commPort.ToString()); | ||||
| 
 | ||||
|             DLL_SerialMgr_PortClose(pCommPort); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public static void serialPortMessageByte(String commport, byte[] data, int length) | ||||
|         { | ||||
|             IntPtr pCommPort = Marshal.StringToBSTR(commport.ToString()); | ||||
| 
 | ||||
|             IntPtr ptr = Marshal.AllocHGlobal(length); | ||||
|             Marshal.Copy(data, 0, ptr, length); | ||||
| 
 | ||||
|             DLL_SerialMgr_PortSendMsg(pCommPort, ptr, length); | ||||
| 
 | ||||
|             //string sdata = Encoding.Default.GetString(data, 0, data.Length); | ||||
| 
 | ||||
|             Marshal.FreeHGlobal(ptr); | ||||
| 
 | ||||
|           //  if (SerialPortMessageReceive != null) | ||||
|           //      SerialPortMessageReceive(sdata); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         //https://stackoverflow.com/questions/13418795/convert-byte-array-to-structure-in-the-compact-framework | ||||
|         public static void serialPortMessage(String commPort, String Message) | ||||
|         { | ||||
|             IntPtr pCommPort = Marshal.StringToBSTR(commPort.ToString()); | ||||
| 
 | ||||
|             StringBuilder sb = new StringBuilder(); | ||||
|             sb.Append((char)0x02); | ||||
|             sb.Append(Message); | ||||
|             sb.Append((char)0x03); | ||||
| 
 | ||||
|             Message = sb.ToString(); | ||||
| 
 | ||||
|             byte[] buffer = Encoding.ASCII.GetBytes(Message); | ||||
|             int count = Encoding.ASCII.GetByteCount(Message); | ||||
|             //byte[] buffer = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | ||||
|             //int count = 10; | ||||
|              | ||||
|             IntPtr ptr = Marshal.AllocHGlobal(count); | ||||
|             Marshal.Copy(buffer, 0, ptr, count); | ||||
| 
 | ||||
|             DLL_SerialMgr_PortSendMsg(pCommPort, ptr, count); | ||||
| 
 | ||||
|             Marshal.FreeHGlobal(ptr); | ||||
|         } | ||||
| 
 | ||||
|         public static void serialPortMessageRaw(String commPort, String Message) | ||||
|         { | ||||
|             IntPtr pCommPort = Marshal.StringToBSTR(commPort.ToString()); | ||||
| 
 | ||||
|             byte[] buffer = Encoding.ASCII.GetBytes(Message); | ||||
|             int count = Encoding.ASCII.GetByteCount(Message); | ||||
|             //byte[] buffer = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | ||||
|             //int count = 10; | ||||
|              | ||||
|             IntPtr ptr = Marshal.AllocHGlobal(count); | ||||
|             Marshal.Copy(buffer, 0, ptr, count); | ||||
| 
 | ||||
|             DLL_SerialMgr_PortSendMsg(pCommPort, ptr, count); | ||||
| 
 | ||||
|             Marshal.FreeHGlobal(ptr); | ||||
|         } | ||||
|         #endregion  | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -12,6 +12,11 @@ | |||
| 	기본형 컨베어 고정밀센서 계량기 | ||||
| */ | ||||
| 
 | ||||
| @ Ver 3.2.0 by CJY | ||||
| 	- 2023.11.08 | ||||
| 	- Ver 3.1.2 Modify | ||||
| 	- 재전송 기능 추가 | ||||
| 
 | ||||
| @ Ver 3.1.2 by CJY | ||||
| 	- 2023.10.31 | ||||
| 	- Ver 3.1.1 Modify | ||||
|  |  | |||
											
												Binary file not shown.
											
										
									
								
											
												Binary file not shown.
											
										
									
								
											
												Binary file not shown.
											
										
									
								
		Loading…
	
		Reference in New Issue