public static bool OnDcsDataAddressValueEventSubscribed() { return(OnDcsDataAddressValue != null && OnDcsDataAddressValue.GetInvocationList().Length > 0); }
internal void ProcessByte(byte b) { try { switch (_state) { case DCSBiosStateEnum.WAIT_FOR_SYNC: /* do nothing */ break; case DCSBiosStateEnum.ADDRESS_LOW: _address = b; _state = DCSBiosStateEnum.ADDRESS_HIGH; break; case DCSBiosStateEnum.ADDRESS_HIGH: _address = (uint)(b << 8) | _address; _state = _address != 0x5555 ? DCSBiosStateEnum.COUNT_LOW : DCSBiosStateEnum.WAIT_FOR_SYNC; break; case DCSBiosStateEnum.COUNT_LOW: _count = b; _state = DCSBiosStateEnum.COUNT_HIGH; break; case DCSBiosStateEnum.COUNT_HIGH: _count = (uint)(b << 8) | _count; _state = DCSBiosStateEnum.DATA_LOW; break; case DCSBiosStateEnum.DATA_LOW: _data = b; _count--; _state = DCSBiosStateEnum.DATA_HIGH; break; case DCSBiosStateEnum.DATA_HIGH: _data = (uint)(b << 8) | _data; _count--; //_iDcsBiosDataListener.DcsBiosDataReceived(_address, _data); if (OnDcsDataAddressValue != null && IsBroadcastable(_address) && _data != 0x55) { /*if (_address == 25332) * { * Debug.Print("SENDING FROM DCS-BIOS address & value --> " + _address + " " + _data); * }*/ try { OnDcsDataAddressValue?.Invoke(this, new DCSBIOSDataEventArgs() { Address = _address, Data = _data }); if (OnDcsDataAddressValue != null) { Debug.WriteLine("OnDcsDataAddressValue : " + OnDcsDataAddressValue.GetInvocationList().Length); } } catch (Exception e) { if (!_errorsLogged.Contains(e.Message)) { Common.LogError(e, "Error in DCS-BIOS stream. This error will be logged *just once*."); _errorsLogged.Add(e.Message); } } } _address += 2; if (_count == 0) { _state = DCSBiosStateEnum.ADDRESS_LOW; } else { _state = DCSBiosStateEnum.DATA_LOW; } break; } if (b == 0x55) { //Console.WriteLine(Environment.TickCount - ticks); //ticks = Environment.TickCount; _syncByteCount++; } else { _syncByteCount = 0; } if (_syncByteCount == 4) { _state = DCSBiosStateEnum.ADDRESS_LOW; _syncByteCount = 0; } } catch (Exception e) { Common.LogError(e, "DCSBIOSProtocolParser.ProcessByte()"); } }