private void OpenSocketEventNotify(AW_API_NET.rfReaderEvent_t rdrEvent)
        {
            string ip;

            lock (myLock)
            {
                if (startProcessEvents)                 //flag to prevent from processing normal communication routines
                {
                    Console.WriteLine("NetRdrReconn  OpenSocketEventNotify is received");
                    if ((ip = GetStringIP(rdrEvent.ip)) != "")
                    {
                        openSockRdrIpList.Remove(ip);
                        if (openSockRdrIpList.Count == 0)
                        {
                            openSockRdrIpListIndex = -1;
                        }

                        resetRdrIpList.Add(ip);

                        if (resetRdrIpListIndex < 0)
                        {
                            resetRdrIpListIndex = 0;
                        }
                    }
                }
            }
        }
        private void StartReconnProcessNotify(AW_API_NET.rfReaderEvent_t rdrEvent)
        {
            string ip;
            int    ret;

            lock (myLock)
            {
                Console.WriteLine("NetRdrReconn  StartReconnProcessNotify is called");
                startProcessEvents = true;

                if ((ip = GetStringIP(rdrEvent.ip)) != "")
                {
                    if (pktID >= 224)
                    {
                        pktID = 1;
                    }

                    //add ip to the list to get scaned
                    if (!scanRdrIpList.Contains(ip))
                    {
                        ret = api.rfCloseSocket(rdrEvent.ip, AW_API_NET.APIConsts.SPECIFIC_IP);
                        scanRdrIpList.Add(ip);                         //string

                        //add to the scaniplist index
                        if (scanRdrIpListIndex < 0)
                        {
                            scanRdrIpListIndex = 0;
                        }
                    }

                    //ret = api.rfScanIP(rdrEvent.ip, pktID++);
                }
            }            //lock
        }
        private void ScanNetworkEventNotify(AW_API_NET.rfReaderEvent_t rdrEvent)
        {
            string ip;

            lock (myLock)
            {
                if (startProcessEvents)                 //flag to prevent from processing normal communication routines
                {
                    Console.WriteLine("NetRdrReconn  ScanNetworkEventNotify is received");

                    if ((ip = GetStringIP(rdrEvent.ip)) != "")
                    {
                        //remove it from scan list and add to opensock list
                        scanRdrIpList.Remove(ip);
                        if (scanRdrIpList.Count == 0)
                        {
                            scanRdrIpListIndex = -1;
                        }

                        openSockRdrIpList.Add(ip);

                        if (openSockRdrIpListIndex < 0)
                        {
                            openSockRdrIpListIndex = 0;
                        }

                        //if (pktID >= 224)
                        //pktID = 1;
                        //ret = api.rfOpenSocket(rdrEvent.ip, 1, false, AW_API_NET.APIConsts.SPECIFIC_IP, pktID++);
                    }
                }
            }
        }
示例#4
0
        void PowerupReaderEventNotifty(AW_API_NET.rfReaderEvent_t readerEvent)
        {
            //populating rdrStat for polling rdr module
            //check if reader is on network
            lock (myLock)
            {
                string ip;
                if ((ip = utility.GetStringIP(readerEvent.ip)) != "")
                {
                    //if ip exits in the rdrStatusList remove it and replace it otherwise add it.
                    readerStatStruct readerObj = new readerStatStruct(readerEvent.reader);
                    if (utility.GetRdrFromList(ip, ref readerObj, rdrStatusList))
                    {
                        rdrStatusList.Remove(readerObj);
                    }

                    readerStatStruct rdrStat = new readerStatStruct(readerEvent.reader);
                    rdrStat.hostID = readerEvent.host;
                    rdrStat.SetIP(utility.GetStringIP(readerEvent.ip));
                    rdrStat.SetStatus(1);                     //online
                    rdrStat.SetProcessing(false);

                    rdrStatusList.Add(rdrStat);
                }
            }
        }
