public aktuator(Int16 index, string name, plc plc, aktor_type type) { _index = index; _name = name; _plc = plc; _type = type; }
public FrmPlcClient(object plc, object cpsNet) { InitializeComponent(); _plc = (plc)plc; _cpsNet = (CpsNet)cpsNet; this.Text = _plc.NamePlc; init_timer(); comboBox_headerFlag.DataSource = Enum.GetValues(typeof(FrameHeaderFlag)); }
private void updateDataGridView_aktuators() { ListAktuatorTmp.Clear(); plc plc = dataGridView_plcs.SelectedRows[0].DataBoundItem as plc; foreach (aktuator a in plc.ListAktuator) { ListAktuatorTmp.Add(a); } }
private void listBox_aktors_refresh() { //List<aktuator> tmp_list_aktor = new List<aktuator>(); tmp_list_aktor.Clear(); //copy aktuator in display list depending on filter settings plc selectedPlc = (plc)comboBox_listPlc.SelectedItem; foreach (plc p in _list_plc) { if (checkBox_plc.Checked) { foreach (aktuator a in selectedPlc.ListAktuator) { if (checkBox_aktorType.Checked) { if (a.AktorType == (aktor_type)comboBox_aktorType.SelectedItem) { tmp_list_aktor.Add(a); } } else { tmp_list_aktor.Add(a); } } } else //alle aktoren aller plc´s hinzufügen { foreach (aktuator a in p.ListAktuator) { if (checkBox_aktorType.Checked) { if (a.AktorType == (aktor_type)comboBox_aktorType.SelectedItem) { tmp_list_aktor.Add(a); } } else { tmp_list_aktor.Add(a); } } } } tmp_list_aktor.Sort((x, y) => x.Index.CompareTo(y.Index)); listBox_aktors.DataSource = null; listBox_aktors.Items.Clear(); listBox_aktors.DataSource = tmp_list_aktor; }
private void listBox_plc_MouseClick(object sender, MouseEventArgs e) { checkBox_add_new_plc.Checked = false; panel_edit_plc.Visible = true; selected_plc = (plc)listBox_plc.SelectedItem; if (selected_plc != null) { textBox_plcip.Text = selected_plc.IPplc; textBox_plc_name.Text = selected_plc.NamePlc; textBox_plc_port.Text = selected_plc.PortPlc; } }
private void button_save_actuator_Click(object sender, EventArgs e) { //ein item wird editiert if (listBox_aktors.SelectedItems.Count == 1 || checkBox_add_new_aktuator.Checked) { textBox_akt_id.BackColor = Color.White; Int16 index; //id auf zahl verifizieren if (Int16.TryParse(textBox_akt_id.Text, out index)) { plc plc = (plc)comboBox_edit_plc.SelectedItem; aktor_type type = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); if (checkBox_add_new_aktuator.Checked) { plc.ListAktuator.Add(new aktuator(index, textBox_edit_name.Text, plc, type)); textBox_akt_id.Text = (Convert.ToInt16(textBox_akt_id.Text) + 1).ToString(); } else { aktuator a = (aktuator)listBox_aktors.SelectedItem; //plc.ListAktuator.FindIndex(a) if (comboBox_edit_type.SelectedItem != null) { a.AktorType = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); } if (comboBox_edit_plc.SelectedItem != null) { if (a._plc != (plc)comboBox_edit_plc.SelectedItem) { ((plc)comboBox_edit_plc.SelectedItem).ListAktuator.Add(a); a._plc.ListAktuator.Remove(a); } } if (textBox_akt_id.Text != "") { a.Index = Convert.ToInt16(textBox_akt_id.Text); } if (textBox_edit_name.Text != "") { a.Name = textBox_edit_name.Text; } //int nr = plc.ListAktuator.IndexOf(a); //plc.ListAktuator[nr].Index = index; //plc.ListAktuator[nr].Name = textBox_edit_name.Text; //plc.ListAktuator[nr]._plc = plc; //plc.ListAktuator[nr]._type = type; } //################################################# TODO: //###################### alle bereits projektierten aktoren suchen und ebenfalls updaten //foreach(platform p in _list_platform) // int fn = p._list_platform_control. } else { textBox_akt_id.BackColor = Color.Red; } } //mehrere items werden gleichzeitig editiert else { ListBox.SelectedObjectCollection collection = new ListBox.SelectedObjectCollection(listBox_aktors); foreach (aktuator a in collection) { if (comboBox_edit_type.SelectedItem != null) { a.AktorType = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); } if (comboBox_edit_plc.SelectedItem != null) { if (a._plc != (plc)comboBox_edit_plc.SelectedItem) { ((plc)comboBox_edit_plc.SelectedItem).ListAktuator.Add(a); a._plc.ListAktuator.Remove(a); } } } } listBox_aktors_refresh(); }