浏览代码

Excel Data Load 후 자동으로Save 하는 기능 추가.

Debug Tx 출력 인자값 추가.
PYJ 5 年之前
父节点
当前提交
891eb0ead0

二进制
.vs/Jdas_Mbic/v15/.suo


二进制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide


二进制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-shm


二进制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-wal


+ 3 - 3
Jdas_Mbic/Debug.cs

@@ -144,7 +144,7 @@ namespace Jdas_Mbic
144 144
             catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
145 145
 
146 146
         }
147
-        public void Data_Send(byte[] text)
147
+        public void Data_Send(byte[] text,int count)
148 148
         {
149 149
             if (checkBoxSend.Checked == false)
150 150
                 return;
@@ -154,7 +154,7 @@ namespace Jdas_Mbic
154 154
             int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
155 155
             try
156 156
             {
157
-                for (int i = 0; i < text.Length; i++)
157
+                for (int i = 0; i < count; i++)
158 158
                 {
159 159
                     
160 160
                     AppendMessage += text[i].ToString("X2");
@@ -200,7 +200,7 @@ namespace Jdas_Mbic
200 200
         {
201 201
             try
202 202
             {
203
-                this.serial.Serial_DataSend(Encoding.ASCII.GetBytes(textBox_senddata.Text));
203
+                this.serial.Serial_DataSend(Encoding.ASCII.GetBytes(textBox_senddata.Text), textBox_senddata.Text.Length);
204 204
             }
205 205
             catch (System.Exception ex)
206 206
             {

+ 5 - 3
Jdas_Mbic/Func/Serial.cs

@@ -228,12 +228,13 @@ namespace Jdas_Mbic
228 228
                 this.Debug.Show();
229 229
             }
230 230
         }
231
-        public void Serial_DataSend(byte[] data)
231
+#if false
232
+        public void Serial_DataSend(byte[] data,int count)
232 233
         {
233 234
             try
234 235
             {
235 236
                 serialPort.Write(data,0,data.Length);
236
-                this.Debug.Data_Send(data);
237
+                this.Debug.Data_Send(data, count);
237 238
                 main_form.pictureBox_R_TX.Visible = false;
238 239
                 main_form.pictureBox_G_TX.Visible = true;
239 240
             }
@@ -242,12 +243,13 @@ namespace Jdas_Mbic
242 243
                 MessageBox.Show(ex.Message);
243 244
             }
244 245
         }
246
+#endif
245 247
         public void Serial_DataSend(byte[] buffer, int count)
246 248
         {
247 249
             try {
248 250
                 serialPort.Write(buffer, 0, count);
249 251
                 if (this.Debug.Created)
250
-                    this.Debug.Data_Send(buffer);
252
+                    this.Debug.Data_Send(buffer, count);
251 253
 
252 254
                 main_form.Invoke(new BoolSet(main_form.TX_Light_ON));
253 255
                 main_form.TX_RX_Light = true;

+ 31 - 18
Jdas_Mbic/Main.Designer.cs

@@ -33,6 +33,7 @@
33 33
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
34 34
             this.Mbic_Setting = new System.Windows.Forms.TabControl();
35 35
             this.tabPage_Main = new System.Windows.Forms.TabPage();
36
+            this.button_Test = new System.Windows.Forms.Button();
36 37
             this.button_Reset = new System.Windows.Forms.Button();
37 38
             this.button_Save = new System.Windows.Forms.Button();
38 39
             this.label62 = new System.Windows.Forms.Label();
@@ -160,6 +161,7 @@
160 161
             this.cmBaudRate = new System.Windows.Forms.Label();
161 162
             this.comboBox_baudrate = new System.Windows.Forms.ComboBox();
162 163
             this.tabPage_Table = new System.Windows.Forms.TabPage();
164
+            this.button_AllExcelLoad = new System.Windows.Forms.Button();
163 165
             this.button_AllExcelSave = new System.Windows.Forms.Button();
164 166
             this.button_ExcelKill = new System.Windows.Forms.Button();
165 167
             this.button_ExcelLoad = new System.Windows.Forms.Button();
@@ -269,7 +271,6 @@
269 271
             this.label44 = new System.Windows.Forms.Label();
270 272
             this.pictureBox_ULShutdown_Alarm_ON = new System.Windows.Forms.PictureBox();
271 273
             this.pictureBox_ULShutdown_Alarm_OFF = new System.Windows.Forms.PictureBox();
272
-            this.button_Test = new System.Windows.Forms.Button();
273 274
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
274 275
             this.Mbic_Setting.SuspendLayout();
275 276
             this.tabPage_Main.SuspendLayout();
@@ -439,6 +440,16 @@
439 440
             this.tabPage_Main.Text = "Main";
440 441
             this.tabPage_Main.UseVisualStyleBackColor = true;
441 442
             // 
443
+            // button_Test
444
+            // 
445
+            this.button_Test.Location = new System.Drawing.Point(81, 682);
446
+            this.button_Test.Name = "button_Test";
447
+            this.button_Test.Size = new System.Drawing.Size(128, 23);
448
+            this.button_Test.TabIndex = 149;
449
+            this.button_Test.Text = "MBIC Down";
450
+            this.button_Test.UseVisualStyleBackColor = true;
451
+            this.button_Test.Click += new System.EventHandler(this.button_Test_Click);
452
+            // 
442 453
             // button_Reset
443 454
             // 
444 455
             this.button_Reset.Location = new System.Drawing.Point(6, 608);
@@ -2083,6 +2094,7 @@
2083 2094
             // 
2084 2095
             // tabPage_Table
2085 2096
             // 
2097
+            this.tabPage_Table.Controls.Add(this.button_AllExcelLoad);
2086 2098
             this.tabPage_Table.Controls.Add(this.button_AllExcelSave);
2087 2099
             this.tabPage_Table.Controls.Add(this.button_ExcelKill);
2088 2100
             this.tabPage_Table.Controls.Add(this.button_ExcelLoad);
@@ -2099,11 +2111,21 @@
2099 2111
             this.tabPage_Table.Text = "Table";
2100 2112
             this.tabPage_Table.UseVisualStyleBackColor = true;
2101 2113
             // 
2114
+            // button_AllExcelLoad
2115
+            // 
2116
+            this.button_AllExcelLoad.Location = new System.Drawing.Point(688, 396);
2117
+            this.button_AllExcelLoad.Name = "button_AllExcelLoad";
2118
+            this.button_AllExcelLoad.Size = new System.Drawing.Size(77, 100);
2119
+            this.button_AllExcelLoad.TabIndex = 7;
2120
+            this.button_AllExcelLoad.Text = "ALL ExcelLoad";
2121
+            this.button_AllExcelLoad.UseVisualStyleBackColor = true;
2122
+            this.button_AllExcelLoad.Click += new System.EventHandler(this.button_AllExcelLoad_Click);
2123
+            // 
2102 2124
             // button_AllExcelSave
2103 2125
             // 
2104
-            this.button_AllExcelSave.Location = new System.Drawing.Point(666, 396);
2126
+            this.button_AllExcelSave.Location = new System.Drawing.Point(600, 396);
2105 2127
             this.button_AllExcelSave.Name = "button_AllExcelSave";
2106
-            this.button_AllExcelSave.Size = new System.Drawing.Size(100, 100);
2128
+            this.button_AllExcelSave.Size = new System.Drawing.Size(77, 100);
2107 2129
             this.button_AllExcelSave.TabIndex = 6;
2108 2130
             this.button_AllExcelSave.Text = "ALL ExcelSave";
2109 2131
             this.button_AllExcelSave.UseVisualStyleBackColor = true;
@@ -2111,9 +2133,9 @@
2111 2133
             // 
2112 2134
             // button_ExcelKill
2113 2135
             // 
2114
-            this.button_ExcelKill.Location = new System.Drawing.Point(556, 396);
2136
+            this.button_ExcelKill.Location = new System.Drawing.Point(512, 396);
2115 2137
             this.button_ExcelKill.Name = "button_ExcelKill";
2116
-            this.button_ExcelKill.Size = new System.Drawing.Size(100, 100);
2138
+            this.button_ExcelKill.Size = new System.Drawing.Size(77, 100);
2117 2139
             this.button_ExcelKill.TabIndex = 5;
2118 2140
             this.button_ExcelKill.Text = "Excell Kill";
2119 2141
             this.button_ExcelKill.UseVisualStyleBackColor = true;
@@ -2121,9 +2143,9 @@
2121 2143
             // 
2122 2144
             // button_ExcelLoad
2123 2145
             // 
2124
-            this.button_ExcelLoad.Location = new System.Drawing.Point(446, 396);
2146
+            this.button_ExcelLoad.Location = new System.Drawing.Point(424, 396);
2125 2147
             this.button_ExcelLoad.Name = "button_ExcelLoad";
2126
-            this.button_ExcelLoad.Size = new System.Drawing.Size(100, 100);
2148
+            this.button_ExcelLoad.Size = new System.Drawing.Size(77, 100);
2127 2149
             this.button_ExcelLoad.TabIndex = 3;
2128 2150
             this.button_ExcelLoad.Text = "ExcelLoad";
2129 2151
             this.button_ExcelLoad.UseVisualStyleBackColor = true;
@@ -2133,7 +2155,7 @@
2133 2155
             // 
2134 2156
             this.button_ExcelSave.Location = new System.Drawing.Point(336, 396);
2135 2157
             this.button_ExcelSave.Name = "button_ExcelSave";
2136
-            this.button_ExcelSave.Size = new System.Drawing.Size(100, 100);
2158
+            this.button_ExcelSave.Size = new System.Drawing.Size(77, 100);
2137 2159
             this.button_ExcelSave.TabIndex = 3;
2138 2160
             this.button_ExcelSave.Text = "ExcelSave";
2139 2161
             this.button_ExcelSave.UseVisualStyleBackColor = true;
@@ -3512,16 +3534,6 @@
3512 3534
             this.pictureBox_ULShutdown_Alarm_OFF.TabStop = false;
3513 3535
             this.pictureBox_ULShutdown_Alarm_OFF.Tag = "2";
3514 3536
             // 
3515
-            // button_Test
3516
-            // 
3517
-            this.button_Test.Location = new System.Drawing.Point(81, 682);
3518
-            this.button_Test.Name = "button_Test";
3519
-            this.button_Test.Size = new System.Drawing.Size(128, 23);
3520
-            this.button_Test.TabIndex = 149;
3521
-            this.button_Test.Text = "MBIC Down";
3522
-            this.button_Test.UseVisualStyleBackColor = true;
3523
-            this.button_Test.Click += new System.EventHandler(this.button_Test_Click);
3524
-            // 
3525 3537
             // JdasMbic
3526 3538
             // 
3527 3539
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -3948,6 +3960,7 @@
3948 3960
         public System.Windows.Forms.PictureBox pictureBox_ULShutdown_Alarm_ON;
3949 3961
         public System.Windows.Forms.PictureBox pictureBox_ULShutdown_Alarm_OFF;
3950 3962
         private System.Windows.Forms.Button button_Test;
3963
+        private System.Windows.Forms.Button button_AllExcelLoad;
3951 3964
     }
3952 3965
 }
3953 3966
 

+ 37 - 9
Jdas_Mbic/Main.cs

@@ -2666,12 +2666,12 @@ namespace Jdas_Mbic
2666 2666
         {
2667 2667
             for (int i = 0; i < comboBox_TableName.Items.Count; i++)
2668 2668
             {
2669
+                CheckForIllegalCrossThreadCalls = false;
2669 2670
                 comboBox_TableName.SelectedIndex = i;
2670 2671
                 Thread.Sleep(1000);
2671 2672
                 button_ExcelSave_Click(null, null);
2672 2673
             }
2673 2674
             rTh[0].Abort(); //쓰레드 강제 종료
2674
-            rTh[1].Abort(); //쓰레드 강제 종료
2675 2675
             Console.WriteLine("Thread 종료~");
2676 2676
         }
2677 2677
 
@@ -2782,7 +2782,7 @@ namespace Jdas_Mbic
2782 2782
             char[] tempchardata;
2783 2783
             OpenFileDialog Mbic_ofd = new OpenFileDialog();
2784 2784
             UInt32 Crcret = 0;
2785
-            byte[] tempdata = new byte[5];
2785
+            byte[] tempdata = new byte[1027];
2786 2786
             
2787 2787
             //파일오픈창 생성 및 설정
2788 2788
             Mbic_ofd.Title = "업데이터 파일 탐색기";
@@ -2799,11 +2799,13 @@ namespace Jdas_Mbic
2799 2799
             {
2800 2800
                 //File명과 확장자를 가지고 온다.
2801 2801
                 string fileName = Mbic_ofd.SafeFileName;
2802
+                
2802 2803
                 //File경로와 File명을 모두 가지고 온다.
2803 2804
                 string fileFullName = Mbic_ofd.FileName;
2805
+                
2804 2806
                 //File경로만 가지고 온다.
2805 2807
                 string filePath = fileFullName.Replace(fileName, "");
2806
-                this.serial.debug_hextoasciiConvert();
2808
+                //this.serial.debug_hextoasciiConvert();
2807 2809
 
2808 2810
                 //출력 예제용 로직
2809 2811
                 //  label1.Text = "File Name  : " + fileName;
@@ -2811,6 +2813,7 @@ namespace Jdas_Mbic
2811 2813
                 // label3.Text = "File Path  : " + filePath;`
2812 2814
                 //File경로 + 파일명 리턴
2813 2815
                 //JT-NRDAS 
2816
+
2814 2817
                 tempchardata = MBIC_HeaderName.ToCharArray();
2815 2818
                 for(int i = 0; i < tempchardata.Length; i++)
2816 2819
                 {
@@ -2840,6 +2843,7 @@ namespace Jdas_Mbic
2840 2843
                 {
2841 2844
                     MBIC_Add_BootLoader_DataArray[i] = DataToConvertHex(s3)[i - 55];
2842 2845
                 }
2846
+
2843 2847
                 MBIC_BootLoader_DataArray = File.ReadAllBytes(Mbic_ofd.FileName);
2844 2848
                 MBIC_Add_BootLoader_DataArray[60] = Convert.ToByte((MBIC_BootLoader_DataArray.Length & 0xFF00) >> 8);
2845 2849
                 MBIC_Add_BootLoader_DataArray[61] = Convert.ToByte((MBIC_BootLoader_DataArray.Length & 0x00FF));
@@ -2849,36 +2853,60 @@ namespace Jdas_Mbic
2849 2853
                 MBIC_Add_BootLoader_DataArray[63] = Convert.ToByte((Crcret & 0x00FF0000) >> (8 * 2));
2850 2854
                 MBIC_Add_BootLoader_DataArray[64] = Convert.ToByte((Crcret & 0x0000FF00) >> (8 * 1));
2851 2855
                 MBIC_Add_BootLoader_DataArray[65] = Convert.ToByte((Crcret & 0x000000FF) >> (8 * 0));
2856
+
2852 2857
                 for (int i = 0; i < 62; i++)
2853
-                    MBIC_Add_BootLoader_DataArray[66 + i] = 0x20;
2858
+                    MBIC_Add_BootLoader_DataArray[66 + i] = 0x00;
2854 2859
 
2855 2860
                 byte[] RetBinary = new byte[MBIC_Add_BootLoader_DataArray.Length + MBIC_BootLoader_DataArray.Length];
2856 2861
                 Array.Copy(MBIC_Add_BootLoader_DataArray, 0, RetBinary, 0, MBIC_Add_BootLoader_DataArray.Length);
2857 2862
                 Array.Copy(MBIC_BootLoader_DataArray, 0, RetBinary, MBIC_Add_BootLoader_DataArray.Length, MBIC_BootLoader_DataArray.Length);
2858
-                System.IO.FileStream infile = new System.IO.FileStream("FileName.bin", System.IO.FileMode.Create); //파일 스트림 선언
2859 2863
 
2860
-                infile.Write(RetBinary, 0, RetBinary.Length);    //쓰기
2861
-                infile.Close();                  //꼭 닫아 주세요. 파일 입출력엔 엄청 중요하죠.
2864
+                //System.IO.FileStream infile = new System.IO.FileStream("FileName.bin", System.IO.FileMode.Create); //파일 스트림 선언
2865
+                //infile.Write(RetBinary, 0, RetBinary.Length);    //쓰기
2866
+                //infile.Close();                  //꼭 닫아 주세요. 파일 입출력엔 엄청 중요하죠.
2867
+                this.serial.Serial_DataSend(RetBinary, 128);
2868
+
2862 2869
                 /*    
2863 2870
                     tempdata[0] = 0xbe;
2864 2871
                     tempdata[1] = Termianl_Reset;
2865 2872
                     tempdata[2] = 0x02;
2866 2873
                     tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
2867 2874
                     tempdata[4] = 0xeb;
2868
-
2869 2875
                     this.serial.Serial_DataSend(tempdata, 5);*/
2870 2876
                 try
2871 2877
                 {
2872 2878
                     // Controller_Debug.Controller_TX_TextLoad(tempdata);
2873 2879
                 }
2874 2880
                 catch { }
2875
-            
2876 2881
             }
2877 2882
             //취소버튼 클릭시 또는 ESC키로 파일창을 종료 했을경우
2878 2883
             else if (dr == DialogResult.Cancel)
2879 2884
             {
2880 2885
             }
2886
+        }
2887
+
2888
+        private void button_AllExcelLoad_Click(object sender, EventArgs e)
2889
+        {
2890
+            //Thread 객체 생성. 생성시 이 Thread가 실행할 메소드를 지정해 준다. 
2891
+            //여기서는 Count라는 메소드를 rTh라는 쓰레드가 실행하게 될 것이다.
2881 2892
 
2893
+            rTh[1] = new Thread(ExcellTableAllLoad);
2894
+            rTh[1].Start();
2895
+        }
2896
+        private void ExcellTableAllLoad()
2897
+        {
2898
+            for (int i = 0; i < comboBox_TableName.Items.Count; i++)
2899
+            {
2900
+                CheckForIllegalCrossThreadCalls = false;
2901
+                comboBox_TableName.SelectedIndex = i;
2902
+                Thread.Sleep(1000);
2903
+                button_ExcelLoad_Click(null, null);
2904
+                Thread.Sleep(1000);
2905
+                button_FileSave_Click(null,null);
2906
+                Thread.Sleep(2000);
2907
+            }
2908
+            rTh[1].Abort(); //쓰레드 강제 종료
2909
+            Console.WriteLine("Thread 종료~");
2882 2910
         }
2883 2911
     }
2884 2912
     class AutoClosingMessageBox

二进制
Jdas_Mbic/bin/Debug/Jdas_Mbic.exe


二进制
Jdas_Mbic/bin/Debug/Jdas_Mbic.pdb


二进制
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.GenerateResource.cache


二进制
Jdas_Mbic/obj/Debug/Jdas_Mbic.exe


二进制
Jdas_Mbic/obj/Debug/Jdas_Mbic.pdb