示例#5
0
        void EnableReaderEventNotify(AW_API_NET.rfReaderEvent_t readerEvent)
        {
            if (!trunOnRdrPolling)
            {
                return;
            }
            //lock(myLock)
            {
                if (ReaderOnlineEventHandler != null)
                {
                    ReaderOnlineEventHandler(readerEvent);
                }

                //if polling rdr is switched on
                readerStatStruct readerObj = new readerStatStruct(readerEvent.reader);
                if (GetRdrFromList(readerEvent.reader, ref readerObj))
                {
                    //if prev rdr stat was offline set the event for online
                    //might need to send everytime to update the app about the status
                    //if (readerObj.GetStatus() == 1)

                    //if (ReaderOnlineEventHandler != null)
                    //ReaderOnlineEventHandler(readerEvent);


                    //set the params to online and reset the counter
                    //readerObj.SetStatus(1);  //online
                    //readerObj.SetCounter(0);
                    //-----------------------------------------

                    //if ip exits in the rdrStatusList remove it and replace it otherwise add it.
                    readerStatStruct rdrStat = new readerStatStruct(readerEvent.reader);
                    rdrStat.hostID = readerEvent.host;
                    //need to fix api to send valid ip with enable rdr
                    //rdrStat.SetIP(GetStringIP(readerEvent.ip));
                    rdrStat.SetIP(readerObj.GetIP());
                    rdrStat.SetStatus(1);                     //online
                    rdrStat.SetCounter(0);
                    rdrStat.online = true;
                    rdrStat.SetProcessing(false);

                    rdrStatusList.Remove(readerObj);

                    rdrStatusList.Add(rdrStat);                      //polling rdr list

                    if (GetAllRdrsStat())
                    {
                        if (AllReadersOnlineEventHandler != null)
                        {
                            AllReadersOnlineEventHandler(true);
                        }
                        //else
                        //AllReadersOnlineEventHandler (false);
                    }
                }        //is reader in the list
            }            //lock
        }
示例#6
0
 void CloseSocketEventNotify(AW_API_NET.rfReaderEvent_t readerEvent)
 {
     /*string ip;
      * if ((ip=GetStringIP(readerEvent.ip)) != "")
      * {
      *      //if ip exits in the rdrStatusList remove it and replace it otherwise add it.
      *      readerStatStruct readerObj = new readerStatStruct(readerEvent.reader);
      *      if (GetRdrFromList (ip, ref readerObj))
      *              rdrStatusList.Remove(readerObj);
      * }*/
 }
        private void PowerupReaderNotifty(AW_API_NET.rfReaderEvent_t rdrEvent)
        {
            string ip;

            lock (myLock)
            {
                if (startProcessEvents)                 //flag to prevent from processing normal communication routines
                {
                    Console.WriteLine("NetRdrReconn  PowerupReaderNotifty is received");

                    if ((ip = GetStringIP(rdrEvent.ip)) != "")
                    {
                        //remove it from reset reader list
                        resetRdrIpList.Remove(ip);
                        if (resetRdrIpList.Count == 0)
                        {
                            resetRdrIpListIndex = -1;
                        }
                    }
                }
            }
        }
 private void CloseSocketEventNotify(AW_API_NET.rfReaderEvent_t rdrEvent)
 {
 }
