Ejemplo n.º 1
0
        void frmCihazTanim_ButtonClick3(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            object adres = gridViewAlarmAdresler.GetRowCellValue(gridViewAlarmAdresler.FocusedRowHandle, "TagAdresi");

            if (adres != null && adres != string.Empty)
            {
                //OpcManager mngr;
                //OPCServer opcserver = Persistence.Read<OPCServer>(new Condition("Aktif", Operator.Equal, 1));
                //if (opcserver != null && opcserver.Id > 0)
                //{
                List <string> adreslist = new List <string>();
                adreslist.Add(adres.ToString());
                mngr = new OpcManager(opcserver.Groups[0].OPCGroupName, adreslist);
                mngr.OPCServerConnect(opcserver.OpcServerName, opcserver.OPCNodeName);
                //mngr.AddOpcGroupServer(opcserver.OPCGroupName, (opcserver.GroupUpdateRate), (opcserver.GroupActiveState), (float)opcserver.GroupDeadBand);
                mngr.AddOpcGroupServer(opcserver.Groups[0].OPCGroupName, opcserver.Groups[0].GroupUpdateRate, opcserver.Groups[0].GroupActiveState, (float)opcserver.Groups[0].GroupDeadBand);
                mngr.OPCAddItems(this.editButtonLokasyon.Text);
                gridViewAlarmAdresler.SetRowCellValue(gridViewAlarmAdresler.FocusedRowHandle, "OkunanDeger", mngr.GetOPCItemSyncRead(this.editButtonLokasyon.Text, adres.ToString()));
                mngr.DisConnectServer();
                mngr = null;
                //}
            }
            else
            {
                MessageBox.Show("Hata:Tag Degeri boş ya da adres seçmediniz !!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        private void LokasyonuGetir(string lokasyon)
        {
            mngr.GlobalDataChangeKapat       = true;
            mngr.ConnectGroupDataChangeKapat = true;
            string eskilokasyonadi = mngr.ConnectedGroup.Name;

            mngr.ConnectedGroup   = mngr.ConnectedOPCServer.OPCGroups.GetOPCGroup(lokasyon);
            panelCihazlar.Visible = true;
            List <OpcItems> silinecektaglar = mngr.GetOPCItem.FindAll(p => p != null && p.OpcGroupName == eskilokasyonadi);

            if (silinecektaglar.Count > 0)
            {
                mngr.DeleteOPCItem(silinecektaglar, eskilokasyonadi);
            }


            mymodel.Adres[] adresler = Persistence.ReadList <Adres>(@"
                                Select 
                                    Adres.* 
                                From Cihaz 
                                Inner Join CihazAdres on CihazAdres.Cihaz_Id=Cihaz.Id and CihazAdres.Aktif=1
                                Inner Join Adres on CihazAdres.Adres_Id=Adres.Id and Adres.Aktif=1 
                                Inner Join Lokasyon on   Lokasyon.Id=Cihaz.Lokasyon_Id and Lokasyon.Aktif=1
                                Where
                                CihazAdres.AdresTipi in ('OkunacakAdres','AlarmAdresi')
                                and Adres.Aktif=@prm0 and Lokasyon.Adi=@prm1", new object[] { true, lokasyon });



            List <string> adreslistesi = new List <string>();

            listBox1.Items.Clear();
            foreach (Adres adres in adresler)
            {
                adreslistesi.Add(adres.TagAdresi);

                listBox1.Items.Add(adres.TagAdresi);
            }

            mngr.SetOpcItems(mngr.ConnectedGroup.Name, adreslistesi);
            mngr.OPCAddItems(mngr.ConnectedGroup.Name);
            //foreach (Adres adres in adresler)
            //{
            //    List<OpcItems> items = mngr.GetOPCItem.FindAll(p => p != null && p.OPCItemName == adres.TagAdresi);
            //    foreach (OpcItems item in items)
            //    {
            //        item.OPCItemValueChange += new OPCItemValueChangeEventHandler(Opcitemchange);
            //    }
            //}


            SetDataControlsReadOnlyRecursive(this);
            mngr.GlobalDataChangeKapat       = false;
            mngr.ConnectGroupDataChangeKapat = false;
        }
Ejemplo n.º 3
0
        void frmCihazTanim_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            object value = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "YazilacakDeger");
            object adres = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TagAdresi");

            if (value != null && value != System.DBNull.Value && adres != null && adres != string.Empty)
            {
                //OpcManager mngr;
                //OPCServer 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;
                //    }

                mymodel.Adres[] adresler  = Persistence.ReadList <Adres>();
                List <string>   adreslist = new List <string>();
                adreslist.Add(adres.ToString());
                mngr = new OpcManager(opcserver.Groups[0].OPCGroupName, adreslist);
                mngr.OPCServerConnect(opcserver.OpcServerName, opcserver.OPCNodeName);
                mngr.AddOpcGroupServer(opcserver.Groups[0].OPCGroupName, opcserver.Groups[0].GroupUpdateRate, opcserver.Groups[0].GroupActiveState, (float)opcserver.Groups[0].GroupDeadBand);
                mngr.OPCAddItems(this.editButtonLokasyon.Text);
                mngr.OPCItemWrite(this.editButtonLokasyon.Text, adres.ToString(), value.ToString());
                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "OkunanDeger", mngr.GetOPCItemSyncRead(this.editButtonLokasyon.Text, adres.ToString()));
                mngr.DisConnectServer();
                mngr = null;
            }
            //}
            // else
            //     MessageBox.Show("Hata:Tag Degeri boş ya da adres seçmediniz !!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Ejemplo n.º 4
0
        public frmCihazIzlem()
        {
            InitializeComponent();

            OPCServer opcserver = Persistence.Read <OPCServer>(new Condition("Aktif", Operator.Equal, 1));

            if (opcserver != null && opcserver.Id > 0)
            {
//                mymodel.Adres[] adresler = Persistence.ReadList<Adres>(@"
//                Select
//                    Adres.*
//                From Adres
//                Inner Join CihazAdres on CihazAdres.Adres_Id=Adres.Id and CihazAdres.Aktif=1
//                Where
//                CihazAdres.AdresTipi in ('OkunacakAdres','AlarmAdresi')
//                and Adres.Aktif=@prm0 ",new object[]{true});

                lokasyons = Persistence.ReadList <Lokasyon>("Select * From Lokasyon Where Aktif=@prm0", new object[] { 1 });;
                treeListLokasyon.DataSource = lokasyons;
                Hashtable adreslist = new Hashtable();
                Utility.SetGridStyle(treeListLokasyon);
                //foreach (Adres ent in adresler)
                //{
                //    adreslist.Add(ent.TagAdresi);
                //    listBox1.Items.Add(ent.tagadresi);
                //}
                foreach (Lokasyon lksyn in lokasyons)
                {
                    if (lksyn.Adres.Id > 0)
                    {
                        lksyn.Adres = Persistence.Read <Adres>(lksyn.Adres.Id);
                        adreslist.Add(lksyn.Kodu, lksyn);
                        listBox1.Items.Add(lksyn.Adres.TagAdresi);
                    }
                }

                mngr = null;
                //mngr = new OpcManager(adreslist);
                mngr = new OpcManager();
                mngr.OPCServerConnect(opcserver.OpcServerName, opcserver.OPCNodeName);
                OPCServerGroup[] groups = OPCServer.ReadGroups(opcserver.Id);
                if (groups != null && groups.Length > 0)
                {
                    opcserver.Groups.AddRange(groups);

                    foreach (OPCServerGroup group in opcserver.Groups)
                    {
                        mngr.AddOpcGroupServer(group.OPCGroupName, group.GroupUpdateRate, group.GroupActiveState, (float)group.GroupDeadBand);


                        List <string> list = new List <string>();
                        Lokasyon      lks  = (Lokasyon)adreslist[group.OPCGroupName];
                        if (lks != null)
                        {
                            list.Add(lks.Adres.TagAdresi);
                            mngr.SetOpcItems("lks" + lks.Kodu, list);
                            mngr.OPCAddItems(lks.Kodu);

                            List <OpcItems> items = mngr.GetOPCItem.FindAll(p => p != null && p.OPCItemName == lks.Adres.TagAdresi && (p.OpcGroupName == group.OPCGroupName || p.OpcGroupName == "lks" + group.OPCGroupName));
                            foreach (OpcItems item in items)
                            {
                                item.OPCItemValueChange += new OPCItemValueChangeEventHandler(Opcitemchange);
                            }
                        }
                    }
                    foreach (OPCAutomation.OPCGroupClass group in mngr.ConnectedOPCServer.OPCGroups)
                    {
                        group.DataChange += mngr.ConnectedGroup_DataChange;
                    }
                    mngr.ConnectedOPCServer.OPCGroups.GlobalDataChange += new OPCAutomation.DIOPCGroupsEvent_GlobalDataChangeEventHandler(mngr.OPCGroups_GlobalDataChange);

                    //foreach (Lokasyon lsyn in lokasyons)
                    //{
                    //    List<OpcItems> items = mngr.GetOPCItem.FindAll(p => p != null && p.OPCItemName == lsyn.Adres.TagAdresi);
                    //    foreach (OpcItems item in items)
                    //    {
                    //        item.OPCItemValueChange += new OPCItemValueChangeEventHandler(Opcitemchange);
                    //    }
                    //}



                    //mngr.AddOpcGroupServer(opcserver.OPCGroupName, (opcserver.GroupUpdateRate), (opcserver.GroupActiveState), (float)opcserver.GroupDeadBand);
                    //mngr.OPCAddItems();
                    //SetDataControlsReadOnlyRecursive(this);
                }
            }
            else
            {
                MessageBox.Show("Bağlanılacak OPC Server Bulunamadı.\nOPC Server Tanım Ekranında gerekli tanımlamayı yapınız");
                return;
            }
        }
Ejemplo n.º 5
0
        public frmCihazIzlem()
        {
            InitializeComponent();

            OPCServer opcserver = Persistence.Read<OPCServer>(new Condition("Aktif", Operator.Equal, 1));
            if (opcserver != null && opcserver.Id > 0)
            {
            //                mymodel.Adres[] adresler = Persistence.ReadList<Adres>(@"
            //                Select
            //                    Adres.*
            //                From Adres
            //                Inner Join CihazAdres on CihazAdres.Adres_Id=Adres.Id and CihazAdres.Aktif=1
            //                Where
            //                CihazAdres.AdresTipi in ('OkunacakAdres','AlarmAdresi')
            //                and Adres.Aktif=@prm0 ",new object[]{true});

                lokasyons = Persistence.ReadList<Lokasyon>("Select * From Lokasyon Where Aktif=@prm0", new object[] { 1 }); ;
                treeListLokasyon.DataSource = lokasyons;
                Hashtable adreslist = new Hashtable();
                Utility.SetGridStyle(treeListLokasyon);
                //foreach (Adres ent in adresler)
                //{
                //    adreslist.Add(ent.TagAdresi);
                //    listBox1.Items.Add(ent.tagadresi);
                //}
                foreach (Lokasyon lksyn in lokasyons)
                {
                    if (lksyn.Adres.Id > 0)
                    {
                        lksyn.Adres = Persistence.Read<Adres>(lksyn.Adres.Id);
                        adreslist.Add(lksyn.Kodu, lksyn);
                        listBox1.Items.Add(lksyn.Adres.TagAdresi);
                    }
                }

                mngr = null;
                //mngr = new OpcManager(adreslist);
                mngr = new OpcManager();
                mngr.OPCServerConnect(opcserver.OpcServerName,opcserver.OPCNodeName);
                OPCServerGroup[] groups=OPCServer.ReadGroups(opcserver.Id);
                if(groups!=null && groups.Length>0)
                {
                    opcserver.Groups.AddRange(groups);

                    foreach (OPCServerGroup group in opcserver.Groups)
                    {
                        mngr.AddOpcGroupServer(group.OPCGroupName, group.GroupUpdateRate, group.GroupActiveState, (float)group.GroupDeadBand);

                        List<string> list = new List<string>();
                        Lokasyon lks = (Lokasyon)adreslist[group.OPCGroupName];
                        if (lks != null)
                        {
                            list.Add(lks.Adres.TagAdresi);
                            mngr.SetOpcItems("lks" + lks.Kodu, list);
                            mngr.OPCAddItems(lks.Kodu);

                            List<OpcItems> items = mngr.GetOPCItem.FindAll(p => p != null && p.OPCItemName == lks.Adres.TagAdresi && (p.OpcGroupName == group.OPCGroupName || p.OpcGroupName == "lks" + group.OPCGroupName));
                            foreach (OpcItems item in items)
                            {
                                item.OPCItemValueChange += new OPCItemValueChangeEventHandler(Opcitemchange);
                            }

                        }
                    }
                    foreach (OPCAutomation.OPCGroupClass group in mngr.ConnectedOPCServer.OPCGroups)
                    {
                        group.DataChange += mngr.ConnectedGroup_DataChange;
                    }
                    mngr.ConnectedOPCServer.OPCGroups.GlobalDataChange += new OPCAutomation.DIOPCGroupsEvent_GlobalDataChangeEventHandler(mngr.OPCGroups_GlobalDataChange);

                    //foreach (Lokasyon lsyn in lokasyons)
                    //{
                    //    List<OpcItems> items = mngr.GetOPCItem.FindAll(p => p != null && p.OPCItemName == lsyn.Adres.TagAdresi);
                    //    foreach (OpcItems item in items)
                    //    {
                    //        item.OPCItemValueChange += new OPCItemValueChangeEventHandler(Opcitemchange);
                    //    }
                    //}

                    //mngr.AddOpcGroupServer(opcserver.OPCGroupName, (opcserver.GroupUpdateRate), (opcserver.GroupActiveState), (float)opcserver.GroupDeadBand);
                    //mngr.OPCAddItems();
                    //SetDataControlsReadOnlyRecursive(this);
                }
            }
            else
            {
                MessageBox.Show("Bağlanılacak OPC Server Bulunamadı.\nOPC Server Tanım Ekranında gerekli tanımlamayı yapınız");
                return;
            }
        }
Ejemplo n.º 6
0
        void frmCihazTanim_ButtonClick3(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            object adres = gridViewAlarmAdresler.GetRowCellValue(gridViewAlarmAdresler.FocusedRowHandle, "TagAdresi");
            if (adres != null && adres != string.Empty)
            {
                //OpcManager mngr;
                //OPCServer opcserver = Persistence.Read<OPCServer>(new Condition("Aktif", Operator.Equal, 1));
                //if (opcserver != null && opcserver.Id > 0)
                //{
                    List<string> adreslist = new List<string>();
                    adreslist.Add(adres.ToString());
                    mngr = new OpcManager(opcserver.Groups[0].OPCGroupName,adreslist);
                    mngr.OPCServerConnect(opcserver.OpcServerName, opcserver.OPCNodeName);
                    //mngr.AddOpcGroupServer(opcserver.OPCGroupName, (opcserver.GroupUpdateRate), (opcserver.GroupActiveState), (float)opcserver.GroupDeadBand);
                    mngr.AddOpcGroupServer(opcserver.Groups[0].OPCGroupName, opcserver.Groups[0].GroupUpdateRate, opcserver.Groups[0].GroupActiveState, (float)opcserver.Groups[0].GroupDeadBand);
                    mngr.OPCAddItems(this.editButtonLokasyon.Text);
                    gridViewAlarmAdresler.SetRowCellValue(gridViewAlarmAdresler.FocusedRowHandle, "OkunanDeger", mngr.GetOPCItemSyncRead(this.editButtonLokasyon.Text,adres.ToString()));
                    mngr.DisConnectServer();
                    mngr = null;
                //}

            }
            else
                MessageBox.Show("Hata:Tag Degeri boş ya da adres seçmediniz !!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Ejemplo n.º 7
0
        void frmCihazTanim_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            object value = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "YazilacakDeger");
            object  adres = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TagAdresi");
            if (value != null && value != System.DBNull.Value && adres != null && adres!=string.Empty)
            {
                //OpcManager mngr;
                //OPCServer 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;
                //    }

                    mymodel.Adres[] adresler = Persistence.ReadList<Adres>();
                    List<string> adreslist = new List<string>();
                    adreslist.Add(adres.ToString());
                    mngr = new OpcManager(opcserver.Groups[0].OPCGroupName,adreslist);
                    mngr.OPCServerConnect(opcserver.OpcServerName, opcserver.OPCNodeName);
                    mngr.AddOpcGroupServer(opcserver.Groups[0].OPCGroupName, opcserver.Groups[0].GroupUpdateRate, opcserver.Groups[0].GroupActiveState, (float)opcserver.Groups[0].GroupDeadBand);
                    mngr.OPCAddItems(this.editButtonLokasyon.Text);
                    mngr.OPCItemWrite(this.editButtonLokasyon.Text,adres.ToString(), value.ToString());
                    gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "OkunanDeger", mngr.GetOPCItemSyncRead(this.editButtonLokasyon.Text,adres.ToString()));
                    mngr.DisConnectServer();
                    mngr = null;
                }
               //}
               // else
               //     MessageBox.Show("Hata:Tag Degeri boş ya da adres seçmediniz !!!", "Uyarı..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }