Пример #1
0
        public void OnNext(string value)
        {
            var parsedLine = DolphinMbpWriteLine.ParseString(value);

            if (parsedLine?.WriteSize == 8)
            {
                uint flagNum = parsedLine.MemoryAddr - FLAGS_BASE_ADDRESS;

                // If the memory address is less than the flags base address, flagNum will overflow
                // so we only need to check flagNum < FLAGS_SIZE
                if (flagNum >= FLAGS_SIZE)
                {
                    return;
                }

                byte oldFlag = cachedFlags[flagNum];
                cachedFlags[flagNum] = (byte)parsedLine.Value;

                if (oldFlag != parsedLine.Value)
                {
                    var eventArgs = new SoALFlagChangedEventArgs {
                        FlagNumber = (int)flagNum,
                        OldValue   = oldFlag,
                        NewValue   = parsedLine.Value
                    };
                    OnChange?.Invoke(this, eventArgs);
                }
            }
        }
Пример #2
0
 private static void LogFlagChange(TextWriter writer, SoALFlagChangedEventArgs arg)
 {
     writer.WriteLine("Flag #{0:d3} changed: {1:x2} -> {2:x2}", arg.FlagNumber, arg.OldValue, arg.NewValue);
 }