프로젝트

일반

사용자정보

개정판 dd624cbd

IDdd624cbd21f310783a78560ad2c6c26073accf57
상위 387b3bc0
하위 da688620, cf505947, ecd39237

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #1227 : fix MappingForm for opc

Change-Id: Icb5ca040676e1064cb7a8d6be4ee8fdf3fa336d2

차이점 보기:

DTI_PID/APIDConverter/DB/Project_DB.cs
81 81
                                    }
82 82
                                    if (dt.Select(string.Format("NAME = '{0}'", APID_OPC_MAPPING_TABLE)).Length == 0)
83 83
                                    {
84
                                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, IN_SYMBOL TEXT, OUT_SYMBOL TEXT, Type INT)", APID_OPC_MAPPING_TABLE);
84
                                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, IN_SYMBOL TEXT, OUT_SYMBOL TEXT, FlowType INT)", APID_OPC_MAPPING_TABLE);
85 85
                                        cmd.ExecuteNonQuery();
86 86
                                    }
87 87
                                }
......
123 123
                                    }
124 124
                                    if (dt.Select(string.Format("NAME = '{0}'", APID_OPC_MAPPING_TABLE)).Length == 0)
125 125
                                    {
126
                                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, IN_SYMBOL varchar(MAX), OUT_SYMBOL varchar(MAX), Type INT)", APID_OPC_MAPPING_TABLE);
126
                                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, IN_SYMBOL varchar(MAX), OUT_SYMBOL varchar(MAX), FlowType INT)", APID_OPC_MAPPING_TABLE);
127 127
                                        cmd.ExecuteNonQuery();
128 128
                                    }
129 129
                                }
......
226 226

  
227 227
            return dt;
228 228
        }
229
        public static DataTable GetOPCMappingTable()
230
        {
231
            DataTable dt = new DataTable();
232
            Project_Info projectInfo = Project_Info.GetInstance();
233
            if (projectInfo.DBType == ID2DB_Type.SQLite)
234
            {
235
                using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
236
                {
237
                    try
238
                    {
239
                        connection.Open();
240
                        using (SQLiteCommand cmd = connection.CreateCommand())
241
                        {
242
                            cmd.CommandText = string.Format(@"
243
                            SELECT s.UID, s.Name, st.Type, sp.IN_SYMBOL, sp.OUT_SYMBOL, sp.FlowType FROM {1} as st, {0} as s 
244
                                LEFT OUTER JOIN {2} as sp 
245
                                    ON s.UID = SP.UID 
246
                            WHERE s.SymbolType_UID = st.UID 
247
                            AND (st.Type = 'Instrument OPC''s' OR st.Type = 'Piping OPC''s') 
248
                            ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, APID_OPC_MAPPING_TABLE);
249
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
250
                                dt.Load(dr);
251
                        }
252
                        connection.Close();
253
                    }
254
                    catch (Exception ex)
255
                    {
256
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
257
                    }
258
                    finally
259
                    {
260
                        connection.Dispose();
261
                    }
262
                }
263
            }
264
            else if (projectInfo.DBType == ID2DB_Type.MSSQL)
265
            {
266
                using (SqlConnection connection = GetSqlConnection())
267
                {
268
                    try
269
                    {
270
                        if (connection != null && connection.State == ConnectionState.Open)
271
                        {
272
                            using (SqlCommand cmd = connection.CreateCommand())
273
                            {
274
                                cmd.CommandText = string.Format(@"
275
                            SELECT CONVERT(VARCHAR(255), s.UID) AS UID, s.Name, st.Type, sp.IN_SYMBOL, sp.OUT_SYMBOL, sp.FlowType FROM {1} as st, {0} as s 
276
                                LEFT OUTER JOIN {2} as sp 
277
                                    ON CONVERT(VARCHAR(255), s.UID) = CONVERT(VARCHAR(255), SP.UID)
278
                            WHERE s.SymbolType_UID = st.UID 
279
                            AND (st.Type = 'Instrument OPC''s' OR st.Type = 'Piping OPC''s') 
280
                            ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, APID_OPC_MAPPING_TABLE);
281
                                using (SqlDataReader dr = cmd.ExecuteReader())
282
                                    dt.Load(dr);
283
                            }
284
                            connection.Close();
285
                        }
286
                    }
287
                    catch (Exception ex)
288
                    {
289
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
290
                    }
291
                    finally
292
                    {
293
                        if (connection != null)
294
                            connection.Dispose();
295
                    }
296
                }
297
            }
298

  
299
            return dt;
300
        }
229 301
        public static DataTable GetLineMappingTable()
230 302
        {
231 303
            DataTable dt = new DataTable();
DTI_PID/APIDConverter/Form/MappingForm.Designer.cs
29 29
        private void InitializeComponent()
30 30
        {
31 31
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MappingForm));
32
            DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup3 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
32
            DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup1 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
33 33
            this.ribbonControl = new DevExpress.XtraBars.Ribbon.RibbonControl();
34 34
            this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
35 35
            this.gridControlLine = new DevExpress.XtraGrid.GridControl();
......
70 70
            this.splitterItem4 = new DevExpress.XtraLayout.SplitterItem();
71 71
            this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
72 72
            this.GroupSpecificSymbol = new DevExpress.XtraLayout.LayoutControlGroup();
73
            this.gridControlOPC = new DevExpress.XtraGrid.GridControl();
74
            this.gridViewOPC = new DevExpress.XtraGrid.Views.Grid.GridView();
75
            this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
76
            this.layoutControlGroup2 = new DevExpress.XtraLayout.LayoutControlGroup();
77
            this.emptySpaceItem3 = new DevExpress.XtraLayout.EmptySpaceItem();
73 78
            ((System.ComponentModel.ISupportInitialize)(this.ribbonControl)).BeginInit();
74 79
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
75 80
            this.layoutControl1.SuspendLayout();
......
108 113
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem4)).BeginInit();
109 114
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
110 115
            ((System.ComponentModel.ISupportInitialize)(this.GroupSpecificSymbol)).BeginInit();
116
            ((System.ComponentModel.ISupportInitialize)(this.gridControlOPC)).BeginInit();
117
            ((System.ComponentModel.ISupportInitialize)(this.gridViewOPC)).BeginInit();
118
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
119
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).BeginInit();
120
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).BeginInit();
111 121
            this.SuspendLayout();
112 122
            // 
113 123
            // ribbonControl
......
127 137
            // 
128 138
            // layoutControl1
129 139
            // 
140
            this.layoutControl1.Controls.Add(this.gridControlOPC);
130 141
            this.layoutControl1.Controls.Add(this.gridControlLine);
131 142
            this.layoutControl1.Controls.Add(this.btnRefreshSymbol);
132 143
            this.layoutControl1.Controls.Add(this.galleryControlAvevaSymbols);
......
178 189
            // 
179 190
            // 
180 191
            // 
181
            galleryItemGroup3.Caption = "Items";
192
            galleryItemGroup1.Caption = "Items";
182 193
            this.galleryControlAvevaSymbols.Gallery.Groups.AddRange(new DevExpress.XtraBars.Ribbon.GalleryItemGroup[] {
183
            galleryItemGroup3});
194
            galleryItemGroup1});
184 195
            this.galleryControlAvevaSymbols.Gallery.ItemDoubleClick += new DevExpress.XtraBars.Ribbon.GalleryItemClickEventHandler(this.galleryControlAvevaSymbols_Gallery_ItemDoubleClick);
185 196
            this.galleryControlAvevaSymbols.Location = new System.Drawing.Point(795, 357);
186 197
            this.galleryControlAvevaSymbols.Name = "galleryControlAvevaSymbols";
......
297 308
            // 
298 309
            this.tabbedControlGroup.Location = new System.Drawing.Point(0, 0);
299 310
            this.tabbedControlGroup.Name = "tabbedControlGroup";
300
            this.tabbedControlGroup.SelectedTabPage = this.GroupSymbol;
311
            this.tabbedControlGroup.SelectedTabPage = this.GroupSpecificSymbol;
301 312
            this.tabbedControlGroup.Size = new System.Drawing.Size(761, 670);
302 313
            this.tabbedControlGroup.TabPages.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
303 314
            this.GroupSymbol,
......
508 519
            // 
509 520
            // GroupSpecificSymbol
510 521
            // 
522
            this.GroupSpecificSymbol.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
523
            this.layoutControlGroup2,
524
            this.emptySpaceItem3});
511 525
            this.GroupSpecificSymbol.Location = new System.Drawing.Point(0, 0);
512 526
            this.GroupSpecificSymbol.Name = "GroupSpecificSymbol";
513 527
            this.GroupSpecificSymbol.Size = new System.Drawing.Size(737, 624);
514 528
            this.GroupSpecificSymbol.Text = "Specific Symbol";
515 529
            // 
530
            // gridControlOPC
531
            // 
532
            this.gridControlOPC.Location = new System.Drawing.Point(36, 79);
533
            this.gridControlOPC.MainView = this.gridViewOPC;
534
            this.gridControlOPC.MenuManager = this.ribbonControl;
535
            this.gridControlOPC.Name = "gridControlOPC";
