//********************************************************************* public RFDevice GetRFDeviceByMAC(String _mac) { foreach (var obj in _AccessPoint) { RFDevice _tV = (RFDevice)obj; if (_tV.getMACAddress().Equals(_mac)) { return(_tV); } } return(null); }
//********************************************************************* 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); }
//********************************************************************* 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); }
//********************************************************************* public Boolean Registration(String Band, Int32 Channel, Double x, Double y) { Key Tk = new Key(Band, Channel); if (_packets.Count == 0) { lock (_T) { _T.Clear(); } } try { if (_T.ContainsKey(Tk)) { ArrayList _temp = (ArrayList)_T[Tk]; if (_temp != null) { foreach (var obj in _temp) { RFDevice _tV = (RFDevice)obj; if (getDistance(x, y, _tV.x, _tV.y) < _Radius + _Radius) { return(false); } //Console.WriteLine(y); } RFDevice ver = new RFDevice(x, y, 0); _temp.Add(ver); lock (_T) { _T[Tk] = _temp; } Thread newThread = new Thread(() => Unregister(Tk, ver)); newThread.Start(); } else { ArrayList _tempArrL = new ArrayList(); RFDevice ver = new RFDevice(x, y, 0); _tempArrL.Add(ver); lock (_T) { _T.Add(Tk, _tempArrL); } Thread newThread = new Thread(() => Unregister(Tk, ver)); newThread.Start(); } } else { ArrayList _tempArrL = new ArrayList(); RFDevice ver = new RFDevice(x, y, 0); _tempArrL.Add(ver); lock (_T) { _T.Add(Tk, _tempArrL); } Thread newThread = new Thread(() => Unregister(Tk, ver)); newThread.Start(); } } catch (Exception ex) { AddToLog("[Registration] Exception:" + ex.Message); return(false); } return(true); }
//********************************************************************* 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); }
public RFDevice(RFDevice ver) { this.SetVertex(ver.x, ver.y, ver.z); }
public ShowLog(RFDevice _sta) { InitializeComponent(); this._sta = _sta; textBox1.Text = _sta._LOG.ToString(); }
//===================================================================== public RFDevice(RFDevice ver) { this.SetVertex(ver.x, ver.y, ver.z); }
//********************************************************************* 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); }