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); } }
private void DisconnectFromServer_Click(object sender, EventArgs e) { try { mngr.DisConnectServer(); } catch (Exception ex) { MessageBox.Show("OPC server disconnect failed with exception: " + ex.Message, "SimpleOPCInterface Exception", MessageBoxButtons.OK); } finally { //' Allow a reconnect once the disconnect completes //OPCServerConnect.Enabled = true; //AvailableOPCServerList.Enabled = true; //OPCServerName.Enabled = true; //' Don't alllow the Disconnect to be issued now that the connection is closed //DisconnectFromServer.Enabled = true; //' Disable the group controls now that we no longer have a server connection //OPCGroupName.Enabled = true; //GroupUpdateRate.Enabled = true; //GroupDeadBand.Enabled = true; //GroupActiveState.Enabled = true; //AddOPCGroup.Enabled = true; } }
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); }
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); }
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); }