Exemple #1
0
        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);
        }
Exemple #2
0
        public static byte[] GetPacketInBytes(ERadioState state, double frequency)
        {
            List <byte> bytes = BitConverter.GetBytes(frequency).ToList();

            bytes.Insert(0, (byte)state);
            return(bytes.ToArray());
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 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);
 }
Exemple #5
0
 public static void SendStateToRemoteMachine(RadioState radioState, ERadioState state)
 {
     byte[] bytes = GetPacketInBytes(state, radioState.Frequency);
     connector.Send(bytes);
 }
Exemple #6
0
 public RemoteRadioState(double frequency, ERadioState radioState) : base(frequency)
 {
     RadioState = radioState;
 }
Exemple #7
0
 public void RemoteStateChanged(double frequency, ERadioState state)
 {
     State.Frequency  = frequency;
     State.RadioState = state;
     Analysis();
 }