//Delegate function to setup EDC XML Information void SetEDCXmlInfo(cls_EDC_Info edc_info, bool edit_flag) { if (edit_flag) { int i = 0; if (edcm.gateway_edc.Count > 0) { foreach (cls_EDC_Info edc in edcm.gateway_edc) { if (edc.serial_id == edc_info.serial_id) { break; } i++; } edcm.gateway_edc[i] = edc_info; } } else { edcm.gateway_edc.Add(edc_info); } }
//Constructor to Edit EDC Xml Information public frmEditEDCXml(SetEDCXmlInfo set_xml, GateWayManager gwm, cls_EDC_Info edc_info, string gateway, string device, bool copy_flag) { InitializeComponent(); this.isEdit = true; this.isCopy = copy_flag; this.gateway_mgr = gwm;; this.edc_data = edc_info; this.gateway_id = gateway; this.device_id = device; this.delgSetEDCXmlInfo = set_xml; }
private void lvEDCXmlList_DoubleClick(object sender, EventArgs e) { string strSerial; string strGatewayID; string strDeviceID; cls_EDC_Info edcTemp = new cls_EDC_Info(); if (lvEDCXmlList.SelectedItems.Count == 0) { MessageBox.Show("Please select the EDC XML config first!", "Error"); return; } strSerial = lvEDCXmlList.SelectedItems[0].Text.Trim(); strGatewayID = lvEDCXmlList.SelectedItems[0].SubItems[1].Text.Trim(); strDeviceID = lvEDCXmlList.SelectedItems[0].SubItems[2].Text.Trim(); int i = 0; foreach (cls_EDC_Info edc in this.edcm.gateway_edc) { if (edc.serial_id == strSerial) { edcTemp = this.edcm.gateway_edc[i]; break; } i++; } frmEditEDCXml frm = new frmEditEDCXml(SetEDCXmlInfo, this.gateway_mgr, edcTemp, strGatewayID, strDeviceID, false); frm.Owner = this; frm.ShowDialog(); edcTemp = null; delgEDCManager(edcm); RefreshEDCXmlList(); lvEDCXmlList.Focus(); }
private void btnSaveEDCXml_Click(object sender, EventArgs e) { cls_EDC_Info tmpEDC = new cls_EDC_Info(); List <Tuple <string, string> > tmp_tag_info = new List <Tuple <string, string> >(); List <Tuple <string, string> > tmp_calc_tag_info = new List <Tuple <string, string> >(); if (txtSerial.Text.Trim() == "") { MessageBox.Show("Please input the serial id!", "Error"); return; } if (cmbGateway.Text.Trim() == "") { MessageBox.Show("Please select the gateway id!", "Error"); return; } if (cmbDevice.Text.Trim() == "") { MessageBox.Show("Please select the device id!", "Error"); return; } if (cmbReportType.Text.Trim() == "") { MessageBox.Show("Please select the report type!", "Error"); return; } if (cmbReportType.Text.Trim() == "interval") { if (txtReportInterval.Text.Trim() == "") { MessageBox.Show("Please input the report interval!", "Error"); return; } else { int value; if (!int.TryParse(txtReportInterval.Text.Trim(), out value)) { MessageBox.Show("Report Interval is number only!", "Error"); return; } tmpEDC.report_interval = int.Parse(txtReportInterval.Text.Trim()); if (chkAVG.Checked) { tmpEDC.interval_function.Add("AVG"); } if (chkMAX.Checked) { tmpEDC.interval_function.Add("MAX"); } if (chkMIN.Checked) { tmpEDC.interval_function.Add("MIN"); } if (tmpEDC.interval_function.Count == 0) { MessageBox.Show("Please checked at lease one interval function!", "Error"); return; } } } if (txtReportPath.Text.Trim() == "") { MessageBox.Show("Please input the report path!", "Error"); return; } if (!this.isEdit) { if (cmbEDCHeaderSet.Text.Trim() == "") { MessageBox.Show("Please select the EDC Header set first!", "Error"); return; } } tmpEDC.serial_id = txtSerial.Text.Trim(); tmpEDC.gateway_id = cmbGateway.Text.Trim(); tmpEDC.device_id = cmbDevice.Text.Trim(); tmpEDC.report_tpye = cmbReportType.Text.Trim(); tmpEDC.ReportEDCPath = txtReportPath.Text.Trim(); if (chkEnable.Checked) { tmpEDC.enable = true; } else { tmpEDC.enable = false; } if (this.isEdit) { tmpEDC.edchead_info = this.edc_data.edchead_info; } else { foreach (cls_EDC_Header h in this.edc_header_list.head_set_list) { if (h.set_name == cmbEDCHeaderSet.Text.Trim()) { tmpEDC.edchead_info = h.head_set; } } } foreach (ListViewItem item in lvTagList.Items) { cls_Tag t = this.gateway_mgr.gateway_list[gateway_index].device_info[device_index].tag_info[item.Text.Trim()]; if (t != null) { if (item.Checked) { this.gateway_mgr.gateway_list[gateway_index].device_info[device_index].tag_info[item.Text.Trim()].report_flag = "Y"; } else { this.gateway_mgr.gateway_list[gateway_index].device_info[device_index].tag_info[item.Text.Trim()].report_flag = "N"; } } } foreach (KeyValuePair <string, cls_Tag> tag in this.gateway_mgr.gateway_list[gateway_index].device_info[device_index].tag_info) { if (tag.Value.report_flag == "Y") { tmp_tag_info.Add(Tuple.Create(tag.Key, tag.Key)); } } foreach (ListViewItem item in lvCalcTagList.Items) { if (item.Checked) { cls_CalcTag ct = this.gateway_mgr.gateway_list[gateway_index].device_info[device_index].calc_tag_info[item.Text.Trim()]; if (ct != null) { tmp_calc_tag_info.Add(Tuple.Create(ct.TagName, ct.TagName)); } } } tmpEDC.tag_info = tmp_tag_info; tmpEDC.calc_tag_info = tmp_calc_tag_info; if (!this.isEdit) { delgSetSerial(this.serial_index); } if (this.isCopy) { delgSetEDCXmlInfo(tmpEDC, false); } else { delgSetEDCXmlInfo(tmpEDC, this.isEdit); } if (!this.gateway_mgr.gateway_list[this.gateway_index].function_list.Contains("EDC")) { this.gateway_mgr.gateway_list[this.gateway_index].function_list.Add("EDC"); } this.Close(); }