• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetNext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetNext函数的典型用法代码示例。如果您正苦于以下问题:C++ GetNext函数的具体用法?C++ GetNext怎么用?C++ GetNext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetNext函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Optimise_Plc

void Optimise_Plc(PLC *plc)
{
	TAG *btag=NULL; // Base Tag for optimized Packet
	PACKET *packet=NULL;
	int bfindex=0,findex=0,bfunc=0,func=0;
	int MaxRealPacketSize=50;
	int MaxEltByPacket=MaxRealPacketSize;

	TrieChListe(&(plc->Tags),&compare_plc);
	LISTE *tags=&(plc->Tags);
	LISTE *packets=&(plc->Packets);
	Log(LOG_DEBUG,"Optimise Plc: %s (%d Tags)\n",plc->PlcName,tags->Count);
	ELEMENT *elt=GetFirst(tags);
	while (elt!=NULL)
	{
		if (btag==NULL)
		{
			btag=elt->Data;
			bfindex=_MBGetC_F_Index(btag->Address);
			//bfunc=_MBGetC_F_Index(btag->Address);
			bfunc=FTable[bfindex].Read_Function;
			elt=GetNext(tags,elt);
			continue;
		} else
		{
			TAG *tag=elt->Data;
			findex=_MBGetC_F_Index(btag->Address);
			//func=_MBGetC_F_Index(tag->Address);
			func=FTable[findex].Read_Function;
			if ((bfunc==func)&&(_MBGetAddress(btag->Address)+MaxEltByPacket>=_MBGetAddress(tag->Address)))
			{
				if (packet==NULL) // create a new packet
				{
					packet=malloc(sizeof(PACKET));
					if (packet!=NULL) // new packet
					{
						AddChListe(packets,packet);
						memset(packet,0,sizeof(PACKET));
						AddPacket(packet,btag); // base tag
						memcpy(packet->BaseAddress,btag->Address,sizeof(packet->BaseAddress));
						RemoveChListe(tags,btag);
					} else Log(LOG_CRIT,"Optimise_Plc : Unable to allocate memory: %s\n",strerror(errno));
				};
				if (packet!=NULL) // add to actual packet
				{
					AddPacket(packet,tag);
					tag->Index=_MBGetAddress(tag->Address)-_MBGetAddress(btag->Address);//-1;
					elt=GetNext(tags,elt);
					RemoveChListe(tags,tag);
					packet->NumElt=_MBGetAddress(tag->Address)-_MBGetAddress(btag->Address)+_MBGetDataSize(FTable[findex].DataType);
					continue;
				}
			} else
			{
				btag=NULL; // if not, there is no possibility of optimization
				packet=NULL;
				continue;
			}
			elt=GetNext(tags,elt);
		}
	}
}
开发者ID:Felipeasg,项目名称:TuxPLC,代码行数:62,代码来源:TuxMdb.c


示例2: GetNext

bool TrackList::CanMoveDown(Track * t) const
{
   return GetNext(t, true) != NULL;
}
开发者ID:SteveDaulton,项目名称:audacity,代码行数:4,代码来源:Track.cpp


示例3: wxCHECK_MSG

size_t wxDir::Traverse(wxDirTraverser& sink,
                       const wxString& filespec,
                       int flags) const
{
    wxCHECK_MSG( IsOpened(), (size_t)-1,
                 wxT("dir must be opened before traversing it") );

    // the total number of files found
    size_t nFiles = 0;

    // the name of this dir with path delimiter at the end
    wxString prefix = GetName();
    prefix += wxFILE_SEP_PATH;

    // first, recurse into subdirs
    if ( flags & wxDIR_DIRS )
    {
        wxString dirname;
        for ( bool cont = GetFirst(&dirname, wxEmptyString, wxDIR_DIRS | (flags & wxDIR_HIDDEN) );
              cont;
              cont = cont && GetNext(&dirname) )
        {
            const wxString fulldirname = prefix + dirname;

            switch ( sink.OnDir(fulldirname) )
            {
                default:
                    wxFAIL_MSG(wxT("unexpected OnDir() return value") );
                    // fall through

                case wxDIR_STOP:
                    cont = false;
                    break;

                case wxDIR_CONTINUE:
                    {
                        wxDir subdir;

                        // don't give the error messages for the directories
                        // which we can't open: there can be all sorts of good
                        // reason for this (e.g. insufficient privileges) and
                        // this shouldn't be treated as an error -- instead
                        // let the user code decide what to do
                        bool ok;
                        do
                        {
                            wxLogNull noLog;
                            ok = subdir.Open(fulldirname);
                            if ( !ok )
                            {
                                // ask the user code what to do
                                bool tryagain;
                                switch ( sink.OnOpenError(fulldirname) )
                                {
                                    default:
                                        wxFAIL_MSG(wxT("unexpected OnOpenError() return value") );
                                        // fall through

                                    case wxDIR_STOP:
                                        cont = false;
                                        // fall through

                                    case wxDIR_IGNORE:
                                        tryagain = false;
                                        break;

                                    case wxDIR_CONTINUE:
                                        tryagain = true;
                                }

                                if ( !tryagain )
                                    break;
                            }
                        }
                        while ( !ok );

                        if ( ok )
                        {
                            nFiles += subdir.Traverse(sink, filespec, flags);
                        }
                    }
                    break;

                case wxDIR_IGNORE:
                    // nothing to do
                    ;
            }
        }
    }

    // now enum our own files
    if ( flags & wxDIR_FILES )
    {
        flags &= ~wxDIR_DIRS;

        wxString filename;
        bool cont = GetFirst(&filename, filespec, flags);
        while ( cont )
        {
            wxDirTraverseResult res = sink.OnFile(prefix + filename);
//.........这里部分代码省略.........
开发者ID:DumaGit,项目名称:winsparkle,代码行数:101,代码来源:dircmn.cpp


示例4: GetHeadPosition

void NEPointerList::OnDraw( VGDevice & hdc ) const
{
	//GRNotationElement* e;
	GuidoPos pos = GetHeadPosition();
	while(pos) GetNext(pos)->OnDraw(hdc);
}
开发者ID:EQ4,项目名称:guido-engine,代码行数:6,代码来源:NEPointerList.cpp


示例5: while

void NEPointerList::setPosition(const NVPoint & newPosition)
{
	GuidoPos pos=GetHeadPosition();
	while(pos) GetNext(pos)->setPosition(newPosition);
}
开发者ID:EQ4,项目名称:guido-engine,代码行数:5,代码来源:NEPointerList.cpp


示例6: GetScoredDistance

double
TaskLeg::ScanDistanceScored(const GeoPoint &ref) const
{
  return GetScoredDistance(ref) +
    (GetNext() ? GetNext()->ScanDistanceScored(ref) : 0);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:6,代码来源:TaskLeg.cpp


示例7: lock

COHScriptObject *CFunctionCollection::GetFirst() {
  CSLock lock(m_critsec);
  enumerator_it = _function_map.begin();
  return GetNext();
}
开发者ID:awptimus,项目名称:openholdembot,代码行数:5,代码来源:CFunctionCollection.cpp


示例8: CheckConnection

int CheckConnection(PLC *plc)
{
	if (plc==NULL) return(0);
		
	Log(LOG_DEBUG,"Checking Connection for %s\n",plc->PlcName);
	
	Eip_Connection *new_connection=NULL;
	Eip_Connection *connection=plc->Connection;
	Eip_Session *session=plc->Session;

	if (session==NULL) return(0);
	if (connection==NULL) 
	{
		Log(LOG_DEBUG,"Connection for %s is NULL\n",plc->PlcName);
		return(BuildConnection(plc));
	}

	BYTE *path=(BYTE*)(((void*)connection)+sizeof(Eip_Connection));
	
	if (plc->NetWork)
		new_connection=_ConnectPLCOverDHP(session,
		plc->PlcType,
		_Priority,_TimeOut_Ticks,
		(int)session, //TO_ConnID,
		connection->ConnectionSerialNumber, //ConnSerialNumber
		connection->OriginatorVendorID,
		connection->OriginatorSerialNumber,
		_TimeOutMultiplier,
		MAX_SAMPLE,
		_Transport,
		plc->NetWork,
		path,
		connection->Path_size);
	else
		new_connection=_ConnectPLCOverCNET(session,
		plc->PlcType,
		_Priority,_TimeOut_Ticks,
		(int)session, //TO_ConnID,
		connection->ConnectionSerialNumber, //ConnSerialNumber
		connection->OriginatorVendorID,
		connection->OriginatorSerialNumber,
		_TimeOutMultiplier,
		MAX_SAMPLE,
		_Transport,
		path,
		connection->Path_size);
	
	//flush(session->query);
	//flush(session->reply);
	
	Log(LOG_DEBUG,"Checking Connection for %s : %s (%X/%X) -> %p\n",plc->PlcName,cip_err_msg,cip_errno,cip_ext_errno,new_connection);
	
	if (new_connection==NULL)
	{
		if ((cip_errno==0x01)&&(cip_ext_errno==0x100)) 
		{
			Log(LOG_WARNING,"Connection OK for %s\n",plc->PlcName);
			return(1); // duplicate Forward open
		}
		// error 
	}else
	{
		if (cip_errno) 
		{
			free(new_connection);
			new_connection=NULL;
		}
	};
	
	//Log(LOG_WARNING,"connection = %p\n",connection);
	
	RemoveChListe(&CONNECTIONs,connection);
	ELEMENT *elt=GetFirst(&PLCs);
	if (elt!=NULL) do
	{
		PLC *plc=elt->Data;
		if (plc->Connection==connection) plc->Connection=new_connection;
	} while ((elt=GetNext(&PLCs,elt))!=NULL);	
	
	if (new_connection!=NULL)
	{
		AddChListe(&CONNECTIONs,new_connection);
		Log(LOG_WARNING,"Connection OK for %s (%d connections)\n",plc->PlcName,CONNECTIONs.Count);
		return(1);
	}else 
	{
		Log(LOG_WARNING,"Connection Error for %s (%d connections)\n",plc->PlcName,CONNECTIONs.Count);
		return(0);
	}
}
开发者ID:Felipeasg,项目名称:TuxPLC,代码行数:90,代码来源:tuxreader.c


示例9: EthGetPacket

// Read next packet
UINT EthGetPacket(ETH *e, void **data)
{
	BLOCK *b;
	bool flag = false;
	// Validate arguments
	if (e == NULL || data == NULL)
	{
		return INFINITE;
	}
	if (e->HasFatalError)
	{
		return INFINITE;
	}

	if (e->SuAdapter != NULL)
	{
		// Read packet with SeLow
		UINT size;
		if (SuGetNextPacket(e->SuAdapter, data, &size) == false)
		{
			// Error occurred
			e->HasFatalError = true;
			return INFINITE;
		}

		return size;
	}

RETRY:
	// Check the presence of the packet in queue
	b = GetNext(e->PacketQueue);
	if (b != NULL)
	{
		UINT size;
		size = b->Size;
		*data = b->Buf;
		Free(b);

		if (e->PacketQueue->num_item == 0)
		{
			e->Empty = true;
		}

		return size;
	}

	if (e->Empty)
	{
		e->Empty = false;
		return 0;
	}

	if (flag == false)
	{
		// Try to get next packet
		PROBE_STR("EthGetPacket: PacketInitPacket");
		wp->PacketInitPacket(e->Packet, e->Buffer, e->BufferSize);
		PROBE_STR("EthGetPacket: PacketReceivePacket");
		if (wp->PacketReceivePacket(e->Adapter, e->Packet, false) == false)
		{
			// Failed
			return INFINITE;
		}
		else
		{
			UCHAR *buf;
			UINT total;
			UINT offset;

			buf = (UCHAR *)e->Packet->Buffer;
			total = e->Packet->ulBytesReceived;
			offset = 0;

			while (offset < total)
			{
				struct bpf_hdr *header;
				UINT packet_size;
				UCHAR *packet_data;

				header = (struct bpf_hdr *)(buf + offset);
				packet_size = header->bh_caplen;
				offset += header->bh_hdrlen;
				packet_data = buf + offset;
				offset = Packet_WORDALIGN(offset + packet_size);

				if (packet_size >= 14)
				{
					UCHAR *tmp;
					BLOCK *b;

					PROBE_DATA2("EthGetPacket: NewBlock", packet_data, packet_size);
					
					tmp = MallocFast(packet_size);

					Copy(tmp, packet_data, packet_size);
					b = NewBlock(tmp, packet_size, 0);
					InsertQueue(e->PacketQueue, b);
				}
			}
//.........这里部分代码省略.........
开发者ID:455475876github,项目名称:SoftEtherVPN,代码行数:101,代码来源:BridgeWin32.c


示例10: while

NodeRenderableBounded *CDRArrowheadStore::GetConvertedNode(DWORD Reference, INT32 *Distance, BOOL *NotPresent)
{
	// set up the not present thingy
	*NotPresent = FALSE;
	
	// find the correct chunk
	CDRArrowheadStoredItem *Item;
	INT32 Size;

	if(IsEmpty())
		return 0;		// no items in the list
	
	Item = (CDRArrowheadStoredItem *)GetHead();

	// scan though the list looking for the reference
	while(Item != 0)
	{
		if(CDRDATA_DWORD(*((DWORD *)(Item->Block))) == Reference)
		{
			Size = Item->Size;
			break;
		}

		Item = (CDRArrowheadStoredItem *)GetNext(Item);
	}
	
	// did we find a chunk?
	if(Item == 0)
	{
		*NotPresent = TRUE;
		return 0;
	}

	// locate the coordinates
	cdrfArrowhead *Arrow = (cdrfArrowhead *)Item->Block;
	cdrfCoord *Coords = (cdrfCoord *)(Item->Block + CDRDATA_WORD(Arrow->CoordsOffset) + cdrfARROWHEAD_COORDOFF_CORRECT);

	// store the distance from the definitons
	*Distance = CDRDATA_SWORD(Arrow->Distance);

	// check to see if a cached pointer is available
	if(Item->pNode != 0)
		return Item->pNode;

	// OK, convert that arrowhead

	// this is not particularly pleasant. We need to scan though the coords creating a path,
	// each sub path must be a seperate path unless the next subpath has the same closedness
	// as the previous one, in which case it's a sub path.
	// this is because closed sub paths have different attributes to open ones. It's a nasty
	// system, and rather overcomplicated, but never mind.

	INT32 ThisType = GCN_LASTSUB_NONE;		// the type of this subpath
	INT32 LastType = GCN_LASTSUB_NONE;		// the type of the last subpath
	
	NodePath *FirstPath = 0;				// the first path in my set of paths
	NodePath *LastPath = 0;					// the last path in my set of paths
	NodePath *ThisPath = 0;					// the path I'm currently working on

	// check that the first node type is a move to avoid stuffing up my next bit
	if((Arrow->NodeTypes[0] & cdrfPATHCOORDTYPE_MASK) != cdrfPATHCOORDTYPE_MOVE)
	{
		// for now, if the first element isn't a move, pretend that it doesn't exist
		*NotPresent = TRUE;
		return 0;
	}

	INT32 CoordType;

	INT32 l;
	
	UINT32 Control1 = 0;		// number of first control point
	UINT32 Control2 = 0;		// of second
	DocCoord co, cn1, cn2;	// coordinates
	PathFlags Flags;

	INT32 NNodes = CDRDATA_WORD(Arrow->NNodes);
	BOOL NeedMoveTo = TRUE;

	// convert all the coordinates
	for(l = 0; l < NNodes; l++)
	{
		CoordType = Arrow->NodeTypes[l] & cdrfPATHCOORDTYPE_MASK;

		if(CoordType == cdrfPATHCOORDTYPE_MOVE || l == 0)
		{
			// start a new path!
			LastType = ThisType;

			// first of all, what type of path is this?
			if((Arrow->NodeTypes[l] & cdrfPATHCOORDATTR_CLOSE) != 0)
				ThisType = GCN_LASTSUB_CLOSED;
			else
				ThisType = GCN_LASTSUB_OPEN;

			// OK, do we need to start a new path?
			if(ThisType != LastType)
			{
				// yep, attach the last one we did
				if(ThisPath != 0)
//.........这里部分代码省略.........
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:101,代码来源:cdroutl.cpp


示例11: mainprog


//.........这里部分代码省略.........
					{
						Log(LOG_INFO,"Connexion d'un client depuis %s (socket : %d)\n", inet_ntoa(sonadr.sin_addr),fd);
						SetCoe(fd);
						client=malloc(sizeof(CLIENT));
						if (client!=NULL)
						{
							if (AddChListe(&CLIENTs,client)>0)
							{ /* ajout du client dans les socket à surveiller */
								memset(client,0,sizeof(CLIENT));
								client->FD=fd;
								FD_SET(fd, &fd_clients); 
								fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL, 0));
								Log(LOG_INFO,"Client connecté depuis %s (socket : %d)\n", inet_ntoa(sonadr.sin_addr),fd);
							} else 
							{
								close(fd);
								Log(LOG_CRIT, "Erreur à l'ajout du client (%s)\n",strerror(errno));
							}
						} else 
						{
							close(fd);
							Log(LOG_WARNING, "Erreur à la création du client (%s)\n",strerror(errno));
						}
					}
				}
				/* Tester si les sockets clientes ont bougées */
				for(fd=0; fd<nfds; fd++ )
				{
					if((fd != Server) && FD_ISSET(fd, &rfds))
					{
						/* Recherche du client */
						client=FindClient(fd,&CLIENTs);
						if (client==NULL)
						{
							Log(LOG_WARNING, "Client inconnu !!! (socket : %d)--\n",fd);
							close(fd);
							FD_CLR(fd, &fd_clients);
							Reply(fd,"Erreur interne (line : %d)\n",__LINE__);
							continue;
						}
						switch (lire_client(client))
						{
							case 0:
								RemoveChListe(&CLIENTs,client);
								free(client);
								close(fd);
								FD_CLR(fd, &fd_clients);
								Log(LOG_INFO, "-- perte d'un client ! (socket : %d)--\n",fd);
								continue;
							default:/* Traitement requete */
								Log(LOG_DEBUG,"<-Client : %p (buffersize : %d)\n",client,client->InBuffer.size);
								Traite(client);
								continue;
						}
					}
				}
				break;
		} 
		/* Checking Tag inactivity */
		if (TAGs.Count>0)
		{
			time_t now=time(NULL);
			ELEMENT *elt=GetFirst(&TAGs);
			if (elt!=NULL) do
			{
				TAG *tag=elt->Data;
				if ((now-tag->Time_Value)>INACTIVITY_TO)
				{
					ELEMENT *elt_old=elt;
					Log(LOG_DEBUG,"\t-Deleting Tag %s on %s (%p / %p)\n",tag->TagName,tag->Plc->PlcName,tag,elt);
					elt=GetNext(&TAGs,elt);
					RemoveChListe_Ex(&TAGs,elt_old);
					free(elt_old);
					if (tag->Plc!=NULL) 
					{
						tag->Plc->References--;
						if (tag->Plc->References<=0)
						{
							Log(LOG_DEBUG,"No more Tag on plc : %s\n",tag->Plc->PlcName);
							DisconnectPlc(tag->Plc);
						}
					}
					free(tag);
					continue;
				}
			} while ((elt=GetNext(&TAGs,elt))!=NULL);
		}
	}	
	close(Server);
	Log(LOG_DEBUG,"Killing all connections\n");
	KillConnections();
	Log(LOG_DEBUG,"Closing list TAGs : %d counts\n",TAGs.Count);
	CloseList(&TAGs);
	Log(LOG_DEBUG,"Closing list PLCs : %d counts\n",PLCs.Count);
	CloseList(&PLCs);
	Log(LOG_DEBUG,"Closing list CLIENTs : %d counts\n",CLIENTs.Count);
	
	CloseList(&CLIENTs);
	return(0);
}
开发者ID:Felipeasg,项目名称:TuxPLC,代码行数:101,代码来源:tuxreader.c


示例12: switch

int RichEditBkImg::PositionItem2Value(const POSITION_ITEM &pos ,int nMin, int nMax,BOOL bX)
{
    int nRet=0;

    switch(pos.pit)
    {
    case PIT_NORMAL: 
        if(pos.cMinus == -1)
            nRet=nMax-(int)pos.nPos;
        else
            nRet=nMin+(int)pos.nPos;
        break;

    case PIT_PREV_NEAR: //“[”相对于前一兄弟窗口。用于X时,参考前一兄弟窗口的right,用于Y时参考前一兄弟窗口的bottom
    case PIT_PREV_FAR:  //“{”相对于前一兄弟窗口。用于X时,参考前一兄弟窗口的left,用于Y时参考前一兄弟窗口的top
        {
            CRect rcRef;
            RichEditObj *pRefObj=GetPrev();
            if(pRefObj)
            {
                rcRef = pRefObj->GetRect();
            }else
            {
                rcRef=m_pObjectHost->GetAdjustedRect();
                rcRef.right = rcRef.left;
                rcRef.bottom = rcRef.top;
            }
            if(bX)
            {
                LONG refPos = (pos.pit == PIT_PREV_NEAR)?rcRef.right:rcRef.left;
                nRet=refPos+(int)pos.nPos*pos.cMinus;
            }else
            {
                LONG refPos = (pos.pit == PIT_PREV_NEAR)?rcRef.bottom:rcRef.top;
                nRet=refPos+(int)pos.nPos*pos.cMinus;
            }
        }
        break;

    case PIT_NEXT_NEAR: //“]”相对于后一兄弟窗口。用于X时,参考后一兄弟的left,用于Y时参考后一兄弟的top
    case PIT_NEXT_FAR:  //“}”相对于后一兄弟窗口。用于X时,参考后一兄弟的right,用于Y时参考后一兄弟的bottom
        {
            CRect rcRef;
            RichEditObj *pRefObj = GetNext();
            if(pRefObj)
            {
                rcRef = pRefObj->GetRect();
            }else
            {
                rcRef = m_pObjectHost->GetAdjustedRect();
                rcRef.left = rcRef.right;
                rcRef.top = rcRef.bottom;
            }

            if(bX)
            {
                LONG refPos = (pos.pit == PIT_NEXT_NEAR)?rcRef.left:rcRef.right;
                nRet=refPos+(int)pos.nPos*pos.cMinus;
            }else
            {
                LONG refPos = (pos.pit == PIT_NEXT_NEAR)?rcRef.top:rcRef.bottom;
                nRet=refPos+(int)pos.nPos*pos.cMinus;
            }
        }
        break;
    }

    return nRet;
}
开发者ID:435420057,项目名称:soui,代码行数:69,代码来源:RichEditObj.cpp


示例13: UsageError

  const char *ExpectNext() {
    if (IsEmpty())
      UsageError();

    return GetNext();
  }
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:6,代码来源:Args.hpp


示例14: Logger

int Logger(LISTE *plcs)
{
	int res=0,Comm_err=0,Read_Something=0;
	if (TEST)
	{
		ListePlc(plcs);
		//return(0);
	}
	int now=time(NULL);
	res=BuildSockets(plcs);
	while (!Terminated)
	{
		ELEMENT *elt=GetFirst(plcs);
		while (elt!=NULL)  // PLCs
		{
			PLC *plc=elt->Data;
			/* Something to do ? */
			if (plc->Next_Time>time(NULL))
			{
				elt=GetNext(plcs,elt);			
				continue;
			}
			/* Test Socket */
			if (plc->socket<0)
			{
				if (BuildSocket(plc)<0)
				{
					Log(LOG_WARNING,"Socket unavailable for : %s\n",plc->PlcName);
					plc->Next_Time=now+WAIT_FOR_RECONNECT;
					elt=GetNext(plcs,elt);
					continue;
				} else Log(LOG_INFO,"Socket build for : %s\n",plc->PlcName);
			}
			now=time(NULL);
			Read_Something=0;
			Comm_err=1;
			//plc->Next_Time=now+0.95*MAX_SAMPLE/1000;
			plc->Next_Time=now+MAX_SAMPLE;
			Log(LOG_DEBUG,"Set plc->Next_Time in %d seconds (MAX_SAMPLE : %d)\n",plc->Next_Time-now,MAX_SAMPLE);
			/* Read Tags */
			ELEMENT *elt2=GetFirst(&(plc->Tags));
			while (elt2!=NULL)
			{
				TAG *tag=elt2->Data;
				if ((now-tag->Time_Value)>(1.5*tag->Time_Sample))
					Log(LOG_WARNING,"Time Sample exceed on tag : %s (%s)\n",tag->TagName,plc->PlcName);
				if ((now-tag->Time_Value)>=tag->Time_Sample)
				{
					//Log(LOG_DEBUG,"Reading tag : %s (%s) (%d - %d > %d)\n",tag->TagName,plc->PlcName,now,tag->Time_Value,tag->Time_Sample);
					Read_Something=1;
					res=ReadTag(plc,tag);
					if (res==0) Comm_err=0; // At least one tag is Ok
					if (mb_errno==EPIPE) CloseSocket(plc->socket,plcs);
				}
				if ((tag->Time_Value+tag->Time_Sample)<(plc->Next_Time))
				{
					plc->Next_Time=tag->Time_Value+tag->Time_Sample;
					Log(LOG_DEBUG,"plc->Next_Time in %d seconds*\n",plc->Next_Time-now);
				}
				elt2=GetNext(&(plc->Tags),elt2);
			}
			/* Read Packets */
			elt2=GetFirst(&(plc->Packets));
			while (elt2!=NULL)
			{
				PACKET *packet=elt2->Data;
				if ((now-packet->Time_Value)>(1.5*packet->Time_Sample))
					Log(LOG_WARNING,"Time Sample exceed on packet : %s (%s)\n",packet->BaseAddress,plc->PlcName);
				if ((now-packet->Time_Value)>=packet->Time_Sample)
				{
					Read_Something=1;
					res=ReadPacket(plc,packet);
					if (res>=0) Comm_err=0; // At least one tag is Ok
					if (mb_errno==EPIPE) CloseSocket(plc->socket,plcs);
				}
				if ((packet->Time_Value+packet->Time_Sample)<(plc->Next_Time))
				{
					plc->Next_Time=packet->Time_Value+packet->Time_Sample;
					Log(LOG_DEBUG,"plc->Next_Time in %d seconds\n",plc->Next_Time-now);
				}
				elt2=GetNext(&(plc->Packets),elt2);
			}
			/* Check Plc */
			if (Comm_err && Read_Something) // All Tags & packets are in error
			{
				Log(LOG_WARNING,"All tags in error for : %s suspending for %d seconds\n",plc->PlcName,WAIT_FOR_RECONNECT);
				plc->Next_Time=now+WAIT_FOR_RECONNECT;
			}
			if (plc->Next_Time>0.8*(time(NULL)+MODBUS_SOCK_TIMEOUT))
			{
				close(plc->socket);
				plc->socket=-1;
				Log(LOG_DEBUG,"Closing socket for plc : %s \n",plc->PlcName);
			}			
			elt=GetNext(plcs,elt);
		}
		sleep(1);
	}
	Log(LOG_NOTICE,"Killing Connections\n");
	KillAll(plcs);
//.........这里部分代码省略.........
开发者ID:Felipeasg,项目名称:TuxPLC,代码行数:101,代码来源:TuxMdb.c


示例15: GetMinimumLegDistance

double
TaskLeg::ScanDistanceMin() const
{
  return GetMinimumLegDistance() +
    (GetNext() ? GetNext()->ScanDistanceMin() : 0);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:6,代码来源:TaskLeg.cpp


示例16: GetNext

XMLElement XMLElement::GetNext(const String& name) const
{
    return GetNext(name.CString());
}
开发者ID:zhzhxtrrk,项目名称:Urho3D,代码行数:4,代码来源:XMLElement.cpp


示例17: GetNominalLegDistance

double
TaskLeg::ScanDistanceNominal() const
{
  return GetNominalLegDistance() +
    (GetNext() ? GetNext()->ScanDistanceNominal() : 0);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:6,代码来源:TaskLeg.cpp


示例18: clearFixtures

void Body::clearFixtures()
{
    for (auto f = getBody().GetFixtureList(); f; f = f->GetNext()) {
        getBody().DestroyFixture(f);
    }
}
开发者ID:vanhung1087,项目名称:avalon,代码行数:6,代码来源:Body.cpp


示例19: CloseEth

// Close Ethernet adapter
void CloseEth(ETH *e)
{
	// Validate arguments
	if (e == NULL)
	{
		return;
	}

	if (e->Tap != NULL)
	{
#ifndef	NO_VLAN
		FreeTap(e->Tap);
#endif	// NO_VLAN
	}

#ifdef BRIDGE_PCAP
	{
		struct CAPTUREBLOCK *block;
		pcap_breakloop(e->Pcap);
		WaitThread(e->CaptureThread, INFINITE);
		ReleaseThread(e->CaptureThread);
		pcap_close(e->Pcap);
		while (block = GetNext(e->Queue)){
			Free(block->Buf);
			FreeCaptureBlock(block);
		}
		ReleaseQueue(e->Queue);
	}
#endif // BRIDGE_PCAP

#ifdef BRIDGE_BPF
#ifdef BRIDGE_BPF_THREAD
	{
		struct CAPTUREBLOCK *block;
		int fd = e->Socket;
		e->Socket = INVALID_SOCKET;
		WaitThread(e->CaptureThread, INFINITE);
		ReleaseThread(e->CaptureThread);
		e->Socket = fd; // restore to close after
		while (block = GetNext(e->Queue)){
			Free(block->Buf);
			FreeCaptureBlock(block);
		}
		ReleaseQueue(e->Queue);
	}
#else // BRIDGE_BPF_THREAD
	Free(e->Buffer);
#endif // BRIDGE_BPF_THREAD
#endif // BRIDGE_BPF

	ReleaseCancel(e->Cancel);
	Free(e->Name);
	Free(e->Title);

	// Restore MTU value
	EthSetMtu(e, 0);

	if (e->Socket != INVALID_SOCKET)
	{
#if defined(BRIDGE_BPF) || defined(BRIDGE_PCAP) || defined(UNIX_SOLARIS)
		close(e->Socket);
#else // BRIDGE_PCAP
		closesocket(e->Socket);
#endif // BRIDGE_PCAP
#if defined(BRIDGE_BPF) || defined(UNIX_SOLARIS)
		if (e->SocketBsdIf != INVALID_SOCKET)
		{
			close(e->SocketBsdIf);
		}
#endif	// BRIDGE_BPF || UNIX_SOLARIS
	}

	Free(e);
}
开发者ID:455475876github,项目名称:SoftEtherVPN,代码行数:75,代码来源:BridgeUnix.c


示例20: ReadDataDistanceMatrix

/*{{{  data*/
void ReadDataDistanceMatrix(value** points, FILE* inputFile, int k) {
	List tempList;

	size_t lineSize = 0;

	char* lineBuff = NULL;
	char* temp;
	char delims[5] = "\t ,\n";
	char* token = NULL;
	int num = 0;
	int i;
	int line = 0;

	dm = malloc(sizeof(datadistanceMatrix));
	dm->data=NULL;
	dm->dataDist=NULL;
	dm->dataNum=0;
	dm->queries=NULL;
	dm->iterator=0;
	dm->queryDist=NULL;
	dm->queryNum=0;
	dm->qIterator=0;
	dm->k = k;
	getline(&lineBuff, &lineSize, inputFile);
	/*skip the first value*/
	token = strtok(lineBuff, delims);

	InitList(&tempList, BUFFSIZE * sizeof(char), NULL, NULL,NULL);
	
	while (token != NULL) {
		token = strtok(NULL, delims);
		if (token == NULL)
			break;
		temp = malloc((LABELSIZE + 1) * sizeof(char));
		memcpy(temp, token, strlen(token));
		temp[strlen(token)] = '\0';
		InsertValueList(tempList, temp);
		num++;
		free(temp);
	}

	SetDataSize(num);
	*points = malloc(num*sizeof(value));
	value* newData = *points;

	char* tempVal = GetFirst(tempList);
	for (i = 0; i < num; i++) {
		newData[i].name = malloc(LABELSIZE * sizeof(char));
		memset(newData[i].name,'\0',LABELSIZE);
		if(tempVal ==NULL)
			continue;
		strcpy(newData[i].name, tempVal);
		tempVal=GetNext(tempList);
	}

	dm->dataDist = malloc(num * sizeof(double*));
	while (getline(&lineBuff, &lineSize, inputFile) != -1) {

		dm->dataDist[line] = malloc(num * sizeof(double));
		newData[line].content=malloc(sizeof(int));
		memcpy(newData[line].content,&line,sizeof(int));


		token = strtok(lineBuff, delims);
		if (token == NULL)
			break;
		for (i = 0; i < num; i++) {
			dm->dataDist[line][i] = atoi(token);
			token = strtok(NULL, delims);
		}
		line++;
	}
	dm->dataNum=line;
	data.tableSize = dm->dataNum;
	DestroyList(&tempList);

	free(lineBuff);


}
开发者ID:sergafts,项目名称:softdevalg,代码行数:81,代码来源:dataDistanceMatrix.c



注:本文中的GetNext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetNextAttackDelay函数代码示例发布时间:2022-05-30
下一篇:
C++ GetNetwork函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap