예제 #1
0
        public frmOpcServer()
        {
            InitializeComponent();
            mngr = new OpcManager();

            server=Persistence.Read<OPCServer>(new Condition[]{new Condition("Aktif",Operator.Equal,true)});
            if (server != null)
            {
                OPCServerGroup[] groups = OPCServer.ReadGroups(server.Id);
                server.Groups.AddRange(groups);
                dataGridView1.DataSource = server.Groups;
                textBoxServerIsmi.Text = server.OpcServerName;
                textBoxOPCNodeIsmi.Text = server.OPCNodeName;
            }
            else
                server = new OPCServer();

            dataGridView1.SetGridStyle(
            @"<Style>
                    <Column Name='Id'                       HeaderText='Id'                                 Width='100'   DisplayIndex='0'    Visible='false'                                         />
                    <Column Name='OPCGroupName'             HeaderText='OPCGroupName'                       Width='100'   DisplayIndex='1'    Visible='true'                                         />
                    <Column Name='GroupUpdateRate'          HeaderText='GroupUpdateRate'                    Width='100' DisplayIndex='2'    Visible='true'                                          />
                    <Column Name='GroupDeadBand'            HeaderText='GroupDeadBand'                      Width='100' DisplayIndex='3'    Visible='true'                                          />
                    <Column Name='GroupActiveState'         HeaderText='GroupActiveState'                   Width='100' DisplayIndex='4'    Visible='true'    Type ='CheckBox'                      />
            </Style>");
        }
예제 #2
0
        protected void InitdataControl()
        {
            DataColumn OkunanDeger = new DataColumn("OkunanDeger", typeof(string));
            DataColumn YazilacakDeger = new DataColumn("YazilacakDeger", typeof(string));
            DataColumn YazButonu = new DataColumn("YazButonu");

            DataColumn OkunanDeger1 = new DataColumn("OkunanDeger", typeof(string));
            DataColumn YazilacakDeger1 = new DataColumn("YazilacakDeger", typeof(string));
            DataColumn YazButonu1 = new DataColumn("YazButonu");

            Adresler.Columns.Add(OkunanDeger);
            Adresler.Columns.Add(YazilacakDeger);
            Adresler.Columns.Add(YazButonu);
            AlarmAdresleri.Columns.Add(OkunanDeger1);
            AlarmAdresleri.Columns.Add(YazilacakDeger1);
            AlarmAdresleri.Columns.Add(YazButonu1);

            GridAdresler.SetGridStyle(
             @"<Style>
                    <Column Name='Id'             HeaderText='Id'             Width='0'     DisplayIndex='0'   Visible='false' />
                    <Column Name='Adres_Id'       HeaderText='Adres_Id'       Width='0'     DisplayIndex='1'   Visible='false' />
                    <Column Name='TagAdresi'      HeaderText='TagAdresi'      Width='100'   DisplayIndex='2'   Visible='true'  Type ='Button' Text='Adres Seç'/>
                    <Column Name='Formul'         HeaderText='Formül'         Width='100'   DisplayIndex='3'   Visible='true'  />
                    <Column Name='AdresTipi'      HeaderText='Adres Tipi'     Width='100'   DisplayIndex='4'   Visible='true'  Type ='ComboBox' />
                    <Column Name='Davranis'       HeaderText='Davranış'       Width='100'   DisplayIndex='5'   Visible='true'  Type ='ComboBox' />
                    <Column Name='IsLogTutulsun'  HeaderText='IsLogTutulsun'  Width='100'   DisplayIndex='6'   Visible='true'  Type ='Checkbox' />
                    <Column Name='OkunanDeger'    HeaderText='OkunanDeger'    Width='100'   DisplayIndex='7'   Visible='true'  />
                    <Column Name='YazilacakDeger' HeaderText='YazilacakDeger' Width='100'   DisplayIndex='8'   Visible='true'  />
                    <Column Name='YazButonu'      HeaderText='Değeri Set Et'      Width='100'   DisplayIndex='9'   Visible='true'  Type ='Button' Text='Değeri Set Et' ShowButtonMode='ShowAlways'/>
                   <Column Name='TagDeğeriniOku'        HeaderText='Tag Değerini Oku'           Width='100' DisplayIndex='12'   Visible='true'  Type ='Button' Text='Tag Değerini Oku'    ShowButtonMode='ShowAlways' />
                </Style>");

            gridAlarmAdresler.SetGridStyle(
             @"<Style>
                    <Column Name='Id'               HeaderText='Id'                         Width='0'   DisplayIndex='0'    Visible='false'                                         />
                    <Column Name='Adres_Id'         HeaderText='Adres_Id'                   Width='0'   DisplayIndex='1'    Visible='false'                                         />
                    <Column Name='TagAdresi'        HeaderText='TagAdresi'                  Width='100' DisplayIndex='2'    Visible='true'    Type ='Button' Text='Adres Seç'       />
                    <Column Name='Formul'           HeaderText='Formül'                     Width='100' DisplayIndex='3'    Visible='true'                                          />
                    <Column Name='AlarmTipi'        HeaderText='Alarm Tipi'                 Width='100' DisplayIndex='4'    Visible='true'    Type ='ComboBox'                      />
                    <Column Name='DataTipi1'        HeaderText='Data Tipi'                  Width='100' DisplayIndex='5'    Visible='true'    Type ='ComboBox'                      />
                    <Column Name='AlarmMesaji'      HeaderText='Alarm Mesajı'               Width='100' DisplayIndex='6'    Visible='true'                                          />
                    <Column Name='SesAcik'          HeaderText='SesAcik'                    Width='100' DisplayIndex='7'    Visible='true'    Type ='Checkbox'                      />
                    <Column Name='SesDosyasiAdresi' HeaderText='SesDosyasiAdresi'           Width='100' DisplayIndex='8'    Visible='true'                                          />
                    <Column Name='IsLogTutulsun1'   HeaderText='IsLogTutulsun'              Width='100' DisplayIndex='9'    Visible='true'    Type ='Checkbox'                      />
                    <Column Name='OkunanDeger'      HeaderText='OkunanDeger'                Width='100' DisplayIndex='10'   Visible='true'                                          />
                    <Column Name='YazilacakDeger'   HeaderText='YazilacakDeger'             Width='100' DisplayIndex='11'   Visible='true'                                          />
                    <Column Name='YazButonu'        HeaderText='Değeri Set Et'              Width='100' DisplayIndex='12'   Visible='true'  Type ='Button' Text='Değeri Set Et'       ShowButtonMode='ShowAlways' />
                    <Column Name='TagDeğeriniOku'   HeaderText='Tag Değerini Oku'           Width='100' DisplayIndex='12'   Visible='true'  Type ='Button' Text='Tag Değerini Oku'    ShowButtonMode='ShowAlways' />
                    <Column Name='RsKodu'           HeaderText='Rs Kodu'                    Width='100' DisplayIndex='13'   Visible='true'    Type ='Button' Text='RS Kodu'       />
                    <Column Name='RSKodu_Id'        HeaderText='RSKodu_Id'                  Width='0'   DisplayIndex='14'   Visible='false'                                       />
            </Style>");

            string[] names = Enum.GetNames(typeof(mymodel.myenum.Davranis));
            foreach (string str in names)
            {
                ((RepositoryItemComboBox)gridView1.Columns["Davranis"].ColumnEdit).Items.Add(str);
            }
            names = null;
            names = Enum.GetNames(typeof(mymodel.myenum.AdresTipi));
            foreach (string str in names)
            {
                ((RepositoryItemComboBox)gridView1.Columns["AdresTipi"].ColumnEdit).Items.Add(str);
            }

            gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            gridadres = new GridEditButtonManager(GridAdresler, new ActionAdresListesi(),
            new string[] { "Adres_Id", "TagAdresi" }, new string[] { "Id", "TagAdresi" }, true);

            names = Enum.GetNames(typeof(mymodel.myenum.AlarmTipi));
            foreach (string str in names)
            {
                ((RepositoryItemComboBox)gridViewAlarmAdresler.Columns["AlarmTipi"].ColumnEdit).Items.Add(str);
            }
            names = null;
            names = Enum.GetNames(typeof(mymodel.myenum.MappedFieldType));
            foreach (string str in names)
            {
                ((RepositoryItemComboBox)gridViewAlarmAdresler.Columns["DataTipi1"].ColumnEdit).Items.Add(str);
            }

            gridViewAlarmAdresler.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            gridalarmadres = new GridEditButtonManager(gridAlarmAdresler, new ActionAdresListesi(),
            new string[] { "Adres_Id", "TagAdresi" }, new string[] { "Id", "TagAdresi" }, true);

            gridrskodu = new GridEditButtonManager(gridAlarmAdresler, new ActionLookupListesi(14),
            new string[] { "RSKodu_Id", "RsKodu" }, new string[] { "Id", "Kodu" }, true);

            RepositoryItemButtonEdit button = ((RepositoryItemButtonEdit)gridView1.Columns["YazButonu"].ColumnEdit);
            button.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            button.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(frmCihazTanim_ButtonClick);

            RepositoryItemButtonEdit button1 = ((RepositoryItemButtonEdit)gridViewAlarmAdresler.Columns["YazButonu"].ColumnEdit);
            button1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            button1.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(frmCihazTanim_ButtonClick1);

            RepositoryItemButtonEdit button2 = ((RepositoryItemButtonEdit)gridView1.Columns["TagDeğeriniOku"].ColumnEdit);
            button2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            button2.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(frmCihazTanim_ButtonClick2);

            RepositoryItemButtonEdit button3 = ((RepositoryItemButtonEdit)gridViewAlarmAdresler.Columns["TagDeğeriniOku"].ColumnEdit);
            button3.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            button3.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(frmCihazTanim_ButtonClick3);

            opcserver = Persistence.Read<OPCServer>(new Condition("Aktif", Operator.Equal, 1));
            if (opcserver != null && opcserver.Id > 0)
            {
                OPCServerGroup groups = OPCServer.ReadGroups(opcserver.Id, editButtonLokasyon.Text);
                if (groups != null)
                {
                    opcserver.Groups.Add(groups);
                }
                else
                {
                    MessageBox.Show("Hata:Bu Lokasyona ait OPCServerGroup ismi boş !!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Hata:OPCServer Kaydı Bulunamadı. OPCServer Kayıt Ekranında gerekli tanımlamayı yapabilirsiniz.!!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }