Пример #1
0
            internal static int CreateStatusResponseMessage(byte[] msgBytes, ushort beaconNum)
            {
                var idx = 0;

                msgBytes[idx] = (byte)MessageIds.StatusResponse;
                idx          += sizeof(byte);
                msgBytes[idx] = (byte)RoutingGlobal._color;
                idx          += sizeof(byte);
                msgBytes[idx] = RoutingGlobal.BestEtx;
                idx          += sizeof(byte);

                var beaconAdj = (ushort)Math.Min(beaconNum, ushort.MaxValue);

                BitConverter.InsertValueIntoArray(msgBytes, idx, beaconAdj);
                idx += sizeof(ushort);

                msgBytes[idx] = RoutingGlobal.GetPathEWRNP();
                idx           = +sizeof(byte);

                return(idx);
            }
Пример #2
0
        public static Candidate GetBestCandidateRelativeToParent(bool refresh)
        {
            // Initializing parent as current best candidate
            Candidate tmpBest = new Candidate(RoutingGlobal.Parent, RoutingGlobal._parentLinkRSSI, RoutingGlobal.BestEtx, byte.MaxValue, RoutingGlobal.GetPathEWRNP());

            if (!IsEmpty())
            {
                //bool candidateFound = false;

                for (int i = 0; i < _length; i++)
                {
                    if (refresh)
                    {
                        _candidateList[i].SetPathEWRNP();
                    }

                    if (_candidateList[i].GetPathEWRNP() < tmpBest.GetPathEWRNP() || (_candidateList[i].GetPathEWRNP() == tmpBest.GetPathEWRNP() && _candidateList[i].GetEtx() < tmpBest.GetEtx()) || (_candidateList[i].GetPathEWRNP() == tmpBest.GetPathEWRNP() && _candidateList[i].GetEtx() == tmpBest.GetEtx() && _candidateList[i].GetRSSI() > tmpBest.GetRSSI()))
                    {
                        tmpBest = _candidateList[i];
                    }
                    #region no longer using _minRSSI
                    //                    if (_candidateList[i].GetRSSI() >= RoutingGlobal._minRSSI)
                    //                    {
                    //                        if (_candidateList[i].GetPathEWRNP() < tmpBest.GetPathEWRNP() || (_candidateList[i].GetPathEWRNP() == tmpBest.GetPathEWRNP() && _candidateList[i].GetEtx() < tmpBest.GetEtx()) || (_candidateList[i].GetPathEWRNP() == tmpBest.GetPathEWRNP() && _candidateList[i].GetEtx() == tmpBest.GetEtx() && _candidateList[i].GetRSSI() > tmpBest.GetRSSI()))
                    //                        {
                    //                            tmpBest = _candidateList[i];
                    //                            candidateFound = true;
                    //#if DBG_SIMPLE
                    //                            Debug.Print("candidate found: " + tmpBest.GetMacID().ToString() + " RSSI: " + tmpBest.GetRSSI().ToString());
                    //#endif
                    //                        }
                    //                    }
                    #endregion
                }
            }

            return(tmpBest);
        }