public static void ParseParams(out ERadioState state, out double frequency, byte[] bytes) { state = (ERadioState)bytes.Take(1).ToArray()[0]; var bfrequency = bytes.Skip(1).Take(8).ToArray(); frequency = BitConverter.ToDouble(bfrequency, 0); }
public static byte[] GetPacketInBytes(ERadioState state, double frequency) { List <byte> bytes = BitConverter.GetBytes(frequency).ToList(); bytes.Insert(0, (byte)state); return(bytes.ToArray()); }
private void ParseERadioState(ERadioState radioState) { bool canIPlay = Math.Abs(baseRadioState.Frequency - State.Frequency) <= Delta; if (radioState == ERadioState.SignalBegin && canIPlay) { TonPlayer.Play(); } if (radioState == ERadioState.SayingBegin && canIPlay) { Saying = true; SayingState?.Invoke(this, null); StatePlaying(canIPlay); } if (radioState == ERadioState.SayingEnd && canIPlay) { Saying = false; StatePlaying(canIPlay); SayingState?.Invoke(this, null); } if (!canIPlay && Saying) { Saying = false; StatePlaying(canIPlay); SayingState?.Invoke(this, null); } }
public static void SendStateToRemoteMachine(ERadioState state) { if (state == ERadioState.Frequency) { throw new Exception("State error!"); } byte[] bytes = GetPacketInBytes(state, Behavior.State.Frequency); connector.Send(bytes); }
public static void SendStateToRemoteMachine(RadioState radioState, ERadioState state) { byte[] bytes = GetPacketInBytes(state, radioState.Frequency); connector.Send(bytes); }
public RemoteRadioState(double frequency, ERadioState radioState) : base(frequency) { RadioState = radioState; }
public void RemoteStateChanged(double frequency, ERadioState state) { State.Frequency = frequency; State.RadioState = state; Analysis(); }