/// <summary> /// Load Proximus line profiles from xml document /// </summary> /// <param name="xmlDoc">Xml document that contains the profiles</param> /// <returns>Proximus line profiles</returns> public static List<ProximusLineProfile> loadProfilesFromXML(XmlDocument xmlDoc) { //run trough all xml profiles List<ProximusLineProfile> listProfiles = new List<ProximusLineProfile>(); foreach (XmlNode profileNode in xmlDoc.SelectNodes("//document/profiles/profile")) { List<int> confirmedDownloadList = new List<int>(); List<int> confirmedUploadList = new List<int>(); foreach (XmlNode confirmedNode in profileNode.SelectNodes("confirmed")) { confirmedDownloadList.Add(Convert.ToInt32(confirmedNode.Attributes["down"].Value)); confirmedUploadList.Add(Convert.ToInt32(confirmedNode.Attributes["up"].Value)); } confirmedDownloadList.Add(Convert.ToInt32(profileNode.SelectNodes("official")[0].Attributes["down"].Value)); confirmedUploadList.Add(Convert.ToInt32(profileNode.SelectNodes("official")[0].Attributes["up"].Value)); ProximusLineProfile profile = new ProximusLineProfile( profileNode.Attributes["name"].Value, confirmedDownloadList.Last(), confirmedUploadList.Last(), Convert.ToBoolean(profileNode.Attributes["provisioning"].Value), Convert.ToBoolean(profileNode.Attributes["dlm"].Value), Convert.ToBoolean(profileNode.Attributes["repair"].Value), Convert.ToBoolean(profileNode.Attributes["vectoring"].Value), (VDSL2Profile)Enum.Parse(typeof(VDSL2Profile), "p" + profileNode.Attributes["vdsl2"].Value), confirmedDownloadList.Distinct().ToList(), confirmedUploadList.Distinct().ToList(), Convert.ToDecimal(profileNode.Attributes["min"].Value, CultureInfo.InvariantCulture), Convert.ToDecimal(profileNode.Attributes["max"].Value, CultureInfo.InvariantCulture)); listProfiles.Add(profile); } return listProfiles; }
private void backgroundWorkerGetLineData_DoWork(object sender, DoWorkEventArgs e) { try { //disable connect button ThreadUtils.SetButtonEnabledFromThread(buttonConnect, false); if (_session is Bbox3Session) { ThreadUtils.SetLabelTextFromThread(distanceLabel, "Estimated distance"); } // Get device info //---------------- SetLabelValueLoading(labelHardwareVersion); SetLabelValueLoading(labelFirmwareVersion); SetLabelValueLoading(labelDeviceUptime); SetLabelValueLoading(labelLinkUptime); DeviceInfo deviceInfo = _session.GetDeviceInfo(); if (_session is Bbox3Session || _session is Bbox2Session) { ThreadUtils.SetLabelTextFromThread(labelHardwareVersion, deviceInfo.HardwareVersion); ThreadUtils.SetLabelTextFromThread(labelFirmwareVersion, deviceInfo.FirmwareVersion); ThreadUtils.SetLabelTextFromThread(labelDeviceUptime, deviceInfo.DeviceUptime); ThreadUtils.SetLabelTextFromThread(labelLinkUptime, deviceInfo.LinkUptime); } if (_session is FritzBoxSession) { setLabelNotApplicable(hwVersionLabel, labelHardwareVersion); setLabelNotApplicable(firmwareVersionLabel, labelFirmwareVersion); setLabelNotApplicable(deviceUptimeLabel, labelDeviceUptime); setLabelNotApplicable(lineUptimeLabel, labelLinkUptime); } // Check line connected //--------------------- if (!_session.LineConnected) { MessageBox.Show("Line status down, please check your connection and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // Get line data (BBox2 & FritzBox) //--------------------------------- if (_session is Bbox2Session || _session is FritzBoxSession) { SetLabelValueLoading(labelDownstreamCurrentBitRate); SetLabelValueLoading(labelUpstreamCurrentBitRate); SetLabelValueLoading(labelDownstreamAttenuation); SetLabelValueLoading(labelUpstreamAttenuation); SetLabelValueLoading(labelDownstreamNoiseMargin); SetLabelValueLoading(labelUpstreamNoiseMargin); SetLabelValueLoading(labelDownstreamMaxBitRate); SetLabelValueLoading(labelUpstreamMaxBitRate); SetLabelValueLoading(labelDistance); SetLabelValueLoading(labelDSLStandard); SetLabelValueLoading(labelVDSLProfile); SetLabelValueLoading(labelVectoringDown); SetLabelValueLoading(labelVectoringUp); SetLabelValueLoading(labelVectoringROPCapable); SetLabelValueLoading(labelVectoringModemCapable); SetLabelValueLoading(labelProximusProfile); SetLabelValueLoading(labelDLM); SetLabelValueLoading(labelRepair); } _session.GetLineData(); // Get dsl standard //----------------- var dslStandardValue = _session.DSLStandard.ToString().Replace("plus", "+"); if (_session.Annex != Annex.unknown) { dslStandardValue += " Annex " + _session.Annex + ""; } ThreadUtils.SetLabelTextFromThread(labelDSLStandard, dslStandardValue); // Get sync values //---------------- SetLabelValueLoading(labelDownstreamCurrentBitRate); setLabelValueAsDecimal(labelDownstreamCurrentBitRate, _session.DownstreamCurrentBitRate, "###,###,##0 'kbps'"); SetLabelValueLoading(labelUpstreamCurrentBitRate); setLabelValueAsDecimal(labelUpstreamCurrentBitRate, _session.UpstreamCurrentBitRate, "###,###,##0 'kbps'"); //distance //-------- SetLabelValueLoading(labelDistance); setLabelValueAsDecimal(labelDistance, _session.Distance, "0 'm'"); //Proximus profile //---------------- if (_session.DSLStandard == DSLStandard.VDSL2) { //get vectoring status SetLabelValueLoading(labelVectoringDown); ThreadUtils.SetLabelTextFromThread(labelVectoringDown, boolToString(_session.VectoringDown)); SetLabelValueLoading(labelVectoringUp); ThreadUtils.SetLabelTextFromThread(labelVectoringUp, boolToString(_session.VectoringUp)); ProximusLineProfile currentProfile = ProfileUtils.GetProfile(_profiles, _session.UpstreamCurrentBitRate, _session.DownstreamCurrentBitRate, _session.VectoringDown, _session.VectoringUp, _session.Distance); if (currentProfile == null) { ThreadUtils.SetLabelTextFromThread(labelDLM, "unknown"); ThreadUtils.SetLabelTextFromThread(labelRepair, "unknown"); ThreadUtils.SetLabelTextFromThread(labelProximusProfile, "unknown"); ThreadUtils.SetLabelTextFromThread(labelVDSLProfile, ProfileUtils.GetVdsl2ProfileFallBack(_session.DownstreamCurrentBitRate, _session.UpstreamCurrentBitRate).ToString().Replace("p", "")); } else { ThreadUtils.SetLabelTextFromThread(labelDLM, boolToString(currentProfile.DlmProfile)); ThreadUtils.SetLabelTextFromThread(labelRepair, boolToString(currentProfile.RepairProfile)); ThreadUtils.SetLabelTextFromThread(labelProximusProfile, currentProfile.SpeedName); ThreadUtils.SetLabelTextFromThread(labelVDSLProfile, currentProfile.ProfileVDSL2.ToString().Replace("p", "")); } } else { setLabelNotApplicable(vdslProfileLabel, labelVDSLProfile); setLabelNotApplicable(vectoringLabel, labelVectoringDown); setLabelNotApplicable(vectoringLabel, labelVectoringUp); setLabelNotApplicable(repairLabel, labelRepair); setLabelNotApplicable(dlmLabel, labelDLM); setLabelNotApplicable(proximusProfileLabel, labelProximusProfile); } //vectoring ROP capable SetLabelValueLoading(labelVectoringROPCapable); ThreadUtils.SetLabelTextFromThread(labelVectoringROPCapable, boolToString(_session.VectoringROPCapable)); SetLabelValueLoading(labelVectoringModemCapable); ThreadUtils.SetLabelTextFromThread(labelVectoringModemCapable, boolToString(_session.VectoringDeviceCapable)); //attenuation //----------- //downstream SetLabelValueLoading(labelDownstreamAttenuation); setLabelValueAsDecimal(labelDownstreamAttenuation, _session.DownstreamAttenuation, "0.0 'dB'"); //upstream: BBOX3 adsl only if (_session is Bbox3Session && new List <DSLStandard> { DSLStandard.ADSL, DSLStandard.ADSL2, DSLStandard.ADSL2plus }.Contains(_session.DSLStandard)) { SetLabelValueLoading(labelUpstreamAttenuation); setLabelValueAsDecimal(labelUpstreamAttenuation, _session.UpstreamAttenuation, "0.0 'dB'"); } else { setLabelNotApplicable(upstreamAttenuationLabel, labelUpstreamAttenuation); } //noise margin //------------ //downstream SetLabelValueLoading(labelDownstreamNoiseMargin); setLabelValueAsDecimal(labelDownstreamNoiseMargin, _session.DownstreamNoiseMargin, "0.0 'dB'"); //upstream: not for BBOX2 if (_session is Bbox3Session || _session is FritzBoxSession) { SetLabelValueLoading(labelUpstreamNoiseMargin); setLabelValueAsDecimal(labelUpstreamNoiseMargin, _session.UpstreamNoiseMargin, "0.0 'dB'"); } else { setLabelNotApplicable(upstreamNoiseMarginLabel, labelUpstreamNoiseMargin); } //max bitrate //----------- //downstream SetLabelValueLoading(labelDownstreamMaxBitRate); setLabelValueAsDecimal(labelDownstreamMaxBitRate, _session.DownstreamMaxBitRate, "###,###,##0 'kbps'"); //upstream: not for BBOX2 if (_session is Bbox3Session || _session is FritzBoxSession) { SetLabelValueLoading(labelUpstreamMaxBitRate); setLabelValueAsDecimal(labelUpstreamMaxBitRate, _session.UpstreamMaxBitRate, "###,###,##0 'kbps'"); } else { setLabelNotApplicable(upstreamMaxBitRateLabel, labelUpstreamMaxBitRate); } } } catch (ThreadCancelledException) { } catch (Exception ex) { MessageBox.Show("Unexpected error occurred. Debug info: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (_connected) { _session.CloseSession(); } } }
/// <summary> /// Load Proximus line profiles from xml document /// </summary> /// <param name="xmlDoc">Xml document that contains the profiles</param> /// <returns>Proximus line profiles</returns> public static List <ProximusLineProfile> LoadProfilesFromXml(XmlDocument xmlDoc) { //run trough all xml profiles List <ProximusLineProfile> listProfiles = new List <ProximusLineProfile>(); XmlNodeList nodeProfiles = xmlDoc.SelectNodes("//document/profiles/profile"); if (nodeProfiles != null) { foreach (XmlNode profileNode in nodeProfiles) { List <int> confirmedDownloadList = new List <int>(); List <int> confirmedUploadList = new List <int>(); XmlNodeList nodeConfirmed = profileNode.SelectNodes("confirmed"); if (nodeConfirmed != null) { foreach (XmlNode confirmedNode in nodeConfirmed) { if (confirmedNode.Attributes != null) { confirmedDownloadList.Add(Convert.ToInt32(confirmedNode.Attributes["down"].Value)); confirmedUploadList.Add(Convert.ToInt32(confirmedNode.Attributes["up"].Value)); } } } XmlNodeList nodeOfficial = profileNode.SelectNodes("official"); if (nodeOfficial != null) { XmlAttributeCollection attributesOfficial = nodeOfficial[0].Attributes; if (attributesOfficial != null) { confirmedDownloadList.Add(Convert.ToInt32(attributesOfficial["down"].Value)); confirmedUploadList.Add(Convert.ToInt32(attributesOfficial["up"].Value)); } } if (profileNode.Attributes != null) { ProximusLineProfile profile = new ProximusLineProfile( profileNode.Attributes["name"].Value, profileNode.Attributes["speedname"].Value, confirmedDownloadList.Last(), confirmedUploadList.Last(), Convert.ToBoolean(profileNode.Attributes["provisioning"].Value), Convert.ToBoolean(profileNode.Attributes["dlm"].Value), Convert.ToBoolean(profileNode.Attributes["repair"].Value), Convert.ToBoolean(profileNode.Attributes["vectoring"].Value), Convert.ToBoolean(profileNode.Attributes["vectoring-up"].Value), (VDSL2Profile)Enum.Parse(typeof(VDSL2Profile), "p" + profileNode.Attributes["vdsl2"].Value), confirmedDownloadList.Distinct().ToList(), confirmedUploadList.Distinct().ToList(), Convert.ToDecimal(profileNode.Attributes["min"].Value, CultureInfo.InvariantCulture), Convert.ToDecimal(profileNode.Attributes["max"].Value, CultureInfo.InvariantCulture)); listProfiles.Add(profile); } } } return(listProfiles); }
private void buttonClipboard_Click(object sender, EventArgs e) { StringBuilder builder = new StringBuilder(); builder.AppendLine("[code]"); builder.AppendLine("B-Box 3 Sagem Tool v" + Application.ProductVersion); builder.AppendLine("--------------------" + new String('-', Application.ProductVersion.Length)); builder.AppendLine("Device: " + _session.DeviceName); builder.AppendLine(""); builder.AppendLine("Downstream current bit rate: " + (_session.DownstreamCurrentBitRate < 0 ? "unknown" : _session.DownstreamCurrentBitRate.ToString("###,###,##0 'kbps'"))); builder.AppendLine("Upstream current bit rate: " + (_session.UpstreamCurrentBitRate < 0 ? "unknown" : _session.UpstreamCurrentBitRate.ToString("###,###,##0 'kbps'"))); builder.AppendLine(""); builder.AppendLine("Downstream max bit rate: " + (_session.DownstreamMaxBitRate < 0 ? "unknown" : _session.DownstreamMaxBitRate.ToString("###,###,##0 'kbps'"))); if (_session is Bbox3Session || _session is FritzBoxSession) { builder.AppendLine("Upstream max bit rate: " + (_session.UpstreamMaxBitRate < 0 ? "unknown" : _session.UpstreamMaxBitRate.ToString("###,###,##0 'kbps'"))); } builder.AppendLine(""); builder.AppendLine("Downstream attenuation: " + (_session.DownstreamAttenuation < 0 ? "unknown" : _session.DownstreamAttenuation.ToString("0.0 'dB'"))); if (_session is Bbox3Session && new List <DSLStandard> { DSLStandard.ADSL, DSLStandard.ADSL2, DSLStandard.ADSL2plus }.Contains(_session.DSLStandard)) { builder.AppendLine("Upstream attenuation: " + (_session.UpstreamAttenuation < 0 ? "unknown" : _session.UpstreamAttenuation.ToString("0.0 'dB'"))); } builder.AppendLine(""); builder.AppendLine("Downstream noise margin: " + (_session.DownstreamNoiseMargin < 0 ? "unknown" : _session.DownstreamNoiseMargin.ToString("0.0 'dB'"))); if (_session is Bbox3Session || _session is FritzBoxSession) { builder.AppendLine("Upstream noise margin: " + (_session.UpstreamNoiseMargin < 0 ? "unknown" : _session.UpstreamNoiseMargin.ToString("0.0 'dB'"))); } builder.AppendLine(""); builder.AppendLine("Vectoring down: " + boolToString(_session.VectoringDown)); builder.AppendLine("Vectoring up: " + boolToString(_session.VectoringUp)); builder.AppendLine("Modem vectoring compatible: " + boolToString(_session.VectoringDeviceCapable)); builder.AppendLine("ROP vectoring compatible: " + boolToString(_session.VectoringROPCapable)); builder.AppendLine(""); var dslStandardValue = _session.DSLStandard.ToString().Replace("plus", "+"); if (_session.Annex != Annex.unknown) { dslStandardValue += " Annex " + _session.Annex + ""; } builder.AppendLine("DSL standard: " + dslStandardValue); if (_session.DSLStandard == DSLStandard.VDSL2) { ProximusLineProfile currentProfile = ProfileUtils.GetProfile(_profiles, _session.UpstreamCurrentBitRate, _session.DownstreamCurrentBitRate, _session.VectoringDown, _session.VectoringUp, _session.Distance); if (currentProfile == null) { builder.AppendLine("DSL profile: " + ProfileUtils.GetVdsl2ProfileFallBack(_session.DownstreamCurrentBitRate, _session.UpstreamCurrentBitRate).ToString().Replace("p", "")); if (_session is Bbox3Session) { builder.AppendLine("Estimated distance: " + (_session.Distance == null ? "unknown" : ((decimal)_session.Distance).ToString("0 'm'"))); } else { builder.AppendLine("Distance " + (_session.Distance == null ? "unknown" : ((decimal)_session.Distance).ToString("0 'm'"))); } builder.AppendLine(""); builder.AppendLine("Proximus profile name: unknown"); builder.AppendLine("Proximus DLM profile: unknown"); builder.AppendLine("Proximus repair profile: unknown"); } else { builder.AppendLine("DSL profile: " + currentProfile.ProfileVDSL2.ToString().Replace("p", "")); if (_session is Bbox3Session) { builder.AppendLine("Estimated distance: " + (_session.Distance == null ? "unknown" : ((decimal)_session.Distance).ToString("0 'm'"))); } else { builder.AppendLine("Distance " + (_session.Distance == null ? "unknown" : ((decimal)_session.Distance).ToString("0 'm'"))); } builder.AppendLine(""); builder.AppendLine("Proximus profile name: " + currentProfile.SpeedName); builder.AppendLine("Proximus DLM profile: " + boolToString(currentProfile.DlmProfile)); builder.AppendLine("Proximus repair profile: " + boolToString(currentProfile.RepairProfile)); } } builder.AppendLine("[/code]"); Clipboard.SetText(builder.ToString()); }