예제 #1
0
        //*********************************************************************
        public Boolean MediumHaveAIRWork(RFDevice device)
        {
            if (this.getPacketsFound() < 1)
            {
                return(false);
            }
            Key Pk  = new Key(device.getOperateBand(), device.getOperateChannel(), device.getMACAddress());
            Key Pk2 = new Key(device.getOperateBand(), device.getOperateChannel(), "FF:FF:FF:FF:FF:FF");

            if (_packets != null && (_packets.ContainsKey(Pk) || _packets.ContainsKey(Pk2)))
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
        //*********************************************************************
        public static Boolean MediumHaveAIRWork(RFDevice device, bool CheckBeacons)
        {
            try
            {
                if (Medium.getPacketsFound() < 1)
                {
                    return(false);
                }
                Key Pk  = new Key(device.Freq, device.getOperateChannel(), device.getMACAddress());
                Key Pk2 = null;
                if (CheckBeacons)
                {
                    Pk2 = new Key(device.Freq, device.getOperateChannel(), _BROADCAST);
                }

                if (CheckBeacons)
                {
                    if (_packets != null && (_packets.ContainsKey(Pk) || _packets.ContainsKey(Pk2)))
                    {
                        return(true);
                    }
                }
                else
                {
                    if (_packets != null && _packets.ContainsKey(Pk))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Medium MediumHaveAIRWork" + ex.Message);
            }
            return(false);
        }
예제 #3
0
        //*********************************************************************
        public IPacket ReceiveData(RFDevice device)
        {
            Key    Pk        = null;
            String errPrefix = "";

            try
            {
                if (_packets != null)
                {
                    lock (_packets)
                    {
                        errPrefix = " Packets ";
                        Pk        = new Key(device.getOperateBand(), device.getOperateChannel(), device.getMACAddress());
                        if (_packets.ContainsKey(Pk))
                        {
                            ArrayList LocalPackets = (ArrayList)_packets[Pk];
                            foreach (object pack in LocalPackets)
                            {
                                if (pack != null)
                                {
                                    SimulatorPacket _LocalPack = (SimulatorPacket)pack;
                                    if (_LocalPack.Source != device.getMACAddress() &&

                                        getDistance(device.x, device.y, _LocalPack.X, _LocalPack.Y) < _Radius + _Radius)
                                    {
                                        //LocalPackets.Remove(pack);
                                        return(_LocalPack);
                                    }
                                }
                                // loop body
                            }
                        }
                    }


                    Pk = new Key(device.getOperateBand(), device.getOperateChannel(), "FF:FF:FF:FF:FF:FF");
                    if (_packets.ContainsKey(Pk))
                    {
                        errPrefix = " Beacons ";
                        ArrayList LocalPackets = (ArrayList)_packets[Pk];
                        foreach (object pack in LocalPackets)
                        {
                            if (pack != null)
                            {
                                SimulatorPacket _LocalPack = (SimulatorPacket)pack;

                                if (_LocalPack.Source != device.getMACAddress() &&
                                    getDistance(device.x, device.y, _LocalPack.X, _LocalPack.Y) < _Radius + _Radius)
                                {
                                    return(_LocalPack);
                                }
                            }
                            // loop body
                        }
                    }
                    else
                    {
                        //AddToLog("Packet not found");
                    }
                }
            }
            catch (Exception ex) { AddToLog("[ReceiveData][" + errPrefix + "]:" + ex.Message); }
            return(null);
        }
예제 #4
0
        //*********************************************************************
        public static SimulatorPacket ReceiveData(RFDevice device)
        {
            Key             Pk       = null;
            SimulatorPacket retvalue = null;

            if (_packets == null)
            {
                return(null);
            }
            try
            {
                _ev.WaitOne();
                //  Private packets
                Pk = new Key(device.Freq, device.getOperateChannel(), device.getMACAddress());
                if (_packets.ContainsKey(Pk))
                {
                    ArrayList LocalPackets = (ArrayList)_packets[Pk];
                    foreach (object pack in LocalPackets)
                    {
                        if (pack != null)
                        {
                            SimulatorPacket _LocalPack = (SimulatorPacket)pack;
                            if (_LocalPack.Source != device.getMACAddress() &&
                                getDistance(device.x, device.y, _LocalPack.X, _LocalPack.Y) < ReceiveDistance)
                            {
                                retvalue = _LocalPack;
                                LocalPackets.Remove(pack);
                                break;
                            }
                        }
                    }
                }

                // Broadcast packets
                if (device.getListenBeacon() && retvalue == null)
                {
                    Pk = new Key(device.Freq, device.getOperateChannel(), _BROADCAST);
                    if (_packets.ContainsKey(Pk))
                    {
                        ArrayList LocalPackets = (ArrayList)_packets[Pk];
                        foreach (object pack in LocalPackets)
                        {
                            if (pack != null)
                            {
                                SimulatorPacket _LocalPack = (SimulatorPacket)pack;
                                if (_LocalPack.Source != device.getMACAddress() &&
                                    getDistance(device.x, device.y, _LocalPack.X, _LocalPack.Y) < ReceiveDistance)
                                {
                                    retvalue = _LocalPack;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                if (DebugLogEnabled)
                {
                    AddToLog("[ReceiveData] " + ex.Message);
                }
            }
            finally{
                _ev.Set();
            }
            return(retvalue);
        }