// Unknown 01/01/01 /// <summary> /// Function operates on a given id string to decode information /// </summary> /// <param name="idString">Assumes valid Id string from an AWG</param> private void GetAwgInformation(string idString) { if (string.IsNullOrEmpty(idString)) { Assert.Fail("No ID string returned from AWG " + LogicalAWGNumber); } //This is kind of cute, C# allows us to label the regex group we want with a name, instead of having to use an array index value. //Regex AwgFeatureMatcher = new Regex(@"TEKTRONIX,(?<type>AWG|HSG)(?<modelNumber>\d+)(?<class>.),(?<serial>.+),SCPI:(?<scpi>.+) FW:(?<fwVersion>.+)"); //To get the 70k to work it doesn't appear to add a SCPI field to its ID string var awgFeatureMatcher = new Regex(@"TEKTRONIX,(?<type>AWG|HSG)(?<modelNumber>\d+)(?<class>.*),(?<serial>.*),FV:(?<AppVersion>.+)"); Match match = awgFeatureMatcher.Match(idString.Trim()); //The ID Assert.IsTrue(match.Success, "The AWG ID string did not match the specified pattern. The actual value returned was: " + idString); // make sure you got a good match //Remember that since we have an instance of the AWG accessors for each one in the setup, these values are specific to that AWG ModelNumber = match.Groups["modelNumber"].Value; ClassLetter = match.Groups["class"].Value; FamilyType = match.Groups["type"].Value; SerialNumber = match.Groups["serial"].Value; AppVersion = match.Groups["AppVersion"].Value; ModelString = FamilyType + ModelNumber + ClassLetter; var awgAppVersionMatcher = new Regex(@"(?<Major>\d+).(?<Minor>\d+).(?<Version>\d+)"); Match versionMatch = awgAppVersionMatcher.Match(AppVersion); Assert.IsTrue(versionMatch.Success, "Unexpected version format" + AppVersion); AppVersionMajor = versionMatch.Groups["Major"].Value; AppVersionMinor = versionMatch.Groups["Minor"].Value; AppVersionVersion = versionMatch.Groups["Version"].Value; if (ModelNumber.Length == 5) { if (ModelNumber.Contains("70")) { Family = "70"; // aka Pascal } else if (ModelNumber.Contains("50")) { Family = "50"; // aka Bode } else { Family = "Unknown"; } } }
void CheckForErrors(ref string errorInfo, string propertyName) { switch (propertyName) { case "ModelNumber": if (ModelNumber != null && ModelNumber.Contains("XXX")) { errorInfo = "ModelName can not contain adult content!"; } break; case "ModelName": if (ModelName == null) { errorInfo = "Can't be null"; } else if (ModelName != null && ModelName.Contains("XXX")) { errorInfo = "ModelName can not contain adult content!"; } break; case "UnitCost": if (UnitCost < 0) { errorInfo = "Unit Cost can not be negative"; } break; case "Description": if (Description != null && Description.Contains("XXX")) { errorInfo = "Description can not contain adult content!"; } break; case "UnitsInStock": if (UnitsInStock < 0) { errorInfo = "Stock count can not be negative!"; } break; } }