public DCSPlayerRadioInfo()
 {
     for (var i = 0; i < 4; i++)
     {
         radios[i] = new RadioInformation();
     }
 }
Esempio n. 2
0
        public void Reset()
        {
            name     = "";
            latLng   = new DCSLatLngPosition();
            ptt      = false;
            selected = 0;
            unit     = "";
            simultaneousTransmission        = false;
            simultaneousTransmissionControl = SimultaneousTransmissionControl.EXTERNAL_DCS_CONTROL;
            LastUpdate = 0;

            for (var i = 0; i < 11; i++)
            {
                radios[i] = new RadioInformation();
            }
        }
Esempio n. 3
0
        public RadioInformation CanHearTransmission(double frequency,
                                                    RadioInformation.Modulation modulation,
                                                    byte encryptionKey,
                                                    uint sendingUnitId,
                                                    List <int> blockedRadios,
                                                    out RadioReceivingState receivingState,
                                                    out bool decryptable)
        {
            if (!IsCurrent())
            {
                receivingState = null;
                decryptable    = false;
                return(null);
            }

            RadioInformation    bestMatchingRadio      = null;
            RadioReceivingState bestMatchingRadioState = null;
            bool bestMatchingDecryptable = false;

            for (var i = 0; i < radios.Length; i++)
            {
                var receivingRadio = radios[i];

                if (receivingRadio != null)
                {
                    //handle INTERCOM Modulation is 2
                    if ((receivingRadio.modulation == RadioInformation.Modulation.INTERCOM) &&
                        (modulation == RadioInformation.Modulation.INTERCOM))
                    {
                        if ((unitId > 0) && (sendingUnitId > 0) &&
                            (unitId == sendingUnitId))
                        {
                            receivingState = new RadioReceivingState
                            {
                                IsSecondary    = false,
                                LastReceviedAt = DateTime.Now.Ticks,
                                ReceivedOn     = i
                            };
                            decryptable = true;
                            return(receivingRadio);
                        }
                        decryptable    = false;
                        receivingState = null;
                        return(null);
                    }

                    if (modulation == RadioInformation.Modulation.DISABLED ||
                        receivingRadio.modulation == RadioInformation.Modulation.DISABLED)
                    {
                        continue;
                    }

                    //within 1khz
                    if ((FreqCloseEnough(receivingRadio.freq, frequency)) &&
                        (receivingRadio.modulation == modulation) &&
                        (receivingRadio.freq > 10000))
                    {
                        bool isDecryptable = (encryptionKey == 0 || (receivingRadio.enc ? receivingRadio.encKey : (byte)0) == encryptionKey);

                        if (isDecryptable && !blockedRadios.Contains(i))
                        {
                            receivingState = new RadioReceivingState
                            {
                                IsSecondary    = false,
                                LastReceviedAt = DateTime.Now.Ticks,
                                ReceivedOn     = i
                            };
                            decryptable = true;
                            return(receivingRadio);
                        }

                        bestMatchingRadio      = receivingRadio;
                        bestMatchingRadioState = new RadioReceivingState
                        {
                            IsSecondary    = false,
                            LastReceviedAt = DateTime.Now.Ticks,
                            ReceivedOn     = i
                        };
                        bestMatchingDecryptable = isDecryptable;
                    }
                    if ((receivingRadio.secFreq == frequency) &&
                        (receivingRadio.secFreq > 10000))
                    {
                        if (encryptionKey == 0 || (receivingRadio.enc ? receivingRadio.encKey : (byte)0) == encryptionKey)
                        {
                            receivingState = new RadioReceivingState
                            {
                                IsSecondary    = true,
                                LastReceviedAt = DateTime.Now.Ticks,
                                ReceivedOn     = i
                            };
                            decryptable = true;
                            return(receivingRadio);
                        }

                        bestMatchingRadio      = receivingRadio;
                        bestMatchingRadioState = new RadioReceivingState
                        {
                            IsSecondary    = true,
                            LastReceviedAt = DateTime.Now.Ticks,
                            ReceivedOn     = i
                        };
                    }
                }
            }

            decryptable    = bestMatchingDecryptable;
            receivingState = bestMatchingRadioState;
            return(bestMatchingRadio);
        }