예제 #1
0
        //################      Public Methods     ##################
        /// <summary>
        /// Check and change input's mac addresses and signals with the Fingerprint's mac addresses and signal ranges
        /// <para>For each successive changes to the range, the value returned will increase</para>
        /// <para>Returns 0 if no mac address ranges has been changed</para>
        /// <para>Uses the following functions: MacTable.AddMac</para>
        /// </summary>
        /// <param name="MAddress">array of Mac Address, EG:"M1,20,M2,20...M10,20"</param>
        /// <returns></returns>
        public int FingCalibrate(string[] MAddress)
        {
            lock (MacStack)
            {
                lock (SigRange)
                {
                    int Calibrated = 0;
                    int macIndex, macLoc;

                    bool valueFound = false;

                    for (int i = 0; i < MAddress.Length; i = i + 2)
                    {
                        valueFound = Macs.TryGetValue(MAddress[i], out macIndex);

                        if (valueFound)
                        {
                            Calibrated += SigCalibrate(macIndex, Convert.ToInt16(MAddress[i + 1]));
                        }
                        else if (MacStack.Count != 0)
                        {
                            if (MacTable.AddMac(MAddress[i], MacTable.GetFingObject(FName)))
                            {
                                macLoc = MacStack.Pop();
                                Macs.Add(MAddress[i], macLoc);
                                SigRange[macLoc, 0] = SigRange[macLoc, 1] = Convert.ToInt16(MAddress[i + 1]);
                                Calibrated++;
                            }
                        }
                    }
                    return(Calibrated);
                }
            }
        }
예제 #2
0
        /// <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);
                }
            }
        }