public int TotalRFNosByDept(Employee emp, RFStatus rFStatus)
 {
     return(db.RequisitionForms
            .Where(x => x.Employee.Department == emp.Department)
            .Where(x => x.RFStatus == rFStatus)
            .Count());
 }
 public int TotalRFNosByEmployee(Employee emp, RFStatus rFStatus)
 {
     return(db.RequisitionForms
            .Where(x => x.Employee == emp)
            .Where(x => x.RFStatus == rFStatus)
            .Count());
 }
Ejemplo n.º 3
0
        //*********************************************************************
        public void SendData(SimulatorPacket pack)
        {
            CheckScanConditionOnSend();
            int Rate  = pack.getTransmitRate();
            int sleep = (int)(600 / Rate);

            lock (RfSync)
            {
                try{
                    RF_STATUS = RFStatus.Tx;
                    short OperateChannel = this.getOperateChannel();
                    int   try_counter    = 0;
                    while (!Medium.Registration(this.Freq, OperateChannel, this.x, this.y, sleep))
                    {
                        Thread.Sleep(new TimeSpan(randomWait.Next(20, 50)));
                        if (try_counter++ > 200)
                        {
                            return;
                        }
                    }
                    this.MACLastTrnsmitRate = pack.getTransmitRate();
                    Medium.SendData(pack);
                }
                catch (Exception ex) {
                    AddToLog("SendData:[" + this.GetType() + "] " + ex.Message);
                    MessageBox.Show("SendData :" + ex.Message);
                }

                RF_STATUS = RFStatus.None;
            }
            if (pack.GetType() == typeof(Data))
            {
                _DataSent++;
            }
        }
Ejemplo n.º 4
0
        //*********************************************************************
        public void SendData(SimulatorPacket pack)
        {
            CheckScanConditionOnSend();
            int Rate = pack.getTransmitRate();
            int sleep = (int)(600 / Rate);
            lock (RfSync)
            {
                try{
                    RF_STATUS = RFStatus.Tx;
                    short OperateChannel = this.getOperateChannel();
                    int try_counter = 0;
                    while (!Medium.Registration(this.Freq, OperateChannel, this.x, this.y, sleep))
                    {
                        Thread.Sleep(new TimeSpan(randomWait.Next(20, 50)));
                        if (try_counter++ > 200)
                            return;
                    }
                    this.MACLastTrnsmitRate = pack.getTransmitRate();
                    Medium.SendData(pack);
                }
                catch(Exception ex){
                    AddToLog("SendData:[" + this.GetType() + "] " + ex.Message);
                    MessageBox.Show("SendData :" + ex.Message);
                }

                RF_STATUS = RFStatus.None;
            }
            if (pack.GetType() == typeof(Data)){
                _DataSent++;
            }
        }
