private void btn_SDS_GetInfo_Click(object sender, EventArgs e) { string targetPN = (tbx_SDS_PartNumber.Text.Trim()).ToUpper(); lb_SDS_Software.Items.Clear(); tbx_SDS_BroadcastString.Text = ""; IVSStructure EBOM = new IVSStructure(); if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text)) MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); else { lb_SDS_Software.Items.Clear(); EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text); PartLineage PN = EBOM.GetModuleByAssyPN(targetPN); if (PN != null) { this.tbx_SDS_Title.Text = PN.ECUAcronym + "_" + PN.AssyPN.Part.ToString(); tbx_SDS_PartNumber.Enabled = true; tbx_SDS_Security.Enabled = true; tbx_SDS_Title.Enabled = true; btn_SDS_GenSDS.Enabled = true; lb_SDS_SWDLMethod.Enabled = true; lb_SDS_Software.Enabled = true; foreach (SoftPart t in PN.Softwares) { lb_SDS_Software.Items.Add(t.ToString()); if (t.IsFlash) lb_SDS_Software.SelectedItems.Add(t.ToString()); } lb_SDS_SWDLMethod.SelectedItem = "SWDL005"; //Broadcast String this.tbx_SDS_BroadcastString.Text = PN.ToBroadcast(); } else MessageBox.Show("Part Number not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ES_btndosearch_Click(object sender, EventArgs e) { string targetPN = ("*" + tbx_ES_Partnumber.Text.Trim() + "*").ToUpper(); bool HasExtra = false; IVSStructure EBOM = new IVSStructure(); if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text)) MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); else { if (EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text)) HasExtra = true; List<XmlNode> SearchResult = new List<XmlNode>(); string CBXSelected = (string)cbx_ES_SearchOption.SelectedItem; //Do Search Here if (CBXSelected == "Top-Assemble" || CBXSelected == "Any") { IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("PartLineage") where IsMatch(t.SelectNodes("AssyPN")[0].InnerText, targetPN) == true select t; SearchResult.AddRange(theList); if (HasExtra) { theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("PartLineage") where IsMatch(t.SelectNodes("AssyPN")[0].InnerText, targetPN) == true select t; SearchResult.AddRange(theList); } } if (CBXSelected == "Hardware" || CBXSelected == "Any") { IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("PartLineage") where IsMatch(t.SelectNodes("HardwareComponentPart/HardwareType")[0].InnerText, targetPN) == true select t; SearchResult.AddRange(theList); if (HasExtra) { theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("PartLineage") where IsMatch(t.SelectNodes("HardwareComponentPart/HardwareType")[0].InnerText, targetPN) == true select t; SearchResult.AddRange(theList); } } if (CBXSelected == "Software" || CBXSelected == "Any") { IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("FilePN") where IsMatch(t.InnerText, targetPN) == true select t; foreach (XmlNode t in theList) if (t.ParentNode.Name != "SupportingSoftwarePart") SearchResult.Add(t.ParentNode.ParentNode.ParentNode); if (HasExtra) { theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("FilePN") where IsMatch(t.InnerText, targetPN) == true select t; foreach (XmlNode t in theList) if (t.ParentNode.Name != "SupportingSoftwarePart") SearchResult.Add(t.ParentNode.ParentNode.ParentNode); } } if (cbx_ES_SearchOption.Text == "SBL" || CBXSelected == "Any") { IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("FilePN") where IsMatch(t.InnerText, targetPN) == true select t; foreach (XmlNode t in theList) if (t.ParentNode.Name == "SupportingSoftwarePart") SearchResult.Add(t.ParentNode.ParentNode.ParentNode); if (HasExtra) { theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("FilePN") where IsMatch(t.InnerText, targetPN) == true select t; foreach (XmlNode t in theList) if (t.ParentNode.Name != "SupportingSoftwarePart") SearchResult.Add(t.ParentNode.ParentNode.ParentNode); } } if (SearchResult.Count == 0) { MessageBox.Show("Part Number Not Found", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { XmlDocument Root = new XmlDocument(); Root.AppendChild(Root.CreateXmlDeclaration("1.0", "utf-8", null)); XmlElement RootElement = Root.CreateElement("Parts"); foreach (XmlNode t in SearchResult) RootElement.AppendChild(Root.ImportNode(t, true)); Root.AppendChild(RootElement); Root.Save("Display"); wb_ES_Browser.Url = new System.Uri(Application.StartupPath + "\\Display"); MessageBox.Show("Totally " + SearchResult.Count.ToString() + " records found"); } } }
private void btn_SDS_GenSDS_Click(object sender, EventArgs e) { IVSStructure EBOM = new IVSStructure(); if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text)) MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page"); else { if (!IVSStructure.isValidPN(tbx_SDS_PartNumber.Text)) MessageBox.Show("Wrong Part Number Format"); else { if (tbx_Setting_EBOMExtra.Text != "") EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text); PartLineage PN = EBOM.GetModuleByAssyPN(tbx_SDS_PartNumber.Text.ToUpper()); if (PN == null) MessageBox.Show("Part Number NOT Found in EBOM"); else { try { string GenerateMessage = ""; if (sfg_SDS_File.ShowDialog() == DialogResult.OK) { string OutputFolder = new FileInfo(sfg_SDS_File.FileName).DirectoryName; String Output = ""; Output += "title\t\t\t\t\t\t= \"" + tbx_SDS_Title.Text + "\";" + "\r\n"; Output += "protocol\t\t\t\t\t= \"Jaguar 11-bit\";" + "\r\n"; Output += "\r\n"; Output += "inhibit_tester_present\t\t\t\t= TRUE;" + "\r\n"; Output += "broadcast_keep_alive_net\t\t\t= TRUE;" + "\r\n"; Output += "check_for_updates_only\t\t\t\t= FALSE;" + "\r\n"; Output += "force_all_updates\t\t\t\t= TRUE;" + "\r\n"; Output += "rig_update_mode\t\t\t\t\t= TRUE;" + "\r\n"; Output += "\r\n"; Output += "node" + "\r\n"; Output += "{"; if (PN.NodeAddr == "MOST") { Output += "\tname\t\t\t\t\t= \"HLDF\";" + "\r\n"; Output += "\tecu_address\t\t\t\t= 0x7A5;" + "\r\n"; } else { Output += "\tname\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n"; Output += "\tecu_address\t\t\t\t= " + "0x" + PN.NodeAddr + ";" + "\r\n"; } Output += "};" + "\r\n"; Output += "\r\n"; Output += "node" + "\r\n"; Output += "{" + "\r\n"; Output += "\tid\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n"; Output += "\r\n"; Output += "\tswdl_method\t\t\t\t= \"" + lb_SDS_SWDLMethod.SelectedItem + "\";" + "\r\n"; Output += "\tname\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n"; Output += "\tecu_address\t\t\t\t= " + "0x" + PN.NodeAddr + ";" + "\r\n"; Output += "\tnd_security_interface\t\t\t= \"" + tbx_SDS_Security.Text + "\";" + "\r\n"; if (PN.SBL != null) { Output += "\tnd_sbl_vbf_file\t\t\t\t= \"" + PN.SBL.Part.ToString() + ".VBF\";" + "\r\n"; if (cbx_SDS_VBF.Checked) { try { string TargetPN = OutputFolder + "\\" + PN.SBL.Part.ToString() + ".VBF"; string SourcePN = tbx_Setting_VBFFolder.Text + "\\" + PN.SBL.Part.ToString() + ".VBF"; if (File.Exists(TargetPN)) File.Delete(TargetPN); File.Copy(SourcePN, TargetPN); } catch { GenerateMessage += PN.SBL.Part.ToString() + " not found\r\n"; } } } else Output += "\tnd_sbl_vbf_file\t\t\t\t= \"(none)\";" + "\r\n"; //Software int j = 1; for (int i = 0; i < PN.Softwares.Count; i++) { if (lb_SDS_Software.SelectedItems.Contains(PN.Softwares[i].ToString())) { Output += "\r\n"; Output += "\tdata" + j.ToString() + "_vbf_file\t\t\t\t= \"" + PN.Softwares[i].Part.ToString() + ".vbf" + "\"" + ";\r\n"; Output += "\tdata" + j.ToString() + "_part_did\t\t\t\t= " + "0x" + PN.Softwares[i].PID + ";\r\n"; Output += "\tdata" + j.ToString() + "_part_ref\t\t\t\t= \"" + PN.Softwares[i].Part.ToString() + "\"" + ";\r\n"; Output += "\tdata" + j.ToString() + "_part_inf\t\t\t\t= \"" + PN.Softwares[i].Type.ToString() + "\"" + ";\r\n"; if (cbx_SDS_VBF.Checked) { try { string TargetPN = OutputFolder + "\\" + PN.Softwares[i].Part.ToString() + ".VBF"; string SourcePN = tbx_Setting_VBFFolder.Text + "\\" + PN.Softwares[i].Part.ToString() + ".VBF"; if (File.Exists(TargetPN)) File.Delete(TargetPN); File.Copy(SourcePN, TargetPN); } catch { GenerateMessage += PN.Softwares[i].Part.ToString() + " not found\r\n"; } } j++; } } Output += "};" + "\r\n"; Output += "\r\n"; Output += "node" + "\r\n"; Output += "{" + "\r\n"; Output += "\tid\t\t\t\t\t= \"Exit and DTC Clear\";" + "\r\n"; Output += "\r\n"; Output += "\tswdl_method\t\t\t\t= \"DTCCLEAR2\";" + "\r\n"; Output += "\tname\t\t\t\t\t= \"EXIT\";" + "\r\n"; Output += "\tecu_address\t\t\t\t= 0x7DF;" + "\r\n"; Output += "};"; if (File.Exists(sfg_SDS_File.FileName)) File.Delete(sfg_SDS_File.FileName); FileStream fs = new FileStream(this.sfg_SDS_File.FileName,FileMode.OpenOrCreate); byte[] data = System.Text.Encoding.Default.GetBytes(Output); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); //Copy Security File string SourceSecu = tbx_setting_SecurityFolder.Text + "\\" + CurrentSecurityFile; string TargetSecu = OutputFolder + "\\" + CurrentSecurityFile; if (File.Exists(SourceSecu)) { if (File.Exists(TargetSecu)) { File.Delete(TargetSecu); } File.Copy(SourceSecu, TargetSecu); } MessageBox.Show("Generate Finished\r\n" + GenerateMessage, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Generate Failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }