public override bool Analyze(Status status) { byte[] byteArray = status.MessageQueue.Select(b => b.Key).ToArray(); string byteStr = Transfer.BaToS(byteArray); string ObRegex = @"680704811([A-Za-z0-9_]{5})([A-Za-z0-9_]{2})"; Regex ObRe = new Regex(ObRegex); string AzRegex = @"680704830([A-Za-z0-9_]{5})([A-Za-z0-9_]{2})"; Regex AzRe = new Regex(AzRegex); if (ObRe.IsMatch(byteStr)) { Match match = ObRe.Match(byteStr); if (SumChecker.CheckSum(match.Value.Substring(2, 12), match.Groups[2].Value)) { status.Component6Obliquity = Convert.ToInt32(match.Groups[1].Value) / 100.0; int index = -1; if ((index = byteStr.IndexOf(match.Value, index + 1)) != -1) { for (int i = index / 2; i < (index + match.Length) / 2; i++) { status.MessageQueue[i] = new KeyValuePair <byte, bool>(status.MessageQueue[i].Key, false); } } return(true); } } if (AzRe.IsMatch(byteStr)) { Match match = AzRe.Match(byteStr); if (SumChecker.CheckSum(match.Value.Substring(2, 12), match.Groups[2].Value)) { status.Component6Azimuth = Convert.ToInt32(match.Groups[1].Value) / 100.0; int index = -1; if ((index = byteStr.IndexOf(match.Value, index + 1)) != -1) { for (int i = index / 2; i < (index + match.Length) / 2; i++) { status.MessageQueue[i] = new KeyValuePair <byte, bool>(status.MessageQueue[i].Key, false); } } return(true); } } return(false); }
static void Main() { // 1. SumChecker sumChecker = new SumChecker(); bool result = sumChecker.Number(x, y); Console.WriteLine($"{result}"); // 2. PointCalc pointCalc = new PointCalc(); Console.WriteLine($"Total points: {pointCalc.Points()}"); //3. StrConcatinate strConcatinate = new StrConcatinate(); Console.WriteLine($"{strConcatinate.GetInitials()}"); }