Ejemplo n.º 5
0
        //=====================================================================
        /// <summary>
        /// Function for Listen And Receive Packets
        /// </summary>
        /// <param name="sender">Value for know info about received packets</param>
        /// <param name="args">Not used - needed by event</param>
        public void Listen(object sender, EventArgs args)
        {
            //while (_Enabled)
            //{
            //SpinWait.SpinUntil(checkIfHaveDataReceive);
            //SpinWait.SpinUntil(RF_Ready);
            if (((SimulatorPacket)sender).PacketChannel != this.getOperateChannel())
                return;
            if (((SimulatorPacket)sender).PacketFrequency != this.Freq)
                return;

            double dist = GetSTADist(((SimulatorPacket) sender).X, ((SimulatorPacket) sender).Y, this.x, this.y);
            if(dist > Medium.ReceiveDistance)
                return;

            string desinationOfReceivedPacket = ((SimulatorPacket)sender).Destination;

            if ((this.GetType() == typeof(STA) && desinationOfReceivedPacket.Equals("FF:FF:FF:FF:FF:FF")) || desinationOfReceivedPacket.Equals(this.getMACAddress()))
            {
                double t = GetNoiseRSSI(((SimulatorPacket) sender).Source);
                if (sender.GetType() == typeof(Data))
                {
                    if (!MissPacket(t, ((SimulatorPacket)sender).getTransmitRate() ))
                    {
                        _badPackets++;
                        return;
                    }

                }

                //SpinWait.SpinUntil(ListenCondition);//,1);
                prev_guid = new Guid();
                SimulatorPacket pack = null;

                lock (RfSync)
                {
                    RF_STATUS = RFStatus.Rx;
                    pack = Medium.ReceiveData(this);
                    RF_STATUS = RFStatus.None;
                }
                if (pack == null){ }
                else //if (pack != null )//&& (prev_guid != pack.GuidD || pack.IsRetransmit))
                {
                    //  Only if we have received packet before
                    //  but flag Rentransmit is UP
                    if (prev_guid == pack.GuidD)
                        pack.IsReceivedRetransmit = true;

                    if (pack.GetType() != typeof(Beacon))
                        prev_guid = pack.GuidD;

                    AllReceivedPackets += 1;

                    //Thread newThread = new Thread(() => ParseReceivedPacket(pack),1);
                    //newThread.Name = "ParseReceivedPacket of " + this.getMACAddress();
                    //newThread.Start();
                    ThreadPool.QueueUserWorkItem(new WaitCallback((s) => ParseReceivedPacket(pack)));
                }
            }
        }
Ejemplo n.º 6
0
        //=====================================================================
        /// <summary>
        /// Function for Listen And Receive Packets
        /// </summary>
        /// <param name="sender">Value for know info about received packets</param>
        /// <param name="args">Not used - needed by event</param>
        public void Listen(object sender, EventArgs args)
        {
            //while (_Enabled)
            //{
            //SpinWait.SpinUntil(checkIfHaveDataReceive);
            //SpinWait.SpinUntil(RF_Ready);
            if (((SimulatorPacket)sender).PacketChannel != this.getOperateChannel())
            {
                return;
            }
            if (((SimulatorPacket)sender).PacketFrequency != this.Freq)
            {
                return;
            }


            double dist = GetSTADist(((SimulatorPacket)sender).X, ((SimulatorPacket)sender).Y, this.x, this.y);

            if (dist > Medium.ReceiveDistance)
            {
                return;
            }

            string desinationOfReceivedPacket = ((SimulatorPacket)sender).Destination;

            if ((this.GetType() == typeof(STA) && desinationOfReceivedPacket.Equals("FF:FF:FF:FF:FF:FF")) || desinationOfReceivedPacket.Equals(this.getMACAddress()))
            {
                double t = GetNoiseRSSI(((SimulatorPacket)sender).Source);
                if (sender.GetType() == typeof(Data))
                {
                    if (!MissPacket(t, ((SimulatorPacket)sender).getTransmitRate()))
                    {
                        _badPackets++;
                        return;
                    }
                }

                //SpinWait.SpinUntil(ListenCondition);//,1);
                prev_guid = new Guid();
                SimulatorPacket pack = null;

                lock (RfSync)
                {
                    RF_STATUS = RFStatus.Rx;
                    pack      = Medium.ReceiveData(this);
                    RF_STATUS = RFStatus.None;
                }
                if (pack == null)
                {
                }
                else //if (pack != null )//&& (prev_guid != pack.GuidD || pack.IsRetransmit))
                {
                    //  Only if we have received packet before
                    //  but flag Rentransmit is UP
                    if (prev_guid == pack.GuidD)
                    {
                        pack.IsReceivedRetransmit = true;
                    }

                    if (pack.GetType() != typeof(Beacon))
                    {
                        prev_guid = pack.GuidD;
                    }

                    AllReceivedPackets += 1;

                    //Thread newThread = new Thread(() => ParseReceivedPacket(pack),1);
                    //newThread.Name = "ParseReceivedPacket of " + this.getMACAddress();
                    //newThread.Start();
                    ThreadPool.QueueUserWorkItem(new WaitCallback((s) => ParseReceivedPacket(pack)));
                }
            }
        }