/// <summary> /// Resets the Mactable,SigRange and MacStack then insert the newly received mac address /// </summary> /// <param name="MAddress">EG: Mac1,Sig1,Mac2,Sig2,...MacN,SigN</param> /// <returns></returns> public int FingRecalibrate(string[] MAddress) { lock (MacStack) { lock (SigRange) { int Calibrated = 0; int index = 0; Macs.Clear(); MacStack.Clear(); for (int i = MacN - 1; i >= 0; i--) { SigRange[i, 0] = SigRange[i, 1] = 0; MacStack.Push(i); } for (int i = 0; i < MAddress.Length; i = i + 2) { index = MacStack.Pop(); Macs.Add(MAddress[i], index); SigRange[index, 0] = SigRange[index, 1] = Convert.ToInt16(MAddress[i + 1]); Calibrated++; } return(Calibrated); } } }
/// <summary> /// Attempt to Deassociate mac address from this fingerprint /// <para>Returns 1 if success, -1 if failed</para> /// </summary> /// <param name="input">A string containing the Mac Address</param> /// <returns>Returns 1 if success, -1 if mac not found</returns> public int MacRemove(string input) { lock (MacStack) { lock (SigRange) { int macIndex; bool macFound = Macs.TryGetValue(input, out macIndex); if (macFound) { SigRange[macIndex, 0] = SigRange[macIndex, 1] = 0; MacStack.Push(macIndex); Macs.Remove(input); return(1); } else { return(-1); } } } }