예제 #1
0
NIDAQDevice::NIDAQDevice(const ParameterValueMap &parameters) :
    IODevice(parameters),
    deviceName(parameters[NAME].str()),
    requestSemName(generateUniqueID()),
    responseSemName(generateUniqueID()),
    controlChannel(boost::interprocess::create_only, requestSemName, responseSemName),
    sharedMemoryName(generateUniqueID()),
    sharedMemory(boost::interprocess::create_only, sharedMemoryName),
    controlMessage(NULL),
    helperPID(-1),
    updateInterval(parameters[UPDATE_INTERVAL]),
    analogInputDataInterval(parameters[ANALOG_INPUT_DATA_INTERVAL]),
    analogReadTimeout(updateInterval),
    assumeMultiplexedADC(parameters[ASSUME_MULTIPLEXED_ADC]),
    analogInputSampleBufferSize(0),
    analogInputTaskRunning(false),
    analogOutputDataInterval(parameters[ANALOG_OUTPUT_DATA_INTERVAL]),
    analogOutputSampleBufferSize(0),
    analogOutputEnabled(parameters[ANALOG_OUTPUT_ENABLED]),
    analogOutputTaskRunning(false),
    digitalInputSampleBufferSize(0),
    digitalInputTaskRunning(false),
    digitalOutputSampleBufferSize(0),
    digitalOutputTasksRunning(false),
    counterInputCountEdgesTasksRunning(false)
{
    if (updateInterval <= 0) {
        throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid update interval");
    }
    
    if (analogInputDataInterval <= 0) {
        throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid analog input data interval");
    }
    if (updateInterval % analogInputDataInterval != 0) {
        throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN,
                              "Update interval must be an integer multiple of analog input data interval");
    }
    
    if (!(parameters[ANALOG_READ_TIMEOUT].empty())) {
        analogReadTimeout = MWTime(parameters[ANALOG_READ_TIMEOUT]);
        if (analogReadTimeout < 0) {
            throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid analog read timeout");
        }
    }
    
    if (analogOutputDataInterval <= 0) {
        throw SimpleException(M_IODEVICE_MESSAGE_DOMAIN, "Invalid analog output data interval");
    }
}
예제 #2
0
파일: VyToken.c 프로젝트: mueschm/Vyper
//Generate a token based off of a user and the requested server
char* generateToken(mongo* conn, const char* userID, const char* serverID)
{
	bson token[1];
	
	//Generate a unique id for the token
	uuid_t* tokenUID = generateUniqueID();
	char* tokenID = printUniqueID(tokenUID);
	free(tokenUID);
	
	//Create a bson with the username server id and unique token id
	bson_init(token);
	bson_append_string(token, "_id", tokenID);
	bson_append_string(token, "username", userID);
	bson_append_string(token, "server", serverID);
	bson_finish(token);
	
	VyLog(5,"Created token for user ",userID," for server ",serverID,"\r\n");
	
	//Insert the token into the server
	if(mongoInsertData(conn,TOKEN_COLLECTION,token) == 1)
		return tokenID;
	
	//If no token could be returned destroy it and say so
	bson_destroy(token);
	
	return "NO Valid Token";
}
예제 #3
0
파일: tcsip.cpp 프로젝트: sipper123/sip2
void CreateSessionData(char * user_at_host)
{
  char myhost[MAX_STR_LEN]={0};
  char username[MAX_STR_LEN]={0};

  gethostname(myhost, MAX_STR_LEN);
  cuserid(username);
  generateUniqueID();

  sprintf(g_SessionData.uri, "sip:%s", user_at_host);
  sprintf(g_SessionData.CallID, "%s@%s", g_UniqueID, myhost);
  sprintf(g_SessionData.MyHost, "%s", myhost);
  sprintf(g_SessionData.From, "%s", username, myhost);
  sprintf(g_SessionData.FromAdrs, "%s@%s", username, myhost);
  sprintf(g_SessionData.ToAdrs, "%s", user_at_host);
  sprintf(g_SessionData.To, "%s", strsep(&user_at_host, "@"));
  sprintf(g_SessionData.RemoteHost, "%s", user_at_host);    

}
예제 #4
0
파일: VyNetwork.c 프로젝트: mueschm/Vyper
//Function to read in messages from each connection and call the corresponding callback
void messageReader(SSLParser sslParser, StandardParser standardParser, UDPParser udpParser, TimeoutFunction timeoutFunction )
{
	int size = getListSize(connNode);
	int i;
	//Loop through all active connections
	for(i = 0;i < size;i++)
	{
		VyConnNode* node = getNodeAtSpot(connNode,i)->data;
		//If it is a TCP connection make sure it is still alive
		if(node->type == TCP_CONNECTION && timeoutFunction != NULL)
		{
		  //If a great deal of time has passed with no response call the timeout function
		  if(node->lastPing++ > 100000000)
		  {
			  //timeoutFunction(node);
		  }
		  //If a short deal of time has time request a ping
		  else if(node->lastPing == 10000000)
		  {	
		      VyConn* conn = node->data;
		      uuid_t* id = generateUniqueID();
		      char* cID = printUniqueID(id);
		      free(id);
		      VyMessage* m = generateNewMessage(cID,"Ping","Request",strlen("Request")+1);
		      sendMessage(conn->socket,m);
		      destroyVyMessage(m);
		      free(cID);
		  }
		}
		VyMessage* message = NULL;
		//Attempt to read in data from the socket and parse it correctly with the assigned callbacks
		if(node->type == TCP_CONNECTION)
		{
			VyConn* conn = node->data;
			message = readMessage(conn);
			if(message != NULL)
			{
				//VyLog(1,"TCP message recieved\r\n");
				standardParser(node, message);
			}
		}
		else if(node->type == SSL_CONNECTION)
		{
			VySSL* ssl = (VySSL*)node->data;
			message = readSSLMessage(ssl);
			if(message != NULL)
			{
				//VyLog(1,"SSL message recieved\r\n");
				sslParser(node, message);
			}
		}
		else if(node->type == UDP_CONNECTION)
		{
			VyConn* conn = node->data;
			message = readUDPMessage(conn);
			if(message != NULL)
			{
				//VyLog(1,"UDP message recieved\r\n");
				udpParser(node, message);
			}
		}
		if(message != NULL)
		   destroyVyMessage(message);
	}
}
예제 #5
0
Window::Window(const int width, const int height, const int left, const int top, const std::string& title)
{
  m_ID = generateUniqueID();
}
예제 #6
0
Object::Object(){
    id = generateUniqueID();
}