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