示例#9
0
        //returns true if the rdr object counter has maxed out
        bool ProcessRdrError(AW_API_NET.rfReaderEvent_t readerEvent, int errorID)          //(ushort rdrID, int errorID)
        {
            //lock(myLock)
            {
                //bool ret = false;
                readerStatStruct rdrObj;                 // = new readerStatStruct(0); //create an readerStatStruct object with temp rdr id
                //rdrStat = (readerStatStruct)rdrStatusList[rdrIndexPoll];
                //foreach (readerStatStruct rdrObj in rdrStatusList)
                for (int i = 0; i < rdrStatusList.Count; i++)
                {
                    rdrObj = new readerStatStruct(0);
                    rdrObj = (readerStatStruct)rdrStatusList[i];

                    if (rdrObj.rdrID == readerEvent.reader)
                    {
                        readerStatStruct rdrObj2 = new readerStatStruct(readerEvent.reader); //new
                        rdrObj.Copy(ref rdrObj2);                                            //new

                        if ((errorID == AW_API_NET.APIConsts.RF_E_NO_RESPONSE) &&
                            (readerEvent.eventType == AW_API_NET.APIConsts.RF_READER_ENABLE))
                        {
                            //if reached max
                            if (rdrObj.GetCounter() >= MAX_READER_NO_RESPONSE)
                            {
                                //if reader prev stat was online set an event in the application
                                //will set event once until the status goes back to online
                                //if (rdrObj.GetStatus() == 1)
                                //ret = true;

                                Console.WriteLine("NetRdrConn - ProcessRdrError - reader #" + Convert.ToString(readerEvent.reader) + " rdrObj counter Maxed");
                                //rdrStatusList.RemoveAt(i);  //new removed
                                rdrStatusList.Remove(rdrObj);                           //new

                                rdrObj2.SetStatus(0);                                   //reader offline
                                rdrObj2.SetCounter(0);                                  //reset the counter

                                //rdrObj.SetProcessing(true);
                                //rdrObj.SetCmdSent(false);
                                rdrStatusList.Add(rdrObj2);

                                //@@ start the process to close and open socket
                                //@@ this process will handle in NetRdrReconn module
                                //if (StartReconnProcessHandler != null)
                                //StartReconnProcessHandler(readerEvent);

                                return(true);
                            }
                            else                             //increment
                            {
                                Console.WriteLine("NetRdrConn - ProcessRdrError - reader #" + Convert.ToString(readerEvent.reader) + " Incrementing rdrObj counter");
                                //increment counter to be used in polling timer to call EnableReader()
                                rdrObj2.SetCounter(Convert.ToUInt16(rdrObj.GetCounter() + 1));                                  //reset the counter
                                rdrObj2.SetProcessing(true);
                                rdrObj2.online = false;
                                //rdrStatusList.RemoveAt(i);  //new removed
                                rdrStatusList.Remove(rdrObj);
                                if (rdrObj.GetCounter() == 0)
                                {
                                    rdrObj2.SetStartTimeSec(DateTime.Now);
                                }
                                rdrStatusList.Add(rdrObj2);
                            }                    //incremet
                        }                        //NO_RESPONSE
                        else if (errorID == AW_API_NET.APIConsts.BUSY)
                        {
                            //Reader is busy servicing other command and is busy and
                            //did not process the EnableReader() command.
                            //may need to put some more code in here
                            Console.WriteLine("NetRdrConn - ProcessRdrError - reader #" + Convert.ToString(readerEvent.reader) + " is BUSY");
                        }
                    }            //if reader in list
                }                //for loop

                return(false);   //no counter not maxed
            }
        }