536
            this.gridControlOPC.Size = new System.Drawing.Size(709, 261);
537
            this.gridControlOPC.TabIndex = 14;
538
            this.gridControlOPC.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
539
            this.gridViewOPC});
540
            // 
541
            // gridViewOPC
542
            // 
543
            this.gridViewOPC.GridControl = this.gridControlOPC;
544
            this.gridViewOPC.Name = "gridViewOPC";
545
            this.gridViewOPC.OptionsView.ShowGroupPanel = false;
546
            // 
547
            // layoutControlItem10
548
            // 
549
            this.layoutControlItem10.Control = this.gridControlOPC;
550
            this.layoutControlItem10.Location = new System.Drawing.Point(0, 0);
551
            this.layoutControlItem10.Name = "layoutControlItem10";
552
            this.layoutControlItem10.Size = new System.Drawing.Size(713, 265);
553
            this.layoutControlItem10.TextSize = new System.Drawing.Size(0, 0);
554
            this.layoutControlItem10.TextVisible = false;
555
            // 
556
            // layoutControlGroup2
557
            // 
558
            this.layoutControlGroup2.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
559
            this.layoutControlItem10});
560
            this.layoutControlGroup2.Location = new System.Drawing.Point(0, 0);
561
            this.layoutControlGroup2.Name = "layoutControlGroup2";
562
            this.layoutControlGroup2.Size = new System.Drawing.Size(737, 310);
563
            this.layoutControlGroup2.Text = "OPC Symbol";
564
            // 
565
            // emptySpaceItem3
566
            // 
567
            this.emptySpaceItem3.AllowHotTrack = false;
568
            this.emptySpaceItem3.Location = new System.Drawing.Point(0, 310);
569
            this.emptySpaceItem3.Name = "emptySpaceItem3";
570
            this.emptySpaceItem3.Size = new System.Drawing.Size(737, 314);
571
            this.emptySpaceItem3.TextSize = new System.Drawing.Size(0, 0);
572
            // 
516 573
            // MappingForm
517 574
            // 
518 575
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
......
564 621
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem4)).EndInit();
565 622
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
566 623
            ((System.ComponentModel.ISupportInitialize)(this.GroupSpecificSymbol)).EndInit();
624
            ((System.ComponentModel.ISupportInitialize)(this.gridControlOPC)).EndInit();
625
            ((System.ComponentModel.ISupportInitialize)(this.gridViewOPC)).EndInit();
626
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
627
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).EndInit();
628
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).EndInit();
567 629
            this.ResumeLayout(false);
568 630
            this.PerformLayout();
569 631

  
......
611 673
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem9;
612 674
        private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup1;
613 675
        private DevExpress.XtraLayout.LayoutControlGroup GroupSpecificSymbol;
676
        private DevExpress.XtraGrid.GridControl gridControlOPC;
677
        private DevExpress.XtraGrid.Views.Grid.GridView gridViewOPC;
678
        private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup2;
679
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem10;
680
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem3;
614 681
    }
615 682
}
DTI_PID/APIDConverter/Form/MappingForm.cs
29 29
        {
30 30
            InitializeComponent();
31 31
            SetSymbolMappingTable();
32
            SetOPCMappingTable();
32 33
            SetAvevaSymbolStructure();
33 34
            SetLineMappingTable();
34 35

  
......
42 43
        }
43 44

  
44 45
        #region Init
45
        private bool SetSymbolMappingTable()
46
        private void SetSymbolMappingTable()
46 47
        {
47 48
            try
48 49
            {
......
72 73
            }
73 74
            catch (Exception ex)
74 75
            {
75
                return false;
76
                
76 77
            }
77

  
78
            return true;
78
        }
79
        private void SetOPCMappingTable()
80
        {
81
            DataTable dt = Project_DB.GetOPCMappingTable();
82

  
83
            gridControlOPC.DataSource = dt;
84
            gridViewOPC.Columns["UID"].Visible = false;
85
            gridViewOPC.Columns["IN_SYMBOL"].Caption = "IN OPC Symbol Name";
86
            gridViewOPC.Columns["OUT_SYMBOL"].Caption = "OUT OPC Symbol Name";
87
            gridViewOPC.Columns["Type"].GroupIndex = 0;
88
            gridViewOPC.Columns["IN_SYMBOL"].OptionsColumn.AllowEdit = false;
89
            gridViewOPC.Columns["OUT_SYMBOL"].OptionsColumn.AllowEdit = false;
90
            gridViewOPC.Columns["Name"].OptionsColumn.AllowEdit = false;
79 91
        }
80 92
        private void SetAvevaSymbolStructure()
81 93
        {

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)