Selaa lähdekoodia

Download Debug TxRx 구현

PYJ 5 vuotta sitten
vanhempi
commit
457cc8ed81

BIN
.vs/Jdas_Mbic/v15/.suo


BIN
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide


BIN
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-shm


BIN
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-wal


+ 25 - 22
Jdas_Mbic/Terminal.Designer.cs

@@ -1,6 +1,6 @@
1 1
 namespace Jdas_Mbic
2 2
 {
3
-    partial class Terminal
3
+    partial class Debug
4 4
     {
5 5
         /// <summary>
6 6
         /// Required designer variable.
@@ -42,13 +42,15 @@
42 42
             // 
43 43
             // tbReceived
44 44
             // 
45
-            this.tbReceived.BackColor = System.Drawing.Color.Black;
46
-            this.tbReceived.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
47
-            this.tbReceived.ForeColor = System.Drawing.Color.Yellow;
48
-            this.tbReceived.Location = new System.Drawing.Point(12, 12);
45
+            this.tbReceived.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
46
+            this.tbReceived.ForeColor = System.Drawing.SystemColors.Window;
47
+            this.tbReceived.Location = new System.Drawing.Point(0, 0);
48
+            this.tbReceived.MaxLength = 0;
49 49
             this.tbReceived.Name = "tbReceived";
50
-            this.tbReceived.Size = new System.Drawing.Size(776, 323);
51
-            this.tbReceived.TabIndex = 0;
50
+            this.tbReceived.ReadOnly = true;
51
+            this.tbReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
52
+            this.tbReceived.Size = new System.Drawing.Size(1230, 403);
53
+            this.tbReceived.TabIndex = 63;
52 54
             this.tbReceived.Text = "";
53 55
             // 
54 56
             // groupBox1
@@ -60,10 +62,10 @@
60 62
             this.groupBox1.Controls.Add(this.button_Clear);
61 63
             this.groupBox1.Controls.Add(this.button_Send);
62 64
             this.groupBox1.Controls.Add(this.textBox_senddata);
63
-            this.groupBox1.Location = new System.Drawing.Point(12, 349);
65
+            this.groupBox1.Location = new System.Drawing.Point(13, 410);
64 66
             this.groupBox1.Name = "groupBox1";
65
-            this.groupBox1.Size = new System.Drawing.Size(776, 89);
66
-            this.groupBox1.TabIndex = 65;
67
+            this.groupBox1.Size = new System.Drawing.Size(1217, 89);
68
+            this.groupBox1.TabIndex = 64;
67 69
             this.groupBox1.TabStop = false;
68 70
             this.groupBox1.Text = "보내는 문자열";
69 71
             // 
@@ -111,39 +113,40 @@
111 113
             // 
112 114
             // button_Clear
113 115
             // 
114
-            this.button_Clear.Location = new System.Drawing.Point(698, 19);
116
+            this.button_Clear.Location = new System.Drawing.Point(1140, 19);
115 117
             this.button_Clear.Name = "button_Clear";
116 118
             this.button_Clear.Size = new System.Drawing.Size(71, 23);
117 119
             this.button_Clear.TabIndex = 2;
118 120
             this.button_Clear.Text = "삭제";
119 121
             this.button_Clear.UseVisualStyleBackColor = true;
122
+            this.button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
120 123
             // 
121 124
             // button_Send
122 125
             // 
123
-            this.button_Send.Location = new System.Drawing.Point(698, 52);
126
+            this.button_Send.Location = new System.Drawing.Point(1140, 52);
124 127
             this.button_Send.Name = "button_Send";
125 128
             this.button_Send.Size = new System.Drawing.Size(71, 23);
126 129
             this.button_Send.TabIndex = 1;
127 130
             this.button_Send.Text = "보내기";
128 131
             this.button_Send.UseVisualStyleBackColor = true;
132
+            this.button_Send.Click += new System.EventHandler(this.Button_Send_Click);
129 133
             // 
130 134
             // textBox_senddata
131 135
             // 
132 136
             this.textBox_senddata.Location = new System.Drawing.Point(7, 54);
133 137
             this.textBox_senddata.Name = "textBox_senddata";
134
-            this.textBox_senddata.Size = new System.Drawing.Size(679, 21);
138
+            this.textBox_senddata.Size = new System.Drawing.Size(1115, 21);
135 139
             this.textBox_senddata.TabIndex = 0;
136 140
             // 
137
-            // Terminal
141
+            // Debug
138 142
             // 
139 143
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
140 144
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
141
-            this.ClientSize = new System.Drawing.Size(812, 450);
145
+            this.ClientSize = new System.Drawing.Size(1242, 511);
142 146
             this.Controls.Add(this.groupBox1);
143 147
             this.Controls.Add(this.tbReceived);
144
-            this.Name = "Terminal";
145
-            this.Text = "Terminal";
146
-            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Terminal_FormClosing);
148
+            this.Name = "Debug";
149
+            this.Text = "Debug";
147 150
             this.groupBox1.ResumeLayout(false);
148 151
             this.groupBox1.PerformLayout();
149 152
             this.ResumeLayout(false);
@@ -152,14 +155,14 @@
152 155
 
153 156
         #endregion
154 157
 
155
-        private System.Windows.Forms.RichTextBox tbReceived;
158
+        public System.Windows.Forms.RichTextBox tbReceived;
156 159
         private System.Windows.Forms.GroupBox groupBox1;
160
+        private System.Windows.Forms.Button button_Send;
161
+        private System.Windows.Forms.TextBox textBox_senddata;
162
+        private System.Windows.Forms.Button button_Clear;
157 163
         private System.Windows.Forms.CheckBox checkBox2;
158 164
         private System.Windows.Forms.CheckBox checkBox1;
159 165
         public System.Windows.Forms.RadioButton radioButton_ascii;
160 166
         public System.Windows.Forms.RadioButton radioButton_hex;
161
-        private System.Windows.Forms.Button button_Clear;
162
-        private System.Windows.Forms.Button button_Send;
163
-        private System.Windows.Forms.TextBox textBox_senddata;
164 167
     }
165 168
 }

+ 222 - 0
Jdas_Mbic/Debug.cs

@@ -0,0 +1,222 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+//Add code
11
+using System.Runtime.InteropServices; //ini파일 로드 필요라이브러리
12
+namespace Jdas_Mbic
13
+{
14
+    public partial class Debug : Form
15
+    {
16
+        JdasMbic main_form;
17
+        int LineLimit = 500;
18
+        [DllImport("user32.dll")]
19
+        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
20
+        private const int WM_SETREDRAW = 11;
21
+        Serial serial;
22
+        public RadioButton RadioButton_ascii { get => radioButton_ascii; set => radioButton_ascii = value; }
23
+        public RadioButton RadioButton_hex { get => radioButton_hex; set => radioButton_hex = value; }
24
+
25
+        public Debug()
26
+        {
27
+            
28
+            InitializeComponent();
29
+            
30
+        }
31
+#if true
32
+        public void Data_Recv_Str(string text)
33
+        {
34
+           
35
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
36
+            try
37
+            {
38
+                try
39
+                {
40
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
41
+                }
42
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
43
+                if (tbReceived.Lines.Length > nLimitLines)
44
+                {
45
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
46
+                    while ((tempLines.Count - nLimitLines) > 0)
47
+                    {
48
+                        tempLines.RemoveFirst();
49
+                    }
50
+
51
+                    tbReceived.Lines = tempLines.ToArray();
52
+
53
+                }
54
+                try
55
+                {
56
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
57
+                }
58
+                catch { return; }
59
+                tbReceived.AppendText(text);
60
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
61
+                tbReceived.ScrollToCaret();
62
+            }
63
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
64
+        }
65
+#endif
66
+#if false
67
+        public void Data_Recv_Hex(byte[] text)
68
+        {
69
+           int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
70
+            try
71
+            {
72
+                try
73
+                {
74
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
75
+                }
76
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
77
+                if (tbReceived.Lines.Length > nLimitLines)
78
+                {
79
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
80
+                    while ((tempLines.Count - nLimitLines) > 0)
81
+                    {
82
+                        tempLines.RemoveFirst();
83
+                    }
84
+
85
+                    tbReceived.Lines = tempLines.ToArray();
86
+
87
+                }
88
+                try
89
+                {
90
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
91
+                }
92
+                catch { return; }
93
+                tbReceived.AppendText(text.ToString());
94
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
95
+                tbReceived.ScrollToCaret();
96
+            }
97
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
98
+
99
+        }
100
+#endif
101
+        public void Data_Recv_Hex(byte[] text)
102
+        {
103
+            string AppendMessage = "";
104
+            
105
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
106
+            try
107
+            {/*
108
+                try
109
+                {
110
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
111
+                }
112
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }*/
113
+                for (int i = 0; i < text.Length; i++)
114
+                {
115
+                    AppendMessage += Convert.ToString(text[i], 16);
116
+                    AppendMessage += " ";
117
+                }
118
+                AppendMessage += "\r\n";
119
+                tbReceived.AppendText(AppendMessage);
120
+               
121
+                if (tbReceived.Lines.Length > nLimitLines)
122
+                {
123
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
124
+
125
+                    while ((tempLines.Count - nLimitLines) > 0)
126
+                    {
127
+                        tempLines.RemoveFirst();
128
+                    }
129
+
130
+                    tbReceived.Lines = tempLines.ToArray();
131
+                }
132
+                try
133
+                {
134
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
135
+                }
136
+                catch { return; }
137
+                tbReceived.Select(tbReceived.Text.Length, 0);
138
+                tbReceived.ScrollToCaret();
139
+            }
140
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
141
+
142
+        }
143
+        public void Data_Send(byte[] text)
144
+        {
145
+            string AppendMessage = "\n[TX]";
146
+
147
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
148
+            try
149
+            {
150
+                for (int i = 0; i < text.Length; i++)
151
+                {
152
+                    AppendMessage += Convert.ToString(text[i], 16);
153
+                }
154
+                tbReceived.AppendText(AppendMessage);
155
+                try
156
+                {
157
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
158
+                }
159
+                catch { return; }
160
+                if (tbReceived.Lines.Length > nLimitLines)
161
+                {
162
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
163
+
164
+                    while ((tempLines.Count - nLimitLines) > 0)
165
+                    {
166
+                        tempLines.RemoveFirst();
167
+                    }
168
+
169
+                    tbReceived.Lines = tempLines.ToArray();
170
+                }
171
+                try
172
+                {
173
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
174
+                }
175
+                catch { return; }
176
+                tbReceived.Select(tbReceived.Text.Length, 0);
177
+                tbReceived.ScrollToCaret();
178
+            }
179
+            finally { }
180
+
181
+        }
182
+    
183
+        public void Serial_ClassSet(object serial)
184
+        {
185
+            this.serial = (Serial)serial;
186
+        }
187
+        private void Button_Send_Click(object sender, EventArgs e)
188
+        {
189
+            try
190
+            {
191
+                this.serial.Serial_DataSend(Encoding.ASCII.GetBytes(textBox_senddata.Text));
192
+            }
193
+            catch (System.Exception ex)
194
+            {
195
+                MessageBox.Show(ex.Message);
196
+            }
197
+        }
198
+
199
+        private void Button_Clear_Click(object sender, EventArgs e)
200
+        {
201
+            try
202
+            {
203
+                this.tbReceived.Text = "";
204
+            }
205
+            finally { }
206
+        }
207
+        public void hex_to_ascii_radiobuttonConvert()
208
+        {
209
+            radioButton_hex.Checked = true;
210
+            radioButton_ascii.Checked = false;
211
+        }
212
+        public void ascii_to_hex_radiobuttonConvert()
213
+        {
214
+            radioButton_ascii.Checked = true;
215
+            radioButton_hex.Checked = false;
216
+        }
217
+        public void Debug_Main_Form_Get(object frm)
218
+        {
219
+            this.main_form = (JdasMbic)frm;
220
+        }
221
+    }
222
+}

Jdas_Mbic/Terminal.resx → Jdas_Mbic/Debug.resx


+ 81 - 0
Jdas_Mbic/Download_bar.Designer.cs

@@ -0,0 +1,81 @@
1
+namespace Jdas_Mbic
2
+{
3
+    partial class Download_bar
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.Firm_Progressbar = new System.Windows.Forms.ProgressBar();
32
+            this.Update_label = new System.Windows.Forms.Label();
33
+            this.SuspendLayout();
34
+            // 
35
+            // Firm_Progressbar
36
+            // 
37
+            this.Firm_Progressbar.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
38
+            | System.Windows.Forms.AnchorStyles.Left) 
39
+            | System.Windows.Forms.AnchorStyles.Right)));
40
+            this.Firm_Progressbar.Location = new System.Drawing.Point(12, 24);
41
+            this.Firm_Progressbar.Name = "Firm_Progressbar";
42
+            this.Firm_Progressbar.Size = new System.Drawing.Size(478, 46);
43
+            this.Firm_Progressbar.Step = 1;
44
+            this.Firm_Progressbar.TabIndex = 133;
45
+            // 
46
+            // Update_label
47
+            // 
48
+            this.Update_label.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
49
+            | System.Windows.Forms.AnchorStyles.Left) 
50
+            | System.Windows.Forms.AnchorStyles.Right)));
51
+            this.Update_label.AutoSize = true;
52
+            this.Update_label.BackColor = System.Drawing.Color.Transparent;
53
+            this.Update_label.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
54
+            this.Update_label.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
55
+            this.Update_label.Location = new System.Drawing.Point(245, 9);
56
+            this.Update_label.Name = "Update_label";
57
+            this.Update_label.Size = new System.Drawing.Size(23, 12);
58
+            this.Update_label.TabIndex = 134;
59
+            this.Update_label.Text = "0%";
60
+            // 
61
+            // Download_bar
62
+            // 
63
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
64
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
65
+            this.ClientSize = new System.Drawing.Size(502, 94);
66
+            this.Controls.Add(this.Update_label);
67
+            this.Controls.Add(this.Firm_Progressbar);
68
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
69
+            this.Name = "Download_bar";
70
+            this.Text = "Download_bar";
71
+            this.ResumeLayout(false);
72
+            this.PerformLayout();
73
+
74
+        }
75
+
76
+        #endregion
77
+
78
+        private System.Windows.Forms.ProgressBar Firm_Progressbar;
79
+        public System.Windows.Forms.Label Update_label;
80
+    }
81
+}

+ 61 - 0
Jdas_Mbic/Download_bar.cs

@@ -0,0 +1,61 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+namespace Jdas_Mbic
12
+{
13
+    public partial class Download_bar : Form
14
+    {
15
+        public Download_bar()
16
+        {
17
+            InitializeComponent();
18
+        }
19
+        public void Progressbar(String val)
20
+        {
21
+            Update_label.Text = val;
22
+        }
23
+        public void Progressbar_gauge_zero()
24
+        {
25
+            Firm_Progressbar.Value = 0;
26
+        }
27
+        public new void FormClosed(object form)
28
+        {
29
+            Download_bar download_Bar = (Download_bar)form;
30
+            CheckForIllegalCrossThreadCalls = false;
31
+            download_Bar.Close();
32
+        }
33
+        public void PerformStepup(object form)
34
+        {
35
+            Download_bar download_Bar = (Download_bar)form;
36
+            CheckForIllegalCrossThreadCalls = false;
37
+            Firm_Progressbar.PerformStep();
38
+        }
39
+        public void PerformStepinc(int val)
40
+        {
41
+            //Download_bar download_Bar = (Download_bar)form;
42
+            CheckForIllegalCrossThreadCalls = false;
43
+            Firm_Progressbar.Increment(val);
44
+        }
45
+        public void Update_Percent(String val)
46
+        {
47
+            CheckForIllegalCrossThreadCalls = false;
48
+            //Firm_Progressbar.PerformStep();
49
+            try
50
+            {
51
+                Update_label.Text = val + "%";
52
+            }
53
+            catch { }
54
+        }
55
+        public int Update_get()
56
+        {
57
+            return Firm_Progressbar.Value;
58
+        }
59
+
60
+    }
61
+}

+ 120 - 0
Jdas_Mbic/Download_bar.resx

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 149 - 0
Jdas_Mbic/Func/Bluecell_BootProtocol.cs

@@ -0,0 +1,149 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace Jdas_Mbic
8
+{
9
+    public enum Bluepro_t
10
+    {
11
+        bluecell_header0 = 0,
12
+        bluecell_header1,
13
+        bluecell_header2,
14
+        bluecell_header3,
15
+        bluecell_type,
16
+        bluecell_length_h,
17
+        bluecell_length_l,
18
+        bluecell_updatecnt_h,
19
+        bluecell_updatecnt_l,
20
+        bluecell_data,
21
+
22
+    };
23
+    public enum Updateseq
24
+    {
25
+        Bluecell_Reset = 0,
26
+        Bluecell_Firmupdate_start,
27
+        Bluecell_Firmupdate_sending,
28
+        Bluecell_Firmupdate_end,
29
+    };
30
+    enum Bluecell_ProtIndex_p
31
+    {
32
+        Bluecell_Header = 0,
33
+        Bluecell_Type,
34
+        Bluecell_Length,
35
+        Bluecell_CrcIndex,
36
+        Bluecell_data,
37
+    }
38
+    enum Bluecell_Prot_t{
39
+        TYPE_BLUECELL_RESET = 0,
40
+        TYPE_BLUECELL_SET   = 1,
41
+        TYPE_BLUECELL_GET   = 2,
42
+        TYPE_BLUECELL_SAVE  = 3,
43
+        TYPE_BLUECELL_ACK   = 4,
44
+    };
45
+    class Bluecell_BootProtocol
46
+    {
47
+        Serial serial;
48
+        /*bluecell Header*/
49
+        public const byte Bluecell_Header0 = 0x42;//ASCII : B
50
+        public const byte Bluecell_Header1 = 0x4C;//ASCII : L
51
+        public const byte Bluecell_Header2 = 0x55;//ASCII : U
52
+        public const byte Bluecell_Header3 = 0x45;//ASCII : E
53
+        /*bluecell type*/
54
+
55
+
56
+        public const int bluecell_Firmupdate_sendlength = 1024;
57
+        Crc16 crc16 = new Crc16();
58
+        public const byte BLUECELL_HEADER = 0xBE;
59
+        public const byte BLUECELL_TAILER = 0xEB;
60
+        const byte BLUECELL_RESET_LENGTH = 6;
61
+        const byte BLUECELL_FIX_DATA_LENGTH = 3;
62
+        public void Bluecell_Reset(object serial)
63
+        {
64
+            this.serial = (Serial)serial;
65
+            byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
66
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header]       = BLUECELL_HEADER;
67
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type]         = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
68
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length]       = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
69
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex]     = (byte)Bluecell_ProtIndex_p.Bluecell_data;
70
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data]         = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
71
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1]     = BLUECELL_TAILER;
72
+            this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
73
+        }
74
+
75
+        public const byte bluecell_length    = 2;
76
+        public const byte bluecell_updatecnt = 2;
77
+        public const byte bluecell_crc16     = 2;
78
+     
79
+   
80
+
81
+#if false
82
+        public int Bluecell_Firmupdate_sendlength() {
83
+            return bluecell_Firmupdate_sendlength;
84
+        }
85
+        private void BootHeaderput(ref byte[] fix_data)
86
+        {
87
+            fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
88
+            fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
89
+            fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
90
+            fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
91
+        }
92
+
93
+        public byte[] Boot_Reset(object serial,byte[] Updatedata)
94
+        {
95
+            this.serial = (Serial)serial;
96
+            byte[] fix_data = new byte[11];
97
+            //Array.Clear(data, 0, data.Length);
98
+            BootHeaderput(ref fix_data);
99
+            fix_data[(int)Bluepro_t.bluecell_type]    = (byte)Updateseq.Bluecell_Reset;
100
+            fix_data[(int)Bluepro_t.bluecell_length_h]  = 0;
101
+            fix_data[(int)Bluepro_t.bluecell_length_l]  = 5;
102
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
103
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
104
+
105
+            fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
106
+            fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
107
+            this.serial.Serial_DataSend(fix_data, fix_data.Length);
108
+            return fix_data;            
109
+        }
110
+     
111
+        public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
112
+        {
113
+            //Array.Clear(data, 0, data.Length);
114
+            byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
115
+            //BootHeaderput(ref fix_data);
116
+            //length += 5;
117
+            Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
118
+            BootHeaderput(ref fix_data);
119
+            fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
120
+            fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
121
+            fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
122
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
123
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
124
+
125
+            //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
126
+            fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
127
+            fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
128
+            return fix_data;
129
+        }
130
+        public byte[] Boot_DataEnd(byte[] update_data, int length)
131
+        {
132
+            //Array.Clear(data, 0, data.Length);
133
+            byte[] fix_data = new byte[11];
134
+            Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
135
+            BootHeaderput(ref fix_data);
136
+            fix_data[(int)Bluepro_t.bluecell_type]    = (byte)Updateseq.Bluecell_Firmupdate_end;
137
+            fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
138
+            fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
139
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
140
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
141
+
142
+            //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
143
+            fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
144
+            fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
145
+            return fix_data;
146
+        }
147
+#endif
148
+    }
149
+}

+ 6 - 13
Jdas_Mbic/Function/CRC16.cs

@@ -4,19 +4,12 @@ using System.Linq;
4 4
 using System.Text;
5 5
 using System.Threading.Tasks;
6 6
 
7
-namespace Jdas_Mbic.Function
7
+namespace Jdas_Mbic
8 8
 {
9
-    class CRC16
10
-    {
11
-        enum Bluecell_CrcIndex_p
12
-        {
13
-            Bluecell_Header = 0,
14
-            Bluecell_Type,
15
-            Bluecell_Length,
16
-            Bluecell_CrcIndex,
17
-            Bluecell_data,
18
-        }
9
+    
19 10
 
11
+    class Crc16
12
+    {
20 13
         private readonly ushort[] Table_CRC16 = {
21 14
             0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
22 15
             0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@@ -73,7 +66,7 @@ namespace Jdas_Mbic.Function
73 66
 
74 67
             if (len != 0)
75 68
             {
76
-                dt = (byte)(buf_ptr[index] << 8);
69
+                dt = (byte)( buf_ptr[index] << 8);
77 70
 
78 71
                 while (len != 0)
79 72
                 {
@@ -153,7 +146,7 @@ namespace Jdas_Mbic.Function
153 146
             byte bit;        // bit mask
154 147
             int crc = 0xFF; // calculated checksum
155 148
             byte byteCtr;    // byte counter
156
-            byte index = (int)Bluecell_CrcIndex_p.Bluecell_Type;
149
+            byte index = (int)Bluecell_ProtIndex_p.Bluecell_Type;
157 150
             // calculates 8-Bit checksum with given polynomial
158 151
             for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
159 152
             {

+ 14 - 18
Jdas_Mbic/Function/Data_Handler.cs

@@ -1,10 +1,11 @@
1
-using System;
1
+using Jdas_Mbic;
2
+using System;
2 3
 using System.Collections.Generic;
3 4
 using System.Linq;
4 5
 using System.Text;
5 6
 using System.Threading.Tasks;
6 7
 
7
-namespace Jdas_Mbic.Function
8
+namespace Jdas_Mbic
8 9
 {
9 10
     class Data_Handler
10 11
     {
@@ -21,7 +22,7 @@ namespace Jdas_Mbic.Function
21 22
         {
22 23
             Boolean ret = false;
23 24
 
24
-            if (data[0] == 0xbe)
25
+            if(data[0] == 0xbe)
25 26
             {
26 27
                 ret = true;
27 28
             }
@@ -31,7 +32,7 @@ namespace Jdas_Mbic.Function
31 32
         {
32 33
             bool ret = false;
33 34
             Crc16 crc = new Crc16();
34
-            byte length, crcindex;
35
+            byte length,crcindex;
35 36
             try
36 37
             {
37 38
                 length = data[2];
@@ -43,30 +44,28 @@ namespace Jdas_Mbic.Function
43 44
             crcindex = (byte)(length + 1);
44 45
             try
45 46
             {
46
-                ret = crc.STH30_CheckCrc(data, length, data[crcindex]);
47
+            ret = crc.STH30_CheckCrc(data,length,data[crcindex]);
47 48
             }
48
-            catch (Exception e)
49
+            catch(Exception e)
49 50
             {
50 51
                 return ret;
51 52
             }
52 53
             return ret;
53 54
         }
54
-
55
+        JdasMbic main_Form; //= new Main_Form();
55 56
         Serial serial;
56
-        Main_Form main_Form; //= new Main_Form();
57
-        public void Recv_dataCheck(object serial, object main_form, object fileDownload, byte[] data)
57
+        public void Recv_dataCheck(object serial,object main_form, object fileDownload, byte[] data)
58 58
         {
59 59
             Boolean DataCheck;
60 60
             Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
61 61
             this.serial = (Serial)serial;
62
-            this.main_Form = (Main_Form)main_form;
62
+            this.main_Form = (JdasMbic)main_form;
63 63
             byte seq;
64 64
             try
65 65
             {
66 66
                 seq = data[1];
67 67
             }
68
-            catch
69
-            {
68
+            catch {
70 69
                 return;
71 70
             }
72 71
             if (fileDownload != null)
@@ -77,7 +76,6 @@ namespace Jdas_Mbic.Function
77 76
             {
78 77
                 this.fileDownload = new Update_Serial();
79 78
             }
80
-            /* * * * * * * * * * * * * *파일 다운로드 부분* * * * * * * * * * * * *  */
81 79
             if (this.fileDownload.Update_ready == true)
82 80
             {
83 81
                 DataCheck = HeaderCheck(data);
@@ -86,7 +84,7 @@ namespace Jdas_Mbic.Function
86 84
                     return;
87 85
                 }
88 86
                 DataCheck = CrcCheck(data);
89
-                if (DataCheck == false)
87
+                if(DataCheck == false)
90 88
                 {
91 89
                     return;
92 90
                 }
@@ -107,7 +105,7 @@ namespace Jdas_Mbic.Function
107 105
                     default:
108 106
                         break;
109 107
                 }
110
-
108
+                
111 109
             }
112 110
             else/* * * * * * * * * * * * * *API RECV 부분 * * * * * * * * * * * * *  */
113 111
             {
@@ -121,9 +119,7 @@ namespace Jdas_Mbic.Function
121 119
                 {
122 120
                     return;
123 121
                 }
124
-
125
-                bluecell_BootProtocol.Bluecell_RF_Status_Get(this.serial, this.main_Form, data);
126
-
122
+                //bluecell_BootProtocol.Bluecell_RF_Status_Get(this.serial,this.main_Form, data);
127 123
             }
128 124
         }
129 125
     }

+ 33 - 231
Jdas_Mbic/Terminal.cs

@@ -1,241 +1,42 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3
-using System.ComponentModel;
4
-using System.Data;
5
-using System.Drawing;
6 3
 using System.Linq;
7
-using System.Runtime.InteropServices;
8 4
 using System.Text;
9 5
 using System.Threading.Tasks;
10
-using System.Windows.Forms;
11
-
12 6
 //Add code
7
+using System.Windows.Forms;
13 8
 using System.IO;
14 9
 using System.IO.Ports;
15
-using Jdas_Mbic.Function;
10
+using System.Data;
11
+using Jdas_Mbic;
16 12
 
17 13
 namespace Jdas_Mbic
18 14
 {
19
-    public partial class Terminal : Form
15
+    class Serial
20 16
     {
21
-        public Terminal()
22
-        {
23
-            InitializeComponent();
24
-        }
25
-
26
-        private void Terminal_FormClosing(object sender, FormClosingEventArgs e)
27
-        {
28
-            this.Dispose();
29
-        }
30
-
31
-        
32 17
         JdasMbic main_form;
33
-        int LineLimit = 500;
34
-        [DllImport("user32.dll")]
35
-        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
36
-        private const int WM_SETREDRAW = 11;
37
-        
38
-        public RadioButton RadioButton_ascii { get => radioButton_ascii; set => radioButton_ascii = value; }
39
-        public RadioButton RadioButton_hex { get => radioButton_hex; set => radioButton_hex = value; }
40
-#if true
41
-        public void Data_Recv_Str(string text)
42
-        {
43
-
44
-            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
45
-            try
46
-            {
47
-                try
48
-                {
49
-                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
50
-                }
51
-                catch (Exception e) { MessageBox.Show(e.StackTrace); }
52
-                if (tbReceived.Lines.Length > nLimitLines)
53
-                {
54
-                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
55
-                    while ((tempLines.Count - nLimitLines) > 0)
56
-                    {
57
-                        tempLines.RemoveFirst();
58
-                    }
59
-
60
-                    tbReceived.Lines = tempLines.ToArray();
61
-
62
-                }
63
-                try
64
-                {
65
-                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
66
-                }
67
-                catch { return; }
68
-                tbReceived.AppendText(text);
69
-                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
70
-                tbReceived.ScrollToCaret();
71
-            }
72
-            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
73
-        }
74
-#endif
75
-#if false
76
-        public void Data_Recv_Hex(byte[] text)
77
-        {
78
-           int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
79
-            try
80
-            {
81
-                try
82
-                {
83
-                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
84
-                }
85
-                catch (Exception e) { MessageBox.Show(e.StackTrace); }
86
-                if (tbReceived.Lines.Length > nLimitLines)
87
-                {
88
-                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
89
-                    while ((tempLines.Count - nLimitLines) > 0)
90
-                    {
91
-                        tempLines.RemoveFirst();
92
-                    }
93
-
94
-                    tbReceived.Lines = tempLines.ToArray();
95
-
96
-                }
97
-                try
98
-                {
99
-                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
100
-                }
101
-                catch { return; }
102
-                tbReceived.AppendText(text.ToString());
103
-                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
104
-                tbReceived.ScrollToCaret();
105
-            }
106
-            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
107
-
108
-        }
109
-#endif
110
-        public void Data_Recv_Hex(byte[] text)
111
-        {
112
-            string AppendMessage = "";
113
-
114
-            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
115
-            try
116
-            {/*
117
-                try
118
-                {
119
-                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
120
-                }
121
-                catch (Exception e) { MessageBox.Show(e.StackTrace); }*/
122
-                for (int i = 0; i < text.Length; i++)
123
-                {
124
-                    AppendMessage += Convert.ToString(text[i], 16);
125
-                    AppendMessage += " ";
126
-                }
127
-                AppendMessage += "\r\n";
128
-                tbReceived.AppendText(AppendMessage);
129
-
130
-                if (tbReceived.Lines.Length > nLimitLines)
131
-                {
132
-                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
133
-
134
-                    while ((tempLines.Count - nLimitLines) > 0)
135
-                    {
136
-                        tempLines.RemoveFirst();
137
-                    }
138
-
139
-                    tbReceived.Lines = tempLines.ToArray();
140
-                }
141
-                try
142
-                {
143
-                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
144
-                }
145
-                catch { return; }
146
-                tbReceived.Select(tbReceived.Text.Length, 0);
147
-                tbReceived.ScrollToCaret();
148
-            }
149
-            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
150
-
151
-        }
152
-        public void Data_Send(byte[] text)
153
-        {
154
-            string AppendMessage = "\n[TX]";
155
-
156
-            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
157
-            try
158
-            {
159
-                for (int i = 0; i < text.Length; i++)
160
-                {
161
-                    AppendMessage += Convert.ToString(text[i], 16);
162
-                }
163
-                tbReceived.AppendText(AppendMessage);
164
-                try
165
-                {
166
-                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
167
-                }
168
-                catch { return; }
169
-                if (tbReceived.Lines.Length > nLimitLines)
170
-                {
171
-                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
172
-
173
-                    while ((tempLines.Count - nLimitLines) > 0)
174
-                    {
175
-                        tempLines.RemoveFirst();
176
-                    }
177
-
178
-                    tbReceived.Lines = tempLines.ToArray();
179
-                }
180
-                try
181
-                {
182
-                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
183
-                }
184
-                catch { return; }
185
-                tbReceived.Select(tbReceived.Text.Length, 0);
186
-                tbReceived.ScrollToCaret();
187
-            }
188
-            finally { }
189
-
190
-        }
191
-
192
-
193
-        private void Button_Send_Click(object sender, EventArgs e)
194
-        {
195
-
196
-        }
197
-
198
-        private void Button_Clear_Click(object sender, EventArgs e)
199
-        {
200
-
201
-        }
202
-        public void hex_to_ascii_radiobuttonConvert()
203
-        {
204
-            radioButton_hex.Checked = true;
205
-            radioButton_ascii.Checked = false;
206
-        }
207
-        public void ascii_to_hex_radiobuttonConvert()
208
-        {
209
-            radioButton_ascii.Checked = true;
210
-            radioButton_hex.Checked = false;
211
-        }
212
-        public void Debug_Main_Form_Get(object frm)
213
-        {
214
-            this.main_form = (JdasMbic)frm;
215
-        }
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-        //public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
18
+        private System.IO.Ports.SerialPort serialPort;
19
+        private Debug Debug = new Debug();    // Teminal Text Wnd Open
20
+        public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
224 21
         Data_Handler data_Handler = new Data_Handler();
225 22
         //FileDownload fileDownload;
226 23
         Update_Serial fileDownload = null;
24
+
227 25
         public void SetPortNameValues(object obj)
228 26
         {
27
+
229 28
             string[] ports = SerialPort.GetPortNames(); // load all name of com ports to string
230 29
             try
231 30
             {
232 31
                 ((ComboBox)obj).Items.Clear(); //delete previous names in combobox items
233 32
             }
234 33
             catch { }
235
-           ((ComboBox)obj).DataSource = null;
34
+
35
+
36
+            ((ComboBox)obj).DataSource = null;
236 37
             foreach (string port in ports) //add this names to comboboxPort items
237 38
             {
238
-                ((ComboBox)obj).Items.Add(port); //if there are some com ports ,select first
39
+                 ((ComboBox)obj).Items.Add(port); //if there are some com ports ,select first
239 40
             }
240 41
             if (((ComboBox)obj).Items.Count > 0)
241 42
             {
@@ -246,6 +47,10 @@ namespace Jdas_Mbic
246 47
                 ((ComboBox)obj).Text = " "; //if there are no com ports ,write Empty
247 48
             }
248 49
         }
50
+        public void Serial_Port_name_Set(ref ComboBox cb_port)
51
+        {
52
+            serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
53
+        }
249 54
         public void Serial_Initialize(ref ComboBox cb_port)
250 55
         {
251 56
             
@@ -263,11 +68,11 @@ namespace Jdas_Mbic
263 68
             cb_port.DataSource =  SerialPort.GetPortNames();
264 69
             try
265 70
             {
266
-                serialPort_JdasMbic.PortName =  cb_port.SelectedItem.ToString();
267
-                serialPort_JdasMbic.BaudRate = (int)921600;
268
-                serialPort_JdasMbic.DataBits = (int)8;
269
-                serialPort_JdasMbic.Parity = System.IO.Ports.Parity.None;
270
-                serialPort_JdasMbic.StopBits = StopBits.One;
71
+                serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
72
+                serialPort.BaudRate = (int)115200;
73
+                serialPort.DataBits = (int)8;
74
+                serialPort.Parity = System.IO.Ports.Parity.None;
75
+                serialPort.StopBits = StopBits.One;
271 76
             }
272 77
             catch { }
273 78
 
@@ -309,9 +114,7 @@ namespace Jdas_Mbic
309 114
             Data_Handler data_Handler = new Data_Handler();
310 115
             int nLnegth = serialPort.BytesToRead;
311 116
             byte[] btdata = new byte[nLnegth];
312
-
313 117
             serialPort.Read(btdata, 0, nLnegth);
314
-
315 118
             main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
316 119
             main_form.TX_RX_Light = true;
317 120
             if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
@@ -319,16 +122,17 @@ namespace Jdas_Mbic
319 122
                 string data = Encoding.Default.GetString(btdata);
320 123
                 // string data = serialPort.ReadExisting();
321 124
 
322
-                if (Debug.RadioButton_ascii.Checked == true)
323
-                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
324
-                else
325
-                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
326
-               
125
+                    if (Debug.RadioButton_ascii.Checked == true)
126
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
127
+                    else
128
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
129
+
327 130
                 data_Handler.Recv_dataCheck(this,this.main_form,this.fileDownload, btdata);
328 131
             }
329 132
             else
330 133
             {
331 134
                 // 리스트 두개 사용
135
+
332 136
                 if (nLnegth > 0)
333 137
                 {
334 138
                     if (this.Debug.Created)
@@ -336,7 +140,7 @@ namespace Jdas_Mbic
336 140
                         if (this.Debug.radioButton_ascii.Checked == true)
337 141
                         {
338 142
                             tmpSTR = Encoding.Default.GetString(btdata).TrimEnd('\0');
339
-                            Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
143
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
340 144
                         }
341 145
                         else
342 146
                         {
@@ -350,7 +154,6 @@ namespace Jdas_Mbic
350 154
                     }
351 155
                     // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
352 156
                 }
353
-
354 157
                 data_Handler.Recv_dataCheck(this, this.main_form,this.fileDownload, btdata);
355 158
             }
356 159
             /****
@@ -373,6 +176,8 @@ namespace Jdas_Mbic
373 176
                 {
374 177
                     if (cb.Text != "")
375 178
                     {
179
+                        //this.main_form.Invoke(new BoolSet(this.main_form.Serial_PortName_get));
180
+                        serialPort.PortName = cb.Text;
376 181
                         serialPort.Open();
377 182
                         Btn_Portonoff.Text = "Port Close";
378 183
                         Debug.Debug_Main_Form_Get(this.main_form);
@@ -426,13 +231,12 @@ namespace Jdas_Mbic
426 231
             }
427 232
             catch
428 233
             {
429
-                System.Diagnostics.Process.GetCurrentProcess().Kill();
430 234
                 MessageBox.Show("Port Open Failed!!!");
431 235
             }
432 236
         }
433
-       
434 237
         public void FileDownloadClass_Set(object filedownload)
435 238
         {
239
+            //this.fileDownload = (FileDownload)filedownload;
436 240
             this.fileDownload = (Update_Serial)filedownload;
437 241
         }
438 242
         public object FileDownloadClass_Get()
@@ -463,11 +267,9 @@ namespace Jdas_Mbic
463 267
             if (this.Debug.Created)
464 268
                 this.Debug.ascii_to_hex_radiobuttonConvert();
465 269
         }
466
-        
467 270
         public void Serial_Main_Form_Get(object frm)
468 271
         {
469
-            this.main_form = (Main_Form)frm;
272
+            this.main_form = (JdasMbic)frm;
470 273
         }
471
-
472 274
     }
473 275
 }

+ 23 - 18
Jdas_Mbic/Function/Update_Serial.cs

@@ -1,10 +1,15 @@
1
-using System;
1
+using Jdas_Mbic;
2
+using System;
2 3
 using System.Collections.Generic;
4
+using System.IO;
3 5
 using System.Linq;
4 6
 using System.Text;
5 7
 using System.Threading.Tasks;
6 8
 
7
-namespace Jdas_Mbic.Function
9
+using System.Windows.Forms;
10
+
11
+
12
+namespace Jdas_Mbic
8 13
 {
9 14
     class Update_Serial
10 15
     {
@@ -87,17 +92,17 @@ namespace Jdas_Mbic.Function
87 92
                 FirmSendingcnt = 0;
88 93
                 Update_ready = true;
89 94
                 Bluecell_BootProtocol.Bluecell_Reset(this.serial);
90
-                /*    
91
-                    tempdata[0] = 0xbe;
92
-                    tempdata[1] = Termianl_Reset;
93
-                    tempdata[2] = 0x02;
94
-                    tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
95
-                    tempdata[4] = 0xeb;
96
-
97
-                    this.serial.Serial_DataSend(tempdata, 5);*/
95
+            /*    
96
+                tempdata[0] = 0xbe;
97
+                tempdata[1] = Termianl_Reset;
98
+                tempdata[2] = 0x02;
99
+                tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
100
+                tempdata[4] = 0xeb;
101
+               
102
+                this.serial.Serial_DataSend(tempdata, 5);*/
98 103
                 try
99 104
                 {
100
-                    // Controller_Debug.Controller_TX_TextLoad(tempdata);
105
+                   // Controller_Debug.Controller_TX_TextLoad(tempdata);
101 106
                 }
102 107
                 catch { }
103 108
                 download_Bar.ShowDialog();
@@ -161,7 +166,7 @@ namespace Jdas_Mbic.Function
161 166
                     this.download_Bar.FormClosed(this.download_Bar);
162 167
                     this.serial.debug_asciitohexConvert();
163 168
                     FirmSendingcnt = PreFirmSendingcnt = FirmCurrcnt = FirmTotalcnt = pretempupdateret = Data_Request_Val = 0;
164
-
169
+      
165 170
                     /*Update_label.Text = "0%";
166 171
                     Update_label.Visible = false;
167 172
                     progressBar1.Visible = false;
@@ -207,8 +212,8 @@ namespace Jdas_Mbic.Function
207 212
             this.download_Bar.Update_Percent(Convert.ToString(tempupdateret));
208 213
             if (pretempupdateret != tempupdateret)
209 214
             {
210
-                //for (int i = 0; i <= tempupdateret - this.download_Bar.Update_get(); i++)
211
-                for (int i = Current_step; i < tempupdateret; i++)
215
+
216
+                for(int i = Current_step; i < tempupdateret; i++)
212 217
                 {
213 218
                     this.download_Bar.PerformStepup(this.download_Bar);
214 219
                     Current_step++;
@@ -223,7 +228,7 @@ namespace Jdas_Mbic.Function
223 228
             this.serial.Serial_DataSend(temp_data, temp_data[2] + 3);
224 229
             try
225 230
             {
226
-                // Controller_Debug.Controller_TX_TextLoad(temp_data);
231
+               // Controller_Debug.Controller_TX_TextLoad(temp_data);
227 232
             }
228 233
             catch { }
229 234
         }
@@ -234,14 +239,14 @@ namespace Jdas_Mbic.Function
234 239
             Type = Text[(int)Bluecell_ProtIndex_p.Bluecell_Type];
235 240
             switch (Type)
236 241
             {
237
-
242
+               
238 243
                 case Termianl_BootStart:
239 244
                 case Termianl_Controller_Update_Ack:
240 245
                 case Termianl_Controller_Update_Nak:
241 246
                     if (Update_ready == true)
242 247
                         FirmwareUpdateCheck(Type);
243 248
                     break;
244
-
249
+               
245 250
                 default:
246 251
                     // MessageBox.Show("다시 시도 해주세요.");
247 252
                     break;
@@ -266,6 +271,6 @@ namespace Jdas_Mbic.Function
266 271
             }
267 272
             return (byte)crc;
268 273
         }
269
-
274
+        
270 275
     }
271 276
 }

+ 24 - 12
Jdas_Mbic/Jdas_Mbic.csproj

@@ -47,9 +47,23 @@
47 47
     <Reference Include="System.Xml" />
48 48
   </ItemGroup>
49 49
   <ItemGroup>
50
-    <Compile Include="Function\CRC16.cs" />
51
-    <Compile Include="Function\Data_Handler.cs" />
52
-    <Compile Include="Function\Update_Serial.cs" />
50
+    <Compile Include="Debug.cs">
51
+      <SubType>Form</SubType>
52
+    </Compile>
53
+    <Compile Include="Debug.designer.cs">
54
+      <DependentUpon>Debug.cs</DependentUpon>
55
+    </Compile>
56
+    <Compile Include="Download_bar.cs">
57
+      <SubType>Form</SubType>
58
+    </Compile>
59
+    <Compile Include="Download_bar.designer.cs">
60
+      <DependentUpon>Download_bar.cs</DependentUpon>
61
+    </Compile>
62
+    <Compile Include="Func\Bluecell_BootProtocol.cs" />
63
+    <Compile Include="Func\Crc16.cs" />
64
+    <Compile Include="Func\Data_Handler.cs" />
65
+    <Compile Include="Func\Serial.cs" />
66
+    <Compile Include="Func\Update_Serial.cs" />
53 67
     <Compile Include="Main.cs">
54 68
       <SubType>Form</SubType>
55 69
     </Compile>
@@ -58,12 +72,12 @@
58 72
     </Compile>
59 73
     <Compile Include="Program.cs" />
60 74
     <Compile Include="Properties\AssemblyInfo.cs" />
61
-    <Compile Include="Terminal.cs">
62
-      <SubType>Form</SubType>
63
-    </Compile>
64
-    <Compile Include="Terminal.Designer.cs">
65
-      <DependentUpon>Terminal.cs</DependentUpon>
66
-    </Compile>
75
+    <EmbeddedResource Include="Debug.resx">
76
+      <DependentUpon>Debug.cs</DependentUpon>
77
+    </EmbeddedResource>
78
+    <EmbeddedResource Include="Download_bar.resx">
79
+      <DependentUpon>Download_bar.cs</DependentUpon>
80
+    </EmbeddedResource>
67 81
     <EmbeddedResource Include="Main.resx">
68 82
       <DependentUpon>Main.cs</DependentUpon>
69 83
     </EmbeddedResource>
@@ -77,9 +91,6 @@
77 91
       <DependentUpon>Resources.resx</DependentUpon>
78 92
       <DesignTime>True</DesignTime>
79 93
     </Compile>
80
-    <EmbeddedResource Include="Terminal.resx">
81
-      <DependentUpon>Terminal.cs</DependentUpon>
82
-    </EmbeddedResource>
83 94
     <None Include="Properties\Settings.settings">
84 95
       <Generator>SettingsSingleFileGenerator</Generator>
85 96
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -114,5 +125,6 @@
114 125
   <ItemGroup>
115 126
     <None Include="Resources\TX_Red_Image.png" />
116 127
   </ItemGroup>
128
+  <ItemGroup />
117 129
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
118 130
 </Project>

+ 105 - 2
Jdas_Mbic/Main.Designer.cs

@@ -39,6 +39,8 @@
39 39
             this.pictureBox26 = new System.Windows.Forms.PictureBox();
40 40
             this.pictureBox27 = new System.Windows.Forms.PictureBox();
41 41
             this.groupBox5 = new System.Windows.Forms.GroupBox();
42
+            this.button_UL3 = new System.Windows.Forms.Button();
43
+            this.button_DL3 = new System.Windows.Forms.Button();
42 44
             this.label19 = new System.Windows.Forms.Label();
43 45
             this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
44 46
             this.label20 = new System.Windows.Forms.Label();
@@ -55,6 +57,8 @@
55 57
             this.pictureBox23 = new System.Windows.Forms.PictureBox();
56 58
             this.label25 = new System.Windows.Forms.Label();
57 59
             this.groupBox2 = new System.Windows.Forms.GroupBox();
60
+            this.button_UL4 = new System.Windows.Forms.Button();
61
+            this.button_DL4 = new System.Windows.Forms.Button();
58 62
             this.label1 = new System.Windows.Forms.Label();
59 63
             this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
60 64
             this.label2 = new System.Windows.Forms.Label();
@@ -71,6 +75,8 @@
71 75
             this.pictureBox11 = new System.Windows.Forms.PictureBox();
72 76
             this.label8 = new System.Windows.Forms.Label();
73 77
             this.groupBox1 = new System.Windows.Forms.GroupBox();
78
+            this.button_UL1 = new System.Windows.Forms.Button();
79
+            this.button_DL1 = new System.Windows.Forms.Button();
74 80
             this.label3 = new System.Windows.Forms.Label();
75 81
             this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
76 82
             this.label9 = new System.Windows.Forms.Label();
@@ -87,6 +93,8 @@
87 93
             this.pictureBox25 = new System.Windows.Forms.PictureBox();
88 94
             this.label28 = new System.Windows.Forms.Label();
89 95
             this.groupBox4 = new System.Windows.Forms.GroupBox();
96
+            this.button_UL2 = new System.Windows.Forms.Button();
97
+            this.button_DL2 = new System.Windows.Forms.Button();
90 98
             this.label12 = new System.Windows.Forms.Label();
91 99
             this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
92 100
             this.label13 = new System.Windows.Forms.Label();
@@ -149,7 +157,6 @@
149 157
             this.dataGridView_TableSetting = new System.Windows.Forms.DataGridView();
150 158
             this.Column_DB = new System.Windows.Forms.DataGridViewTextBoxColumn();
151 159
             this.Column_Offset = new System.Windows.Forms.DataGridViewTextBoxColumn();
152
-            this.serialPort_JdasMbic = new System.IO.Ports.SerialPort(this.components);
153 160
             this.timer_JdasMbic = new System.Windows.Forms.Timer(this.components);
154 161
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
155 162
             this.tabControl1.SuspendLayout();
@@ -303,6 +310,8 @@
303 310
             // 
304 311
             // groupBox5
305 312
             // 
313
+            this.groupBox5.Controls.Add(this.button_UL3);
314
+            this.groupBox5.Controls.Add(this.button_DL3);
306 315
             this.groupBox5.Controls.Add(this.label19);
307 316
             this.groupBox5.Controls.Add(this.numericUpDown6);
308 317
             this.groupBox5.Controls.Add(this.label20);
@@ -325,6 +334,26 @@
325 334
             this.groupBox5.TabStop = false;
326 335
             this.groupBox5.Text = "TRX3";
327 336
             // 
337
+            // button_UL3
338
+            // 
339
+            this.button_UL3.Location = new System.Drawing.Point(254, 97);
340
+            this.button_UL3.Name = "button_UL3";
341
+            this.button_UL3.Size = new System.Drawing.Size(53, 23);
342
+            this.button_UL3.TabIndex = 144;
343
+            this.button_UL3.Text = "Apply";
344
+            this.button_UL3.UseVisualStyleBackColor = true;
345
+            this.button_UL3.Click += new System.EventHandler(this.button_UL3_Click);
346
+            // 
347
+            // button_DL3
348
+            // 
349
+            this.button_DL3.Location = new System.Drawing.Point(254, 75);
350
+            this.button_DL3.Name = "button_DL3";
351
+            this.button_DL3.Size = new System.Drawing.Size(53, 23);
352
+            this.button_DL3.TabIndex = 145;
353
+            this.button_DL3.Text = "Apply";
354
+            this.button_DL3.UseVisualStyleBackColor = true;
355
+            this.button_DL3.Click += new System.EventHandler(this.button_DL3_Click);
356
+            // 
328 357
             // label19
329 358
             // 
330 359
             this.label19.AutoSize = true;
@@ -501,6 +530,8 @@
501 530
             // 
502 531
             // groupBox2
503 532
             // 
533
+            this.groupBox2.Controls.Add(this.button_UL4);
534
+            this.groupBox2.Controls.Add(this.button_DL4);
504 535
             this.groupBox2.Controls.Add(this.label1);
505 536
             this.groupBox2.Controls.Add(this.numericUpDown1);
506 537
             this.groupBox2.Controls.Add(this.label2);
@@ -523,6 +554,26 @@
523 554
             this.groupBox2.TabStop = false;
524 555
             this.groupBox2.Text = "TRX4";
525 556
             // 
557
+            // button_UL4
558
+            // 
559
+            this.button_UL4.Location = new System.Drawing.Point(254, 97);
560
+            this.button_UL4.Name = "button_UL4";
561
+            this.button_UL4.Size = new System.Drawing.Size(53, 23);
562
+            this.button_UL4.TabIndex = 146;
563
+            this.button_UL4.Text = "Apply";
564
+            this.button_UL4.UseVisualStyleBackColor = true;
565
+            this.button_UL4.Click += new System.EventHandler(this.button_UL4_Click);
566
+            // 
567
+            // button_DL4
568
+            // 
569
+            this.button_DL4.Location = new System.Drawing.Point(254, 75);
570
+            this.button_DL4.Name = "button_DL4";
571
+            this.button_DL4.Size = new System.Drawing.Size(53, 23);
572
+            this.button_DL4.TabIndex = 147;
573
+            this.button_DL4.Text = "Apply";
574
+            this.button_DL4.UseVisualStyleBackColor = true;
575
+            this.button_DL4.Click += new System.EventHandler(this.button_DL4_Click);
576
+            // 
526 577
             // label1
527 578
             // 
528 579
             this.label1.AutoSize = true;
@@ -699,6 +750,8 @@
699 750
             // 
700 751
             // groupBox1
701 752
             // 
753
+            this.groupBox1.Controls.Add(this.button_UL1);
754
+            this.groupBox1.Controls.Add(this.button_DL1);
702 755
             this.groupBox1.Controls.Add(this.label3);
703 756
             this.groupBox1.Controls.Add(this.numericUpDown3);
704 757
             this.groupBox1.Controls.Add(this.label9);
@@ -721,6 +774,26 @@
721 774
             this.groupBox1.TabStop = false;
722 775
             this.groupBox1.Text = "TRX1";
723 776
             // 
777
+            // button_UL1
778
+            // 
779
+            this.button_UL1.Location = new System.Drawing.Point(254, 96);
780
+            this.button_UL1.Name = "button_UL1";
781
+            this.button_UL1.Size = new System.Drawing.Size(53, 23);
782
+            this.button_UL1.TabIndex = 143;
783
+            this.button_UL1.Text = "Apply";
784
+            this.button_UL1.UseVisualStyleBackColor = true;
785
+            this.button_UL1.Click += new System.EventHandler(this.button_UL1_Click);
786
+            // 
787
+            // button_DL1
788
+            // 
789
+            this.button_DL1.Location = new System.Drawing.Point(254, 74);
790
+            this.button_DL1.Name = "button_DL1";
791
+            this.button_DL1.Size = new System.Drawing.Size(53, 23);
792
+            this.button_DL1.TabIndex = 143;
793
+            this.button_DL1.Text = "Apply";
794
+            this.button_DL1.UseVisualStyleBackColor = true;
795
+            this.button_DL1.Click += new System.EventHandler(this.button_DL1_Click);
796
+            // 
724 797
             // label3
725 798
             // 
726 799
             this.label3.AutoSize = true;
@@ -897,6 +970,8 @@
897 970
             // 
898 971
             // groupBox4
899 972
             // 
973
+            this.groupBox4.Controls.Add(this.button_UL2);
974
+            this.groupBox4.Controls.Add(this.button_DL2);
900 975
             this.groupBox4.Controls.Add(this.label12);
901 976
             this.groupBox4.Controls.Add(this.numericUpDown4);
902 977
             this.groupBox4.Controls.Add(this.label13);
@@ -919,6 +994,26 @@
919 994
             this.groupBox4.TabStop = false;
920 995
             this.groupBox4.Text = "TRX2";
921 996
             // 
997
+            // button_UL2
998
+            // 
999
+            this.button_UL2.Location = new System.Drawing.Point(254, 96);
1000
+            this.button_UL2.Name = "button_UL2";
1001
+            this.button_UL2.Size = new System.Drawing.Size(53, 23);
1002
+            this.button_UL2.TabIndex = 144;
1003
+            this.button_UL2.Text = "Apply";
1004
+            this.button_UL2.UseVisualStyleBackColor = true;
1005
+            this.button_UL2.Click += new System.EventHandler(this.button_UL2_Click);
1006
+            // 
1007
+            // button_DL2
1008
+            // 
1009
+            this.button_DL2.Location = new System.Drawing.Point(254, 74);
1010
+            this.button_DL2.Name = "button_DL2";
1011
+            this.button_DL2.Size = new System.Drawing.Size(53, 23);
1012
+            this.button_DL2.TabIndex = 145;
1013
+            this.button_DL2.Text = "Apply";
1014
+            this.button_DL2.UseVisualStyleBackColor = true;
1015
+            this.button_DL2.Click += new System.EventHandler(this.button_DL2_Click);
1016
+            // 
922 1017
             // label12
923 1018
             // 
924 1019
             this.label12.AutoSize = true;
@@ -1665,6 +1760,7 @@
1665 1760
             // 
1666 1761
             // timer_JdasMbic
1667 1762
             // 
1763
+            this.timer_JdasMbic.Interval = 500;
1668 1764
             this.timer_JdasMbic.Tick += new System.EventHandler(this.timer1_Tick);
1669 1765
             // 
1670 1766
             // JdasMbic
@@ -1870,7 +1966,14 @@
1870 1966
         public System.Windows.Forms.Label label33;
1871 1967
         public System.Windows.Forms.PictureBox pictureBox26;
1872 1968
         public System.Windows.Forms.PictureBox pictureBox27;
1873
-        public System.IO.Ports.SerialPort serialPort_JdasMbic;
1969
+        private System.Windows.Forms.Button button_UL1;
1970
+        private System.Windows.Forms.Button button_DL1;
1971
+        private System.Windows.Forms.Button button_UL3;
1972
+        private System.Windows.Forms.Button button_DL3;
1973
+        private System.Windows.Forms.Button button_UL4;
1974
+        private System.Windows.Forms.Button button_DL4;
1975
+        private System.Windows.Forms.Button button_UL2;
1976
+        private System.Windows.Forms.Button button_DL2;
1874 1977
     }
1875 1978
 }
1876 1979
 

+ 131 - 72
Jdas_Mbic/Main.cs

@@ -1,4 +1,6 @@
1
-using System;
1
+
2
+
3
+using System;
2 4
 using System.Collections.Generic;
3 5
 using System.ComponentModel;
4 6
 using System.Data;
@@ -18,7 +20,7 @@ namespace Jdas_Mbic
18 20
         const int Table_DL_DefaultValue = 5;
19 21
         const int Table_UL_DefaultValue = -15;
20 22
         const int Table_Temp_DefaultValue = -10;
21
-
23
+        Serial serial = new Serial(); // Uart Open
22 24
         enum DLUL_Category
23 25
         {
24 26
             DL_DET = 0,
@@ -34,7 +36,8 @@ namespace Jdas_Mbic
34 36
         private void JdasMbic_Load(object sender, EventArgs e)
35 37
         {
36 38
             ATT_TableLayoutSetting();
37
-            Serial_Initialize(ref comboBox_Port); // Uart SerialPort Find Init
39
+            serial.Serial_Initialize(ref comboBox_Port);
40
+
38 41
         }
39 42
         
40 43
         private void ATT_TableLayoutSetting()
@@ -87,7 +90,6 @@ namespace Jdas_Mbic
87 90
                         tempstr = string.Format("{0:0}", Temp_UL_Data);
88 91
                         dataGridView_TableSetting[0, i].Value = Convert.ToString(tempstr) + " dBm";
89 92
                         Temp_UL_Data = Temp_UL_Data - 1;
90
-
91 93
                     }
92 94
                     break;
93 95
             }
@@ -282,7 +284,7 @@ namespace Jdas_Mbic
282 284
         private void button_PortOpen_Click(object sender, EventArgs e)
283 285
         {
284 286
             bool ret = false;
285
-            ret = Serial_connectiondisable(Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
287
+            ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
286 288
             if (ret == false && timer_JdasMbic.Enabled == false)
287 289
             {
288 290
                 timer_JdasMbic.Start(); //타이머를 발동시킨다.
@@ -295,88 +297,29 @@ namespace Jdas_Mbic
295 297
             {
296 298
                 /*NOP*/
297 299
             }
298
-            //serial.Serial_Main_Form_Get(this);
300
+            serial.Serial_Main_Form_Get(this);
299 301
         }
300 302
 
301 303
         private void button_terminal_Click(object sender, EventArgs e)
302 304
         {
303
-            Terminal tml = new Terminal();
304
-            tml.Show();
305
-        }
306
-        public void Serial_Initialize(ref ComboBox cb_port)
307
-        {
308
-            Serial_Init();
309
-        }
310
-        public void Serial_Init()
311
-        {
312
-            this.serialPort_JdasMbic = new System.IO.Ports.SerialPort();
313
-            this.serialPort_JdasMbic.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.sPort_DataReceived);
314
-
315
-            comboBox_Port.BeginUpdate();
316
-            foreach (string comport in SerialPort.GetPortNames())//foreach (string comport in SerialPort_TestProgram.GetPortNames())
317
-            {
318
-                comboBox_Port.Items.Add(comport);
319
-            }
320
-            comboBox_Port.EndUpdate();
321
-            //SerialPort 초기 설정.
322
-            //  serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
323
-            comboBox_Port.DataSource = SerialPort.GetPortNames();
324
-            try
325
-            {
326
-                serialPort_JdasMbic.PortName = comboBox_Port.SelectedItem.ToString();
327
-                serialPort_JdasMbic.BaudRate = (int)115200;
328
-                serialPort_JdasMbic.DataBits = (int)8;
329
-                serialPort_JdasMbic.Parity = System.IO.Ports.Parity.None;
330
-                serialPort_JdasMbic.StopBits = StopBits.One;
331
-            }
332
-            catch { }
305
+            serial.Serial_TerminalOpen(serial);
333 306
         }
307
+        
308
+       
334 309
         public bool Serial_connectiondisable(Boolean on_off)
335 310
         {
336 311
             comboBox_Port.Enabled = on_off;
337 312
             comboBox_baudrate.Enabled = on_off;
338 313
             return on_off;
339 314
         }
340
-        public Boolean Serial_PortOpen(ref Button Btn_Portonoff, ref ComboBox cb)
341
-        {
342
-            Boolean ret = false;
343
-            try
344
-            {
345
-                if (serialPort_JdasMbic.IsOpen)
346
-                { //When the port is open
347
-                    serialPort_JdasMbic.Close();
348
-                    Btn_Portonoff.Text = "Port Open";
349
-                    ret = true;
350
-                }
351
-                else//When the port is close
352
-                {
353
-                    if (cb.Text != "")
354
-                    {
355
-                        serialPort_JdasMbic.Open();
356
-                        Btn_Portonoff.Text = "Port Close";
357
-                    //   Debug.Debug_Main_Form_Get(this.main_form);
358
-                    }
359
-                    else
360
-                    {
361
-                        MessageBox.Show("Port is not set");
362
-                        ret = true;
363
-                    }
364
-                }
365
-            }
366
-            catch
367
-            {
368
-                MessageBox.Show("already port open " + comboBox_Port.Text);
369
-
370
-            }
371
-            return ret;
372
-        }
315
+        public bool TX_RX_Light = false;
373 316
         private delegate void StringSend(string Text);
374 317
         private delegate void GridviewSend(ref object gridview, string Text);
375 318
         private delegate void ByteSend(byte[] Text);
376 319
 
377 320
         int offset = 0;
378 321
         byte[] rxBuffer;
379
-
322
+#if false
380 323
         private void sPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
381 324
         {
382 325
             string startStr = "V";
@@ -458,6 +401,8 @@ namespace Jdas_Mbic
458 401
             catch { }
459 402
 
460 403
         }
404
+#endif
405
+
461 406
         int LineLimit = 500;
462 407
         [DllImport("user32.dll")]
463 408
         public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
@@ -555,10 +500,47 @@ namespace Jdas_Mbic
555 500
             }
556 501
             catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
557 502
         }
503
+        Int64 Timer_Cnt = 0;
504
+        Int32 ReqTimer_Cnt = 0;
558 505
 
559 506
         private void timer1_Tick(object sender, EventArgs e)
560 507
         {
561
-
508
+            Update_Serial update_Serial = null;
509
+            bool req_set = false;
510
+            if (update_Serial == null)
511
+            {
512
+                update_Serial = (Update_Serial)serial.FileDownloadClass_Get();
513
+                if (update_Serial == null)
514
+                    req_set = true;
515
+                else if (update_Serial.Update_ready == false)
516
+                    req_set = true;
517
+            }
518
+            if (req_set)
519
+            {
520
+                ReqTimer_Cnt++;
521
+            }
522
+            if (TX_RX_Light == true)
523
+            {
524
+                Timer_Cnt++;
525
+            }
526
+            if (Timer_Cnt < 1000)
527
+            {
528
+                if (this.pictureBox_G_TX.Visible == true)
529
+                {
530
+                    TX_Light_OFF();
531
+                }
532
+                if (this.pictureBox_G_RX.Visible == true)
533
+                {
534
+                    RX_Light_OFF();
535
+                }
536
+                Timer_Cnt = 0;
537
+                TX_RX_Light = false;
538
+            }
539
+            if (ReqTimer_Cnt > 6)
540
+            {
541
+                // bluecell_BootProtocol.Bluecell_RF_Status_Req(serial);
542
+                ReqTimer_Cnt = 0;
543
+            }
562 544
         }
563 545
 
564 546
         private void radioButton_ATT_CheckedChanged(object sender, EventArgs e)
@@ -598,8 +580,85 @@ namespace Jdas_Mbic
598 580
         {
599 581
 
600 582
         }
601
-
583
+        Update_Serial file = new Update_Serial();
602 584
         private void button_FirmwareUpdate_Click(object sender, EventArgs e)
585
+        {
586
+            OpenFileDialog ofd = new OpenFileDialog();
587
+            //FileDownload file = new FileDownload();
588
+            if (setcheck_checkBox.Checked == true)
589
+                setcheck_checkBox.Checked = false;
590
+            file.ShowFileOpenDialog(ref serial, ofd);
591
+        }
592
+        public void TX_Light_ON()
593
+        {
594
+            this.pictureBox_G_TX.Visible = true;
595
+            this.pictureBox_R_TX.Visible = false;
596
+        }
597
+        public void TX_Light_OFF()
598
+        {
599
+            this.pictureBox_R_TX.Visible = true;
600
+            this.pictureBox_G_TX.Visible = false;
601
+        }
602
+        public void RX_Light_ON()
603
+        {
604
+            this.pictureBox_G_RX.Visible = true;
605
+            this.pictureBox_R_RX.Visible = false;
606
+        }
607
+        public void RX_Light_OFF()
608
+        {
609
+            this.pictureBox_R_RX.Visible = true;
610
+            this.pictureBox_G_RX.Visible = false;
611
+        }
612
+        const byte BLUECELL_RESET_LENGTH = 7;
613
+        public const byte BLUECELL_HEADER = 0xBE;
614
+        public const byte BLUECELL_TAILER = 0xEB;
615
+
616
+        private void button_DL1_Click(object sender, EventArgs e)
617
+        {
618
+     
619
+            byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
620
+
621
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header]   = BLUECELL_HEADER;
622
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type]     = 0x01;
623
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length]   = 6;
624
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = 5;
625
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data]     = 1;
626
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = 1;
627
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 2] = 1;
628
+            serial.Serial_DataSend(temp_buf, temp_buf.Length);
629
+        }
630
+
631
+        private void button_UL1_Click(object sender, EventArgs e)
632
+        {
633
+
634
+        }
635
+
636
+        private void button_DL3_Click(object sender, EventArgs e)
637
+        {
638
+
639
+        }
640
+
641
+        private void button_UL3_Click(object sender, EventArgs e)
642
+        {
643
+
644
+        }
645
+
646
+        private void button_DL4_Click(object sender, EventArgs e)
647
+        {
648
+
649
+        }
650
+
651
+        private void button_UL4_Click(object sender, EventArgs e)
652
+        {
653
+
654
+        }
655
+
656
+        private void button_DL2_Click(object sender, EventArgs e)
657
+        {
658
+
659
+        }
660
+
661
+        private void button_UL2_Click(object sender, EventArgs e)
603 662
         {
604 663
 
605 664
         }

+ 6 - 3
Jdas_Mbic/Main.resx

@@ -1359,10 +1359,13 @@
1359 1359
   <metadata name="Column_Offset.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
1360 1360
     <value>True</value>
1361 1361
   </metadata>
1362
-  <metadata name="serialPort_JdasMbic.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
1363
-    <value>17, 17</value>
1362
+  <metadata name="Column_DB.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
1363
+    <value>True</value>
1364
+  </metadata>
1365
+  <metadata name="Column_Offset.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
1366
+    <value>True</value>
1364 1367
   </metadata>
1365 1368
   <metadata name="timer_JdasMbic.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
1366
-    <value>177, 17</value>
1369
+    <value>27, 11</value>
1367 1370
   </metadata>
1368 1371
 </root>

BIN
Jdas_Mbic/bin/Debug/Jdas_Mbic.exe


BIN
Jdas_Mbic/bin/Debug/Jdas_Mbic.pdb


BIN
Jdas_Mbic/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


Jdas_Mbic/obj/Debug/Jdas_Mbic.Terminal.resources → Jdas_Mbic/obj/Debug/Jdas_Mbic.Debug.resources


BIN
Jdas_Mbic/obj/Debug/Jdas_Mbic.Download_bar.resources


+ 1 - 1
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
1
-c5715ee6603524e81f8c9e064b293d8a0d06fab0
1
+53dbdbd66ae0861e92a7b6562dbfd2841fa8ad91

+ 2 - 1
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.FileListAbsolute.txt

@@ -19,4 +19,5 @@ G:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.exe
19 19
 G:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.pdb
20 20
 G:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.Terminal.resources
21 21
 D:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.JdasMbic.resources
22
-D:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.Terminal.resources
22
+D:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.Debug.resources
23
+D:\C#\Jdas_Mbic\Jdas_Mbic\obj\Debug\Jdas_Mbic.Download_bar.resources

BIN
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.GenerateResource.cache


BIN
Jdas_Mbic/obj/Debug/Jdas_Mbic.exe


BIN
Jdas_Mbic/obj/Debug/Jdas_Mbic.pdb