示例#10
0
        void ErrorEventNotify(AW_API_NET.rfReaderEvent_t readerEvent)
        {
            //lock(myLock)
            {
                if (readerEvent.eventType == AW_API_NET.APIConsts.RF_READER_ENABLE)
                {
                    //if NOT_RESPONDING .....
                    //if RESDER BUSY .....
                    if (readerEvent.errorStatus == AW_API_NET.APIConsts.RF_E_NO_RESPONSE)
                    {
                        //find the status of that rdr from reader array
                        //readerStatStruct readerObj = new readerStatStruct(readerEvent.reader);
                        if (ProcessRdrError(readerEvent, AW_API_NET.APIConsts.RF_E_NO_RESPONSE))
                        {
                            //int ret = communication.EnableReader(rdrStat.rdrID, rdrStat.hostID);
                            //if (ret < 0) //some error took place will not go to the error notification process it here
                            //{

                            Console.WriteLine("NetRdrConn   OnErrorNotify Counter = MAX for NO_RESPONSE Notification. Rdr=" + Convert.ToString(readerEvent.reader));

                            // 1 - send offline event to the app
                            // 2 - closesocket(ip)
                            // 3 - send scanNetwork(ip)

                            //if (ReaderOfflineEventHandler != null)
                            //ReaderOfflineEventHandler(readerEvent);

                            string ip;
                            if ((ip = GetStringIP(readerEvent.ip)) == "")
                            {
                                Console.WriteLine("NetRdrConn  Invalid ip address");
                                return;
                            }

                            readerStatStruct readerObj = new readerStatStruct(readerEvent.reader);
                            if (GetRdrFromList(ip, ref readerObj))
                            {
                                DateTime timeNow;
                                int      tSecNow;
                                int      sTime;
                                if (readerObj.GetProcessing() || !readerObj.online)
                                {
                                    timeNow = DateTime.Now;
                                    tSecNow = timeNow.Hour * 3600 + timeNow.Minute * 60 + timeNow.Second;
                                    Console.WriteLine("NetRdrConn  OnErrorNotify startTime= " + DateTime.Now.ToString());
                                    sTime = readerObj.GetStartTimeSec() + 3;

                                    /*if (sTime < tSecNow)
                                     * {
                                     *      Console.WriteLine("NetRdrConn  OnErrorNotify Time NOT EXPIRED. startTime=" + Convert.ToString(sTime) + " TimeNow=" + Convert.ToString(tSecNow));
                                     *      return;
                                     * }
                                     * else*/
                                    {
                                        //Console.WriteLine("NetRdrConn  OnErrorNotify Time EXPIRED. startTime=" + Convert.ToString(sTime) + " TimeNow=" + Convert.ToString(tSecNow));

                                        readerStatStruct newRdrObj = new readerStatStruct(readerEvent.reader);
                                        newRdrObj.SetIP(ip);
                                        newRdrObj.hostID = readerObj.hostID;
                                        newRdrObj.online = false;
                                        newRdrObj.SetStatus(0);
                                        newRdrObj.SetCounter(0);
                                        newRdrObj.SetProcessing(true);
                                        newRdrObj.SetStartTimeSec(DateTime.Now);
                                        rdrStatusList.Remove(readerObj);
                                        rdrStatusList.Add(newRdrObj);
                                    }
                                }                                 //if (readerObj.GetProcessing() || !readerObj.online)

                                /*else
                                 * {
                                 *      Console.WriteLine("NetRdrConn  OnErrorNotify - First Time reader #" + Convert.ToString(readerEvent.reader) + "offline");
                                 *      readerStatStruct newRdrObj = new readerStatStruct(readerEvent.reader);
                                 *      newRdrObj.SetIP(ip);
                                 *      newRdrObj.hostID = readerEvent.host;
                                 *      newRdrObj.online = false;
                                 *      newRdrObj.SetStatus(0);
                                 *      newRdrObj.SetCounter(0);
                                 *      newRdrObj.SetProcessing(true);
                                 *      newRdrObj.SetStartTimeSec(DateTime.Now);
                                 *      rdrStatusList.Remove(readerObj);
                                 *      rdrStatusList.Add(newRdrObj);
                                 * }*/
                            }                            //if (GetRdrFromList(ip
                            else
                            {
                                Console.WriteLine("NetRdrConn  Could not find reader in rdrStatusList");
                            }

                            Console.WriteLine("NetRdrConn  OnPollRdr Send OFFLINE Event for rdr=" + Convert.ToString(readerEvent.reader));
                            if (ReaderOfflineEventHandler != null)
                            {
                                ReaderOfflineEventHandler(readerEvent);
                            }

                            Console.WriteLine("NetRdrConn  SocketDisconnection() called for ip = " + ip);
                            int ret = communication.SocketDisconnection(readerEvent.ip);

                            Thread.Sleep(300);

                            Console.WriteLine("NetRdrConn  ScanNetwork() called for ip = " + ip);
                            ret = communication.ScanNetwork(readerEvent.ip);
                        }                        //ProcessRdrError
                                                 //else
                                                 //{
                        //if (ReaderOfflineEventHandler != null)
                        //ReaderOfflineEventHandler(readerEvent);
                        //}
                    }            //NO_RESPONSE
                }                //ENABLE_READER
            }

            //need to set an event in NetRdrReconnClass to process reconn to socket
            //check to see if this event already setup for the module
            //call the event with ip included
        }