private void OnSearchReaderTimer(object source, ElapsedEventArgs e) { lock (myLock) { if (startSearch) { if (srchIndex >= rdrStatusList.Count) { if (counter >= MAX_TRY) { startSearch = false; srchIndex = 0; ProcessSrchList(); return; } srchIndex = 0; counter += 1; } readerStatStruct rdrStat = new readerStatStruct(0); //create an readerStatStruct object with temp rdr id for (int n = srchIndex; n < rdrStatusList.Count; n++) { rdrStat = (readerStatStruct)rdrStatusList[n]; if (rdrStat.GetSearchReader()) { if (rdrStat.GetCounter() < MAX_TRY) { if (!rdrStat.GetSrchStatus()) //tagFound { Console.WriteLine("OnSearchTimer(TagSearchClass) send Query Cmd time:" + DateTime.Now.ToString()); int ret = communication.QueryTag(rdrStat.rdrID, srchTagID, "AST"); return; } } } srchIndex += 1; } } //if (startSearch) } //lock }
public void SetRdrPolling(string ip, bool b) { //lock(myLock) { readerStatStruct rdrStatObj = new readerStatStruct(0); if (GetRdrFromList(ip, ref rdrStatObj)) { readerStatStruct rdrStatObj1 = new readerStatStruct(0); rdrStatObj1.rdrID = rdrStatObj.rdrID; rdrStatObj1.hostID = rdrStatObj.hostID; rdrStatObj1.SetCounter(rdrStatObj.GetCounter()); rdrStatObj1.SetPollReader(false); rdrStatObj1.online = rdrStatObj.online; rdrStatObj1.SetProcessing(rdrStatObj.GetProcessing()); rdrStatObj1.SetStatus(rdrStatObj.GetStatus()); rdrStatObj1.SetStartTimeSec(rdrStatObj.GetStartTimeSec()); rdrStatObj1.SetIP(rdrStatObj.GetIP()); rdrStatusList.Remove(rdrStatObj); rdrStatusList.Add(rdrStatObj1); } } //lock }
//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 } }